2
1

grub.400-nic_update2.patch 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064
  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. Index: b/configure
  10. ===================================================================
  11. --- a/configure
  12. +++ b/configure
  13. @@ -872,47 +872,32 @@
  14. --disable-packet-retransmission
  15. turn off packet retransmission
  16. --enable-pci-direct access PCI directly instead of using BIOS
  17. - --enable-3c509 enable 3Com509 driver
  18. - --enable-3c529 enable 3Com529 driver
  19. --enable-3c595 enable 3Com595 driver
  20. --enable-3c90x enable 3Com90x driver
  21. - --enable-cs89x0 enable CS89x0 driver
  22. --enable-davicom enable Davicom driver
  23. - --enable-depca enable DEPCA and EtherWORKS driver
  24. - --enable-eepro enable Etherexpress Pro/10 driver
  25. + --enable-e1000 enable Etherexpress Pro/1000 driver
  26. --enable-eepro100 enable Etherexpress Pro/100 driver
  27. --enable-epic100 enable SMC 83c170 EPIC/100 driver
  28. - --enable-3c507 enable 3Com507 driver
  29. - --enable-exos205 enable EXOS205 driver
  30. - --enable-ni5210 enable Racal-Interlan NI5210 driver
  31. - --enable-lance enable Lance PCI PCNet/32 driver
  32. - --enable-ne2100 enable Novell NE2100 driver
  33. - --enable-ni6510 enable Racal-Interlan NI6510 driver
  34. + --enable-forcedeth enable Nvidia Geforce driver
  35. --enable-natsemi enable NatSemi DP8381x driver
  36. - --enable-ni5010 enable Racal-Interlan NI5010 driver
  37. - --enable-3c503 enable 3Com503 driver
  38. - --enable-ne enable NE1000/2000 ISA driver
  39. + --enable-ns83820 enable NS83820 driver
  40. --enable-ns8390 enable NE2000 PCI driver
  41. - --enable-wd enable WD8003/8013, SMC8216/8416 driver
  42. - --enable-otulip enable old Tulip driver
  43. + --enable-pcnet32 enable AMD Lance/PCI PCNet/32 driver
  44. + --enable-pnic enable Bochs Pseudo Nic driver
  45. --enable-rtl8139 enable Realtek 8139 driver
  46. + --enable-r8169 enable Realtek 8169 driver
  47. --enable-sis900 enable SIS 900 and SIS 7016 driver
  48. - --enable-sk-g16 enable Schneider and Koch G16 driver
  49. - --enable-smc9000 enable SMC9000 driver
  50. - --enable-tiara enable Tiara driver
  51. + --enable-tg3 enable Broadcom Tigon3 driver
  52. --enable-tulip enable Tulip driver
  53. + --enable-tlan enable TI ThunderLAN driver
  54. + --enable-undi enable PXE UNDI driver
  55. --enable-via-rhine enable Rhine-I/II driver
  56. - --enable-w89c840 enable Winbond W89c840, Compex RL100-ATX driver
  57. - --enable-3c503-shmem use 3c503 shared memory mode
  58. - --enable-3c503-aui use AUI by default on 3c503 cards
  59. + --enable-w89c840 enable Winbond W89c840 driver
  60. --enable-compex-rl2000-fix
  61. specify this if you have a Compex RL2000 PCI
  62. - --enable-smc9000-scan=LIST
  63. - probe for SMC9000 I/O addresses using LIST
  64. --enable-ne-scan=LIST probe for NE base address using LIST
  65. --enable-wd-default-mem=MEM
  66. set the default memory location for WD/SMC
  67. - --enable-cs-scan=LIST probe for CS89x0 base address using LIST
  68. --enable-diskless enable diskless support
  69. --disable-graphics disable graphics terminal support
  70. --disable-hercules disable hercules terminal support
  71. @@ -5537,7 +5522,7 @@
  72. fi;
  73. if test "x$enable_packet_retransmission" != xno; then
  74. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1"
  75. + NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1 -DCONFIG_PCI"
  76. fi
  77. # Check whether --enable-pci-direct or --disable-pci-direct was given.
  78. @@ -5549,26 +5534,6 @@
  79. NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONFIG_PCI_DIRECT=1"
  80. fi
  81. -# Check whether --enable-3c509 or --disable-3c509 was given.
  82. -if test "${enable_3c509+set}" = set; then
  83. - enableval="$enable_3c509"
  84. -
  85. -fi;
  86. -if test "x$enable_3c509" = xyes; then
  87. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C509"
  88. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c509.o"
  89. -fi
  90. -
  91. -# Check whether --enable-3c529 or --disable-3c529 was given.
  92. -if test "${enable_3c529+set}" = set; then
  93. - enableval="$enable_3c529"
  94. -
  95. -fi;
  96. -if test "x$enable_3c529" = xyes; then
  97. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C529=1"
  98. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c529.o"
  99. -fi
  100. -
  101. # Check whether --enable-3c595 or --disable-3c595 was given.
  102. if test "${enable_3c595+set}" = set; then
  103. enableval="$enable_3c595"
  104. @@ -5589,16 +5554,6 @@
  105. NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c90x.o"
  106. fi
  107. -# Check whether --enable-cs89x0 or --disable-cs89x0 was given.
  108. -if test "${enable_cs89x0+set}" = set; then
  109. - enableval="$enable_cs89x0"
  110. -
  111. -fi;
  112. -if test "x$enable_cs89x0" = xyes; then
  113. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_CS89X0=1"
  114. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS cs89x0.o"
  115. -fi
  116. -
  117. # Check whether --enable-davicom or --disable-davicom was given.
  118. if test "${enable_davicom+set}" = set; then
  119. enableval="$enable_davicom"
  120. @@ -5609,24 +5564,14 @@
  121. NETBOOT_DRIVERS="$NETBOOT_DRIVERS davicom.o"
  122. fi
  123. -# Check whether --enable-depca or --disable-depca was given.
  124. -if test "${enable_depca+set}" = set; then
  125. - enableval="$enable_depca"
  126. +# Check whether --enable-e1000 or --disable-e1000 was given.
  127. +if test "${enable_e1000+set}" = set; then
  128. + enableval="$enable_e1000"
  129. fi;
  130. -if test "x$enable_depca" = xyes; then
  131. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_DEPCA=1"
  132. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS depca.o"
  133. -fi
  134. -
  135. -# Check whether --enable-eepro or --disable-eepro was given.
  136. -if test "${enable_eepro+set}" = set; then
  137. - enableval="$enable_eepro"
  138. -
  139. -fi;
  140. -if test "x$enable_eepro" = xyes; then
  141. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_EEPRO=1"
  142. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS eepro.o"
  143. +if test "x$enable_e1000" = xyes; then
  144. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_E1000=1"
  145. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS e1000.o"
  146. fi
  147. # Check whether --enable-eepro100 or --disable-eepro100 was given.
  148. @@ -5649,64 +5594,14 @@
  149. NETBOOT_DRIVERS="$NETBOOT_DRIVERS epic100.o"
  150. fi
  151. -# Check whether --enable-3c507 or --disable-3c507 was given.
  152. -if test "${enable_3c507+set}" = set; then
  153. - enableval="$enable_3c507"
  154. -
  155. -fi;
  156. -if test "x$enable_3c507" = xyes; then
  157. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C507=1"
  158. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c507.o"
  159. -fi
  160. -
  161. -# Check whether --enable-exos205 or --disable-exos205 was given.
  162. -if test "${enable_exos205+set}" = set; then
  163. - enableval="$enable_exos205"
  164. -
  165. -fi;
  166. -if test "x$enable_exos205" = xyes; then
  167. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_EXOS205=1"
  168. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS exos205.o"
  169. -fi
  170. -
  171. -# Check whether --enable-ni5210 or --disable-ni5210 was given.
  172. -if test "${enable_ni5210+set}" = set; then
  173. - enableval="$enable_ni5210"
  174. -
  175. -fi;
  176. -if test "x$enable_ni5210" = xyes; then
  177. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI5210=1"
  178. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni5210.o"
  179. -fi
  180. -
  181. -# Check whether --enable-lance or --disable-lance was given.
  182. -if test "${enable_lance+set}" = set; then
  183. - enableval="$enable_lance"
  184. -
  185. -fi;
  186. -if test "x$enable_lance" = xyes; then
  187. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_LANCE=1"
  188. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS lance.o"
  189. -fi
  190. -
  191. -# Check whether --enable-ne2100 or --disable-ne2100 was given.
  192. -if test "${enable_ne2100+set}" = set; then
  193. - enableval="$enable_ne2100"
  194. -
  195. -fi;
  196. -if test "x$enable_ne2100" = xyes; then
  197. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NE2100=1"
  198. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ne2100.o"
  199. -fi
  200. -
  201. -# Check whether --enable-ni6510 or --disable-ni6510 was given.
  202. -if test "${enable_ni6510+set}" = set; then
  203. - enableval="$enable_ni6510"
  204. +# Check whether --enable-forcedeth or --disable-forcedeth was given.
  205. +if test "${enable_forcedeth+set}" = set; then
  206. + enableval="$enable_forcedeth"
  207. fi;
  208. -if test "x$enable_ni6510" = xyes; then
  209. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI6510=1"
  210. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni6510.o"
  211. +if test "x$enable_forcedeth" = xyes; then
  212. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_FORCEDETH=1"
  213. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS forcedeth.o"
  214. fi
  215. # Check whether --enable-natsemi or --disable-natsemi was given.
  216. @@ -5719,34 +5614,14 @@
  217. NETBOOT_DRIVERS="$NETBOOT_DRIVERS natsemi.o"
  218. fi
  219. -# Check whether --enable-ni5010 or --disable-ni5010 was given.
  220. -if test "${enable_ni5010+set}" = set; then
  221. - enableval="$enable_ni5010"
  222. +# Check whether --enable-ns83820 or --disable-ns83820 was given.
  223. +if test "${enable_ns83820+set}" = set; then
  224. + enableval="$enable_ns83820"
  225. fi;
  226. -if test "x$enable_ni5010" = xyes; then
  227. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI5010=1"
  228. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni5010.o"
  229. -fi
  230. -
  231. -# Check whether --enable-3c503 or --disable-3c503 was given.
  232. -if test "${enable_3c503+set}" = set; then
  233. - enableval="$enable_3c503"
  234. -
  235. -fi;
  236. -if test "x$enable_3c503" = xyes; then
  237. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C503=1"
  238. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c503.o"
  239. -fi
  240. -
  241. -# Check whether --enable-ne or --disable-ne was given.
  242. -if test "${enable_ne+set}" = set; then
  243. - enableval="$enable_ne"
  244. -
  245. -fi;
  246. -if test "x$enable_ne" = xyes; then
  247. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NE=1"
  248. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ne.o"
  249. +if test "x$enable_ns83820" = xyes; then
  250. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NS83820=1"
  251. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS ns83820.o"
  252. fi
  253. # Check whether --enable-ns8390 or --disable-ns8390 was given.
  254. @@ -5759,24 +5634,24 @@
  255. NETBOOT_DRIVERS="$NETBOOT_DRIVERS ns8390.o"
  256. fi
  257. -# Check whether --enable-wd or --disable-wd was given.
  258. -if test "${enable_wd+set}" = set; then
  259. - enableval="$enable_wd"
  260. +# Check whether --enable-pcnet32 or --disable-pcnet32 was given.
  261. +if test "${enable_pcnet32+set}" = set; then
  262. + enableval="$enable_pcnet32"
  263. fi;
  264. -if test "x$enable_wd" = xyes; then
  265. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_WD=1"
  266. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS wd.o"
  267. +if test "x$enable_pcnet32" = xyes; then
  268. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_PCNET32=1"
  269. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS pcnet32.o"
  270. fi
  271. -# Check whether --enable-otulip or --disable-otulip was given.
  272. -if test "${enable_otulip+set}" = set; then
  273. - enableval="$enable_otulip"
  274. +# Check whether --enable-pnic or --disable-pnic was given.
  275. +if test "${enable_pnic+set}" = set; then
  276. + enableval="$enable_pnic"
  277. fi;
  278. -if test "x$enable_otulip" = xyes; then
  279. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_OTULIP=1"
  280. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS otulip.o"
  281. +if test "x$enable_pnic" = xyes; then
  282. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_PNIC=1"
  283. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS pnic.o"
  284. fi
  285. # Check whether --enable-rtl8139 or --disable-rtl8139 was given.
  286. @@ -5789,6 +5664,16 @@
  287. NETBOOT_DRIVERS="$NETBOOT_DRIVERS rtl8139.o"
  288. fi
  289. +# Check whether --enable-r8169 or --disable-r8169 was given.
  290. +if test "${enable_r8169+set}" = set; then
  291. + enableval="$enable_r8169"
  292. +
  293. +fi;
  294. +if test "x$enable_r8169" = xyes; then
  295. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_R8169=1"
  296. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS r8169.o"
  297. +fi
  298. +
  299. # Check whether --enable-sis900 or --disable-sis900 was given.
  300. if test "${enable_sis900+set}" = set; then
  301. enableval="$enable_sis900"
  302. @@ -5799,34 +5684,14 @@
  303. NETBOOT_DRIVERS="$NETBOOT_DRIVERS sis900.o"
  304. fi
  305. -# Check whether --enable-sk-g16 or --disable-sk-g16 was given.
  306. -if test "${enable_sk_g16+set}" = set; then
  307. - enableval="$enable_sk_g16"
  308. -
  309. -fi;
  310. -if test "x$enable_sk_g16" = xyes; then
  311. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_SK_G16=1"
  312. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS sk_g16.o"
  313. -fi
  314. -
  315. -# Check whether --enable-smc9000 or --disable-smc9000 was given.
  316. -if test "${enable_smc9000+set}" = set; then
  317. - enableval="$enable_smc9000"
  318. -
  319. -fi;
  320. -if test "x$enable_smc9000" = xyes; then
  321. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_SMC9000=1"
  322. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS smc9000.o"
  323. -fi
  324. -
  325. -# Check whether --enable-tiara or --disable-tiara was given.
  326. -if test "${enable_tiara+set}" = set; then
  327. - enableval="$enable_tiara"
  328. +# Check whether --enable-tg3 or --disable-tg3 was given.
  329. +if test "${enable_tg3+set}" = set; then
  330. + enableval="$enable_tg3"
  331. fi;
  332. -if test "x$enable_tiara" = xyes; then
  333. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TIARA=1"
  334. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS tiara.o"
  335. +if test "x$enable_tg3" = xyes; then
  336. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TG3=1"
  337. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS tg3.o"
  338. fi
  339. # Check whether --enable-tulip or --disable-tulip was given.
  340. @@ -5839,6 +5704,16 @@
  341. NETBOOT_DRIVERS="$NETBOOT_DRIVERS tulip.o"
  342. fi
  343. +# Check whether --enable-tlan or --disable-tlan was given.
  344. +if test "${enable_tlan+set}" = set; then
  345. + enableval="$enable_tlan"
  346. +
  347. +fi;
  348. +if test "x$enable_tlan" = xyes; then
  349. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TLAN=1"
  350. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS tlan.o"
  351. +fi
  352. +
  353. # Check whether --enable-via-rhine or --disable-via-rhine was given.
  354. if test "${enable_via_rhine+set}" = set; then
  355. enableval="$enable_via_rhine"
  356. @@ -5873,24 +5748,6 @@
  357. FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_TFTP=1"
  358. fi
  359. -# Check whether --enable-3c503-shmem or --disable-3c503-shmem was given.
  360. -if test "${enable_3c503_shmem+set}" = set; then
  361. - enableval="$enable_3c503_shmem"
  362. -
  363. -fi;
  364. -if test "x$enable_3c503_shmem" = xyes; then
  365. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DT503_SHMEM=1"
  366. -fi
  367. -
  368. -# Check whether --enable-3c503-aui or --disable-3c503-aui was given.
  369. -if test "${enable_3c503_aui+set}" = set; then
  370. - enableval="$enable_3c503_aui"
  371. -
  372. -fi;
  373. -if test "x$enable_3c503_aui" = xyes; then
  374. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DT503_AUI=1"
  375. -fi
  376. -
  377. # Check whether --enable-compex-rl2000-fix or --disable-compex-rl2000-fix was given.
  378. if test "${enable_compex_rl2000_fix+set}" = set; then
  379. enableval="$enable_compex_rl2000_fix"
  380. @@ -5900,12 +5757,6 @@
  381. NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCOMPEX_RL2000_FIX=1"
  382. fi
  383. -# Check whether --enable-smc9000-scan or --disable-smc9000-scan was given.
  384. -if test "${enable_smc9000_scan+set}" = set; then
  385. - enableval="$enable_smc9000_scan"
  386. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DSMC9000_SCAN=$enable_smc9000_scan"
  387. -fi;
  388. -
  389. # Check whether --enable-ne-scan or --disable-ne-scan was given.
  390. if test "${enable_ne_scan+set}" = set; then
  391. enableval="$enable_ne_scan"
  392. @@ -5922,12 +5773,6 @@
  393. NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DWD_DEFAULT_MEM=0xCC000"
  394. fi;
  395. -# Check whether --enable-cs-scan or --disable-cs-scan was given.
  396. -if test "${enable_cs_scan+set}" = set; then
  397. - enableval="$enable_cs_scan"
  398. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCS_SCAN=$enable_cs_scan"
  399. -fi;
  400. -
  401. # Check whether --enable-diskless or --disable-diskless was given.
  402. if test "${enable_diskless+set}" = set; then
  403. enableval="$enable_diskless"
  404. Index: b/configure.ac
  405. ===================================================================
  406. --- a/configure.ac
  407. +++ b/configure.ac
  408. @@ -344,7 +344,7 @@
  409. [ --disable-packet-retransmission
  410. turn off packet retransmission])
  411. if test "x$enable_packet_retransmission" != xno; then
  412. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1"
  413. + NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1 -DCONFIG_PCI"
  414. fi
  415. AC_ARG_ENABLE(pci-direct,
  416. @@ -354,20 +354,6 @@
  417. fi
  418. dnl Device drivers.
  419. -AC_ARG_ENABLE(3c509,
  420. - [ --enable-3c509 enable 3Com509 driver])
  421. -if test "x$enable_3c509" = xyes; then
  422. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C509"
  423. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c509.o"
  424. -fi
  425. -
  426. -AC_ARG_ENABLE(3c529,
  427. - [ --enable-3c529 enable 3Com529 driver])
  428. -if test "x$enable_3c529" = xyes; then
  429. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C529=1"
  430. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c529.o"
  431. -fi
  432. -
  433. AC_ARG_ENABLE(3c595,
  434. [ --enable-3c595 enable 3Com595 driver])
  435. if test "x$enable_3c595" = xyes; then
  436. @@ -382,13 +368,6 @@
  437. NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c90x.o"
  438. fi
  439. -AC_ARG_ENABLE(cs89x0,
  440. - [ --enable-cs89x0 enable CS89x0 driver])
  441. -if test "x$enable_cs89x0" = xyes; then
  442. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_CS89X0=1"
  443. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS cs89x0.o"
  444. -fi
  445. -
  446. AC_ARG_ENABLE(davicom,
  447. [ --enable-davicom enable Davicom driver])
  448. if test "x$enable_davicom" = xyes; then
  449. @@ -396,18 +375,11 @@
  450. NETBOOT_DRIVERS="$NETBOOT_DRIVERS davicom.o"
  451. fi
  452. -AC_ARG_ENABLE(depca,
  453. - [ --enable-depca enable DEPCA and EtherWORKS driver])
  454. -if test "x$enable_depca" = xyes; then
  455. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_DEPCA=1"
  456. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS depca.o"
  457. -fi
  458. -
  459. -AC_ARG_ENABLE(eepro,
  460. - [ --enable-eepro enable Etherexpress Pro/10 driver])
  461. -if test "x$enable_eepro" = xyes; then
  462. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_EEPRO=1"
  463. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS eepro.o"
  464. +AC_ARG_ENABLE(e1000,
  465. + [ --enable-e1000 enable Etherexpress Pro/1000 driver])
  466. +if test "x$enable_e1000" = xyes; then
  467. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_E1000=1"
  468. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS e1000.o"
  469. fi
  470. AC_ARG_ENABLE(eepro100,
  471. @@ -424,46 +396,11 @@
  472. NETBOOT_DRIVERS="$NETBOOT_DRIVERS epic100.o"
  473. fi
  474. -AC_ARG_ENABLE(3c507,
  475. - [ --enable-3c507 enable 3Com507 driver])
  476. -if test "x$enable_3c507" = xyes; then
  477. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C507=1"
  478. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c507.o"
  479. -fi
  480. -
  481. -AC_ARG_ENABLE(exos205,
  482. - [ --enable-exos205 enable EXOS205 driver])
  483. -if test "x$enable_exos205" = xyes; then
  484. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_EXOS205=1"
  485. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS exos205.o"
  486. -fi
  487. -
  488. -AC_ARG_ENABLE(ni5210,
  489. - [ --enable-ni5210 enable Racal-Interlan NI5210 driver])
  490. -if test "x$enable_ni5210" = xyes; then
  491. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI5210=1"
  492. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni5210.o"
  493. -fi
  494. -
  495. -AC_ARG_ENABLE(lance,
  496. - [ --enable-lance enable Lance PCI PCNet/32 driver])
  497. -if test "x$enable_lance" = xyes; then
  498. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_LANCE=1"
  499. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS lance.o"
  500. -fi
  501. -
  502. -AC_ARG_ENABLE(ne2100,
  503. - [ --enable-ne2100 enable Novell NE2100 driver])
  504. -if test "x$enable_ne2100" = xyes; then
  505. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NE2100=1"
  506. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ne2100.o"
  507. -fi
  508. -
  509. -AC_ARG_ENABLE(ni6510,
  510. - [ --enable-ni6510 enable Racal-Interlan NI6510 driver])
  511. -if test "x$enable_ni6510" = xyes; then
  512. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI6510=1"
  513. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni6510.o"
  514. +AC_ARG_ENABLE(forcedeth,
  515. + [ --enable-forcedeth enable Nvidia Geforce driver])
  516. +if test "x$enable_forcedeth" = xyes; then
  517. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_FORCEDETH=1"
  518. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS forcedeth.o"
  519. fi
  520. AC_ARG_ENABLE(natsemi,
  521. @@ -473,25 +410,11 @@
  522. NETBOOT_DRIVERS="$NETBOOT_DRIVERS natsemi.o"
  523. fi
  524. -AC_ARG_ENABLE(ni5010,
  525. - [ --enable-ni5010 enable Racal-Interlan NI5010 driver])
  526. -if test "x$enable_ni5010" = xyes; then
  527. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI5010=1"
  528. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni5010.o"
  529. -fi
  530. -
  531. -AC_ARG_ENABLE(3c503,
  532. - [ --enable-3c503 enable 3Com503 driver])
  533. -if test "x$enable_3c503" = xyes; then
  534. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C503=1"
  535. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c503.o"
  536. -fi
  537. -
  538. -AC_ARG_ENABLE(ne,
  539. - [ --enable-ne enable NE1000/2000 ISA driver])
  540. -if test "x$enable_ne" = xyes; then
  541. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NE=1"
  542. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ne.o"
  543. +AC_ARG_ENABLE(ns83820,
  544. + [ --enable-ns83820 enable NS83820 driver])
  545. +if test "x$enable_ns83820" = xyes; then
  546. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NS83820=1"
  547. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS ns83820.o"
  548. fi
  549. AC_ARG_ENABLE(ns8390,
  550. @@ -501,18 +424,18 @@
  551. NETBOOT_DRIVERS="$NETBOOT_DRIVERS ns8390.o"
  552. fi
  553. -AC_ARG_ENABLE(wd,
  554. - [ --enable-wd enable WD8003/8013, SMC8216/8416 driver])
  555. -if test "x$enable_wd" = xyes; then
  556. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_WD=1"
  557. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS wd.o"
  558. +AC_ARG_ENABLE(pcnet32,
  559. + [ --enable-pcnet32 enable AMD Lance/PCI PCNet/32 driver])
  560. +if test "x$enable_pcnet32" = xyes; then
  561. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_PCNET32=1"
  562. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS pcnet32.o"
  563. fi
  564. -AC_ARG_ENABLE(otulip,
  565. - [ --enable-otulip enable old Tulip driver])
  566. -if test "x$enable_otulip" = xyes; then
  567. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_OTULIP=1"
  568. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS otulip.o"
  569. +AC_ARG_ENABLE(pnic,
  570. + [ --enable-pnic enable Bochs Pseudo Nic driver])
  571. +if test "x$enable_pnic" = xyes; then
  572. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_PNIC=1"
  573. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS pnic.o"
  574. fi
  575. AC_ARG_ENABLE(rtl8139,
  576. @@ -522,6 +445,13 @@
  577. NETBOOT_DRIVERS="$NETBOOT_DRIVERS rtl8139.o"
  578. fi
  579. +AC_ARG_ENABLE(r8169,
  580. + [ --enable-r8169 enable Realtek 8169 driver])
  581. +if test "x$enable_r8169" = xyes; then
  582. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_R8169=1"
  583. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS r8169.o"
  584. +fi
  585. +
  586. AC_ARG_ENABLE(sis900,
  587. [ --enable-sis900 enable SIS 900 and SIS 7016 driver])
  588. if test "x$enable_sis900" = xyes; then
  589. @@ -529,25 +459,11 @@
  590. NETBOOT_DRIVERS="$NETBOOT_DRIVERS sis900.o"
  591. fi
  592. -AC_ARG_ENABLE(sk-g16,
  593. - [ --enable-sk-g16 enable Schneider and Koch G16 driver])
  594. -if test "x$enable_sk_g16" = xyes; then
  595. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_SK_G16=1"
  596. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS sk_g16.o"
  597. -fi
  598. -
  599. -AC_ARG_ENABLE(smc9000,
  600. - [ --enable-smc9000 enable SMC9000 driver])
  601. -if test "x$enable_smc9000" = xyes; then
  602. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_SMC9000=1"
  603. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS smc9000.o"
  604. -fi
  605. -
  606. -AC_ARG_ENABLE(tiara,
  607. - [ --enable-tiara enable Tiara driver])
  608. -if test "x$enable_tiara" = xyes; then
  609. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TIARA=1"
  610. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS tiara.o"
  611. +AC_ARG_ENABLE(tg3,
  612. + [ --enable-tg3 enable Broadcom Tigon3 driver])
  613. +if test "x$enable_tg3" = xyes; then
  614. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TG3=1"
  615. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS tg3.o"
  616. fi
  617. AC_ARG_ENABLE(tulip,
  618. @@ -557,6 +473,13 @@
  619. NETBOOT_DRIVERS="$NETBOOT_DRIVERS tulip.o"
  620. fi
  621. +AC_ARG_ENABLE(tlan,
  622. + [ --enable-tlan enable TI ThunderLAN driver])
  623. +if test "x$enable_tlan" = xyes; then
  624. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TLAN=1"
  625. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS tlan.o"
  626. +fi
  627. +
  628. AC_ARG_ENABLE(via-rhine,
  629. [ --enable-via-rhine enable Rhine-I/II driver])
  630. if test "x$enable_via_rhine" = xyes; then
  631. @@ -565,7 +488,7 @@
  632. fi
  633. AC_ARG_ENABLE(w89c840,
  634. - [ --enable-w89c840 enable Winbond W89c840, Compex RL100-ATX driver])
  635. + [ --enable-w89c840 enable Winbond W89c840 driver])
  636. if test "x$enable_w89c840" = xyes; then
  637. NET_CFLAGS="$NET_CFLAGS -DINCLUDE_W89C840=1"
  638. NETBOOT_DRIVERS="$NETBOOT_DRIVERS w89c840.o"
  639. @@ -577,19 +500,7 @@
  640. FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_TFTP=1"
  641. fi
  642. -dnl Extra options.
  643. -AC_ARG_ENABLE(3c503-shmem,
  644. - [ --enable-3c503-shmem use 3c503 shared memory mode])
  645. -if test "x$enable_3c503_shmem" = xyes; then
  646. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DT503_SHMEM=1"
  647. -fi
  648. -
  649. -AC_ARG_ENABLE(3c503-aui,
  650. - [ --enable-3c503-aui use AUI by default on 3c503 cards])
  651. -if test "x$enable_3c503_aui" = xyes; then
  652. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DT503_AUI=1"
  653. -fi
  654. -
  655. +dnl extra flag for ns8390.c
  656. AC_ARG_ENABLE(compex-rl2000-fix,
  657. [ --enable-compex-rl2000-fix
  658. specify this if you have a Compex RL2000 PCI])
  659. @@ -597,11 +508,6 @@
  660. NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCOMPEX_RL2000_FIX=1"
  661. fi
  662. -AC_ARG_ENABLE(smc9000-scan,
  663. - [ --enable-smc9000-scan=LIST
  664. - probe for SMC9000 I/O addresses using LIST],
  665. - [NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DSMC9000_SCAN=$enable_smc9000_scan"])
  666. -
  667. AC_ARG_ENABLE(ne-scan,
  668. [ --enable-ne-scan=LIST probe for NE base address using LIST],
  669. [NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DNE_SCAN=$enable_ne_scan"],
  670. @@ -613,10 +519,6 @@
  671. [NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DWD_DEFAULT_MEM=$enable_wd_default_mem"],
  672. [NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DWD_DEFAULT_MEM=0xCC000"])
  673. -AC_ARG_ENABLE(cs-scan,
  674. - [ --enable-cs-scan=LIST probe for CS89x0 base address using LIST],
  675. - [NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCS_SCAN=$enable_cs_scan"])
  676. -
  677. dnl Diskless
  678. AC_ARG_ENABLE(diskless,
  679. [ --enable-diskless enable diskless support])
  680. Index: b/netboot/3c509.h
  681. ===================================================================
  682. --- a/netboot/3c509.h
  683. +++ /dev/null
  684. @@ -1,397 +0,0 @@
  685. -/*
  686. - * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) All rights reserved.
  687. - *
  688. - * Redistribution and use in source and binary forms, with or without
  689. - * modification, are permitted provided that the following conditions are
  690. - * met: 1. Redistributions of source code must retain the above copyright
  691. - * notice, this list of conditions and the following disclaimer. 2. The name
  692. - * of the author may not be used to endorse or promote products derived from
  693. - * this software withough specific prior written permission
  694. - *
  695. - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  696. - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  697. - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  698. - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  699. - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  700. - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  701. - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  702. - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  703. - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  704. - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  705. - *
  706. - * if_epreg.h,v 1.4 1994/11/13 10:12:37 gibbs Exp Modified by:
  707. - *
  708. - October 2, 1994
  709. -
  710. - Modified by: Andres Vega Garcia
  711. -
  712. - INRIA - Sophia Antipolis, France
  713. - e-mail: avega@sophia.inria.fr
  714. - finger: avega@pax.inria.fr
  715. -
  716. - */
  717. -
  718. -/*
  719. - * Ethernet software status per interface.
  720. - */
  721. -/*
  722. - * Some global constants
  723. - */
  724. -
  725. -#define TX_INIT_RATE 16
  726. -#define TX_INIT_MAX_RATE 64
  727. -#define RX_INIT_LATENCY 64
  728. -#define RX_INIT_EARLY_THRESH 64
  729. -#define MIN_RX_EARLY_THRESHF 16 /* not less than ether_header */
  730. -#define MIN_RX_EARLY_THRESHL 4
  731. -
  732. -#define EEPROMSIZE 0x40
  733. -#define MAX_EEPROMBUSY 1000
  734. -#define EP_LAST_TAG 0xd7
  735. -#define EP_MAX_BOARDS 16
  736. -#define EP_ID_PORT 0x100
  737. -
  738. -/*
  739. - * some macros to acces long named fields
  740. - */
  741. -#define IS_BASE (eth_nic_base)
  742. -#define BASE (eth_nic_base)
  743. -
  744. -/*
  745. - * Commands to read/write EEPROM trough EEPROM command register (Window 0,
  746. - * Offset 0xa)
  747. - */
  748. -#define EEPROM_CMD_RD 0x0080 /* Read: Address required (5 bits) */
  749. -#define EEPROM_CMD_WR 0x0040 /* Write: Address required (5 bits) */
  750. -#define EEPROM_CMD_ERASE 0x00c0 /* Erase: Address required (5 bits) */
  751. -#define EEPROM_CMD_EWEN 0x0030 /* Erase/Write Enable: No data required */
  752. -
  753. -#define EEPROM_BUSY (1<<15)
  754. -#define EEPROM_TST_MODE (1<<14)
  755. -
  756. -/*
  757. - * Some short functions, worth to let them be a macro
  758. - */
  759. -#define is_eeprom_busy(b) (inw((b)+EP_W0_EEPROM_COMMAND)&EEPROM_BUSY)
  760. -#define GO_WINDOW(x) outw(WINDOW_SELECT|(x), BASE+EP_COMMAND)
  761. -
  762. -/**************************************************************************
  763. - *
  764. - * These define the EEPROM data structure. They are used in the probe
  765. - * function to verify the existance of the adapter after having sent
  766. - * the ID_Sequence.
  767. - *
  768. - * There are others but only the ones we use are defined here.
  769. - *
  770. - **************************************************************************/
  771. -
  772. -#define EEPROM_NODE_ADDR_0 0x0 /* Word */
  773. -#define EEPROM_NODE_ADDR_1 0x1 /* Word */
  774. -#define EEPROM_NODE_ADDR_2 0x2 /* Word */
  775. -#define EEPROM_PROD_ID 0x3 /* 0x9[0-f]50 */
  776. -#define EEPROM_MFG_ID 0x7 /* 0x6d50 */
  777. -#define EEPROM_ADDR_CFG 0x8 /* Base addr */
  778. -#define EEPROM_RESOURCE_CFG 0x9 /* IRQ. Bits 12-15 */
  779. -
  780. -/**************************************************************************
  781. - *
  782. - * These are the registers for the 3Com 3c509 and their bit patterns when
  783. - * applicable. They have been taken out the the "EtherLink III Parallel
  784. - * Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual
  785. - * from 3com.
  786. - *
  787. - **************************************************************************/
  788. -
  789. -#define EP_COMMAND 0x0e /* Write. BASE+0x0e is always a
  790. - * command reg. */
  791. -#define EP_STATUS 0x0e /* Read. BASE+0x0e is always status
  792. - * reg. */
  793. -#define EP_WINDOW 0x0f /* Read. BASE+0x0f is always window
  794. - * reg. */
  795. -/*
  796. - * Window 0 registers. Setup.
  797. - */
  798. -/* Write */
  799. -#define EP_W0_EEPROM_DATA 0x0c
  800. -#define EP_W0_EEPROM_COMMAND 0x0a
  801. -#define EP_W0_RESOURCE_CFG 0x08
  802. -#define EP_W0_ADDRESS_CFG 0x06
  803. -#define EP_W0_CONFIG_CTRL 0x04
  804. -/* Read */
  805. -#define EP_W0_PRODUCT_ID 0x02
  806. -#define EP_W0_MFG_ID 0x00
  807. -
  808. -/*
  809. - * Window 1 registers. Operating Set.
  810. - */
  811. -/* Write */
  812. -#define EP_W1_TX_PIO_WR_2 0x02
  813. -#define EP_W1_TX_PIO_WR_1 0x00
  814. -/* Read */
  815. -#define EP_W1_FREE_TX 0x0c
  816. -#define EP_W1_TX_STATUS 0x0b /* byte */
  817. -#define EP_W1_TIMER 0x0a /* byte */
  818. -#define EP_W1_RX_STATUS 0x08
  819. -#define EP_W1_RX_PIO_RD_2 0x02
  820. -#define EP_W1_RX_PIO_RD_1 0x00
  821. -
  822. -/*
  823. - * Window 2 registers. Station Address Setup/Read
  824. - */
  825. -/* Read/Write */
  826. -#define EP_W2_ADDR_5 0x05
  827. -#define EP_W2_ADDR_4 0x04
  828. -#define EP_W2_ADDR_3 0x03
  829. -#define EP_W2_ADDR_2 0x02
  830. -#define EP_W2_ADDR_1 0x01
  831. -#define EP_W2_ADDR_0 0x00
  832. -
  833. -/*
  834. - * Window 3 registers. FIFO Management.
  835. - */
  836. -/* Read */
  837. -#define EP_W3_FREE_TX 0x0c
  838. -#define EP_W3_FREE_RX 0x0a
  839. -
  840. -/*
  841. - * Window 4 registers. Diagnostics.
  842. - */
  843. -/* Read/Write */
  844. -#define EP_W4_MEDIA_TYPE 0x0a
  845. -#define EP_W4_CTRLR_STATUS 0x08
  846. -#define EP_W4_NET_DIAG 0x06
  847. -#define EP_W4_FIFO_DIAG 0x04
  848. -#define EP_W4_HOST_DIAG 0x02
  849. -#define EP_W4_TX_DIAG 0x00
  850. -
  851. -/*
  852. - * Window 5 Registers. Results and Internal status.
  853. - */
  854. -/* Read */
  855. -#define EP_W5_READ_0_MASK 0x0c
  856. -#define EP_W5_INTR_MASK 0x0a
  857. -#define EP_W5_RX_FILTER 0x08
  858. -#define EP_W5_RX_EARLY_THRESH 0x06
  859. -#define EP_W5_TX_AVAIL_THRESH 0x02
  860. -#define EP_W5_TX_START_THRESH 0x00
  861. -
  862. -/*
  863. - * Window 6 registers. Statistics.
  864. - */
  865. -/* Read/Write */
  866. -#define TX_TOTAL_OK 0x0c
  867. -#define RX_TOTAL_OK 0x0a
  868. -#define TX_DEFERRALS 0x08
  869. -#define RX_FRAMES_OK 0x07
  870. -#define TX_FRAMES_OK 0x06
  871. -#define RX_OVERRUNS 0x05
  872. -#define TX_COLLISIONS 0x04
  873. -#define TX_AFTER_1_COLLISION 0x03
  874. -#define TX_AFTER_X_COLLISIONS 0x02
  875. -#define TX_NO_SQE 0x01
  876. -#define TX_CD_LOST 0x00
  877. -
  878. -/****************************************
  879. - *
  880. - * Register definitions.
  881. - *
  882. - ****************************************/
  883. -
  884. -/*
  885. - * Command register. All windows.
  886. - *
  887. - * 16 bit register.
  888. - * 15-11: 5-bit code for command to be executed.
  889. - * 10-0: 11-bit arg if any. For commands with no args;
  890. - * this can be set to anything.
  891. - */
  892. -#define GLOBAL_RESET (unsigned short) 0x0000 /* Wait at least 1ms
  893. - * after issuing */
  894. -#define WINDOW_SELECT (unsigned short) (0x1<<11)
  895. -#define START_TRANSCEIVER (unsigned short) (0x2<<11) /* Read ADDR_CFG reg to
  896. - * determine whether
  897. - * this is needed. If
  898. - * so; wait 800 uSec
  899. - * before using trans-
  900. - * ceiver. */
  901. -#define RX_DISABLE (unsigned short) (0x3<<11) /* state disabled on
  902. - * power-up */
  903. -#define RX_ENABLE (unsigned short) (0x4<<11)
  904. -#define RX_RESET (unsigned short) (0x5<<11)
  905. -#define RX_DISCARD_TOP_PACK (unsigned short) (0x8<<11)
  906. -#define TX_ENABLE (unsigned short) (0x9<<11)
  907. -#define TX_DISABLE (unsigned short) (0xa<<11)
  908. -#define TX_RESET (unsigned short) (0xb<<11)
  909. -#define REQ_INTR (unsigned short) (0xc<<11)
  910. -#define SET_INTR_MASK (unsigned short) (0xe<<11)
  911. -#define SET_RD_0_MASK (unsigned short) (0xf<<11)
  912. -#define SET_RX_FILTER (unsigned short) (0x10<<11)
  913. -#define FIL_INDIVIDUAL (unsigned short) (0x1)
  914. -#define FIL_GROUP (unsigned short) (0x2)
  915. -#define FIL_BRDCST (unsigned short) (0x4)
  916. -#define FIL_ALL (unsigned short) (0x8)
  917. -#define SET_RX_EARLY_THRESH (unsigned short) (0x11<<11)
  918. -#define SET_TX_AVAIL_THRESH (unsigned short) (0x12<<11)
  919. -#define SET_TX_START_THRESH (unsigned short) (0x13<<11)
  920. -#define STATS_ENABLE (unsigned short) (0x15<<11)
  921. -#define STATS_DISABLE (unsigned short) (0x16<<11)
  922. -#define STOP_TRANSCEIVER (unsigned short) (0x17<<11)
  923. -/*
  924. - * The following C_* acknowledge the various interrupts. Some of them don't
  925. - * do anything. See the manual.
  926. - */
  927. -#define ACK_INTR (unsigned short) (0x6800)
  928. -#define C_INTR_LATCH (unsigned short) (ACK_INTR|0x1)
  929. -#define C_CARD_FAILURE (unsigned short) (ACK_INTR|0x2)
  930. -#define C_TX_COMPLETE (unsigned short) (ACK_INTR|0x4)
  931. -#define C_TX_AVAIL (unsigned short) (ACK_INTR|0x8)
  932. -#define C_RX_COMPLETE (unsigned short) (ACK_INTR|0x10)
  933. -#define C_RX_EARLY (unsigned short) (ACK_INTR|0x20)
  934. -#define C_INT_RQD (unsigned short) (ACK_INTR|0x40)
  935. -#define C_UPD_STATS (unsigned short) (ACK_INTR|0x80)
  936. -
  937. -/*
  938. - * Status register. All windows.
  939. - *
  940. - * 15-13: Window number(0-7).
  941. - * 12: Command_in_progress.
  942. - * 11: reserved.
  943. - * 10: reserved.
  944. - * 9: reserved.
  945. - * 8: reserved.
  946. - * 7: Update Statistics.
  947. - * 6: Interrupt Requested.
  948. - * 5: RX Early.
  949. - * 4: RX Complete.
  950. - * 3: TX Available.
  951. - * 2: TX Complete.
  952. - * 1: Adapter Failure.
  953. - * 0: Interrupt Latch.
  954. - */
  955. -#define S_INTR_LATCH (unsigned short) (0x1)
  956. -#define S_CARD_FAILURE (unsigned short) (0x2)
  957. -#define S_TX_COMPLETE (unsigned short) (0x4)
  958. -#define S_TX_AVAIL (unsigned short) (0x8)
  959. -#define S_RX_COMPLETE (unsigned short) (0x10)
  960. -#define S_RX_EARLY (unsigned short) (0x20)
  961. -#define S_INT_RQD (unsigned short) (0x40)
  962. -#define S_UPD_STATS (unsigned short) (0x80)
  963. -#define S_5_INTS (S_CARD_FAILURE|S_TX_COMPLETE|\
  964. - S_TX_AVAIL|S_RX_COMPLETE|S_RX_EARLY)
  965. -#define S_COMMAND_IN_PROGRESS (unsigned short) (0x1000)
  966. -
  967. -/*
  968. - * FIFO Registers.
  969. - * RX Status. Window 1/Port 08
  970. - *
  971. - * 15: Incomplete or FIFO empty.
  972. - * 14: 1: Error in RX Packet 0: Incomplete or no error.
  973. - * 13-11: Type of error.
  974. - * 1000 = Overrun.
  975. - * 1011 = Run Packet Error.
  976. - * 1100 = Alignment Error.
  977. - * 1101 = CRC Error.
  978. - * 1001 = Oversize Packet Error (>1514 bytes)
  979. - * 0010 = Dribble Bits.
  980. - * (all other error codes, no errors.)
  981. - *
  982. - * 10-0: RX Bytes (0-1514)
  983. - */
  984. -#define ERR_RX_INCOMPLETE (unsigned short) (0x1<<15)
  985. -#define ERR_RX (unsigned short) (0x1<<14)
  986. -#define ERR_RX_OVERRUN (unsigned short) (0x8<<11)
  987. -#define ERR_RX_RUN_PKT (unsigned short) (0xb<<11)
  988. -#define ERR_RX_ALIGN (unsigned short) (0xc<<11)
  989. -#define ERR_RX_CRC (unsigned short) (0xd<<11)
  990. -#define ERR_RX_OVERSIZE (unsigned short) (0x9<<11)
  991. -#define ERR_RX_DRIBBLE (unsigned short) (0x2<<11)
  992. -
  993. -/*
  994. - * FIFO Registers.
  995. - * TX Status. Window 1/Port 0B
  996. - *
  997. - * Reports the transmit status of a completed transmission. Writing this
  998. - * register pops the transmit completion stack.
  999. - *
  1000. - * Window 1/Port 0x0b.
  1001. - *
  1002. - * 7: Complete
  1003. - * 6: Interrupt on successful transmission requested.
  1004. - * 5: Jabber Error (TP Only, TX Reset required. )
  1005. - * 4: Underrun (TX Reset required. )
  1006. - * 3: Maximum Collisions.
  1007. - * 2: TX Status Overflow.
  1008. - * 1-0: Undefined.
  1009. - *
  1010. - */
  1011. -#define TXS_COMPLETE 0x80
  1012. -#define TXS_SUCCES_INTR_REQ 0x40
  1013. -#define TXS_JABBER 0x20
  1014. -#define TXS_UNDERRUN 0x10
  1015. -#define TXS_MAX_COLLISION 0x8
  1016. -#define TXS_STATUS_OVERFLOW 0x4
  1017. -
  1018. -/*
  1019. - * Configuration control register.
  1020. - * Window 0/Port 04
  1021. - */
  1022. -/* Read */
  1023. -#define IS_AUI (1<<13)
  1024. -#define IS_BNC (1<<12)
  1025. -#define IS_UTP (1<<9)
  1026. -/* Write */
  1027. -#define ENABLE_DRQ_IRQ 0x0001
  1028. -#define W0_P4_CMD_RESET_ADAPTER 0x4
  1029. -#define W0_P4_CMD_ENABLE_ADAPTER 0x1
  1030. -/*
  1031. - * Media type and status.
  1032. - * Window 4/Port 0A
  1033. - */
  1034. -#define ENABLE_UTP 0xc0
  1035. -#define DISABLE_UTP 0x0
  1036. -
  1037. -/*
  1038. - * Resource control register
  1039. - */
  1040. -
  1041. -#define SET_IRQ(i) ( ((i)<<12) | 0xF00) /* set IRQ i */
  1042. -
  1043. -/*
  1044. - * Receive status register
  1045. - */
  1046. -
  1047. -#define RX_BYTES_MASK (unsigned short) (0x07ff)
  1048. -#define RX_ERROR 0x4000
  1049. -#define RX_INCOMPLETE 0x8000
  1050. -
  1051. -
  1052. -/*
  1053. - * Misc defines for various things.
  1054. - */
  1055. -#define ACTIVATE_ADAPTER_TO_CONFIG 0xff /* to the id_port */
  1056. -#define MFG_ID 0x6d50 /* in EEPROM and W0 ADDR_CONFIG */
  1057. -#define PROD_ID 0x9150
  1058. -
  1059. -#define AUI 0x1
  1060. -#define BNC 0x2
  1061. -#define UTP 0x4
  1062. -
  1063. -#define RX_BYTES_MASK (unsigned short) (0x07ff)
  1064. -
  1065. - /* EISA support */
  1066. -#define EP_EISA_START 0x1000
  1067. -#define EP_EISA_W0 0x0c80
  1068. -
  1069. -#ifdef INCLUDE_3C529
  1070. - /* MCA support */
  1071. -#define MCA_MOTHERBOARD_SETUP_REG 0x94
  1072. -#define MCA_ADAPTER_SETUP_REG 0x96
  1073. -#define MCA_MAX_SLOT_NR 8
  1074. -#define MCA_POS_REG(n) (0x100+(n))
  1075. -#endif
  1076. -
  1077. -/*
  1078. - * Local variables:
  1079. - * c-basic-offset: 8
  1080. - * End:
  1081. - */
  1082. Index: b/netboot/3c595.c
  1083. ===================================================================
  1084. --- a/netboot/3c595.c
  1085. +++ b/netboot/3c595.c
  1086. @@ -20,6 +20,7 @@
  1087. *
  1088. * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
  1089. *
  1090. +* timlegge 08-24-2003 Add Multicast Support
  1091. */
  1092. /* #define EDEBUG */
  1093. @@ -30,7 +31,7 @@
  1094. #include "3c595.h"
  1095. #include "timer.h"
  1096. -static unsigned short eth_nic_base, eth_asic_base;
  1097. +static unsigned short eth_nic_base;
  1098. static unsigned short vx_connector, vx_connectors;
  1099. static struct connector_entry {
  1100. @@ -57,14 +58,12 @@
  1101. static void vxgetlink(void);
  1102. static void vxsetlink(void);
  1103. -#define udelay(n) waiton_timer2(((n)*TICKS_PER_MS)/1000)
  1104. -
  1105. /**************************************************************************
  1106. ETH_RESET - Reset adapter
  1107. ***************************************************************************/
  1108. static void t595_reset(struct nic *nic)
  1109. {
  1110. - int i, j;
  1111. + int i;
  1112. /***********************************************************
  1113. Reset 3Com 595 card
  1114. @@ -133,7 +132,7 @@
  1115. outw(ACK_INTR | 0xff, BASE + VX_COMMAND);
  1116. outw(SET_RX_FILTER | FIL_INDIVIDUAL |
  1117. - FIL_BRDCST, BASE + VX_COMMAND);
  1118. + FIL_BRDCST|FIL_MULTICAST, BASE + VX_COMMAND);
  1119. vxsetlink();
  1120. /*{
  1121. @@ -225,10 +224,9 @@
  1122. /**************************************************************************
  1123. ETH_POLL - Wait for a frame
  1124. ***************************************************************************/
  1125. -static int t595_poll(struct nic *nic)
  1126. +static int t595_poll(struct nic *nic, int retrieve)
  1127. {
  1128. /* common variables */
  1129. - unsigned short type = 0; /* used by EDEBUG */
  1130. /* variables for 3C595 */
  1131. short status, cst;
  1132. register short rx_fifo;
  1133. @@ -262,6 +260,8 @@
  1134. if (rx_fifo==0)
  1135. return 0;
  1136. + if ( ! retrieve ) return 1;
  1137. +
  1138. /* read packet */
  1139. #ifdef EDEBUG
  1140. printf("[l=%d",rx_fifo);
  1141. @@ -300,12 +300,15 @@
  1142. outw(RX_DISCARD_TOP_PACK, BASE + VX_COMMAND);
  1143. while (inw(BASE + VX_STATUS) & S_COMMAND_IN_PROGRESS);
  1144. #ifdef EDEBUG
  1145. +{
  1146. + unsigned short type = 0; /* used by EDEBUG */
  1147. type = (nic->packet[12]<<8) | nic->packet[13];
  1148. if(nic->packet[0]+nic->packet[1]+nic->packet[2]+nic->packet[3]+nic->packet[4]+
  1149. nic->packet[5] == 0xFF*ETH_ALEN)
  1150. printf(",t=%hX,b]",type);
  1151. else
  1152. printf(",t=%hX]",type);
  1153. +}
  1154. #endif
  1155. return 1;
  1156. }
  1157. @@ -382,9 +385,8 @@
  1158. static void
  1159. vxsetlink(void)
  1160. {
  1161. - int i, j, k;
  1162. + int i, j;
  1163. char *reason, *warning;
  1164. - static short prev_flags;
  1165. static char prev_conn = -1;
  1166. if (prev_conn == -1) {
  1167. @@ -438,28 +440,47 @@
  1168. GO_WINDOW(1);
  1169. }
  1170. -static void t595_disable(struct nic *nic)
  1171. +static void t595_disable(struct dev *dev)
  1172. {
  1173. - outw(STOP_TRANSCEIVER, BASE + VX_COMMAND);
  1174. - udelay(8000);
  1175. - GO_WINDOW(4);
  1176. - outw(0, BASE + VX_W4_MEDIA_TYPE);
  1177. - GO_WINDOW(1);
  1178. + struct nic *nic = (struct nic *)dev;
  1179. + t595_reset(nic);
  1180. +
  1181. + outw(STOP_TRANSCEIVER, BASE + VX_COMMAND);
  1182. + udelay(8000);
  1183. + GO_WINDOW(4);
  1184. + outw(0, BASE + VX_W4_MEDIA_TYPE);
  1185. + GO_WINDOW(1);
  1186. +}
  1187. +
  1188. +static void t595_irq(struct nic *nic __unused, irq_action_t action __unused)
  1189. +{
  1190. + switch ( action ) {
  1191. + case DISABLE :
  1192. + break;
  1193. + case ENABLE :
  1194. + break;
  1195. + case FORCE :
  1196. + break;
  1197. + }
  1198. }
  1199. /**************************************************************************
  1200. ETH_PROBE - Look for an adapter
  1201. ***************************************************************************/
  1202. -struct nic *t595_probe(struct nic *nic, unsigned short *probeaddrs, struct pci_device *pci)
  1203. +static int t595_probe(struct dev *dev, struct pci_device *pci)
  1204. {
  1205. + struct nic *nic = (struct nic *)dev;
  1206. int i;
  1207. unsigned short *p;
  1208. - if (probeaddrs == 0 || probeaddrs[0] == 0)
  1209. + if (pci->ioaddr == 0)
  1210. return 0;
  1211. /* eth_nic_base = probeaddrs[0] & ~3; */
  1212. eth_nic_base = pci->ioaddr;
  1213. + nic->irqno = 0;
  1214. + nic->ioaddr = pci->ioaddr & ~3;
  1215. +
  1216. GO_WINDOW(0);
  1217. outw(GLOBAL_RESET, BASE + VX_COMMAND);
  1218. VX_BUSY_WAIT;
  1219. @@ -487,14 +508,40 @@
  1220. printf("Ethernet address: %!\n", nic->node_addr);
  1221. t595_reset(nic);
  1222. - nic->reset = t595_reset;
  1223. - nic->poll = t595_poll;
  1224. + dev->disable = t595_disable;
  1225. + nic->poll = t595_poll;
  1226. nic->transmit = t595_transmit;
  1227. - nic->disable = t595_disable;
  1228. - return nic;
  1229. + nic->irq = t595_irq;
  1230. + return 1;
  1231. }
  1232. +static struct pci_id t595_nics[] = {
  1233. +PCI_ROM(0x10b7, 0x5900, "3c590", "3Com590"), /* Vortex 10Mbps */
  1234. +PCI_ROM(0x10b7, 0x5950, "3c595", "3Com595"), /* Vortex 100baseTx */
  1235. +PCI_ROM(0x10b7, 0x5951, "3c595-1", "3Com595"), /* Vortex 100baseT4 */
  1236. +PCI_ROM(0x10b7, 0x5952, "3c595-2", "3Com595"), /* Vortex 100base-MII */
  1237. +PCI_ROM(0x10b7, 0x9000, "3c900-tpo", "3Com900-TPO"), /* 10 Base TPO */
  1238. +PCI_ROM(0x10b7, 0x9001, "3c900-t4", "3Com900-Combo"), /* 10/100 T4 */
  1239. +PCI_ROM(0x10b7, 0x9004, "3c900b-tpo", "3Com900B-TPO"), /* 10 Base TPO */
  1240. +PCI_ROM(0x10b7, 0x9005, "3c900b-combo", "3Com900B-Combo"), /* 10 Base Combo */
  1241. +PCI_ROM(0x10b7, 0x9006, "3c900b-tpb2", "3Com900B-2/T"), /* 10 Base TP and Base2 */
  1242. +PCI_ROM(0x10b7, 0x900a, "3c900b-fl", "3Com900B-FL"), /* 10 Base F */
  1243. +PCI_ROM(0x10b7, 0x9800, "3c980-cyclone-1", "3Com980-Cyclone"), /* Cyclone */
  1244. +PCI_ROM(0x10b7, 0x9805, "3c9805-1", "3Com9805"), /* Dual Port Server Cyclone */
  1245. +PCI_ROM(0x10b7, 0x7646, "3csoho100-tx-1", "3CSOHO100-TX"), /* Hurricane */
  1246. +PCI_ROM(0x10b7, 0x4500, "3c450-1", "3Com450 HomePNA Tornado"),
  1247. +};
  1248. +
  1249. +struct pci_driver t595_driver = {
  1250. + .type = NIC_DRIVER,
  1251. + .name = "3C595",
  1252. + .probe = t595_probe,
  1253. + .ids = t595_nics,
  1254. + .id_count = sizeof(t595_nics)/sizeof(t595_nics[0]),
  1255. + .class = 0,
  1256. +};
  1257. +
  1258. /*
  1259. * Local variables:
  1260. * c-basic-offset: 8
  1261. Index: b/netboot/3c90x.c
  1262. ===================================================================
  1263. --- a/netboot/3c90x.c
  1264. +++ b/netboot/3c90x.c
  1265. @@ -1,7 +1,7 @@
  1266. /*
  1267. * 3c90x.c -- This file implements the 3c90x driver for etherboot. Written
  1268. * by Greg Beeley, Greg.Beeley@LightSys.org. Modified by Steve Smith,
  1269. - * Steve.Smith@Juno.Com
  1270. + * Steve.Smith@Juno.Com. Alignment bug fix Neil Newell (nn@icenoir.net).
  1271. *
  1272. * This program Copyright (C) 1999 LightSys Technology Services, Inc.
  1273. * Portions Copyright (C) 1999 Steve Smith
  1274. @@ -31,13 +31,15 @@
  1275. * Re-wrote poll and transmit for
  1276. * better error recovery and heavy
  1277. * network traffic operation
  1278. + * v2.01 5-26-2003 NN Fixed driver alignment issue which
  1279. + * caused system lockups if driver structures
  1280. + * not 8-byte aligned.
  1281. *
  1282. */
  1283. #include "etherboot.h"
  1284. #include "nic.h"
  1285. #include "pci.h"
  1286. -#include "cards.h"
  1287. #include "timer.h"
  1288. #define XCVR_MAGIC (0x5A00)
  1289. @@ -47,9 +49,6 @@
  1290. **/
  1291. #define XMIT_RETRIES 250
  1292. -#undef virt_to_bus
  1293. -#define virt_to_bus(x) ((unsigned long)x)
  1294. -
  1295. /*** Register definitions for the 3c905 ***/
  1296. enum Registers
  1297. {
  1298. @@ -225,7 +224,7 @@
  1299. unsigned int DataAddr;
  1300. unsigned int DataLength;
  1301. }
  1302. - TXD;
  1303. + TXD __attribute__ ((aligned(8))); /* 64-bit aligned for bus mastering */
  1304. /*** RX descriptor ***/
  1305. typedef struct
  1306. @@ -235,7 +234,7 @@
  1307. unsigned int DataAddr;
  1308. unsigned int DataLength;
  1309. }
  1310. - RXD;
  1311. + RXD __attribute__ ((aligned(8))); /* 64-bit aligned for bus mastering */
  1312. /*** Global variables ***/
  1313. static struct
  1314. @@ -311,6 +310,7 @@
  1315. }
  1316. +#if 0
  1317. /*** a3c90x_internal_WriteEepromWord - write a physical word of
  1318. *** data to the onboard serial eeprom (not the BIOS prom, but the
  1319. *** nvram in the card that stores, among other things, the MAC
  1320. @@ -344,8 +344,9 @@
  1321. return 0;
  1322. }
  1323. +#endif
  1324. -
  1325. +#if 0
  1326. /*** a3c90x_internal_WriteEeprom - write data to the serial eeprom,
  1327. *** and re-compute the eeprom checksum.
  1328. ***/
  1329. @@ -384,8 +385,7 @@
  1330. return 0;
  1331. }
  1332. -
  1333. -
  1334. +#endif
  1335. /*** a3c90x_reset: exported function that resets the card to its default
  1336. *** state. This is so the Linux driver can re-set the card up the way
  1337. @@ -393,12 +393,10 @@
  1338. *** not alter the selected transceiver that we used to download the boot
  1339. *** image.
  1340. ***/
  1341. -static void
  1342. -a3c90x_reset(struct nic *nic)
  1343. +static void a3c90x_reset(void)
  1344. {
  1345. - int cfg;
  1346. -
  1347. #ifdef CFG_3C90X_PRESERVE_XCVR
  1348. + int cfg;
  1349. /** Read the current InternalConfig value. **/
  1350. a3c90x_internal_SetWindow(INF_3C90X.IOAddr, winTxRxOptions3);
  1351. cfg = inl(INF_3C90X.IOAddr + regInternalConfig_3_l);
  1352. @@ -473,7 +471,7 @@
  1353. *** p - the pointer to the packet data itself.
  1354. ***/
  1355. static void
  1356. -a3c90x_transmit(struct nic *nic, const char *d, unsigned int t,
  1357. +a3c90x_transmit(struct nic *nic __unused, const char *d, unsigned int t,
  1358. unsigned int s, const char *p)
  1359. {
  1360. @@ -553,7 +551,7 @@
  1361. if (status & 0x02)
  1362. {
  1363. printf("3C90X: Tx Reclaim Error (%hhX)\n", status);
  1364. - a3c90x_reset(NULL);
  1365. + a3c90x_reset();
  1366. }
  1367. else if (status & 0x04)
  1368. {
  1369. @@ -572,18 +570,18 @@
  1370. else if (status & 0x10)
  1371. {
  1372. printf("3C90X: Tx Underrun (%hhX)\n", status);
  1373. - a3c90x_reset(NULL);
  1374. + a3c90x_reset();
  1375. }
  1376. else if (status & 0x20)
  1377. {
  1378. printf("3C90X: Tx Jabber (%hhX)\n", status);
  1379. - a3c90x_reset(NULL);
  1380. + a3c90x_reset();
  1381. }
  1382. else if ((status & 0x80) != 0x80)
  1383. {
  1384. printf("3C90X: Internal Error - Incomplete Transmission (%hhX)\n",
  1385. status);
  1386. - a3c90x_reset(NULL);
  1387. + a3c90x_reset();
  1388. }
  1389. }
  1390. @@ -601,7 +599,7 @@
  1391. *** in nic->packetlen. Return 1 if a packet was found.
  1392. ***/
  1393. static int
  1394. -a3c90x_poll(struct nic *nic)
  1395. +a3c90x_poll(struct nic *nic, int retrieve)
  1396. {
  1397. int i, errcode;
  1398. @@ -610,6 +608,8 @@
  1399. return 0;
  1400. }
  1401. + if ( ! retrieve ) return 1;
  1402. +
  1403. /** we don't need to acknowledge rxComplete -- the upload engine
  1404. ** does it for us.
  1405. **/
  1406. @@ -663,34 +663,51 @@
  1407. *** [Ken]
  1408. ***/
  1409. static void
  1410. -a3c90x_disable(struct nic *nic)
  1411. - {
  1412. +a3c90x_disable(struct dev *dev __unused)
  1413. +{
  1414. + /* reset and disable merge */
  1415. + a3c90x_reset();
  1416. /* Disable the receiver and transmitter. */
  1417. outw(cmdRxDisable, INF_3C90X.IOAddr + regCommandIntStatus_w);
  1418. outw(cmdTxDisable, INF_3C90X.IOAddr + regCommandIntStatus_w);
  1419. - }
  1420. -
  1421. +}
  1422. +static void a3c90x_irq(struct nic *nic __unused, irq_action_t action __unused)
  1423. +{
  1424. + switch ( action ) {
  1425. + case DISABLE :
  1426. + break;
  1427. + case ENABLE :
  1428. + break;
  1429. + case FORCE :
  1430. + break;
  1431. + }
  1432. +}
  1433. /*** a3c90x_probe: exported routine to probe for the 3c905 card and perform
  1434. *** initialization. If this routine is called, the pci functions did find the
  1435. *** card. We just have to init it here.
  1436. ***/
  1437. -struct nic*
  1438. -a3c90x_probe(struct nic *nic, unsigned short *probeaddrs, struct pci_device *pci)
  1439. - {
  1440. +static int a3c90x_probe(struct dev *dev, struct pci_device *pci)
  1441. +{
  1442. + struct nic *nic = (struct nic *)dev;
  1443. int i, c;
  1444. unsigned short eeprom[0x21];
  1445. unsigned int cfg;
  1446. unsigned int mopt;
  1447. + unsigned int mstat;
  1448. unsigned short linktype;
  1449. +#define HWADDR_OFFSET 10
  1450. - if (probeaddrs == 0 || probeaddrs[0] == 0)
  1451. + if (pci->ioaddr == 0)
  1452. return 0;
  1453. adjust_pci_device(pci);
  1454. - INF_3C90X.IOAddr = probeaddrs[0] & ~3;
  1455. + nic->ioaddr = pci->ioaddr & ~3;
  1456. + nic->irqno = 0;
  1457. +
  1458. + INF_3C90X.IOAddr = pci->ioaddr & ~3;
  1459. INF_3C90X.CurrentWindow = 255;
  1460. switch (a3c90x_internal_ReadEeprom(INF_3C90X.IOAddr, 0x03))
  1461. {
  1462. @@ -756,30 +773,45 @@
  1463. "Copyright 1999 LightSys Technology Services, Inc.\n"
  1464. "Portions Copyright 1999 Steve Smith\n");
  1465. printf("Provided with ABSOLUTELY NO WARRANTY.\n");
  1466. +#ifdef CFG_3C90X_BOOTROM_FIX
  1467. + if (INF_3C90X.isBrev)
  1468. + {
  1469. + printf("NOTE: 3c905b bootrom fix enabled; has side "
  1470. + "effects. See 3c90x.txt for info.\n");
  1471. + }
  1472. +#endif
  1473. printf("-------------------------------------------------------"
  1474. "------------------------\n");
  1475. /** Retrieve the Hardware address and print it on the screen. **/
  1476. - INF_3C90X.HWAddr[0] = eeprom[0]>>8;
  1477. - INF_3C90X.HWAddr[1] = eeprom[0]&0xFF;
  1478. - INF_3C90X.HWAddr[2] = eeprom[1]>>8;
  1479. - INF_3C90X.HWAddr[3] = eeprom[1]&0xFF;
  1480. - INF_3C90X.HWAddr[4] = eeprom[2]>>8;
  1481. - INF_3C90X.HWAddr[5] = eeprom[2]&0xFF;
  1482. + INF_3C90X.HWAddr[0] = eeprom[HWADDR_OFFSET + 0]>>8;
  1483. + INF_3C90X.HWAddr[1] = eeprom[HWADDR_OFFSET + 0]&0xFF;
  1484. + INF_3C90X.HWAddr[2] = eeprom[HWADDR_OFFSET + 1]>>8;
  1485. + INF_3C90X.HWAddr[3] = eeprom[HWADDR_OFFSET + 1]&0xFF;
  1486. + INF_3C90X.HWAddr[4] = eeprom[HWADDR_OFFSET + 2]>>8;
  1487. + INF_3C90X.HWAddr[5] = eeprom[HWADDR_OFFSET + 2]&0xFF;
  1488. printf("MAC Address = %!\n", INF_3C90X.HWAddr);
  1489. + /* Test if the link is good, if not continue */
  1490. + a3c90x_internal_SetWindow(INF_3C90X.IOAddr, winDiagnostics4);
  1491. + mstat = inw(INF_3C90X.IOAddr + regMediaStatus_4_w);
  1492. + if((mstat & (1<<11)) == 0) {
  1493. + printf("Valid link not established\n");
  1494. + return 0;
  1495. + }
  1496. +
  1497. /** Program the MAC address into the station address registers **/
  1498. a3c90x_internal_SetWindow(INF_3C90X.IOAddr, winAddressing2);
  1499. - outw(htons(eeprom[0]), INF_3C90X.IOAddr + regStationAddress_2_3w);
  1500. - outw(htons(eeprom[1]), INF_3C90X.IOAddr + regStationAddress_2_3w+2);
  1501. - outw(htons(eeprom[2]), INF_3C90X.IOAddr + regStationAddress_2_3w+4);
  1502. + outw(htons(eeprom[HWADDR_OFFSET + 0]), INF_3C90X.IOAddr + regStationAddress_2_3w);
  1503. + outw(htons(eeprom[HWADDR_OFFSET + 1]), INF_3C90X.IOAddr + regStationAddress_2_3w+2);
  1504. + outw(htons(eeprom[HWADDR_OFFSET + 2]), INF_3C90X.IOAddr + regStationAddress_2_3w+4);
  1505. outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+0);
  1506. outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+2);
  1507. outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+4);
  1508. /** Fill in our entry in the etherboot arp table **/
  1509. for(i=0;i<ETH_ALEN;i++)
  1510. - nic->node_addr[i] = (eeprom[i/2] >> (8*((i&1)^1))) & 0xff;
  1511. + nic->node_addr[i] = (eeprom[HWADDR_OFFSET + i/2] >> (8*((i&1)^1))) & 0xff;
  1512. /** Read the media options register, print a message and set default
  1513. ** xcvr.
  1514. @@ -903,8 +935,8 @@
  1515. while (inw(INF_3C90X.IOAddr + regCommandIntStatus_w) & INT_CMDINPROGRESS)
  1516. ;
  1517. - /** Set the RX filter = receive only individual pkts & bcast. **/
  1518. - a3c90x_internal_IssueCommand(INF_3C90X.IOAddr, cmdSetRxFilter, 0x01 + 0x04);
  1519. + /** Set the RX filter = receive only individual pkts & multicast & bcast. **/
  1520. + a3c90x_internal_IssueCommand(INF_3C90X.IOAddr, cmdSetRxFilter, 0x01 + 0x02 + 0x04);
  1521. a3c90x_internal_IssueCommand(INF_3C90X.IOAddr, cmdRxEnable, 0);
  1522. @@ -918,12 +950,46 @@
  1523. cmdAcknowledgeInterrupt, 0x661);
  1524. /** Set our exported functions **/
  1525. - nic->reset = a3c90x_reset;
  1526. + dev->disable = a3c90x_disable;
  1527. nic->poll = a3c90x_poll;
  1528. nic->transmit = a3c90x_transmit;
  1529. - nic->disable = a3c90x_disable;
  1530. + nic->irq = a3c90x_irq;
  1531. - return nic;
  1532. - }
  1533. + return 1;
  1534. +}
  1535. +static struct pci_id a3c90x_nics[] = {
  1536. +/* Original 90x revisions: */
  1537. +PCI_ROM(0x10b7, 0x9000, "3c905-tpo", "3Com900-TPO"), /* 10 Base TPO */
  1538. +PCI_ROM(0x10b7, 0x9001, "3c905-t4", "3Com900-Combo"), /* 10/100 T4 */
  1539. +PCI_ROM(0x10b7, 0x9050, "3c905-tpo100", "3Com905-TX"), /* 100 Base TX / 10/100 TPO */
  1540. +PCI_ROM(0x10b7, 0x9051, "3c905-combo", "3Com905-T4"), /* 100 Base T4 / 10 Base Combo */
  1541. +/* Newer 90xB revisions: */
  1542. +PCI_ROM(0x10b7, 0x9004, "3c905b-tpo", "3Com900B-TPO"), /* 10 Base TPO */
  1543. +PCI_ROM(0x10b7, 0x9005, "3c905b-combo", "3Com900B-Combo"), /* 10 Base Combo */
  1544. +PCI_ROM(0x10b7, 0x9006, "3c905b-tpb2", "3Com900B-2/T"), /* 10 Base TP and Base2 */
  1545. +PCI_ROM(0x10b7, 0x900a, "3c905b-fl", "3Com900B-FL"), /* 10 Base FL */
  1546. +PCI_ROM(0x10b7, 0x9055, "3c905b-tpo100", "3Com905B-TX"), /* 10/100 TPO */
  1547. +PCI_ROM(0x10b7, 0x9056, "3c905b-t4", "3Com905B-T4"), /* 10/100 T4 */
  1548. +PCI_ROM(0x10b7, 0x9058, "3c905b-9058", "3Com905B-9058"), /* Cyclone 10/100/BNC */
  1549. +PCI_ROM(0x10b7, 0x905a, "3c905b-fx", "3Com905B-FL"), /* 100 Base FX / 10 Base FX */
  1550. +/* Newer 90xC revision: */
  1551. +PCI_ROM(0x10b7, 0x9200, "3c905c-tpo", "3Com905C-TXM"), /* 10/100 TPO (3C905C-TXM) */
  1552. +PCI_ROM(0x10b7, 0x9210, "3c920b-emb-wnm","3Com20B-EMB WNM"),
  1553. +PCI_ROM(0x10b7, 0x9800, "3c980", "3Com980-Cyclone"), /* Cyclone */
  1554. +PCI_ROM(0x10b7, 0x9805, "3c9805", "3Com9805"), /* Dual Port Server Cyclone */
  1555. +PCI_ROM(0x10b7, 0x7646, "3csoho100-tx", "3CSOHO100-TX"), /* Hurricane */
  1556. +PCI_ROM(0x10b7, 0x4500, "3c450", "3Com450 HomePNA Tornado"),
  1557. +PCI_ROM(0x10b7, 0x1201, "3c982a", "3Com982A"),
  1558. +PCI_ROM(0x10b7, 0x1202, "3c982b", "3Com982B"),
  1559. +};
  1560. +
  1561. +struct pci_driver a3c90x_driver = {
  1562. + .type = NIC_DRIVER,
  1563. + .name = "3C90X",
  1564. + .probe = a3c90x_probe,
  1565. + .ids = a3c90x_nics,
  1566. + .id_count = sizeof(a3c90x_nics)/sizeof(a3c90x_nics[0]),
  1567. + .class = 0,
  1568. +};
  1569. Index: b/netboot/3c90x.txt
  1570. ===================================================================
  1571. --- a/netboot/3c90x.txt
  1572. +++ /dev/null
  1573. @@ -1,307 +0,0 @@
  1574. -
  1575. - Instructions for use of the 3C90X driver for EtherBoot
  1576. -
  1577. - Original 3C905B support by:
  1578. - Greg Beeley (Greg.Beeley@LightSys.org),
  1579. - LightSys Technology Services, Inc.
  1580. - February 11, 1999
  1581. -
  1582. - Updates for 3C90X family by:
  1583. - Steve Smith (steve.smith@juno.com)
  1584. - October 1, 1999
  1585. -
  1586. - Minor documentation updates by
  1587. - Greg Beeley (Greg.Beeley@LightSys.org)
  1588. - March 29, 2000
  1589. -
  1590. --------------------------------------------------------------------------------
  1591. -
  1592. -I OVERVIEW
  1593. -
  1594. - The 3c90X series ethernet cards are a group of high-performance busmaster
  1595. - DMA cards from 3Com. This particular driver supports both the 3c90x and
  1596. - the 3c90xB revision cards. 3C90xC family support has been tested to some
  1597. - degree but not extensively.
  1598. -
  1599. - Here's the licensing information:
  1600. -
  1601. - This program Copyright (C) 1999 LightSys Technology Services, Inc.
  1602. - Portions Copyright (C) 1999 Steve Smith.
  1603. -
  1604. - This program may be re-distributed in source or binary form, modified,
  1605. - sold, or copied for any purpose, provided that the above copyright message
  1606. - and this text are included with all source copies or derivative works, and
  1607. - provided that the above copyright message and this text are included in the
  1608. - documentation of any binary-only distributions. This program is
  1609. - distributed WITHOUT ANY WARRANTY, without even the warranty of FITNESS FOR
  1610. - A PARTICULAR PURPOSE or MERCHANTABILITY. Please read the associated
  1611. - documentation "3c90x.txt" before compiling and using this driver.
  1612. -
  1613. -
  1614. -II FLASH PROMS
  1615. -
  1616. - The 3c90xB cards, according to the 3Com documentation, only accept the
  1617. - following flash memory chips:
  1618. -
  1619. - Atmel AT29C512 (64 kilobyte)
  1620. - Atmel AT29C010 (128 kilobyte)
  1621. -
  1622. - The 3c90x cards, according to the 3Com documentation, accept the
  1623. - following flash memory chips capacities:
  1624. -
  1625. - 64 kb (8 kB)
  1626. - 128 kb (16 kB)
  1627. - 256 kb (32 kB) and
  1628. - 512 kb (64 kB)
  1629. -
  1630. - Atmel AT29C512 (64 kilobyte) chips are specifically listed for both
  1631. - adapters, but flashing on the 3c905b cards would only be supported
  1632. - through the Atmel parts. Any device, of the supported size, should
  1633. - be supported when programmed by a dedicated PROM programmer (e.g.
  1634. - not the card).
  1635. -
  1636. - To use this driver in such a PROM, visit Atmel's web site and download
  1637. - their .PDF file containing a list of their distributors. Contact the
  1638. - distributors for pricing information. The prices are quite reasonable
  1639. - (about $3 US each for the 64 kB part), and are comparable to what one would
  1640. - expect for similarly sized standard EPROMs. And, the flash chips are much
  1641. - easier to work with, as they don't need to be UV-erased to be reprogrammed.
  1642. - The 3C905B card actually provides a method to program the flash memory
  1643. - while it is resident on board the card itself; if someone would like to
  1644. - write a small DOS program to do the programming, I can provide the
  1645. - information about the registers and so forth.
  1646. -
  1647. - A utility program, 3c90xutil, is provided with Etherboot in the 'contrib'
  1648. - directory that allows for the on-board flashing of the ROM while Linux
  1649. - is running. The program has been successfully used under Linux, but I
  1650. - have heard problem reports of its use under FreeBSD. Anyone willing to
  1651. - make it work under FreeBSD is more than welcome to do so!
  1652. -
  1653. - You also have the option of using EPROM chips - the 3C905B-TX-NM has been
  1654. - successfully tested with 27C256 (32kB) and 27C512 (64kB) chips with a
  1655. - specified access time of 100ns and faster.
  1656. -
  1657. -
  1658. -III GENERAL USE
  1659. -
  1660. - Normally, the basic procedure for using this driver is as follows:
  1661. -
  1662. - 1. Run the 3c90xcfg program on the driver diskette to enable the
  1663. - boot PROM and set it to 64k or 128k, as appropriate.
  1664. - 2. Build the appropriate 3c90x.fd0 or 3c90x.fd0 floppy image with
  1665. - possibly the value CFG_3C90X_XCVR defined to the transceiver type that
  1666. - you want to use (i.e., 10/100 rj45, AUI, coax, MII).
  1667. - 3. Run the floppy image on the PC to be network booted, to get
  1668. - it configured, and to verify that it will boot properly.
  1669. - 4. Build the 3c90x.rom or 3c90x.lzrom PROM image and program
  1670. - it into the flash or EPROM memory chip.
  1671. - 5. Put the PROM in the ethernet card, boot and enable 'boot from
  1672. - network first' in the system BIOS, save and reboot.
  1673. -
  1674. - Here are some issues to be aware of:
  1675. -
  1676. - 1. If you experience crashes or different behaviour when using the
  1677. - boot PROM, add the setting CFG_3C90X_BOOTROM_FIX and go through the
  1678. - steps 2-5 above. This works around a bug in some 3c905B cards (see
  1679. - below), but has some side-effects which may not be desirable.
  1680. - Please note that you have to boot off a floppy (not PROM!) once for
  1681. - this fix to take effect.
  1682. - 2. The possible need to manually set the CFG_3C90X_XCVR value to
  1683. - configure the transceiver type. Values are listed below.
  1684. - 3. The possible need to define CFG_3C90X_PRESERVE_XCVR for use in
  1685. - operating systems that don't intelligently determine the
  1686. - transceiver type.
  1687. -
  1688. - Some things that are on the 'To-Do' list, perhaps for me, but perhaps
  1689. - for any other volunteers out there:
  1690. -
  1691. - 1. Extend the driver to fully implement the auto-select
  1692. - algorithm if the card has multiple media ports.
  1693. - 2. Fix any bugs in the code <grin>....
  1694. - 3. Extend the driver to support the 3c905c revision cards
  1695. - "officially". Right now, the support has been primarily empirical
  1696. - and not based on 3c905C documentation.
  1697. -
  1698. - Now for the details....
  1699. -
  1700. - This driver has been tested on roughly 300 systems. The main two
  1701. - configuration issues to contend with are:
  1702. -
  1703. - 1. Ensure that PCI Busmastering is enabled for the adapter (configured
  1704. - in the CMOS setup)
  1705. - 2. Some systems don't work properly with the adapter when plug and
  1706. - play OS is enabled; I always set it to "No" or "Disabled" -- this makes
  1707. - it easier and really doesn't adversely affect anything.
  1708. -
  1709. - Roughly 95% of the systems worked when configured properly. A few
  1710. - have issues with booting locally once the boot PROM has been installed
  1711. - (this number has been less than 2%). Other configuration issues that
  1712. - to check:
  1713. -
  1714. - 1. Newer BIOS's actually work correctly with the network boot order.
  1715. - Set the network adapter first. Most older BIOS's automatically go to
  1716. - the network boot PROM first.
  1717. - 2. For systems where the adapter was already installed and is just
  1718. - having the PROM installed, try setting the "reset configuration data"
  1719. - to yes in the CMOS setup if the BIOS isn't seen at first. If your BIOS
  1720. - doesn't have this option, remove the card, start the system, shut down,
  1721. - install the card and restart (or switch to a different PCI slot).
  1722. - 3. Make sure the CMOS security settings aren't preventing a boot.
  1723. -
  1724. - The 3c905B cards have a significant 'bug' that relates to the flash prom:
  1725. - unless the card is set internally to the MII transceiver, it will only
  1726. - read the first 8k of the PROM image. Don't ask why -- it seems really
  1727. - obscure, but it has to do with the way they mux'd the address lines
  1728. - from the PCI bus to the ROM. Unfortunately, most of us are not using
  1729. - MII transceivers, and even the .lzrom image ends up being just a little
  1730. - bit larger than 8k. Note that the workaround for this is disabled by
  1731. - default, because the Windows NT 4.0 driver does not like it (no packets
  1732. - are transmitted).
  1733. -
  1734. - So, the solution that I've used is to internally set the card's nvram
  1735. - configuration to use MII when it boots. The 3c905b driver does this
  1736. - automatically. This way, the 16k prom image can be loaded into memory,
  1737. - and then the 3c905b driver can set the temporary configuration of the
  1738. - card to an appropriate value, either configurable by the user or chosen
  1739. - by the driver.
  1740. -
  1741. - To enable the 3c905B bugfix, which is necessary for these cards when
  1742. - booting from the Flash ROM, define -DCFG_3C90X_BOOTROM_FIX when building,
  1743. - create a floppy image and boot it once.
  1744. - Thereafter, the card should accept the larger prom image.
  1745. -
  1746. - The driver should choose an appropriate transceiver on the card. However,
  1747. - if it doesn't on your card or if you need to, for instance, set your
  1748. - card to 10mbps when connected to an unmanaged 10/100 hub, you can specify
  1749. - which transceiver you want to use. To do this, build the 3c905b.fd0
  1750. - image with -DCFG_3C90X_XCVR=x, where 'x' is one of the following
  1751. - values:
  1752. -
  1753. - 0 10Base-T
  1754. - 1 10mbps AUI
  1755. - 3 10Base-2 (thinnet/coax)
  1756. - 4 100Base-TX
  1757. - 5 100Base-FX
  1758. - 6 MII
  1759. - 8 Auto-negotiation 10Base-T / 100Base-TX (usually the default)
  1760. - 9 MII External MAC Mode
  1761. - 255 Allow driver to choose an 'appropriate' media port.
  1762. -
  1763. - Then proceed from step 2 in the above 'general use' instructions. The
  1764. - .rom image can be built with CFG_3C90X_XCVR set to a value, but you
  1765. - normally don't want to do this, since it is easier to change the
  1766. - transceiver type by rebuilding a new floppy, changing the BIOS to floppy
  1767. - boot, booting, and then changing the BIOS back to network boot. If
  1768. - CFG_3C90X_XCVR is not set in a particular build, it just uses the
  1769. - current configuration (either its 'best guess' or whatever the stored
  1770. - CFG_3C90X_XCVR value was from the last time it was set).
  1771. -
  1772. - [[ Note for the more technically inclined: The CFG_3C90X_XCVR value is
  1773. - programmed into a register in the card's NVRAM that was reserved for
  1774. - LanWorks PROM images to use. When the driver boots, the card comes
  1775. - up in MII mode, and the driver checks the LanWorks register to find
  1776. - out if the user specified a transceiver type. If it finds that
  1777. - information, it uses that, otherwise it picks a transceiver that the
  1778. - card has based on the 3c905b's MediaOptions register. This driver isn't
  1779. - quite smart enough to always determine which media port is actually
  1780. - _connected_; maybe someone else would like to take on that task (it
  1781. - actually involves sending a self-directed packet and seeing if it
  1782. - comes back. IF it does, that port is connected). ]]
  1783. -
  1784. - Another issue to keep in mind is that it is possible that some OS'es
  1785. - might not be happy with the way I've handled the PROM-image hack with
  1786. - setting MII mode on bootup. Linux 2.0.35 does not have this problem.
  1787. - Behavior of other systems may vary. The 3com documentation specifically
  1788. - says that, at least with the card that I have, the device driver in the
  1789. - OS should auto-select the media port, so other drivers should work fine
  1790. - with this 'hack'. However, if yours doesn't seem to, you can try defining
  1791. - CFG_3C90X_PRESERVE_XCVR when building to cause Etherboot to keep the
  1792. - working setting (that allowed the bootp/tftp process) across the eth_reset
  1793. - operation.
  1794. -
  1795. -
  1796. -IV FOR DEVELOPERS....
  1797. -
  1798. - If you would like to fix/extend/etc. this driver, feel free to do so; just
  1799. - be sure you can test the modified version on the 3c905B-TX cards that the
  1800. - driver was originally designed for. This section of this document gives
  1801. - some information that might be relevant to a programmer.
  1802. -
  1803. - A. Main Entry Point
  1804. -
  1805. - a3c90x_probe is the main entry point for this driver. It is referred
  1806. - to in an array in 'config.c'.
  1807. -
  1808. - B. Other Important Functions
  1809. -
  1810. - The functions a3c90x_transmit, a3c90x_poll, a3c90x_reset, and
  1811. - a3c90x_disable are static functions that EtherBoot finds out about
  1812. - as a result of a3c90x_probe setting entries in the nic structure
  1813. - for them. The EtherBoot framework does not use interrupts. It is
  1814. - polled. All transmit and receive operations are initiated by the
  1815. - etherboot framework, not by an interrupt or by the driver.
  1816. -
  1817. - C. Internal Functions
  1818. -
  1819. - The following functions are internal to the driver:
  1820. -
  1821. - a3c90x_internal_IssueCommand - sends a command to the 3c905b card.
  1822. - a3c90x_internal_SetWindow - shifts between one of eight register
  1823. - windows onboard the 3c90x. The bottom 16 bytes of the card's
  1824. - I/O space are multiplexed among 128 bytes, only 16 of which are
  1825. - visible at any one time. This SetWindow function selects one of
  1826. - the eight sets.
  1827. - a3c90x_internal_ReadEeprom - reads a word (16 bits) from the
  1828. - card's onboard nvram. This is NOT the BIOS boot rom. This is
  1829. - where the card stores such things as its hardware address.
  1830. - a3c90x_internal_WriteEeprom - writes a word (16 bits) to the
  1831. - card's nvram, and recomputes the eeprom checksum.
  1832. - a3c90x_internal_WriteEepromWord - writes a word (16 bits) to the
  1833. - card's nvram. Used by the above routine.
  1834. - a3c90x_internal_WriteEepromWord - writes a word (16 bits) to the
  1835. - card's nvram. Used by the above routine.
  1836. -
  1837. - D. Globals
  1838. -
  1839. - All global variables are inside a global structure named INF_3C90X.
  1840. - So, wherever you see that structure referenced, you know the variable
  1841. - is a global. Just keeps things a little neater.
  1842. -
  1843. - E. Enumerations
  1844. -
  1845. - There are quite a few enumerated type definitions for registers and
  1846. - so forth, many for registers that I didn't even touch in the driver.
  1847. - Register types start with 'reg', window numbers (for SetWindow)
  1848. - start with 'win', and commands (for IssueCommand) start with 'cmd'.
  1849. - Register offsets also include an indication in the name as to the
  1850. - size of the register (_b = byte, _w = word, _l = long), and which
  1851. - window the register is in, if it is windowed (0-7).
  1852. -
  1853. - F. Why the 'a3c90x' name?
  1854. -
  1855. - I had to come up with a letter at the beginning of all of the
  1856. - identifiers, since 3com so conveniently had their name start with a
  1857. - number. Another driver used 't' (for 'three'?); I chose 'a' for
  1858. - no reason at all.
  1859. -
  1860. -Addendum by Jorge L. deLyra <delyra@latt.if.usp.br>, 22Nov2000 re
  1861. -working around the 3C905 hardware bug mentioned above:
  1862. -
  1863. -Use this floppy to fix any 3COM model 3C905B PCI 10/100 Ethernet cards
  1864. -that fail to load and run the boot program the first time around. If
  1865. -they have a "Lucent" rather than a "Broadcom" chipset these cards have
  1866. -a configuration bug that causes a hang when trying to load the boot
  1867. -program from the PROM, if you try to use them right out of the box.
  1868. -
  1869. -The boot program in this floppy is the file named 3c905b-tpo100.rom
  1870. -from Etherboot version 4.6.10, compiled with the bugfix parameter
  1871. -
  1872. - CFG_3C90X_BOOTROM_FIX
  1873. -
  1874. -You have to take the chip off the card and boot the system once using
  1875. -this floppy. Once loaded from the floppy, the boot program will access
  1876. -the card and change some setting in it, correcting the problem. After
  1877. -that you may use either this boot program or the normal one, compiled
  1878. -without this bugfix parameter, to boot the machine from the PROM chip.
  1879. -
  1880. -[Any recent Etherboot version should do, not just 4.6.10 - Ed.]
  1881. Index: b/netboot/Makefile.am
  1882. ===================================================================
  1883. --- a/netboot/Makefile.am
  1884. +++ b/netboot/Makefile.am
  1885. @@ -10,58 +10,72 @@
  1886. noinst_LIBRARIES = $(LIBDRIVERS)
  1887. -libdrivers_a_SOURCES = cards.h config.c etherboot.h \
  1888. - fsys_tftp.c linux-asm-io.h linux-asm-string.h \
  1889. - main.c misc.c nic.h osdep.h pci.c pci.h timer.c timer.h
  1890. -EXTRA_libdrivers_a_SOURCES = 3c509.c 3c509.h 3c595.c 3c595.h 3c90x.c \
  1891. - cs89x0.c cs89x0.h davicom.c depca.c eepro.c eepro100.c \
  1892. - epic100.c epic100.h fa311.c i82586.c lance.c natsemi.c \
  1893. - ni5010.c ns8390.c ns8390.h otulip.c otulip.h rtl8139.c \
  1894. - sis900.c sis900.h sk_g16.c sk_g16.h smc9000.c smc9000.h \
  1895. - tiara.c tlan.c tulip.c via-rhine.c w89c840.c
  1896. +libdrivers_a_SOURCES = big_bswap.h bootp.h byteswap.h config.c cpu.h \
  1897. + dev.h elf.h endian.h etherboot.h fsys_tftp.c grub.h \
  1898. + i386_byteswap.h i386_elf.h i386_endian.h i386_timer.c \
  1899. + if_arp.h if_ether.h igmp.h in.h io.h ip.h isa.h latch.h \
  1900. + little_bswap.h misc.c nic.c nic.h osdep.h pci.c pci.h \
  1901. + pci_ids.h pci_io.c stdint.h tftp.h timer.c timer.h \
  1902. + types.h udp.h mii.h pic8259.c pic8259.h pxe.h basemem.c segoff.h
  1903. +EXTRA_libdrivers_a_SOURCES = 3c595.c 3c595.h 3c90x.c davicom.c \
  1904. + e1000.c e1000_hw.h eepro100.c epic100.c epic100.h natsemi.c \
  1905. + ns8390.c ns8390.h pcnet32.c rtl8139.c sis900.c sis900.h \
  1906. + sundance.c tg3.c tg3.h tlan.c tlan.h tulip.c via-rhine.c \
  1907. + w89c840.c r8169.c forcedeth.c ns83820.c pnic.c pnic_api.c \
  1908. + undi.c undi.h
  1909. libdrivers_a_CFLAGS = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1910. -DFSYS_TFTP=1 $(NET_CFLAGS) $(NET_EXTRAFLAGS)
  1911. # Filled by configure.
  1912. libdrivers_a_LIBADD = @NETBOOT_DRIVERS@
  1913. libdrivers_a_DEPENDENCIES = $(libdrivers_a_LIBADD)
  1914. -EXTRA_DIST = README.netboot 3c90x.txt cs89x0.txt sis900.txt tulip.txt
  1915. +EXTRA_DIST = README.netboot
  1916. # These below are several special rules for the device drivers.
  1917. # We cannot use a simple rule for them...
  1918. # What objects are derived from a driver?
  1919. -3c509_drivers = 3c509.o 3c529.o
  1920. +#3c509_drivers = 3c509.o 3c529.o
  1921. 3c595_drivers = 3c595.o
  1922. 3c90x_drivers = 3c90x.o
  1923. -cs89x0_drivers = cs89x0.o
  1924. +#cs89x0_drivers = cs89x0.o
  1925. davicom_drivers = davicom.o
  1926. -depca_drivers = depca.o
  1927. -eepro_drivers = eepro.o
  1928. +#depca_drivers = depca.o
  1929. +#eepro_drivers = eepro.o
  1930. +e1000_drivers = e1000.o
  1931. eepro100_drivers = eepro100.o
  1932. epic100_drivers = epic100.o
  1933. #fa311_drivers = fa311.o
  1934. -i82586_drivers = 3c507.o exos205.o ni5210.o
  1935. -lance_drivers = lance.o ne2100.o ni6510.o
  1936. +forcedeth_drivers = forcedeth.o
  1937. +#i82586_drivers = 3c507.o exos205.o ni5210.o
  1938. +#lance_drivers = lance.o ne2100.o ni6510.o
  1939. natsemi_drivers = natsemi.o
  1940. -ni5010_drivers = ni5010.o
  1941. +#ni5010_drivers = ni5010.o
  1942. +ns83820_drivers = ns83820.o
  1943. ns8390_drivers = 3c503.o ne.o ns8390.o wd.o
  1944. -otulip_drivers = otulip.o
  1945. +#otulip_drivers = otulip.o
  1946. +pcnet32_drivers = pcnet32.o
  1947. +pnic_drivers = pnic.o
  1948. +r8169_drivers = r8169.o
  1949. rtl8139_drivers = rtl8139.o
  1950. sis900_drivers = sis900.o
  1951. -sk_g16_drivers = sk_g16.o
  1952. -smc9000_drivers = smc9000.o
  1953. -tiara_drivers = tiara.o
  1954. -#tlan_drivers = tlan.o
  1955. +#sk_g16_drivers = sk_g16.o
  1956. +sundance_driver = sundance.o
  1957. +#smc9000_drivers = smc9000.o
  1958. +tg3_drivers = tg3.o
  1959. +#tiara_drivers = tiara.o
  1960. +tlan_drivers = tlan.o
  1961. tulip_drivers = tulip.o
  1962. +undi_drivers = undi.o
  1963. via_rhine_drivers = via_rhine.o
  1964. w89c840_drivers = w89c840.o
  1965. +
  1966. # Is it really necessary to specify dependecies explicitly?
  1967. -$(3c509_drivers): 3c509.c 3c509.h
  1968. -$(3c509_drivers): %.o: 3c509.c
  1969. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1970. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1971. +#$(3c509_drivers): 3c509.c 3c509.h
  1972. +#$(3c509_drivers): %.o: 3c509.c
  1973. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1974. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1975. $(3c595_drivers): 3c595.c 3c595.h
  1976. $(3c595_drivers): %.o: 3c595.c
  1977. @@ -73,23 +87,28 @@
  1978. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1979. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1980. -$(cs89x0_drivers): cs89x0.c cs89x0.h
  1981. -$(cs89x0_drivers): %.o: cs89x0.c
  1982. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1983. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1984. +#$(cs89x0_drivers): cs89x0.c cs89x0.h
  1985. +#$(cs89x0_drivers): %.o: cs89x0.c
  1986. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1987. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1988. $(davicom_drivers): davicom.c
  1989. $(davicom_drivers): %.o: davicom.c
  1990. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1991. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1992. -$(depca_drivers): depca.c
  1993. -$(depca_drivers): %.o: depca.c
  1994. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1995. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1996. +#$(depca_drivers): depca.c
  1997. +#$(depca_drivers): %.o: depca.c
  1998. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1999. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2000. +
  2001. +#$(eepro_drivers): eepro.c
  2002. +#$(eepro_drivers): %.o: eepro.c
  2003. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2004. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2005. -$(eepro_drivers): eepro.c
  2006. -$(eepro_drivers): %.o: eepro.c
  2007. +$(e1000_drivers): e1000.c e1000_hw.h
  2008. +$(e1000_drivers): %.o: e1000.c
  2009. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2010. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2011. @@ -103,28 +122,38 @@
  2012. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2013. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2014. +$(forcedeth_drivers): forcedeth.c
  2015. +$(forcedeth_drivers): %.o: forcedeth.c
  2016. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2017. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2018. +
  2019. #$(fa311_drivers): fa311.c
  2020. #$(fa311_drivers): %.o: fa311.c
  2021. # $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2022. # $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2023. -$(i82586_drivers): i82586.c
  2024. -$(i82586_drivers): %.o: i82586.c
  2025. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2026. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2027. +#$(i82586_drivers): i82586.c
  2028. +#$(i82586_drivers): %.o: i82586.c
  2029. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2030. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2031. -$(lance_drivers): lance.c
  2032. -$(lance_drivers): %.o: lance.c
  2033. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2034. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2035. +#$(lance_drivers): lance.c
  2036. +#$(lance_drivers): %.o: lance.c
  2037. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2038. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2039. $(natsemi_drivers): natsemi.c
  2040. $(natsemi_drivers): %.o: natsemi.c
  2041. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2042. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2043. -$(ni5010_drivers): ni5010.c
  2044. -$(ni5010_drivers): %.o: ni5010.c
  2045. +#$(ni5010_drivers): ni5010.c
  2046. +#$(ni5010_drivers): %.o: ni5010.c
  2047. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2048. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2049. +
  2050. +$(ns83820_drivers): ns83820.c
  2051. +$(ns83820_drivers): %.o: ns83820.c
  2052. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2053. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2054. @@ -133,8 +162,18 @@
  2055. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2056. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2057. -$(otulip_drivers): otulip.c otulip.h
  2058. -$(otulip_drivers): %.o: otulip.c
  2059. +#$(otulip_drivers): otulip.c otulip.h
  2060. +#$(otulip_drivers): %.o: otulip.c
  2061. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2062. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2063. +
  2064. +$(pcnet32_drivers): pcnet32.c
  2065. +$(pcnet32_drivers): %.o: pcnet32.c
  2066. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2067. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2068. +
  2069. +$(pnic_drivers): pnic.c
  2070. +$(pnic_drivers): %.o: pnic.c pnic_api.h
  2071. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2072. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2073. @@ -143,36 +182,56 @@
  2074. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2075. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2076. -$(sis900_drivers): sis900.c
  2077. -$(sis900_drivers): %.o: sis900.c sis900.h
  2078. +$(r8169_drivers): r8169.c
  2079. +$(r8169_drivers): %.o: r8169.c
  2080. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2081. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2082. -$(sk_g16_drivers): sk_g16.c sk_g16.h
  2083. -$(sk_g16_drivers): %.o: sk_g16.c
  2084. +$(sis900_drivers): sis900.c sis900.h
  2085. +$(sis900_drivers): %.o: sis900.c
  2086. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2087. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2088. -$(smc9000_drivers): smc9000.c smc9000.h
  2089. -$(smc9000_drivers): %.o: smc9000.c
  2090. +#$(sk_g16_drivers): sk_g16.c sk_g16.h
  2091. +#$(sk_g16_drivers): %.o: sk_g16.c
  2092. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2093. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2094. +
  2095. +#$(smc9000_drivers): smc9000.c smc9000.h
  2096. +#$(smc9000_drivers): %.o: smc9000.c
  2097. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2098. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2099. +
  2100. +$(sundance_drivers): sundance.c
  2101. +$(sundance_drivers): %.o: sundance.c
  2102. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2103. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2104. -$(tiara_drivers): tiara.c
  2105. -$(tiara_drivers): %.o: tiara.c
  2106. +$(tg3_drivers): tg3.c tg3.h
  2107. +$(tg3_drivers): %.o: tg3.c
  2108. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2109. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2110. -#$(tlan_drivers): tlan.c
  2111. -#$(tlan_drivers): %.o: tlan.c
  2112. +#$(tiara_drivers): tiara.c
  2113. +#$(tiara_drivers): %.o: tiara.c
  2114. # $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2115. # $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2116. +$(tlan_drivers): tlan.c tlan.h
  2117. +$(tlan_drivers): %.o: tlan.c
  2118. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2119. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2120. +
  2121. $(tulip_drivers): tulip.c
  2122. $(tulip_drivers): %.o: tulip.c
  2123. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2124. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2125. +$(undi_drivers): undi.c undi.h
  2126. +$(undi_drivers): %.o: undi.c
  2127. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2128. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2129. +
  2130. $(via_rhine_drivers): via-rhine.c
  2131. $(via_rhine_drivers): %.o: via-rhine.c
  2132. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2133. @@ -184,36 +243,45 @@
  2134. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2135. # Per-object flags.
  2136. -3c509_o_CFLAGS = -DINCLUDE_3C509=1
  2137. -3c529_o_CFLAGS = -DINCLUDE_3C529=1
  2138. +#3c509_o_CFLAGS = -DINCLUDE_3C509=1
  2139. +#3c529_o_CFLAGS = -DINCLUDE_3C529=1
  2140. 3c595_o_CFLAGS = -DINCLUDE_3C595=1
  2141. 3c90x_o_CFLAGS = -DINCLUDE_3C90X=1
  2142. -cs89x0_o_CFLAGS = -DINCLUDE_CS89X0=1
  2143. +#cs89x0_o_CFLAGS = -DINCLUDE_CS89X0=1
  2144. davicom_o_CFLAGS = -DINCLUDE_DAVICOM=1
  2145. -depca_o_CFLAGS = -DINCLUDE_DEPCA=1
  2146. -eepro_o_CFLAGS = -DINCLUDE_EEPRO=1
  2147. +#depca_o_CFLAGS = -DINCLUDE_DEPCA=1
  2148. +#eepro_o_CFLAGS = -DINCLUDE_EEPRO=1
  2149. +e1000_o_CFLAGS = -DINCLUDE_E1000=1
  2150. eepro100_o_CFLAGS = -DINCLUDE_EEPRO100=1
  2151. epic100_o_CFLAGS = -DINCLUDE_EPIC100=1
  2152. #fa311_o_CFLAGS = -DINCLUDE_FA311=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. +forcedeth_o_CFLAGS = -DINCLUDE_FORCEDETH=1
  2160. +#3c507_o_CFLAGS = -DINCLUDE_3C507=1
  2161. +#exos205_o_CFLAGS = -DINCLUDE_EXOS205=1
  2162. +#ni5210_o_CFLAGS = -DINCLUDE_NI5210=1
  2163. +#lance_o_CFLAGS = -DINCLUDE_LANCE=1
  2164. +#ne2100_o_CFLAGS = -DINCLUDE_NE2100=1
  2165. +#ni6510_o_CFLAGS = -DINCLUDE_NI6510=1
  2166. natsemi_o_CFLAGS = -DINCLUDE_NATSEMI=1
  2167. -ni5010_o_CFLAGS = -DINCLUDE_NI5010=1
  2168. -3c503_o_CFLAGS = -DINCLUDE_3C503=1
  2169. -ne_o_CFLAGS = -DINCLUDE_NE=1
  2170. +#ni5010_o_CFLAGS = -DINCLUDE_NI5010=1
  2171. +#3c503_o_CFLAGS = -DINCLUDE_3C503=1
  2172. +#ne_o_CFLAGS = -DINCLUDE_NE=1
  2173. +ns83820_o_CFLAGS = -DINCLUDE_NS83820=1
  2174. ns8390_o_CFLAGS = -DINCLUDE_NS8390=1
  2175. -wd_o_CFLAGS = -DINCLUDE_WD=1
  2176. -otulip_o_CFLAGS = -DINCLUDE_OTULIP=1
  2177. +#wd_o_CFLAGS = -DINCLUDE_WD=1
  2178. +#otulip_o_CFLAGS = -DINCLUDE_OTULIP=1
  2179. +pcnet32_o_CFLAGS = -DINCLUDE_PCNET32=1
  2180. +pnic_o_CFLAGS = -DINCLUDE_PNIC=1
  2181. +r8169_o_CFLAGS = -DINCLUDE_R8169=1
  2182. rtl8139_o_CFLAGS = -DINCLUDE_RTL8139=1
  2183. sis900_o_CFLAGS = -DINCLUDE_SIS900=1
  2184. -sk_g16_o_CFLAGS = -DINCLUDE_SK_G16=1
  2185. -smc9000_o_CFLAGS = -DINCLUDE_SMC9000=1
  2186. -tiara_o_CFLAGS = -DINCLUDE_TIARA=1
  2187. -#tlan_o_CFLAGS = -DINCLUDE_TLAN=1
  2188. +#sk_g16_o_CFLAGS = -DINCLUDE_SK_G16=1
  2189. +#smc9000_o_CFLAGS = -DINCLUDE_SMC9000=1
  2190. +sundance_o_CFLAGS = -DINCLUDE_SUNDANCE=1
  2191. +#tiara_o_CFLAGS = -DINCLUDE_TIARA=1
  2192. +tg3_o_CFLAGS = -DINCLUDE_TG3=1
  2193. +tlan_o_CFLAGS = -DINCLUDE_TLAN=1
  2194. tulip_o_CFLAGS = -DINCLUDE_TULIP=1
  2195. +undi_o_CFLAGS = -DINCLUDE_UNDI=1
  2196. via_rhine_o_CFLAGS = -DINCLUDE_VIA_RHINE=1
  2197. w89c840_o_CFLAGS = -DINCLUDE_W89C840=1
  2198. Index: b/netboot/Makefile.in
  2199. ===================================================================
  2200. --- a/netboot/Makefile.in
  2201. +++ b/netboot/Makefile.in
  2202. @@ -46,18 +46,51 @@
  2203. mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
  2204. CONFIG_HEADER = $(top_builddir)/config.h
  2205. CONFIG_CLEAN_FILES =
  2206. -LIBRARIES = $(noinst_LIBRARIES)
  2207. AR = ar
  2208. ARFLAGS = cru
  2209. +LIBRARIES = $(noinst_LIBRARIES)
  2210. libdrivers_a_AR = $(AR) $(ARFLAGS)
  2211. am_libdrivers_a_OBJECTS = libdrivers_a-config.$(OBJEXT) \
  2212. - libdrivers_a-fsys_tftp.$(OBJEXT) libdrivers_a-main.$(OBJEXT) \
  2213. - libdrivers_a-misc.$(OBJEXT) libdrivers_a-pci.$(OBJEXT) \
  2214. - libdrivers_a-timer.$(OBJEXT)
  2215. + libdrivers_a-fsys_tftp.$(OBJEXT) \
  2216. + libdrivers_a-i386_timer.$(OBJEXT) libdrivers_a-misc.$(OBJEXT) \
  2217. + libdrivers_a-nic.$(OBJEXT) libdrivers_a-pci.$(OBJEXT) \
  2218. + libdrivers_a-pci_io.$(OBJEXT) libdrivers_a-timer.$(OBJEXT) \
  2219. + libdrivers_a-pic8259.$(OBJEXT) libdrivers_a-basemem.$(OBJEXT)
  2220. libdrivers_a_OBJECTS = $(am_libdrivers_a_OBJECTS)
  2221. DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
  2222. depcomp = $(SHELL) $(top_srcdir)/depcomp
  2223. am__depfiles_maybe = depfiles
  2224. +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/libdrivers_a-3c595.Po \
  2225. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-3c90x.Po \
  2226. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-basemem.Po \
  2227. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-config.Po \
  2228. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-davicom.Po \
  2229. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-e1000.Po \
  2230. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-eepro100.Po \
  2231. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-epic100.Po \
  2232. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-forcedeth.Po \
  2233. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-fsys_tftp.Po \
  2234. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-i386_timer.Po \
  2235. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-misc.Po \
  2236. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-natsemi.Po \
  2237. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-nic.Po \
  2238. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-ns83820.Po \
  2239. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-ns8390.Po \
  2240. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pci.Po \
  2241. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pci_io.Po \
  2242. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pcnet32.Po \
  2243. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pic8259.Po \
  2244. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pnic.Po \
  2245. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pnic_api.Po \
  2246. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-r8169.Po \
  2247. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-rtl8139.Po \
  2248. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-sis900.Po \
  2249. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-tg3.Po \
  2250. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-timer.Po \
  2251. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-tlan.Po \
  2252. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-tulip.Po \
  2253. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-via-rhine.Po \
  2254. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-w89c840.Po
  2255. COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
  2256. $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
  2257. CCLD = $(CC)
  2258. @@ -148,8 +181,6 @@
  2259. am__include = @am__include@
  2260. am__leading_dot = @am__leading_dot@
  2261. am__quote = @am__quote@
  2262. -am__tar = @am__tar@
  2263. -am__untar = @am__untar@
  2264. bindir = @bindir@
  2265. build = @build@
  2266. build_alias = @build_alias@
  2267. @@ -186,16 +217,19 @@
  2268. # Don't build the netboot support by default.
  2269. @NETBOOT_SUPPORT_TRUE@LIBDRIVERS = libdrivers.a
  2270. noinst_LIBRARIES = $(LIBDRIVERS)
  2271. -libdrivers_a_SOURCES = cards.h config.c etherboot.h \
  2272. - fsys_tftp.c linux-asm-io.h linux-asm-string.h \
  2273. - main.c misc.c nic.h osdep.h pci.c pci.h timer.c timer.h
  2274. -
  2275. -EXTRA_libdrivers_a_SOURCES = 3c509.c 3c509.h 3c595.c 3c595.h 3c90x.c \
  2276. - cs89x0.c cs89x0.h davicom.c depca.c eepro.c eepro100.c \
  2277. - epic100.c epic100.h fa311.c i82586.c lance.c natsemi.c \
  2278. - ni5010.c ns8390.c ns8390.h otulip.c otulip.h rtl8139.c \
  2279. - sis900.c sis900.h sk_g16.c sk_g16.h smc9000.c smc9000.h \
  2280. - tiara.c tlan.c tulip.c via-rhine.c w89c840.c
  2281. +libdrivers_a_SOURCES = big_bswap.h bootp.h byteswap.h config.c cpu.h \
  2282. + dev.h elf.h endian.h etherboot.h fsys_tftp.c grub.h \
  2283. + i386_byteswap.h i386_elf.h i386_endian.h i386_timer.c \
  2284. + if_arp.h if_ether.h igmp.h in.h io.h ip.h isa.h latch.h \
  2285. + little_bswap.h misc.c nic.c nic.h osdep.h pci.c pci.h \
  2286. + pci_ids.h pci_io.c stdint.h tftp.h timer.c timer.h \
  2287. + types.h udp.h mii.h pic8259.c pic8259.h pxe.h basemem.c segoff.h
  2288. +
  2289. +EXTRA_libdrivers_a_SOURCES = 3c595.c 3c595.h 3c90x.c davicom.c \
  2290. + e1000.c e1000_hw.h eepro100.c epic100.c epic100.h natsemi.c \
  2291. + ns8390.c ns8390.h pcnet32.c rtl8139.c sis900.c sis900.h \
  2292. + tg3.c tg3.h tlan.c tlan.h tulip.c via-rhine.c \
  2293. + w89c840.c r8169.c forcedeth.c ns83820.c pnic.c pnic_api.c
  2294. libdrivers_a_CFLAGS = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2295. -DFSYS_TFTP=1 $(NET_CFLAGS) $(NET_EXTRAFLAGS)
  2296. @@ -203,69 +237,83 @@
  2297. # Filled by configure.
  2298. libdrivers_a_LIBADD = @NETBOOT_DRIVERS@
  2299. libdrivers_a_DEPENDENCIES = $(libdrivers_a_LIBADD)
  2300. -EXTRA_DIST = README.netboot 3c90x.txt cs89x0.txt sis900.txt tulip.txt
  2301. +EXTRA_DIST = README.netboot
  2302. # These below are several special rules for the device drivers.
  2303. # We cannot use a simple rule for them...
  2304. # What objects are derived from a driver?
  2305. -3c509_drivers = 3c509.o 3c529.o
  2306. +#3c509_drivers = 3c509.o 3c529.o
  2307. 3c595_drivers = 3c595.o
  2308. 3c90x_drivers = 3c90x.o
  2309. -cs89x0_drivers = cs89x0.o
  2310. +#cs89x0_drivers = cs89x0.o
  2311. davicom_drivers = davicom.o
  2312. -depca_drivers = depca.o
  2313. -eepro_drivers = eepro.o
  2314. +#depca_drivers = depca.o
  2315. +#eepro_drivers = eepro.o
  2316. +e1000_drivers = e1000.o
  2317. eepro100_drivers = eepro100.o
  2318. epic100_drivers = epic100.o
  2319. #fa311_drivers = fa311.o
  2320. -i82586_drivers = 3c507.o exos205.o ni5210.o
  2321. -lance_drivers = lance.o ne2100.o ni6510.o
  2322. +forcedeth_drivers = forcedeth.o
  2323. +#i82586_drivers = 3c507.o exos205.o ni5210.o
  2324. +#lance_drivers = lance.o ne2100.o ni6510.o
  2325. natsemi_drivers = natsemi.o
  2326. -ni5010_drivers = ni5010.o
  2327. +#ni5010_drivers = ni5010.o
  2328. +ns83820_drivers = ns83820.o
  2329. ns8390_drivers = 3c503.o ne.o ns8390.o wd.o
  2330. -otulip_drivers = otulip.o
  2331. +#otulip_drivers = otulip.o
  2332. +pcnet32_drivers = pcnet32.o
  2333. +pnic_drivers = pnic.o
  2334. +r8169_drivers = r8169.o
  2335. rtl8139_drivers = rtl8139.o
  2336. sis900_drivers = sis900.o
  2337. -sk_g16_drivers = sk_g16.o
  2338. -smc9000_drivers = smc9000.o
  2339. -tiara_drivers = tiara.o
  2340. -#tlan_drivers = tlan.o
  2341. +#sk_g16_drivers = sk_g16.o
  2342. +#smc9000_drivers = smc9000.o
  2343. +tg3_drivers = tg3.o
  2344. +#tiara_drivers = tiara.o
  2345. +tlan_drivers = tlan.o
  2346. tulip_drivers = tulip.o
  2347. via_rhine_drivers = via_rhine.o
  2348. w89c840_drivers = w89c840.o
  2349. # Per-object flags.
  2350. -3c509_o_CFLAGS = -DINCLUDE_3C509=1
  2351. -3c529_o_CFLAGS = -DINCLUDE_3C529=1
  2352. +#3c509_o_CFLAGS = -DINCLUDE_3C509=1
  2353. +#3c529_o_CFLAGS = -DINCLUDE_3C529=1
  2354. 3c595_o_CFLAGS = -DINCLUDE_3C595=1
  2355. 3c90x_o_CFLAGS = -DINCLUDE_3C90X=1
  2356. -cs89x0_o_CFLAGS = -DINCLUDE_CS89X0=1
  2357. +#cs89x0_o_CFLAGS = -DINCLUDE_CS89X0=1
  2358. davicom_o_CFLAGS = -DINCLUDE_DAVICOM=1
  2359. -depca_o_CFLAGS = -DINCLUDE_DEPCA=1
  2360. -eepro_o_CFLAGS = -DINCLUDE_EEPRO=1
  2361. +#depca_o_CFLAGS = -DINCLUDE_DEPCA=1
  2362. +#eepro_o_CFLAGS = -DINCLUDE_EEPRO=1
  2363. +e1000_o_CFLAGS = -DINCLUDE_E1000=1
  2364. eepro100_o_CFLAGS = -DINCLUDE_EEPRO100=1
  2365. epic100_o_CFLAGS = -DINCLUDE_EPIC100=1
  2366. #fa311_o_CFLAGS = -DINCLUDE_FA311=1
  2367. -3c507_o_CFLAGS = -DINCLUDE_3C507=1
  2368. -exos205_o_CFLAGS = -DINCLUDE_EXOS205=1
  2369. -ni5210_o_CFLAGS = -DINCLUDE_NI5210=1
  2370. -lance_o_CFLAGS = -DINCLUDE_LANCE=1
  2371. -ne2100_o_CFLAGS = -DINCLUDE_NE2100=1
  2372. -ni6510_o_CFLAGS = -DINCLUDE_NI6510=1
  2373. +forcedeth_o_CFLAGS = -DINCLUDE_FORCEDETH=1
  2374. +#3c507_o_CFLAGS = -DINCLUDE_3C507=1
  2375. +#exos205_o_CFLAGS = -DINCLUDE_EXOS205=1
  2376. +#ni5210_o_CFLAGS = -DINCLUDE_NI5210=1
  2377. +#lance_o_CFLAGS = -DINCLUDE_LANCE=1
  2378. +#ne2100_o_CFLAGS = -DINCLUDE_NE2100=1
  2379. +#ni6510_o_CFLAGS = -DINCLUDE_NI6510=1
  2380. natsemi_o_CFLAGS = -DINCLUDE_NATSEMI=1
  2381. -ni5010_o_CFLAGS = -DINCLUDE_NI5010=1
  2382. -3c503_o_CFLAGS = -DINCLUDE_3C503=1
  2383. -ne_o_CFLAGS = -DINCLUDE_NE=1
  2384. +#ni5010_o_CFLAGS = -DINCLUDE_NI5010=1
  2385. +#3c503_o_CFLAGS = -DINCLUDE_3C503=1
  2386. +#ne_o_CFLAGS = -DINCLUDE_NE=1
  2387. +ns83820_o_CFLAGS = -DINCLUDE_NS83820=1
  2388. ns8390_o_CFLAGS = -DINCLUDE_NS8390=1
  2389. -wd_o_CFLAGS = -DINCLUDE_WD=1
  2390. -otulip_o_CFLAGS = -DINCLUDE_OTULIP=1
  2391. +#wd_o_CFLAGS = -DINCLUDE_WD=1
  2392. +#otulip_o_CFLAGS = -DINCLUDE_OTULIP=1
  2393. +pcnet32_o_CFLAGS = -DINCLUDE_PCNET32=1
  2394. +pnic_o_CFLAGS = -DINCLUDE_PNIC=1
  2395. +r8169_o_CFLAGS = -DINCLUDE_R8169=1
  2396. rtl8139_o_CFLAGS = -DINCLUDE_RTL8139=1
  2397. sis900_o_CFLAGS = -DINCLUDE_SIS900=1
  2398. -sk_g16_o_CFLAGS = -DINCLUDE_SK_G16=1
  2399. -smc9000_o_CFLAGS = -DINCLUDE_SMC9000=1
  2400. -tiara_o_CFLAGS = -DINCLUDE_TIARA=1
  2401. -#tlan_o_CFLAGS = -DINCLUDE_TLAN=1
  2402. +#sk_g16_o_CFLAGS = -DINCLUDE_SK_G16=1
  2403. +#smc9000_o_CFLAGS = -DINCLUDE_SMC9000=1
  2404. +#tiara_o_CFLAGS = -DINCLUDE_TIARA=1
  2405. +tg3_o_CFLAGS = -DINCLUDE_TG3=1
  2406. +tlan_o_CFLAGS = -DINCLUDE_TLAN=1
  2407. tulip_o_CFLAGS = -DINCLUDE_TULIP=1
  2408. via_rhine_o_CFLAGS = -DINCLUDE_VIA_RHINE=1
  2409. w89c840_o_CFLAGS = -DINCLUDE_W89C840=1
  2410. @@ -316,32 +364,32 @@
  2411. distclean-compile:
  2412. -rm -f *.tab.c
  2413. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-3c509.Po@am__quote@
  2414. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-3c595.Po@am__quote@
  2415. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-3c90x.Po@am__quote@
  2416. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-basemem.Po@am__quote@
  2417. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-config.Po@am__quote@
  2418. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-cs89x0.Po@am__quote@
  2419. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-davicom.Po@am__quote@
  2420. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-depca.Po@am__quote@
  2421. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-eepro.Po@am__quote@
  2422. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-e1000.Po@am__quote@
  2423. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-eepro100.Po@am__quote@
  2424. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-epic100.Po@am__quote@
  2425. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-fa311.Po@am__quote@
  2426. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-forcedeth.Po@am__quote@
  2427. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-fsys_tftp.Po@am__quote@
  2428. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-i82586.Po@am__quote@
  2429. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-lance.Po@am__quote@
  2430. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-main.Po@am__quote@
  2431. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-i386_timer.Po@am__quote@
  2432. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-misc.Po@am__quote@
  2433. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-natsemi.Po@am__quote@
  2434. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-ni5010.Po@am__quote@
  2435. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-nic.Po@am__quote@
  2436. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-ns83820.Po@am__quote@
  2437. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-ns8390.Po@am__quote@
  2438. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-otulip.Po@am__quote@
  2439. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pci.Po@am__quote@
  2440. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pci_io.Po@am__quote@
  2441. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pcnet32.Po@am__quote@
  2442. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pic8259.Po@am__quote@
  2443. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pnic.Po@am__quote@
  2444. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pnic_api.Po@am__quote@
  2445. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-r8169.Po@am__quote@
  2446. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-rtl8139.Po@am__quote@
  2447. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-sis900.Po@am__quote@
  2448. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-sk_g16.Po@am__quote@
  2449. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-smc9000.Po@am__quote@
  2450. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-tiara.Po@am__quote@
  2451. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-tg3.Po@am__quote@
  2452. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-timer.Po@am__quote@
  2453. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-tlan.Po@am__quote@
  2454. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-tulip.Po@am__quote@
  2455. @@ -352,450 +400,513 @@
  2456. @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
  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 $<
  2463. .c.obj:
  2464. @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
  2465. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
  2466. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
  2467. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2468. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
  2469. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2470. @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
  2471. libdrivers_a-config.o: config.c
  2472. @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; \
  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.o' 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.o `test -f 'config.c' || echo '$(srcdir)/'`config.c
  2479. libdrivers_a-config.obj: config.c
  2480. @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`; \
  2481. @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
  2482. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config.c' object='libdrivers_a-config.obj' libtool=no @AMDEPBACKSLASH@
  2483. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2484. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-config.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-config.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-config.obj `if test -f 'config.c'; then $(CYGPATH_W) 'config.c'; else $(CYGPATH_W) '$(srcdir)/config.c'; fi`
  2487. libdrivers_a-fsys_tftp.o: 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.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; \
  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.o' 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.o `test -f 'fsys_tftp.c' || echo '$(srcdir)/'`fsys_tftp.c
  2495. libdrivers_a-fsys_tftp.obj: fsys_tftp.c
  2496. @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`; \
  2497. @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
  2498. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fsys_tftp.c' object='libdrivers_a-fsys_tftp.obj' libtool=no @AMDEPBACKSLASH@
  2499. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2500. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-fsys_tftp.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-fsys_tftp.TPo' @AMDEPBACKSLASH@
  2501. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2502. @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`
  2503. -libdrivers_a-main.o: main.c
  2504. -@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; \
  2505. -@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
  2506. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='libdrivers_a-main.o' libtool=no @AMDEPBACKSLASH@
  2507. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2508. -@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
  2509. -
  2510. -libdrivers_a-main.obj: main.c
  2511. -@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`; \
  2512. -@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
  2513. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='libdrivers_a-main.obj' libtool=no @AMDEPBACKSLASH@
  2514. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2515. -@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`
  2516. +libdrivers_a-i386_timer.o: 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.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; \
  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.o' 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.o `test -f 'i386_timer.c' || echo '$(srcdir)/'`i386_timer.c
  2523. +
  2524. +libdrivers_a-i386_timer.obj: i386_timer.c
  2525. +@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`; \
  2526. +@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
  2527. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='i386_timer.c' object='libdrivers_a-i386_timer.obj' libtool=no @AMDEPBACKSLASH@
  2528. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-i386_timer.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-i386_timer.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-i386_timer.obj `if test -f 'i386_timer.c'; then $(CYGPATH_W) 'i386_timer.c'; else $(CYGPATH_W) '$(srcdir)/i386_timer.c'; fi`
  2531. libdrivers_a-misc.o: misc.c
  2532. @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; \
  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.o' 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.o `test -f 'misc.c' || echo '$(srcdir)/'`misc.c
  2539. libdrivers_a-misc.obj: misc.c
  2540. @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`; \
  2541. @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
  2542. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='misc.c' object='libdrivers_a-misc.obj' libtool=no @AMDEPBACKSLASH@
  2543. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2544. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-misc.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-misc.TPo' @AMDEPBACKSLASH@
  2545. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2546. @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`
  2547. +libdrivers_a-nic.o: nic.c
  2548. +@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; \
  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.o' 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.o `test -f 'nic.c' || echo '$(srcdir)/'`nic.c
  2554. +
  2555. +libdrivers_a-nic.obj: nic.c
  2556. +@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`; \
  2557. +@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
  2558. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nic.c' object='libdrivers_a-nic.obj' libtool=no @AMDEPBACKSLASH@
  2559. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-nic.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-nic.TPo' @AMDEPBACKSLASH@
  2560. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2561. +@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`
  2562. +
  2563. libdrivers_a-pci.o: pci.c
  2564. @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; \
  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.o' 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.o `test -f 'pci.c' || echo '$(srcdir)/'`pci.c
  2571. libdrivers_a-pci.obj: pci.c
  2572. @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`; \
  2573. @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
  2574. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pci.c' object='libdrivers_a-pci.obj' libtool=no @AMDEPBACKSLASH@
  2575. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2576. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pci.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pci.TPo' @AMDEPBACKSLASH@
  2577. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2578. @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`
  2579. +libdrivers_a-pci_io.o: 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.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; \
  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.o' 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.o `test -f 'pci_io.c' || echo '$(srcdir)/'`pci_io.c
  2586. +
  2587. +libdrivers_a-pci_io.obj: pci_io.c
  2588. +@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`; \
  2589. +@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
  2590. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pci_io.c' object='libdrivers_a-pci_io.obj' libtool=no @AMDEPBACKSLASH@
  2591. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pci_io.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pci_io.TPo' @AMDEPBACKSLASH@
  2592. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2593. +@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`
  2594. +
  2595. libdrivers_a-timer.o: timer.c
  2596. @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; \
  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.o' 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.o `test -f 'timer.c' || echo '$(srcdir)/'`timer.c
  2603. libdrivers_a-timer.obj: timer.c
  2604. @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`; \
  2605. @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
  2606. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='timer.c' object='libdrivers_a-timer.obj' libtool=no @AMDEPBACKSLASH@
  2607. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2608. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-timer.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-timer.TPo' @AMDEPBACKSLASH@
  2609. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2610. @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`
  2611. -libdrivers_a-3c509.o: 3c509.c
  2612. -@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; \
  2613. -@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
  2614. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='3c509.c' object='libdrivers_a-3c509.o' libtool=no @AMDEPBACKSLASH@
  2615. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2616. -@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
  2617. -
  2618. -libdrivers_a-3c509.obj: 3c509.c
  2619. -@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`; \
  2620. -@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
  2621. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='3c509.c' object='libdrivers_a-3c509.obj' libtool=no @AMDEPBACKSLASH@
  2622. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2623. -@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`
  2624. +libdrivers_a-pic8259.o: pic8259.c
  2625. +@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; \
  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.o' 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.o `test -f 'pic8259.c' || echo '$(srcdir)/'`pic8259.c
  2631. +
  2632. +libdrivers_a-pic8259.obj: pic8259.c
  2633. +@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`; \
  2634. +@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
  2635. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pic8259.c' object='libdrivers_a-pic8259.obj' libtool=no @AMDEPBACKSLASH@
  2636. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pic8259.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pic8259.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-pic8259.obj `if test -f 'pic8259.c'; then $(CYGPATH_W) 'pic8259.c'; else $(CYGPATH_W) '$(srcdir)/pic8259.c'; fi`
  2639. +
  2640. +libdrivers_a-basemem.o: basemem.c
  2641. +@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; \
  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.o' 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.o `test -f 'basemem.c' || echo '$(srcdir)/'`basemem.c
  2647. +
  2648. +libdrivers_a-basemem.obj: basemem.c
  2649. +@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`; \
  2650. +@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
  2651. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='basemem.c' object='libdrivers_a-basemem.obj' libtool=no @AMDEPBACKSLASH@
  2652. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-basemem.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-basemem.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-basemem.obj `if test -f 'basemem.c'; then $(CYGPATH_W) 'basemem.c'; else $(CYGPATH_W) '$(srcdir)/basemem.c'; fi`
  2655. libdrivers_a-3c595.o: 3c595.c
  2656. @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; \
  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.o' 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.o `test -f '3c595.c' || echo '$(srcdir)/'`3c595.c
  2663. libdrivers_a-3c595.obj: 3c595.c
  2664. @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`; \
  2665. @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
  2666. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='3c595.c' object='libdrivers_a-3c595.obj' libtool=no @AMDEPBACKSLASH@
  2667. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2668. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-3c595.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-3c595.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-3c595.obj `if test -f '3c595.c'; then $(CYGPATH_W) '3c595.c'; else $(CYGPATH_W) '$(srcdir)/3c595.c'; fi`
  2671. libdrivers_a-3c90x.o: 3c90x.c
  2672. @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; \
  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.o' 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.o `test -f '3c90x.c' || echo '$(srcdir)/'`3c90x.c
  2679. libdrivers_a-3c90x.obj: 3c90x.c
  2680. @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`; \
  2681. @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
  2682. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='3c90x.c' object='libdrivers_a-3c90x.obj' libtool=no @AMDEPBACKSLASH@
  2683. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2684. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-3c90x.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-3c90x.TPo' @AMDEPBACKSLASH@
  2685. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2686. @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`
  2687. -libdrivers_a-cs89x0.o: cs89x0.c
  2688. -@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; \
  2689. -@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
  2690. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cs89x0.c' object='libdrivers_a-cs89x0.o' libtool=no @AMDEPBACKSLASH@
  2691. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2692. -@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
  2693. -
  2694. -libdrivers_a-cs89x0.obj: cs89x0.c
  2695. -@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`; \
  2696. -@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
  2697. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cs89x0.c' object='libdrivers_a-cs89x0.obj' libtool=no @AMDEPBACKSLASH@
  2698. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2699. -@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`
  2700. -
  2701. libdrivers_a-davicom.o: davicom.c
  2702. @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; \
  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.o' 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.o `test -f 'davicom.c' || echo '$(srcdir)/'`davicom.c
  2709. libdrivers_a-davicom.obj: davicom.c
  2710. @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`; \
  2711. @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
  2712. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='davicom.c' object='libdrivers_a-davicom.obj' libtool=no @AMDEPBACKSLASH@
  2713. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2714. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-davicom.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-davicom.TPo' @AMDEPBACKSLASH@
  2715. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2716. @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`
  2717. -libdrivers_a-depca.o: depca.c
  2718. -@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; \
  2719. -@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
  2720. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='depca.c' object='libdrivers_a-depca.o' libtool=no @AMDEPBACKSLASH@
  2721. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2722. -@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
  2723. -
  2724. -libdrivers_a-depca.obj: depca.c
  2725. -@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`; \
  2726. -@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
  2727. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='depca.c' object='libdrivers_a-depca.obj' libtool=no @AMDEPBACKSLASH@
  2728. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2729. -@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`
  2730. -
  2731. -libdrivers_a-eepro.o: eepro.c
  2732. -@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; \
  2733. -@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
  2734. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eepro.c' object='libdrivers_a-eepro.o' libtool=no @AMDEPBACKSLASH@
  2735. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2736. -@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
  2737. -
  2738. -libdrivers_a-eepro.obj: eepro.c
  2739. -@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`; \
  2740. -@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
  2741. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eepro.c' object='libdrivers_a-eepro.obj' libtool=no @AMDEPBACKSLASH@
  2742. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2743. -@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`
  2744. +libdrivers_a-e1000.o: e1000.c
  2745. +@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; \
  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.o' 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.o `test -f 'e1000.c' || echo '$(srcdir)/'`e1000.c
  2751. +
  2752. +libdrivers_a-e1000.obj: e1000.c
  2753. +@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`; \
  2754. +@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
  2755. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='e1000.c' object='libdrivers_a-e1000.obj' libtool=no @AMDEPBACKSLASH@
  2756. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-e1000.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-e1000.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-e1000.obj `if test -f 'e1000.c'; then $(CYGPATH_W) 'e1000.c'; else $(CYGPATH_W) '$(srcdir)/e1000.c'; fi`
  2759. libdrivers_a-eepro100.o: eepro100.c
  2760. @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; \
  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.o' 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.o `test -f 'eepro100.c' || echo '$(srcdir)/'`eepro100.c
  2767. libdrivers_a-eepro100.obj: eepro100.c
  2768. @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`; \
  2769. @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
  2770. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eepro100.c' object='libdrivers_a-eepro100.obj' libtool=no @AMDEPBACKSLASH@
  2771. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2772. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-eepro100.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-eepro100.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-eepro100.obj `if test -f 'eepro100.c'; then $(CYGPATH_W) 'eepro100.c'; else $(CYGPATH_W) '$(srcdir)/eepro100.c'; fi`
  2775. libdrivers_a-epic100.o: epic100.c
  2776. @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; \
  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.o' 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.o `test -f 'epic100.c' || echo '$(srcdir)/'`epic100.c
  2783. libdrivers_a-epic100.obj: epic100.c
  2784. @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`; \
  2785. @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
  2786. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='epic100.c' object='libdrivers_a-epic100.obj' libtool=no @AMDEPBACKSLASH@
  2787. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2788. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-epic100.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-epic100.TPo' @AMDEPBACKSLASH@
  2789. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2790. @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`
  2791. -libdrivers_a-fa311.o: fa311.c
  2792. -@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; \
  2793. -@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
  2794. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fa311.c' object='libdrivers_a-fa311.o' libtool=no @AMDEPBACKSLASH@
  2795. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2796. -@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
  2797. -
  2798. -libdrivers_a-fa311.obj: fa311.c
  2799. -@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`; \
  2800. -@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
  2801. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fa311.c' object='libdrivers_a-fa311.obj' libtool=no @AMDEPBACKSLASH@
  2802. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2803. -@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`
  2804. -
  2805. -libdrivers_a-i82586.o: i82586.c
  2806. -@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; \
  2807. -@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
  2808. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='i82586.c' object='libdrivers_a-i82586.o' libtool=no @AMDEPBACKSLASH@
  2809. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2810. -@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
  2811. -
  2812. -libdrivers_a-i82586.obj: i82586.c
  2813. -@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`; \
  2814. -@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
  2815. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='i82586.c' object='libdrivers_a-i82586.obj' libtool=no @AMDEPBACKSLASH@
  2816. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2817. -@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`
  2818. -
  2819. -libdrivers_a-lance.o: lance.c
  2820. -@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; \
  2821. -@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
  2822. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='lance.c' object='libdrivers_a-lance.o' libtool=no @AMDEPBACKSLASH@
  2823. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2824. -@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
  2825. -
  2826. -libdrivers_a-lance.obj: lance.c
  2827. -@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`; \
  2828. -@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
  2829. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='lance.c' object='libdrivers_a-lance.obj' libtool=no @AMDEPBACKSLASH@
  2830. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2831. -@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`
  2832. -
  2833. libdrivers_a-natsemi.o: natsemi.c
  2834. @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; \
  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.o' 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.o `test -f 'natsemi.c' || echo '$(srcdir)/'`natsemi.c
  2841. libdrivers_a-natsemi.obj: natsemi.c
  2842. @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`; \
  2843. @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
  2844. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='natsemi.c' object='libdrivers_a-natsemi.obj' libtool=no @AMDEPBACKSLASH@
  2845. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2846. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-natsemi.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-natsemi.TPo' @AMDEPBACKSLASH@
  2847. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2848. @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`
  2849. -libdrivers_a-ni5010.o: ni5010.c
  2850. -@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; \
  2851. -@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
  2852. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ni5010.c' object='libdrivers_a-ni5010.o' libtool=no @AMDEPBACKSLASH@
  2853. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2854. -@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
  2855. -
  2856. -libdrivers_a-ni5010.obj: ni5010.c
  2857. -@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`; \
  2858. -@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
  2859. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ni5010.c' object='libdrivers_a-ni5010.obj' libtool=no @AMDEPBACKSLASH@
  2860. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2861. -@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`
  2862. -
  2863. libdrivers_a-ns8390.o: ns8390.c
  2864. @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; \
  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.o' 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.o `test -f 'ns8390.c' || echo '$(srcdir)/'`ns8390.c
  2871. libdrivers_a-ns8390.obj: ns8390.c
  2872. @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`; \
  2873. @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
  2874. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ns8390.c' object='libdrivers_a-ns8390.obj' libtool=no @AMDEPBACKSLASH@
  2875. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2876. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-ns8390.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-ns8390.TPo' @AMDEPBACKSLASH@
  2877. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2878. @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`
  2879. -libdrivers_a-otulip.o: otulip.c
  2880. -@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; \
  2881. -@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
  2882. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='otulip.c' object='libdrivers_a-otulip.o' libtool=no @AMDEPBACKSLASH@
  2883. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2884. -@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
  2885. -
  2886. -libdrivers_a-otulip.obj: otulip.c
  2887. -@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`; \
  2888. -@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
  2889. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='otulip.c' object='libdrivers_a-otulip.obj' libtool=no @AMDEPBACKSLASH@
  2890. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2891. -@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`
  2892. +libdrivers_a-pcnet32.o: pcnet32.c
  2893. +@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; \
  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.o' 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.o `test -f 'pcnet32.c' || echo '$(srcdir)/'`pcnet32.c
  2899. +
  2900. +libdrivers_a-pcnet32.obj: pcnet32.c
  2901. +@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`; \
  2902. +@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
  2903. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pcnet32.c' object='libdrivers_a-pcnet32.obj' libtool=no @AMDEPBACKSLASH@
  2904. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pcnet32.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pcnet32.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-pcnet32.obj `if test -f 'pcnet32.c'; then $(CYGPATH_W) 'pcnet32.c'; else $(CYGPATH_W) '$(srcdir)/pcnet32.c'; fi`
  2907. libdrivers_a-rtl8139.o: rtl8139.c
  2908. @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; \
  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.o' 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.o `test -f 'rtl8139.c' || echo '$(srcdir)/'`rtl8139.c
  2915. libdrivers_a-rtl8139.obj: rtl8139.c
  2916. @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`; \
  2917. @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
  2918. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rtl8139.c' object='libdrivers_a-rtl8139.obj' libtool=no @AMDEPBACKSLASH@
  2919. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2920. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-rtl8139.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-rtl8139.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-rtl8139.obj `if test -f 'rtl8139.c'; then $(CYGPATH_W) 'rtl8139.c'; else $(CYGPATH_W) '$(srcdir)/rtl8139.c'; fi`
  2923. libdrivers_a-sis900.o: sis900.c
  2924. @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; \
  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.o' 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.o `test -f 'sis900.c' || echo '$(srcdir)/'`sis900.c
  2931. libdrivers_a-sis900.obj: sis900.c
  2932. @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`; \
  2933. @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
  2934. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sis900.c' object='libdrivers_a-sis900.obj' libtool=no @AMDEPBACKSLASH@
  2935. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2936. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-sis900.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-sis900.TPo' @AMDEPBACKSLASH@
  2937. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2938. @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`
  2939. -libdrivers_a-sk_g16.o: sk_g16.c
  2940. -@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; \
  2941. -@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
  2942. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sk_g16.c' object='libdrivers_a-sk_g16.o' libtool=no @AMDEPBACKSLASH@
  2943. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2944. -@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
  2945. -
  2946. -libdrivers_a-sk_g16.obj: sk_g16.c
  2947. -@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`; \
  2948. -@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
  2949. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sk_g16.c' object='libdrivers_a-sk_g16.obj' libtool=no @AMDEPBACKSLASH@
  2950. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2951. -@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`
  2952. -
  2953. -libdrivers_a-smc9000.o: smc9000.c
  2954. -@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; \
  2955. -@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
  2956. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='smc9000.c' object='libdrivers_a-smc9000.o' libtool=no @AMDEPBACKSLASH@
  2957. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2958. -@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
  2959. -
  2960. -libdrivers_a-smc9000.obj: smc9000.c
  2961. -@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`; \
  2962. -@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
  2963. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='smc9000.c' object='libdrivers_a-smc9000.obj' libtool=no @AMDEPBACKSLASH@
  2964. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2965. -@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`
  2966. -
  2967. -libdrivers_a-tiara.o: tiara.c
  2968. -@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; \
  2969. -@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
  2970. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tiara.c' object='libdrivers_a-tiara.o' libtool=no @AMDEPBACKSLASH@
  2971. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2972. -@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
  2973. -
  2974. -libdrivers_a-tiara.obj: tiara.c
  2975. -@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`; \
  2976. -@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
  2977. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tiara.c' object='libdrivers_a-tiara.obj' libtool=no @AMDEPBACKSLASH@
  2978. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2979. -@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`
  2980. +libdrivers_a-tg3.o: tg3.c
  2981. +@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; \
  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.o' 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.o `test -f 'tg3.c' || echo '$(srcdir)/'`tg3.c
  2987. +
  2988. +libdrivers_a-tg3.obj: tg3.c
  2989. +@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`; \
  2990. +@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
  2991. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tg3.c' object='libdrivers_a-tg3.obj' libtool=no @AMDEPBACKSLASH@
  2992. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-tg3.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-tg3.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-tg3.obj `if test -f 'tg3.c'; then $(CYGPATH_W) 'tg3.c'; else $(CYGPATH_W) '$(srcdir)/tg3.c'; fi`
  2995. libdrivers_a-tlan.o: tlan.c
  2996. @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; \
  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.o' 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.o `test -f 'tlan.c' || echo '$(srcdir)/'`tlan.c
  3003. libdrivers_a-tlan.obj: tlan.c
  3004. @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`; \
  3005. @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
  3006. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tlan.c' object='libdrivers_a-tlan.obj' libtool=no @AMDEPBACKSLASH@
  3007. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3008. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-tlan.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-tlan.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-tlan.obj `if test -f 'tlan.c'; then $(CYGPATH_W) 'tlan.c'; else $(CYGPATH_W) '$(srcdir)/tlan.c'; fi`
  3011. libdrivers_a-tulip.o: tulip.c
  3012. @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; \
  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.o' 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.o `test -f 'tulip.c' || echo '$(srcdir)/'`tulip.c
  3019. libdrivers_a-tulip.obj: tulip.c
  3020. @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`; \
  3021. @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
  3022. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tulip.c' object='libdrivers_a-tulip.obj' libtool=no @AMDEPBACKSLASH@
  3023. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3024. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-tulip.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-tulip.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-tulip.obj `if test -f 'tulip.c'; then $(CYGPATH_W) 'tulip.c'; else $(CYGPATH_W) '$(srcdir)/tulip.c'; fi`
  3027. libdrivers_a-via-rhine.o: 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.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; \
  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.o' 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.o `test -f 'via-rhine.c' || echo '$(srcdir)/'`via-rhine.c
  3035. libdrivers_a-via-rhine.obj: via-rhine.c
  3036. @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`; \
  3037. @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
  3038. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='via-rhine.c' object='libdrivers_a-via-rhine.obj' libtool=no @AMDEPBACKSLASH@
  3039. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3040. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-via-rhine.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-via-rhine.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-via-rhine.obj `if test -f 'via-rhine.c'; then $(CYGPATH_W) 'via-rhine.c'; else $(CYGPATH_W) '$(srcdir)/via-rhine.c'; fi`
  3043. libdrivers_a-w89c840.o: w89c840.c
  3044. @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; \
  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.o' 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.o `test -f 'w89c840.c' || echo '$(srcdir)/'`w89c840.c
  3051. libdrivers_a-w89c840.obj: w89c840.c
  3052. @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`; \
  3053. @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
  3054. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='w89c840.c' object='libdrivers_a-w89c840.obj' libtool=no @AMDEPBACKSLASH@
  3055. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3056. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-w89c840.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-w89c840.TPo' @AMDEPBACKSLASH@
  3057. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3058. @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`
  3059. -uninstall-info-am:
  3060. +
  3061. +libdrivers_a-r8169.o: r8169.c
  3062. +@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; \
  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.o' 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.o `test -f 'r8169.c' || echo '$(srcdir)/'`r8169.c
  3068. +
  3069. +libdrivers_a-r8169.obj: r8169.c
  3070. +@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`; \
  3071. +@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
  3072. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='r8169.c' object='libdrivers_a-r8169.obj' libtool=no @AMDEPBACKSLASH@
  3073. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-r8169.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-r8169.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-r8169.obj `if test -f 'r8169.c'; then $(CYGPATH_W) 'r8169.c'; else $(CYGPATH_W) '$(srcdir)/r8169.c'; fi`
  3076. +
  3077. +libdrivers_a-forcedeth.o: forcedeth.c
  3078. +@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; \
  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.o' 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.o `test -f 'forcedeth.c' || echo '$(srcdir)/'`forcedeth.c
  3084. +
  3085. +libdrivers_a-forcedeth.obj: forcedeth.c
  3086. +@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`; \
  3087. +@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
  3088. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='forcedeth.c' object='libdrivers_a-forcedeth.obj' libtool=no @AMDEPBACKSLASH@
  3089. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-forcedeth.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-forcedeth.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-forcedeth.obj `if test -f 'forcedeth.c'; then $(CYGPATH_W) 'forcedeth.c'; else $(CYGPATH_W) '$(srcdir)/forcedeth.c'; fi`
  3092. +
  3093. +libdrivers_a-ns83820.o: ns83820.c
  3094. +@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; \
  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.o' 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.o `test -f 'ns83820.c' || echo '$(srcdir)/'`ns83820.c
  3100. +
  3101. +libdrivers_a-ns83820.obj: ns83820.c
  3102. +@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`; \
  3103. +@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
  3104. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ns83820.c' object='libdrivers_a-ns83820.obj' libtool=no @AMDEPBACKSLASH@
  3105. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-ns83820.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-ns83820.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-ns83820.obj `if test -f 'ns83820.c'; then $(CYGPATH_W) 'ns83820.c'; else $(CYGPATH_W) '$(srcdir)/ns83820.c'; fi`
  3108. +
  3109. +libdrivers_a-pnic.o: pnic.c
  3110. +@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; \
  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.o' 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.o `test -f 'pnic.c' || echo '$(srcdir)/'`pnic.c
  3116. +
  3117. +libdrivers_a-pnic.obj: pnic.c
  3118. +@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`; \
  3119. +@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
  3120. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pnic.c' object='libdrivers_a-pnic.obj' libtool=no @AMDEPBACKSLASH@
  3121. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pnic.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pnic.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.obj `if test -f 'pnic.c'; then $(CYGPATH_W) 'pnic.c'; else $(CYGPATH_W) '$(srcdir)/pnic.c'; fi`
  3124. +
  3125. +libdrivers_a-pnic_api.o: 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.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; \
  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.o' 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.o `test -f 'pnic_api.c' || echo '$(srcdir)/'`pnic_api.c
  3132. +
  3133. +libdrivers_a-pnic_api.obj: pnic_api.c
  3134. +@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`; \
  3135. +@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
  3136. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pnic_api.c' object='libdrivers_a-pnic_api.obj' libtool=no @AMDEPBACKSLASH@
  3137. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pnic_api.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pnic_api.TPo' @AMDEPBACKSLASH@
  3138. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3139. +@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`
  3140. ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
  3141. list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
  3142. @@ -817,11 +928,9 @@
  3143. done | \
  3144. $(AWK) ' { files[$$0] = 1; } \
  3145. END { for (i in files) print i; }'`; \
  3146. - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
  3147. - test -n "$$unique" || unique=$$empty_fix; \
  3148. - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
  3149. - $$tags $$unique; \
  3150. - fi
  3151. + test -z "$(ETAGS_ARGS)$$tags$$unique" \
  3152. + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
  3153. + $$tags $$unique
  3154. ctags: CTAGS
  3155. CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
  3156. $(TAGS_FILES) $(LISP)
  3157. @@ -895,7 +1004,7 @@
  3158. clean-generic:
  3159. distclean-generic:
  3160. - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
  3161. + -rm -f $(CONFIG_CLEAN_FILES)
  3162. maintainer-clean-generic:
  3163. @echo "This command is intended for maintainers to use"
  3164. @@ -962,10 +1071,10 @@
  3165. # Is it really necessary to specify dependecies explicitly?
  3166. -$(3c509_drivers): 3c509.c 3c509.h
  3167. -$(3c509_drivers): %.o: 3c509.c
  3168. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3169. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3170. +#$(3c509_drivers): 3c509.c 3c509.h
  3171. +#$(3c509_drivers): %.o: 3c509.c
  3172. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3173. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3174. $(3c595_drivers): 3c595.c 3c595.h
  3175. $(3c595_drivers): %.o: 3c595.c
  3176. @@ -977,23 +1086,28 @@
  3177. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3178. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3179. -$(cs89x0_drivers): cs89x0.c cs89x0.h
  3180. -$(cs89x0_drivers): %.o: cs89x0.c
  3181. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3182. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3183. +#$(cs89x0_drivers): cs89x0.c cs89x0.h
  3184. +#$(cs89x0_drivers): %.o: cs89x0.c
  3185. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3186. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3187. $(davicom_drivers): davicom.c
  3188. $(davicom_drivers): %.o: davicom.c
  3189. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3190. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3191. -$(depca_drivers): depca.c
  3192. -$(depca_drivers): %.o: depca.c
  3193. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3194. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3195. +#$(depca_drivers): depca.c
  3196. +#$(depca_drivers): %.o: depca.c
  3197. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3198. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3199. -$(eepro_drivers): eepro.c
  3200. -$(eepro_drivers): %.o: eepro.c
  3201. +#$(eepro_drivers): eepro.c
  3202. +#$(eepro_drivers): %.o: eepro.c
  3203. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3204. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3205. +
  3206. +$(e1000_drivers): e1000.c e1000_hw.h
  3207. +$(e1000_drivers): %.o: e1000.c
  3208. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3209. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3210. @@ -1007,28 +1121,38 @@
  3211. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3212. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3213. +$(forcedeth_drivers): forcedeth.c
  3214. +$(forcedeth_drivers): %.o: forcedeth.c
  3215. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3216. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3217. +
  3218. #$(fa311_drivers): fa311.c
  3219. #$(fa311_drivers): %.o: fa311.c
  3220. # $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3221. # $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3222. -$(i82586_drivers): i82586.c
  3223. -$(i82586_drivers): %.o: i82586.c
  3224. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3225. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3226. +#$(i82586_drivers): i82586.c
  3227. +#$(i82586_drivers): %.o: i82586.c
  3228. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3229. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3230. -$(lance_drivers): lance.c
  3231. -$(lance_drivers): %.o: lance.c
  3232. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3233. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3234. +#$(lance_drivers): lance.c
  3235. +#$(lance_drivers): %.o: lance.c
  3236. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3237. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3238. $(natsemi_drivers): natsemi.c
  3239. $(natsemi_drivers): %.o: natsemi.c
  3240. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3241. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3242. -$(ni5010_drivers): ni5010.c
  3243. -$(ni5010_drivers): %.o: ni5010.c
  3244. +#$(ni5010_drivers): ni5010.c
  3245. +#$(ni5010_drivers): %.o: ni5010.c
  3246. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3247. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3248. +
  3249. +$(ns83820_drivers): ns83820.c
  3250. +$(ns83820_drivers): %.o: ns83820.c
  3251. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3252. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3253. @@ -1037,41 +1161,62 @@
  3254. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3255. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3256. -$(otulip_drivers): otulip.c otulip.h
  3257. -$(otulip_drivers): %.o: otulip.c
  3258. +#$(otulip_drivers): otulip.c otulip.h
  3259. +#$(otulip_drivers): %.o: otulip.c
  3260. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3261. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3262. +
  3263. +$(pcnet32_drivers): pcnet32.c
  3264. +$(pcnet32_drivers): %.o: pcnet32.c
  3265. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3266. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3267. -$(rtl8139_drivers): rtl8139.c
  3268. -$(rtl8139_drivers): %.o: rtl8139.c
  3269. +$(pnic_drivers): pnic.c
  3270. +$(pnic_drivers): %.o: pnic.c pnic_api.h
  3271. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3272. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3273. -$(sis900_drivers): sis900.c
  3274. -$(sis900_drivers): %.o: sis900.c sis900.h
  3275. +$(rtl8139_drivers): rtl8139.c
  3276. +$(rtl8139_drivers): %.o: rtl8139.c
  3277. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3278. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3279. -$(sk_g16_drivers): sk_g16.c sk_g16.h
  3280. -$(sk_g16_drivers): %.o: sk_g16.c
  3281. +$(r8169_drivers): r8169.c
  3282. +$(r8169_drivers): %.o: r8169.c
  3283. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3284. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3285. -$(smc9000_drivers): smc9000.c smc9000.h
  3286. -$(smc9000_drivers): %.o: smc9000.c
  3287. +$(sis900_drivers): sis900.c sis900.h
  3288. +$(sis900_drivers): %.o: sis900.c
  3289. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3290. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3291. -$(tiara_drivers): tiara.c
  3292. -$(tiara_drivers): %.o: tiara.c
  3293. +#$(sk_g16_drivers): sk_g16.c sk_g16.h
  3294. +#$(sk_g16_drivers): %.o: sk_g16.c
  3295. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3296. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3297. +
  3298. +#$(smc9000_drivers): smc9000.c smc9000.h
  3299. +#$(smc9000_drivers): %.o: smc9000.c
  3300. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3301. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3302. +
  3303. +
  3304. +$(tg3_drivers): tg3.c tg3.h
  3305. +$(tg3_drivers): %.o: tg3.c
  3306. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3307. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3308. -#$(tlan_drivers): tlan.c
  3309. -#$(tlan_drivers): %.o: tlan.c
  3310. +#$(tiara_drivers): tiara.c
  3311. +#$(tiara_drivers): %.o: tiara.c
  3312. # $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3313. # $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3314. +$(tlan_drivers): tlan.c tlan.h
  3315. +$(tlan_drivers): %.o: tlan.c
  3316. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3317. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3318. +
  3319. $(tulip_drivers): tulip.c
  3320. $(tulip_drivers): %.o: tulip.c
  3321. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3322. Index: b/netboot/basemem.c
  3323. ===================================================================
  3324. --- /dev/null
  3325. +++ b/netboot/basemem.c
  3326. @@ -0,0 +1,178 @@
  3327. +#include "etherboot.h"
  3328. +#define DEBUG_BASEMEM
  3329. +/* Routines to allocate base memory in a BIOS-compatible way, by
  3330. + * updating the Free Base Memory Size counter at 40:13h.
  3331. + *
  3332. + * Michael Brown <mbrown@fensystems.co.uk> (mcb30)
  3333. + * $Id: grub-0.95-diskless-patch-2-undi.patch,v 1.1.1.1 2005/06/14 08:18:50 wesolows Exp $
  3334. + */
  3335. +
  3336. +#define fbms ( ( uint16_t * ) phys_to_virt ( 0x413 ) )
  3337. +#define BASE_MEMORY_MAX ( 640 )
  3338. +#define FREE_BLOCK_MAGIC ( ('!'<<0) + ('F'<<8) + ('R'<<16) + ('E'<<24) )
  3339. +
  3340. +typedef struct free_base_memory_block {
  3341. + uint32_t magic;
  3342. + uint16_t size_kb;
  3343. +} free_base_memory_block_t;
  3344. +
  3345. +/* Return amount of free base memory in bytes
  3346. + */
  3347. +
  3348. +uint32_t get_free_base_memory ( void ) {
  3349. + return *fbms << 10;
  3350. +}
  3351. +
  3352. +/* Adjust the real mode stack pointer. We keep the real mode stack at
  3353. + * the top of free base memory, rather than allocating space for it.
  3354. + */
  3355. +
  3356. +inline void adjust_real_mode_stack ( void ) {
  3357. +/* real_mode_stack = ( *fbms << 10 ); */
  3358. +}
  3359. +
  3360. +/* Allocate N bytes of base memory. Amount allocated will be rounded
  3361. + * up to the nearest kB, since that's the granularity of the BIOS FBMS
  3362. + * counter. Returns NULL if memory cannot be allocated.
  3363. + */
  3364. +
  3365. +void * allot_base_memory ( size_t size ) {
  3366. + uint16_t size_kb = ( size + 1023 ) >> 10;
  3367. + void *ptr = NULL;
  3368. +
  3369. +#ifdef DEBUG_BASEMEM
  3370. + printf ( "Trying to allocate %d kB of base memory, %d kB free\n",
  3371. + size_kb, *fbms );
  3372. +#endif
  3373. +
  3374. + /* Free up any unused memory before we start */
  3375. + free_unused_base_memory();
  3376. +
  3377. + /* Check available base memory */
  3378. + if ( size_kb > *fbms ) { return NULL; }
  3379. +
  3380. + /* Reduce available base memory */
  3381. + *fbms -= size_kb;
  3382. +
  3383. + /* Calculate address of memory allocated */
  3384. + ptr = phys_to_virt ( *fbms << 10 );
  3385. +
  3386. +#ifdef DEBUG_BASEMEM
  3387. + /* Zero out memory. We do this so that allocation of
  3388. + * already-used space will show up in the form of a crash as
  3389. + * soon as possible.
  3390. + */
  3391. + memset ( ptr, 0, size_kb << 10 );
  3392. +#endif
  3393. +
  3394. + /* Adjust real mode stack pointer */
  3395. + adjust_real_mode_stack ();
  3396. +
  3397. + return ptr;
  3398. +}
  3399. +
  3400. +/* Free base memory allocated by allot_base_memory. The BIOS provides
  3401. + * nothing better than a LIFO mechanism for freeing memory (i.e. it
  3402. + * just has the single "total free memory" counter), but we improve
  3403. + * upon this slightly; as long as you free all the allotted blocks, it
  3404. + * doesn't matter what order you free them in. (This will only work
  3405. + * for blocks that are freed via forget_base_memory()).
  3406. + *
  3407. + * Yes, it's annoying that you have to remember the size of the blocks
  3408. + * you've allotted. However, since our granularity of allocation is
  3409. + * 1K, the alternative is to risk wasting the occasional kB of base
  3410. + * memory, which is a Bad Thing. Really, you should be using as
  3411. + * little base memory as possible, so consider the awkwardness of the
  3412. + * API to be a feature! :-)
  3413. + */
  3414. +
  3415. +void forget_base_memory ( void *ptr, size_t size ) {
  3416. + uint16_t remainder = virt_to_phys(ptr) & 1023;
  3417. + uint16_t size_kb = ( size + remainder + 1023 ) >> 10;
  3418. + free_base_memory_block_t *free_block =
  3419. + ( free_base_memory_block_t * ) ( ptr - remainder );
  3420. +
  3421. + if ( ( ptr == NULL ) || ( size == 0 ) ) { return; }
  3422. +
  3423. +#ifdef DEBUG_BASEMEM
  3424. + printf ( "Trying to free %d bytes base memory at 0x%x\n",
  3425. + size, virt_to_phys ( ptr ) );
  3426. + if ( remainder > 0 ) {
  3427. + printf ( "WARNING: destructively expanding free block "
  3428. + "downwards to 0x%x\n",
  3429. + virt_to_phys ( ptr - remainder ) );
  3430. + }
  3431. +#endif
  3432. +
  3433. + /* Mark every kilobyte within this block as free. This is
  3434. + * overkill for normal purposes, but helps when something has
  3435. + * allocated base memory with a granularity finer than the
  3436. + * BIOS granularity of 1kB. PXE ROMs tend to do this when
  3437. + * they allocate their own memory. This method allows us to
  3438. + * free their blocks (admittedly in a rather dangerous,
  3439. + * tread-on-anything-either-side sort of way, but there's no
  3440. + * other way to do it).
  3441. + *
  3442. + * Since we're marking every kB as free, there's actually no
  3443. + * need for recording the size of the blocks. However, we
  3444. + * keep this in so that debug messages are friendlier. It
  3445. + * probably adds around 8 bytes to the overall code size.
  3446. + */
  3447. + while ( size_kb > 0 ) {
  3448. + /* Mark this block as unused */
  3449. + free_block->magic = FREE_BLOCK_MAGIC;
  3450. + free_block->size_kb = size_kb;
  3451. + /* Move up by 1 kB */
  3452. + (void *)(free_block += ( 1 << 10 ));
  3453. + size_kb--;
  3454. + }
  3455. +
  3456. + /* Free up unused base memory */
  3457. + free_unused_base_memory();
  3458. +}
  3459. +
  3460. +/* Do the actual freeing of memory. This is split out from
  3461. + * forget_base_memory() so that it may be called separately. It
  3462. + * should be called whenever base memory is deallocated by an external
  3463. + * entity (if we can detect that it has done so) so that we get the
  3464. + * chance to free up our own blocks.
  3465. + */
  3466. +void free_unused_base_memory ( void ) {
  3467. + free_base_memory_block_t *free_block = NULL;
  3468. +
  3469. + /* Try to release memory back to the BIOS. Free all
  3470. + * consecutive blocks marked as free.
  3471. + */
  3472. + while ( 1 ) {
  3473. + /* Calculate address of next potential free block */
  3474. + free_block = ( free_base_memory_block_t * )
  3475. + phys_to_virt ( *fbms << 10 );
  3476. +
  3477. + /* Stop processing if we're all the way up to 640K or
  3478. + * if this is not a free block
  3479. + */
  3480. + if ( ( *fbms == BASE_MEMORY_MAX ) ||
  3481. + ( free_block->magic != FREE_BLOCK_MAGIC ) ) {
  3482. + break;
  3483. + }
  3484. +
  3485. + /* Return memory to BIOS */
  3486. + *fbms += free_block->size_kb;
  3487. +
  3488. +#ifdef DEBUG_BASEMEM
  3489. + printf ( "Freed %d kB base memory, %d kB now free\n",
  3490. + free_block->size_kb, *fbms );
  3491. +
  3492. + /* Zero out freed block. We do this in case
  3493. + * the block contained any structures that
  3494. + * might be located by scanning through
  3495. + * memory.
  3496. + */
  3497. + memset ( free_block, 0, free_block->size_kb << 10 );
  3498. +#endif
  3499. + }
  3500. +
  3501. + /* Adjust real mode stack pointer */
  3502. + adjust_real_mode_stack ();
  3503. +}
  3504. +
  3505. Index: b/netboot/big_bswap.h
  3506. ===================================================================
  3507. --- /dev/null
  3508. +++ b/netboot/big_bswap.h
  3509. @@ -0,0 +1,17 @@
  3510. +#ifndef ETHERBOOT_BIG_BSWAP_H
  3511. +#define ETHERBOOT_BIG_BSWAP_H
  3512. +
  3513. +#define ntohl(x) (x)
  3514. +#define htonl(x) (x)
  3515. +#define ntohs(x) (x)
  3516. +#define htons(x) (x)
  3517. +#define cpu_to_le32(x) __bswap_32(x)
  3518. +#define cpu_to_le16(x) __bswap_16(x)
  3519. +#define cpu_to_be32(x) (x)
  3520. +#define cpu_to_be16(x) (x)
  3521. +#define le32_to_cpu(x) __bswap_32(x)
  3522. +#define le16_to_cpu(x) __bswap_16(x)
  3523. +#define be32_to_cpu(x) (x)
  3524. +#define be16_to_cpu(x) (x)
  3525. +
  3526. +#endif /* ETHERBOOT_BIG_BSWAP_H */
  3527. Index: b/netboot/bootp.h
  3528. ===================================================================
  3529. --- /dev/null
  3530. +++ b/netboot/bootp.h
  3531. @@ -0,0 +1,182 @@
  3532. +#ifndef _BOOTP_H
  3533. +#define _BOOTP_H
  3534. +
  3535. +#include "if_ether.h"
  3536. +#include "ip.h"
  3537. +#include "udp.h"
  3538. +
  3539. +#ifndef MAX_BOOTP_RETRIES
  3540. +#define MAX_BOOTP_RETRIES 20
  3541. +#endif
  3542. +
  3543. +#ifdef ALTERNATE_DHCP_PORTS_1067_1068
  3544. +#undef NON_STANDARD_BOOTP_SERVER
  3545. +#define NON_STANDARD_BOOTP_SERVER 1067
  3546. +#undef NON_STANDARD_BOOTP_CLIENT
  3547. +#define NON_STANDARD_BOOTP_CLIENT 1068
  3548. +#endif
  3549. +
  3550. +#ifdef NON_STANDARD_BOOTP_SERVER
  3551. +#define BOOTP_SERVER NON_STANDARD_BOOTP_SERVER
  3552. +#else
  3553. +#define BOOTP_SERVER 67
  3554. +#endif
  3555. +#ifdef NON_STANDARD_BOOTP_CLIENT
  3556. +#define BOOTP_CLIENT NON_STANDARD_BOOTP_CLIENT
  3557. +#else
  3558. +#define BOOTP_CLIENT 68
  3559. +#endif
  3560. +
  3561. +#define BOOTP_REQUEST 1
  3562. +#define BOOTP_REPLY 2
  3563. +
  3564. +#define TAG_LEN(p) (*((p)+1))
  3565. +#define RFC1533_COOKIE 99, 130, 83, 99
  3566. +#define RFC1533_PAD 0
  3567. +#define RFC1533_NETMASK 1
  3568. +#define RFC1533_TIMEOFFSET 2
  3569. +#define RFC1533_GATEWAY 3
  3570. +#define RFC1533_TIMESERVER 4
  3571. +#define RFC1533_IEN116NS 5
  3572. +#define RFC1533_DNS 6
  3573. +#define RFC1533_LOGSERVER 7
  3574. +#define RFC1533_COOKIESERVER 8
  3575. +#define RFC1533_LPRSERVER 9
  3576. +#define RFC1533_IMPRESSSERVER 10
  3577. +#define RFC1533_RESOURCESERVER 11
  3578. +#define RFC1533_HOSTNAME 12
  3579. +#define RFC1533_BOOTFILESIZE 13
  3580. +#define RFC1533_MERITDUMPFILE 14
  3581. +#define RFC1533_DOMAINNAME 15
  3582. +#define RFC1533_SWAPSERVER 16
  3583. +#define RFC1533_ROOTPATH 17
  3584. +#define RFC1533_EXTENSIONPATH 18
  3585. +#define RFC1533_IPFORWARDING 19
  3586. +#define RFC1533_IPSOURCEROUTING 20
  3587. +#define RFC1533_IPPOLICYFILTER 21
  3588. +#define RFC1533_IPMAXREASSEMBLY 22
  3589. +#define RFC1533_IPTTL 23
  3590. +#define RFC1533_IPMTU 24
  3591. +#define RFC1533_IPMTUPLATEAU 25
  3592. +#define RFC1533_INTMTU 26
  3593. +#define RFC1533_INTLOCALSUBNETS 27
  3594. +#define RFC1533_INTBROADCAST 28
  3595. +#define RFC1533_INTICMPDISCOVER 29
  3596. +#define RFC1533_INTICMPRESPOND 30
  3597. +#define RFC1533_INTROUTEDISCOVER 31
  3598. +#define RFC1533_INTROUTESOLICIT 32
  3599. +#define RFC1533_INTSTATICROUTES 33
  3600. +#define RFC1533_LLTRAILERENCAP 34
  3601. +#define RFC1533_LLARPCACHETMO 35
  3602. +#define RFC1533_LLETHERNETENCAP 36
  3603. +#define RFC1533_TCPTTL 37
  3604. +#define RFC1533_TCPKEEPALIVETMO 38
  3605. +#define RFC1533_TCPKEEPALIVEGB 39
  3606. +#define RFC1533_NISDOMAIN 40
  3607. +#define RFC1533_NISSERVER 41
  3608. +#define RFC1533_NTPSERVER 42
  3609. +#define RFC1533_VENDOR 43
  3610. +#define RFC1533_NBNS 44
  3611. +#define RFC1533_NBDD 45
  3612. +#define RFC1533_NBNT 46
  3613. +#define RFC1533_NBSCOPE 47
  3614. +#define RFC1533_XFS 48
  3615. +#define RFC1533_XDM 49
  3616. +#ifndef NO_DHCP_SUPPORT
  3617. +#define RFC2132_REQ_ADDR 50
  3618. +#define RFC2132_MSG_TYPE 53
  3619. +#define RFC2132_SRV_ID 54
  3620. +#define RFC2132_PARAM_LIST 55
  3621. +#define RFC2132_MAX_SIZE 57
  3622. +#define RFC2132_VENDOR_CLASS_ID 60
  3623. +
  3624. +#define DHCPDISCOVER 1
  3625. +#define DHCPOFFER 2
  3626. +#define DHCPREQUEST 3
  3627. +#define DHCPACK 5
  3628. +#endif /* NO_DHCP_SUPPORT */
  3629. +
  3630. +#define RFC1533_VENDOR_MAJOR 0
  3631. +#define RFC1533_VENDOR_MINOR 0
  3632. +
  3633. +#define RFC1533_VENDOR_MAGIC 128
  3634. +#define RFC1533_VENDOR_ADDPARM 129
  3635. +#define RFC1533_VENDOR_ETHDEV 130
  3636. +#ifdef IMAGE_FREEBSD
  3637. +#define RFC1533_VENDOR_HOWTO 132
  3638. +#define RFC1533_VENDOR_KERNEL_ENV 133
  3639. +#endif
  3640. +#define RFC1533_VENDOR_ETHERBOOT_ENCAP 150
  3641. +#define RFC1533_VENDOR_MNUOPTS 160
  3642. +#define RFC1533_VENDOR_NIC_DEV_ID 175
  3643. +#define RFC1533_VENDOR_SELECTION 176
  3644. +#define RFC1533_VENDOR_ARCH 177
  3645. +#define RFC1533_VENDOR_MOTD 184
  3646. +#define RFC1533_VENDOR_NUMOFMOTD 8
  3647. +#define RFC1533_VENDOR_IMG 192
  3648. +#define RFC1533_VENDOR_NUMOFIMG 16
  3649. +
  3650. +#define RFC1533_VENDOR_CONFIGFILE 150
  3651. +
  3652. +#define RFC1533_END 255
  3653. +
  3654. +#define BOOTP_VENDOR_LEN 64
  3655. +
  3656. +#define DHCP_OPT_LEN 312
  3657. +
  3658. +/* Format of a bootp packet */
  3659. +struct bootp_t {
  3660. + uint8_t bp_op;
  3661. + uint8_t bp_htype;
  3662. + uint8_t bp_hlen;
  3663. + uint8_t bp_hops;
  3664. + uint32_t bp_xid;
  3665. + uint16_t bp_secs;
  3666. + uint16_t unused;
  3667. + in_addr bp_ciaddr;
  3668. + in_addr bp_yiaddr;
  3669. + in_addr bp_siaddr;
  3670. + in_addr bp_giaddr;
  3671. + uint8_t bp_hwaddr[16];
  3672. + uint8_t bp_sname[64];
  3673. + char bp_file[128];
  3674. + uint8_t bp_vend[BOOTP_VENDOR_LEN];
  3675. +};
  3676. +
  3677. +struct dhcp_t {
  3678. + uint8_t bp_op;
  3679. + uint8_t bp_htype;
  3680. + uint8_t bp_hlen;
  3681. + uint8_t bp_hops;
  3682. + uint32_t bp_xid;
  3683. + uint16_t bp_secs;
  3684. + uint16_t bp_flag;
  3685. + in_addr bp_ciaddr;
  3686. + in_addr bp_yiaddr;
  3687. + in_addr bp_siaddr;
  3688. + in_addr bp_giaddr;
  3689. + uint8_t bp_hwaddr[16];
  3690. + uint8_t bp_sname[64];
  3691. + char bp_file[128];
  3692. + uint8_t bp_vend[DHCP_OPT_LEN];
  3693. +};
  3694. +
  3695. +/* Format of a bootp IP packet */
  3696. +struct bootpip_t
  3697. +{
  3698. + struct iphdr ip;
  3699. + struct udphdr udp;
  3700. + struct bootp_t bp;
  3701. +};
  3702. +struct dhcpip_t
  3703. +{
  3704. + struct iphdr ip;
  3705. + struct udphdr udp;
  3706. + struct dhcp_t bp;
  3707. +};
  3708. +
  3709. +#define MAX_RFC1533_VENDLEN (ETH_MAX_MTU - sizeof(struct bootpip_t) + BOOTP_VENDOR_LEN)
  3710. +
  3711. +#define BOOTP_DATA_ADDR (&bootp_data)
  3712. +
  3713. +#endif /* _BOOTP_H */
  3714. Index: b/netboot/byteswap.h
  3715. ===================================================================
  3716. --- /dev/null
  3717. +++ b/netboot/byteswap.h
  3718. @@ -0,0 +1,20 @@
  3719. +#ifndef ETHERBOOT_BYTESWAP_H
  3720. +#define ETHERBOOT_BYTESWAP_H
  3721. +
  3722. +#include "endian.h"
  3723. +#include "i386_byteswap.h"
  3724. +
  3725. +#if __BYTE_ORDER == __LITTLE_ENDIAN
  3726. +#include "little_bswap.h"
  3727. +#endif
  3728. +#if __BYTE_ORDER == __BIG_ENDIAN
  3729. +#include "big_bswap.h"
  3730. +#endif
  3731. +
  3732. +/* Make routines available to all */
  3733. +#define swap32(x) __bswap_32(x)
  3734. +#define swap16(x) __bswap_16(x)
  3735. +#define bswap_32(x) __bswap_32(x)
  3736. +#define bswap_16(x) __bswap_16(x)
  3737. +
  3738. +#endif /* ETHERBOOT_BYTESWAP_H */
  3739. Index: b/netboot/cards.h
  3740. ===================================================================
  3741. --- a/netboot/cards.h
  3742. +++ /dev/null
  3743. @@ -1,183 +0,0 @@
  3744. -#ifndef CARDS_H
  3745. -#define CARDS_H
  3746. -
  3747. -/*
  3748. - * This program is free software; you can redistribute it and/or
  3749. - * modify it under the terms of the GNU General Public License as
  3750. - * published by the Free Software Foundation; either version 2, or (at
  3751. - * your option) any later version.
  3752. - */
  3753. -
  3754. -#include "nic.h"
  3755. -
  3756. -/* OK, this is how the PCI support hack works: if pci.h is included before
  3757. - * this file is included, assume that the driver supports PCI. This means that
  3758. - * this file is usually included last. */
  3759. -
  3760. -#ifdef PCI_H
  3761. -#define PCI_ARG(x) ,x
  3762. -#else
  3763. -#define PCI_ARG(x)
  3764. -#endif
  3765. -
  3766. -#ifdef INCLUDE_WD
  3767. -extern struct nic *wd_probe(struct nic *, unsigned short *
  3768. - PCI_ARG(struct pci_device *));
  3769. -#endif
  3770. -
  3771. -#ifdef INCLUDE_3C503
  3772. -extern struct nic *t503_probe(struct nic *, unsigned short *
  3773. - PCI_ARG(struct pci_device *));
  3774. -#endif
  3775. -
  3776. -#ifdef INCLUDE_VIA_RHINE
  3777. -extern struct nic *rhine_probe(struct nic *, unsigned short *
  3778. - PCI_ARG(struct pci_device *));
  3779. -#endif
  3780. -
  3781. -#ifdef INCLUDE_NE
  3782. -extern struct nic *ne_probe(struct nic *, unsigned short *
  3783. - PCI_ARG(struct pci_device *));
  3784. -#endif
  3785. -
  3786. -#ifdef INCLUDE_NS8390
  3787. -extern struct nic *nepci_probe(struct nic *, unsigned short *
  3788. - PCI_ARG(struct pci_device *));
  3789. -#endif
  3790. -
  3791. -#ifdef INCLUDE_3C509
  3792. -extern struct nic *t509_probe(struct nic *, unsigned short *
  3793. - PCI_ARG(struct pci_device *));
  3794. -#endif
  3795. -
  3796. -#ifdef INCLUDE_3C529
  3797. -extern struct nic *t529_probe(struct nic *, unsigned short *
  3798. - PCI_ARG(struct pci_device *));
  3799. -#endif
  3800. -
  3801. -#ifdef INCLUDE_3C595
  3802. -extern struct nic *t595_probe(struct nic *, unsigned short *
  3803. - PCI_ARG(struct pci_device *));
  3804. -#endif
  3805. -
  3806. -#ifdef INCLUDE_3C90X
  3807. -extern struct nic *a3c90x_probe(struct nic *, unsigned short *
  3808. - PCI_ARG(struct pci_device *));
  3809. -#endif
  3810. -
  3811. -#ifdef INCLUDE_EEPRO
  3812. -extern struct nic *eepro_probe(struct nic *, unsigned short *
  3813. - PCI_ARG(struct pci_device *));
  3814. -#endif
  3815. -
  3816. -#ifdef INCLUDE_EEPRO100
  3817. -extern struct nic *eepro100_probe(struct nic *, unsigned short *
  3818. - PCI_ARG(struct pci_device *));
  3819. -#endif
  3820. -
  3821. -#ifdef INCLUDE_EPIC100
  3822. -extern struct nic *epic100_probe(struct nic *, unsigned short *
  3823. - PCI_ARG(struct pci_device *));
  3824. -#endif
  3825. -
  3826. -#ifdef INCLUDE_OTULIP
  3827. -extern struct nic *otulip_probe(struct nic *, unsigned short *
  3828. - PCI_ARG(struct pci_device *));
  3829. -#endif
  3830. -
  3831. -#ifdef INCLUDE_TULIP
  3832. -extern struct nic *tulip_probe(struct nic *, unsigned short *
  3833. - PCI_ARG(struct pci_device *));
  3834. -#endif
  3835. -
  3836. -#ifdef INCLUDE_DAVICOM
  3837. -extern struct nic *davicom_probe(struct nic *, unsigned short *
  3838. - PCI_ARG(struct pci_device *));
  3839. -#endif
  3840. -
  3841. -#ifdef INCLUDE_CS89X0
  3842. -extern struct nic *cs89x0_probe(struct nic *, unsigned short *
  3843. - PCI_ARG(struct pci_device *));
  3844. -#endif
  3845. -
  3846. -#ifdef INCLUDE_LANCE
  3847. -extern struct nic *lancepci_probe(struct nic *, unsigned short *
  3848. - PCI_ARG(struct pci_device *));
  3849. -#endif
  3850. -
  3851. -#ifdef INCLUDE_NE2100
  3852. -extern struct nic *ne2100_probe(struct nic *, unsigned short *
  3853. - PCI_ARG(struct pci_device *));
  3854. -#endif
  3855. -
  3856. -#ifdef INCLUDE_NI6510
  3857. -extern struct nic *ni6510_probe(struct nic *, unsigned short *
  3858. - PCI_ARG(struct pci_device *));
  3859. -#endif
  3860. -
  3861. -#ifdef INCLUDE_SK_G16
  3862. -extern struct nic *SK_probe(struct nic *, unsigned short *
  3863. - PCI_ARG(struct pci_device *));
  3864. -#endif
  3865. -
  3866. -#ifdef INCLUDE_3C507
  3867. -extern struct nic *t507_probe(struct nic *, unsigned short *
  3868. - PCI_ARG(struct pci_device *));
  3869. -#endif
  3870. -
  3871. -#ifdef INCLUDE_NI5010
  3872. -extern struct nic *ni5010_probe(struct nic *, unsigned short *
  3873. - PCI_ARG(struct pci_device *));
  3874. -#endif
  3875. -
  3876. -#ifdef INCLUDE_NI5210
  3877. -extern struct nic *ni5210_probe(struct nic *, unsigned short *
  3878. - PCI_ARG(struct pci_device *));
  3879. -#endif
  3880. -
  3881. -#ifdef INCLUDE_EXOS205
  3882. -extern struct nic *exos205_probe(struct nic *, unsigned short *
  3883. - PCI_ARG(struct pci_device *));
  3884. -#endif
  3885. -
  3886. -#ifdef INCLUDE_SMC9000
  3887. -extern struct nic *smc9000_probe(struct nic *, unsigned short *
  3888. - PCI_ARG(struct pci_device *));
  3889. -#endif
  3890. -
  3891. -#ifdef INCLUDE_TIARA
  3892. -extern struct nic *tiara_probe(struct nic *, unsigned short *
  3893. - PCI_ARG(struct pci_device *));
  3894. -#endif
  3895. -
  3896. -#ifdef INCLUDE_DEPCA
  3897. -extern struct nic *depca_probe(struct nic *, unsigned short *
  3898. - PCI_ARG(struct pci_device *));
  3899. -#endif
  3900. -
  3901. -#ifdef INCLUDE_RTL8139
  3902. -extern struct nic *rtl8139_probe(struct nic *, unsigned short *
  3903. - PCI_ARG(struct pci_device *));
  3904. -#endif
  3905. -
  3906. -#ifdef INCLUDE_W89C840
  3907. -extern struct nic *w89c840_probe(struct nic *, unsigned short *
  3908. - PCI_ARG(struct pci_device *));
  3909. -#endif
  3910. -
  3911. -#ifdef INCLUDE_SIS900
  3912. -extern struct nic *sis900_probe(struct nic *, unsigned short *
  3913. - PCI_ARG(struct pci_device *));
  3914. -#endif
  3915. -
  3916. -#ifdef INCLUDE_NATSEMI
  3917. -extern struct nic *natsemi_probe(struct nic *, unsigned short *
  3918. - PCI_ARG(struct pci_device *));
  3919. -#endif
  3920. -
  3921. -#ifdef INCLUDE_TLAN
  3922. -extern struct nic *tlan_probe(struct nic *, unsigned short *
  3923. - PCI_ARG(struct pci_device *));
  3924. -#endif
  3925. -
  3926. -#endif /* CARDS_H */
  3927. Index: b/netboot/config.c
  3928. ===================================================================
  3929. --- a/netboot/config.c
  3930. +++ b/netboot/config.c
  3931. @@ -1,598 +1,165 @@
  3932. /*
  3933. - * GRUB -- GRand Unified Bootloader
  3934. - * Copyright (C) 2001,2002 Free Software Foundation, Inc.
  3935. - *
  3936. - * This program is free software; you can redistribute it and/or modify
  3937. - * it under the terms of the GNU General Public License as published by
  3938. - * the Free Software Foundation; either version 2 of the License, or
  3939. - * (at your option) any later version.
  3940. - *
  3941. - * This program is distributed in the hope that it will be useful,
  3942. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3943. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3944. - * GNU General Public License for more details.
  3945. - *
  3946. - * You should have received a copy of the GNU General Public License
  3947. - * along with this program; if not, write to the Free Software
  3948. - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  3949. - */
  3950. -
  3951. -/* Based on "src/config.c" in etherboot-5.0.5. */
  3952. -
  3953. -/*
  3954. * This program is free software; you can redistribute it and/or
  3955. * modify it under the terms of the GNU General Public License as
  3956. * published by the Free Software Foundation; either version 2, or (at
  3957. * your option) any later version.
  3958. */
  3959. -#define GRUB 1
  3960. -#include <etherboot.h>
  3961. -#include <nic.h>
  3962. +#include "grub.h"
  3963. +#include "pci.h"
  3964. +#include "isa.h"
  3965. +#include "nic.h"
  3966. -#undef INCLUDE_PCI
  3967. -#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)
  3968. - /* || others later */
  3969. -# define INCLUDE_PCI
  3970. -# include <pci.h>
  3971. -static unsigned short pci_ioaddrs[16];
  3972. -
  3973. -static struct pci_device pci_nic_list[] =
  3974. +#ifdef CONFIG_PCI
  3975. +static int pci_probe(struct dev *dev, const char *type_name)
  3976. {
  3977. -#ifdef INCLUDE_NS8390
  3978. - { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8029,
  3979. - "Realtek 8029", 0, 0, 0, 0},
  3980. - { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C940,
  3981. - "Winbond NE2000-PCI", 0, 0, 0, 0},
  3982. - { PCI_VENDOR_ID_COMPEX, PCI_DEVICE_ID_COMPEX_RL2000,
  3983. - "Compex ReadyLink 2000", 0, 0, 0, 0},
  3984. - { PCI_VENDOR_ID_KTI, PCI_DEVICE_ID_KTI_ET32P2,
  3985. - "KTI ET32P2", 0, 0, 0, 0},
  3986. - { PCI_VENDOR_ID_NETVIN, PCI_DEVICE_ID_NETVIN_NV5000SC,
  3987. - "NetVin NV5000SC", 0, 0, 0, 0},
  3988. - { PCI_VENDOR_ID_HOLTEK, PCI_DEVICE_ID_HOLTEK_HT80232,
  3989. - "Holtek HT80232", 0, 0, 0, 0},
  3990. -#endif
  3991. -#ifdef INCLUDE_3C90X
  3992. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900TPO,
  3993. - "3Com900-TPO", 0, 0, 0, 0},
  3994. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900COMBO,
  3995. - "3Com900-Combo", 0, 0, 0, 0},
  3996. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905TX,
  3997. - "3Com905-TX", 0, 0, 0, 0},
  3998. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905T4,
  3999. - "3Com905-T4", 0, 0, 0, 0},
  4000. - { PCI_VENDOR_ID_3COM, 0x9004,
  4001. - "3Com900B-TPO", 0, 0, 0, 0},
  4002. - { PCI_VENDOR_ID_3COM, 0x9005,
  4003. - "3Com900B-Combo", 0, 0, 0, 0},
  4004. - { PCI_VENDOR_ID_3COM, 0x9006,
  4005. - "3Com900B-2/T", 0, 0, 0, 0},
  4006. - { PCI_VENDOR_ID_3COM, 0x900A,
  4007. - "3Com900B-FL", 0, 0, 0, 0},
  4008. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905B_TX,
  4009. - "3Com905B-TX", 0, 0, 0, 0},
  4010. - { PCI_VENDOR_ID_3COM, 0x9056,
  4011. - "3Com905B-T4", 0, 0, 0, 0},
  4012. - { PCI_VENDOR_ID_3COM, 0x905A,
  4013. - "3Com905B-FL", 0, 0, 0, 0},
  4014. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905C_TXM,
  4015. - "3Com905C-TXM", 0, 0, 0, 0},
  4016. - { PCI_VENDOR_ID_3COM, 0x9800,
  4017. - "3Com980-Cyclone", 0, 0, 0, 0},
  4018. - { PCI_VENDOR_ID_3COM, 0x9805,
  4019. - "3Com9805", 0, 0, 0, 0},
  4020. - { PCI_VENDOR_ID_3COM, 0x7646,
  4021. - "3CSOHO100-TX", 0, 0, 0, 0},
  4022. -#endif
  4023. -#ifdef INCLUDE_3C595
  4024. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C590,
  4025. - "3Com590", 0, 0, 0, 0},
  4026. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595,
  4027. - "3Com595", 0, 0, 0, 0},
  4028. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595_1,
  4029. - "3Com595", 0, 0, 0, 0},
  4030. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595_2,
  4031. - "3Com595", 0, 0, 0, 0},
  4032. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900TPO,
  4033. - "3Com900-TPO", 0, 0, 0, 0},
  4034. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900COMBO,
  4035. - "3Com900-Combo", 0, 0, 0, 0},
  4036. - { PCI_VENDOR_ID_3COM, 0x9004,
  4037. - "3Com900B-TPO", 0, 0, 0, 0},
  4038. - { PCI_VENDOR_ID_3COM, 0x9005,
  4039. - "3Com900B-Combo", 0, 0, 0, 0},
  4040. - { PCI_VENDOR_ID_3COM, 0x9006,
  4041. - "3Com900B-2/T", 0, 0, 0, 0},
  4042. - { PCI_VENDOR_ID_3COM, 0x900A,
  4043. - "3Com900B-FL", 0, 0, 0, 0},
  4044. - { PCI_VENDOR_ID_3COM, 0x9800,
  4045. - "3Com980-Cyclone", 0, 0, 0, 0},
  4046. - { PCI_VENDOR_ID_3COM, 0x9805,
  4047. - "3Com9805", 0, 0, 0, 0},
  4048. - { PCI_VENDOR_ID_3COM, 0x7646,
  4049. - "3CSOHO100-TX", 0, 0, 0, 0},
  4050. -#endif
  4051. -#ifdef INCLUDE_EEPRO100
  4052. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557,
  4053. - "Intel EtherExpressPro100", 0, 0, 0, 0},
  4054. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER,
  4055. - "Intel EtherExpressPro100 82559ER", 0, 0, 0, 0},
  4056. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1029,
  4057. - "Intel EtherExpressPro100 ID1029", 0, 0, 0, 0},
  4058. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1030,
  4059. - "Intel Corporation 82559 InBusiness 10/100", 0, 0, 0, 0},
  4060. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82562,
  4061. - "Intel EtherExpressPro100 82562EM", 0, 0, 0, 0},
  4062. -#endif
  4063. -#ifdef INCLUDE_EPIC100
  4064. - { PCI_VENDOR_ID_SMC, PCI_DEVICE_ID_SMC_EPIC100,
  4065. - "SMC EtherPowerII", 0, 0, 0, 0},
  4066. -#endif
  4067. -#ifdef INCLUDE_LANCE
  4068. - { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE,
  4069. - "AMD Lance/PCI", 0, 0, 0, 0},
  4070. - { PCI_VENDOR_ID_AMD_HOMEPNA, PCI_DEVICE_ID_AMD_HOMEPNA,
  4071. - "AMD Lance/HomePNA", 0, 0, 0, 0},
  4072. -#endif
  4073. -#ifdef INCLUDE_RTL8139
  4074. - { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139,
  4075. - "Realtek 8139", 0, 0, 0, 0},
  4076. - { PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DFE530TXP,
  4077. - "DFE530TX+/DFE538TX", 0, 0, 0, 0},
  4078. - { PCI_VENDOR_ID_SMC_1211, PCI_DEVICE_ID_SMC_1211,
  4079. - "SMC EZ10/100", 0, 0, 0, 0},
  4080. -#endif
  4081. -#ifdef INCLUDE_OTULIP
  4082. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP,
  4083. - "Digital Tulip", 0, 0, 0, 0},
  4084. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST,
  4085. - "Digital Tulip Fast", 0, 0, 0, 0},
  4086. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS,
  4087. - "Digital Tulip+", 0, 0, 0, 0},
  4088. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142,
  4089. - "Digital Tulip 21142", 0, 0, 0, 0},
  4090. -#endif
  4091. -#ifdef INCLUDE_TULIP
  4092. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP,
  4093. - "Digital Tulip", 0, 0, 0, 0},
  4094. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST,
  4095. - "Digital Tulip Fast", 0, 0, 0, 0},
  4096. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS,
  4097. - "Digital Tulip+", 0, 0, 0, 0},
  4098. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142,
  4099. - "Digital Tulip 21142", 0, 0, 0, 0},
  4100. - { PCI_VENDOR_ID_MACRONIX, PCI_DEVICE_ID_MX987x5,
  4101. - "Macronix MX987x5", 0, 0, 0, 0},
  4102. - { PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LC82C115,
  4103. - "LinkSys LNE100TX", 0, 0, 0, 0},
  4104. - { PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_DEC_TULIP,
  4105. - "Netgear FA310TX", 0, 0, 0, 0},
  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. - { PCI_VENDOR_ID_ADMTEK, PCI_DEVICE_ID_ADMTEK_0985,
  4111. - "ADMtek Centaur-P", 0, 0, 0, 0},
  4112. - { PCI_VENDOR_ID_ADMTEK, 0x0981,
  4113. - "ADMtek AN981 Comet", 0, 0, 0, 0},
  4114. - { 0x125B, 0x1400,
  4115. - "ASIX AX88140", 0, 0, 0, 0 },
  4116. - { 0x11F6, 0x9881,
  4117. - "Compex RL100-TX", 0, 0, 0, 0 },
  4118. -#endif
  4119. -#ifdef INCLUDE_DAVICOM
  4120. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9102,
  4121. - "Davicom 9102", 0, 0, 0, 0},
  4122. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9009,
  4123. - "Davicom 9009", 0, 0, 0, 0},
  4124. -#endif
  4125. -#ifdef INCLUDE_VIA_RHINE
  4126. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_VT6102,
  4127. - "VIA 6102", 0, 0, 0, 0},
  4128. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_RHINE_I,
  4129. - "VIA 3043", 0, 0, 0, 0},
  4130. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_86C100A,
  4131. - "VIA 86C100A", 0, 0, 0, 0},
  4132. -#endif
  4133. -#ifdef INCLUDE_W89C840
  4134. - { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C840,
  4135. - "Winbond W89C840F", 0, 0, 0, 0},
  4136. - { PCI_VENDOR_ID_COMPEX, PCI_DEVICE_ID_COMPEX_RL100ATX,
  4137. - "Compex RL100ATX", 0, 0, 0, 0},
  4138. -#endif
  4139. -#ifdef INCLUDE_SIS900
  4140. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS900,
  4141. - "SIS900", 0, 0, 0, 0},
  4142. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS7016,
  4143. - "SIS7016", 0, 0, 0, 0},
  4144. -#endif
  4145. -
  4146. -#ifdef INCLUDE_NATSEMI
  4147. - { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_DP83815,
  4148. - "DP83815", 0, 0, 0, 0},
  4149. -#endif
  4150. -
  4151. -#ifdef INCLUDE_TLAN
  4152. - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2326,
  4153. - "OC2326", 0, 0, 0, 0},
  4154. +/*
  4155. + * NIC probing is in pci device order, followed by the
  4156. + * link order of the drivers. A driver that matches
  4157. + * on vendor and device id will supersede a driver
  4158. + * that matches on pci class.
  4159. + *
  4160. + * If you want to probe for another device behind the same pci
  4161. + * device just increment index. And the previous probe call
  4162. + * will be repeated.
  4163. + */
  4164. + struct pci_probe_state *state = &dev->state.pci;
  4165. + printf("Probing pci %s...\n", type_name);
  4166. + if (dev->how_probe == PROBE_FIRST) {
  4167. + state->advance = 1;
  4168. + state->dev.driver = 0;
  4169. + state->dev.bus = 0;
  4170. + state->dev.devfn = 0;
  4171. + dev->index = -1;
  4172. + }
  4173. + for(;;) {
  4174. + if ((dev->how_probe != PROBE_AWAKE) && state->advance) {
  4175. + find_pci(dev->type, &state->dev);
  4176. + dev->index = -1;
  4177. + }
  4178. + state->advance = 1;
  4179. +
  4180. + if (state->dev.driver == 0)
  4181. + break;
  4182. +
  4183. +#if 0
  4184. + /* FIXME the romaddr code needs a total rethought to be useful */
  4185. + if (state->dev.romaddr != ((unsigned long) rom.rom_segment << 4)) {
  4186. + continue;
  4187. + }
  4188. +#endif
  4189. + if (dev->how_probe != PROBE_AWAKE) {
  4190. + dev->type_index++;
  4191. + }
  4192. + dev->devid.bus_type = PCI_BUS_TYPE;
  4193. + dev->devid.vendor_id = htons(state->dev.vendor);
  4194. + dev->devid.device_id = htons(state->dev.dev_id);
  4195. + /* FIXME how do I handle dev->index + PROBE_AGAIN?? */
  4196. +
  4197. + printf("[%s]", state->dev.name);
  4198. + if (state->dev.driver->probe(dev, &state->dev)) {
  4199. + state->advance = (dev->index == -1);
  4200. + return PROBE_WORKED;
  4201. + }
  4202. + putchar('\n');
  4203. + }
  4204. + return PROBE_FAILED;
  4205. +}
  4206. #endif
  4207. - /* other PCI NICs go here */
  4208. - {0, 0, NULL, 0, 0, 0, 0}
  4209. -};
  4210. -#endif /* INCLUDE_*PCI */
  4211. -
  4212. -#include <cards.h>
  4213. -
  4214. -#ifdef INCLUDE_PCI
  4215. -struct pci_dispatch_table
  4216. +#ifdef CONFIG_ISA
  4217. +static int isa_probe(struct dev *dev, const char *type_name)
  4218. {
  4219. - unsigned short vendor;
  4220. - unsigned short dev_id;
  4221. - struct nic *(*eth_probe) (struct nic *, unsigned short *,
  4222. - struct pci_device *);
  4223. -};
  4224. -
  4225. -static struct pci_dispatch_table PCI_NIC[] =
  4226. -{
  4227. -# ifdef INCLUDE_NS8390
  4228. - { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8029, nepci_probe },
  4229. - { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C940, nepci_probe },
  4230. - { PCI_VENDOR_ID_COMPEX, PCI_DEVICE_ID_COMPEX_RL2000, nepci_probe },
  4231. - { PCI_VENDOR_ID_KTI, PCI_DEVICE_ID_KTI_ET32P2, nepci_probe },
  4232. - { PCI_VENDOR_ID_NETVIN, PCI_DEVICE_ID_NETVIN_NV5000SC, nepci_probe },
  4233. - { PCI_VENDOR_ID_HOLTEK, PCI_DEVICE_ID_HOLTEK_HT80232, nepci_probe },
  4234. -# endif /* INCLUDE_NS8390 */
  4235. -# ifdef INCLUDE_3C90X
  4236. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900TPO, a3c90x_probe },
  4237. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900COMBO, a3c90x_probe },
  4238. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905TX, a3c90x_probe },
  4239. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905T4, a3c90x_probe },
  4240. - { PCI_VENDOR_ID_3COM, 0x9004, a3c90x_probe },
  4241. - { PCI_VENDOR_ID_3COM, 0x9005, a3c90x_probe },
  4242. - { PCI_VENDOR_ID_3COM, 0x9006, a3c90x_probe },
  4243. - { PCI_VENDOR_ID_3COM, 0x900A, a3c90x_probe },
  4244. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905B_TX, a3c90x_probe },
  4245. - { PCI_VENDOR_ID_3COM, 0x9056, a3c90x_probe },
  4246. - { PCI_VENDOR_ID_3COM, 0x905A, a3c90x_probe },
  4247. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905C_TXM, a3c90x_probe },
  4248. - { PCI_VENDOR_ID_3COM, 0x9800, a3c90x_probe },
  4249. - { PCI_VENDOR_ID_3COM, 0x9805, a3c90x_probe },
  4250. - { PCI_VENDOR_ID_3COM, 0x7646, a3c90x_probe },
  4251. -# endif /* INCLUDE_3C90X */
  4252. -# ifdef INCLUDE_3C595
  4253. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C590, t595_probe },
  4254. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595, t595_probe },
  4255. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595_1, t595_probe },
  4256. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595_2, t595_probe },
  4257. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900TPO, t595_probe },
  4258. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900COMBO, t595_probe },
  4259. - { PCI_VENDOR_ID_3COM, 0x9004, t595_probe },
  4260. - { PCI_VENDOR_ID_3COM, 0x9005, t595_probe },
  4261. - { PCI_VENDOR_ID_3COM, 0x9006, t595_probe },
  4262. - { PCI_VENDOR_ID_3COM, 0x900A, t595_probe },
  4263. - { PCI_VENDOR_ID_3COM, 0x9800, t595_probe },
  4264. - { PCI_VENDOR_ID_3COM, 0x9805, t595_probe },
  4265. - { PCI_VENDOR_ID_3COM, 0x7646, t595_probe },
  4266. -# endif /* INCLUDE_3C595 */
  4267. -# ifdef INCLUDE_EEPRO100
  4268. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557, eepro100_probe },
  4269. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER, eepro100_probe },
  4270. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1029, eepro100_probe },
  4271. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1030, eepro100_probe },
  4272. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82562, eepro100_probe },
  4273. -# endif /* INCLUDE_EEPRO100 */
  4274. -# ifdef INCLUDE_EPIC100
  4275. - { PCI_VENDOR_ID_SMC, PCI_DEVICE_ID_SMC_EPIC100, epic100_probe },
  4276. -# endif /* INCLUDE_EPIC100 */
  4277. -# ifdef INCLUDE_LANCE
  4278. - { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE, lancepci_probe },
  4279. - { PCI_VENDOR_ID_AMD_HOMEPNA, PCI_DEVICE_ID_AMD_HOMEPNA, lancepci_probe },
  4280. -# endif /* INCLUDE_LANCE */
  4281. -# ifdef INCLUDE_RTL8139
  4282. - { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139, rtl8139_probe },
  4283. - { PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DFE530TXP, rtl8139_probe },
  4284. - { PCI_VENDOR_ID_SMC_1211, PCI_DEVICE_ID_SMC_1211, rtl8139_probe },
  4285. -# endif /* INCLUDE_RTL8139 */
  4286. -# ifdef INCLUDE_OTULIP
  4287. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP, otulip_probe },
  4288. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST, otulip_probe },
  4289. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS, otulip_probe },
  4290. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142, otulip_probe },
  4291. -# endif /* INCLUDE_OTULIP */
  4292. -# ifdef INCLUDE_TULIP
  4293. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP, tulip_probe },
  4294. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST, tulip_probe },
  4295. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS, tulip_probe },
  4296. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142, tulip_probe },
  4297. - { PCI_VENDOR_ID_MACRONIX, PCI_DEVICE_ID_MX987x5, tulip_probe },
  4298. - { PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LC82C115, tulip_probe },
  4299. - { PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_DEC_TULIP, tulip_probe },
  4300. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9102, tulip_probe },
  4301. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9009, tulip_probe },
  4302. - { PCI_VENDOR_ID_ADMTEK, PCI_DEVICE_ID_ADMTEK_0985, tulip_probe },
  4303. - { PCI_VENDOR_ID_ADMTEK, 0x0981, tulip_probe },
  4304. - { 0x125B, 0x1400, tulip_probe },
  4305. - { 0x11F6, 0x9881, tulip_probe },
  4306. -# endif /* INCLUDE_TULIP */
  4307. -# ifdef INCLUDE_DAVICOM
  4308. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9102, davicom_probe },
  4309. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9009, davicom_probe },
  4310. -# endif /* INCLUDE_DAVICOM */
  4311. -# ifdef INCLUDE_VIA_RHINE
  4312. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_VT6102, rhine_probe },
  4313. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_RHINE_I, rhine_probe },
  4314. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_86C100A, rhine_probe },
  4315. -# endif /* INCLUDE_VIA_RHINE */
  4316. -# ifdef INCLUDE_W89C840
  4317. - { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C840, w89c840_probe },
  4318. - { PCI_VENDOR_ID_COMPEX, PCI_DEVICE_ID_COMPEX_RL100ATX, w89c840_probe },
  4319. -# endif /* INCLUDE_W89C840 */
  4320. -# ifdef INCLUDE_SIS900
  4321. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS900, sis900_probe },
  4322. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS7016, sis900_probe },
  4323. -# endif /* INCLUDE_SIS900 */
  4324. -# ifdef INCLUDE_NATSEMI
  4325. - { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_DP83815, natsemi_probe },
  4326. -# endif /* INCLUDE_NATSEMI */
  4327. -# ifdef INCLUDE_TLAN
  4328. - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2326, tlan_probe },
  4329. -# endif /* INCLUDE_TLAN */
  4330. - { 0, 0, 0 }
  4331. -};
  4332. -#endif /* GRUB && INCLUDE_PCI */
  4333. -
  4334. -struct dispatch_table
  4335. -{
  4336. - const char *nic_name;
  4337. -#ifdef INCLUDE_PCI
  4338. - struct nic *(*eth_probe) (struct nic *, unsigned short *,
  4339. - struct pci_device *);
  4340. -#else
  4341. - struct nic *(*eth_probe) (struct nic *, unsigned short *);
  4342. -#endif /* INCLUDE_PCI */
  4343. - unsigned short *probe_ioaddrs; /* for probe overrides */
  4344. -};
  4345. -
  4346. /*
  4347. - * NIC probing is in order of appearance in this table.
  4348. + * NIC probing is in the order the drivers were linked togeter.
  4349. * If for some reason you want to change the order,
  4350. - * just rearrange the entries (bracketed by the #ifdef/#endif)
  4351. + * just change the order you list the drivers in.
  4352. */
  4353. -static struct dispatch_table NIC[] =
  4354. -{
  4355. -#ifdef INCLUDE_RTL8139
  4356. - { "RTL8139", rtl8139_probe, pci_ioaddrs },
  4357. -#endif
  4358. -#ifdef INCLUDE_SIS900
  4359. - { "SIS900", sis900_probe, pci_ioaddrs },
  4360. -#endif
  4361. -#ifdef INCLUDE_NATSEMI
  4362. - { "NATSEMI", natsemi_probe, pci_ioaddrs },
  4363. -#endif
  4364. -#ifdef INCLUDE_WD
  4365. - { "WD", wd_probe, 0 },
  4366. -#endif
  4367. -#ifdef INCLUDE_3C503
  4368. - { "3C503", t503_probe, 0 },
  4369. -#endif
  4370. -#ifdef INCLUDE_NE
  4371. - { "NE*000", ne_probe, 0 },
  4372. -#endif
  4373. -#ifdef INCLUDE_3C509
  4374. - { "3C5x9", t509_probe, 0 },
  4375. -#endif
  4376. -#ifdef INCLUDE_3C529
  4377. - { "3C5x9", t529_probe, 0 },
  4378. -#endif
  4379. -#ifdef INCLUDE_3C595
  4380. - { "3C595", t595_probe, pci_ioaddrs },
  4381. -#endif
  4382. -#ifdef INCLUDE_3C90X
  4383. - { "3C90X", a3c90x_probe, pci_ioaddrs },
  4384. -#endif
  4385. -#ifdef INCLUDE_EEPRO
  4386. - { "EEPRO", eepro_probe, 0 },
  4387. -#endif
  4388. -#ifdef INCLUDE_EEPRO100
  4389. - { "EEPRO100", eepro100_probe, pci_ioaddrs },
  4390. -#endif
  4391. -#ifdef INCLUDE_EPIC100
  4392. - { "EPIC100", epic100_probe, pci_ioaddrs },
  4393. -#endif
  4394. -#ifdef INCLUDE_OTULIP
  4395. - { "OTulip", otulip_probe, pci_ioaddrs },
  4396. -#endif
  4397. -#ifdef INCLUDE_TULIP
  4398. - { "Tulip", tulip_probe, pci_ioaddrs },
  4399. -#endif
  4400. -#ifdef INCLUDE_DAVICOM
  4401. - { "DAVICOM", davicom_probe, pci_ioaddrs },
  4402. -#endif
  4403. -#ifdef INCLUDE_CS89X0
  4404. - { "CS89x0", cs89x0_probe, 0 },
  4405. -#endif
  4406. -#ifdef INCLUDE_NE2100
  4407. - { "NE2100", ne2100_probe, 0 },
  4408. -#endif
  4409. -#ifdef INCLUDE_NI6510
  4410. - { "NI6510", ni6510_probe, 0 },
  4411. -#endif
  4412. -#ifdef INCLUDE_SK_G16
  4413. - { "SK_G16", SK_probe, 0 },
  4414. -#endif
  4415. -#ifdef INCLUDE_3C507
  4416. - { "3C507", t507_probe, 0 },
  4417. -#endif
  4418. -#ifdef INCLUDE_NI5010
  4419. - { "NI5010", ni5010_probe, 0 },
  4420. -#endif
  4421. -#ifdef INCLUDE_NI5210
  4422. - { "NI5210", ni5210_probe, 0 },
  4423. -#endif
  4424. -#ifdef INCLUDE_EXOS205
  4425. - { "EXOS205", exos205_probe, 0 },
  4426. -#endif
  4427. -#ifdef INCLUDE_SMC9000
  4428. - { "SMC9000", smc9000_probe, 0 },
  4429. -#endif
  4430. -#ifdef INCLUDE_TIARA
  4431. - { "TIARA", tiara_probe, 0 },
  4432. -#endif
  4433. -#ifdef INCLUDE_DEPCA
  4434. - { "DEPCA", depca_probe, 0 },
  4435. -#endif
  4436. -#ifdef INCLUDE_NS8390
  4437. - { "NE2000/PCI", nepci_probe, pci_ioaddrs },
  4438. -#endif
  4439. -#ifdef INCLUDE_LANCE
  4440. - { "LANCE/PCI", lancepci_probe, pci_ioaddrs },
  4441. -#endif
  4442. -#ifdef INCLUDE_VIA_RHINE
  4443. - { "VIA 86C100", rhine_probe, pci_ioaddrs },
  4444. -#endif
  4445. -#ifdef INCLUDE_W89C840
  4446. - { "W89C840F", w89c840_probe, pci_ioaddrs },
  4447. -#endif
  4448. -#ifdef INCLUDE_TLAN
  4449. - { "Olicom 2326", tlan_probe, pci_ioaddrs },
  4450. -#endif
  4451. - /* this entry must always be last to mark the end of list */
  4452. - { 0, 0, 0 }
  4453. -};
  4454. -
  4455. -#define NIC_TABLE_SIZE (sizeof (NIC) / sizeof (NIC[0]))
  4456. -
  4457. -static int
  4458. -eth_dummy (struct nic *dummy)
  4459. -{
  4460. - return 0;
  4461. + struct isa_probe_state *state = &dev->state.isa;
  4462. + printf("Probing isa %s...\n", type_name);
  4463. + if (dev->how_probe == PROBE_FIRST) {
  4464. + state->advance = 0;
  4465. + state->driver = isa_drivers;
  4466. + dev->index = -1;
  4467. + }
  4468. + for(;;)
  4469. + {
  4470. + if ((dev->how_probe != PROBE_AWAKE) && state->advance) {
  4471. + state->driver++;
  4472. + dev->index = -1;
  4473. + }
  4474. + state->advance = 1;
  4475. +
  4476. + if (state->driver >= isa_drivers_end)
  4477. + break;
  4478. +
  4479. + if (state->driver->type != dev->type)
  4480. + continue;
  4481. +
  4482. + if (dev->how_probe != PROBE_AWAKE) {
  4483. + dev->type_index++;
  4484. + }
  4485. + printf("[%s]", state->driver->name);
  4486. + dev->devid.bus_type = ISA_BUS_TYPE;
  4487. + /* FIXME how do I handle dev->index + PROBE_AGAIN?? */
  4488. + /* driver will fill in vendor and device IDs */
  4489. + if (state->driver->probe(dev, state->driver->ioaddrs)) {
  4490. + state->advance = (dev->index == -1);
  4491. + return PROBE_WORKED;
  4492. + }
  4493. + putchar('\n');
  4494. + }
  4495. + return PROBE_FAILED;
  4496. }
  4497. -
  4498. -static char packet[ETH_FRAME_LEN];
  4499. -
  4500. -struct nic nic =
  4501. -{
  4502. - (void (*) (struct nic *)) eth_dummy, /* reset */
  4503. - eth_dummy, /* poll */
  4504. - (void (*) (struct nic *, const char *,
  4505. - unsigned int, unsigned int,
  4506. - const char *)) eth_dummy, /* transmit */
  4507. - (void (*) (struct nic *)) eth_dummy, /* disable */
  4508. -#ifdef T503_AUI
  4509. - 1, /* aui */
  4510. #else
  4511. - 0, /* no aui */
  4512. +#define isa_probe(d,tn) (PROBE_FAILED)
  4513. #endif
  4514. - &rom, /* rom_info */
  4515. - arptable[ARP_CLIENT].node, /* node_addr */
  4516. - packet, /* packet */
  4517. - 0, /* packetlen */
  4518. - 0, /* priv_data */
  4519. +static const char *driver_name[] = {
  4520. + "nic",
  4521. + "disk",
  4522. + "floppy",
  4523. };
  4524. -
  4525. -void
  4526. -eth_reset (void)
  4527. +int probe(struct dev *dev)
  4528. {
  4529. - (*nic.reset) (&nic);
  4530. -}
  4531. + const char *type_name;
  4532. -int
  4533. -eth_probe (void)
  4534. -{
  4535. - struct pci_device *p;
  4536. - const struct dispatch_table *t;
  4537. - static int probed = 0;
  4538. + EnterFunction("probe");
  4539. - /* If already probed, don't try to probe it any longer. */
  4540. - if (probed)
  4541. - return 1;
  4542. -
  4543. - /* Clear the ready flag. */
  4544. - network_ready = 0;
  4545. - /* Clear the ARP table. */
  4546. - grub_memset ((char *) arptable, 0,
  4547. - MAX_ARP * sizeof (struct arptable_t));
  4548. -
  4549. - p = 0;
  4550. -
  4551. -#ifdef INCLUDE_PCI
  4552. - /* In GRUB, the ROM info is initialized here. */
  4553. - rom = *((struct rom_info *) ROM_INFO_LOCATION);
  4554. -
  4555. - eth_pci_init(pci_nic_list);
  4556. - pci_ioaddrs[0] = 0;
  4557. - pci_ioaddrs[1] = 0;
  4558. - /* at this point we have a list of possible PCI candidates
  4559. - we just pick the first one with a non-zero ioaddr */
  4560. - for (p = pci_nic_list; p->vendor != 0; ++p)
  4561. - {
  4562. - if (p->ioaddr != 0)
  4563. - {
  4564. - pci_ioaddrs[0] = p->ioaddr;
  4565. - break;
  4566. + type_name = "";
  4567. + if ((dev->type >= 0) &&
  4568. + (dev->type < sizeof(driver_name)/sizeof(driver_name[0]))) {
  4569. + type_name = driver_name[dev->type];
  4570. }
  4571. - }
  4572. -#endif
  4573. -
  4574. - etherboot_printf("Probing...");
  4575. -
  4576. -#ifdef INCLUDE_PCI
  4577. - if (p->vendor)
  4578. - {
  4579. - struct pci_dispatch_table *pt;
  4580. -
  4581. - for (pt = PCI_NIC; pt->eth_probe != 0; pt++)
  4582. - if (p->vendor == pt->vendor && p->dev_id == pt->dev_id)
  4583. - {
  4584. - etherboot_printf ("[%s]", p->name);
  4585. - if ((pt->eth_probe) (&nic, pci_ioaddrs, p))
  4586. - {
  4587. - probed = 1;
  4588. - return 1;
  4589. - }
  4590. - }
  4591. - }
  4592. -#endif /* INCLUDE_PCI */
  4593. -
  4594. - for (t = NIC; t->nic_name != 0; ++t)
  4595. - {
  4596. - etherboot_printf("[%s]", t->nic_name);
  4597. -#ifdef INCLUDE_PCI
  4598. - if ((*t->eth_probe) (&nic, t->probe_ioaddrs, p))
  4599. - {
  4600. - probed = 1;
  4601. - return 1;
  4602. + if (dev->how_probe == PROBE_FIRST) {
  4603. + dev->to_probe = PROBE_PCI;
  4604. + memset(&dev->state, 0, sizeof(dev->state));
  4605. }
  4606. -#else
  4607. - if ((*t->eth_probe) (&nic, t->probe_ioaddrs))
  4608. - {
  4609. - probed = 1;
  4610. - return 1;
  4611. + if (dev->to_probe == PROBE_PCI) {
  4612. + dev->how_probe = pci_probe(dev, type_name);
  4613. + if (dev->how_probe == PROBE_FAILED) {
  4614. + dev->to_probe = PROBE_ISA;
  4615. + }
  4616. + }
  4617. + if (dev->to_probe == PROBE_ISA) {
  4618. + dev->how_probe = isa_probe(dev, type_name);
  4619. + if (dev->how_probe == PROBE_FAILED) {
  4620. + dev->to_probe = PROBE_NONE;
  4621. + }
  4622. + }
  4623. + if ((dev->to_probe != PROBE_PCI) &&
  4624. + (dev->to_probe != PROBE_ISA)) {
  4625. + dev->how_probe = PROBE_FAILED;
  4626. +
  4627. }
  4628. -#endif /* INCLUDE_PCI */
  4629. - }
  4630. -
  4631. - return 0;
  4632. -}
  4633. -
  4634. -int
  4635. -eth_poll (void)
  4636. -{
  4637. - return ((*nic.poll) (&nic));
  4638. -}
  4639. -void
  4640. -eth_transmit (const char *d, unsigned int t, unsigned int s, const void *p)
  4641. -{
  4642. - (*nic.transmit) (&nic, d, t, s, p);
  4643. - if (t == IP)
  4644. - twiddle ();
  4645. + LeaveFunction("probe");
  4646. + return dev->how_probe;
  4647. }
  4648. -void
  4649. -eth_disable (void)
  4650. +void disable(struct dev *dev)
  4651. {
  4652. - (*nic.disable) (&nic);
  4653. + if (dev->disable) {
  4654. + dev->disable(dev);
  4655. + dev->disable = 0;
  4656. + }
  4657. }
  4658. Index: b/netboot/cpu.h
  4659. ===================================================================
  4660. --- /dev/null
  4661. +++ b/netboot/cpu.h
  4662. @@ -0,0 +1,243 @@
  4663. +#ifndef I386_BITS_CPU_H
  4664. +#define I386_BITS_CPU_H
  4665. +
  4666. +
  4667. +/* Sample usage: CPU_FEATURE_P(cpu.x86_capability, FPU) */
  4668. +#define CPU_FEATURE_P(CAP, FEATURE) \
  4669. + (!!(CAP[(X86_FEATURE_##FEATURE)/32] & ((X86_FEATURE_##FEATURE) & 0x1f)))
  4670. +
  4671. +#define NCAPINTS 4 /* Currently we have 4 32-bit words worth of info */
  4672. +
  4673. +/* Intel-defined CPU features, CPUID level 0x00000001, word 0 */
  4674. +#define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */
  4675. +#define X86_FEATURE_VME (0*32+ 1) /* Virtual Mode Extensions */
  4676. +#define X86_FEATURE_DE (0*32+ 2) /* Debugging Extensions */
  4677. +#define X86_FEATURE_PSE (0*32+ 3) /* Page Size Extensions */
  4678. +#define X86_FEATURE_TSC (0*32+ 4) /* Time Stamp Counter */
  4679. +#define X86_FEATURE_MSR (0*32+ 5) /* Model-Specific Registers, RDMSR, WRMSR */
  4680. +#define X86_FEATURE_PAE (0*32+ 6) /* Physical Address Extensions */
  4681. +#define X86_FEATURE_MCE (0*32+ 7) /* Machine Check Architecture */
  4682. +#define X86_FEATURE_CX8 (0*32+ 8) /* CMPXCHG8 instruction */
  4683. +#define X86_FEATURE_APIC (0*32+ 9) /* Onboard APIC */
  4684. +#define X86_FEATURE_SEP (0*32+11) /* SYSENTER/SYSEXIT */
  4685. +#define X86_FEATURE_MTRR (0*32+12) /* Memory Type Range Registers */
  4686. +#define X86_FEATURE_PGE (0*32+13) /* Page Global Enable */
  4687. +#define X86_FEATURE_MCA (0*32+14) /* Machine Check Architecture */
  4688. +#define X86_FEATURE_CMOV (0*32+15) /* CMOV instruction (FCMOVCC and FCOMI too if FPU present) */
  4689. +#define X86_FEATURE_PAT (0*32+16) /* Page Attribute Table */
  4690. +#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */
  4691. +#define X86_FEATURE_PN (0*32+18) /* Processor serial number */
  4692. +#define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */
  4693. +#define X86_FEATURE_DTES (0*32+21) /* Debug Trace Store */
  4694. +#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */
  4695. +#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */
  4696. +#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */
  4697. + /* of FPU context), and CR4.OSFXSR available */
  4698. +#define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */
  4699. +#define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */
  4700. +#define X86_FEATURE_SELFSNOOP (0*32+27) /* CPU self snoop */
  4701. +#define X86_FEATURE_HT (0*32+28) /* Hyper-Threading */
  4702. +#define X86_FEATURE_ACC (0*32+29) /* Automatic clock control */
  4703. +#define X86_FEATURE_IA64 (0*32+30) /* IA-64 processor */
  4704. +
  4705. +/* AMD-defined CPU features, CPUID level 0x80000001, word 1 */
  4706. +/* Don't duplicate feature flags which are redundant with Intel! */
  4707. +#define X86_FEATURE_SYSCALL (1*32+11) /* SYSCALL/SYSRET */
  4708. +#define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */
  4709. +#define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64) */
  4710. +#define X86_FEATURE_3DNOWEXT (1*32+30) /* AMD 3DNow! extensions */
  4711. +#define X86_FEATURE_3DNOW (1*32+31) /* 3DNow! */
  4712. +
  4713. +/* Transmeta-defined CPU features, CPUID level 0x80860001, word 2 */
  4714. +#define X86_FEATURE_RECOVERY (2*32+ 0) /* CPU in recovery mode */
  4715. +#define X86_FEATURE_LONGRUN (2*32+ 1) /* Longrun power control */
  4716. +#define X86_FEATURE_LRTI (2*32+ 3) /* LongRun table interface */
  4717. +
  4718. +/* Other features, Linux-defined mapping, word 3 */
  4719. +/* This range is used for feature bits which conflict or are synthesized */
  4720. +#define X86_FEATURE_CXMMX (3*32+ 0) /* Cyrix MMX extensions */
  4721. +#define X86_FEATURE_K6_MTRR (3*32+ 1) /* AMD K6 nonstandard MTRRs */
  4722. +#define X86_FEATURE_CYRIX_ARR (3*32+ 2) /* Cyrix ARRs (= MTRRs) */
  4723. +#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */
  4724. +
  4725. +#define MAX_X86_VENDOR_ID 16
  4726. +struct cpuinfo_x86 {
  4727. + uint8_t x86; /* CPU family */
  4728. + uint8_t x86_model;
  4729. + uint8_t x86_mask;
  4730. +
  4731. + int cpuid_level; /* Maximum supported CPUID level, -1=no CPUID */
  4732. + unsigned x86_capability[NCAPINTS];
  4733. + char x86_vendor_id[MAX_X86_VENDOR_ID];
  4734. +};
  4735. +
  4736. +
  4737. +#define X86_VENDOR_INTEL 0
  4738. +#define X86_VENDOR_CYRIX 1
  4739. +#define X86_VENDOR_AMD 2
  4740. +#define X86_VENDOR_UMC 3
  4741. +#define X86_VENDOR_NEXGEN 4
  4742. +#define X86_VENDOR_CENTAUR 5
  4743. +#define X86_VENDOR_RISE 6
  4744. +#define X86_VENDOR_TRANSMETA 7
  4745. +#define X86_VENDOR_NSC 8
  4746. +#define X86_VENDOR_UNKNOWN 0xff
  4747. +
  4748. +/*
  4749. + * EFLAGS bits
  4750. + */
  4751. +#define X86_EFLAGS_CF 0x00000001 /* Carry Flag */
  4752. +#define X86_EFLAGS_PF 0x00000004 /* Parity Flag */
  4753. +#define X86_EFLAGS_AF 0x00000010 /* Auxillary carry Flag */
  4754. +#define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */
  4755. +#define X86_EFLAGS_SF 0x00000080 /* Sign Flag */
  4756. +#define X86_EFLAGS_TF 0x00000100 /* Trap Flag */
  4757. +#define X86_EFLAGS_IF 0x00000200 /* Interrupt Flag */
  4758. +#define X86_EFLAGS_DF 0x00000400 /* Direction Flag */
  4759. +#define X86_EFLAGS_OF 0x00000800 /* Overflow Flag */
  4760. +#define X86_EFLAGS_IOPL 0x00003000 /* IOPL mask */
  4761. +#define X86_EFLAGS_NT 0x00004000 /* Nested Task */
  4762. +#define X86_EFLAGS_RF 0x00010000 /* Resume Flag */
  4763. +#define X86_EFLAGS_VM 0x00020000 /* Virtual Mode */
  4764. +#define X86_EFLAGS_AC 0x00040000 /* Alignment Check */
  4765. +#define X86_EFLAGS_VIF 0x00080000 /* Virtual Interrupt Flag */
  4766. +#define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
  4767. +#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
  4768. +
  4769. +/*
  4770. + * Generic CPUID function
  4771. + */
  4772. +static inline void cpuid(int op,
  4773. + unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx)
  4774. +{
  4775. + __asm__("cpuid"
  4776. + : "=a" (*eax),
  4777. + "=b" (*ebx),
  4778. + "=c" (*ecx),
  4779. + "=d" (*edx)
  4780. + : "0" (op));
  4781. +}
  4782. +
  4783. +/*
  4784. + * CPUID functions returning a single datum
  4785. + */
  4786. +static inline unsigned int cpuid_eax(unsigned int op)
  4787. +{
  4788. + unsigned int eax;
  4789. +
  4790. + __asm__("cpuid"
  4791. + : "=a" (eax)
  4792. + : "0" (op)
  4793. + : "bx", "cx", "dx");
  4794. + return eax;
  4795. +}
  4796. +static inline unsigned int cpuid_ebx(unsigned int op)
  4797. +{
  4798. + unsigned int eax, ebx;
  4799. +
  4800. + __asm__("cpuid"
  4801. + : "=a" (eax), "=b" (ebx)
  4802. + : "0" (op)
  4803. + : "cx", "dx" );
  4804. + return ebx;
  4805. +}
  4806. +static inline unsigned int cpuid_ecx(unsigned int op)
  4807. +{
  4808. + unsigned int eax, ecx;
  4809. +
  4810. + __asm__("cpuid"
  4811. + : "=a" (eax), "=c" (ecx)
  4812. + : "0" (op)
  4813. + : "bx", "dx" );
  4814. + return ecx;
  4815. +}
  4816. +static inline unsigned int cpuid_edx(unsigned int op)
  4817. +{
  4818. + unsigned int eax, edx;
  4819. +
  4820. + __asm__("cpuid"
  4821. + : "=a" (eax), "=d" (edx)
  4822. + : "0" (op)
  4823. + : "bx", "cx");
  4824. + return edx;
  4825. +}
  4826. +
  4827. +/*
  4828. + * Intel CPU features in CR4
  4829. + */
  4830. +#define X86_CR4_VME 0x0001 /* enable vm86 extensions */
  4831. +#define X86_CR4_PVI 0x0002 /* virtual interrupts flag enable */
  4832. +#define X86_CR4_TSD 0x0004 /* disable time stamp at ipl 3 */
  4833. +#define X86_CR4_DE 0x0008 /* enable debugging extensions */
  4834. +#define X86_CR4_PSE 0x0010 /* enable page size extensions */
  4835. +#define X86_CR4_PAE 0x0020 /* enable physical address extensions */
  4836. +#define X86_CR4_MCE 0x0040 /* Machine check enable */
  4837. +#define X86_CR4_PGE 0x0080 /* enable global pages */
  4838. +#define X86_CR4_PCE 0x0100 /* enable performance counters at ipl 3 */
  4839. +#define X86_CR4_OSFXSR 0x0200 /* enable fast FPU save and restore */
  4840. +#define X86_CR4_OSXMMEXCPT 0x0400 /* enable unmasked SSE exceptions */
  4841. +
  4842. +
  4843. +#define MSR_K6_EFER 0xC0000080
  4844. +/* EFER bits: */
  4845. +#define _EFER_SCE 0 /* SYSCALL/SYSRET */
  4846. +#define _EFER_LME 8 /* Long mode enable */
  4847. +#define _EFER_LMA 10 /* Long mode active (read-only) */
  4848. +#define _EFER_NX 11 /* No execute enable */
  4849. +
  4850. +#define EFER_SCE (1<<_EFER_SCE)
  4851. +#define EFER_LME (1<<EFER_LME)
  4852. +#define EFER_LMA (1<<EFER_LMA)
  4853. +#define EFER_NX (1<<_EFER_NX)
  4854. +
  4855. +#define rdmsr(msr,val1,val2) \
  4856. + __asm__ __volatile__("rdmsr" \
  4857. + : "=a" (val1), "=d" (val2) \
  4858. + : "c" (msr))
  4859. +
  4860. +#define wrmsr(msr,val1,val2) \
  4861. + __asm__ __volatile__("wrmsr" \
  4862. + : /* no outputs */ \
  4863. + : "c" (msr), "a" (val1), "d" (val2))
  4864. +
  4865. +
  4866. +#define read_cr0() ({ \
  4867. + unsigned int __dummy; \
  4868. + __asm__( \
  4869. + "movl %%cr0, %0\n\t" \
  4870. + :"=r" (__dummy)); \
  4871. + __dummy; \
  4872. +})
  4873. +#define write_cr0(x) \
  4874. + __asm__("movl %0,%%cr0": :"r" (x));
  4875. +
  4876. +#define read_cr3() ({ \
  4877. + unsigned int __dummy; \
  4878. + __asm__( \
  4879. + "movl %%cr3, %0\n\t" \
  4880. + :"=r" (__dummy)); \
  4881. + __dummy; \
  4882. +})
  4883. +#define write_cr3x(x) \
  4884. + __asm__("movl %0,%%cr3": :"r" (x));
  4885. +
  4886. +
  4887. +#define read_cr4() ({ \
  4888. + unsigned int __dummy; \
  4889. + __asm__( \
  4890. + "movl %%cr4, %0\n\t" \
  4891. + :"=r" (__dummy)); \
  4892. + __dummy; \
  4893. +})
  4894. +#define write_cr4x(x) \
  4895. + __asm__("movl %0,%%cr4": :"r" (x));
  4896. +
  4897. +
  4898. +extern struct cpuinfo_x86 cpu_info;
  4899. +#ifdef CONFIG_X86_64
  4900. +extern void cpu_setup(void);
  4901. +#else
  4902. +#define cpu_setup() do {} while(0)
  4903. +#endif
  4904. +
  4905. +#endif /* I386_BITS_CPU_H */
  4906. Index: b/netboot/cs89x0.c
  4907. ===================================================================
  4908. --- a/netboot/cs89x0.c
  4909. +++ b/netboot/cs89x0.c
  4910. @@ -16,662 +16,3 @@
  4911. -- quote from email
  4912. **/
  4913. -/* cs89x0.c: A Crystal Semiconductor CS89[02]0 driver for etherboot. */
  4914. -/*
  4915. - Permission is granted to distribute the enclosed cs89x0.[ch] driver
  4916. - only in conjunction with the Etherboot package. The code is
  4917. - ordinarily distributed under the GPL.
  4918. -
  4919. - Russ Nelson, January 2000
  4920. -
  4921. - ChangeLog:
  4922. -
  4923. - Thu Dec 6 22:40:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4924. -
  4925. - * disabled all "advanced" features; this should make the code more reliable
  4926. -
  4927. - * reorganized the reset function
  4928. -
  4929. - * always reset the address port, so that autoprobing will continue working
  4930. -
  4931. - * some cosmetic changes
  4932. -
  4933. - * 2.5
  4934. -
  4935. - Thu Dec 5 21:00:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4936. -
  4937. - * tested the code against a CS8900 card
  4938. -
  4939. - * lots of minor bug fixes and adjustments
  4940. -
  4941. - * this is the first release, that actually works! it still requires some
  4942. - changes in order to be more tolerant to different environments
  4943. -
  4944. - * 4
  4945. -
  4946. - Fri Nov 22 23:00:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4947. -
  4948. - * read the manuals for the CS89x0 chipsets and took note of all the
  4949. - changes that will be neccessary in order to adapt Russel Nelson's code
  4950. - to the requirements of a BOOT-Prom
  4951. -
  4952. - * 6
  4953. -
  4954. - Thu Nov 19 22:00:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4955. -
  4956. - * Synched with Russel Nelson's current code (v1.00)
  4957. -
  4958. - * 2
  4959. -
  4960. - Thu Nov 12 18:00:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4961. -
  4962. - * Cleaned up some of the code and tried to optimize the code size.
  4963. -
  4964. - * 1.5
  4965. -
  4966. - Sun Nov 10 16:30:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4967. -
  4968. - * First experimental release. This code compiles fine, but I
  4969. - have no way of testing whether it actually works.
  4970. -
  4971. - * I did not (yet) bother to make the code 16bit aware, so for
  4972. - the time being, it will only work for Etherboot/32.
  4973. -
  4974. - * 12
  4975. -
  4976. - */
  4977. -
  4978. -#include "etherboot.h"
  4979. -#include "nic.h"
  4980. -#include "cards.h"
  4981. -#include "cs89x0.h"
  4982. -
  4983. -static unsigned short eth_nic_base;
  4984. -static unsigned long eth_mem_start;
  4985. -static unsigned short eth_irq;
  4986. -static unsigned short eth_cs_type; /* one of: CS8900, CS8920, CS8920M */
  4987. -static unsigned short eth_auto_neg_cnf;
  4988. -static unsigned short eth_adapter_cnf;
  4989. -static unsigned short eth_linectl;
  4990. -
  4991. -/*************************************************************************
  4992. - CS89x0 - specific routines
  4993. -**************************************************************************/
  4994. -
  4995. -static inline int readreg(int portno)
  4996. -{
  4997. - outw(portno, eth_nic_base + ADD_PORT);
  4998. - return inw(eth_nic_base + DATA_PORT);
  4999. -}
  5000. -
  5001. -static inline void writereg(int portno, int value)
  5002. -{
  5003. - outw(portno, eth_nic_base + ADD_PORT);
  5004. - outw(value, eth_nic_base + DATA_PORT);
  5005. - return;
  5006. -}
  5007. -
  5008. -/*************************************************************************
  5009. -EEPROM access
  5010. -**************************************************************************/
  5011. -
  5012. -static int wait_eeprom_ready(void)
  5013. -{
  5014. - unsigned long tmo = currticks() + 4*TICKS_PER_SEC;
  5015. -
  5016. - /* check to see if the EEPROM is ready, a timeout is used -
  5017. - just in case EEPROM is ready when SI_BUSY in the
  5018. - PP_SelfST is clear */
  5019. - while(readreg(PP_SelfST) & SI_BUSY) {
  5020. - if (currticks() >= tmo)
  5021. - return -1; }
  5022. - return 0;
  5023. -}
  5024. -
  5025. -static int get_eeprom_data(int off, int len, unsigned short *buffer)
  5026. -{
  5027. - int i;
  5028. -
  5029. -#ifdef EDEBUG
  5030. - printf("\ncs: EEPROM data from %hX for %hX:",off,len);
  5031. -#endif
  5032. - for (i = 0; i < len; i++) {
  5033. - if (wait_eeprom_ready() < 0)
  5034. - return -1;
  5035. - /* Now send the EEPROM read command and EEPROM location
  5036. - to read */
  5037. - writereg(PP_EECMD, (off + i) | EEPROM_READ_CMD);
  5038. - if (wait_eeprom_ready() < 0)
  5039. - return -1;
  5040. - buffer[i] = readreg(PP_EEData);
  5041. -#ifdef EDEBUG
  5042. - if (!(i%10))
  5043. - printf("\ncs: ");
  5044. - printf("%hX ", buffer[i]);
  5045. -#endif
  5046. - }
  5047. -#ifdef EDEBUG
  5048. - putchar('\n');
  5049. -#endif
  5050. -
  5051. - return(0);
  5052. -}
  5053. -
  5054. -static int get_eeprom_chksum(int off, int len, unsigned short *buffer)
  5055. -{
  5056. - int i, cksum;
  5057. -
  5058. - cksum = 0;
  5059. - for (i = 0; i < len; i++)
  5060. - cksum += buffer[i];
  5061. - cksum &= 0xffff;
  5062. - if (cksum == 0)
  5063. - return 0;
  5064. - return -1;
  5065. -}
  5066. -
  5067. -/*************************************************************************
  5068. -Activate all of the available media and probe for network
  5069. -**************************************************************************/
  5070. -
  5071. -static void clrline(void)
  5072. -{
  5073. - int i;
  5074. -
  5075. - putchar('\r');
  5076. - for (i = 79; i--; ) putchar(' ');
  5077. - printf("\rcs: ");
  5078. - return;
  5079. -}
  5080. -
  5081. -static void control_dc_dc(int on_not_off)
  5082. -{
  5083. - unsigned int selfcontrol;
  5084. - unsigned long tmo = currticks() + TICKS_PER_SEC;
  5085. -
  5086. - /* control the DC to DC convertor in the SelfControl register. */
  5087. - selfcontrol = HCB1_ENBL; /* Enable the HCB1 bit as an output */
  5088. - if (((eth_adapter_cnf & A_CNF_DC_DC_POLARITY) != 0) ^ on_not_off)
  5089. - selfcontrol |= HCB1;
  5090. - else
  5091. - selfcontrol &= ~HCB1;
  5092. - writereg(PP_SelfCTL, selfcontrol);
  5093. -
  5094. - /* Wait for the DC/DC converter to power up - 1000ms */
  5095. - while (currticks() < tmo);
  5096. -
  5097. - return;
  5098. -}
  5099. -
  5100. -static int detect_tp(void)
  5101. -{
  5102. - unsigned long tmo;
  5103. -
  5104. - /* Turn on the chip auto detection of 10BT/ AUI */
  5105. -
  5106. - clrline(); printf("attempting %s:","TP");
  5107. -
  5108. - /* If connected to another full duplex capable 10-Base-T card
  5109. - the link pulses seem to be lost when the auto detect bit in
  5110. - the LineCTL is set. To overcome this the auto detect bit
  5111. - will be cleared whilst testing the 10-Base-T interface.
  5112. - This would not be necessary for the sparrow chip but is
  5113. - simpler to do it anyway. */
  5114. - writereg(PP_LineCTL, eth_linectl &~ AUI_ONLY);
  5115. - control_dc_dc(0);
  5116. -
  5117. - /* Delay for the hardware to work out if the TP cable is
  5118. - present - 150ms */
  5119. - for (tmo = currticks() + 4; currticks() < tmo; );
  5120. -
  5121. - if ((readreg(PP_LineST) & LINK_OK) == 0)
  5122. - return 0;
  5123. -
  5124. - if (eth_cs_type != CS8900) {
  5125. -
  5126. - writereg(PP_AutoNegCTL, eth_auto_neg_cnf & AUTO_NEG_MASK);
  5127. -
  5128. - if ((eth_auto_neg_cnf & AUTO_NEG_BITS) == AUTO_NEG_ENABLE) {
  5129. - printf(" negotiating duplex... ");
  5130. - while (readreg(PP_AutoNegST) & AUTO_NEG_BUSY) {
  5131. - if (currticks() - tmo > 40*TICKS_PER_SEC) {
  5132. - printf("time out ");
  5133. - break;
  5134. - }
  5135. - }
  5136. - }
  5137. - if (readreg(PP_AutoNegST) & FDX_ACTIVE)
  5138. - printf("using full duplex");
  5139. - else
  5140. - printf("using half duplex");
  5141. - }
  5142. -
  5143. - return A_CNF_MEDIA_10B_T;
  5144. -}
  5145. -
  5146. -/* send a test packet - return true if carrier bits are ok */
  5147. -static int send_test_pkt(struct nic *nic)
  5148. -{
  5149. - static unsigned char testpacket[] = { 0,0,0,0,0,0, 0,0,0,0,0,0,
  5150. - 0, 46, /*A 46 in network order */
  5151. - 0, 0, /*DSAP=0 & SSAP=0 fields */
  5152. - 0xf3,0 /*Control (Test Req+P bit set)*/ };
  5153. - unsigned long tmo;
  5154. -
  5155. - writereg(PP_LineCTL, readreg(PP_LineCTL) | SERIAL_TX_ON);
  5156. -
  5157. - memcpy(testpacket, nic->node_addr, ETH_ALEN);
  5158. - memcpy(testpacket+ETH_ALEN, nic->node_addr, ETH_ALEN);
  5159. -
  5160. - outw(TX_AFTER_ALL, eth_nic_base + TX_CMD_PORT);
  5161. - outw(ETH_ZLEN, eth_nic_base + TX_LEN_PORT);
  5162. -
  5163. - /* Test to see if the chip has allocated memory for the packet */
  5164. - for (tmo = currticks() + 2;
  5165. - (readreg(PP_BusST) & READY_FOR_TX_NOW) == 0; )
  5166. - if (currticks() >= tmo)
  5167. - return(0);
  5168. -
  5169. - /* Write the contents of the packet */
  5170. - outsw(eth_nic_base + TX_FRAME_PORT, testpacket,
  5171. - (ETH_ZLEN+1)>>1);
  5172. -
  5173. - printf(" sending test packet ");
  5174. - /* wait a couple of timer ticks for packet to be received */
  5175. - for (tmo = currticks() + 2; currticks() < tmo; );
  5176. -
  5177. - if ((readreg(PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) {
  5178. - printf("succeeded");
  5179. - return 1;
  5180. - }
  5181. - printf("failed");
  5182. - return 0;
  5183. -}
  5184. -
  5185. -
  5186. -static int detect_aui(struct nic *nic)
  5187. -{
  5188. - clrline(); printf("attempting %s:","AUI");
  5189. - control_dc_dc(0);
  5190. -
  5191. - writereg(PP_LineCTL, (eth_linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
  5192. -
  5193. - if (send_test_pkt(nic)) {
  5194. - return A_CNF_MEDIA_AUI; }
  5195. - else
  5196. - return 0;
  5197. -}
  5198. -
  5199. -static int detect_bnc(struct nic *nic)
  5200. -{
  5201. - clrline(); printf("attempting %s:","BNC");
  5202. - control_dc_dc(1);
  5203. -
  5204. - writereg(PP_LineCTL, (eth_linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
  5205. -
  5206. - if (send_test_pkt(nic)) {
  5207. - return A_CNF_MEDIA_10B_2; }
  5208. - else
  5209. - return 0;
  5210. -}
  5211. -
  5212. -/**************************************************************************
  5213. -ETH_RESET - Reset adapter
  5214. -***************************************************************************/
  5215. -
  5216. -static void cs89x0_reset(struct nic *nic)
  5217. -{
  5218. - int i;
  5219. - unsigned long reset_tmo;
  5220. -
  5221. - writereg(PP_SelfCTL, readreg(PP_SelfCTL) | POWER_ON_RESET);
  5222. -
  5223. - /* wait for two ticks; that is 2*55ms */
  5224. - for (reset_tmo = currticks() + 2; currticks() < reset_tmo; );
  5225. -
  5226. - if (eth_cs_type != CS8900) {
  5227. - /* Hardware problem requires PNP registers to be reconfigured
  5228. - after a reset */
  5229. - if (eth_irq != 0xFFFF) {
  5230. - outw(PP_CS8920_ISAINT, eth_nic_base + ADD_PORT);
  5231. - outb(eth_irq, eth_nic_base + DATA_PORT);
  5232. - outb(0, eth_nic_base + DATA_PORT + 1); }
  5233. -
  5234. - if (eth_mem_start) {
  5235. - outw(PP_CS8920_ISAMemB, eth_nic_base + ADD_PORT);
  5236. - outb((eth_mem_start >> 8) & 0xff, eth_nic_base + DATA_PORT);
  5237. - outb((eth_mem_start >> 24) & 0xff, eth_nic_base + DATA_PORT + 1); } }
  5238. -
  5239. - /* Wait until the chip is reset */
  5240. - for (reset_tmo = currticks() + 2;
  5241. - (readreg(PP_SelfST) & INIT_DONE) == 0 &&
  5242. - currticks() < reset_tmo; );
  5243. -
  5244. - /* disable interrupts and memory accesses */
  5245. - writereg(PP_BusCTL, 0);
  5246. -
  5247. - /* set the ethernet address */
  5248. - for (i=0; i < ETH_ALEN/2; i++)
  5249. - writereg(PP_IA+i*2,
  5250. - nic->node_addr[i*2] |
  5251. - (nic->node_addr[i*2+1] << 8));
  5252. -
  5253. - /* receive only error free packets addressed to this card */
  5254. - writereg(PP_RxCTL, DEF_RX_ACCEPT);
  5255. -
  5256. - /* do not generate any interrupts on receive operations */
  5257. - writereg(PP_RxCFG, 0);
  5258. -
  5259. - /* do not generate any interrupts on transmit operations */
  5260. - writereg(PP_TxCFG, 0);
  5261. -
  5262. - /* do not generate any interrupts on buffer operations */
  5263. - writereg(PP_BufCFG, 0);
  5264. -
  5265. - /* reset address port, so that autoprobing will keep working */
  5266. - outw(PP_ChipID, eth_nic_base + ADD_PORT);
  5267. -
  5268. - return;
  5269. -}
  5270. -
  5271. -/**************************************************************************
  5272. -ETH_TRANSMIT - Transmit a frame
  5273. -***************************************************************************/
  5274. -
  5275. -static void cs89x0_transmit(
  5276. - struct nic *nic,
  5277. - const char *d, /* Destination */
  5278. - unsigned int t, /* Type */
  5279. - unsigned int s, /* size */
  5280. - const char *p) /* Packet */
  5281. -{
  5282. - unsigned long tmo;
  5283. - int sr;
  5284. -
  5285. - /* does this size have to be rounded??? please,
  5286. - somebody have a look in the specs */
  5287. - if ((sr = ((s + ETH_HLEN + 1)&~1)) < ETH_ZLEN)
  5288. - sr = ETH_ZLEN;
  5289. -
  5290. -retry:
  5291. - /* initiate a transmit sequence */
  5292. - outw(TX_AFTER_ALL, eth_nic_base + TX_CMD_PORT);
  5293. - outw(sr, eth_nic_base + TX_LEN_PORT);
  5294. -
  5295. - /* Test to see if the chip has allocated memory for the packet */
  5296. - if ((readreg(PP_BusST) & READY_FOR_TX_NOW) == 0) {
  5297. - /* Oops... this should not happen! */
  5298. - printf("cs: unable to send packet; retrying...\n");
  5299. - for (tmo = currticks() + 5*TICKS_PER_SEC; currticks() < tmo; );
  5300. - cs89x0_reset(nic);
  5301. - goto retry; }
  5302. -
  5303. - /* Write the contents of the packet */
  5304. - outsw(eth_nic_base + TX_FRAME_PORT, d, ETH_ALEN/2);
  5305. - outsw(eth_nic_base + TX_FRAME_PORT, nic->node_addr,
  5306. - ETH_ALEN/2);
  5307. - outw(((t >> 8)&0xFF)|(t << 8), eth_nic_base + TX_FRAME_PORT);
  5308. - outsw(eth_nic_base + TX_FRAME_PORT, p, (s+1)/2);
  5309. - for (sr = sr/2 - (s+1)/2 - ETH_ALEN - 1; sr-- > 0;
  5310. - outw(0, eth_nic_base + TX_FRAME_PORT));
  5311. -
  5312. - /* wait for transfer to succeed */
  5313. - for (tmo = currticks()+5*TICKS_PER_SEC;
  5314. - (s = readreg(PP_TxEvent)&~0x1F) == 0 && currticks() < tmo;)
  5315. - /* nothing */ ;
  5316. - if ((s & TX_SEND_OK_BITS) != TX_OK) {
  5317. - printf("\ntransmission error %#hX\n", s);
  5318. - }
  5319. -
  5320. - return;
  5321. -}
  5322. -
  5323. -/**************************************************************************
  5324. -ETH_POLL - Wait for a frame
  5325. -***************************************************************************/
  5326. -
  5327. -static int cs89x0_poll(struct nic *nic)
  5328. -{
  5329. - int status;
  5330. -
  5331. - status = readreg(PP_RxEvent);
  5332. -
  5333. - if ((status & RX_OK) == 0)
  5334. - return(0);
  5335. -
  5336. - status = inw(eth_nic_base + RX_FRAME_PORT);
  5337. - nic->packetlen = inw(eth_nic_base + RX_FRAME_PORT);
  5338. - insw(eth_nic_base + RX_FRAME_PORT, nic->packet, nic->packetlen >> 1);
  5339. - if (nic->packetlen & 1)
  5340. - nic->packet[nic->packetlen-1] = inw(eth_nic_base + RX_FRAME_PORT);
  5341. - return 1;
  5342. -}
  5343. -
  5344. -static void cs89x0_disable(struct nic *nic)
  5345. -{
  5346. - cs89x0_reset(nic);
  5347. -}
  5348. -
  5349. -/**************************************************************************
  5350. -ETH_PROBE - Look for an adapter
  5351. -***************************************************************************/
  5352. -
  5353. -struct nic *cs89x0_probe(struct nic *nic, unsigned short *probe_addrs)
  5354. -{
  5355. - static const unsigned int netcard_portlist[] = {
  5356. -#ifdef CS_SCAN
  5357. - CS_SCAN,
  5358. -#else /* use "conservative" default values for autoprobing */
  5359. - 0x300,0x320,0x340,0x200,0x220,0x240,
  5360. - 0x260,0x280,0x2a0,0x2c0,0x2e0,
  5361. - /* if that did not work, then be more aggressive */
  5362. - 0x301,0x321,0x341,0x201,0x221,0x241,
  5363. - 0x261,0x281,0x2a1,0x2c1,0x2e1,
  5364. -#endif
  5365. - 0};
  5366. -
  5367. - int i, result = -1;
  5368. - unsigned rev_type = 0, ioaddr, ioidx, isa_cnf, cs_revision;
  5369. - unsigned short eeprom_buff[CHKSUM_LEN];
  5370. -
  5371. -
  5372. - for (ioidx = 0; (ioaddr=netcard_portlist[ioidx++]) != 0; ) {
  5373. - /* if they give us an odd I/O address, then do ONE write to
  5374. - the address port, to get it back to address zero, where we
  5375. - expect to find the EISA signature word. */
  5376. - if (ioaddr & 1) {
  5377. - ioaddr &= ~1;
  5378. - if ((inw(ioaddr + ADD_PORT) & ADD_MASK) != ADD_SIG)
  5379. - continue;
  5380. - outw(PP_ChipID, ioaddr + ADD_PORT);
  5381. - }
  5382. -
  5383. - if (inw(ioaddr + DATA_PORT) != CHIP_EISA_ID_SIG)
  5384. - continue;
  5385. - eth_nic_base = ioaddr;
  5386. -
  5387. - /* get the chip type */
  5388. - rev_type = readreg(PRODUCT_ID_ADD);
  5389. - eth_cs_type = rev_type &~ REVISON_BITS;
  5390. - cs_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';
  5391. -
  5392. - printf("\ncs: cs89%c0%s rev %c, base %#hX",
  5393. - eth_cs_type==CS8900?'0':'2',
  5394. - eth_cs_type==CS8920M?"M":"",
  5395. - cs_revision,
  5396. - eth_nic_base);
  5397. -
  5398. - /* First check to see if an EEPROM is attached*/
  5399. - if ((readreg(PP_SelfST) & EEPROM_PRESENT) == 0) {
  5400. - printf("\ncs: no EEPROM...\n");
  5401. - outw(PP_ChipID, eth_nic_base + ADD_PORT);
  5402. - continue; }
  5403. - else if (get_eeprom_data(START_EEPROM_DATA,CHKSUM_LEN,
  5404. - eeprom_buff) < 0) {
  5405. - printf("\ncs: EEPROM read failed...\n");
  5406. - outw(PP_ChipID, eth_nic_base + ADD_PORT);
  5407. - continue; }
  5408. - else if (get_eeprom_chksum(START_EEPROM_DATA,CHKSUM_LEN,
  5409. - eeprom_buff) < 0) {
  5410. - printf("\ncs: EEPROM checksum bad...\n");
  5411. - outw(PP_ChipID, eth_nic_base + ADD_PORT);
  5412. - continue; }
  5413. -
  5414. - /* get transmission control word but keep the
  5415. - autonegotiation bits */
  5416. - eth_auto_neg_cnf = eeprom_buff[AUTO_NEG_CNF_OFFSET/2];
  5417. - /* Store adapter configuration */
  5418. - eth_adapter_cnf = eeprom_buff[ADAPTER_CNF_OFFSET/2];
  5419. - /* Store ISA configuration */
  5420. - isa_cnf = eeprom_buff[ISA_CNF_OFFSET/2];
  5421. -
  5422. - /* store the initial memory base address */
  5423. - eth_mem_start = eeprom_buff[PACKET_PAGE_OFFSET/2] << 8;
  5424. -
  5425. - printf("%s%s%s, addr ",
  5426. - (eth_adapter_cnf & A_CNF_10B_T)?", RJ-45":"",
  5427. - (eth_adapter_cnf & A_CNF_AUI)?", AUI":"",
  5428. - (eth_adapter_cnf & A_CNF_10B_2)?", BNC":"");
  5429. -
  5430. - /* If this is a CS8900 then no pnp soft */
  5431. - if (eth_cs_type != CS8900 &&
  5432. - /* Check if the ISA IRQ has been set */
  5433. - (i = readreg(PP_CS8920_ISAINT) & 0xff,
  5434. - (i != 0 && i < CS8920_NO_INTS)))
  5435. - eth_irq = i;
  5436. - else {
  5437. - i = isa_cnf & INT_NO_MASK;
  5438. - if (eth_cs_type == CS8900) {
  5439. - /* the table that follows is dependent
  5440. - upon how you wired up your cs8900
  5441. - in your system. The table is the
  5442. - same as the cs8900 engineering demo
  5443. - board. irq_map also depends on the
  5444. - contents of the table. Also see
  5445. - write_irq, which is the reverse
  5446. - mapping of the table below. */
  5447. - if (i < 4) i = "\012\013\014\005"[i];
  5448. - else printf("\ncs: BUG: isa_config is %d\n", i); }
  5449. - eth_irq = i; }
  5450. -
  5451. - /* Retrieve and print the ethernet address. */
  5452. - for (i=0; i<ETH_ALEN; i++) {
  5453. - nic->node_addr[i] = ((unsigned char *)eeprom_buff)[i];
  5454. - }
  5455. - printf("%!\n", nic->node_addr);
  5456. -
  5457. - /* Set the LineCTL quintuplet based on adapter
  5458. - configuration read from EEPROM */
  5459. - if ((eth_adapter_cnf & A_CNF_EXTND_10B_2) &&
  5460. - (eth_adapter_cnf & A_CNF_LOW_RX_SQUELCH))
  5461. - eth_linectl = LOW_RX_SQUELCH;
  5462. - else
  5463. - eth_linectl = 0;
  5464. -
  5465. - /* check to make sure that they have the "right"
  5466. - hardware available */
  5467. - switch(eth_adapter_cnf & A_CNF_MEDIA_TYPE) {
  5468. - case A_CNF_MEDIA_10B_T: result = eth_adapter_cnf & A_CNF_10B_T;
  5469. - break;
  5470. - case A_CNF_MEDIA_AUI: result = eth_adapter_cnf & A_CNF_AUI;
  5471. - break;
  5472. - case A_CNF_MEDIA_10B_2: result = eth_adapter_cnf & A_CNF_10B_2;
  5473. - break;
  5474. - default: result = eth_adapter_cnf & (A_CNF_10B_T | A_CNF_AUI |
  5475. - A_CNF_10B_2);
  5476. - }
  5477. - if (!result) {
  5478. - printf("cs: EEPROM is configured for unavailable media\n");
  5479. - error:
  5480. - writereg(PP_LineCTL, readreg(PP_LineCTL) &
  5481. - ~(SERIAL_TX_ON | SERIAL_RX_ON));
  5482. - outw(PP_ChipID, eth_nic_base + ADD_PORT);
  5483. - continue;
  5484. - }
  5485. -
  5486. - /* Initialize the card for probing of the attached media */
  5487. - cs89x0_reset(nic);
  5488. -
  5489. - /* set the hardware to the configured choice */
  5490. - switch(eth_adapter_cnf & A_CNF_MEDIA_TYPE) {
  5491. - case A_CNF_MEDIA_10B_T:
  5492. - result = detect_tp();
  5493. - if (!result) {
  5494. - clrline();
  5495. - printf("10Base-T (RJ-45%s",
  5496. - ") has no cable\n"); }
  5497. - /* check "ignore missing media" bit */
  5498. - if (eth_auto_neg_cnf & IMM_BIT)
  5499. - /* Yes! I don't care if I see a link pulse */
  5500. - result = A_CNF_MEDIA_10B_T;
  5501. - break;
  5502. - case A_CNF_MEDIA_AUI:
  5503. - result = detect_aui(nic);
  5504. - if (!result) {
  5505. - clrline();
  5506. - printf("10Base-5 (AUI%s",
  5507. - ") has no cable\n"); }
  5508. - /* check "ignore missing media" bit */
  5509. - if (eth_auto_neg_cnf & IMM_BIT)
  5510. - /* Yes! I don't care if I see a carrrier */
  5511. - result = A_CNF_MEDIA_AUI;
  5512. - break;
  5513. - case A_CNF_MEDIA_10B_2:
  5514. - result = detect_bnc(nic);
  5515. - if (!result) {
  5516. - clrline();
  5517. - printf("10Base-2 (BNC%s",
  5518. - ") has no cable\n"); }
  5519. - /* check "ignore missing media" bit */
  5520. - if (eth_auto_neg_cnf & IMM_BIT)
  5521. - /* Yes! I don't care if I can xmit a packet */
  5522. - result = A_CNF_MEDIA_10B_2;
  5523. - break;
  5524. - case A_CNF_MEDIA_AUTO:
  5525. - writereg(PP_LineCTL, eth_linectl | AUTO_AUI_10BASET);
  5526. - if (eth_adapter_cnf & A_CNF_10B_T)
  5527. - if ((result = detect_tp()) != 0)
  5528. - break;
  5529. - if (eth_adapter_cnf & A_CNF_AUI)
  5530. - if ((result = detect_aui(nic)) != 0)
  5531. - break;
  5532. - if (eth_adapter_cnf & A_CNF_10B_2)
  5533. - if ((result = detect_bnc(nic)) != 0)
  5534. - break;
  5535. - clrline(); printf("no media detected\n");
  5536. - goto error;
  5537. - }
  5538. - clrline();
  5539. - switch(result) {
  5540. - case 0: printf("no network cable attached to configured media\n");
  5541. - goto error;
  5542. - case A_CNF_MEDIA_10B_T: printf("using 10Base-T (RJ-45)\n");
  5543. - break;
  5544. - case A_CNF_MEDIA_AUI: printf("using 10Base-5 (AUI)\n");
  5545. - break;
  5546. - case A_CNF_MEDIA_10B_2: printf("using 10Base-2 (BNC)\n");
  5547. - break;
  5548. - }
  5549. -
  5550. - /* Turn on both receive and transmit operations */
  5551. - writereg(PP_LineCTL, readreg(PP_LineCTL) | SERIAL_RX_ON |
  5552. - SERIAL_TX_ON);
  5553. -
  5554. - break;
  5555. - }
  5556. -
  5557. - if (ioaddr == 0)
  5558. - return (0);
  5559. - nic->reset = cs89x0_reset;
  5560. - nic->poll = cs89x0_poll;
  5561. - nic->transmit = cs89x0_transmit;
  5562. - nic->disable = cs89x0_disable;
  5563. - return (nic);
  5564. -}
  5565. -
  5566. -/*
  5567. - * Local variables:
  5568. - * c-basic-offset: 8
  5569. - * End:
  5570. - */
  5571. -
  5572. Index: b/netboot/cs89x0.h
  5573. ===================================================================
  5574. --- a/netboot/cs89x0.h
  5575. +++ b/netboot/cs89x0.h
  5576. @@ -16,464 +16,3 @@
  5577. -- quote from email
  5578. **/
  5579. -/* Copyright, 1988-1992, Russell Nelson, Crynwr Software
  5580. -
  5581. - This program is free software; you can redistribute it and/or modify
  5582. - it under the terms of the GNU General Public License as published by
  5583. - the Free Software Foundation, version 1.
  5584. -
  5585. - This program is distributed in the hope that it will be useful,
  5586. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  5587. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5588. - GNU General Public License for more details.
  5589. -
  5590. - You should have received a copy of the GNU General Public License
  5591. - along with this program; if not, write to the Free Software
  5592. - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
  5593. -
  5594. -#define PP_ChipID 0x0000 /* offset 0h -> Corp -ID */
  5595. - /* offset 2h -> Model/Product Number */
  5596. - /* offset 3h -> Chip Revision Number */
  5597. -
  5598. -#define PP_ISAIOB 0x0020 /* IO base address */
  5599. -#define PP_CS8900_ISAINT 0x0022 /* ISA interrupt select */
  5600. -#define PP_CS8920_ISAINT 0x0370 /* ISA interrupt select */
  5601. -#define PP_CS8900_ISADMA 0x0024 /* ISA Rec DMA channel */
  5602. -#define PP_CS8920_ISADMA 0x0374 /* ISA Rec DMA channel */
  5603. -#define PP_ISASOF 0x0026 /* ISA DMA offset */
  5604. -#define PP_DmaFrameCnt 0x0028 /* ISA DMA Frame count */
  5605. -#define PP_DmaByteCnt 0x002A /* ISA DMA Byte count */
  5606. -#define PP_CS8900_ISAMemB 0x002C /* Memory base */
  5607. -#define PP_CS8920_ISAMemB 0x0348 /* */
  5608. -
  5609. -#define PP_ISABootBase 0x0030 /* Boot Prom base */
  5610. -#define PP_ISABootMask 0x0034 /* Boot Prom Mask */
  5611. -
  5612. -/* EEPROM data and command registers */
  5613. -#define PP_EECMD 0x0040 /* NVR Interface Command register */
  5614. -#define PP_EEData 0x0042 /* NVR Interface Data Register */
  5615. -#define PP_DebugReg 0x0044 /* Debug Register */
  5616. -
  5617. -#define PP_RxCFG 0x0102 /* Rx Bus config */
  5618. -#define PP_RxCTL 0x0104 /* Receive Control Register */
  5619. -#define PP_TxCFG 0x0106 /* Transmit Config Register */
  5620. -#define PP_TxCMD 0x0108 /* Transmit Command Register */
  5621. -#define PP_BufCFG 0x010A /* Bus configuration Register */
  5622. -#define PP_LineCTL 0x0112 /* Line Config Register */
  5623. -#define PP_SelfCTL 0x0114 /* Self Command Register */
  5624. -#define PP_BusCTL 0x0116 /* ISA bus control Register */
  5625. -#define PP_TestCTL 0x0118 /* Test Register */
  5626. -#define PP_AutoNegCTL 0x011C /* Auto Negotiation Ctrl */
  5627. -
  5628. -#define PP_ISQ 0x0120 /* Interrupt Status */
  5629. -#define PP_RxEvent 0x0124 /* Rx Event Register */
  5630. -#define PP_TxEvent 0x0128 /* Tx Event Register */
  5631. -#define PP_BufEvent 0x012C /* Bus Event Register */
  5632. -#define PP_RxMiss 0x0130 /* Receive Miss Count */
  5633. -#define PP_TxCol 0x0132 /* Transmit Collision Count */
  5634. -#define PP_LineST 0x0134 /* Line State Register */
  5635. -#define PP_SelfST 0x0136 /* Self State register */
  5636. -#define PP_BusST 0x0138 /* Bus Status */
  5637. -#define PP_TDR 0x013C /* Time Domain Reflectometry */
  5638. -#define PP_AutoNegST 0x013E /* Auto Neg Status */
  5639. -#define PP_TxCommand 0x0144 /* Tx Command */
  5640. -#define PP_TxLength 0x0146 /* Tx Length */
  5641. -#define PP_LAF 0x0150 /* Hash Table */
  5642. -#define PP_IA 0x0158 /* Physical Address Register */
  5643. -
  5644. -#define PP_RxStatus 0x0400 /* Receive start of frame */
  5645. -#define PP_RxLength 0x0402 /* Receive Length of frame */
  5646. -#define PP_RxFrame 0x0404 /* Receive frame pointer */
  5647. -#define PP_TxFrame 0x0A00 /* Transmit frame pointer */
  5648. -
  5649. -/* Primary I/O Base Address. If no I/O base is supplied by the user, then this */
  5650. -/* can be used as the default I/O base to access the PacketPage Area. */
  5651. -#define DEFAULTIOBASE 0x0300
  5652. -#define FIRST_IO 0x020C /* First I/O port to check */
  5653. -#define LAST_IO 0x037C /* Last I/O port to check (+10h) */
  5654. -#define ADD_MASK 0x3000 /* Mask it use of the ADD_PORT register */
  5655. -#define ADD_SIG 0x3000 /* Expected ID signature */
  5656. -
  5657. -#define CHIP_EISA_ID_SIG 0x630E /* Product ID Code for Crystal Chip (CS8900 spec 4.3) */
  5658. -
  5659. -#ifdef IBMEIPKT
  5660. -#define EISA_ID_SIG 0x4D24 /* IBM */
  5661. -#define PART_NO_SIG 0x1010 /* IBM */
  5662. -#define MONGOOSE_BIT 0x0000 /* IBM */
  5663. -#else
  5664. -#define EISA_ID_SIG 0x630E /* PnP Vendor ID (same as chip id for Crystal board) */
  5665. -#define PART_NO_SIG 0x4000 /* ID code CS8920 board (PnP Vendor Product code) */
  5666. -#define MONGOOSE_BIT 0x2000 /* PART_NO_SIG + MONGOOSE_BUT => ID of mongoose */
  5667. -#endif
  5668. -
  5669. -#define PRODUCT_ID_ADD 0x0002 /* Address of product ID */
  5670. -
  5671. -/* Mask to find out the types of registers */
  5672. -#define REG_TYPE_MASK 0x001F
  5673. -
  5674. -/* Eeprom Commands */
  5675. -#define ERSE_WR_ENBL 0x00F0
  5676. -#define ERSE_WR_DISABLE 0x0000
  5677. -
  5678. -/* Defines Control/Config register quintuplet numbers */
  5679. -#define RX_BUF_CFG 0x0003
  5680. -#define RX_CONTROL 0x0005
  5681. -#define TX_CFG 0x0007
  5682. -#define TX_COMMAND 0x0009
  5683. -#define BUF_CFG 0x000B
  5684. -#define LINE_CONTROL 0x0013
  5685. -#define SELF_CONTROL 0x0015
  5686. -#define BUS_CONTROL 0x0017
  5687. -#define TEST_CONTROL 0x0019
  5688. -
  5689. -/* Defines Status/Count registers quintuplet numbers */
  5690. -#define RX_EVENT 0x0004
  5691. -#define TX_EVENT 0x0008
  5692. -#define BUF_EVENT 0x000C
  5693. -#define RX_MISS_COUNT 0x0010
  5694. -#define TX_COL_COUNT 0x0012
  5695. -#define LINE_STATUS 0x0014
  5696. -#define SELF_STATUS 0x0016
  5697. -#define BUS_STATUS 0x0018
  5698. -#define TDR 0x001C
  5699. -
  5700. -/* PP_RxCFG - Receive Configuration and Interrupt Mask bit definition - Read/write */
  5701. -#define SKIP_1 0x0040
  5702. -#define RX_STREAM_ENBL 0x0080
  5703. -#define RX_OK_ENBL 0x0100
  5704. -#define RX_DMA_ONLY 0x0200
  5705. -#define AUTO_RX_DMA 0x0400
  5706. -#define BUFFER_CRC 0x0800
  5707. -#define RX_CRC_ERROR_ENBL 0x1000
  5708. -#define RX_RUNT_ENBL 0x2000
  5709. -#define RX_EXTRA_DATA_ENBL 0x4000
  5710. -
  5711. -/* PP_RxCTL - Receive Control bit definition - Read/write */
  5712. -#define RX_IA_HASH_ACCEPT 0x0040
  5713. -#define RX_PROM_ACCEPT 0x0080
  5714. -#define RX_OK_ACCEPT 0x0100
  5715. -#define RX_MULTCAST_ACCEPT 0x0200
  5716. -#define RX_IA_ACCEPT 0x0400
  5717. -#define RX_BROADCAST_ACCEPT 0x0800
  5718. -#define RX_BAD_CRC_ACCEPT 0x1000
  5719. -#define RX_RUNT_ACCEPT 0x2000
  5720. -#define RX_EXTRA_DATA_ACCEPT 0x4000
  5721. -#define RX_ALL_ACCEPT (RX_PROM_ACCEPT|RX_BAD_CRC_ACCEPT|RX_RUNT_ACCEPT|RX_EXTRA_DATA_ACCEPT)
  5722. -/* Default receive mode - individually addressed, broadcast, and error free */
  5723. -#define DEF_RX_ACCEPT (RX_IA_ACCEPT | RX_BROADCAST_ACCEPT | RX_OK_ACCEPT)
  5724. -
  5725. -/* PP_TxCFG - Transmit Configuration Interrupt Mask bit definition - Read/write */
  5726. -#define TX_LOST_CRS_ENBL 0x0040
  5727. -#define TX_SQE_ERROR_ENBL 0x0080
  5728. -#define TX_OK_ENBL 0x0100
  5729. -#define TX_LATE_COL_ENBL 0x0200
  5730. -#define TX_JBR_ENBL 0x0400
  5731. -#define TX_ANY_COL_ENBL 0x0800
  5732. -#define TX_16_COL_ENBL 0x8000
  5733. -
  5734. -/* PP_TxCMD - Transmit Command bit definition - Read-only */
  5735. -#define TX_START_4_BYTES 0x0000
  5736. -#define TX_START_64_BYTES 0x0040
  5737. -#define TX_START_128_BYTES 0x0080
  5738. -#define TX_START_ALL_BYTES 0x00C0
  5739. -#define TX_FORCE 0x0100
  5740. -#define TX_ONE_COL 0x0200
  5741. -#define TX_TWO_PART_DEFF_DISABLE 0x0400
  5742. -#define TX_NO_CRC 0x1000
  5743. -#define TX_RUNT 0x2000
  5744. -
  5745. -/* PP_BufCFG - Buffer Configuration Interrupt Mask bit definition - Read/write */
  5746. -#define GENERATE_SW_INTERRUPT 0x0040
  5747. -#define RX_DMA_ENBL 0x0080
  5748. -#define READY_FOR_TX_ENBL 0x0100
  5749. -#define TX_UNDERRUN_ENBL 0x0200
  5750. -#define RX_MISS_ENBL 0x0400
  5751. -#define RX_128_BYTE_ENBL 0x0800
  5752. -#define TX_COL_COUNT_OVRFLOW_ENBL 0x1000
  5753. -#define RX_MISS_COUNT_OVRFLOW_ENBL 0x2000
  5754. -#define RX_DEST_MATCH_ENBL 0x8000
  5755. -
  5756. -/* PP_LineCTL - Line Control bit definition - Read/write */
  5757. -#define SERIAL_RX_ON 0x0040
  5758. -#define SERIAL_TX_ON 0x0080
  5759. -#define AUI_ONLY 0x0100
  5760. -#define AUTO_AUI_10BASET 0x0200
  5761. -#define MODIFIED_BACKOFF 0x0800
  5762. -#define NO_AUTO_POLARITY 0x1000
  5763. -#define TWO_PART_DEFDIS 0x2000
  5764. -#define LOW_RX_SQUELCH 0x4000
  5765. -
  5766. -/* PP_SelfCTL - Software Self Control bit definition - Read/write */
  5767. -#define POWER_ON_RESET 0x0040
  5768. -#define SW_STOP 0x0100
  5769. -#define SLEEP_ON 0x0200
  5770. -#define AUTO_WAKEUP 0x0400
  5771. -#define HCB0_ENBL 0x1000
  5772. -#define HCB1_ENBL 0x2000
  5773. -#define HCB0 0x4000
  5774. -#define HCB1 0x8000
  5775. -
  5776. -/* PP_BusCTL - ISA Bus Control bit definition - Read/write */
  5777. -#define RESET_RX_DMA 0x0040
  5778. -#define MEMORY_ON 0x0400
  5779. -#define DMA_BURST_MODE 0x0800
  5780. -#define IO_CHANNEL_READY_ON 0x1000
  5781. -#define RX_DMA_SIZE_64K 0x2000
  5782. -#define ENABLE_IRQ 0x8000
  5783. -
  5784. -/* PP_TestCTL - Test Control bit definition - Read/write */
  5785. -#define LINK_OFF 0x0080
  5786. -#define ENDEC_LOOPBACK 0x0200
  5787. -#define AUI_LOOPBACK 0x0400
  5788. -#define BACKOFF_OFF 0x0800
  5789. -#define FAST_TEST 0x8000
  5790. -
  5791. -/* PP_RxEvent - Receive Event Bit definition - Read-only */
  5792. -#define RX_IA_HASHED 0x0040
  5793. -#define RX_DRIBBLE 0x0080
  5794. -#define RX_OK 0x0100
  5795. -#define RX_HASHED 0x0200
  5796. -#define RX_IA 0x0400
  5797. -#define RX_BROADCAST 0x0800
  5798. -#define RX_CRC_ERROR 0x1000
  5799. -#define RX_RUNT 0x2000
  5800. -#define RX_EXTRA_DATA 0x4000
  5801. -
  5802. -#define HASH_INDEX_MASK 0x0FC00
  5803. -
  5804. -/* PP_TxEvent - Transmit Event Bit definition - Read-only */
  5805. -#define TX_LOST_CRS 0x0040
  5806. -#define TX_SQE_ERROR 0x0080
  5807. -#define TX_OK 0x0100
  5808. -#define TX_LATE_COL 0x0200
  5809. -#define TX_JBR 0x0400
  5810. -#define TX_16_COL 0x8000
  5811. -#define TX_SEND_OK_BITS (TX_OK|TX_LOST_CRS)
  5812. -#define TX_COL_COUNT_MASK 0x7800
  5813. -
  5814. -/* PP_BufEvent - Buffer Event Bit definition - Read-only */
  5815. -#define SW_INTERRUPT 0x0040
  5816. -#define RX_DMA 0x0080
  5817. -#define READY_FOR_TX 0x0100
  5818. -#define TX_UNDERRUN 0x0200
  5819. -#define RX_MISS 0x0400
  5820. -#define RX_128_BYTE 0x0800
  5821. -#define TX_COL_OVRFLW 0x1000
  5822. -#define RX_MISS_OVRFLW 0x2000
  5823. -#define RX_DEST_MATCH 0x8000
  5824. -
  5825. -/* PP_LineST - Ethernet Line Status bit definition - Read-only */
  5826. -#define LINK_OK 0x0080
  5827. -#define AUI_ON 0x0100
  5828. -#define TENBASET_ON 0x0200
  5829. -#define POLARITY_OK 0x1000
  5830. -#define CRS_OK 0x4000
  5831. -
  5832. -/* PP_SelfST - Chip Software Status bit definition */
  5833. -#define ACTIVE_33V 0x0040
  5834. -#define INIT_DONE 0x0080
  5835. -#define SI_BUSY 0x0100
  5836. -#define EEPROM_PRESENT 0x0200
  5837. -#define EEPROM_OK 0x0400
  5838. -#define EL_PRESENT 0x0800
  5839. -#define EE_SIZE_64 0x1000
  5840. -
  5841. -/* PP_BusST - ISA Bus Status bit definition */
  5842. -#define TX_BID_ERROR 0x0080
  5843. -#define READY_FOR_TX_NOW 0x0100
  5844. -
  5845. -/* PP_AutoNegCTL - Auto Negotiation Control bit definition */
  5846. -#define RE_NEG_NOW 0x0040
  5847. -#define ALLOW_FDX 0x0080
  5848. -#define AUTO_NEG_ENABLE 0x0100
  5849. -#define NLP_ENABLE 0x0200
  5850. -#define FORCE_FDX 0x8000
  5851. -#define AUTO_NEG_BITS (FORCE_FDX|NLP_ENABLE|AUTO_NEG_ENABLE)
  5852. -#define AUTO_NEG_MASK (FORCE_FDX|NLP_ENABLE|AUTO_NEG_ENABLE|ALLOW_FDX|RE_NEG_NOW)
  5853. -
  5854. -/* PP_AutoNegST - Auto Negotiation Status bit definition */
  5855. -#define AUTO_NEG_BUSY 0x0080
  5856. -#define FLP_LINK 0x0100
  5857. -#define FLP_LINK_GOOD 0x0800
  5858. -#define LINK_FAULT 0x1000
  5859. -#define HDX_ACTIVE 0x4000
  5860. -#define FDX_ACTIVE 0x8000
  5861. -
  5862. -/* The following block defines the ISQ event types */
  5863. -#define ISQ_RECEIVER_EVENT 0x04
  5864. -#define ISQ_TRANSMITTER_EVENT 0x08
  5865. -#define ISQ_BUFFER_EVENT 0x0c
  5866. -#define ISQ_RX_MISS_EVENT 0x10
  5867. -#define ISQ_TX_COL_EVENT 0x12
  5868. -
  5869. -#define ISQ_EVENT_MASK 0x003F /* ISQ mask to find out type of event */
  5870. -#define ISQ_HIST 16 /* small history buffer */
  5871. -#define AUTOINCREMENT 0x8000 /* Bit mask to set bit-15 for autoincrement */
  5872. -
  5873. -#define TXRXBUFSIZE 0x0600
  5874. -#define RXDMABUFSIZE 0x8000
  5875. -#define RXDMASIZE 0x4000
  5876. -#define TXRX_LENGTH_MASK 0x07FF
  5877. -
  5878. -/* rx options bits */
  5879. -#define RCV_WITH_RXON 1 /* Set SerRx ON */
  5880. -#define RCV_COUNTS 2 /* Use Framecnt1 */
  5881. -#define RCV_PONG 4 /* Pong respondent */
  5882. -#define RCV_DONG 8 /* Dong operation */
  5883. -#define RCV_POLLING 0x10 /* Poll RxEvent */
  5884. -#define RCV_ISQ 0x20 /* Use ISQ, int */
  5885. -#define RCV_AUTO_DMA 0x100 /* Set AutoRxDMAE */
  5886. -#define RCV_DMA 0x200 /* Set RxDMA only */
  5887. -#define RCV_DMA_ALL 0x400 /* Copy all DMA'ed */
  5888. -#define RCV_FIXED_DATA 0x800 /* Every frame same */
  5889. -#define RCV_IO 0x1000 /* Use ISA IO only */
  5890. -#define RCV_MEMORY 0x2000 /* Use ISA Memory */
  5891. -
  5892. -#define RAM_SIZE 0x1000 /* The card has 4k bytes or RAM */
  5893. -#define PKT_START PP_TxFrame /* Start of packet RAM */
  5894. -
  5895. -#define RX_FRAME_PORT 0x0000
  5896. -#define TX_FRAME_PORT RX_FRAME_PORT
  5897. -#define TX_CMD_PORT 0x0004
  5898. -#define TX_NOW 0x0000 /* Tx packet after 5 bytes copied */
  5899. -#define TX_AFTER_381 0x0020 /* Tx packet after 381 bytes copied */
  5900. -#define TX_AFTER_ALL 0x0060 /* Tx packet after all bytes copied */
  5901. -#define TX_LEN_PORT 0x0006
  5902. -#define ISQ_PORT 0x0008
  5903. -#define ADD_PORT 0x000A
  5904. -#define DATA_PORT 0x000C
  5905. -
  5906. -#define EEPROM_WRITE_EN 0x00F0
  5907. -#define EEPROM_WRITE_DIS 0x0000
  5908. -#define EEPROM_WRITE_CMD 0x0100
  5909. -#define EEPROM_READ_CMD 0x0200
  5910. -
  5911. -/* Receive Header */
  5912. -/* Description of header of each packet in receive area of memory */
  5913. -#define RBUF_EVENT_LOW 0 /* Low byte of RxEvent - status of received frame */
  5914. -#define RBUF_EVENT_HIGH 1 /* High byte of RxEvent - status of received frame */
  5915. -#define RBUF_LEN_LOW 2 /* Length of received data - low byte */
  5916. -#define RBUF_LEN_HI 3 /* Length of received data - high byte */
  5917. -#define RBUF_HEAD_LEN 4 /* Length of this header */
  5918. -
  5919. -#define CHIP_READ 0x1 /* Used to mark state of the repins code (chip or dma) */
  5920. -#define DMA_READ 0x2 /* Used to mark state of the repins code (chip or dma) */
  5921. -
  5922. -/* for bios scan */
  5923. -/* */
  5924. -#ifdef CSDEBUG
  5925. -/* use these values for debugging bios scan */
  5926. -#define BIOS_START_SEG 0x00000
  5927. -#define BIOS_OFFSET_INC 0x0010
  5928. -#else
  5929. -#define BIOS_START_SEG 0x0c000
  5930. -#define BIOS_OFFSET_INC 0x0200
  5931. -#endif
  5932. -
  5933. -#define BIOS_LAST_OFFSET 0x0fc00
  5934. -
  5935. -/* Byte offsets into the EEPROM configuration buffer */
  5936. -#define ISA_CNF_OFFSET 0x6
  5937. -#define TX_CTL_OFFSET (ISA_CNF_OFFSET + 8) /* 8900 eeprom */
  5938. -#define AUTO_NEG_CNF_OFFSET (ISA_CNF_OFFSET + 8) /* 8920 eeprom */
  5939. -
  5940. - /* the assumption here is that the bits in the eeprom are generally */
  5941. - /* in the same position as those in the autonegctl register. */
  5942. - /* Of course the IMM bit is not in that register so it must be */
  5943. - /* masked out */
  5944. -#define EE_FORCE_FDX 0x8000
  5945. -#define EE_NLP_ENABLE 0x0200
  5946. -#define EE_AUTO_NEG_ENABLE 0x0100
  5947. -#define EE_ALLOW_FDX 0x0080
  5948. -#define EE_AUTO_NEG_CNF_MASK (EE_FORCE_FDX|EE_NLP_ENABLE|EE_AUTO_NEG_ENABLE|EE_ALLOW_FDX)
  5949. -
  5950. -#define IMM_BIT 0x0040 /* ignore missing media */
  5951. -
  5952. -#define ADAPTER_CNF_OFFSET (AUTO_NEG_CNF_OFFSET + 2)
  5953. -#define A_CNF_10B_T 0x0001
  5954. -#define A_CNF_AUI 0x0002
  5955. -#define A_CNF_10B_2 0x0004
  5956. -#define A_CNF_MEDIA_TYPE 0x0060
  5957. -#define A_CNF_MEDIA_AUTO 0x0000
  5958. -#define A_CNF_MEDIA_10B_T 0x0020
  5959. -#define A_CNF_MEDIA_AUI 0x0040
  5960. -#define A_CNF_MEDIA_10B_2 0x0060
  5961. -#define A_CNF_DC_DC_POLARITY 0x0080
  5962. -#define A_CNF_NO_AUTO_POLARITY 0x2000
  5963. -#define A_CNF_LOW_RX_SQUELCH 0x4000
  5964. -#define A_CNF_EXTND_10B_2 0x8000
  5965. -
  5966. -#define PACKET_PAGE_OFFSET 0x8
  5967. -
  5968. -/* Bit definitions for the ISA configuration word from the EEPROM */
  5969. -#define INT_NO_MASK 0x000F
  5970. -#define DMA_NO_MASK 0x0070
  5971. -#define ISA_DMA_SIZE 0x0200
  5972. -#define ISA_AUTO_RxDMA 0x0400
  5973. -#define ISA_RxDMA 0x0800
  5974. -#define DMA_BURST 0x1000
  5975. -#define STREAM_TRANSFER 0x2000
  5976. -#define ANY_ISA_DMA (ISA_AUTO_RxDMA | ISA_RxDMA)
  5977. -
  5978. -/* DMA controller registers */
  5979. -#define DMA_BASE 0x00 /* DMA controller base */
  5980. -#define DMA_BASE_2 0x0C0 /* DMA controller base */
  5981. -
  5982. -#define DMA_STAT 0x0D0 /* DMA controller status register */
  5983. -#define DMA_MASK 0x0D4 /* DMA controller mask register */
  5984. -#define DMA_MODE 0x0D6 /* DMA controller mode register */
  5985. -#define DMA_RESETFF 0x0D8 /* DMA controller first/last flip flop */
  5986. -
  5987. -/* DMA data */
  5988. -#define DMA_DISABLE 0x04 /* Disable channel n */
  5989. -#define DMA_ENABLE 0x00 /* Enable channel n */
  5990. -/* Demand transfers, incr. address, auto init, writes, ch. n */
  5991. -#define DMA_RX_MODE 0x14
  5992. -/* Demand transfers, incr. address, auto init, reads, ch. n */
  5993. -#define DMA_TX_MODE 0x18
  5994. -
  5995. -#define DMA_SIZE (16*1024) /* Size of dma buffer - 16k */
  5996. -
  5997. -#define CS8900 0x0000
  5998. -#define CS8920 0x4000
  5999. -#define CS8920M 0x6000
  6000. -#define REVISON_BITS 0x1F00
  6001. -#define EEVER_NUMBER 0x12
  6002. -#define CHKSUM_LEN 0x14
  6003. -#define CHKSUM_VAL 0x0000
  6004. -#define START_EEPROM_DATA 0x001c /* Offset into eeprom for start of data */
  6005. -#define IRQ_MAP_EEPROM_DATA 0x0046 /* Offset into eeprom for the IRQ map */
  6006. -#define IRQ_MAP_LEN 0x0004 /* No of bytes to read for the IRQ map */
  6007. -#define PNP_IRQ_FRMT 0x0022 /* PNP small item IRQ format */
  6008. -#define CS8900_IRQ_MAP 0x1c20 /* This IRQ map is fixed */
  6009. -
  6010. -#define CS8920_NO_INTS 0x0F /* Max CS8920 interrupt select # */
  6011. -
  6012. -#define PNP_ADD_PORT 0x0279
  6013. -#define PNP_WRITE_PORT 0x0A79
  6014. -
  6015. -#define GET_PNP_ISA_STRUCT 0x40
  6016. -#define PNP_ISA_STRUCT_LEN 0x06
  6017. -#define PNP_CSN_CNT_OFF 0x01
  6018. -#define PNP_RD_PORT_OFF 0x02
  6019. -#define PNP_FUNCTION_OK 0x00
  6020. -#define PNP_WAKE 0x03
  6021. -#define PNP_RSRC_DATA 0x04
  6022. -#define PNP_RSRC_READY 0x01
  6023. -#define PNP_STATUS 0x05
  6024. -#define PNP_ACTIVATE 0x30
  6025. -#define PNP_CNF_IO_H 0x60
  6026. -#define PNP_CNF_IO_L 0x61
  6027. -#define PNP_CNF_INT 0x70
  6028. -#define PNP_CNF_DMA 0x74
  6029. -#define PNP_CNF_MEM 0x48
  6030. -
  6031. -#define BIT0 1
  6032. -#define BIT15 0x8000
  6033. -
  6034. -/*
  6035. - * Local variables:
  6036. - * c-basic-offset: 8
  6037. - * End:
  6038. - */
  6039. -
  6040. Index: b/netboot/cs89x0.txt
  6041. ===================================================================
  6042. --- a/netboot/cs89x0.txt
  6043. +++ /dev/null
  6044. @@ -1,26 +0,0 @@
  6045. -Permission is granted to distribute the enclosed cs89x0.[ch] driver
  6046. -only in conjunction with the Etherboot package. The code is
  6047. -ordinarily distributed under the GPL.
  6048. -
  6049. -Russ Nelson, January 2000
  6050. -
  6051. -CREDITS
  6052. -
  6053. -I want to thank
  6054. -
  6055. - Mike Cruse <mcruse@cti-ltd.com>
  6056. - for providing an evaluation NIC and for sponsoring the
  6057. - development of this driver.
  6058. -
  6059. - Randall Sears <sears@crystal.cirrus.com>
  6060. - Deva Bodas <bodas@crystal.cirrus.com>
  6061. - Andreas Kraemer <akraemer@crystal.cirrus.com>
  6062. - Wolfgang Krause <100303.2673@compuserve.com>
  6063. - for excellent technical support and for providing the required
  6064. - programming information. I appreciate Crystal Semiconductor's
  6065. - commitment towards free software.
  6066. -
  6067. - Russell Nelson <nelson@crynwr.com>
  6068. - for writing the Linux device driver for the CS89x0
  6069. - chipset. Russel's code is very well designed and simplified my
  6070. - job a lot.
  6071. Index: b/netboot/davicom.c
  6072. ===================================================================
  6073. --- a/netboot/davicom.c
  6074. +++ b/netboot/davicom.c
  6075. @@ -1,12 +1,12 @@
  6076. +#ifdef ALLMULTI
  6077. +#error multicast support is not yet implemented
  6078. +#endif
  6079. /*
  6080. DAVICOM DM9009/DM9102/DM9102A Etherboot Driver V1.00
  6081. - This driver was ported from Marty Conner's Tulip Etherboot driver.
  6082. - Thanks Marty Connor (mdc@thinguin.org)
  6083. - You can get Tulip driver source file from this URL:
  6084. + This driver was ported from Marty Connor's Tulip Etherboot driver.
  6085. + Thanks Marty Connor (mdc@etherboot.org)
  6086. - "http://etherboot.sourceforge..net/#Distribution"
  6087. -
  6088. This davicom etherboot driver supports DM9009/DM9102/DM9102A/
  6089. DM9102A+DM9801/DM9102A+DM9802 NICs.
  6090. @@ -36,7 +36,6 @@
  6091. register(CR6)
  6092. */
  6093. -
  6094. /*********************************************************************/
  6095. /* Declarations */
  6096. /*********************************************************************/
  6097. @@ -44,7 +43,6 @@
  6098. #include "etherboot.h"
  6099. #include "nic.h"
  6100. #include "pci.h"
  6101. -#include "cards.h"
  6102. #undef DAVICOM_DEBUG
  6103. #undef DAVICOM_DEBUG_WHERE
  6104. @@ -99,8 +97,10 @@
  6105. #define eeprom_delay() inl(ee_addr)
  6106. /* helpful macro if on a big_endian machine for changing byte order.
  6107. - not strictly needed on Intel */
  6108. + not strictly needed on Intel
  6109. + Already defined in Etherboot includes
  6110. #define le16_to_cpu(val) (val)
  6111. +*/
  6112. /* transmit and receive descriptor format */
  6113. struct txdesc {
  6114. @@ -138,20 +138,12 @@
  6115. /* transmit descriptor and buffer */
  6116. #define NTXD 2
  6117. static struct txdesc txd[NTXD] __attribute__ ((aligned(4)));
  6118. -#ifdef USE_LOWMEM_BUFFER
  6119. -#define txb ((char *)0x10000 - BUFLEN)
  6120. -#else
  6121. static unsigned char txb[BUFLEN] __attribute__ ((aligned(4)));
  6122. -#endif
  6123. /* receive descriptor(s) and buffer(s) */
  6124. #define NRXD 4
  6125. static struct rxdesc rxd[NRXD] __attribute__ ((aligned(4)));
  6126. -#ifdef USE_LOWMEM_BUFFER
  6127. -#define rxb ((char *)0x10000 - NRXD * BUFLEN - BUFLEN)
  6128. -#else
  6129. static unsigned char rxb[NRXD * BUFLEN] __attribute__ ((aligned(4)));
  6130. -#endif
  6131. static int rxd_tail;
  6132. static int TxPtr;
  6133. @@ -161,15 +153,13 @@
  6134. /*********************************************************************/
  6135. static void whereami(const char *str);
  6136. static int read_eeprom(unsigned long ioaddr, int location, int addr_len);
  6137. -struct nic *davicom_probe(struct nic *nic, unsigned short *io_addrs,
  6138. - struct pci_device *pci);
  6139. +static int davicom_probe(struct dev *dev, struct pci_device *pci);
  6140. static void davicom_init_chain(struct nic *nic); /* Sten 10/9 */
  6141. static void davicom_reset(struct nic *nic);
  6142. static void davicom_transmit(struct nic *nic, const char *d, unsigned int t,
  6143. unsigned int s, const char *p);
  6144. -static int davicom_poll(struct nic *nic);
  6145. -static void davicom_disable(struct nic *nic);
  6146. -static void whereami (const char *str);
  6147. +static int davicom_poll(struct nic *nic, int retrieve);
  6148. +static void davicom_disable(struct dev *dev);
  6149. #ifdef DAVICOM_DEBUG
  6150. static void davicom_more(void);
  6151. #endif /* DAVICOM_DEBUG */
  6152. @@ -184,13 +174,10 @@
  6153. /*********************************************************************/
  6154. /* Utility Routines */
  6155. /*********************************************************************/
  6156. -
  6157. -static inline void whereami (const char *str)
  6158. +static inline void whereami(const char *str)
  6159. {
  6160. -#ifdef DAVICOM_DEBUG_WHERE
  6161. printf("%s\n", str);
  6162. /* sleep(2); */
  6163. -#endif
  6164. }
  6165. #ifdef DAVICOM_DEBUG
  6166. @@ -360,7 +347,7 @@
  6167. /*
  6168. Sense media mode and set CR6
  6169. */
  6170. -static void davicom_media_chk(struct nic * nic)
  6171. +static void davicom_media_chk(struct nic * nic __unused)
  6172. {
  6173. unsigned long to, csr6;
  6174. @@ -446,8 +433,8 @@
  6175. /* Sten: Set 2 TX descriptor but use one TX buffer because
  6176. it transmit a packet and wait complete every time. */
  6177. for (i=0; i<NTXD; i++) {
  6178. - txd[i].buf1addr = &txb[0]; /* Used same TX buffer */
  6179. - txd[i].buf2addr = (unsigned char *)&txd[i+1]; /* Point to Next TX desc */
  6180. + txd[i].buf1addr = (void *)virt_to_bus(&txb[0]); /* Used same TX buffer */
  6181. + txd[i].buf2addr = (void *)virt_to_bus(&txd[i+1]); /* Point to Next TX desc */
  6182. txd[i].buf1sz = 0;
  6183. txd[i].buf2sz = 0;
  6184. txd[i].control = 0x184; /* Begin/End/Chain */
  6185. @@ -466,8 +453,8 @@
  6186. /* setup receive descriptor */
  6187. for (i=0; i<NRXD; i++) {
  6188. - rxd[i].buf1addr = &rxb[i * BUFLEN];
  6189. - rxd[i].buf2addr = (unsigned char *)&rxd[i+1]; /* Point to Next RX desc */
  6190. + rxd[i].buf1addr = (void *)virt_to_bus(&rxb[i * BUFLEN]);
  6191. + rxd[i].buf2addr = (void *)virt_to_bus(&rxd[i+1]); /* Point to Next RX desc */
  6192. rxd[i].buf1sz = BUFLEN;
  6193. rxd[i].buf2sz = 0; /* not used */
  6194. rxd[i].control = 0x4; /* Chain Structure */
  6195. @@ -475,8 +462,8 @@
  6196. }
  6197. /* Chain the last descriptor to first */
  6198. - txd[NTXD - 1].buf2addr = (unsigned char *)&txd[0];
  6199. - rxd[NRXD - 1].buf2addr = (unsigned char *)&rxd[0];
  6200. + txd[NTXD - 1].buf2addr = (void *)virt_to_bus(&txd[0]);
  6201. + rxd[NRXD - 1].buf2addr = (void *)virt_to_bus(&rxd[0]);
  6202. TxPtr = 0;
  6203. rxd_tail = 0;
  6204. }
  6205. @@ -488,7 +475,6 @@
  6206. static void davicom_reset(struct nic *nic)
  6207. {
  6208. unsigned long to;
  6209. - u32 addr_low, addr_high;
  6210. whereami("davicom_reset\n");
  6211. @@ -507,8 +493,8 @@
  6212. davicom_init_chain(nic); /* Sten 10/9 */
  6213. /* Point to receive descriptor */
  6214. - outl((unsigned long)&rxd[0], ioaddr + CSR3);
  6215. - outl((unsigned long)&txd[0], ioaddr + CSR4); /* Sten 10/9 */
  6216. + outl(virt_to_bus(&rxd[0]), ioaddr + CSR3);
  6217. + outl(virt_to_bus(&txd[0]), ioaddr + CSR4); /* Sten 10/9 */
  6218. /* According phyxcer media mode to set CR6,
  6219. DM9102/A phyxcer can auto-detect media mode */
  6220. @@ -591,13 +577,15 @@
  6221. /*********************************************************************/
  6222. /* eth_poll - Wait for a frame */
  6223. /*********************************************************************/
  6224. -static int davicom_poll(struct nic *nic)
  6225. +static int davicom_poll(struct nic *nic, int retrieve)
  6226. {
  6227. whereami("davicom_poll\n");
  6228. if (rxd[rxd_tail].status & 0x80000000)
  6229. return 0;
  6230. + if ( ! retrieve ) return 1;
  6231. +
  6232. whereami("davicom_poll got one\n");
  6233. nic->packetlen = (rxd[rxd_tail].status & 0x3FFF0000) >> 16;
  6234. @@ -627,10 +615,13 @@
  6235. /*********************************************************************/
  6236. /* eth_disable - Disable the interface */
  6237. /*********************************************************************/
  6238. -static void davicom_disable(struct nic *nic)
  6239. +static void davicom_disable(struct dev *dev)
  6240. {
  6241. + struct nic *nic = (struct nic *)dev;
  6242. whereami("davicom_disable\n");
  6243. + davicom_reset(nic);
  6244. +
  6245. /* disable interrupts */
  6246. outl(0x00000000, ioaddr + CSR7);
  6247. @@ -640,24 +631,43 @@
  6248. /* Clear the missed-packet counter. */
  6249. (volatile unsigned long)inl(ioaddr + CSR8);
  6250. }
  6251. +
  6252. +
  6253. +/*********************************************************************/
  6254. +/* eth_irq - enable, disable and force interrupts */
  6255. +/*********************************************************************/
  6256. +static void davicom_irq(struct nic *nic __unused, irq_action_t action __unused)
  6257. +{
  6258. + switch ( action ) {
  6259. + case DISABLE :
  6260. + break;
  6261. + case ENABLE :
  6262. + break;
  6263. + case FORCE :
  6264. + break;
  6265. + }
  6266. +}
  6267. +
  6268. /*********************************************************************/
  6269. /* eth_probe - Look for an adapter */
  6270. /*********************************************************************/
  6271. -struct nic *davicom_probe(struct nic *nic, unsigned short *io_addrs,
  6272. - struct pci_device *pci)
  6273. +static int davicom_probe(struct dev *dev, struct pci_device *pci)
  6274. {
  6275. + struct nic *nic = (struct nic *)dev;
  6276. unsigned int i;
  6277. - u32 l1, l2;
  6278. whereami("davicom_probe\n");
  6279. - if (io_addrs == 0 || *io_addrs == 0)
  6280. + if (pci->ioaddr == 0)
  6281. return 0;
  6282. vendor = pci->vendor;
  6283. dev_id = pci->dev_id;
  6284. - ioaddr = *io_addrs;
  6285. + ioaddr = pci->ioaddr & ~3;
  6286. +
  6287. + nic->irqno = 0;
  6288. + nic->ioaddr = pci->ioaddr & ~3;
  6289. /* wakeup chip */
  6290. pcibios_write_config_dword(pci->bus, pci->devfn, 0x40, 0x00000000);
  6291. @@ -683,10 +693,26 @@
  6292. /* initialize device */
  6293. davicom_reset(nic);
  6294. - nic->reset = davicom_reset;
  6295. + dev->disable = davicom_disable;
  6296. nic->poll = davicom_poll;
  6297. nic->transmit = davicom_transmit;
  6298. - nic->disable = davicom_disable;
  6299. + nic->irq = davicom_irq;
  6300. - return nic;
  6301. + return 1;
  6302. }
  6303. +
  6304. +static struct pci_id davicom_nics[] = {
  6305. +PCI_ROM(0x1282, 0x9100, "davicom9100", "Davicom 9100"),
  6306. +PCI_ROM(0x1282, 0x9102, "davicom9102", "Davicom 9102"),
  6307. +PCI_ROM(0x1282, 0x9009, "davicom9009", "Davicom 9009"),
  6308. +PCI_ROM(0x1282, 0x9132, "davicom9132", "Davicom 9132"), /* Needs probably some fixing */
  6309. +};
  6310. +
  6311. +struct pci_driver davicom_driver = {
  6312. + .type = NIC_DRIVER,
  6313. + .name = "DAVICOM",
  6314. + .probe = davicom_probe,
  6315. + .ids = davicom_nics,
  6316. + .id_count = sizeof(davicom_nics)/sizeof(davicom_nics[0]),
  6317. + .class = 0,
  6318. +};
  6319. Index: b/netboot/depca.c
  6320. ===================================================================
  6321. --- a/netboot/depca.c
  6322. +++ /dev/null
  6323. @@ -1,752 +0,0 @@
  6324. -/* Etherboot: depca.h merged, comments from Linux driver retained */
  6325. -/* depca.c: A DIGITAL DEPCA & EtherWORKS ethernet driver for linux.
  6326. -
  6327. - Written 1994, 1995 by David C. Davies.
  6328. -
  6329. -
  6330. - Copyright 1994 David C. Davies
  6331. - and
  6332. - United States Government
  6333. - (as represented by the Director, National Security Agency).
  6334. -
  6335. - Copyright 1995 Digital Equipment Corporation.
  6336. -
  6337. -
  6338. - This software may be used and distributed according to the terms of
  6339. - the GNU Public License, incorporated herein by reference.
  6340. -
  6341. - This driver is written for the Digital Equipment Corporation series
  6342. - of DEPCA and EtherWORKS ethernet cards:
  6343. -
  6344. - DEPCA (the original)
  6345. - DE100
  6346. - DE101
  6347. - DE200 Turbo
  6348. - DE201 Turbo
  6349. - DE202 Turbo (TP BNC)
  6350. - DE210
  6351. - DE422 (EISA)
  6352. -
  6353. - The driver has been tested on DE100, DE200 and DE202 cards in a
  6354. - relatively busy network. The DE422 has been tested a little.
  6355. -
  6356. - This driver will NOT work for the DE203, DE204 and DE205 series of
  6357. - cards, since they have a new custom ASIC in place of the AMD LANCE
  6358. - chip. See the 'ewrk3.c' driver in the Linux source tree for running
  6359. - those cards.
  6360. -
  6361. - I have benchmarked the driver with a DE100 at 595kB/s to (542kB/s from)
  6362. - a DECstation 5000/200.
  6363. -
  6364. - The author may be reached at davies@maniac.ultranet.com
  6365. -
  6366. - =========================================================================
  6367. -
  6368. - The driver was originally based on the 'lance.c' driver from Donald
  6369. - Becker which is included with the standard driver distribution for
  6370. - linux. V0.4 is a complete re-write with only the kernel interface
  6371. - remaining from the original code.
  6372. -
  6373. - 1) Lance.c code in /linux/drivers/net/
  6374. - 2) "Ethernet/IEEE 802.3 Family. 1992 World Network Data Book/Handbook",
  6375. - AMD, 1992 [(800) 222-9323].
  6376. - 3) "Am79C90 CMOS Local Area Network Controller for Ethernet (C-LANCE)",
  6377. - AMD, Pub. #17881, May 1993.
  6378. - 4) "Am79C960 PCnet-ISA(tm), Single-Chip Ethernet Controller for ISA",
  6379. - AMD, Pub. #16907, May 1992
  6380. - 5) "DEC EtherWORKS LC Ethernet Controller Owners Manual",
  6381. - Digital Equipment corporation, 1990, Pub. #EK-DE100-OM.003
  6382. - 6) "DEC EtherWORKS Turbo Ethernet Controller Owners Manual",
  6383. - Digital Equipment corporation, 1990, Pub. #EK-DE200-OM.003
  6384. - 7) "DEPCA Hardware Reference Manual", Pub. #EK-DEPCA-PR
  6385. - Digital Equipment Corporation, 1989
  6386. - 8) "DEC EtherWORKS Turbo_(TP BNC) Ethernet Controller Owners Manual",
  6387. - Digital Equipment corporation, 1991, Pub. #EK-DE202-OM.001
  6388. -
  6389. -
  6390. - Peter Bauer's depca.c (V0.5) was referred to when debugging V0.1 of this
  6391. - driver.
  6392. -
  6393. - The original DEPCA card requires that the ethernet ROM address counter
  6394. - be enabled to count and has an 8 bit NICSR. The ROM counter enabling is
  6395. - only done when a 0x08 is read as the first address octet (to minimise
  6396. - the chances of writing over some other hardware's I/O register). The
  6397. - NICSR accesses have been changed to byte accesses for all the cards
  6398. - supported by this driver, since there is only one useful bit in the MSB
  6399. - (remote boot timeout) and it is not used. Also, there is a maximum of
  6400. - only 48kB network RAM for this card. My thanks to Torbjorn Lindh for
  6401. - help debugging all this (and holding my feet to the fire until I got it
  6402. - right).
  6403. -
  6404. - The DE200 series boards have on-board 64kB RAM for use as a shared
  6405. - memory network buffer. Only the DE100 cards make use of a 2kB buffer
  6406. - mode which has not been implemented in this driver (only the 32kB and
  6407. - 64kB modes are supported [16kB/48kB for the original DEPCA]).
  6408. -
  6409. - At the most only 2 DEPCA cards can be supported on the ISA bus because
  6410. - there is only provision for two I/O base addresses on each card (0x300
  6411. - and 0x200). The I/O address is detected by searching for a byte sequence
  6412. - in the Ethernet station address PROM at the expected I/O address for the
  6413. - Ethernet PROM. The shared memory base address is 'autoprobed' by
  6414. - looking for the self test PROM and detecting the card name. When a
  6415. - second DEPCA is detected, information is placed in the base_addr
  6416. - variable of the next device structure (which is created if necessary),
  6417. - thus enabling ethif_probe initialization for the device. More than 2
  6418. - EISA cards can be supported, but care will be needed assigning the
  6419. - shared memory to ensure that each slot has the correct IRQ, I/O address
  6420. - and shared memory address assigned.
  6421. -
  6422. - ************************************************************************
  6423. -
  6424. - NOTE: If you are using two ISA DEPCAs, it is important that you assign
  6425. - the base memory addresses correctly. The driver autoprobes I/O 0x300
  6426. - then 0x200. The base memory address for the first device must be less
  6427. - than that of the second so that the auto probe will correctly assign the
  6428. - I/O and memory addresses on the same card. I can't think of a way to do
  6429. - this unambiguously at the moment, since there is nothing on the cards to
  6430. - tie I/O and memory information together.
  6431. -
  6432. - I am unable to test 2 cards together for now, so this code is
  6433. - unchecked. All reports, good or bad, are welcome.
  6434. -
  6435. - ************************************************************************
  6436. -
  6437. - The board IRQ setting must be at an unused IRQ which is auto-probed
  6438. - using Donald Becker's autoprobe routines. DEPCA and DE100 board IRQs are
  6439. - {2,3,4,5,7}, whereas the DE200 is at {5,9,10,11,15}. Note that IRQ2 is
  6440. - really IRQ9 in machines with 16 IRQ lines.
  6441. -
  6442. - No 16MB memory limitation should exist with this driver as DMA is not
  6443. - used and the common memory area is in low memory on the network card (my
  6444. - current system has 20MB and I've not had problems yet).
  6445. -
  6446. - The ability to load this driver as a loadable module has been added. To
  6447. - utilise this ability, you have to do <8 things:
  6448. -
  6449. - 0) have a copy of the loadable modules code installed on your system.
  6450. - 1) copy depca.c from the /linux/drivers/net directory to your favourite
  6451. - temporary directory.
  6452. - 2) if you wish, edit the source code near line 1530 to reflect the I/O
  6453. - address and IRQ you're using (see also 5).
  6454. - 3) compile depca.c, but include -DMODULE in the command line to ensure
  6455. - that the correct bits are compiled (see end of source code).
  6456. - 4) if you are wanting to add a new card, goto 5. Otherwise, recompile a
  6457. - kernel with the depca configuration turned off and reboot.
  6458. - 5) insmod depca.o [irq=7] [io=0x200] [mem=0xd0000] [adapter_name=DE100]
  6459. - [Alan Cox: Changed the code to allow command line irq/io assignments]
  6460. - [Dave Davies: Changed the code to allow command line mem/name
  6461. - assignments]
  6462. - 6) run the net startup bits for your eth?? interface manually
  6463. - (usually /etc/rc.inet[12] at boot time).
  6464. - 7) enjoy!
  6465. -
  6466. - Note that autoprobing is not allowed in loadable modules - the system is
  6467. - already up and running and you're messing with interrupts.
  6468. -
  6469. - To unload a module, turn off the associated interface
  6470. - 'ifconfig eth?? down' then 'rmmod depca'.
  6471. -
  6472. - To assign a base memory address for the shared memory when running as a
  6473. - loadable module, see 5 above. To include the adapter name (if you have
  6474. - no PROM but know the card name) also see 5 above. Note that this last
  6475. - option will not work with kernel built-in depca's.
  6476. -
  6477. - The shared memory assignment for a loadable module makes sense to avoid
  6478. - the 'memory autoprobe' picking the wrong shared memory (for the case of
  6479. - 2 depca's in a PC).
  6480. -
  6481. - ************************************************************************
  6482. - Support for MCA EtherWORKS cards added 11-3-98.
  6483. - Verified to work with up to 2 DE212 cards in a system (although not
  6484. - fully stress-tested).
  6485. -
  6486. - Currently known bugs/limitations:
  6487. -
  6488. - Note: with the MCA stuff as a module, it trusts the MCA configuration,
  6489. - not the command line for IRQ and memory address. You can
  6490. - specify them if you want, but it will throw your values out.
  6491. - You still have to pass the IO address it was configured as
  6492. - though.
  6493. -
  6494. - ************************************************************************
  6495. - TO DO:
  6496. - ------
  6497. -
  6498. -
  6499. - Revision History
  6500. - ----------------
  6501. -
  6502. - Version Date Description
  6503. -
  6504. - 0.1 25-jan-94 Initial writing.
  6505. - 0.2 27-jan-94 Added LANCE TX hardware buffer chaining.
  6506. - 0.3 1-feb-94 Added multiple DEPCA support.
  6507. - 0.31 4-feb-94 Added DE202 recognition.
  6508. - 0.32 19-feb-94 Tidy up. Improve multi-DEPCA support.
  6509. - 0.33 25-feb-94 Fix DEPCA ethernet ROM counter enable.
  6510. - Add jabber packet fix from murf@perftech.com
  6511. - and becker@super.org
  6512. - 0.34 7-mar-94 Fix DEPCA max network memory RAM & NICSR access.
  6513. - 0.35 8-mar-94 Added DE201 recognition. Tidied up.
  6514. - 0.351 30-apr-94 Added EISA support. Added DE422 recognition.
  6515. - 0.36 16-may-94 DE422 fix released.
  6516. - 0.37 22-jul-94 Added MODULE support
  6517. - 0.38 15-aug-94 Added DBR ROM switch in depca_close().
  6518. - Multi DEPCA bug fix.
  6519. - 0.38axp 15-sep-94 Special version for Alpha AXP Linux V1.0.
  6520. - 0.381 12-dec-94 Added DE101 recognition, fix multicast bug.
  6521. - 0.382 9-feb-95 Fix recognition bug reported by <bkm@star.rl.ac.uk>.
  6522. - 0.383 22-feb-95 Fix for conflict with VESA SCSI reported by
  6523. - <stromain@alf.dec.com>
  6524. - 0.384 17-mar-95 Fix a ring full bug reported by <bkm@star.rl.ac.uk>
  6525. - 0.385 3-apr-95 Fix a recognition bug reported by
  6526. - <ryan.niemi@lastfrontier.com>
  6527. - 0.386 21-apr-95 Fix the last fix...sorry, must be galloping senility
  6528. - 0.40 25-May-95 Rewrite for portability & updated.
  6529. - ALPHA support from <jestabro@amt.tay1.dec.com>
  6530. - 0.41 26-Jun-95 Added verify_area() calls in depca_ioctl() from
  6531. - suggestion by <heiko@colossus.escape.de>
  6532. - 0.42 27-Dec-95 Add 'mem' shared memory assignment for loadable
  6533. - modules.
  6534. - Add 'adapter_name' for loadable modules when no PROM.
  6535. - Both above from a suggestion by
  6536. - <pchen@woodruffs121.residence.gatech.edu>.
  6537. - Add new multicasting code.
  6538. - 0.421 22-Apr-96 Fix alloc_device() bug <jari@markkus2.fimr.fi>
  6539. - 0.422 29-Apr-96 Fix depca_hw_init() bug <jari@markkus2.fimr.fi>
  6540. - 0.423 7-Jun-96 Fix module load bug <kmg@barco.be>
  6541. - 0.43 16-Aug-96 Update alloc_device() to conform to de4x5.c
  6542. - 0.44 1-Sep-97 Fix *_probe() to test check_region() first - bug
  6543. - reported by <mmogilvi@elbert.uccs.edu>
  6544. - 0.45 3-Nov-98 Added support for MCA EtherWORKS (DE210/DE212) cards
  6545. - by <tymm@computer.org>
  6546. - 0.451 5-Nov-98 Fixed mca stuff cuz I'm a dummy. <tymm@computer.org>
  6547. - 0.5 14-Nov-98 Re-spin for 2.1.x kernels.
  6548. - 0.51 27-Jun-99 Correct received packet length for CRC from
  6549. - report by <worm@dkik.dk>
  6550. -
  6551. - =========================================================================
  6552. -*/
  6553. -
  6554. -#include "etherboot.h"
  6555. -#include "nic.h"
  6556. -#include "cards.h"
  6557. -
  6558. -/*
  6559. -** I/O addresses. Note that the 2k buffer option is not supported in
  6560. -** this driver.
  6561. -*/
  6562. -#define DEPCA_NICSR ioaddr+0x00 /* Network interface CSR */
  6563. -#define DEPCA_RBI ioaddr+0x02 /* RAM buffer index (2k buffer mode) */
  6564. -#define DEPCA_DATA ioaddr+0x04 /* LANCE registers' data port */
  6565. -#define DEPCA_ADDR ioaddr+0x06 /* LANCE registers' address port */
  6566. -#define DEPCA_HBASE ioaddr+0x08 /* EISA high memory base address reg. */
  6567. -#define DEPCA_PROM ioaddr+0x0c /* Ethernet address ROM data port */
  6568. -#define DEPCA_CNFG ioaddr+0x0c /* EISA Configuration port */
  6569. -#define DEPCA_RBSA ioaddr+0x0e /* RAM buffer starting address (2k buff.) */
  6570. -
  6571. -/*
  6572. -** These are LANCE registers addressable through DEPCA_ADDR
  6573. -*/
  6574. -#define CSR0 0
  6575. -#define CSR1 1
  6576. -#define CSR2 2
  6577. -#define CSR3 3
  6578. -
  6579. -/*
  6580. -** NETWORK INTERFACE CSR (NI_CSR) bit definitions
  6581. -*/
  6582. -
  6583. -#define TO 0x0100 /* Time Out for remote boot */
  6584. -#define SHE 0x0080 /* SHadow memory Enable */
  6585. -#define BS 0x0040 /* Bank Select */
  6586. -#define BUF 0x0020 /* BUFfer size (1->32k, 0->64k) */
  6587. -#define RBE 0x0010 /* Remote Boot Enable (1->net boot) */
  6588. -#define AAC 0x0008 /* Address ROM Address Counter (1->enable) */
  6589. -#define _128KB 0x0008 /* 128kB Network RAM (1->enable) */
  6590. -#define IM 0x0004 /* Interrupt Mask (1->mask) */
  6591. -#define IEN 0x0002 /* Interrupt tristate ENable (1->enable) */
  6592. -#define LED 0x0001 /* LED control */
  6593. -
  6594. -/*
  6595. -** Control and Status Register 0 (CSR0) bit definitions
  6596. -*/
  6597. -
  6598. -#define ERR 0x8000 /* Error summary */
  6599. -#define BABL 0x4000 /* Babble transmitter timeout error */
  6600. -#define CERR 0x2000 /* Collision Error */
  6601. -#define MISS 0x1000 /* Missed packet */
  6602. -#define MERR 0x0800 /* Memory Error */
  6603. -#define RINT 0x0400 /* Receiver Interrupt */
  6604. -#define TINT 0x0200 /* Transmit Interrupt */
  6605. -#define IDON 0x0100 /* Initialization Done */
  6606. -#define INTR 0x0080 /* Interrupt Flag */
  6607. -#define INEA 0x0040 /* Interrupt Enable */
  6608. -#define RXON 0x0020 /* Receiver on */
  6609. -#define TXON 0x0010 /* Transmitter on */
  6610. -#define TDMD 0x0008 /* Transmit Demand */
  6611. -#define STOP 0x0004 /* Stop */
  6612. -#define STRT 0x0002 /* Start */
  6613. -#define INIT 0x0001 /* Initialize */
  6614. -#define INTM 0xff00 /* Interrupt Mask */
  6615. -#define INTE 0xfff0 /* Interrupt Enable */
  6616. -
  6617. -/*
  6618. -** CONTROL AND STATUS REGISTER 3 (CSR3)
  6619. -*/
  6620. -
  6621. -#define BSWP 0x0004 /* Byte SWaP */
  6622. -#define ACON 0x0002 /* ALE control */
  6623. -#define BCON 0x0001 /* Byte CONtrol */
  6624. -
  6625. -/*
  6626. -** Initialization Block Mode Register
  6627. -*/
  6628. -
  6629. -#define PROM 0x8000 /* Promiscuous Mode */
  6630. -#define EMBA 0x0080 /* Enable Modified Back-off Algorithm */
  6631. -#define INTL 0x0040 /* Internal Loopback */
  6632. -#define DRTY 0x0020 /* Disable Retry */
  6633. -#define COLL 0x0010 /* Force Collision */
  6634. -#define DTCR 0x0008 /* Disable Transmit CRC */
  6635. -#define LOOP 0x0004 /* Loopback */
  6636. -#define DTX 0x0002 /* Disable the Transmitter */
  6637. -#define DRX 0x0001 /* Disable the Receiver */
  6638. -
  6639. -/*
  6640. -** Receive Message Descriptor 1 (RMD1) bit definitions.
  6641. -*/
  6642. -
  6643. -#define R_OWN 0x80000000 /* Owner bit 0 = host, 1 = lance */
  6644. -#define R_ERR 0x4000 /* Error Summary */
  6645. -#define R_FRAM 0x2000 /* Framing Error */
  6646. -#define R_OFLO 0x1000 /* Overflow Error */
  6647. -#define R_CRC 0x0800 /* CRC Error */
  6648. -#define R_BUFF 0x0400 /* Buffer Error */
  6649. -#define R_STP 0x0200 /* Start of Packet */
  6650. -#define R_ENP 0x0100 /* End of Packet */
  6651. -
  6652. -/*
  6653. -** Transmit Message Descriptor 1 (TMD1) bit definitions.
  6654. -*/
  6655. -
  6656. -#define T_OWN 0x80000000 /* Owner bit 0 = host, 1 = lance */
  6657. -#define T_ERR 0x4000 /* Error Summary */
  6658. -#define T_ADD_FCS 0x2000 /* More the 1 retry needed to Xmit */
  6659. -#define T_MORE 0x1000 /* >1 retry to transmit packet */
  6660. -#define T_ONE 0x0800 /* 1 try needed to transmit the packet */
  6661. -#define T_DEF 0x0400 /* Deferred */
  6662. -#define T_STP 0x02000000 /* Start of Packet */
  6663. -#define T_ENP 0x01000000 /* End of Packet */
  6664. -#define T_FLAGS 0xff000000 /* TX Flags Field */
  6665. -
  6666. -/*
  6667. -** Transmit Message Descriptor 3 (TMD3) bit definitions.
  6668. -*/
  6669. -
  6670. -#define TMD3_BUFF 0x8000 /* BUFFer error */
  6671. -#define TMD3_UFLO 0x4000 /* UnderFLOw error */
  6672. -#define TMD3_RES 0x2000 /* REServed */
  6673. -#define TMD3_LCOL 0x1000 /* Late COLlision */
  6674. -#define TMD3_LCAR 0x0800 /* Loss of CARrier */
  6675. -#define TMD3_RTRY 0x0400 /* ReTRY error */
  6676. -
  6677. -/*
  6678. -** Ethernet PROM defines
  6679. -*/
  6680. -#define PROBE_LENGTH 32
  6681. -
  6682. -/*
  6683. -** Set the number of Tx and Rx buffers. Ensure that the memory requested
  6684. -** here is <= to the amount of shared memory set up by the board switches.
  6685. -** The number of descriptors MUST BE A POWER OF 2.
  6686. -**
  6687. -** total_memory = NUM_RX_DESC*(8+RX_BUFF_SZ) + NUM_TX_DESC*(8+TX_BUFF_SZ)
  6688. -*/
  6689. -#define NUM_RX_DESC 2 /* Number of RX descriptors */
  6690. -#define NUM_TX_DESC 2 /* Number of TX descriptors */
  6691. -#define RX_BUFF_SZ 1536 /* Buffer size for each Rx buffer */
  6692. -#define TX_BUFF_SZ 1536 /* Buffer size for each Tx buffer */
  6693. -
  6694. -/*
  6695. -** ISA Bus defines
  6696. -*/
  6697. -#define DEPCA_IO_PORTS {0x300, 0x200, 0}
  6698. -
  6699. -#ifndef DEPCA_MODEL
  6700. -#define DEPCA_MODEL DEPCA
  6701. -#endif
  6702. -
  6703. -static enum {
  6704. - DEPCA, DE100, DE101, DE200, DE201, DE202, DE210, DE212, DE422, unknown
  6705. -} adapter = DEPCA_MODEL;
  6706. -
  6707. -/*
  6708. -** Name <-> Adapter mapping
  6709. -*/
  6710. -
  6711. -static char *adapter_name[] = {
  6712. - "DEPCA",
  6713. - "DE100","DE101",
  6714. - "DE200","DE201","DE202",
  6715. - "DE210","DE212",
  6716. - "DE422",
  6717. - ""
  6718. -};
  6719. -
  6720. -#ifndef DEPCA_RAM_BASE
  6721. -#define DEPCA_RAM_BASE 0xd0000
  6722. -#endif
  6723. -
  6724. -/*
  6725. -** Memory Alignment. Each descriptor is 4 longwords long. To force a
  6726. -** particular alignment on the TX descriptor, adjust DESC_SKIP_LEN and
  6727. -** DESC_ALIGN. ALIGN aligns the start address of the private memory area
  6728. -** and hence the RX descriptor ring's first entry.
  6729. -*/
  6730. -#define ALIGN4 ((u32)4 - 1) /* 1 longword align */
  6731. -#define ALIGN8 ((u32)8 - 1) /* 2 longword (quadword) align */
  6732. -#define ALIGN ALIGN8 /* Keep the LANCE happy... */
  6733. -
  6734. -typedef long s32;
  6735. -typedef unsigned long u32;
  6736. -typedef short s16;
  6737. -typedef unsigned short u16;
  6738. -typedef char s8;
  6739. -typedef unsigned char u8;
  6740. -
  6741. -/*
  6742. -** The DEPCA Rx and Tx ring descriptors.
  6743. -*/
  6744. -struct depca_rx_desc {
  6745. - volatile s32 base;
  6746. - s16 buf_length; /* This length is negative 2's complement! */
  6747. - s16 msg_length; /* This length is "normal". */
  6748. -};
  6749. -
  6750. -struct depca_tx_desc {
  6751. - volatile s32 base;
  6752. - s16 length; /* This length is negative 2's complement! */
  6753. - s16 misc; /* Errors and TDR info */
  6754. -};
  6755. -
  6756. -#define LA_MASK 0x0000ffff /* LANCE address mask for mapping network RAM
  6757. - to LANCE memory address space */
  6758. -
  6759. -/*
  6760. -** The Lance initialization block, described in databook, in common memory.
  6761. -*/
  6762. -struct depca_init {
  6763. - u16 mode; /* Mode register */
  6764. - u8 phys_addr[ETH_ALEN]; /* Physical ethernet address */
  6765. - u8 mcast_table[8]; /* Multicast Hash Table. */
  6766. - u32 rx_ring; /* Rx ring base pointer & ring length */
  6767. - u32 tx_ring; /* Tx ring base pointer & ring length */
  6768. -};
  6769. -
  6770. -struct depca_private {
  6771. - struct depca_rx_desc *rx_ring;
  6772. - struct depca_tx_desc *tx_ring;
  6773. - struct depca_init init_block; /* Shadow init block */
  6774. - char *rx_memcpy[NUM_RX_DESC];
  6775. - char *tx_memcpy[NUM_TX_DESC];
  6776. - u32 bus_offset; /* ISA bus address offset */
  6777. - u32 sh_mem; /* address of shared mem */
  6778. - u32 dma_buffs; /* Rx & Tx buffer start */
  6779. - int rx_cur, tx_cur; /* Next free ring entry */
  6780. - int txRingMask, rxRingMask;
  6781. - s32 rx_rlen, tx_rlen;
  6782. - /* log2([rt]xRingMask+1) for the descriptors */
  6783. -};
  6784. -
  6785. -static Address mem_start = DEPCA_RAM_BASE;
  6786. -static Address mem_len, offset;
  6787. -static unsigned short ioaddr = 0;
  6788. -static struct depca_private lp;
  6789. -
  6790. -/*
  6791. -** Miscellaneous defines...
  6792. -*/
  6793. -#define STOP_DEPCA \
  6794. - outw(CSR0, DEPCA_ADDR);\
  6795. - outw(STOP, DEPCA_DATA)
  6796. -
  6797. -/* Initialize the lance Rx and Tx descriptor rings. */
  6798. -static void depca_init_ring(struct nic *nic)
  6799. -{
  6800. - int i;
  6801. - u32 p;
  6802. -
  6803. - lp.rx_cur = lp.tx_cur = 0;
  6804. - /* Initialize the base addresses and length of each buffer in the ring */
  6805. - for (i = 0; i <= lp.rxRingMask; i++) {
  6806. - writel((p = lp.dma_buffs + i * RX_BUFF_SZ) | R_OWN, &lp.rx_ring[i].base);
  6807. - writew(-RX_BUFF_SZ, &lp.rx_ring[i].buf_length);
  6808. - lp.rx_memcpy[i] = (char *) (p + lp.bus_offset);
  6809. - }
  6810. - for (i = 0; i <= lp.txRingMask; i++) {
  6811. - writel((p = lp.dma_buffs + (i + lp.txRingMask + 1) * TX_BUFF_SZ) & 0x00ffffff, &lp.tx_ring[i].base);
  6812. - lp.tx_memcpy[i] = (char *) (p + lp.bus_offset);
  6813. - }
  6814. -
  6815. - /* Set up the initialization block */
  6816. - lp.init_block.rx_ring = ((u32) ((u32) lp.rx_ring) & LA_MASK) | lp.rx_rlen;
  6817. - lp.init_block.tx_ring = ((u32) ((u32) lp.tx_ring) & LA_MASK) | lp.tx_rlen;
  6818. - for (i = 0; i < ETH_ALEN; i++)
  6819. - lp.init_block.phys_addr[i] = nic->node_addr[i];
  6820. - lp.init_block.mode = 0x0000; /* Enable the Tx and Rx */
  6821. - memset(lp.init_block.mcast_table, 0, sizeof(lp.init_block.mcast_table));
  6822. -}
  6823. -
  6824. -static void LoadCSRs(void)
  6825. -{
  6826. - outw(CSR1, DEPCA_ADDR); /* initialisation block address LSW */
  6827. - outw((u16) (lp.sh_mem & LA_MASK), DEPCA_DATA);
  6828. - outw(CSR2, DEPCA_ADDR); /* initialisation block address MSW */
  6829. - outw((u16) ((lp.sh_mem & LA_MASK) >> 16), DEPCA_DATA);
  6830. - outw(CSR3, DEPCA_ADDR); /* ALE control */
  6831. - outw(ACON, DEPCA_DATA);
  6832. - outw(CSR0, DEPCA_ADDR); /* Point back to CSR0 */
  6833. -}
  6834. -
  6835. -static int InitRestartDepca(void)
  6836. -{
  6837. - int i;
  6838. -
  6839. - /* Copy the shadow init_block to shared memory */
  6840. - memcpy_toio((char *)lp.sh_mem, &lp.init_block, sizeof(struct depca_init));
  6841. - outw(CSR0, DEPCA_ADDR); /* point back to CSR0 */
  6842. - outw(INIT, DEPCA_DATA); /* initialise DEPCA */
  6843. -
  6844. - for (i = 0; i < 100 && !(inw(DEPCA_DATA) & IDON); i++)
  6845. - ;
  6846. - if (i < 100) {
  6847. - /* clear IDON by writing a 1, and start LANCE */
  6848. - outw(IDON | STRT, DEPCA_DATA);
  6849. - } else {
  6850. - printf("DEPCA not initialised\n");
  6851. - return (1);
  6852. - }
  6853. - return (0);
  6854. -}
  6855. -
  6856. -/**************************************************************************
  6857. -RESET - Reset adapter
  6858. -***************************************************************************/
  6859. -static void depca_reset(struct nic *nic)
  6860. -{
  6861. - s16 nicsr;
  6862. - int i, j;
  6863. -
  6864. - STOP_DEPCA;
  6865. - nicsr = inb(DEPCA_NICSR);
  6866. - nicsr = ((nicsr & ~SHE & ~RBE & ~IEN) | IM);
  6867. - outb(nicsr, DEPCA_NICSR);
  6868. - if (inw(DEPCA_DATA) != STOP)
  6869. - {
  6870. - printf("depca: Cannot stop NIC\n");
  6871. - return;
  6872. - }
  6873. -
  6874. - /* Initialisation block */
  6875. - lp.sh_mem = mem_start;
  6876. - mem_start += sizeof(struct depca_init);
  6877. - /* Tx & Rx descriptors (aligned to a quadword boundary) */
  6878. - mem_start = (mem_start + ALIGN) & ~ALIGN;
  6879. - lp.rx_ring = (struct depca_rx_desc *) mem_start;
  6880. - mem_start += (sizeof(struct depca_rx_desc) * NUM_RX_DESC);
  6881. - lp.tx_ring = (struct depca_tx_desc *) mem_start;
  6882. - mem_start += (sizeof(struct depca_tx_desc) * NUM_TX_DESC);
  6883. -
  6884. - lp.bus_offset = mem_start & 0x00ff0000;
  6885. - /* LANCE re-mapped start address */
  6886. - lp.dma_buffs = mem_start & LA_MASK;
  6887. -
  6888. - /* Finish initialising the ring information. */
  6889. - lp.rxRingMask = NUM_RX_DESC - 1;
  6890. - lp.txRingMask = NUM_TX_DESC - 1;
  6891. -
  6892. - /* Calculate Tx/Rx RLEN size for the descriptors. */
  6893. - for (i = 0, j = lp.rxRingMask; j > 0; i++) {
  6894. - j >>= 1;
  6895. - }
  6896. - lp.rx_rlen = (s32) (i << 29);
  6897. - for (i = 0, j = lp.txRingMask; j > 0; i++) {
  6898. - j >>= 1;
  6899. - }
  6900. - lp.tx_rlen = (s32) (i << 29);
  6901. -
  6902. - /* Load the initialisation block */
  6903. - depca_init_ring(nic);
  6904. - LoadCSRs();
  6905. - InitRestartDepca();
  6906. -}
  6907. -
  6908. -/**************************************************************************
  6909. -POLL - Wait for a frame
  6910. -***************************************************************************/
  6911. -static int depca_poll(struct nic *nic)
  6912. -{
  6913. - int entry;
  6914. - u32 status;
  6915. -
  6916. - entry = lp.rx_cur;
  6917. - if ((status = readl(&lp.rx_ring[entry].base) & R_OWN))
  6918. - return (0);
  6919. - memcpy(nic->packet, lp.rx_memcpy[entry], nic->packetlen = lp.rx_ring[entry].msg_length);
  6920. - lp.rx_ring[entry].base |= R_OWN;
  6921. - lp.rx_cur = (++lp.rx_cur) & lp.rxRingMask;
  6922. - return (1);
  6923. -}
  6924. -
  6925. -/**************************************************************************
  6926. -TRANSMIT - Transmit a frame
  6927. -***************************************************************************/
  6928. -static void depca_transmit(
  6929. - struct nic *nic,
  6930. - const char *d, /* Destination */
  6931. - unsigned int t, /* Type */
  6932. - unsigned int s, /* size */
  6933. - const char *p) /* Packet */
  6934. -{
  6935. - int entry, len;
  6936. - char *mem;
  6937. -
  6938. - /* send the packet to destination */
  6939. - /*
  6940. - ** Caution: the right order is important here... dont
  6941. - ** setup the ownership rights until all the other
  6942. - ** information is in place
  6943. - */
  6944. - mem = lp.tx_memcpy[entry = lp.tx_cur];
  6945. - memcpy_toio(mem, d, ETH_ALEN);
  6946. - memcpy_toio(mem + ETH_ALEN, nic->node_addr, ETH_ALEN);
  6947. - mem[ETH_ALEN * 2] = t >> 8;
  6948. - mem[ETH_ALEN * 2 + 1] = t;
  6949. - memcpy_toio(mem + ETH_HLEN, p, s);
  6950. - s += ETH_HLEN;
  6951. - len = (s < ETH_ZLEN ? ETH_ZLEN : s);
  6952. - /* clean out flags */
  6953. - writel(readl(&lp.tx_ring[entry].base) & ~T_FLAGS, &lp.tx_ring[entry].base);
  6954. - /* clears other error flags */
  6955. - writew(0x0000, &lp.tx_ring[entry].misc);
  6956. - /* packet length in buffer */
  6957. - writew(-len, &lp.tx_ring[entry].length);
  6958. - /* start and end of packet, ownership */
  6959. - writel(readl(&lp.tx_ring[entry].base) | (T_STP|T_ENP|T_OWN), &lp.tx_ring[entry].base);
  6960. - /* update current pointers */
  6961. - lp.tx_cur = (++lp.tx_cur) & lp.txRingMask;
  6962. -}
  6963. -
  6964. -/**************************************************************************
  6965. -DISABLE - Turn off ethernet interface
  6966. -***************************************************************************/
  6967. -static void depca_disable(struct nic *nic)
  6968. -{
  6969. - STOP_DEPCA;
  6970. -}
  6971. -
  6972. -/*
  6973. -** Look for a special sequence in the Ethernet station address PROM that
  6974. -** is common across all DEPCA products. Note that the original DEPCA needs
  6975. -** its ROM address counter to be initialized and enabled. Only enable
  6976. -** if the first address octet is a 0x08 - this minimises the chances of
  6977. -** messing around with some other hardware, but it assumes that this DEPCA
  6978. -** card initialized itself correctly.
  6979. -**
  6980. -** Search the Ethernet address ROM for the signature. Since the ROM address
  6981. -** counter can start at an arbitrary point, the search must include the entire
  6982. -** probe sequence length plus the (length_of_the_signature - 1).
  6983. -** Stop the search IMMEDIATELY after the signature is found so that the
  6984. -** PROM address counter is correctly positioned at the start of the
  6985. -** ethernet address for later read out.
  6986. -*/
  6987. -static int depca_probe1(struct nic *nic)
  6988. -{
  6989. - u8 data, nicsr;
  6990. - /* This is only correct for little endian machines, but then
  6991. - Etherboot doesn't work on anything but a PC */
  6992. - u8 sig[] = { 0xFF, 0x00, 0x55, 0xAA, 0xFF, 0x00, 0x55, 0xAA };
  6993. - int i, j;
  6994. - long sum, chksum;
  6995. -
  6996. - data = inb(DEPCA_PROM); /* clear counter on DEPCA */
  6997. - data = inb(DEPCA_PROM); /* read data */
  6998. - if (data == 0x8) {
  6999. - nicsr = inb(DEPCA_NICSR);
  7000. - nicsr |= AAC;
  7001. - outb(nicsr, DEPCA_NICSR);
  7002. - }
  7003. - for (i = 0, j = 0; j < (int)sizeof(sig) && i < PROBE_LENGTH+((int)sizeof(sig))-1; ++i) {
  7004. - data = inb(DEPCA_PROM);
  7005. - if (data == sig[j]) /* track signature */
  7006. - ++j;
  7007. - else
  7008. - j = (data == sig[0]) ? 1 : 0;
  7009. - }
  7010. - if (j != sizeof(sig))
  7011. - return (0);
  7012. - /* put the card in its initial state */
  7013. - STOP_DEPCA;
  7014. - nicsr = ((inb(DEPCA_NICSR) & ~SHE & ~RBE & ~IEN) | IM);
  7015. - outb(nicsr, DEPCA_NICSR);
  7016. - if (inw(DEPCA_DATA) != STOP)
  7017. - return (0);
  7018. - memcpy((char *)mem_start, sig, sizeof(sig));
  7019. - if (memcmp((char *)mem_start, sig, sizeof(sig)) != 0)
  7020. - return (0);
  7021. - for (i = 0, j = 0, sum = 0; j < 3; j++) {
  7022. - sum <<= 1;
  7023. - if (sum > 0xFFFF)
  7024. - sum -= 0xFFFF;
  7025. - sum += (u8)(nic->node_addr[i++] = inb(DEPCA_PROM));
  7026. - sum += (u16)((nic->node_addr[i++] = inb(DEPCA_PROM)) << 8);
  7027. - if (sum > 0xFFFF)
  7028. - sum -= 0xFFFF;
  7029. - }
  7030. - if (sum == 0xFFFF)
  7031. - sum = 0;
  7032. - chksum = (u8)inb(DEPCA_PROM);
  7033. - chksum |= (u16)(inb(DEPCA_PROM) << 8);
  7034. - mem_len = (adapter == DEPCA) ? (48 << 10) : (64 << 10);
  7035. - offset = 0;
  7036. - if (nicsr & BUF) {
  7037. - offset = 0x8000;
  7038. - nicsr &= ~BS;
  7039. - mem_len -= (32 << 10);
  7040. - }
  7041. - if (adapter != DEPCA) /* enable shadow RAM */
  7042. - outb(nicsr |= SHE, DEPCA_NICSR);
  7043. - printf("%s base %#hX, memory [%#hX-%#hX], addr %!",
  7044. - adapter_name[adapter], ioaddr, mem_start, mem_start + mem_len,
  7045. - nic->node_addr);
  7046. - if (sum != chksum)
  7047. - printf(" (bad checksum)");
  7048. - putchar('\n');
  7049. - return (1);
  7050. -}
  7051. -
  7052. -/**************************************************************************
  7053. -PROBE - Look for an adapter, this routine's visible to the outside
  7054. -***************************************************************************/
  7055. -struct nic *depca_probe(struct nic *nic, unsigned short *probe_addrs)
  7056. -{
  7057. - static unsigned short base[] = DEPCA_IO_PORTS;
  7058. - int i;
  7059. -
  7060. - if (probe_addrs == 0 || probe_addrs[0] == 0)
  7061. - probe_addrs = base; /* Use defaults */
  7062. - for (i = 0; (ioaddr = base[i]) != 0; ++i) {
  7063. - if (depca_probe1(nic))
  7064. - break;
  7065. - }
  7066. - if (ioaddr == 0)
  7067. - return (0);
  7068. - depca_reset(nic);
  7069. - /* point to NIC specific routines */
  7070. - nic->reset = depca_reset;
  7071. - nic->poll = depca_poll;
  7072. - nic->transmit = depca_transmit;
  7073. - nic->disable = depca_disable;
  7074. - return (nic);
  7075. -}
  7076. Index: b/netboot/dev.h
  7077. ===================================================================
  7078. --- /dev/null
  7079. +++ b/netboot/dev.h
  7080. @@ -0,0 +1,83 @@
  7081. +#ifndef _DEV_H
  7082. +#define _DEV_H
  7083. +
  7084. +#include "isa.h"
  7085. +#include "pci.h"
  7086. +
  7087. +/* Need to check the packing of this struct if Etherboot is ported */
  7088. +struct dev_id
  7089. +{
  7090. + unsigned short vendor_id;
  7091. + unsigned short device_id;
  7092. + unsigned char bus_type;
  7093. +#define PCI_BUS_TYPE 1
  7094. +#define ISA_BUS_TYPE 2
  7095. +};
  7096. +
  7097. +/* Dont use sizeof, that will include the padding */
  7098. +#define DEV_ID_SIZE 8
  7099. +
  7100. +
  7101. +struct pci_probe_state
  7102. +{
  7103. +#ifdef CONFIG_PCI
  7104. + struct pci_device dev;
  7105. + int advance;
  7106. +#else
  7107. + int dummy;
  7108. +#endif
  7109. +};
  7110. +struct isa_probe_state
  7111. +{
  7112. +#ifdef CONFIG_ISA
  7113. + const struct isa_driver *driver;
  7114. + int advance;
  7115. +#else
  7116. + int dummy;
  7117. +#endif
  7118. +};
  7119. +
  7120. +union probe_state
  7121. +{
  7122. + struct pci_probe_state pci;
  7123. + struct isa_probe_state isa;
  7124. +};
  7125. +
  7126. +struct dev
  7127. +{
  7128. + void (*disable)P((struct dev *));
  7129. + struct dev_id devid; /* device ID string (sent to DHCP server) */
  7130. + int index; /* Index of next device on this controller to probe */
  7131. + int type; /* Type of device I am probing for */
  7132. + int how_probe; /* First, next or awake */
  7133. + int to_probe; /* Flavor of device I am probing */
  7134. + int failsafe; /* Failsafe probe requested */
  7135. + int type_index; /* Index of this device (within type) */
  7136. +#define PROBE_NONE 0
  7137. +#define PROBE_PCI 1
  7138. +#define PROBE_ISA 2
  7139. + union probe_state state;
  7140. +};
  7141. +
  7142. +
  7143. +#define NIC_DRIVER 0
  7144. +#define DISK_DRIVER 1
  7145. +#define FLOPPY_DRIVER 2
  7146. +
  7147. +#define BRIDGE_DRIVER 1000
  7148. +
  7149. +#define PROBE_FIRST (-1)
  7150. +#define PROBE_NEXT 0
  7151. +#define PROBE_AWAKE 1 /* After calling disable bring up the same device */
  7152. +
  7153. +/* The probe result codes are selected
  7154. + * to allow them to be fed back into the probe
  7155. + * routine and get a successful probe.
  7156. + */
  7157. +#define PROBE_FAILED PROBE_FIRST
  7158. +#define PROBE_WORKED PROBE_NEXT
  7159. +
  7160. +extern int probe(struct dev *dev);
  7161. +extern void disable(struct dev *dev);
  7162. +
  7163. +#endif /* _DEV_H */
  7164. Index: b/netboot/e1000.c
  7165. ===================================================================
  7166. --- /dev/null
  7167. +++ b/netboot/e1000.c
  7168. @@ -0,0 +1,3682 @@
  7169. +/**************************************************************************
  7170. +Etherboot - BOOTP/TFTP Bootstrap Program
  7171. +Inter Pro 1000 for Etherboot
  7172. +Drivers are port from Intel's Linux driver e1000-4.3.15
  7173. +
  7174. +***************************************************************************/
  7175. +/*******************************************************************************
  7176. +
  7177. +
  7178. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
  7179. +
  7180. + This program is free software; you can redistribute it and/or modify it
  7181. + under the terms of the GNU General Public License as published by the Free
  7182. + Software Foundation; either version 2 of the License, or (at your option)
  7183. + any later version.
  7184. +
  7185. + This program is distributed in the hope that it will be useful, but WITHOUT
  7186. + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  7187. + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  7188. + more details.
  7189. +
  7190. + You should have received a copy of the GNU General Public License along with
  7191. + this program; if not, write to the Free Software Foundation, Inc., 59
  7192. + Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  7193. +
  7194. + The full GNU General Public License is included in this distribution in the
  7195. + file called LICENSE.
  7196. +
  7197. + Contact Information:
  7198. + Linux NICS <linux.nics@intel.com>
  7199. + Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  7200. +
  7201. +*******************************************************************************/
  7202. +/*
  7203. + * Copyright (C) Archway Digital Solutions.
  7204. + *
  7205. + * written by Chrsitopher Li <cli at arcyway dot com> or <chrisl at gnuchina dot org>
  7206. + * 2/9/2002
  7207. + *
  7208. + * Copyright (C) Linux Networx.
  7209. + * Massive upgrade to work with the new intel gigabit NICs.
  7210. + * <ebiederman at lnxi dot com>
  7211. + *
  7212. + * Support for 82541ei & 82547ei chips from Intel's Linux driver 5.1.13 added by
  7213. + * Georg Baum <gbaum@users.sf.net>, sponsored by PetaMem GmbH and linkLINE Communications, Inc.
  7214. + *
  7215. + * 01/2004: Updated to Linux driver 5.2.22 by Georg Baum <gbaum@users.sf.net>
  7216. + */
  7217. +
  7218. +/* to get some global routines like printf */
  7219. +#include "etherboot.h"
  7220. +/* to get the interface to the body of the program */
  7221. +#include "nic.h"
  7222. +/* to get the PCI support functions, if this is a PCI NIC */
  7223. +#include "pci.h"
  7224. +#include "timer.h"
  7225. +
  7226. +typedef unsigned char *dma_addr_t;
  7227. +
  7228. +typedef enum {
  7229. + FALSE = 0,
  7230. + TRUE = 1
  7231. +} boolean_t;
  7232. +
  7233. +#define DEBUG 0
  7234. +
  7235. +
  7236. +/* Some pieces of code are disabled with #if 0 ... #endif.
  7237. + * They are not deleted to show where the etherboot driver differs
  7238. + * from the linux driver below the function level.
  7239. + * Some member variables of the hw struct have been eliminated
  7240. + * and the corresponding inplace checks inserted instead.
  7241. + * Pieces such as LED handling that we definitely don't need are deleted.
  7242. + *
  7243. + * The following defines should not be needed normally,
  7244. + * but may be helpful for debugging purposes. */
  7245. +
  7246. +/* Define this if you want to program the transmission control register
  7247. + * the way the Linux driver does it. */
  7248. +#undef LINUX_DRIVER_TCTL
  7249. +
  7250. +/* Define this to behave more like the Linux driver. */
  7251. +#undef LINUX_DRIVER
  7252. +
  7253. +#include "e1000_hw.h"
  7254. +
  7255. +/* NIC specific static variables go here */
  7256. +static struct e1000_hw hw;
  7257. +static char tx_pool[128 + 16];
  7258. +static char rx_pool[128 + 16];
  7259. +static char packet[2096];
  7260. +
  7261. +static struct e1000_tx_desc *tx_base;
  7262. +static struct e1000_rx_desc *rx_base;
  7263. +
  7264. +static int tx_tail;
  7265. +static int rx_tail, rx_last;
  7266. +
  7267. +/* Function forward declarations */
  7268. +static int e1000_setup_link(struct e1000_hw *hw);
  7269. +static int e1000_setup_fiber_serdes_link(struct e1000_hw *hw);
  7270. +static int e1000_setup_copper_link(struct e1000_hw *hw);
  7271. +static int e1000_phy_setup_autoneg(struct e1000_hw *hw);
  7272. +static void e1000_config_collision_dist(struct e1000_hw *hw);
  7273. +static int e1000_config_mac_to_phy(struct e1000_hw *hw);
  7274. +static int e1000_config_fc_after_link_up(struct e1000_hw *hw);
  7275. +static int e1000_check_for_link(struct e1000_hw *hw);
  7276. +static int e1000_wait_autoneg(struct e1000_hw *hw);
  7277. +static void e1000_get_speed_and_duplex(struct e1000_hw *hw, uint16_t *speed, uint16_t *duplex);
  7278. +static int e1000_read_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *phy_data);
  7279. +static int e1000_read_phy_reg_ex(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *phy_data);
  7280. +static int e1000_write_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t phy_data);
  7281. +static int e1000_write_phy_reg_ex(struct e1000_hw *hw, uint32_t reg_addr, uint16_t phy_data);
  7282. +static void e1000_phy_hw_reset(struct e1000_hw *hw);
  7283. +static int e1000_phy_reset(struct e1000_hw *hw);
  7284. +static int e1000_detect_gig_phy(struct e1000_hw *hw);
  7285. +
  7286. +/* Printing macros... */
  7287. +
  7288. +#define E1000_ERR(args...) printf("e1000: " args)
  7289. +
  7290. +#if DEBUG >= 3
  7291. +#define E1000_DBG(args...) printf("e1000: " args)
  7292. +#else
  7293. +#define E1000_DBG(args...)
  7294. +#endif
  7295. +
  7296. +#define MSGOUT(S, A, B) printk(S "\n", A, B)
  7297. +#if DEBUG >= 2
  7298. +#define DEBUGFUNC(F) DEBUGOUT(F "\n");
  7299. +#else
  7300. +#define DEBUGFUNC(F)
  7301. +#endif
  7302. +#if DEBUG >= 1
  7303. +#define DEBUGOUT(S) printf(S)
  7304. +#define DEBUGOUT1(S,A) printf(S,A)
  7305. +#define DEBUGOUT2(S,A,B) printf(S,A,B)
  7306. +#define DEBUGOUT3(S,A,B,C) printf(S,A,B,C)
  7307. +#define DEBUGOUT7(S,A,B,C,D,E,F,G) printf(S,A,B,C,D,E,F,G)
  7308. +#else
  7309. +#define DEBUGOUT(S)
  7310. +#define DEBUGOUT1(S,A)
  7311. +#define DEBUGOUT2(S,A,B)
  7312. +#define DEBUGOUT3(S,A,B,C)
  7313. +#define DEBUGOUT7(S,A,B,C,D,E,F,G)
  7314. +#endif
  7315. +
  7316. +#define E1000_WRITE_REG(a, reg, value) ( \
  7317. + ((a)->mac_type >= e1000_82543) ? \
  7318. + (writel((value), ((a)->hw_addr + E1000_##reg))) : \
  7319. + (writel((value), ((a)->hw_addr + E1000_82542_##reg))))
  7320. +
  7321. +#define E1000_READ_REG(a, reg) ( \
  7322. + ((a)->mac_type >= e1000_82543) ? \
  7323. + readl((a)->hw_addr + E1000_##reg) : \
  7324. + readl((a)->hw_addr + E1000_82542_##reg))
  7325. +
  7326. +#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
  7327. + ((a)->mac_type >= e1000_82543) ? \
  7328. + writel((value), ((a)->hw_addr + E1000_##reg + ((offset) << 2))) : \
  7329. + writel((value), ((a)->hw_addr + E1000_82542_##reg + ((offset) << 2))))
  7330. +
  7331. +#define E1000_READ_REG_ARRAY(a, reg, offset) ( \
  7332. + ((a)->mac_type >= e1000_82543) ? \
  7333. + readl((a)->hw_addr + E1000_##reg + ((offset) << 2)) : \
  7334. + readl((a)->hw_addr + E1000_82542_##reg + ((offset) << 2)))
  7335. +
  7336. +#define E1000_WRITE_FLUSH(a) {uint32_t x; x = E1000_READ_REG(a, STATUS);}
  7337. +
  7338. +uint32_t
  7339. +e1000_io_read(struct e1000_hw *hw __unused, uint32_t port)
  7340. +{
  7341. + return inl(port);
  7342. +}
  7343. +
  7344. +void
  7345. +e1000_io_write(struct e1000_hw *hw __unused, uint32_t port, uint32_t value)
  7346. +{
  7347. + outl(value, port);
  7348. +}
  7349. +
  7350. +static inline void e1000_pci_set_mwi(struct e1000_hw *hw)
  7351. +{
  7352. + pci_write_config_word(hw->pdev, PCI_COMMAND, hw->pci_cmd_word);
  7353. +}
  7354. +
  7355. +static inline void e1000_pci_clear_mwi(struct e1000_hw *hw)
  7356. +{
  7357. + pci_write_config_word(hw->pdev, PCI_COMMAND,
  7358. + hw->pci_cmd_word & ~PCI_COMMAND_INVALIDATE);
  7359. +}
  7360. +
  7361. +/******************************************************************************
  7362. + * Raises the EEPROM's clock input.
  7363. + *
  7364. + * hw - Struct containing variables accessed by shared code
  7365. + * eecd - EECD's current value
  7366. + *****************************************************************************/
  7367. +static void
  7368. +e1000_raise_ee_clk(struct e1000_hw *hw,
  7369. + uint32_t *eecd)
  7370. +{
  7371. + /* Raise the clock input to the EEPROM (by setting the SK bit), and then
  7372. + * wait <delay> microseconds.
  7373. + */
  7374. + *eecd = *eecd | E1000_EECD_SK;
  7375. + E1000_WRITE_REG(hw, EECD, *eecd);
  7376. + E1000_WRITE_FLUSH(hw);
  7377. + udelay(hw->eeprom.delay_usec);
  7378. +}
  7379. +
  7380. +/******************************************************************************
  7381. + * Lowers the EEPROM's clock input.
  7382. + *
  7383. + * hw - Struct containing variables accessed by shared code
  7384. + * eecd - EECD's current value
  7385. + *****************************************************************************/
  7386. +static void
  7387. +e1000_lower_ee_clk(struct e1000_hw *hw,
  7388. + uint32_t *eecd)
  7389. +{
  7390. + /* Lower the clock input to the EEPROM (by clearing the SK bit), and then
  7391. + * wait 50 microseconds.
  7392. + */
  7393. + *eecd = *eecd & ~E1000_EECD_SK;
  7394. + E1000_WRITE_REG(hw, EECD, *eecd);
  7395. + E1000_WRITE_FLUSH(hw);
  7396. + udelay(hw->eeprom.delay_usec);
  7397. +}
  7398. +
  7399. +/******************************************************************************
  7400. + * Shift data bits out to the EEPROM.
  7401. + *
  7402. + * hw - Struct containing variables accessed by shared code
  7403. + * data - data to send to the EEPROM
  7404. + * count - number of bits to shift out
  7405. + *****************************************************************************/
  7406. +static void
  7407. +e1000_shift_out_ee_bits(struct e1000_hw *hw,
  7408. + uint16_t data,
  7409. + uint16_t count)
  7410. +{
  7411. + struct e1000_eeprom_info *eeprom = &hw->eeprom;
  7412. + uint32_t eecd;
  7413. + uint32_t mask;
  7414. +
  7415. + /* We need to shift "count" bits out to the EEPROM. So, value in the
  7416. + * "data" parameter will be shifted out to the EEPROM one bit at a time.
  7417. + * In order to do this, "data" must be broken down into bits.
  7418. + */
  7419. + mask = 0x01 << (count - 1);
  7420. + eecd = E1000_READ_REG(hw, EECD);
  7421. + if (eeprom->type == e1000_eeprom_microwire) {
  7422. + eecd &= ~E1000_EECD_DO;
  7423. + } else if (eeprom->type == e1000_eeprom_spi) {
  7424. + eecd |= E1000_EECD_DO;
  7425. + }
  7426. + do {
  7427. + /* A "1" is shifted out to the EEPROM by setting bit "DI" to a "1",
  7428. + * and then raising and then lowering the clock (the SK bit controls
  7429. + * the clock input to the EEPROM). A "0" is shifted out to the EEPROM
  7430. + * by setting "DI" to "0" and then raising and then lowering the clock.
  7431. + */
  7432. + eecd &= ~E1000_EECD_DI;
  7433. +
  7434. + if(data & mask)
  7435. + eecd |= E1000_EECD_DI;
  7436. +
  7437. + E1000_WRITE_REG(hw, EECD, eecd);
  7438. + E1000_WRITE_FLUSH(hw);
  7439. +
  7440. + udelay(eeprom->delay_usec);
  7441. +
  7442. + e1000_raise_ee_clk(hw, &eecd);
  7443. + e1000_lower_ee_clk(hw, &eecd);
  7444. +
  7445. + mask = mask >> 1;
  7446. +
  7447. + } while(mask);
  7448. +
  7449. + /* We leave the "DI" bit set to "0" when we leave this routine. */
  7450. + eecd &= ~E1000_EECD_DI;
  7451. + E1000_WRITE_REG(hw, EECD, eecd);
  7452. +}
  7453. +
  7454. +/******************************************************************************
  7455. + * Shift data bits in from the EEPROM
  7456. + *
  7457. + * hw - Struct containing variables accessed by shared code
  7458. + *****************************************************************************/
  7459. +static uint16_t
  7460. +e1000_shift_in_ee_bits(struct e1000_hw *hw,
  7461. + uint16_t count)
  7462. +{
  7463. + uint32_t eecd;
  7464. + uint32_t i;
  7465. + uint16_t data;
  7466. +
  7467. + /* In order to read a register from the EEPROM, we need to shift 'count'
  7468. + * bits in from the EEPROM. Bits are "shifted in" by raising the clock
  7469. + * input to the EEPROM (setting the SK bit), and then reading the value of
  7470. + * the "DO" bit. During this "shifting in" process the "DI" bit should
  7471. + * always be clear.
  7472. + */
  7473. +
  7474. + eecd = E1000_READ_REG(hw, EECD);
  7475. +
  7476. + eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
  7477. + data = 0;
  7478. +
  7479. + for(i = 0; i < count; i++) {
  7480. + data = data << 1;
  7481. + e1000_raise_ee_clk(hw, &eecd);
  7482. +
  7483. + eecd = E1000_READ_REG(hw, EECD);
  7484. +
  7485. + eecd &= ~(E1000_EECD_DI);
  7486. + if(eecd & E1000_EECD_DO)
  7487. + data |= 1;
  7488. +
  7489. + e1000_lower_ee_clk(hw, &eecd);
  7490. + }
  7491. +
  7492. + return data;
  7493. +}
  7494. +
  7495. +/******************************************************************************
  7496. + * Prepares EEPROM for access
  7497. + *
  7498. + * hw - Struct containing variables accessed by shared code
  7499. + *
  7500. + * Lowers EEPROM clock. Clears input pin. Sets the chip select pin. This
  7501. + * function should be called before issuing a command to the EEPROM.
  7502. + *****************************************************************************/
  7503. +static int32_t
  7504. +e1000_acquire_eeprom(struct e1000_hw *hw)
  7505. +{
  7506. + struct e1000_eeprom_info *eeprom = &hw->eeprom;
  7507. + uint32_t eecd, i=0;
  7508. +
  7509. + eecd = E1000_READ_REG(hw, EECD);
  7510. +
  7511. + /* Request EEPROM Access */
  7512. + if(hw->mac_type > e1000_82544) {
  7513. + eecd |= E1000_EECD_REQ;
  7514. + E1000_WRITE_REG(hw, EECD, eecd);
  7515. + eecd = E1000_READ_REG(hw, EECD);
  7516. + while((!(eecd & E1000_EECD_GNT)) &&
  7517. + (i < E1000_EEPROM_GRANT_ATTEMPTS)) {
  7518. + i++;
  7519. + udelay(5);
  7520. + eecd = E1000_READ_REG(hw, EECD);
  7521. + }
  7522. + if(!(eecd & E1000_EECD_GNT)) {
  7523. + eecd &= ~E1000_EECD_REQ;
  7524. + E1000_WRITE_REG(hw, EECD, eecd);
  7525. + DEBUGOUT("Could not acquire EEPROM grant\n");
  7526. + return -E1000_ERR_EEPROM;
  7527. + }
  7528. + }
  7529. +
  7530. + /* Setup EEPROM for Read/Write */
  7531. +
  7532. + if (eeprom->type == e1000_eeprom_microwire) {
  7533. + /* Clear SK and DI */
  7534. + eecd &= ~(E1000_EECD_DI | E1000_EECD_SK);
  7535. + E1000_WRITE_REG(hw, EECD, eecd);
  7536. +
  7537. + /* Set CS */
  7538. + eecd |= E1000_EECD_CS;
  7539. + E1000_WRITE_REG(hw, EECD, eecd);
  7540. + } else if (eeprom->type == e1000_eeprom_spi) {
  7541. + /* Clear SK and CS */
  7542. + eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
  7543. + E1000_WRITE_REG(hw, EECD, eecd);
  7544. + udelay(1);
  7545. + }
  7546. +
  7547. + return E1000_SUCCESS;
  7548. +}
  7549. +
  7550. +/******************************************************************************
  7551. + * Returns EEPROM to a "standby" state
  7552. + *
  7553. + * hw - Struct containing variables accessed by shared code
  7554. + *****************************************************************************/
  7555. +static void
  7556. +e1000_standby_eeprom(struct e1000_hw *hw)
  7557. +{
  7558. + struct e1000_eeprom_info *eeprom = &hw->eeprom;
  7559. + uint32_t eecd;
  7560. +
  7561. + eecd = E1000_READ_REG(hw, EECD);
  7562. +
  7563. + if(eeprom->type == e1000_eeprom_microwire) {
  7564. +
  7565. + /* Deselect EEPROM */
  7566. + eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
  7567. + E1000_WRITE_REG(hw, EECD, eecd);
  7568. + E1000_WRITE_FLUSH(hw);
  7569. + udelay(eeprom->delay_usec);
  7570. +
  7571. + /* Clock high */
  7572. + eecd |= E1000_EECD_SK;
  7573. + E1000_WRITE_REG(hw, EECD, eecd);
  7574. + E1000_WRITE_FLUSH(hw);
  7575. + udelay(eeprom->delay_usec);
  7576. +
  7577. + /* Select EEPROM */
  7578. + eecd |= E1000_EECD_CS;
  7579. + E1000_WRITE_REG(hw, EECD, eecd);
  7580. + E1000_WRITE_FLUSH(hw);
  7581. + udelay(eeprom->delay_usec);
  7582. +
  7583. + /* Clock low */
  7584. + eecd &= ~E1000_EECD_SK;
  7585. + E1000_WRITE_REG(hw, EECD, eecd);
  7586. + E1000_WRITE_FLUSH(hw);
  7587. + udelay(eeprom->delay_usec);
  7588. + } else if(eeprom->type == e1000_eeprom_spi) {
  7589. + /* Toggle CS to flush commands */
  7590. + eecd |= E1000_EECD_CS;
  7591. + E1000_WRITE_REG(hw, EECD, eecd);
  7592. + E1000_WRITE_FLUSH(hw);
  7593. + udelay(eeprom->delay_usec);
  7594. + eecd &= ~E1000_EECD_CS;
  7595. + E1000_WRITE_REG(hw, EECD, eecd);
  7596. + E1000_WRITE_FLUSH(hw);
  7597. + udelay(eeprom->delay_usec);
  7598. + }
  7599. +}
  7600. +
  7601. +/******************************************************************************
  7602. + * Terminates a command by inverting the EEPROM's chip select pin
  7603. + *
  7604. + * hw - Struct containing variables accessed by shared code
  7605. + *****************************************************************************/
  7606. +static void
  7607. +e1000_release_eeprom(struct e1000_hw *hw)
  7608. +{
  7609. + uint32_t eecd;
  7610. +
  7611. + eecd = E1000_READ_REG(hw, EECD);
  7612. +
  7613. + if (hw->eeprom.type == e1000_eeprom_spi) {
  7614. + eecd |= E1000_EECD_CS; /* Pull CS high */
  7615. + eecd &= ~E1000_EECD_SK; /* Lower SCK */
  7616. +
  7617. + E1000_WRITE_REG(hw, EECD, eecd);
  7618. +
  7619. + udelay(hw->eeprom.delay_usec);
  7620. + } else if(hw->eeprom.type == e1000_eeprom_microwire) {
  7621. + /* cleanup eeprom */
  7622. +
  7623. + /* CS on Microwire is active-high */
  7624. + eecd &= ~(E1000_EECD_CS | E1000_EECD_DI);
  7625. +
  7626. + E1000_WRITE_REG(hw, EECD, eecd);
  7627. +
  7628. + /* Rising edge of clock */
  7629. + eecd |= E1000_EECD_SK;
  7630. + E1000_WRITE_REG(hw, EECD, eecd);
  7631. + E1000_WRITE_FLUSH(hw);
  7632. + udelay(hw->eeprom.delay_usec);
  7633. +
  7634. + /* Falling edge of clock */
  7635. + eecd &= ~E1000_EECD_SK;
  7636. + E1000_WRITE_REG(hw, EECD, eecd);
  7637. + E1000_WRITE_FLUSH(hw);
  7638. + udelay(hw->eeprom.delay_usec);
  7639. + }
  7640. +
  7641. + /* Stop requesting EEPROM access */
  7642. + if(hw->mac_type > e1000_82544) {
  7643. + eecd &= ~E1000_EECD_REQ;
  7644. + E1000_WRITE_REG(hw, EECD, eecd);
  7645. + }
  7646. +}
  7647. +
  7648. +/******************************************************************************
  7649. + * Reads a 16 bit word from the EEPROM.
  7650. + *
  7651. + * hw - Struct containing variables accessed by shared code
  7652. + *****************************************************************************/
  7653. +static int32_t
  7654. +e1000_spi_eeprom_ready(struct e1000_hw *hw)
  7655. +{
  7656. + uint16_t retry_count = 0;
  7657. + uint8_t spi_stat_reg;
  7658. +
  7659. + /* Read "Status Register" repeatedly until the LSB is cleared. The
  7660. + * EEPROM will signal that the command has been completed by clearing
  7661. + * bit 0 of the internal status register. If it's not cleared within
  7662. + * 5 milliseconds, then error out.
  7663. + */
  7664. + retry_count = 0;
  7665. + do {
  7666. + e1000_shift_out_ee_bits(hw, EEPROM_RDSR_OPCODE_SPI,
  7667. + hw->eeprom.opcode_bits);
  7668. + spi_stat_reg = (uint8_t)e1000_shift_in_ee_bits(hw, 8);
  7669. + if (!(spi_stat_reg & EEPROM_STATUS_RDY_SPI))
  7670. + break;
  7671. +
  7672. + udelay(5);
  7673. + retry_count += 5;
  7674. +
  7675. + } while(retry_count < EEPROM_MAX_RETRY_SPI);
  7676. +
  7677. + /* ATMEL SPI write time could vary from 0-20mSec on 3.3V devices (and
  7678. + * only 0-5mSec on 5V devices)
  7679. + */
  7680. + if(retry_count >= EEPROM_MAX_RETRY_SPI) {
  7681. + DEBUGOUT("SPI EEPROM Status error\n");
  7682. + return -E1000_ERR_EEPROM;
  7683. + }
  7684. +
  7685. + return E1000_SUCCESS;
  7686. +}
  7687. +
  7688. +/******************************************************************************
  7689. + * Reads a 16 bit word from the EEPROM.
  7690. + *
  7691. + * hw - Struct containing variables accessed by shared code
  7692. + * offset - offset of word in the EEPROM to read
  7693. + * data - word read from the EEPROM
  7694. + * words - number of words to read
  7695. + *****************************************************************************/
  7696. +static int
  7697. +e1000_read_eeprom(struct e1000_hw *hw,
  7698. + uint16_t offset,
  7699. + uint16_t words,
  7700. + uint16_t *data)
  7701. +{
  7702. + struct e1000_eeprom_info *eeprom = &hw->eeprom;
  7703. + uint32_t i = 0;
  7704. +
  7705. + DEBUGFUNC("e1000_read_eeprom");
  7706. +
  7707. + /* A check for invalid values: offset too large, too many words, and not
  7708. + * enough words.
  7709. + */
  7710. + if((offset > eeprom->word_size) || (words > eeprom->word_size - offset) ||
  7711. + (words == 0)) {
  7712. + DEBUGOUT("\"words\" parameter out of bounds\n");
  7713. + return -E1000_ERR_EEPROM;
  7714. + }
  7715. +
  7716. + /* Prepare the EEPROM for reading */
  7717. + if(e1000_acquire_eeprom(hw) != E1000_SUCCESS)
  7718. + return -E1000_ERR_EEPROM;
  7719. +
  7720. + if(eeprom->type == e1000_eeprom_spi) {
  7721. + uint16_t word_in;
  7722. + uint8_t read_opcode = EEPROM_READ_OPCODE_SPI;
  7723. +
  7724. + if(e1000_spi_eeprom_ready(hw)) {
  7725. + e1000_release_eeprom(hw);
  7726. + return -E1000_ERR_EEPROM;
  7727. + }
  7728. +
  7729. + e1000_standby_eeprom(hw);
  7730. +
  7731. + /* Some SPI eeproms use the 8th address bit embedded in the opcode */
  7732. + if((eeprom->address_bits == 8) && (offset >= 128))
  7733. + read_opcode |= EEPROM_A8_OPCODE_SPI;
  7734. +
  7735. + /* Send the READ command (opcode + addr) */
  7736. + e1000_shift_out_ee_bits(hw, read_opcode, eeprom->opcode_bits);
  7737. + e1000_shift_out_ee_bits(hw, (uint16_t)(offset*2), eeprom->address_bits);
  7738. +
  7739. + /* Read the data. The address of the eeprom internally increments with
  7740. + * each byte (spi) being read, saving on the overhead of eeprom setup
  7741. + * and tear-down. The address counter will roll over if reading beyond
  7742. + * the size of the eeprom, thus allowing the entire memory to be read
  7743. + * starting from any offset. */
  7744. + for (i = 0; i < words; i++) {
  7745. + word_in = e1000_shift_in_ee_bits(hw, 16);
  7746. + data[i] = (word_in >> 8) | (word_in << 8);
  7747. + }
  7748. + } else if(eeprom->type == e1000_eeprom_microwire) {
  7749. + for (i = 0; i < words; i++) {
  7750. + /* Send the READ command (opcode + addr) */
  7751. + e1000_shift_out_ee_bits(hw, EEPROM_READ_OPCODE_MICROWIRE,
  7752. + eeprom->opcode_bits);
  7753. + e1000_shift_out_ee_bits(hw, (uint16_t)(offset + i),
  7754. + eeprom->address_bits);
  7755. +
  7756. + /* Read the data. For microwire, each word requires the overhead
  7757. + * of eeprom setup and tear-down. */
  7758. + data[i] = e1000_shift_in_ee_bits(hw, 16);
  7759. + e1000_standby_eeprom(hw);
  7760. + }
  7761. + }
  7762. +
  7763. + /* End this read operation */
  7764. + e1000_release_eeprom(hw);
  7765. +
  7766. + return E1000_SUCCESS;
  7767. +}
  7768. +
  7769. +/******************************************************************************
  7770. + * Verifies that the EEPROM has a valid checksum
  7771. + *
  7772. + * hw - Struct containing variables accessed by shared code
  7773. + *
  7774. + * Reads the first 64 16 bit words of the EEPROM and sums the values read.
  7775. + * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is
  7776. + * valid.
  7777. + *****************************************************************************/
  7778. +static int
  7779. +e1000_validate_eeprom_checksum(struct e1000_hw *hw)
  7780. +{
  7781. + uint16_t checksum = 0;
  7782. + uint16_t i, eeprom_data;
  7783. +
  7784. + DEBUGFUNC("e1000_validate_eeprom_checksum");
  7785. +
  7786. + for(i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
  7787. + if(e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) {
  7788. + DEBUGOUT("EEPROM Read Error\n");
  7789. + return -E1000_ERR_EEPROM;
  7790. + }
  7791. + checksum += eeprom_data;
  7792. + }
  7793. +
  7794. + if(checksum == (uint16_t) EEPROM_SUM)
  7795. + return E1000_SUCCESS;
  7796. + else {
  7797. + DEBUGOUT("EEPROM Checksum Invalid\n");
  7798. + return -E1000_ERR_EEPROM;
  7799. + }
  7800. +}
  7801. +
  7802. +/******************************************************************************
  7803. + * Reads the adapter's MAC address from the EEPROM and inverts the LSB for the
  7804. + * second function of dual function devices
  7805. + *
  7806. + * hw - Struct containing variables accessed by shared code
  7807. + *****************************************************************************/
  7808. +static int
  7809. +e1000_read_mac_addr(struct e1000_hw *hw)
  7810. +{
  7811. + uint16_t offset;
  7812. + uint16_t eeprom_data;
  7813. + int i;
  7814. +
  7815. + DEBUGFUNC("e1000_read_mac_addr");
  7816. +
  7817. + for(i = 0; i < NODE_ADDRESS_SIZE; i += 2) {
  7818. + offset = i >> 1;
  7819. + if(e1000_read_eeprom(hw, offset, 1, &eeprom_data) < 0) {
  7820. + DEBUGOUT("EEPROM Read Error\n");
  7821. + return -E1000_ERR_EEPROM;
  7822. + }
  7823. + hw->mac_addr[i] = eeprom_data & 0xff;
  7824. + hw->mac_addr[i+1] = (eeprom_data >> 8) & 0xff;
  7825. + }
  7826. + if(((hw->mac_type == e1000_82546) || (hw->mac_type == e1000_82546_rev_3)) &&
  7827. + (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1))
  7828. + /* Invert the last bit if this is the second device */
  7829. + hw->mac_addr[5] ^= 1;
  7830. + return E1000_SUCCESS;
  7831. +}
  7832. +
  7833. +/******************************************************************************
  7834. + * Initializes receive address filters.
  7835. + *
  7836. + * hw - Struct containing variables accessed by shared code
  7837. + *
  7838. + * Places the MAC address in receive address register 0 and clears the rest
  7839. + * of the receive addresss registers. Clears the multicast table. Assumes
  7840. + * the receiver is in reset when the routine is called.
  7841. + *****************************************************************************/
  7842. +static void
  7843. +e1000_init_rx_addrs(struct e1000_hw *hw)
  7844. +{
  7845. + uint32_t i;
  7846. + uint32_t addr_low;
  7847. + uint32_t addr_high;
  7848. +
  7849. + DEBUGFUNC("e1000_init_rx_addrs");
  7850. +
  7851. + /* Setup the receive address. */
  7852. + DEBUGOUT("Programming MAC Address into RAR[0]\n");
  7853. + addr_low = (hw->mac_addr[0] |
  7854. + (hw->mac_addr[1] << 8) |
  7855. + (hw->mac_addr[2] << 16) | (hw->mac_addr[3] << 24));
  7856. +
  7857. + addr_high = (hw->mac_addr[4] |
  7858. + (hw->mac_addr[5] << 8) | E1000_RAH_AV);
  7859. +
  7860. + E1000_WRITE_REG_ARRAY(hw, RA, 0, addr_low);
  7861. + E1000_WRITE_REG_ARRAY(hw, RA, 1, addr_high);
  7862. +
  7863. + /* Zero out the other 15 receive addresses. */
  7864. + DEBUGOUT("Clearing RAR[1-15]\n");
  7865. + for(i = 1; i < E1000_RAR_ENTRIES; i++) {
  7866. + E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
  7867. + E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
  7868. + }
  7869. +}
  7870. +
  7871. +/******************************************************************************
  7872. + * Clears the VLAN filer table
  7873. + *
  7874. + * hw - Struct containing variables accessed by shared code
  7875. + *****************************************************************************/
  7876. +static void
  7877. +e1000_clear_vfta(struct e1000_hw *hw)
  7878. +{
  7879. + uint32_t offset;
  7880. +
  7881. + for(offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++)
  7882. + E1000_WRITE_REG_ARRAY(hw, VFTA, offset, 0);
  7883. +}
  7884. +
  7885. +/******************************************************************************
  7886. +* Writes a value to one of the devices registers using port I/O (as opposed to
  7887. +* memory mapped I/O). Only 82544 and newer devices support port I/O. *
  7888. +* hw - Struct containing variables accessed by shared code
  7889. +* offset - offset to write to * value - value to write
  7890. +*****************************************************************************/
  7891. +void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset, uint32_t value){
  7892. + uint32_t io_addr = hw->io_base;
  7893. + uint32_t io_data = hw->io_base + 4;
  7894. + e1000_io_write(hw, io_addr, offset);
  7895. + e1000_io_write(hw, io_data, value);
  7896. +}
  7897. +
  7898. +/******************************************************************************
  7899. + * Set the phy type member in the hw struct.
  7900. + *
  7901. + * hw - Struct containing variables accessed by shared code
  7902. + *****************************************************************************/
  7903. +static int32_t
  7904. +e1000_set_phy_type(struct e1000_hw *hw)
  7905. +{
  7906. + DEBUGFUNC("e1000_set_phy_type");
  7907. +
  7908. + switch(hw->phy_id) {
  7909. + case M88E1000_E_PHY_ID:
  7910. + case M88E1000_I_PHY_ID:
  7911. + case M88E1011_I_PHY_ID:
  7912. + hw->phy_type = e1000_phy_m88;
  7913. + break;
  7914. + case IGP01E1000_I_PHY_ID:
  7915. + hw->phy_type = e1000_phy_igp;
  7916. + break;
  7917. + default:
  7918. + /* Should never have loaded on this device */
  7919. + hw->phy_type = e1000_phy_undefined;
  7920. + return -E1000_ERR_PHY_TYPE;
  7921. + }
  7922. +
  7923. + return E1000_SUCCESS;
  7924. +}
  7925. +
  7926. +/******************************************************************************
  7927. + * IGP phy init script - initializes the GbE PHY
  7928. + *
  7929. + * hw - Struct containing variables accessed by shared code
  7930. + *****************************************************************************/
  7931. +static void
  7932. +e1000_phy_init_script(struct e1000_hw *hw)
  7933. +{
  7934. + DEBUGFUNC("e1000_phy_init_script");
  7935. +
  7936. +#if 0
  7937. + /* See e1000_sw_init() of the Linux driver */
  7938. + if(hw->phy_init_script) {
  7939. +#else
  7940. + if((hw->mac_type == e1000_82541) ||
  7941. + (hw->mac_type == e1000_82547) ||
  7942. + (hw->mac_type == e1000_82541_rev_2) ||
  7943. + (hw->mac_type == e1000_82547_rev_2)) {
  7944. +#endif
  7945. + mdelay(20);
  7946. +
  7947. + e1000_write_phy_reg(hw,0x0000,0x0140);
  7948. +
  7949. + mdelay(5);
  7950. +
  7951. + if(hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547) {
  7952. + e1000_write_phy_reg(hw, 0x1F95, 0x0001);
  7953. +
  7954. + e1000_write_phy_reg(hw, 0x1F71, 0xBD21);
  7955. +
  7956. + e1000_write_phy_reg(hw, 0x1F79, 0x0018);
  7957. +
  7958. + e1000_write_phy_reg(hw, 0x1F30, 0x1600);
  7959. +
  7960. + e1000_write_phy_reg(hw, 0x1F31, 0x0014);
  7961. +
  7962. + e1000_write_phy_reg(hw, 0x1F32, 0x161C);
  7963. +
  7964. + e1000_write_phy_reg(hw, 0x1F94, 0x0003);
  7965. +
  7966. + e1000_write_phy_reg(hw, 0x1F96, 0x003F);
  7967. +
  7968. + e1000_write_phy_reg(hw, 0x2010, 0x0008);
  7969. + } else {
  7970. + e1000_write_phy_reg(hw, 0x1F73, 0x0099);
  7971. + }
  7972. +
  7973. + e1000_write_phy_reg(hw, 0x0000, 0x3300);
  7974. +
  7975. +
  7976. + if(hw->mac_type == e1000_82547) {
  7977. + uint16_t fused, fine, coarse;
  7978. +
  7979. + /* Move to analog registers page */
  7980. + e1000_read_phy_reg(hw, IGP01E1000_ANALOG_SPARE_FUSE_STATUS, &fused);
  7981. +
  7982. + if(!(fused & IGP01E1000_ANALOG_SPARE_FUSE_ENABLED)) {
  7983. + e1000_read_phy_reg(hw, IGP01E1000_ANALOG_FUSE_STATUS, &fused);
  7984. +
  7985. + fine = fused & IGP01E1000_ANALOG_FUSE_FINE_MASK;
  7986. + coarse = fused & IGP01E1000_ANALOG_FUSE_COARSE_MASK;
  7987. +
  7988. + if(coarse > IGP01E1000_ANALOG_FUSE_COARSE_THRESH) {
  7989. + coarse -= IGP01E1000_ANALOG_FUSE_COARSE_10;
  7990. + fine -= IGP01E1000_ANALOG_FUSE_FINE_1;
  7991. + } else if(coarse == IGP01E1000_ANALOG_FUSE_COARSE_THRESH)
  7992. + fine -= IGP01E1000_ANALOG_FUSE_FINE_10;
  7993. +
  7994. + fused = (fused & IGP01E1000_ANALOG_FUSE_POLY_MASK) |
  7995. + (fine & IGP01E1000_ANALOG_FUSE_FINE_MASK) |
  7996. + (coarse & IGP01E1000_ANALOG_FUSE_COARSE_MASK);
  7997. +
  7998. + e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_CONTROL, fused);
  7999. + e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_BYPASS,
  8000. + IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL);
  8001. + }
  8002. + }
  8003. + }
  8004. +}
  8005. +
  8006. +/******************************************************************************
  8007. + * Set the mac type member in the hw struct.
  8008. + *
  8009. + * hw - Struct containing variables accessed by shared code
  8010. + *****************************************************************************/
  8011. +static int
  8012. +e1000_set_mac_type(struct e1000_hw *hw)
  8013. +{
  8014. + DEBUGFUNC("e1000_set_mac_type");
  8015. +
  8016. + switch (hw->device_id) {
  8017. + case E1000_DEV_ID_82542:
  8018. + switch (hw->revision_id) {
  8019. + case E1000_82542_2_0_REV_ID:
  8020. + hw->mac_type = e1000_82542_rev2_0;
  8021. + break;
  8022. + case E1000_82542_2_1_REV_ID:
  8023. + hw->mac_type = e1000_82542_rev2_1;
  8024. + break;
  8025. + default:
  8026. + /* Invalid 82542 revision ID */
  8027. + return -E1000_ERR_MAC_TYPE;
  8028. + }
  8029. + break;
  8030. + case E1000_DEV_ID_82543GC_FIBER:
  8031. + case E1000_DEV_ID_82543GC_COPPER:
  8032. + hw->mac_type = e1000_82543;
  8033. + break;
  8034. + case E1000_DEV_ID_82544EI_COPPER:
  8035. + case E1000_DEV_ID_82544EI_FIBER:
  8036. + case E1000_DEV_ID_82544GC_COPPER:
  8037. + case E1000_DEV_ID_82544GC_LOM:
  8038. + hw->mac_type = e1000_82544;
  8039. + break;
  8040. + case E1000_DEV_ID_82540EM:
  8041. + case E1000_DEV_ID_82540EM_LOM:
  8042. + case E1000_DEV_ID_82540EP:
  8043. + case E1000_DEV_ID_82540EP_LOM:
  8044. + case E1000_DEV_ID_82540EP_LP:
  8045. + hw->mac_type = e1000_82540;
  8046. + break;
  8047. + case E1000_DEV_ID_82545EM_COPPER:
  8048. + case E1000_DEV_ID_82545EM_FIBER:
  8049. + hw->mac_type = e1000_82545;
  8050. + break;
  8051. + case E1000_DEV_ID_82545GM_COPPER:
  8052. + case E1000_DEV_ID_82545GM_FIBER:
  8053. + case E1000_DEV_ID_82545GM_SERDES:
  8054. + hw->mac_type = e1000_82545_rev_3;
  8055. + break;
  8056. + case E1000_DEV_ID_82546EB_COPPER:
  8057. + case E1000_DEV_ID_82546EB_FIBER:
  8058. + case E1000_DEV_ID_82546EB_QUAD_COPPER:
  8059. + hw->mac_type = e1000_82546;
  8060. + break;
  8061. + case E1000_DEV_ID_82546GB_COPPER:
  8062. + case E1000_DEV_ID_82546GB_FIBER:
  8063. + case E1000_DEV_ID_82546GB_SERDES:
  8064. + hw->mac_type = e1000_82546_rev_3;
  8065. + break;
  8066. + case E1000_DEV_ID_82541EI:
  8067. + case E1000_DEV_ID_82541EI_MOBILE:
  8068. + hw->mac_type = e1000_82541;
  8069. + break;
  8070. + case E1000_DEV_ID_82541ER:
  8071. + case E1000_DEV_ID_82541GI:
  8072. + case E1000_DEV_ID_82541GI_MOBILE:
  8073. + hw->mac_type = e1000_82541_rev_2;
  8074. + break;
  8075. + case E1000_DEV_ID_82547EI:
  8076. + hw->mac_type = e1000_82547;
  8077. + break;
  8078. + case E1000_DEV_ID_82547GI:
  8079. + hw->mac_type = e1000_82547_rev_2;
  8080. + break;
  8081. + default:
  8082. + /* Should never have loaded on this device */
  8083. + return -E1000_ERR_MAC_TYPE;
  8084. + }
  8085. +
  8086. + return E1000_SUCCESS;
  8087. +}
  8088. +
  8089. +/*****************************************************************************
  8090. + * Set media type and TBI compatibility.
  8091. + *
  8092. + * hw - Struct containing variables accessed by shared code
  8093. + * **************************************************************************/
  8094. +static void
  8095. +e1000_set_media_type(struct e1000_hw *hw)
  8096. +{
  8097. + uint32_t status;
  8098. +
  8099. + DEBUGFUNC("e1000_set_media_type");
  8100. +
  8101. + if(hw->mac_type != e1000_82543) {
  8102. + /* tbi_compatibility is only valid on 82543 */
  8103. + hw->tbi_compatibility_en = FALSE;
  8104. + }
  8105. +
  8106. + switch (hw->device_id) {
  8107. + case E1000_DEV_ID_82545GM_SERDES:
  8108. + case E1000_DEV_ID_82546GB_SERDES:
  8109. + hw->media_type = e1000_media_type_internal_serdes;
  8110. + break;
  8111. + default:
  8112. + if(hw->mac_type >= e1000_82543) {
  8113. + status = E1000_READ_REG(hw, STATUS);
  8114. + if(status & E1000_STATUS_TBIMODE) {
  8115. + hw->media_type = e1000_media_type_fiber;
  8116. + /* tbi_compatibility not valid on fiber */
  8117. + hw->tbi_compatibility_en = FALSE;
  8118. + } else {
  8119. + hw->media_type = e1000_media_type_copper;
  8120. + }
  8121. + } else {
  8122. + /* This is an 82542 (fiber only) */
  8123. + hw->media_type = e1000_media_type_fiber;
  8124. + }
  8125. + }
  8126. +}
  8127. +
  8128. +/******************************************************************************
  8129. + * Reset the transmit and receive units; mask and clear all interrupts.
  8130. + *
  8131. + * hw - Struct containing variables accessed by shared code
  8132. + *****************************************************************************/
  8133. +static void
  8134. +e1000_reset_hw(struct e1000_hw *hw)
  8135. +{
  8136. + uint32_t ctrl;
  8137. + uint32_t ctrl_ext;
  8138. + uint32_t icr;
  8139. + uint32_t manc;
  8140. +
  8141. + DEBUGFUNC("e1000_reset_hw");
  8142. +
  8143. + /* For 82542 (rev 2.0), disable MWI before issuing a device reset */
  8144. + if(hw->mac_type == e1000_82542_rev2_0) {
  8145. + DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
  8146. + e1000_pci_clear_mwi(hw);
  8147. + }
  8148. +
  8149. + /* Clear interrupt mask to stop board from generating interrupts */
  8150. + DEBUGOUT("Masking off all interrupts\n");
  8151. + E1000_WRITE_REG(hw, IMC, 0xffffffff);
  8152. +
  8153. + /* Disable the Transmit and Receive units. Then delay to allow
  8154. + * any pending transactions to complete before we hit the MAC with
  8155. + * the global reset.
  8156. + */
  8157. + E1000_WRITE_REG(hw, RCTL, 0);
  8158. + E1000_WRITE_REG(hw, TCTL, E1000_TCTL_PSP);
  8159. + E1000_WRITE_FLUSH(hw);
  8160. +
  8161. + /* The tbi_compatibility_on Flag must be cleared when Rctl is cleared. */
  8162. + hw->tbi_compatibility_on = FALSE;
  8163. +
  8164. + /* Delay to allow any outstanding PCI transactions to complete before
  8165. + * resetting the device
  8166. + */
  8167. + mdelay(10);
  8168. +
  8169. + ctrl = E1000_READ_REG(hw, CTRL);
  8170. +
  8171. + /* Must reset the PHY before resetting the MAC */
  8172. + if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
  8173. + E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_PHY_RST));
  8174. + mdelay(5);
  8175. + }
  8176. +
  8177. + /* Issue a global reset to the MAC. This will reset the chip's
  8178. + * transmit, receive, DMA, and link units. It will not effect
  8179. + * the current PCI configuration. The global reset bit is self-
  8180. + * clearing, and should clear within a microsecond.
  8181. + */
  8182. + DEBUGOUT("Issuing a global reset to MAC\n");
  8183. +
  8184. + switch(hw->mac_type) {
  8185. + case e1000_82544:
  8186. + case e1000_82540:
  8187. + case e1000_82545:
  8188. + case e1000_82546:
  8189. + case e1000_82541:
  8190. + case e1000_82541_rev_2:
  8191. + /* These controllers can't ack the 64-bit write when issuing the
  8192. + * reset, so use IO-mapping as a workaround to issue the reset */
  8193. + E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_RST));
  8194. + break;
  8195. + case e1000_82545_rev_3:
  8196. + case e1000_82546_rev_3:
  8197. + /* Reset is performed on a shadow of the control register */
  8198. + E1000_WRITE_REG(hw, CTRL_DUP, (ctrl | E1000_CTRL_RST));
  8199. + break;
  8200. + default:
  8201. + E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_RST));
  8202. + break;
  8203. + }
  8204. +
  8205. + /* After MAC reset, force reload of EEPROM to restore power-on settings to
  8206. + * device. Later controllers reload the EEPROM automatically, so just wait
  8207. + * for reload to complete.
  8208. + */
  8209. + switch(hw->mac_type) {
  8210. + case e1000_82542_rev2_0:
  8211. + case e1000_82542_rev2_1:
  8212. + case e1000_82543:
  8213. + case e1000_82544:
  8214. + /* Wait for reset to complete */
  8215. + udelay(10);
  8216. + ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
  8217. + ctrl_ext |= E1000_CTRL_EXT_EE_RST;
  8218. + E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  8219. + E1000_WRITE_FLUSH(hw);
  8220. + /* Wait for EEPROM reload */
  8221. + mdelay(2);
  8222. + break;
  8223. + case e1000_82541:
  8224. + case e1000_82541_rev_2:
  8225. + case e1000_82547:
  8226. + case e1000_82547_rev_2:
  8227. + /* Wait for EEPROM reload */
  8228. + mdelay(20);
  8229. + break;
  8230. + default:
  8231. + /* Wait for EEPROM reload (it happens automatically) */
  8232. + mdelay(5);
  8233. + break;
  8234. + }
  8235. +
  8236. + /* Disable HW ARPs on ASF enabled adapters */
  8237. + if(hw->mac_type >= e1000_82540) {
  8238. + manc = E1000_READ_REG(hw, MANC);
  8239. + manc &= ~(E1000_MANC_ARP_EN);
  8240. + E1000_WRITE_REG(hw, MANC, manc);
  8241. + }
  8242. +
  8243. + if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
  8244. + e1000_phy_init_script(hw);
  8245. + }
  8246. +
  8247. + /* Clear interrupt mask to stop board from generating interrupts */
  8248. + DEBUGOUT("Masking off all interrupts\n");
  8249. + E1000_WRITE_REG(hw, IMC, 0xffffffff);
  8250. +
  8251. + /* Clear any pending interrupt events. */
  8252. + icr = E1000_READ_REG(hw, ICR);
  8253. +
  8254. + /* If MWI was previously enabled, reenable it. */
  8255. + if(hw->mac_type == e1000_82542_rev2_0) {
  8256. +#ifdef LINUX_DRIVER
  8257. + if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
  8258. +#endif
  8259. + e1000_pci_set_mwi(hw);
  8260. + }
  8261. +}
  8262. +
  8263. +/******************************************************************************
  8264. + * Performs basic configuration of the adapter.
  8265. + *
  8266. + * hw - Struct containing variables accessed by shared code
  8267. + *
  8268. + * Assumes that the controller has previously been reset and is in a
  8269. + * post-reset uninitialized state. Initializes the receive address registers,
  8270. + * multicast table, and VLAN filter table. Calls routines to setup link
  8271. + * configuration and flow control settings. Clears all on-chip counters. Leaves
  8272. + * the transmit and receive units disabled and uninitialized.
  8273. + *****************************************************************************/
  8274. +static int
  8275. +e1000_init_hw(struct e1000_hw *hw)
  8276. +{
  8277. + uint32_t ctrl, status;
  8278. + uint32_t i;
  8279. + int32_t ret_val;
  8280. + uint16_t pcix_cmd_word;
  8281. + uint16_t pcix_stat_hi_word;
  8282. + uint16_t cmd_mmrbc;
  8283. + uint16_t stat_mmrbc;
  8284. + e1000_bus_type bus_type = e1000_bus_type_unknown;
  8285. +
  8286. + DEBUGFUNC("e1000_init_hw");
  8287. +
  8288. + /* Set the media type and TBI compatibility */
  8289. + e1000_set_media_type(hw);
  8290. +
  8291. + /* Disabling VLAN filtering. */
  8292. + DEBUGOUT("Initializing the IEEE VLAN\n");
  8293. + E1000_WRITE_REG(hw, VET, 0);
  8294. +
  8295. + e1000_clear_vfta(hw);
  8296. +
  8297. + /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
  8298. + if(hw->mac_type == e1000_82542_rev2_0) {
  8299. + DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
  8300. + e1000_pci_clear_mwi(hw);
  8301. + E1000_WRITE_REG(hw, RCTL, E1000_RCTL_RST);
  8302. + E1000_WRITE_FLUSH(hw);
  8303. + mdelay(5);
  8304. + }
  8305. +
  8306. + /* Setup the receive address. This involves initializing all of the Receive
  8307. + * Address Registers (RARs 0 - 15).
  8308. + */
  8309. + e1000_init_rx_addrs(hw);
  8310. +
  8311. + /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
  8312. + if(hw->mac_type == e1000_82542_rev2_0) {
  8313. + E1000_WRITE_REG(hw, RCTL, 0);
  8314. + E1000_WRITE_FLUSH(hw);
  8315. + mdelay(1);
  8316. +#ifdef LINUX_DRIVER
  8317. + if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
  8318. +#endif
  8319. + e1000_pci_set_mwi(hw);
  8320. + }
  8321. +
  8322. + /* Zero out the Multicast HASH table */
  8323. + DEBUGOUT("Zeroing the MTA\n");
  8324. + for(i = 0; i < E1000_MC_TBL_SIZE; i++)
  8325. + E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
  8326. +
  8327. +#if 0
  8328. + /* Set the PCI priority bit correctly in the CTRL register. This
  8329. + * determines if the adapter gives priority to receives, or if it
  8330. + * gives equal priority to transmits and receives.
  8331. + */
  8332. + if(hw->dma_fairness) {
  8333. + ctrl = E1000_READ_REG(hw, CTRL);
  8334. + E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PRIOR);
  8335. + }
  8336. +#endif
  8337. +
  8338. + switch(hw->mac_type) {
  8339. + case e1000_82545_rev_3:
  8340. + case e1000_82546_rev_3:
  8341. + break;
  8342. + default:
  8343. + if (hw->mac_type >= e1000_82543) {
  8344. + /* See e1000_get_bus_info() of the Linux driver */
  8345. + status = E1000_READ_REG(hw, STATUS);
  8346. + bus_type = (status & E1000_STATUS_PCIX_MODE) ?
  8347. + e1000_bus_type_pcix : e1000_bus_type_pci;
  8348. + }
  8349. +
  8350. + /* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */
  8351. + if(bus_type == e1000_bus_type_pcix) {
  8352. + pci_read_config_word(hw->pdev, PCIX_COMMAND_REGISTER, &pcix_cmd_word);
  8353. + pci_read_config_word(hw->pdev, PCIX_STATUS_REGISTER_HI, &pcix_stat_hi_word);
  8354. + cmd_mmrbc = (pcix_cmd_word & PCIX_COMMAND_MMRBC_MASK) >>
  8355. + PCIX_COMMAND_MMRBC_SHIFT;
  8356. + stat_mmrbc = (pcix_stat_hi_word & PCIX_STATUS_HI_MMRBC_MASK) >>
  8357. + PCIX_STATUS_HI_MMRBC_SHIFT;
  8358. + if(stat_mmrbc == PCIX_STATUS_HI_MMRBC_4K)
  8359. + stat_mmrbc = PCIX_STATUS_HI_MMRBC_2K;
  8360. + if(cmd_mmrbc > stat_mmrbc) {
  8361. + pcix_cmd_word &= ~PCIX_COMMAND_MMRBC_MASK;
  8362. + pcix_cmd_word |= stat_mmrbc << PCIX_COMMAND_MMRBC_SHIFT;
  8363. + pci_write_config_word(hw->pdev, PCIX_COMMAND_REGISTER, pcix_cmd_word);
  8364. + }
  8365. + }
  8366. + break;
  8367. + }
  8368. +
  8369. + /* Call a subroutine to configure the link and setup flow control. */
  8370. + ret_val = e1000_setup_link(hw);
  8371. +
  8372. + /* Set the transmit descriptor write-back policy */
  8373. + if(hw->mac_type > e1000_82544) {
  8374. + ctrl = E1000_READ_REG(hw, TXDCTL);
  8375. + ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
  8376. + E1000_WRITE_REG(hw, TXDCTL, ctrl);
  8377. + }
  8378. +
  8379. +#if 0
  8380. + /* Clear all of the statistics registers (clear on read). It is
  8381. + * important that we do this after we have tried to establish link
  8382. + * because the symbol error count will increment wildly if there
  8383. + * is no link.
  8384. + */
  8385. + e1000_clear_hw_cntrs(hw);
  8386. +#endif
  8387. +
  8388. + return ret_val;
  8389. +}
  8390. +
  8391. +/******************************************************************************
  8392. + * Adjust SERDES output amplitude based on EEPROM setting.
  8393. + *
  8394. + * hw - Struct containing variables accessed by shared code.
  8395. + *****************************************************************************/
  8396. +static int32_t
  8397. +e1000_adjust_serdes_amplitude(struct e1000_hw *hw)
  8398. +{
  8399. + uint16_t eeprom_data;
  8400. + int32_t ret_val;
  8401. +
  8402. + DEBUGFUNC("e1000_adjust_serdes_amplitude");
  8403. +
  8404. + if(hw->media_type != e1000_media_type_internal_serdes)
  8405. + return E1000_SUCCESS;
  8406. +
  8407. + switch(hw->mac_type) {
  8408. + case e1000_82545_rev_3:
  8409. + case e1000_82546_rev_3:
  8410. + break;
  8411. + default:
  8412. + return E1000_SUCCESS;
  8413. + }
  8414. +
  8415. + if ((ret_val = e1000_read_eeprom(hw, EEPROM_SERDES_AMPLITUDE, 1,
  8416. + &eeprom_data))) {
  8417. + return ret_val;
  8418. + }
  8419. +
  8420. + if(eeprom_data != EEPROM_RESERVED_WORD) {
  8421. + /* Adjust SERDES output amplitude only. */
  8422. + eeprom_data &= EEPROM_SERDES_AMPLITUDE_MASK;
  8423. + if((ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_EXT_CTRL,
  8424. + eeprom_data)))
  8425. + return ret_val;
  8426. + }
  8427. +
  8428. + return E1000_SUCCESS;
  8429. +}
  8430. +
  8431. +/******************************************************************************
  8432. + * Configures flow control and link settings.
  8433. + *
  8434. + * hw - Struct containing variables accessed by shared code
  8435. + *
  8436. + * Determines which flow control settings to use. Calls the apropriate media-
  8437. + * specific link configuration function. Configures the flow control settings.
  8438. + * Assuming the adapter has a valid link partner, a valid link should be
  8439. + * established. Assumes the hardware has previously been reset and the
  8440. + * transmitter and receiver are not enabled.
  8441. + *****************************************************************************/
  8442. +static int
  8443. +e1000_setup_link(struct e1000_hw *hw)
  8444. +{
  8445. + uint32_t ctrl_ext;
  8446. + int32_t ret_val;
  8447. + uint16_t eeprom_data;
  8448. +
  8449. + DEBUGFUNC("e1000_setup_link");
  8450. +
  8451. + /* Read and store word 0x0F of the EEPROM. This word contains bits
  8452. + * that determine the hardware's default PAUSE (flow control) mode,
  8453. + * a bit that determines whether the HW defaults to enabling or
  8454. + * disabling auto-negotiation, and the direction of the
  8455. + * SW defined pins. If there is no SW over-ride of the flow
  8456. + * control setting, then the variable hw->fc will
  8457. + * be initialized based on a value in the EEPROM.
  8458. + */
  8459. + if(e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data) < 0) {
  8460. + DEBUGOUT("EEPROM Read Error\n");
  8461. + return -E1000_ERR_EEPROM;
  8462. + }
  8463. +
  8464. + if(hw->fc == e1000_fc_default) {
  8465. + if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0)
  8466. + hw->fc = e1000_fc_none;
  8467. + else if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) ==
  8468. + EEPROM_WORD0F_ASM_DIR)
  8469. + hw->fc = e1000_fc_tx_pause;
  8470. + else
  8471. + hw->fc = e1000_fc_full;
  8472. + }
  8473. +
  8474. + /* We want to save off the original Flow Control configuration just
  8475. + * in case we get disconnected and then reconnected into a different
  8476. + * hub or switch with different Flow Control capabilities.
  8477. + */
  8478. + if(hw->mac_type == e1000_82542_rev2_0)
  8479. + hw->fc &= (~e1000_fc_tx_pause);
  8480. +
  8481. +#if 0
  8482. + /* See e1000_sw_init() of the Linux driver */
  8483. + if((hw->mac_type < e1000_82543) && (hw->report_tx_early == 1))
  8484. +#else
  8485. + if((hw->mac_type < e1000_82543) && (hw->mac_type >= e1000_82543))
  8486. +#endif
  8487. + hw->fc &= (~e1000_fc_rx_pause);
  8488. +
  8489. +#if 0
  8490. + hw->original_fc = hw->fc;
  8491. +#endif
  8492. +
  8493. + DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw->fc);
  8494. +
  8495. + /* Take the 4 bits from EEPROM word 0x0F that determine the initial
  8496. + * polarity value for the SW controlled pins, and setup the
  8497. + * Extended Device Control reg with that info.
  8498. + * This is needed because one of the SW controlled pins is used for
  8499. + * signal detection. So this should be done before e1000_setup_pcs_link()
  8500. + * or e1000_phy_setup() is called.
  8501. + */
  8502. + if(hw->mac_type == e1000_82543) {
  8503. + ctrl_ext = ((eeprom_data & EEPROM_WORD0F_SWPDIO_EXT) <<
  8504. + SWDPIO__EXT_SHIFT);
  8505. + E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  8506. + }
  8507. +
  8508. + /* Call the necessary subroutine to configure the link. */
  8509. + ret_val = (hw->media_type == e1000_media_type_copper) ?
  8510. + e1000_setup_copper_link(hw) :
  8511. + e1000_setup_fiber_serdes_link(hw);
  8512. + if (ret_val < 0) {
  8513. + return ret_val;
  8514. + }
  8515. +
  8516. + /* Initialize the flow control address, type, and PAUSE timer
  8517. + * registers to their default values. This is done even if flow
  8518. + * control is disabled, because it does not hurt anything to
  8519. + * initialize these registers.
  8520. + */
  8521. + DEBUGOUT("Initializing the Flow Control address, type and timer regs\n");
  8522. +
  8523. + E1000_WRITE_REG(hw, FCAL, FLOW_CONTROL_ADDRESS_LOW);
  8524. + E1000_WRITE_REG(hw, FCAH, FLOW_CONTROL_ADDRESS_HIGH);
  8525. + E1000_WRITE_REG(hw, FCT, FLOW_CONTROL_TYPE);
  8526. +#if 0
  8527. + E1000_WRITE_REG(hw, FCTTV, hw->fc_pause_time);
  8528. +#else
  8529. + E1000_WRITE_REG(hw, FCTTV, FC_DEFAULT_TX_TIMER);
  8530. +#endif
  8531. +
  8532. + /* Set the flow control receive threshold registers. Normally,
  8533. + * these registers will be set to a default threshold that may be
  8534. + * adjusted later by the driver's runtime code. However, if the
  8535. + * ability to transmit pause frames in not enabled, then these
  8536. + * registers will be set to 0.
  8537. + */
  8538. + if(!(hw->fc & e1000_fc_tx_pause)) {
  8539. + E1000_WRITE_REG(hw, FCRTL, 0);
  8540. + E1000_WRITE_REG(hw, FCRTH, 0);
  8541. + } else {
  8542. + /* We need to set up the Receive Threshold high and low water marks
  8543. + * as well as (optionally) enabling the transmission of XON frames.
  8544. + */
  8545. +#if 0
  8546. + if(hw->fc_send_xon) {
  8547. + E1000_WRITE_REG(hw, FCRTL, (hw->fc_low_water | E1000_FCRTL_XONE));
  8548. + E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
  8549. + } else {
  8550. + E1000_WRITE_REG(hw, FCRTL, hw->fc_low_water);
  8551. + E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
  8552. + }
  8553. +#else
  8554. + E1000_WRITE_REG(hw, FCRTL, (FC_DEFAULT_LO_THRESH | E1000_FCRTL_XONE));
  8555. + E1000_WRITE_REG(hw, FCRTH, FC_DEFAULT_HI_THRESH);
  8556. +#endif
  8557. + }
  8558. + return ret_val;
  8559. +}
  8560. +
  8561. +/******************************************************************************
  8562. + * Sets up link for a fiber based or serdes based adapter
  8563. + *
  8564. + * hw - Struct containing variables accessed by shared code
  8565. + *
  8566. + * Manipulates Physical Coding Sublayer functions in order to configure
  8567. + * link. Assumes the hardware has been previously reset and the transmitter
  8568. + * and receiver are not enabled.
  8569. + *****************************************************************************/
  8570. +static int
  8571. +e1000_setup_fiber_serdes_link(struct e1000_hw *hw)
  8572. +{
  8573. + uint32_t ctrl;
  8574. + uint32_t status;
  8575. + uint32_t txcw = 0;
  8576. + uint32_t i;
  8577. + uint32_t signal = 0;
  8578. + int32_t ret_val;
  8579. +
  8580. + DEBUGFUNC("e1000_setup_fiber_serdes_link");
  8581. +
  8582. + /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
  8583. + * set when the optics detect a signal. On older adapters, it will be
  8584. + * cleared when there is a signal. This applies to fiber media only.
  8585. + * If we're on serdes media, adjust the output amplitude to value set in
  8586. + * the EEPROM.
  8587. + */
  8588. + ctrl = E1000_READ_REG(hw, CTRL);
  8589. + if(hw->media_type == e1000_media_type_fiber)
  8590. + signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
  8591. +
  8592. + if((ret_val = e1000_adjust_serdes_amplitude(hw)))
  8593. + return ret_val;
  8594. +
  8595. + /* Take the link out of reset */
  8596. + ctrl &= ~(E1000_CTRL_LRST);
  8597. +
  8598. +#if 0
  8599. + /* Adjust VCO speed to improve BER performance */
  8600. + if((ret_val = e1000_set_vco_speed(hw)))
  8601. + return ret_val;
  8602. +#endif
  8603. +
  8604. + e1000_config_collision_dist(hw);
  8605. +
  8606. + /* Check for a software override of the flow control settings, and setup
  8607. + * the device accordingly. If auto-negotiation is enabled, then software
  8608. + * will have to set the "PAUSE" bits to the correct value in the Tranmsit
  8609. + * Config Word Register (TXCW) and re-start auto-negotiation. However, if
  8610. + * auto-negotiation is disabled, then software will have to manually
  8611. + * configure the two flow control enable bits in the CTRL register.
  8612. + *
  8613. + * The possible values of the "fc" parameter are:
  8614. + * 0: Flow control is completely disabled
  8615. + * 1: Rx flow control is enabled (we can receive pause frames, but
  8616. + * not send pause frames).
  8617. + * 2: Tx flow control is enabled (we can send pause frames but we do
  8618. + * not support receiving pause frames).
  8619. + * 3: Both Rx and TX flow control (symmetric) are enabled.
  8620. + */
  8621. + switch (hw->fc) {
  8622. + case e1000_fc_none:
  8623. + /* Flow control is completely disabled by a software over-ride. */
  8624. + txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
  8625. + break;
  8626. + case e1000_fc_rx_pause:
  8627. + /* RX Flow control is enabled and TX Flow control is disabled by a
  8628. + * software over-ride. Since there really isn't a way to advertise
  8629. + * that we are capable of RX Pause ONLY, we will advertise that we
  8630. + * support both symmetric and asymmetric RX PAUSE. Later, we will
  8631. + * disable the adapter's ability to send PAUSE frames.
  8632. + */
  8633. + txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
  8634. + break;
  8635. + case e1000_fc_tx_pause:
  8636. + /* TX Flow control is enabled, and RX Flow control is disabled, by a
  8637. + * software over-ride.
  8638. + */
  8639. + txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);
  8640. + break;
  8641. + case e1000_fc_full:
  8642. + /* Flow control (both RX and TX) is enabled by a software over-ride. */
  8643. + txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
  8644. + break;
  8645. + default:
  8646. + DEBUGOUT("Flow control param set incorrectly\n");
  8647. + return -E1000_ERR_CONFIG;
  8648. + break;
  8649. + }
  8650. +
  8651. + /* Since auto-negotiation is enabled, take the link out of reset (the link
  8652. + * will be in reset, because we previously reset the chip). This will
  8653. + * restart auto-negotiation. If auto-neogtiation is successful then the
  8654. + * link-up status bit will be set and the flow control enable bits (RFCE
  8655. + * and TFCE) will be set according to their negotiated value.
  8656. + */
  8657. + DEBUGOUT("Auto-negotiation enabled\n");
  8658. +
  8659. + E1000_WRITE_REG(hw, TXCW, txcw);
  8660. + E1000_WRITE_REG(hw, CTRL, ctrl);
  8661. + E1000_WRITE_FLUSH(hw);
  8662. +
  8663. + hw->txcw = txcw;
  8664. + mdelay(1);
  8665. +
  8666. + /* If we have a signal (the cable is plugged in) then poll for a "Link-Up"
  8667. + * indication in the Device Status Register. Time-out if a link isn't
  8668. + * seen in 500 milliseconds seconds (Auto-negotiation should complete in
  8669. + * less than 500 milliseconds even if the other end is doing it in SW).
  8670. + * For internal serdes, we just assume a signal is present, then poll.
  8671. + */
  8672. + if(hw->media_type == e1000_media_type_internal_serdes ||
  8673. + (E1000_READ_REG(hw, CTRL) & E1000_CTRL_SWDPIN1) == signal) {
  8674. + DEBUGOUT("Looking for Link\n");
  8675. + for(i = 0; i < (LINK_UP_TIMEOUT / 10); i++) {
  8676. + mdelay(10);
  8677. + status = E1000_READ_REG(hw, STATUS);
  8678. + if(status & E1000_STATUS_LU) break;
  8679. + }
  8680. + if(i == (LINK_UP_TIMEOUT / 10)) {
  8681. + DEBUGOUT("Never got a valid link from auto-neg!!!\n");
  8682. + hw->autoneg_failed = 1;
  8683. + /* AutoNeg failed to achieve a link, so we'll call
  8684. + * e1000_check_for_link. This routine will force the link up if
  8685. + * we detect a signal. This will allow us to communicate with
  8686. + * non-autonegotiating link partners.
  8687. + */
  8688. + if((ret_val = e1000_check_for_link(hw))) {
  8689. + DEBUGOUT("Error while checking for link\n");
  8690. + return ret_val;
  8691. + }
  8692. + hw->autoneg_failed = 0;
  8693. + } else {
  8694. + hw->autoneg_failed = 0;
  8695. + DEBUGOUT("Valid Link Found\n");
  8696. + }
  8697. + } else {
  8698. + DEBUGOUT("No Signal Detected\n");
  8699. + }
  8700. + return E1000_SUCCESS;
  8701. +}
  8702. +
  8703. +/******************************************************************************
  8704. +* Detects which PHY is present and the speed and duplex
  8705. +*
  8706. +* hw - Struct containing variables accessed by shared code
  8707. +******************************************************************************/
  8708. +static int
  8709. +e1000_setup_copper_link(struct e1000_hw *hw)
  8710. +{
  8711. + uint32_t ctrl;
  8712. + int32_t ret_val;
  8713. + uint16_t i;
  8714. + uint16_t phy_data;
  8715. +
  8716. + DEBUGFUNC("e1000_setup_copper_link");
  8717. +
  8718. + ctrl = E1000_READ_REG(hw, CTRL);
  8719. + /* With 82543, we need to force speed and duplex on the MAC equal to what
  8720. + * the PHY speed and duplex configuration is. In addition, we need to
  8721. + * perform a hardware reset on the PHY to take it out of reset.
  8722. + */
  8723. + if(hw->mac_type > e1000_82543) {
  8724. + ctrl |= E1000_CTRL_SLU;
  8725. + ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  8726. + E1000_WRITE_REG(hw, CTRL, ctrl);
  8727. + } else {
  8728. + ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_SLU);
  8729. + E1000_WRITE_REG(hw, CTRL, ctrl);
  8730. + e1000_phy_hw_reset(hw);
  8731. + }
  8732. +
  8733. + /* Make sure we have a valid PHY */
  8734. + if((ret_val = e1000_detect_gig_phy(hw))) {
  8735. + DEBUGOUT("Error, did not detect valid phy.\n");
  8736. + return ret_val;
  8737. + }
  8738. + DEBUGOUT1("Phy ID = %x \n", hw->phy_id);
  8739. +
  8740. + if(hw->mac_type <= e1000_82543 ||
  8741. + hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547 ||
  8742. +#if 0
  8743. + hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2)
  8744. + hw->phy_reset_disable = FALSE;
  8745. +
  8746. + if(!hw->phy_reset_disable) {
  8747. +#else
  8748. + hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2) {
  8749. +#endif
  8750. + if (hw->phy_type == e1000_phy_igp) {
  8751. +
  8752. + if((ret_val = e1000_phy_reset(hw))) {
  8753. + DEBUGOUT("Error Resetting the PHY\n");
  8754. + return ret_val;
  8755. + }
  8756. +
  8757. + /* Wait 10ms for MAC to configure PHY from eeprom settings */
  8758. + mdelay(15);
  8759. +
  8760. +#if 0
  8761. + /* disable lplu d3 during driver init */
  8762. + if((ret_val = e1000_set_d3_lplu_state(hw, FALSE))) {
  8763. + DEBUGOUT("Error Disabling LPLU D3\n");
  8764. + return ret_val;
  8765. + }
  8766. +
  8767. + /* Configure mdi-mdix settings */
  8768. + if((ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL,
  8769. + &phy_data)))
  8770. + return ret_val;
  8771. +
  8772. + if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
  8773. + hw->dsp_config_state = e1000_dsp_config_disabled;
  8774. + /* Force MDI for IGP B-0 PHY */
  8775. + phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX |
  8776. + IGP01E1000_PSCR_FORCE_MDI_MDIX);
  8777. + hw->mdix = 1;
  8778. +
  8779. + } else {
  8780. + hw->dsp_config_state = e1000_dsp_config_enabled;
  8781. + phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
  8782. +
  8783. + switch (hw->mdix) {
  8784. + case 1:
  8785. + phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
  8786. + break;
  8787. + case 2:
  8788. + phy_data |= IGP01E1000_PSCR_FORCE_MDI_MDIX;
  8789. + break;
  8790. + case 0:
  8791. + default:
  8792. + phy_data |= IGP01E1000_PSCR_AUTO_MDIX;
  8793. + break;
  8794. + }
  8795. + }
  8796. + if((ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL,
  8797. + phy_data)))
  8798. + return ret_val;
  8799. +
  8800. + /* set auto-master slave resolution settings */
  8801. + e1000_ms_type phy_ms_setting = hw->master_slave;
  8802. +
  8803. + if(hw->ffe_config_state == e1000_ffe_config_active)
  8804. + hw->ffe_config_state = e1000_ffe_config_enabled;
  8805. +
  8806. + if(hw->dsp_config_state == e1000_dsp_config_activated)
  8807. + hw->dsp_config_state = e1000_dsp_config_enabled;
  8808. +#endif
  8809. +
  8810. + /* when autonegotiation advertisment is only 1000Mbps then we
  8811. + * should disable SmartSpeed and enable Auto MasterSlave
  8812. + * resolution as hardware default. */
  8813. + if(hw->autoneg_advertised == ADVERTISE_1000_FULL) {
  8814. + /* Disable SmartSpeed */
  8815. + if((ret_val = e1000_read_phy_reg(hw,
  8816. + IGP01E1000_PHY_PORT_CONFIG,
  8817. + &phy_data)))
  8818. + return ret_val;
  8819. + phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  8820. + if((ret_val = e1000_write_phy_reg(hw,
  8821. + IGP01E1000_PHY_PORT_CONFIG,
  8822. + phy_data)))
  8823. + return ret_val;
  8824. + /* Set auto Master/Slave resolution process */
  8825. + if((ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL,
  8826. + &phy_data)))
  8827. + return ret_val;
  8828. + phy_data &= ~CR_1000T_MS_ENABLE;
  8829. + if((ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL,
  8830. + phy_data)))
  8831. + return ret_val;
  8832. + }
  8833. +
  8834. + if((ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL,
  8835. + &phy_data)))
  8836. + return ret_val;
  8837. +
  8838. +#if 0
  8839. + /* load defaults for future use */
  8840. + hw->original_master_slave = (phy_data & CR_1000T_MS_ENABLE) ?
  8841. + ((phy_data & CR_1000T_MS_VALUE) ?
  8842. + e1000_ms_force_master :
  8843. + e1000_ms_force_slave) :
  8844. + e1000_ms_auto;
  8845. +
  8846. + switch (phy_ms_setting) {
  8847. + case e1000_ms_force_master:
  8848. + phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
  8849. + break;
  8850. + case e1000_ms_force_slave:
  8851. + phy_data |= CR_1000T_MS_ENABLE;
  8852. + phy_data &= ~(CR_1000T_MS_VALUE);
  8853. + break;
  8854. + case e1000_ms_auto:
  8855. + phy_data &= ~CR_1000T_MS_ENABLE;
  8856. + default:
  8857. + break;
  8858. + }
  8859. +#endif
  8860. +
  8861. + if((ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL,
  8862. + phy_data)))
  8863. + return ret_val;
  8864. + } else {
  8865. + /* Enable CRS on TX. This must be set for half-duplex operation. */
  8866. + if((ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
  8867. + &phy_data)))
  8868. + return ret_val;
  8869. +
  8870. + phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
  8871. +
  8872. + /* Options:
  8873. + * MDI/MDI-X = 0 (default)
  8874. + * 0 - Auto for all speeds
  8875. + * 1 - MDI mode
  8876. + * 2 - MDI-X mode
  8877. + * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
  8878. + */
  8879. +#if 0
  8880. + phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
  8881. +
  8882. + switch (hw->mdix) {
  8883. + case 1:
  8884. + phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE;
  8885. + break;
  8886. + case 2:
  8887. + phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE;
  8888. + break;
  8889. + case 3:
  8890. + phy_data |= M88E1000_PSCR_AUTO_X_1000T;
  8891. + break;
  8892. + case 0:
  8893. + default:
  8894. +#endif
  8895. + phy_data |= M88E1000_PSCR_AUTO_X_MODE;
  8896. +#if 0
  8897. + break;
  8898. + }
  8899. +#endif
  8900. +
  8901. + /* Options:
  8902. + * disable_polarity_correction = 0 (default)
  8903. + * Automatic Correction for Reversed Cable Polarity
  8904. + * 0 - Disabled
  8905. + * 1 - Enabled
  8906. + */
  8907. + phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL;
  8908. + if((ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
  8909. + phy_data)))
  8910. + return ret_val;
  8911. +
  8912. + /* Force TX_CLK in the Extended PHY Specific Control Register
  8913. + * to 25MHz clock.
  8914. + */
  8915. + if((ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL,
  8916. + &phy_data)))
  8917. + return ret_val;
  8918. +
  8919. + phy_data |= M88E1000_EPSCR_TX_CLK_25;
  8920. +
  8921. +#ifdef LINUX_DRIVER
  8922. + if (hw->phy_revision < M88E1011_I_REV_4) {
  8923. +#endif
  8924. + /* Configure Master and Slave downshift values */
  8925. + phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
  8926. + M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
  8927. + phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
  8928. + M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
  8929. + if((ret_val = e1000_write_phy_reg(hw,
  8930. + M88E1000_EXT_PHY_SPEC_CTRL,
  8931. + phy_data)))
  8932. + return ret_val;
  8933. + }
  8934. +
  8935. + /* SW Reset the PHY so all changes take effect */
  8936. + if((ret_val = e1000_phy_reset(hw))) {
  8937. + DEBUGOUT("Error Resetting the PHY\n");
  8938. + return ret_val;
  8939. +#ifdef LINUX_DRIVER
  8940. + }
  8941. +#endif
  8942. + }
  8943. +
  8944. + /* Options:
  8945. + * autoneg = 1 (default)
  8946. + * PHY will advertise value(s) parsed from
  8947. + * autoneg_advertised and fc
  8948. + * autoneg = 0
  8949. + * PHY will be set to 10H, 10F, 100H, or 100F
  8950. + * depending on value parsed from forced_speed_duplex.
  8951. + */
  8952. +
  8953. + /* Is autoneg enabled? This is enabled by default or by software
  8954. + * override. If so, call e1000_phy_setup_autoneg routine to parse the
  8955. + * autoneg_advertised and fc options. If autoneg is NOT enabled, then
  8956. + * the user should have provided a speed/duplex override. If so, then
  8957. + * call e1000_phy_force_speed_duplex to parse and set this up.
  8958. + */
  8959. + /* Perform some bounds checking on the hw->autoneg_advertised
  8960. + * parameter. If this variable is zero, then set it to the default.
  8961. + */
  8962. + hw->autoneg_advertised &= AUTONEG_ADVERTISE_SPEED_DEFAULT;
  8963. +
  8964. + /* If autoneg_advertised is zero, we assume it was not defaulted
  8965. + * by the calling code so we set to advertise full capability.
  8966. + */
  8967. + if(hw->autoneg_advertised == 0)
  8968. + hw->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  8969. +
  8970. + DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
  8971. + if((ret_val = e1000_phy_setup_autoneg(hw))) {
  8972. + DEBUGOUT("Error Setting up Auto-Negotiation\n");
  8973. + return ret_val;
  8974. + }
  8975. + DEBUGOUT("Restarting Auto-Neg\n");
  8976. +
  8977. + /* Restart auto-negotiation by setting the Auto Neg Enable bit and
  8978. + * the Auto Neg Restart bit in the PHY control register.
  8979. + */
  8980. + if((ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data)))
  8981. + return ret_val;
  8982. +
  8983. + phy_data |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
  8984. + if((ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data)))
  8985. + return ret_val;
  8986. +
  8987. +#if 0
  8988. + /* Does the user want to wait for Auto-Neg to complete here, or
  8989. + * check at a later time (for example, callback routine).
  8990. + */
  8991. + if(hw->wait_autoneg_complete) {
  8992. + if((ret_val = e1000_wait_autoneg(hw))) {
  8993. + DEBUGOUT("Error while waiting for autoneg to complete\n");
  8994. + return ret_val;
  8995. + }
  8996. + }
  8997. +#else
  8998. + /* If we do not wait for autonegotiation to complete I
  8999. + * do not see a valid link status.
  9000. + */
  9001. + if((ret_val = e1000_wait_autoneg(hw))) {
  9002. + DEBUGOUT("Error while waiting for autoneg to complete\n");
  9003. + return ret_val;
  9004. + }
  9005. +#endif
  9006. + } /* !hw->phy_reset_disable */
  9007. +
  9008. + /* Check link status. Wait up to 100 microseconds for link to become
  9009. + * valid.
  9010. + */
  9011. + for(i = 0; i < 10; i++) {
  9012. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  9013. + return ret_val;
  9014. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  9015. + return ret_val;
  9016. +
  9017. + if(phy_data & MII_SR_LINK_STATUS) {
  9018. + /* We have link, so we need to finish the config process:
  9019. + * 1) Set up the MAC to the current PHY speed/duplex
  9020. + * if we are on 82543. If we
  9021. + * are on newer silicon, we only need to configure
  9022. + * collision distance in the Transmit Control Register.
  9023. + * 2) Set up flow control on the MAC to that established with
  9024. + * the link partner.
  9025. + */
  9026. + if(hw->mac_type >= e1000_82544) {
  9027. + e1000_config_collision_dist(hw);
  9028. + } else {
  9029. + if((ret_val = e1000_config_mac_to_phy(hw))) {
  9030. + DEBUGOUT("Error configuring MAC to PHY settings\n");
  9031. + return ret_val;
  9032. + }
  9033. + }
  9034. + if((ret_val = e1000_config_fc_after_link_up(hw))) {
  9035. + DEBUGOUT("Error Configuring Flow Control\n");
  9036. + return ret_val;
  9037. + }
  9038. +#if 0
  9039. + if(hw->phy_type == e1000_phy_igp) {
  9040. + if((ret_val = e1000_config_dsp_after_link_change(hw, TRUE))) {
  9041. + DEBUGOUT("Error Configuring DSP after link up\n");
  9042. + return ret_val;
  9043. + }
  9044. + }
  9045. +#endif
  9046. + DEBUGOUT("Valid link established!!!\n");
  9047. + return E1000_SUCCESS;
  9048. + }
  9049. + udelay(10);
  9050. + }
  9051. +
  9052. + DEBUGOUT("Unable to establish link!!!\n");
  9053. + return -E1000_ERR_NOLINK;
  9054. +}
  9055. +
  9056. +/******************************************************************************
  9057. +* Configures PHY autoneg and flow control advertisement settings
  9058. +*
  9059. +* hw - Struct containing variables accessed by shared code
  9060. +******************************************************************************/
  9061. +static int
  9062. +e1000_phy_setup_autoneg(struct e1000_hw *hw)
  9063. +{
  9064. + int32_t ret_val;
  9065. + uint16_t mii_autoneg_adv_reg;
  9066. + uint16_t mii_1000t_ctrl_reg;
  9067. +
  9068. + DEBUGFUNC("e1000_phy_setup_autoneg");
  9069. +
  9070. + /* Read the MII Auto-Neg Advertisement Register (Address 4). */
  9071. + if((ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV,
  9072. + &mii_autoneg_adv_reg)))
  9073. + return ret_val;
  9074. +
  9075. + /* Read the MII 1000Base-T Control Register (Address 9). */
  9076. + if((ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg)))
  9077. + return ret_val;
  9078. +
  9079. + /* Need to parse both autoneg_advertised and fc and set up
  9080. + * the appropriate PHY registers. First we will parse for
  9081. + * autoneg_advertised software override. Since we can advertise
  9082. + * a plethora of combinations, we need to check each bit
  9083. + * individually.
  9084. + */
  9085. +
  9086. + /* First we clear all the 10/100 mb speed bits in the Auto-Neg
  9087. + * Advertisement Register (Address 4) and the 1000 mb speed bits in
  9088. + * the 1000Base-T Control Register (Address 9).
  9089. + */
  9090. + mii_autoneg_adv_reg &= ~REG4_SPEED_MASK;
  9091. + mii_1000t_ctrl_reg &= ~REG9_SPEED_MASK;
  9092. +
  9093. + DEBUGOUT1("autoneg_advertised %x\n", hw->autoneg_advertised);
  9094. +
  9095. + /* Do we want to advertise 10 Mb Half Duplex? */
  9096. + if(hw->autoneg_advertised & ADVERTISE_10_HALF) {
  9097. + DEBUGOUT("Advertise 10mb Half duplex\n");
  9098. + mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS;
  9099. + }
  9100. +
  9101. + /* Do we want to advertise 10 Mb Full Duplex? */
  9102. + if(hw->autoneg_advertised & ADVERTISE_10_FULL) {
  9103. + DEBUGOUT("Advertise 10mb Full duplex\n");
  9104. + mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS;
  9105. + }
  9106. +
  9107. + /* Do we want to advertise 100 Mb Half Duplex? */
  9108. + if(hw->autoneg_advertised & ADVERTISE_100_HALF) {
  9109. + DEBUGOUT("Advertise 100mb Half duplex\n");
  9110. + mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS;
  9111. + }
  9112. +
  9113. + /* Do we want to advertise 100 Mb Full Duplex? */
  9114. + if(hw->autoneg_advertised & ADVERTISE_100_FULL) {
  9115. + DEBUGOUT("Advertise 100mb Full duplex\n");
  9116. + mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS;
  9117. + }
  9118. +
  9119. + /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
  9120. + if(hw->autoneg_advertised & ADVERTISE_1000_HALF) {
  9121. + DEBUGOUT("Advertise 1000mb Half duplex requested, request denied!\n");
  9122. + }
  9123. +
  9124. + /* Do we want to advertise 1000 Mb Full Duplex? */
  9125. + if(hw->autoneg_advertised & ADVERTISE_1000_FULL) {
  9126. + DEBUGOUT("Advertise 1000mb Full duplex\n");
  9127. + mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS;
  9128. + }
  9129. +
  9130. + /* Check for a software override of the flow control settings, and
  9131. + * setup the PHY advertisement registers accordingly. If
  9132. + * auto-negotiation is enabled, then software will have to set the
  9133. + * "PAUSE" bits to the correct value in the Auto-Negotiation
  9134. + * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-negotiation.
  9135. + *
  9136. + * The possible values of the "fc" parameter are:
  9137. + * 0: Flow control is completely disabled
  9138. + * 1: Rx flow control is enabled (we can receive pause frames
  9139. + * but not send pause frames).
  9140. + * 2: Tx flow control is enabled (we can send pause frames
  9141. + * but we do not support receiving pause frames).
  9142. + * 3: Both Rx and TX flow control (symmetric) are enabled.
  9143. + * other: No software override. The flow control configuration
  9144. + * in the EEPROM is used.
  9145. + */
  9146. + switch (hw->fc) {
  9147. + case e1000_fc_none: /* 0 */
  9148. + /* Flow control (RX & TX) is completely disabled by a
  9149. + * software over-ride.
  9150. + */
  9151. + mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  9152. + break;
  9153. + case e1000_fc_rx_pause: /* 1 */
  9154. + /* RX Flow control is enabled, and TX Flow control is
  9155. + * disabled, by a software over-ride.
  9156. + */
  9157. + /* Since there really isn't a way to advertise that we are
  9158. + * capable of RX Pause ONLY, we will advertise that we
  9159. + * support both symmetric and asymmetric RX PAUSE. Later
  9160. + * (in e1000_config_fc_after_link_up) we will disable the
  9161. + *hw's ability to send PAUSE frames.
  9162. + */
  9163. + mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  9164. + break;
  9165. + case e1000_fc_tx_pause: /* 2 */
  9166. + /* TX Flow control is enabled, and RX Flow control is
  9167. + * disabled, by a software over-ride.
  9168. + */
  9169. + mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR;
  9170. + mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE;
  9171. + break;
  9172. + case e1000_fc_full: /* 3 */
  9173. + /* Flow control (both RX and TX) is enabled by a software
  9174. + * over-ride.
  9175. + */
  9176. + mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  9177. + break;
  9178. + default:
  9179. + DEBUGOUT("Flow control param set incorrectly\n");
  9180. + return -E1000_ERR_CONFIG;
  9181. + }
  9182. +
  9183. + if((ret_val = e1000_write_phy_reg(hw, PHY_AUTONEG_ADV,
  9184. + mii_autoneg_adv_reg)))
  9185. + return ret_val;
  9186. +
  9187. + DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
  9188. +
  9189. + if((ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg)))
  9190. + return ret_val;
  9191. +
  9192. + return E1000_SUCCESS;
  9193. +}
  9194. +
  9195. +/******************************************************************************
  9196. +* Sets the collision distance in the Transmit Control register
  9197. +*
  9198. +* hw - Struct containing variables accessed by shared code
  9199. +*
  9200. +* Link should have been established previously. Reads the speed and duplex
  9201. +* information from the Device Status register.
  9202. +******************************************************************************/
  9203. +static void
  9204. +e1000_config_collision_dist(struct e1000_hw *hw)
  9205. +{
  9206. + uint32_t tctl;
  9207. +
  9208. + tctl = E1000_READ_REG(hw, TCTL);
  9209. +
  9210. + tctl &= ~E1000_TCTL_COLD;
  9211. + tctl |= E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT;
  9212. +
  9213. + E1000_WRITE_REG(hw, TCTL, tctl);
  9214. + E1000_WRITE_FLUSH(hw);
  9215. +}
  9216. +
  9217. +/******************************************************************************
  9218. +* Sets MAC speed and duplex settings to reflect the those in the PHY
  9219. +*
  9220. +* hw - Struct containing variables accessed by shared code
  9221. +* mii_reg - data to write to the MII control register
  9222. +*
  9223. +* The contents of the PHY register containing the needed information need to
  9224. +* be passed in.
  9225. +******************************************************************************/
  9226. +static int
  9227. +e1000_config_mac_to_phy(struct e1000_hw *hw)
  9228. +{
  9229. + uint32_t ctrl;
  9230. + int32_t ret_val;
  9231. + uint16_t phy_data;
  9232. +
  9233. + DEBUGFUNC("e1000_config_mac_to_phy");
  9234. +
  9235. + /* Read the Device Control Register and set the bits to Force Speed
  9236. + * and Duplex.
  9237. + */
  9238. + ctrl = E1000_READ_REG(hw, CTRL);
  9239. + ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  9240. + ctrl &= ~(E1000_CTRL_SPD_SEL | E1000_CTRL_ILOS);
  9241. +
  9242. + /* Set up duplex in the Device Control and Transmit Control
  9243. + * registers depending on negotiated values.
  9244. + */
  9245. + if (hw->phy_type == e1000_phy_igp) {
  9246. + if((ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS,
  9247. + &phy_data)))
  9248. + return ret_val;
  9249. +
  9250. + if(phy_data & IGP01E1000_PSSR_FULL_DUPLEX) ctrl |= E1000_CTRL_FD;
  9251. + else ctrl &= ~E1000_CTRL_FD;
  9252. +
  9253. + e1000_config_collision_dist(hw);
  9254. +
  9255. + /* Set up speed in the Device Control register depending on
  9256. + * negotiated values.
  9257. + */
  9258. + if((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
  9259. + IGP01E1000_PSSR_SPEED_1000MBPS)
  9260. + ctrl |= E1000_CTRL_SPD_1000;
  9261. + else if((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
  9262. + IGP01E1000_PSSR_SPEED_100MBPS)
  9263. + ctrl |= E1000_CTRL_SPD_100;
  9264. + } else {
  9265. + if((ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
  9266. + &phy_data)))
  9267. + return ret_val;
  9268. +
  9269. + if(phy_data & M88E1000_PSSR_DPLX) ctrl |= E1000_CTRL_FD;
  9270. + else ctrl &= ~E1000_CTRL_FD;
  9271. +
  9272. + e1000_config_collision_dist(hw);
  9273. +
  9274. + /* Set up speed in the Device Control register depending on
  9275. + * negotiated values.
  9276. + */
  9277. + if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)
  9278. + ctrl |= E1000_CTRL_SPD_1000;
  9279. + else if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS)
  9280. + ctrl |= E1000_CTRL_SPD_100;
  9281. + }
  9282. + /* Write the configured values back to the Device Control Reg. */
  9283. + E1000_WRITE_REG(hw, CTRL, ctrl);
  9284. + return E1000_SUCCESS;
  9285. +}
  9286. +
  9287. +/******************************************************************************
  9288. + * Forces the MAC's flow control settings.
  9289. + *
  9290. + * hw - Struct containing variables accessed by shared code
  9291. + *
  9292. + * Sets the TFCE and RFCE bits in the device control register to reflect
  9293. + * the adapter settings. TFCE and RFCE need to be explicitly set by
  9294. + * software when a Copper PHY is used because autonegotiation is managed
  9295. + * by the PHY rather than the MAC. Software must also configure these
  9296. + * bits when link is forced on a fiber connection.
  9297. + *****************************************************************************/
  9298. +static int
  9299. +e1000_force_mac_fc(struct e1000_hw *hw)
  9300. +{
  9301. + uint32_t ctrl;
  9302. +
  9303. + DEBUGFUNC("e1000_force_mac_fc");
  9304. +
  9305. + /* Get the current configuration of the Device Control Register */
  9306. + ctrl = E1000_READ_REG(hw, CTRL);
  9307. +
  9308. + /* Because we didn't get link via the internal auto-negotiation
  9309. + * mechanism (we either forced link or we got link via PHY
  9310. + * auto-neg), we have to manually enable/disable transmit an
  9311. + * receive flow control.
  9312. + *
  9313. + * The "Case" statement below enables/disable flow control
  9314. + * according to the "hw->fc" parameter.
  9315. + *
  9316. + * The possible values of the "fc" parameter are:
  9317. + * 0: Flow control is completely disabled
  9318. + * 1: Rx flow control is enabled (we can receive pause
  9319. + * frames but not send pause frames).
  9320. + * 2: Tx flow control is enabled (we can send pause frames
  9321. + * frames but we do not receive pause frames).
  9322. + * 3: Both Rx and TX flow control (symmetric) is enabled.
  9323. + * other: No other values should be possible at this point.
  9324. + */
  9325. +
  9326. + switch (hw->fc) {
  9327. + case e1000_fc_none:
  9328. + ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE));
  9329. + break;
  9330. + case e1000_fc_rx_pause:
  9331. + ctrl &= (~E1000_CTRL_TFCE);
  9332. + ctrl |= E1000_CTRL_RFCE;
  9333. + break;
  9334. + case e1000_fc_tx_pause:
  9335. + ctrl &= (~E1000_CTRL_RFCE);
  9336. + ctrl |= E1000_CTRL_TFCE;
  9337. + break;
  9338. + case e1000_fc_full:
  9339. + ctrl |= (E1000_CTRL_TFCE | E1000_CTRL_RFCE);
  9340. + break;
  9341. + default:
  9342. + DEBUGOUT("Flow control param set incorrectly\n");
  9343. + return -E1000_ERR_CONFIG;
  9344. + }
  9345. +
  9346. + /* Disable TX Flow Control for 82542 (rev 2.0) */
  9347. + if(hw->mac_type == e1000_82542_rev2_0)
  9348. + ctrl &= (~E1000_CTRL_TFCE);
  9349. +
  9350. + E1000_WRITE_REG(hw, CTRL, ctrl);
  9351. + return E1000_SUCCESS;
  9352. +}
  9353. +
  9354. +/******************************************************************************
  9355. + * Configures flow control settings after link is established
  9356. + *
  9357. + * hw - Struct containing variables accessed by shared code
  9358. + *
  9359. + * Should be called immediately after a valid link has been established.
  9360. + * Forces MAC flow control settings if link was forced. When in MII/GMII mode
  9361. + * and autonegotiation is enabled, the MAC flow control settings will be set
  9362. + * based on the flow control negotiated by the PHY. In TBI mode, the TFCE
  9363. + * and RFCE bits will be automaticaly set to the negotiated flow control mode.
  9364. + *****************************************************************************/
  9365. +static int
  9366. +e1000_config_fc_after_link_up(struct e1000_hw *hw)
  9367. +{
  9368. + int32_t ret_val;
  9369. + uint16_t mii_status_reg;
  9370. + uint16_t mii_nway_adv_reg;
  9371. + uint16_t mii_nway_lp_ability_reg;
  9372. + uint16_t speed;
  9373. + uint16_t duplex;
  9374. +
  9375. + DEBUGFUNC("e1000_config_fc_after_link_up");
  9376. +
  9377. + /* Check for the case where we have fiber media and auto-neg failed
  9378. + * so we had to force link. In this case, we need to force the
  9379. + * configuration of the MAC to match the "fc" parameter.
  9380. + */
  9381. + if(((hw->media_type == e1000_media_type_fiber) && (hw->autoneg_failed)) ||
  9382. + ((hw->media_type == e1000_media_type_internal_serdes) && (hw->autoneg_failed))) {
  9383. + if((ret_val = e1000_force_mac_fc(hw))) {
  9384. + DEBUGOUT("Error forcing flow control settings\n");
  9385. + return ret_val;
  9386. + }
  9387. + }
  9388. +
  9389. + /* Check for the case where we have copper media and auto-neg is
  9390. + * enabled. In this case, we need to check and see if Auto-Neg
  9391. + * has completed, and if so, how the PHY and link partner has
  9392. + * flow control configured.
  9393. + */
  9394. + if(hw->media_type == e1000_media_type_copper) {
  9395. + /* Read the MII Status Register and check to see if AutoNeg
  9396. + * has completed. We read this twice because this reg has
  9397. + * some "sticky" (latched) bits.
  9398. + */
  9399. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg)))
  9400. + return ret_val;
  9401. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg)))
  9402. + return ret_val;
  9403. +
  9404. + if(mii_status_reg & MII_SR_AUTONEG_COMPLETE) {
  9405. + /* The AutoNeg process has completed, so we now need to
  9406. + * read both the Auto Negotiation Advertisement Register
  9407. + * (Address 4) and the Auto_Negotiation Base Page Ability
  9408. + * Register (Address 5) to determine how flow control was
  9409. + * negotiated.
  9410. + */
  9411. + if((ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV,
  9412. + &mii_nway_adv_reg)))
  9413. + return ret_val;
  9414. + if((ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY,
  9415. + &mii_nway_lp_ability_reg)))
  9416. + return ret_val;
  9417. +
  9418. + /* Two bits in the Auto Negotiation Advertisement Register
  9419. + * (Address 4) and two bits in the Auto Negotiation Base
  9420. + * Page Ability Register (Address 5) determine flow control
  9421. + * for both the PHY and the link partner. The following
  9422. + * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
  9423. + * 1999, describes these PAUSE resolution bits and how flow
  9424. + * control is determined based upon these settings.
  9425. + * NOTE: DC = Don't Care
  9426. + *
  9427. + * LOCAL DEVICE | LINK PARTNER
  9428. + * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
  9429. + *-------|---------|-------|---------|--------------------
  9430. + * 0 | 0 | DC | DC | e1000_fc_none
  9431. + * 0 | 1 | 0 | DC | e1000_fc_none
  9432. + * 0 | 1 | 1 | 0 | e1000_fc_none
  9433. + * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
  9434. + * 1 | 0 | 0 | DC | e1000_fc_none
  9435. + * 1 | DC | 1 | DC | e1000_fc_full
  9436. + * 1 | 1 | 0 | 0 | e1000_fc_none
  9437. + * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
  9438. + *
  9439. + */
  9440. + /* Are both PAUSE bits set to 1? If so, this implies
  9441. + * Symmetric Flow Control is enabled at both ends. The
  9442. + * ASM_DIR bits are irrelevant per the spec.
  9443. + *
  9444. + * For Symmetric Flow Control:
  9445. + *
  9446. + * LOCAL DEVICE | LINK PARTNER
  9447. + * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
  9448. + *-------|---------|-------|---------|--------------------
  9449. + * 1 | DC | 1 | DC | e1000_fc_full
  9450. + *
  9451. + */
  9452. + if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
  9453. + (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) {
  9454. + /* Now we need to check if the user selected RX ONLY
  9455. + * of pause frames. In this case, we had to advertise
  9456. + * FULL flow control because we could not advertise RX
  9457. + * ONLY. Hence, we must now check to see if we need to
  9458. + * turn OFF the TRANSMISSION of PAUSE frames.
  9459. + */
  9460. +#if 0
  9461. + if(hw->original_fc == e1000_fc_full) {
  9462. + hw->fc = e1000_fc_full;
  9463. +#else
  9464. + if(hw->fc == e1000_fc_full) {
  9465. +#endif
  9466. + DEBUGOUT("Flow Control = FULL.\r\n");
  9467. + } else {
  9468. + hw->fc = e1000_fc_rx_pause;
  9469. + DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n");
  9470. + }
  9471. + }
  9472. + /* For receiving PAUSE frames ONLY.
  9473. + *
  9474. + * LOCAL DEVICE | LINK PARTNER
  9475. + * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
  9476. + *-------|---------|-------|---------|--------------------
  9477. + * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
  9478. + *
  9479. + */
  9480. + else if(!(mii_nway_adv_reg & NWAY_AR_PAUSE) &&
  9481. + (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
  9482. + (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
  9483. + (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
  9484. + hw->fc = e1000_fc_tx_pause;
  9485. + DEBUGOUT("Flow Control = TX PAUSE frames only.\r\n");
  9486. + }
  9487. + /* For transmitting PAUSE frames ONLY.
  9488. + *
  9489. + * LOCAL DEVICE | LINK PARTNER
  9490. + * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
  9491. + *-------|---------|-------|---------|--------------------
  9492. + * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
  9493. + *
  9494. + */
  9495. + else if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
  9496. + (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
  9497. + !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
  9498. + (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
  9499. + hw->fc = e1000_fc_rx_pause;
  9500. + DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n");
  9501. + }
  9502. + /* Per the IEEE spec, at this point flow control should be
  9503. + * disabled. However, we want to consider that we could
  9504. + * be connected to a legacy switch that doesn't advertise
  9505. + * desired flow control, but can be forced on the link
  9506. + * partner. So if we advertised no flow control, that is
  9507. + * what we will resolve to. If we advertised some kind of
  9508. + * receive capability (Rx Pause Only or Full Flow Control)
  9509. + * and the link partner advertised none, we will configure
  9510. + * ourselves to enable Rx Flow Control only. We can do
  9511. + * this safely for two reasons: If the link partner really
  9512. + * didn't want flow control enabled, and we enable Rx, no
  9513. + * harm done since we won't be receiving any PAUSE frames
  9514. + * anyway. If the intent on the link partner was to have
  9515. + * flow control enabled, then by us enabling RX only, we
  9516. + * can at least receive pause frames and process them.
  9517. + * This is a good idea because in most cases, since we are
  9518. + * predominantly a server NIC, more times than not we will
  9519. + * be asked to delay transmission of packets than asking
  9520. + * our link partner to pause transmission of frames.
  9521. + */
  9522. +#if 0
  9523. + else if(hw->original_fc == e1000_fc_none ||
  9524. + hw->original_fc == e1000_fc_tx_pause) {
  9525. +#else
  9526. + else if(hw->fc == e1000_fc_none)
  9527. + DEBUGOUT("Flow Control = NONE.\r\n");
  9528. + else if(hw->fc == e1000_fc_tx_pause) {
  9529. +#endif
  9530. + hw->fc = e1000_fc_none;
  9531. + DEBUGOUT("Flow Control = NONE.\r\n");
  9532. + } else {
  9533. + hw->fc = e1000_fc_rx_pause;
  9534. + DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n");
  9535. + }
  9536. +
  9537. + /* Now we need to do one last check... If we auto-
  9538. + * negotiated to HALF DUPLEX, flow control should not be
  9539. + * enabled per IEEE 802.3 spec.
  9540. + */
  9541. + e1000_get_speed_and_duplex(hw, &speed, &duplex);
  9542. +
  9543. + if(duplex == HALF_DUPLEX)
  9544. + hw->fc = e1000_fc_none;
  9545. +
  9546. + /* Now we call a subroutine to actually force the MAC
  9547. + * controller to use the correct flow control settings.
  9548. + */
  9549. + if((ret_val = e1000_force_mac_fc(hw))) {
  9550. + DEBUGOUT("Error forcing flow control settings\n");
  9551. + return ret_val;
  9552. + }
  9553. + } else {
  9554. + DEBUGOUT("Copper PHY and Auto Neg has not completed.\r\n");
  9555. + }
  9556. + }
  9557. + return E1000_SUCCESS;
  9558. +}
  9559. +
  9560. +/******************************************************************************
  9561. + * Checks to see if the link status of the hardware has changed.
  9562. + *
  9563. + * hw - Struct containing variables accessed by shared code
  9564. + *
  9565. + * Called by any function that needs to check the link status of the adapter.
  9566. + *****************************************************************************/
  9567. +static int
  9568. +e1000_check_for_link(struct e1000_hw *hw)
  9569. +{
  9570. + uint32_t rxcw;
  9571. + uint32_t ctrl;
  9572. + uint32_t status;
  9573. + uint32_t rctl;
  9574. + uint32_t signal = 0;
  9575. + int32_t ret_val;
  9576. + uint16_t phy_data;
  9577. + uint16_t lp_capability;
  9578. +
  9579. + DEBUGFUNC("e1000_check_for_link");
  9580. +
  9581. + /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
  9582. + * set when the optics detect a signal. On older adapters, it will be
  9583. + * cleared when there is a signal. This applies to fiber media only.
  9584. + */
  9585. + if(hw->media_type == e1000_media_type_fiber)
  9586. + signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
  9587. +
  9588. + ctrl = E1000_READ_REG(hw, CTRL);
  9589. + status = E1000_READ_REG(hw, STATUS);
  9590. + rxcw = E1000_READ_REG(hw, RXCW);
  9591. +
  9592. + /* If we have a copper PHY then we only want to go out to the PHY
  9593. + * registers to see if Auto-Neg has completed and/or if our link
  9594. + * status has changed. The get_link_status flag will be set if we
  9595. + * receive a Link Status Change interrupt or we have Rx Sequence
  9596. + * Errors.
  9597. + */
  9598. +#if 0
  9599. + if((hw->media_type == e1000_media_type_copper) && hw->get_link_status) {
  9600. +#else
  9601. + if(hw->media_type == e1000_media_type_copper) {
  9602. +#endif
  9603. + /* First we want to see if the MII Status Register reports
  9604. + * link. If so, then we want to get the current speed/duplex
  9605. + * of the PHY.
  9606. + * Read the register twice since the link bit is sticky.
  9607. + */
  9608. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  9609. + return ret_val;
  9610. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  9611. + return ret_val;
  9612. +
  9613. + if(phy_data & MII_SR_LINK_STATUS) {
  9614. +#if 0
  9615. + hw->get_link_status = FALSE;
  9616. +#endif
  9617. + } else {
  9618. + /* No link detected */
  9619. + return -E1000_ERR_NOLINK;
  9620. + }
  9621. +
  9622. + /* We have a M88E1000 PHY and Auto-Neg is enabled. If we
  9623. + * have Si on board that is 82544 or newer, Auto
  9624. + * Speed Detection takes care of MAC speed/duplex
  9625. + * configuration. So we only need to configure Collision
  9626. + * Distance in the MAC. Otherwise, we need to force
  9627. + * speed/duplex on the MAC to the current PHY speed/duplex
  9628. + * settings.
  9629. + */
  9630. + if(hw->mac_type >= e1000_82544)
  9631. + e1000_config_collision_dist(hw);
  9632. + else {
  9633. + if((ret_val = e1000_config_mac_to_phy(hw))) {
  9634. + DEBUGOUT("Error configuring MAC to PHY settings\n");
  9635. + return ret_val;
  9636. + }
  9637. + }
  9638. +
  9639. + /* Configure Flow Control now that Auto-Neg has completed. First, we
  9640. + * need to restore the desired flow control settings because we may
  9641. + * have had to re-autoneg with a different link partner.
  9642. + */
  9643. + if((ret_val = e1000_config_fc_after_link_up(hw))) {
  9644. + DEBUGOUT("Error configuring flow control\n");
  9645. + return ret_val;
  9646. + }
  9647. +
  9648. + /* At this point we know that we are on copper and we have
  9649. + * auto-negotiated link. These are conditions for checking the link
  9650. + * parter capability register. We use the link partner capability to
  9651. + * determine if TBI Compatibility needs to be turned on or off. If
  9652. + * the link partner advertises any speed in addition to Gigabit, then
  9653. + * we assume that they are GMII-based, and TBI compatibility is not
  9654. + * needed. If no other speeds are advertised, we assume the link
  9655. + * partner is TBI-based, and we turn on TBI Compatibility.
  9656. + */
  9657. + if(hw->tbi_compatibility_en) {
  9658. + if((ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY,
  9659. + &lp_capability)))
  9660. + return ret_val;
  9661. + if(lp_capability & (NWAY_LPAR_10T_HD_CAPS |
  9662. + NWAY_LPAR_10T_FD_CAPS |
  9663. + NWAY_LPAR_100TX_HD_CAPS |
  9664. + NWAY_LPAR_100TX_FD_CAPS |
  9665. + NWAY_LPAR_100T4_CAPS)) {
  9666. + /* If our link partner advertises anything in addition to
  9667. + * gigabit, we do not need to enable TBI compatibility.
  9668. + */
  9669. + if(hw->tbi_compatibility_on) {
  9670. + /* If we previously were in the mode, turn it off. */
  9671. + rctl = E1000_READ_REG(hw, RCTL);
  9672. + rctl &= ~E1000_RCTL_SBP;
  9673. + E1000_WRITE_REG(hw, RCTL, rctl);
  9674. + hw->tbi_compatibility_on = FALSE;
  9675. + }
  9676. + } else {
  9677. + /* If TBI compatibility is was previously off, turn it on. For
  9678. + * compatibility with a TBI link partner, we will store bad
  9679. + * packets. Some frames have an additional byte on the end and
  9680. + * will look like CRC errors to to the hardware.
  9681. + */
  9682. + if(!hw->tbi_compatibility_on) {
  9683. + hw->tbi_compatibility_on = TRUE;
  9684. + rctl = E1000_READ_REG(hw, RCTL);
  9685. + rctl |= E1000_RCTL_SBP;
  9686. + E1000_WRITE_REG(hw, RCTL, rctl);
  9687. + }
  9688. + }
  9689. + }
  9690. + }
  9691. + /* If we don't have link (auto-negotiation failed or link partner cannot
  9692. + * auto-negotiate), the cable is plugged in (we have signal), and our
  9693. + * link partner is not trying to auto-negotiate with us (we are receiving
  9694. + * idles or data), we need to force link up. We also need to give
  9695. + * auto-negotiation time to complete, in case the cable was just plugged
  9696. + * in. The autoneg_failed flag does this.
  9697. + */
  9698. + else if((((hw->media_type == e1000_media_type_fiber) &&
  9699. + ((ctrl & E1000_CTRL_SWDPIN1) == signal)) ||
  9700. + (hw->media_type == e1000_media_type_internal_serdes)) &&
  9701. + (!(status & E1000_STATUS_LU)) &&
  9702. + (!(rxcw & E1000_RXCW_C))) {
  9703. + if(hw->autoneg_failed == 0) {
  9704. + hw->autoneg_failed = 1;
  9705. + return 0;
  9706. + }
  9707. + DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\r\n");
  9708. +
  9709. + /* Disable auto-negotiation in the TXCW register */
  9710. + E1000_WRITE_REG(hw, TXCW, (hw->txcw & ~E1000_TXCW_ANE));
  9711. +
  9712. + /* Force link-up and also force full-duplex. */
  9713. + ctrl = E1000_READ_REG(hw, CTRL);
  9714. + ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
  9715. + E1000_WRITE_REG(hw, CTRL, ctrl);
  9716. +
  9717. + /* Configure Flow Control after forcing link up. */
  9718. + if((ret_val = e1000_config_fc_after_link_up(hw))) {
  9719. + DEBUGOUT("Error configuring flow control\n");
  9720. + return ret_val;
  9721. + }
  9722. + }
  9723. + /* If we are forcing link and we are receiving /C/ ordered sets, re-enable
  9724. + * auto-negotiation in the TXCW register and disable forced link in the
  9725. + * Device Control register in an attempt to auto-negotiate with our link
  9726. + * partner.
  9727. + */
  9728. + else if(((hw->media_type == e1000_media_type_fiber) ||
  9729. + (hw->media_type == e1000_media_type_internal_serdes)) &&
  9730. + (ctrl & E1000_CTRL_SLU) &&
  9731. + (rxcw & E1000_RXCW_C)) {
  9732. + DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\r\n");
  9733. + E1000_WRITE_REG(hw, TXCW, hw->txcw);
  9734. + E1000_WRITE_REG(hw, CTRL, (ctrl & ~E1000_CTRL_SLU));
  9735. + }
  9736. +#if 0
  9737. + /* If we force link for non-auto-negotiation switch, check link status
  9738. + * based on MAC synchronization for internal serdes media type.
  9739. + */
  9740. + else if((hw->media_type == e1000_media_type_internal_serdes) &&
  9741. + !(E1000_TXCW_ANE & E1000_READ_REG(hw, TXCW))) {
  9742. + /* SYNCH bit and IV bit are sticky. */
  9743. + udelay(10);
  9744. + if(E1000_RXCW_SYNCH & E1000_READ_REG(hw, RXCW)) {
  9745. + if(!(rxcw & E1000_RXCW_IV)) {
  9746. + hw->serdes_link_down = FALSE;
  9747. + DEBUGOUT("SERDES: Link is up.\n");
  9748. + }
  9749. + } else {
  9750. + hw->serdes_link_down = TRUE;
  9751. + DEBUGOUT("SERDES: Link is down.\n");
  9752. + }
  9753. + }
  9754. +#endif
  9755. + return E1000_SUCCESS;
  9756. +}
  9757. +
  9758. +/******************************************************************************
  9759. + * Detects the current speed and duplex settings of the hardware.
  9760. + *
  9761. + * hw - Struct containing variables accessed by shared code
  9762. + * speed - Speed of the connection
  9763. + * duplex - Duplex setting of the connection
  9764. + *****************************************************************************/
  9765. +static void
  9766. +e1000_get_speed_and_duplex(struct e1000_hw *hw,
  9767. + uint16_t *speed,
  9768. + uint16_t *duplex)
  9769. +{
  9770. + uint32_t status;
  9771. +
  9772. + DEBUGFUNC("e1000_get_speed_and_duplex");
  9773. +
  9774. + if(hw->mac_type >= e1000_82543) {
  9775. + status = E1000_READ_REG(hw, STATUS);
  9776. + if(status & E1000_STATUS_SPEED_1000) {
  9777. + *speed = SPEED_1000;
  9778. + DEBUGOUT("1000 Mbs, ");
  9779. + } else if(status & E1000_STATUS_SPEED_100) {
  9780. + *speed = SPEED_100;
  9781. + DEBUGOUT("100 Mbs, ");
  9782. + } else {
  9783. + *speed = SPEED_10;
  9784. + DEBUGOUT("10 Mbs, ");
  9785. + }
  9786. +
  9787. + if(status & E1000_STATUS_FD) {
  9788. + *duplex = FULL_DUPLEX;
  9789. + DEBUGOUT("Full Duplex\r\n");
  9790. + } else {
  9791. + *duplex = HALF_DUPLEX;
  9792. + DEBUGOUT(" Half Duplex\r\n");
  9793. + }
  9794. + } else {
  9795. + DEBUGOUT("1000 Mbs, Full Duplex\r\n");
  9796. + *speed = SPEED_1000;
  9797. + *duplex = FULL_DUPLEX;
  9798. + }
  9799. +}
  9800. +
  9801. +/******************************************************************************
  9802. +* Blocks until autoneg completes or times out (~4.5 seconds)
  9803. +*
  9804. +* hw - Struct containing variables accessed by shared code
  9805. +******************************************************************************/
  9806. +static int
  9807. +e1000_wait_autoneg(struct e1000_hw *hw)
  9808. +{
  9809. + int32_t ret_val;
  9810. + uint16_t i;
  9811. + uint16_t phy_data;
  9812. +
  9813. + DEBUGFUNC("e1000_wait_autoneg");
  9814. + DEBUGOUT("Waiting for Auto-Neg to complete.\n");
  9815. +
  9816. + /* We will wait for autoneg to complete or 4.5 seconds to expire. */
  9817. + for(i = PHY_AUTO_NEG_TIME; i > 0; i--) {
  9818. + /* Read the MII Status Register and wait for Auto-Neg
  9819. + * Complete bit to be set.
  9820. + */
  9821. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  9822. + return ret_val;
  9823. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  9824. + return ret_val;
  9825. + if(phy_data & MII_SR_AUTONEG_COMPLETE) {
  9826. + DEBUGOUT("Auto-Neg complete.\n");
  9827. + return E1000_SUCCESS;
  9828. + }
  9829. + mdelay(100);
  9830. + }
  9831. + DEBUGOUT("Auto-Neg timedout.\n");
  9832. + return -E1000_ERR_TIMEOUT;
  9833. +}
  9834. +
  9835. +/******************************************************************************
  9836. +* Raises the Management Data Clock
  9837. +*
  9838. +* hw - Struct containing variables accessed by shared code
  9839. +* ctrl - Device control register's current value
  9840. +******************************************************************************/
  9841. +static void
  9842. +e1000_raise_mdi_clk(struct e1000_hw *hw,
  9843. + uint32_t *ctrl)
  9844. +{
  9845. + /* Raise the clock input to the Management Data Clock (by setting the MDC
  9846. + * bit), and then delay 10 microseconds.
  9847. + */
  9848. + E1000_WRITE_REG(hw, CTRL, (*ctrl | E1000_CTRL_MDC));
  9849. + E1000_WRITE_FLUSH(hw);
  9850. + udelay(10);
  9851. +}
  9852. +
  9853. +/******************************************************************************
  9854. +* Lowers the Management Data Clock
  9855. +*
  9856. +* hw - Struct containing variables accessed by shared code
  9857. +* ctrl - Device control register's current value
  9858. +******************************************************************************/
  9859. +static void
  9860. +e1000_lower_mdi_clk(struct e1000_hw *hw,
  9861. + uint32_t *ctrl)
  9862. +{
  9863. + /* Lower the clock input to the Management Data Clock (by clearing the MDC
  9864. + * bit), and then delay 10 microseconds.
  9865. + */
  9866. + E1000_WRITE_REG(hw, CTRL, (*ctrl & ~E1000_CTRL_MDC));
  9867. + E1000_WRITE_FLUSH(hw);
  9868. + udelay(10);
  9869. +}
  9870. +
  9871. +/******************************************************************************
  9872. +* Shifts data bits out to the PHY
  9873. +*
  9874. +* hw - Struct containing variables accessed by shared code
  9875. +* data - Data to send out to the PHY
  9876. +* count - Number of bits to shift out
  9877. +*
  9878. +* Bits are shifted out in MSB to LSB order.
  9879. +******************************************************************************/
  9880. +static void
  9881. +e1000_shift_out_mdi_bits(struct e1000_hw *hw,
  9882. + uint32_t data,
  9883. + uint16_t count)
  9884. +{
  9885. + uint32_t ctrl;
  9886. + uint32_t mask;
  9887. +
  9888. + /* We need to shift "count" number of bits out to the PHY. So, the value
  9889. + * in the "data" parameter will be shifted out to the PHY one bit at a
  9890. + * time. In order to do this, "data" must be broken down into bits.
  9891. + */
  9892. + mask = 0x01;
  9893. + mask <<= (count - 1);
  9894. +
  9895. + ctrl = E1000_READ_REG(hw, CTRL);
  9896. +
  9897. + /* Set MDIO_DIR and MDC_DIR direction bits to be used as output pins. */
  9898. + ctrl |= (E1000_CTRL_MDIO_DIR | E1000_CTRL_MDC_DIR);
  9899. +
  9900. + while(mask) {
  9901. + /* A "1" is shifted out to the PHY by setting the MDIO bit to "1" and
  9902. + * then raising and lowering the Management Data Clock. A "0" is
  9903. + * shifted out to the PHY by setting the MDIO bit to "0" and then
  9904. + * raising and lowering the clock.
  9905. + */
  9906. + if(data & mask) ctrl |= E1000_CTRL_MDIO;
  9907. + else ctrl &= ~E1000_CTRL_MDIO;
  9908. +
  9909. + E1000_WRITE_REG(hw, CTRL, ctrl);
  9910. + E1000_WRITE_FLUSH(hw);
  9911. +
  9912. + udelay(10);
  9913. +
  9914. + e1000_raise_mdi_clk(hw, &ctrl);
  9915. + e1000_lower_mdi_clk(hw, &ctrl);
  9916. +
  9917. + mask = mask >> 1;
  9918. + }
  9919. +}
  9920. +
  9921. +/******************************************************************************
  9922. +* Shifts data bits in from the PHY
  9923. +*
  9924. +* hw - Struct containing variables accessed by shared code
  9925. +*
  9926. +* Bits are shifted in in MSB to LSB order.
  9927. +******************************************************************************/
  9928. +static uint16_t
  9929. +e1000_shift_in_mdi_bits(struct e1000_hw *hw)
  9930. +{
  9931. + uint32_t ctrl;
  9932. + uint16_t data = 0;
  9933. + uint8_t i;
  9934. +
  9935. + /* In order to read a register from the PHY, we need to shift in a total
  9936. + * of 18 bits from the PHY. The first two bit (turnaround) times are used
  9937. + * to avoid contention on the MDIO pin when a read operation is performed.
  9938. + * These two bits are ignored by us and thrown away. Bits are "shifted in"
  9939. + * by raising the input to the Management Data Clock (setting the MDC bit),
  9940. + * and then reading the value of the MDIO bit.
  9941. + */
  9942. + ctrl = E1000_READ_REG(hw, CTRL);
  9943. +
  9944. + /* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as input. */
  9945. + ctrl &= ~E1000_CTRL_MDIO_DIR;
  9946. + ctrl &= ~E1000_CTRL_MDIO;
  9947. +
  9948. + E1000_WRITE_REG(hw, CTRL, ctrl);
  9949. + E1000_WRITE_FLUSH(hw);
  9950. +
  9951. + /* Raise and Lower the clock before reading in the data. This accounts for
  9952. + * the turnaround bits. The first clock occurred when we clocked out the
  9953. + * last bit of the Register Address.
  9954. + */
  9955. + e1000_raise_mdi_clk(hw, &ctrl);
  9956. + e1000_lower_mdi_clk(hw, &ctrl);
  9957. +
  9958. + for(data = 0, i = 0; i < 16; i++) {
  9959. + data = data << 1;
  9960. + e1000_raise_mdi_clk(hw, &ctrl);
  9961. + ctrl = E1000_READ_REG(hw, CTRL);
  9962. + /* Check to see if we shifted in a "1". */
  9963. + if(ctrl & E1000_CTRL_MDIO) data |= 1;
  9964. + e1000_lower_mdi_clk(hw, &ctrl);
  9965. + }
  9966. +
  9967. + e1000_raise_mdi_clk(hw, &ctrl);
  9968. + e1000_lower_mdi_clk(hw, &ctrl);
  9969. +
  9970. + return data;
  9971. +}
  9972. +
  9973. +/*****************************************************************************
  9974. +* Reads the value from a PHY register, if the value is on a specific non zero
  9975. +* page, sets the page first.
  9976. +*
  9977. +* hw - Struct containing variables accessed by shared code
  9978. +* reg_addr - address of the PHY register to read
  9979. +******************************************************************************/
  9980. +static int
  9981. +e1000_read_phy_reg(struct e1000_hw *hw,
  9982. + uint32_t reg_addr,
  9983. + uint16_t *phy_data)
  9984. +{
  9985. + uint32_t ret_val;
  9986. +
  9987. + DEBUGFUNC("e1000_read_phy_reg");
  9988. +
  9989. + if(hw->phy_type == e1000_phy_igp &&
  9990. + (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
  9991. + if((ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
  9992. + (uint16_t)reg_addr)))
  9993. + return ret_val;
  9994. + }
  9995. +
  9996. + ret_val = e1000_read_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT & reg_addr,
  9997. + phy_data);
  9998. +
  9999. + return ret_val;
  10000. +}
  10001. +
  10002. +static int
  10003. +e1000_read_phy_reg_ex(struct e1000_hw *hw,
  10004. + uint32_t reg_addr,
  10005. + uint16_t *phy_data)
  10006. +{
  10007. + uint32_t i;
  10008. + uint32_t mdic = 0;
  10009. + const uint32_t phy_addr = 1;
  10010. +
  10011. + DEBUGFUNC("e1000_read_phy_reg_ex");
  10012. +
  10013. + if(reg_addr > MAX_PHY_REG_ADDRESS) {
  10014. + DEBUGOUT1("PHY Address %d is out of range\n", reg_addr);
  10015. + return -E1000_ERR_PARAM;
  10016. + }
  10017. +
  10018. + if(hw->mac_type > e1000_82543) {
  10019. + /* Set up Op-code, Phy Address, and register address in the MDI
  10020. + * Control register. The MAC will take care of interfacing with the
  10021. + * PHY to retrieve the desired data.
  10022. + */
  10023. + mdic = ((reg_addr << E1000_MDIC_REG_SHIFT) |
  10024. + (phy_addr << E1000_MDIC_PHY_SHIFT) |
  10025. + (E1000_MDIC_OP_READ));
  10026. +
  10027. + E1000_WRITE_REG(hw, MDIC, mdic);
  10028. +
  10029. + /* Poll the ready bit to see if the MDI read completed */
  10030. + for(i = 0; i < 64; i++) {
  10031. + udelay(50);
  10032. + mdic = E1000_READ_REG(hw, MDIC);
  10033. + if(mdic & E1000_MDIC_READY) break;
  10034. + }
  10035. + if(!(mdic & E1000_MDIC_READY)) {
  10036. + DEBUGOUT("MDI Read did not complete\n");
  10037. + return -E1000_ERR_PHY;
  10038. + }
  10039. + if(mdic & E1000_MDIC_ERROR) {
  10040. + DEBUGOUT("MDI Error\n");
  10041. + return -E1000_ERR_PHY;
  10042. + }
  10043. + *phy_data = (uint16_t) mdic;
  10044. + } else {
  10045. + /* We must first send a preamble through the MDIO pin to signal the
  10046. + * beginning of an MII instruction. This is done by sending 32
  10047. + * consecutive "1" bits.
  10048. + */
  10049. + e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
  10050. +
  10051. + /* Now combine the next few fields that are required for a read
  10052. + * operation. We use this method instead of calling the
  10053. + * e1000_shift_out_mdi_bits routine five different times. The format of
  10054. + * a MII read instruction consists of a shift out of 14 bits and is
  10055. + * defined as follows:
  10056. + * <Preamble><SOF><Op Code><Phy Addr><Reg Addr>
  10057. + * followed by a shift in of 18 bits. This first two bits shifted in
  10058. + * are TurnAround bits used to avoid contention on the MDIO pin when a
  10059. + * READ operation is performed. These two bits are thrown away
  10060. + * followed by a shift in of 16 bits which contains the desired data.
  10061. + */
  10062. + mdic = ((reg_addr) | (phy_addr << 5) |
  10063. + (PHY_OP_READ << 10) | (PHY_SOF << 12));
  10064. +
  10065. + e1000_shift_out_mdi_bits(hw, mdic, 14);
  10066. +
  10067. + /* Now that we've shifted out the read command to the MII, we need to
  10068. + * "shift in" the 16-bit value (18 total bits) of the requested PHY
  10069. + * register address.
  10070. + */
  10071. + *phy_data = e1000_shift_in_mdi_bits(hw);
  10072. + }
  10073. + return E1000_SUCCESS;
  10074. +}
  10075. +
  10076. +/******************************************************************************
  10077. +* Writes a value to a PHY register
  10078. +*
  10079. +* hw - Struct containing variables accessed by shared code
  10080. +* reg_addr - address of the PHY register to write
  10081. +* data - data to write to the PHY
  10082. +******************************************************************************/
  10083. +static int
  10084. +e1000_write_phy_reg(struct e1000_hw *hw,
  10085. + uint32_t reg_addr,
  10086. + uint16_t phy_data)
  10087. +{
  10088. + uint32_t ret_val;
  10089. +
  10090. + DEBUGFUNC("e1000_write_phy_reg");
  10091. +
  10092. + if(hw->phy_type == e1000_phy_igp &&
  10093. + (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
  10094. + if((ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
  10095. + (uint16_t)reg_addr)))
  10096. + return ret_val;
  10097. + }
  10098. +
  10099. + ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT & reg_addr,
  10100. + phy_data);
  10101. +
  10102. + return ret_val;
  10103. +}
  10104. +
  10105. +static int
  10106. +e1000_write_phy_reg_ex(struct e1000_hw *hw,
  10107. + uint32_t reg_addr,
  10108. + uint16_t phy_data)
  10109. +{
  10110. + uint32_t i;
  10111. + uint32_t mdic = 0;
  10112. + const uint32_t phy_addr = 1;
  10113. +
  10114. + DEBUGFUNC("e1000_write_phy_reg_ex");
  10115. +
  10116. + if(reg_addr > MAX_PHY_REG_ADDRESS) {
  10117. + DEBUGOUT1("PHY Address %d is out of range\n", reg_addr);
  10118. + return -E1000_ERR_PARAM;
  10119. + }
  10120. +
  10121. + if(hw->mac_type > e1000_82543) {
  10122. + /* Set up Op-code, Phy Address, register address, and data intended
  10123. + * for the PHY register in the MDI Control register. The MAC will take
  10124. + * care of interfacing with the PHY to send the desired data.
  10125. + */
  10126. + mdic = (((uint32_t) phy_data) |
  10127. + (reg_addr << E1000_MDIC_REG_SHIFT) |
  10128. + (phy_addr << E1000_MDIC_PHY_SHIFT) |
  10129. + (E1000_MDIC_OP_WRITE));
  10130. +
  10131. + E1000_WRITE_REG(hw, MDIC, mdic);
  10132. +
  10133. + /* Poll the ready bit to see if the MDI read completed */
  10134. + for(i = 0; i < 640; i++) {
  10135. + udelay(5);
  10136. + mdic = E1000_READ_REG(hw, MDIC);
  10137. + if(mdic & E1000_MDIC_READY) break;
  10138. + }
  10139. + if(!(mdic & E1000_MDIC_READY)) {
  10140. + DEBUGOUT("MDI Write did not complete\n");
  10141. + return -E1000_ERR_PHY;
  10142. + }
  10143. + } else {
  10144. + /* We'll need to use the SW defined pins to shift the write command
  10145. + * out to the PHY. We first send a preamble to the PHY to signal the
  10146. + * beginning of the MII instruction. This is done by sending 32
  10147. + * consecutive "1" bits.
  10148. + */
  10149. + e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
  10150. +
  10151. + /* Now combine the remaining required fields that will indicate a
  10152. + * write operation. We use this method instead of calling the
  10153. + * e1000_shift_out_mdi_bits routine for each field in the command. The
  10154. + * format of a MII write instruction is as follows:
  10155. + * <Preamble><SOF><Op Code><Phy Addr><Reg Addr><Turnaround><Data>.
  10156. + */
  10157. + mdic = ((PHY_TURNAROUND) | (reg_addr << 2) | (phy_addr << 7) |
  10158. + (PHY_OP_WRITE << 12) | (PHY_SOF << 14));
  10159. + mdic <<= 16;
  10160. + mdic |= (uint32_t) phy_data;
  10161. +
  10162. + e1000_shift_out_mdi_bits(hw, mdic, 32);
  10163. + }
  10164. +
  10165. + return E1000_SUCCESS;
  10166. +}
  10167. +
  10168. +/******************************************************************************
  10169. +* Returns the PHY to the power-on reset state
  10170. +*
  10171. +* hw - Struct containing variables accessed by shared code
  10172. +******************************************************************************/
  10173. +static void
  10174. +e1000_phy_hw_reset(struct e1000_hw *hw)
  10175. +{
  10176. + uint32_t ctrl, ctrl_ext;
  10177. +
  10178. + DEBUGFUNC("e1000_phy_hw_reset");
  10179. +
  10180. + DEBUGOUT("Resetting Phy...\n");
  10181. +
  10182. + if(hw->mac_type > e1000_82543) {
  10183. + /* Read the device control register and assert the E1000_CTRL_PHY_RST
  10184. + * bit. Then, take it out of reset.
  10185. + */
  10186. + ctrl = E1000_READ_REG(hw, CTRL);
  10187. + E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST);
  10188. + E1000_WRITE_FLUSH(hw);
  10189. + mdelay(10);
  10190. + E1000_WRITE_REG(hw, CTRL, ctrl);
  10191. + E1000_WRITE_FLUSH(hw);
  10192. + } else {
  10193. + /* Read the Extended Device Control Register, assert the PHY_RESET_DIR
  10194. + * bit to put the PHY into reset. Then, take it out of reset.
  10195. + */
  10196. + ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
  10197. + ctrl_ext |= E1000_CTRL_EXT_SDP4_DIR;
  10198. + ctrl_ext &= ~E1000_CTRL_EXT_SDP4_DATA;
  10199. + E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  10200. + E1000_WRITE_FLUSH(hw);
  10201. + mdelay(10);
  10202. + ctrl_ext |= E1000_CTRL_EXT_SDP4_DATA;
  10203. + E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  10204. + E1000_WRITE_FLUSH(hw);
  10205. + }
  10206. + udelay(150);
  10207. +}
  10208. +
  10209. +/******************************************************************************
  10210. +* Resets the PHY
  10211. +*
  10212. +* hw - Struct containing variables accessed by shared code
  10213. +*
  10214. +* Sets bit 15 of the MII Control regiser
  10215. +******************************************************************************/
  10216. +static int
  10217. +e1000_phy_reset(struct e1000_hw *hw)
  10218. +{
  10219. + int32_t ret_val;
  10220. + uint16_t phy_data;
  10221. +
  10222. + DEBUGFUNC("e1000_phy_reset");
  10223. +
  10224. + if(hw->mac_type != e1000_82541_rev_2) {
  10225. + if((ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data)))
  10226. + return ret_val;
  10227. +
  10228. + phy_data |= MII_CR_RESET;
  10229. + if((ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data)))
  10230. + return ret_val;
  10231. +
  10232. + udelay(1);
  10233. + } else e1000_phy_hw_reset(hw);
  10234. +
  10235. + if(hw->phy_type == e1000_phy_igp)
  10236. + e1000_phy_init_script(hw);
  10237. +
  10238. + return E1000_SUCCESS;
  10239. +}
  10240. +
  10241. +/******************************************************************************
  10242. +* Probes the expected PHY address for known PHY IDs
  10243. +*
  10244. +* hw - Struct containing variables accessed by shared code
  10245. +******************************************************************************/
  10246. +static int
  10247. +e1000_detect_gig_phy(struct e1000_hw *hw)
  10248. +{
  10249. + int32_t phy_init_status, ret_val;
  10250. + uint16_t phy_id_high, phy_id_low;
  10251. + boolean_t match = FALSE;
  10252. +
  10253. + DEBUGFUNC("e1000_detect_gig_phy");
  10254. +
  10255. + /* Read the PHY ID Registers to identify which PHY is onboard. */
  10256. + if((ret_val = e1000_read_phy_reg(hw, PHY_ID1, &phy_id_high)))
  10257. + return ret_val;
  10258. +
  10259. + hw->phy_id = (uint32_t) (phy_id_high << 16);
  10260. + udelay(20);
  10261. + if((ret_val = e1000_read_phy_reg(hw, PHY_ID2, &phy_id_low)))
  10262. + return ret_val;
  10263. +
  10264. + hw->phy_id |= (uint32_t) (phy_id_low & PHY_REVISION_MASK);
  10265. +#ifdef LINUX_DRIVER
  10266. + hw->phy_revision = (uint32_t) phy_id_low & ~PHY_REVISION_MASK;
  10267. +#endif
  10268. +
  10269. + switch(hw->mac_type) {
  10270. + case e1000_82543:
  10271. + if(hw->phy_id == M88E1000_E_PHY_ID) match = TRUE;
  10272. + break;
  10273. + case e1000_82544:
  10274. + if(hw->phy_id == M88E1000_I_PHY_ID) match = TRUE;
  10275. + break;
  10276. + case e1000_82540:
  10277. + case e1000_82545:
  10278. + case e1000_82545_rev_3:
  10279. + case e1000_82546:
  10280. + case e1000_82546_rev_3:
  10281. + if(hw->phy_id == M88E1011_I_PHY_ID) match = TRUE;
  10282. + break;
  10283. + case e1000_82541:
  10284. + case e1000_82541_rev_2:
  10285. + case e1000_82547:
  10286. + case e1000_82547_rev_2:
  10287. + if(hw->phy_id == IGP01E1000_I_PHY_ID) match = TRUE;
  10288. + break;
  10289. + default:
  10290. + DEBUGOUT1("Invalid MAC type %d\n", hw->mac_type);
  10291. + return -E1000_ERR_CONFIG;
  10292. + }
  10293. + phy_init_status = e1000_set_phy_type(hw);
  10294. +
  10295. + if ((match) && (phy_init_status == E1000_SUCCESS)) {
  10296. + DEBUGOUT1("PHY ID 0x%X detected\n", hw->phy_id);
  10297. + return E1000_SUCCESS;
  10298. + }
  10299. + DEBUGOUT1("Invalid PHY ID 0x%X\n", hw->phy_id);
  10300. + return -E1000_ERR_PHY;
  10301. +}
  10302. +
  10303. +/******************************************************************************
  10304. + * Sets up eeprom variables in the hw struct. Must be called after mac_type
  10305. + * is configured.
  10306. + *
  10307. + * hw - Struct containing variables accessed by shared code
  10308. + *****************************************************************************/
  10309. +static void
  10310. +e1000_init_eeprom_params(struct e1000_hw *hw)
  10311. +{
  10312. + struct e1000_eeprom_info *eeprom = &hw->eeprom;
  10313. + uint32_t eecd = E1000_READ_REG(hw, EECD);
  10314. + uint16_t eeprom_size;
  10315. +
  10316. + DEBUGFUNC("e1000_init_eeprom_params");
  10317. +
  10318. + switch (hw->mac_type) {
  10319. + case e1000_82542_rev2_0:
  10320. + case e1000_82542_rev2_1:
  10321. + case e1000_82543:
  10322. + case e1000_82544:
  10323. + eeprom->type = e1000_eeprom_microwire;
  10324. + eeprom->word_size = 64;
  10325. + eeprom->opcode_bits = 3;
  10326. + eeprom->address_bits = 6;
  10327. + eeprom->delay_usec = 50;
  10328. + break;
  10329. + case e1000_82540:
  10330. + case e1000_82545:
  10331. + case e1000_82545_rev_3:
  10332. + case e1000_82546:
  10333. + case e1000_82546_rev_3:
  10334. + eeprom->type = e1000_eeprom_microwire;
  10335. + eeprom->opcode_bits = 3;
  10336. + eeprom->delay_usec = 50;
  10337. + if(eecd & E1000_EECD_SIZE) {
  10338. + eeprom->word_size = 256;
  10339. + eeprom->address_bits = 8;
  10340. + } else {
  10341. + eeprom->word_size = 64;
  10342. + eeprom->address_bits = 6;
  10343. + }
  10344. + break;
  10345. + case e1000_82541:
  10346. + case e1000_82541_rev_2:
  10347. + case e1000_82547:
  10348. + case e1000_82547_rev_2:
  10349. + if (eecd & E1000_EECD_TYPE) {
  10350. + eeprom->type = e1000_eeprom_spi;
  10351. + if (eecd & E1000_EECD_ADDR_BITS) {
  10352. + eeprom->page_size = 32;
  10353. + eeprom->address_bits = 16;
  10354. + } else {
  10355. + eeprom->page_size = 8;
  10356. + eeprom->address_bits = 8;
  10357. + }
  10358. + } else {
  10359. + eeprom->type = e1000_eeprom_microwire;
  10360. + eeprom->opcode_bits = 3;
  10361. + eeprom->delay_usec = 50;
  10362. + if (eecd & E1000_EECD_ADDR_BITS) {
  10363. + eeprom->word_size = 256;
  10364. + eeprom->address_bits = 8;
  10365. + } else {
  10366. + eeprom->word_size = 64;
  10367. + eeprom->address_bits = 6;
  10368. + }
  10369. + }
  10370. + break;
  10371. + default:
  10372. + eeprom->type = e1000_eeprom_spi;
  10373. + if (eecd & E1000_EECD_ADDR_BITS) {
  10374. + eeprom->page_size = 32;
  10375. + eeprom->address_bits = 16;
  10376. + } else {
  10377. + eeprom->page_size = 8;
  10378. + eeprom->address_bits = 8;
  10379. + }
  10380. + break;
  10381. + }
  10382. +
  10383. + if (eeprom->type == e1000_eeprom_spi) {
  10384. + eeprom->opcode_bits = 8;
  10385. + eeprom->delay_usec = 1;
  10386. + eeprom->word_size = 64;
  10387. + if (e1000_read_eeprom(hw, EEPROM_CFG, 1, &eeprom_size) == 0) {
  10388. + eeprom_size &= EEPROM_SIZE_MASK;
  10389. +
  10390. + switch (eeprom_size) {
  10391. + case EEPROM_SIZE_16KB:
  10392. + eeprom->word_size = 8192;
  10393. + break;
  10394. + case EEPROM_SIZE_8KB:
  10395. + eeprom->word_size = 4096;
  10396. + break;
  10397. + case EEPROM_SIZE_4KB:
  10398. + eeprom->word_size = 2048;
  10399. + break;
  10400. + case EEPROM_SIZE_2KB:
  10401. + eeprom->word_size = 1024;
  10402. + break;
  10403. + case EEPROM_SIZE_1KB:
  10404. + eeprom->word_size = 512;
  10405. + break;
  10406. + case EEPROM_SIZE_512B:
  10407. + eeprom->word_size = 256;
  10408. + break;
  10409. + case EEPROM_SIZE_128B:
  10410. + default:
  10411. + break;
  10412. + }
  10413. + }
  10414. + }
  10415. +}
  10416. +
  10417. +/**
  10418. + * e1000_reset - Reset the adapter
  10419. + */
  10420. +
  10421. +static int
  10422. +e1000_reset(struct e1000_hw *hw)
  10423. +{
  10424. + uint32_t pba;
  10425. + /* Repartition Pba for greater than 9k mtu
  10426. + * To take effect CTRL.RST is required.
  10427. + */
  10428. +
  10429. + if(hw->mac_type < e1000_82547) {
  10430. + pba = E1000_PBA_48K;
  10431. + } else {
  10432. + pba = E1000_PBA_30K;
  10433. + }
  10434. + E1000_WRITE_REG(hw, PBA, pba);
  10435. +
  10436. + /* flow control settings */
  10437. +#if 0
  10438. + hw->fc_high_water = FC_DEFAULT_HI_THRESH;
  10439. + hw->fc_low_water = FC_DEFAULT_LO_THRESH;
  10440. + hw->fc_pause_time = FC_DEFAULT_TX_TIMER;
  10441. + hw->fc_send_xon = 1;
  10442. + hw->fc = hw->original_fc;
  10443. +#endif
  10444. +
  10445. + e1000_reset_hw(hw);
  10446. + if(hw->mac_type >= e1000_82544)
  10447. + E1000_WRITE_REG(hw, WUC, 0);
  10448. + return e1000_init_hw(hw);
  10449. +}
  10450. +
  10451. +/**
  10452. + * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
  10453. + * @adapter: board private structure to initialize
  10454. + *
  10455. + * e1000_sw_init initializes the Adapter private data structure.
  10456. + * Fields are initialized based on PCI device information and
  10457. + * OS network device settings (MTU size).
  10458. + **/
  10459. +
  10460. +static int
  10461. +e1000_sw_init(struct pci_device *pdev, struct e1000_hw *hw)
  10462. +{
  10463. + int result;
  10464. +
  10465. + /* PCI config space info */
  10466. + pci_read_config_word(pdev, PCI_VENDOR_ID, &hw->vendor_id);
  10467. + pci_read_config_word(pdev, PCI_DEVICE_ID, &hw->device_id);
  10468. + pci_read_config_byte(pdev, PCI_REVISION, &hw->revision_id);
  10469. +#if 0
  10470. + pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID,
  10471. + &hw->subsystem_vendor_id);
  10472. + pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &hw->subsystem_id);
  10473. +#endif
  10474. +
  10475. + pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
  10476. +
  10477. + /* identify the MAC */
  10478. +
  10479. + result = e1000_set_mac_type(hw);
  10480. + if (result) {
  10481. + E1000_ERR("Unknown MAC Type\n");
  10482. + return result;
  10483. + }
  10484. +
  10485. + /* initialize eeprom parameters */
  10486. +
  10487. + e1000_init_eeprom_params(hw);
  10488. +
  10489. +#if 0
  10490. + if((hw->mac_type == e1000_82541) ||
  10491. + (hw->mac_type == e1000_82547) ||
  10492. + (hw->mac_type == e1000_82541_rev_2) ||
  10493. + (hw->mac_type == e1000_82547_rev_2))
  10494. + hw->phy_init_script = 1;
  10495. +#endif
  10496. +
  10497. + e1000_set_media_type(hw);
  10498. +
  10499. +#if 0
  10500. + if(hw->mac_type < e1000_82543)
  10501. + hw->report_tx_early = 0;
  10502. + else
  10503. + hw->report_tx_early = 1;
  10504. +
  10505. + hw->wait_autoneg_complete = FALSE;
  10506. +#endif
  10507. + hw->tbi_compatibility_en = TRUE;
  10508. +#if 0
  10509. + hw->adaptive_ifs = TRUE;
  10510. +
  10511. + /* Copper options */
  10512. +
  10513. + if(hw->media_type == e1000_media_type_copper) {
  10514. + hw->mdix = AUTO_ALL_MODES;
  10515. + hw->disable_polarity_correction = FALSE;
  10516. + hw->master_slave = E1000_MASTER_SLAVE;
  10517. + }
  10518. +#endif
  10519. + return E1000_SUCCESS;
  10520. +}
  10521. +
  10522. +static void fill_rx (void)
  10523. +{
  10524. + struct e1000_rx_desc *rd;
  10525. + rx_last = rx_tail;
  10526. + rd = rx_base + rx_tail;
  10527. + rx_tail = (rx_tail + 1) % 8;
  10528. + memset (rd, 0, 16);
  10529. + rd->buffer_addr = virt_to_bus(&packet);
  10530. + E1000_WRITE_REG (&hw, RDT, rx_tail);
  10531. +}
  10532. +
  10533. +static void init_descriptor (void)
  10534. +{
  10535. + unsigned long ptr;
  10536. + unsigned long tctl;
  10537. +
  10538. + ptr = virt_to_phys(tx_pool);
  10539. + if (ptr & 0xf)
  10540. + ptr = (ptr + 0x10) & (~0xf);
  10541. +
  10542. + tx_base = phys_to_virt(ptr);
  10543. +
  10544. + E1000_WRITE_REG (&hw, TDBAL, virt_to_bus(tx_base));
  10545. + E1000_WRITE_REG (&hw, TDBAH, 0);
  10546. + E1000_WRITE_REG (&hw, TDLEN, 128);
  10547. +
  10548. + /* Setup the HW Tx Head and Tail descriptor pointers */
  10549. +
  10550. + E1000_WRITE_REG (&hw, TDH, 0);
  10551. + E1000_WRITE_REG (&hw, TDT, 0);
  10552. + tx_tail = 0;
  10553. +
  10554. + /* Program the Transmit Control Register */
  10555. +
  10556. +#ifdef LINUX_DRIVER_TCTL
  10557. + tctl = E1000_READ_REG(&hw, TCTL);
  10558. +
  10559. + tctl &= ~E1000_TCTL_CT;
  10560. + tctl |= E1000_TCTL_EN | E1000_TCTL_PSP |
  10561. + (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
  10562. +#else
  10563. + tctl = E1000_TCTL_PSP | E1000_TCTL_EN |
  10564. + (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT) |
  10565. + (E1000_HDX_COLLISION_DISTANCE << E1000_COLD_SHIFT);
  10566. +#endif
  10567. +
  10568. + E1000_WRITE_REG (&hw, TCTL, tctl);
  10569. +
  10570. + e1000_config_collision_dist(&hw);
  10571. +
  10572. +
  10573. + rx_tail = 0;
  10574. + /* disable receive */
  10575. + E1000_WRITE_REG (&hw, RCTL, 0);
  10576. + ptr = virt_to_phys(rx_pool);
  10577. + if (ptr & 0xf)
  10578. + ptr = (ptr + 0x10) & (~0xf);
  10579. + rx_base = phys_to_virt(ptr);
  10580. +
  10581. + /* Setup the Base and Length of the Rx Descriptor Ring */
  10582. +
  10583. + E1000_WRITE_REG (&hw, RDBAL, virt_to_bus(rx_base));
  10584. + E1000_WRITE_REG (&hw, RDBAH, 0);
  10585. +
  10586. + E1000_WRITE_REG (&hw, RDLEN, 128);
  10587. +
  10588. + /* Setup the HW Rx Head and Tail Descriptor Pointers */
  10589. + E1000_WRITE_REG (&hw, RDH, 0);
  10590. + E1000_WRITE_REG (&hw, RDT, 0);
  10591. +
  10592. + E1000_WRITE_REG (&hw, RCTL,
  10593. + E1000_RCTL_EN |
  10594. + E1000_RCTL_BAM |
  10595. + E1000_RCTL_SZ_2048 |
  10596. + E1000_RCTL_MPE);
  10597. + fill_rx();
  10598. +}
  10599. +
  10600. +
  10601. +
  10602. +/**************************************************************************
  10603. +POLL - Wait for a frame
  10604. +***************************************************************************/
  10605. +static int
  10606. +e1000_poll (struct nic *nic, int retrieve)
  10607. +{
  10608. + /* return true if there's an ethernet packet ready to read */
  10609. + /* nic->packet should contain data on return */
  10610. + /* nic->packetlen should contain length of data */
  10611. + struct e1000_rx_desc *rd;
  10612. +
  10613. + rd = rx_base + rx_last;
  10614. + if (!rd->status & E1000_RXD_STAT_DD)
  10615. + return 0;
  10616. +
  10617. + if ( ! retrieve ) return 1;
  10618. +
  10619. + // printf("recv: packet %! -> %! len=%d \n", packet+6, packet,rd->Length);
  10620. + memcpy (nic->packet, packet, rd->length);
  10621. + nic->packetlen = rd->length;
  10622. + fill_rx ();
  10623. + return 1;
  10624. +}
  10625. +
  10626. +/**************************************************************************
  10627. +TRANSMIT - Transmit a frame
  10628. +***************************************************************************/
  10629. +static void
  10630. +e1000_transmit (struct nic *nic, const char *d, /* Destination */
  10631. + unsigned int type, /* Type */
  10632. + unsigned int size, /* size */
  10633. + const char *p) /* Packet */
  10634. +{
  10635. + /* send the packet to destination */
  10636. + struct eth_hdr {
  10637. + unsigned char dst_addr[ETH_ALEN];
  10638. + unsigned char src_addr[ETH_ALEN];
  10639. + unsigned short type;
  10640. + } hdr;
  10641. + struct e1000_tx_desc *txhd; /* header */
  10642. + struct e1000_tx_desc *txp; /* payload */
  10643. + DEBUGFUNC("send");
  10644. +
  10645. + memcpy (&hdr.dst_addr, d, ETH_ALEN);
  10646. + memcpy (&hdr.src_addr, nic->node_addr, ETH_ALEN);
  10647. +
  10648. + hdr.type = htons (type);
  10649. + txhd = tx_base + tx_tail;
  10650. + tx_tail = (tx_tail + 1) % 8;
  10651. + txp = tx_base + tx_tail;
  10652. + tx_tail = (tx_tail + 1) % 8;
  10653. +
  10654. + txhd->buffer_addr = virt_to_bus (&hdr);
  10655. + txhd->lower.data = sizeof (hdr);
  10656. + txhd->upper.data = 0;
  10657. +
  10658. + txp->buffer_addr = virt_to_bus(p);
  10659. + txp->lower.data = E1000_TXD_CMD_RPS | E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS | size;
  10660. + txp->upper.data = 0;
  10661. +
  10662. + E1000_WRITE_REG (&hw, TDT, tx_tail);
  10663. + while (!(txp->upper.data & E1000_TXD_STAT_DD)) {
  10664. + udelay(10); /* give the nic a chance to write to the register */
  10665. + poll_interruptions();
  10666. + }
  10667. + DEBUGFUNC("send end");
  10668. +}
  10669. +
  10670. +
  10671. +/**************************************************************************
  10672. +DISABLE - Turn off ethernet interface
  10673. +***************************************************************************/
  10674. +static void e1000_disable (struct dev *dev __unused)
  10675. +{
  10676. + /* Clear the transmit ring */
  10677. + E1000_WRITE_REG (&hw, TDH, 0);
  10678. + E1000_WRITE_REG (&hw, TDT, 0);
  10679. +
  10680. + /* Clear the receive ring */
  10681. + E1000_WRITE_REG (&hw, RDH, 0);
  10682. + E1000_WRITE_REG (&hw, RDT, 0);
  10683. +
  10684. + /* put the card in its initial state */
  10685. + E1000_WRITE_REG (&hw, CTRL, E1000_CTRL_RST);
  10686. +
  10687. + /* Turn off the ethernet interface */
  10688. + E1000_WRITE_REG (&hw, RCTL, 0);
  10689. + E1000_WRITE_REG (&hw, TCTL, 0);
  10690. + mdelay (10);
  10691. +
  10692. + /* Unmap my window to the device */
  10693. + iounmap(hw.hw_addr);
  10694. +}
  10695. +
  10696. +/**************************************************************************
  10697. +IRQ - Enable, Disable, or Force interrupts
  10698. +***************************************************************************/
  10699. +static void e1000_irq(struct nic *nic __unused, irq_action_t action __unused)
  10700. +{
  10701. + switch ( action ) {
  10702. + case DISABLE :
  10703. + break;
  10704. + case ENABLE :
  10705. + break;
  10706. + case FORCE :
  10707. + break;
  10708. + }
  10709. +}
  10710. +
  10711. +#define IORESOURCE_IO 0x00000100 /* Resource type */
  10712. +#define BAR_0 0
  10713. +#define BAR_1 1
  10714. +#define BAR_5 5
  10715. +
  10716. +/**************************************************************************
  10717. +PROBE - Look for an adapter, this routine's visible to the outside
  10718. +You should omit the last argument struct pci_device * for a non-PCI NIC
  10719. +***************************************************************************/
  10720. +static int e1000_probe(struct dev *dev, struct pci_device *p)
  10721. +{
  10722. + struct nic *nic = (struct nic *)dev;
  10723. + unsigned long mmio_start, mmio_len;
  10724. + int ret_val, i;
  10725. +
  10726. + if (p == 0)
  10727. + return 0;
  10728. + /* Initialize hw with default values */
  10729. + memset(&hw, 0, sizeof(hw));
  10730. + hw.pdev = p;
  10731. +
  10732. +#if 1
  10733. + /* Are these variables needed? */
  10734. + hw.fc = e1000_fc_none;
  10735. +#if 0
  10736. + hw.original_fc = e1000_fc_none;
  10737. +#endif
  10738. + hw.autoneg_failed = 0;
  10739. +#if 0
  10740. + hw.get_link_status = TRUE;
  10741. +#endif
  10742. +#endif
  10743. +
  10744. + mmio_start = pci_bar_start(p, PCI_BASE_ADDRESS_0);
  10745. + mmio_len = pci_bar_size(p, PCI_BASE_ADDRESS_0);
  10746. + hw.hw_addr = ioremap(mmio_start, mmio_len);
  10747. +
  10748. + for(i = BAR_1; i <= BAR_5; i++) {
  10749. + if(pci_bar_size(p, i) == 0)
  10750. + continue;
  10751. + if(pci_find_capability(p, i) & IORESOURCE_IO) {
  10752. + hw.io_base = pci_bar_start(p, i);
  10753. + break;
  10754. + }
  10755. + }
  10756. +
  10757. + adjust_pci_device(p);
  10758. +
  10759. + nic->ioaddr = p->ioaddr & ~3;
  10760. + nic->irqno = 0;
  10761. +
  10762. + /* From Matt Hortman <mbhortman@acpthinclient.com> */
  10763. + /* MAC and Phy settings */
  10764. +
  10765. + /* setup the private structure */
  10766. + if (e1000_sw_init(p, &hw) < 0) {
  10767. + iounmap(hw.hw_addr);
  10768. + return 0;
  10769. + }
  10770. +
  10771. + /* make sure the EEPROM is good */
  10772. +
  10773. + if (e1000_validate_eeprom_checksum(&hw) < 0) {
  10774. + printf ("The EEPROM Checksum Is Not Valid\n");
  10775. + iounmap(hw.hw_addr);
  10776. + return 0;
  10777. + }
  10778. +
  10779. + /* copy the MAC address out of the EEPROM */
  10780. +
  10781. + e1000_read_mac_addr(&hw);
  10782. + memcpy (nic->node_addr, hw.mac_addr, ETH_ALEN);
  10783. +
  10784. + printf("Ethernet addr: %!\n", nic->node_addr);
  10785. +
  10786. + /* reset the hardware with the new settings */
  10787. +
  10788. + ret_val = e1000_reset(&hw);
  10789. + if (ret_val < 0) {
  10790. + if ((ret_val == -E1000_ERR_NOLINK) ||
  10791. + (ret_val == -E1000_ERR_TIMEOUT)) {
  10792. + E1000_ERR("Valid Link not detected\n");
  10793. + } else {
  10794. + E1000_ERR("Hardware Initialization Failed\n");
  10795. + }
  10796. + iounmap(hw.hw_addr);
  10797. + return 0;
  10798. + }
  10799. + init_descriptor();
  10800. +
  10801. + /* point to NIC specific routines */
  10802. + dev->disable = e1000_disable;
  10803. + nic->poll = e1000_poll;
  10804. + nic->transmit = e1000_transmit;
  10805. + nic->irq = e1000_irq;
  10806. +
  10807. + return 1;
  10808. +}
  10809. +
  10810. +static struct pci_id e1000_nics[] = {
  10811. +PCI_ROM(0x8086, 0x1000, "e1000-82542", "Intel EtherExpressPro1000"),
  10812. +PCI_ROM(0x8086, 0x1001, "e1000-82543gc-fiber", "Intel EtherExpressPro1000 82543GC Fiber"),
  10813. +PCI_ROM(0x8086, 0x1004, "e1000-82543gc-copper", "Intel EtherExpressPro1000 82543GC Copper"),
  10814. +PCI_ROM(0x8086, 0x1008, "e1000-82544ei-copper", "Intel EtherExpressPro1000 82544EI Copper"),
  10815. +PCI_ROM(0x8086, 0x1009, "e1000-82544ei-fiber", "Intel EtherExpressPro1000 82544EI Fiber"),
  10816. +PCI_ROM(0x8086, 0x100C, "e1000-82544gc-copper", "Intel EtherExpressPro1000 82544GC Copper"),
  10817. +PCI_ROM(0x8086, 0x100D, "e1000-82544gc-lom", "Intel EtherExpressPro1000 82544GC LOM"),
  10818. +PCI_ROM(0x8086, 0x100E, "e1000-82540em", "Intel EtherExpressPro1000 82540EM"),
  10819. +PCI_ROM(0x8086, 0x100F, "e1000-82545em-copper", "Intel EtherExpressPro1000 82545EM Copper"),
  10820. +PCI_ROM(0x8086, 0x1010, "e1000-82546eb-copper", "Intel EtherExpressPro1000 82546EB Copper"),
  10821. +PCI_ROM(0x8086, 0x1011, "e1000-82545em-fiber", "Intel EtherExpressPro1000 82545EM Fiber"),
  10822. +PCI_ROM(0x8086, 0x1012, "e1000-82546eb-fiber", "Intel EtherExpressPro1000 82546EB Copper"),
  10823. +PCI_ROM(0x8086, 0x1013, "e1000-82541ei", "Intel EtherExpressPro1000 82541EI"),
  10824. +PCI_ROM(0x8086, 0x1015, "e1000-82540em-lom", "Intel EtherExpressPro1000 82540EM LOM"),
  10825. +PCI_ROM(0x8086, 0x1016, "e1000-82540ep-lom", "Intel EtherExpressPro1000 82540EP LOM"),
  10826. +PCI_ROM(0x8086, 0x1017, "e1000-82540ep", "Intel EtherExpressPro1000 82540EP"),
  10827. +PCI_ROM(0x8086, 0x1018, "e1000-82541ep", "Intel EtherExpressPro1000 82541EP"),
  10828. +PCI_ROM(0x8086, 0x1019, "e1000-82547ei", "Intel EtherExpressPro1000 82547EI"),
  10829. +PCI_ROM(0x8086, 0x101d, "e1000-82546eb-quad-copper", "Intel EtherExpressPro1000 82546EB Quad Copper"),
  10830. +PCI_ROM(0x8086, 0x101e, "e1000-82540ep-lp", "Intel EtherExpressPro1000 82540EP LP"),
  10831. +PCI_ROM(0x8086, 0x1026, "e1000-82545gm-copper", "Intel EtherExpressPro1000 82545GM Copper"),
  10832. +PCI_ROM(0x8086, 0x1027, "e1000-82545gm-fiber", "Intel EtherExpressPro1000 82545GM Fiber"),
  10833. +PCI_ROM(0x8086, 0x1028, "e1000-82545gm-serdes", "Intel EtherExpressPro1000 82545GM SERDES"),
  10834. +PCI_ROM(0x8086, 0x1075, "e1000-82547gi", "Intel EtherExpressPro1000 82547GI"),
  10835. +PCI_ROM(0x8086, 0x1076, "e1000-82541gi", "Intel EtherExpressPro1000 82541GI"),
  10836. +PCI_ROM(0x8086, 0x1077, "e1000-82541gi-mobile", "Intel EtherExpressPro1000 82541GI Mobile"),
  10837. +PCI_ROM(0x8086, 0x1078, "e1000-82541er", "Intel EtherExpressPro1000 82541ER"),
  10838. +PCI_ROM(0x8086, 0x1079, "e1000-82546gb-copper", "Intel EtherExpressPro1000 82546GB Copper"),
  10839. +PCI_ROM(0x8086, 0x107a, "e1000-82546gb-fiber", "Intel EtherExpressPro1000 82546GB Fiber"),
  10840. +PCI_ROM(0x8086, 0x107b, "e1000-82546gb-serdes", "Intel EtherExpressPro1000 82546GB SERDES"),
  10841. +};
  10842. +
  10843. +struct pci_driver e1000_driver = {
  10844. + .type = NIC_DRIVER,
  10845. + .name = "E1000",
  10846. + .probe = e1000_probe,
  10847. + .ids = e1000_nics,
  10848. + .id_count = sizeof(e1000_nics)/sizeof(e1000_nics[0]),
  10849. + .class = 0,
  10850. +};
  10851. Index: b/netboot/e1000_hw.h
  10852. ===================================================================
  10853. --- /dev/null
  10854. +++ b/netboot/e1000_hw.h
  10855. @@ -0,0 +1,2058 @@
  10856. +/*******************************************************************************
  10857. +
  10858. +
  10859. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
  10860. +
  10861. + This program is free software; you can redistribute it and/or modify it
  10862. + under the terms of the GNU General Public License as published by the Free
  10863. + Software Foundation; either version 2 of the License, or (at your option)
  10864. + any later version.
  10865. +
  10866. + This program is distributed in the hope that it will be useful, but WITHOUT
  10867. + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10868. + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10869. + more details.
  10870. +
  10871. + You should have received a copy of the GNU General Public License along with
  10872. + this program; if not, write to the Free Software Foundation, Inc., 59
  10873. + Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  10874. +
  10875. + The full GNU General Public License is included in this distribution in the
  10876. + file called LICENSE.
  10877. +
  10878. + Contact Information:
  10879. + Linux NICS <linux.nics@intel.com>
  10880. + Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  10881. +
  10882. +*******************************************************************************/
  10883. +
  10884. +/* e1000_hw.h
  10885. + * Structures, enums, and macros for the MAC
  10886. + */
  10887. +
  10888. +#ifndef _E1000_HW_H_
  10889. +#define _E1000_HW_H_
  10890. +
  10891. +/* Forward declarations of structures used by the shared code */
  10892. +struct e1000_hw;
  10893. +struct e1000_hw_stats;
  10894. +
  10895. +/* Enumerated types specific to the e1000 hardware */
  10896. +/* Media Access Controlers */
  10897. +typedef enum {
  10898. + e1000_undefined = 0,
  10899. + e1000_82542_rev2_0,
  10900. + e1000_82542_rev2_1,
  10901. + e1000_82543,
  10902. + e1000_82544,
  10903. + e1000_82540,
  10904. + e1000_82545,
  10905. + e1000_82545_rev_3,
  10906. + e1000_82546,
  10907. + e1000_82546_rev_3,
  10908. + e1000_82541,
  10909. + e1000_82541_rev_2,
  10910. + e1000_82547,
  10911. + e1000_82547_rev_2,
  10912. + e1000_num_macs
  10913. +} e1000_mac_type;
  10914. +
  10915. +typedef enum {
  10916. + e1000_eeprom_uninitialized = 0,
  10917. + e1000_eeprom_spi,
  10918. + e1000_eeprom_microwire,
  10919. + e1000_num_eeprom_types
  10920. +} e1000_eeprom_type;
  10921. +
  10922. +/* Media Types */
  10923. +typedef enum {
  10924. + e1000_media_type_copper = 0,
  10925. + e1000_media_type_fiber = 1,
  10926. + e1000_media_type_internal_serdes = 2,
  10927. + e1000_num_media_types
  10928. +} e1000_media_type;
  10929. +
  10930. +typedef enum {
  10931. + e1000_10_half = 0,
  10932. + e1000_10_full = 1,
  10933. + e1000_100_half = 2,
  10934. + e1000_100_full = 3
  10935. +} e1000_speed_duplex_type;
  10936. +
  10937. +/* Flow Control Settings */
  10938. +typedef enum {
  10939. + e1000_fc_none = 0,
  10940. + e1000_fc_rx_pause = 1,
  10941. + e1000_fc_tx_pause = 2,
  10942. + e1000_fc_full = 3,
  10943. + e1000_fc_default = 0xFF
  10944. +} e1000_fc_type;
  10945. +
  10946. +/* PCI bus types */
  10947. +typedef enum {
  10948. + e1000_bus_type_unknown = 0,
  10949. + e1000_bus_type_pci,
  10950. + e1000_bus_type_pcix,
  10951. + e1000_bus_type_reserved
  10952. +} e1000_bus_type;
  10953. +
  10954. +/* PCI bus speeds */
  10955. +typedef enum {
  10956. + e1000_bus_speed_unknown = 0,
  10957. + e1000_bus_speed_33,
  10958. + e1000_bus_speed_66,
  10959. + e1000_bus_speed_100,
  10960. + e1000_bus_speed_120,
  10961. + e1000_bus_speed_133,
  10962. + e1000_bus_speed_reserved
  10963. +} e1000_bus_speed;
  10964. +
  10965. +/* PCI bus widths */
  10966. +typedef enum {
  10967. + e1000_bus_width_unknown = 0,
  10968. + e1000_bus_width_32,
  10969. + e1000_bus_width_64,
  10970. + e1000_bus_width_reserved
  10971. +} e1000_bus_width;
  10972. +
  10973. +/* PHY status info structure and supporting enums */
  10974. +typedef enum {
  10975. + e1000_cable_length_50 = 0,
  10976. + e1000_cable_length_50_80,
  10977. + e1000_cable_length_80_110,
  10978. + e1000_cable_length_110_140,
  10979. + e1000_cable_length_140,
  10980. + e1000_cable_length_undefined = 0xFF
  10981. +} e1000_cable_length;
  10982. +
  10983. +typedef enum {
  10984. + e1000_igp_cable_length_10 = 10,
  10985. + e1000_igp_cable_length_20 = 20,
  10986. + e1000_igp_cable_length_30 = 30,
  10987. + e1000_igp_cable_length_40 = 40,
  10988. + e1000_igp_cable_length_50 = 50,
  10989. + e1000_igp_cable_length_60 = 60,
  10990. + e1000_igp_cable_length_70 = 70,
  10991. + e1000_igp_cable_length_80 = 80,
  10992. + e1000_igp_cable_length_90 = 90,
  10993. + e1000_igp_cable_length_100 = 100,
  10994. + e1000_igp_cable_length_110 = 110,
  10995. + e1000_igp_cable_length_120 = 120,
  10996. + e1000_igp_cable_length_130 = 130,
  10997. + e1000_igp_cable_length_140 = 140,
  10998. + e1000_igp_cable_length_150 = 150,
  10999. + e1000_igp_cable_length_160 = 160,
  11000. + e1000_igp_cable_length_170 = 170,
  11001. + e1000_igp_cable_length_180 = 180
  11002. +} e1000_igp_cable_length;
  11003. +
  11004. +typedef enum {
  11005. + e1000_10bt_ext_dist_enable_normal = 0,
  11006. + e1000_10bt_ext_dist_enable_lower,
  11007. + e1000_10bt_ext_dist_enable_undefined = 0xFF
  11008. +} e1000_10bt_ext_dist_enable;
  11009. +
  11010. +typedef enum {
  11011. + e1000_rev_polarity_normal = 0,
  11012. + e1000_rev_polarity_reversed,
  11013. + e1000_rev_polarity_undefined = 0xFF
  11014. +} e1000_rev_polarity;
  11015. +
  11016. +typedef enum {
  11017. + e1000_downshift_normal = 0,
  11018. + e1000_downshift_activated,
  11019. + e1000_downshift_undefined = 0xFF
  11020. +} e1000_downshift;
  11021. +
  11022. +typedef enum {
  11023. + e1000_polarity_reversal_enabled = 0,
  11024. + e1000_polarity_reversal_disabled,
  11025. + e1000_polarity_reversal_undefined = 0xFF
  11026. +} e1000_polarity_reversal;
  11027. +
  11028. +typedef enum {
  11029. + e1000_auto_x_mode_manual_mdi = 0,
  11030. + e1000_auto_x_mode_manual_mdix,
  11031. + e1000_auto_x_mode_auto1,
  11032. + e1000_auto_x_mode_auto2,
  11033. + e1000_auto_x_mode_undefined = 0xFF
  11034. +} e1000_auto_x_mode;
  11035. +
  11036. +typedef enum {
  11037. + e1000_1000t_rx_status_not_ok = 0,
  11038. + e1000_1000t_rx_status_ok,
  11039. + e1000_1000t_rx_status_undefined = 0xFF
  11040. +} e1000_1000t_rx_status;
  11041. +
  11042. +typedef enum {
  11043. + e1000_phy_m88 = 0,
  11044. + e1000_phy_igp,
  11045. + e1000_phy_undefined = 0xFF
  11046. +} e1000_phy_type;
  11047. +
  11048. +typedef enum {
  11049. + e1000_ms_hw_default = 0,
  11050. + e1000_ms_force_master,
  11051. + e1000_ms_force_slave,
  11052. + e1000_ms_auto
  11053. +} e1000_ms_type;
  11054. +
  11055. +typedef enum {
  11056. + e1000_ffe_config_enabled = 0,
  11057. + e1000_ffe_config_active,
  11058. + e1000_ffe_config_blocked
  11059. +} e1000_ffe_config;
  11060. +
  11061. +typedef enum {
  11062. + e1000_dsp_config_disabled = 0,
  11063. + e1000_dsp_config_enabled,
  11064. + e1000_dsp_config_activated,
  11065. + e1000_dsp_config_undefined = 0xFF
  11066. +} e1000_dsp_config;
  11067. +
  11068. +struct e1000_phy_info {
  11069. + e1000_cable_length cable_length;
  11070. + e1000_10bt_ext_dist_enable extended_10bt_distance;
  11071. + e1000_rev_polarity cable_polarity;
  11072. + e1000_downshift downshift;
  11073. + e1000_polarity_reversal polarity_correction;
  11074. + e1000_auto_x_mode mdix_mode;
  11075. + e1000_1000t_rx_status local_rx;
  11076. + e1000_1000t_rx_status remote_rx;
  11077. +};
  11078. +
  11079. +struct e1000_phy_stats {
  11080. + uint32_t idle_errors;
  11081. + uint32_t receive_errors;
  11082. +};
  11083. +
  11084. +struct e1000_eeprom_info {
  11085. + e1000_eeprom_type type;
  11086. + uint16_t word_size;
  11087. + uint16_t opcode_bits;
  11088. + uint16_t address_bits;
  11089. + uint16_t delay_usec;
  11090. + uint16_t page_size;
  11091. +};
  11092. +
  11093. +
  11094. +
  11095. +/* Error Codes */
  11096. +#define E1000_SUCCESS 0
  11097. +#define E1000_ERR_EEPROM 1
  11098. +#define E1000_ERR_PHY 2
  11099. +#define E1000_ERR_CONFIG 3
  11100. +#define E1000_ERR_PARAM 4
  11101. +#define E1000_ERR_MAC_TYPE 5
  11102. +#define E1000_ERR_PHY_TYPE 6
  11103. +#define E1000_ERR_NOLINK 7
  11104. +#define E1000_ERR_TIMEOUT 8
  11105. +
  11106. +#define E1000_READ_REG_IO(a, reg) \
  11107. + e1000_read_reg_io((a), E1000_##reg)
  11108. +#define E1000_WRITE_REG_IO(a, reg, val) \
  11109. + e1000_write_reg_io((a), E1000_##reg, val)
  11110. +
  11111. +/* PCI Device IDs */
  11112. +#define E1000_DEV_ID_82542 0x1000
  11113. +#define E1000_DEV_ID_82543GC_FIBER 0x1001
  11114. +#define E1000_DEV_ID_82543GC_COPPER 0x1004
  11115. +#define E1000_DEV_ID_82544EI_COPPER 0x1008
  11116. +#define E1000_DEV_ID_82544EI_FIBER 0x1009
  11117. +#define E1000_DEV_ID_82544GC_COPPER 0x100C
  11118. +#define E1000_DEV_ID_82544GC_LOM 0x100D
  11119. +#define E1000_DEV_ID_82540EM 0x100E
  11120. +#define E1000_DEV_ID_82540EM_LOM 0x1015
  11121. +#define E1000_DEV_ID_82540EP_LOM 0x1016
  11122. +#define E1000_DEV_ID_82540EP 0x1017
  11123. +#define E1000_DEV_ID_82540EP_LP 0x101E
  11124. +#define E1000_DEV_ID_82545EM_COPPER 0x100F
  11125. +#define E1000_DEV_ID_82545EM_FIBER 0x1011
  11126. +#define E1000_DEV_ID_82545GM_COPPER 0x1026
  11127. +#define E1000_DEV_ID_82545GM_FIBER 0x1027
  11128. +#define E1000_DEV_ID_82545GM_SERDES 0x1028
  11129. +#define E1000_DEV_ID_82546EB_COPPER 0x1010
  11130. +#define E1000_DEV_ID_82546EB_FIBER 0x1012
  11131. +#define E1000_DEV_ID_82546EB_QUAD_COPPER 0x101D
  11132. +#define E1000_DEV_ID_82541EI 0x1013
  11133. +#define E1000_DEV_ID_82541EI_MOBILE 0x1018
  11134. +#define E1000_DEV_ID_82541ER 0x1078
  11135. +#define E1000_DEV_ID_82547GI 0x1075
  11136. +#define E1000_DEV_ID_82541GI 0x1076
  11137. +#define E1000_DEV_ID_82541GI_MOBILE 0x1077
  11138. +#define E1000_DEV_ID_82546GB_COPPER 0x1079
  11139. +#define E1000_DEV_ID_82546GB_FIBER 0x107A
  11140. +#define E1000_DEV_ID_82546GB_SERDES 0x107B
  11141. +#define E1000_DEV_ID_82547EI 0x1019
  11142. +
  11143. +#define NODE_ADDRESS_SIZE 6
  11144. +#define ETH_LENGTH_OF_ADDRESS 6
  11145. +
  11146. +/* MAC decode size is 128K - This is the size of BAR0 */
  11147. +#define MAC_DECODE_SIZE (128 * 1024)
  11148. +
  11149. +#define E1000_82542_2_0_REV_ID 2
  11150. +#define E1000_82542_2_1_REV_ID 3
  11151. +
  11152. +#define SPEED_10 10
  11153. +#define SPEED_100 100
  11154. +#define SPEED_1000 1000
  11155. +#define HALF_DUPLEX 1
  11156. +#define FULL_DUPLEX 2
  11157. +
  11158. +/* The sizes (in bytes) of a ethernet packet */
  11159. +#define ENET_HEADER_SIZE 14
  11160. +#define MAXIMUM_ETHERNET_FRAME_SIZE 1518 /* With FCS */
  11161. +#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */
  11162. +#define ETHERNET_FCS_SIZE 4
  11163. +#define MAXIMUM_ETHERNET_PACKET_SIZE \
  11164. + (MAXIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
  11165. +#define MINIMUM_ETHERNET_PACKET_SIZE \
  11166. + (MINIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
  11167. +#define CRC_LENGTH ETHERNET_FCS_SIZE
  11168. +#define MAX_JUMBO_FRAME_SIZE 0x3F00
  11169. +
  11170. +
  11171. +/* 802.1q VLAN Packet Sizes */
  11172. +#define VLAN_TAG_SIZE 4 /* 802.3ac tag (not DMAed) */
  11173. +
  11174. +/* Ethertype field values */
  11175. +#define ETHERNET_IEEE_VLAN_TYPE 0x8100 /* 802.3ac packet */
  11176. +#define ETHERNET_IP_TYPE 0x0800 /* IP packets */
  11177. +#define ETHERNET_ARP_TYPE 0x0806 /* Address Resolution Protocol (ARP) */
  11178. +
  11179. +/* Packet Header defines */
  11180. +#define IP_PROTOCOL_TCP 6
  11181. +#define IP_PROTOCOL_UDP 0x11
  11182. +
  11183. +/* This defines the bits that are set in the Interrupt Mask
  11184. + * Set/Read Register. Each bit is documented below:
  11185. + * o RXDMT0 = Receive Descriptor Minimum Threshold hit (ring 0)
  11186. + * o RXSEQ = Receive Sequence Error
  11187. + */
  11188. +#define POLL_IMS_ENABLE_MASK ( \
  11189. + E1000_IMS_RXDMT0 | \
  11190. + E1000_IMS_RXSEQ)
  11191. +
  11192. +/* This defines the bits that are set in the Interrupt Mask
  11193. + * Set/Read Register. Each bit is documented below:
  11194. + * o RXT0 = Receiver Timer Interrupt (ring 0)
  11195. + * o TXDW = Transmit Descriptor Written Back
  11196. + * o RXDMT0 = Receive Descriptor Minimum Threshold hit (ring 0)
  11197. + * o RXSEQ = Receive Sequence Error
  11198. + * o LSC = Link Status Change
  11199. + */
  11200. +#define IMS_ENABLE_MASK ( \
  11201. + E1000_IMS_RXT0 | \
  11202. + E1000_IMS_TXDW | \
  11203. + E1000_IMS_RXDMT0 | \
  11204. + E1000_IMS_RXSEQ | \
  11205. + E1000_IMS_LSC)
  11206. +
  11207. +/* Number of high/low register pairs in the RAR. The RAR (Receive Address
  11208. + * Registers) holds the directed and multicast addresses that we monitor. We
  11209. + * reserve one of these spots for our directed address, allowing us room for
  11210. + * E1000_RAR_ENTRIES - 1 multicast addresses.
  11211. + */
  11212. +#define E1000_RAR_ENTRIES 15
  11213. +
  11214. +#define MIN_NUMBER_OF_DESCRIPTORS 8
  11215. +#define MAX_NUMBER_OF_DESCRIPTORS 0xFFF8
  11216. +
  11217. +/* Receive Descriptor */
  11218. +struct e1000_rx_desc {
  11219. + uint64_t buffer_addr; /* Address of the descriptor's data buffer */
  11220. + uint16_t length; /* Length of data DMAed into data buffer */
  11221. + uint16_t csum; /* Packet checksum */
  11222. + uint8_t status; /* Descriptor status */
  11223. + uint8_t errors; /* Descriptor Errors */
  11224. + uint16_t special;
  11225. +};
  11226. +
  11227. +/* Receive Decriptor bit definitions */
  11228. +#define E1000_RXD_STAT_DD 0x01 /* Descriptor Done */
  11229. +#define E1000_RXD_STAT_EOP 0x02 /* End of Packet */
  11230. +#define E1000_RXD_STAT_IXSM 0x04 /* Ignore checksum */
  11231. +#define E1000_RXD_STAT_VP 0x08 /* IEEE VLAN Packet */
  11232. +#define E1000_RXD_STAT_TCPCS 0x20 /* TCP xsum calculated */
  11233. +#define E1000_RXD_STAT_IPCS 0x40 /* IP xsum calculated */
  11234. +#define E1000_RXD_STAT_PIF 0x80 /* passed in-exact filter */
  11235. +#define E1000_RXD_ERR_CE 0x01 /* CRC Error */
  11236. +#define E1000_RXD_ERR_SE 0x02 /* Symbol Error */
  11237. +#define E1000_RXD_ERR_SEQ 0x04 /* Sequence Error */
  11238. +#define E1000_RXD_ERR_CXE 0x10 /* Carrier Extension Error */
  11239. +#define E1000_RXD_ERR_TCPE 0x20 /* TCP/UDP Checksum Error */
  11240. +#define E1000_RXD_ERR_IPE 0x40 /* IP Checksum Error */
  11241. +#define E1000_RXD_ERR_RXE 0x80 /* Rx Data Error */
  11242. +#define E1000_RXD_SPC_VLAN_MASK 0x0FFF /* VLAN ID is in lower 12 bits */
  11243. +#define E1000_RXD_SPC_PRI_MASK 0xE000 /* Priority is in upper 3 bits */
  11244. +#define E1000_RXD_SPC_PRI_SHIFT 0x000D /* Priority is in upper 3 of 16 */
  11245. +#define E1000_RXD_SPC_CFI_MASK 0x1000 /* CFI is bit 12 */
  11246. +#define E1000_RXD_SPC_CFI_SHIFT 0x000C /* CFI is bit 12 */
  11247. +
  11248. +/* mask to determine if packets should be dropped due to frame errors */
  11249. +#define E1000_RXD_ERR_FRAME_ERR_MASK ( \
  11250. + E1000_RXD_ERR_CE | \
  11251. + E1000_RXD_ERR_SE | \
  11252. + E1000_RXD_ERR_SEQ | \
  11253. + E1000_RXD_ERR_CXE | \
  11254. + E1000_RXD_ERR_RXE)
  11255. +
  11256. +/* Transmit Descriptor */
  11257. +struct e1000_tx_desc {
  11258. + uint64_t buffer_addr; /* Address of the descriptor's data buffer */
  11259. + union {
  11260. + uint32_t data;
  11261. + struct {
  11262. + uint16_t length; /* Data buffer length */
  11263. + uint8_t cso; /* Checksum offset */
  11264. + uint8_t cmd; /* Descriptor control */
  11265. + } flags;
  11266. + } lower;
  11267. + union {
  11268. + uint32_t data;
  11269. + struct {
  11270. + uint8_t status; /* Descriptor status */
  11271. + uint8_t css; /* Checksum start */
  11272. + uint16_t special;
  11273. + } fields;
  11274. + } upper;
  11275. +};
  11276. +
  11277. +/* Transmit Descriptor bit definitions */
  11278. +#define E1000_TXD_DTYP_D 0x00100000 /* Data Descriptor */
  11279. +#define E1000_TXD_DTYP_C 0x00000000 /* Context Descriptor */
  11280. +#define E1000_TXD_POPTS_IXSM 0x01 /* Insert IP checksum */
  11281. +#define E1000_TXD_POPTS_TXSM 0x02 /* Insert TCP/UDP checksum */
  11282. +#define E1000_TXD_CMD_EOP 0x01000000 /* End of Packet */
  11283. +#define E1000_TXD_CMD_IFCS 0x02000000 /* Insert FCS (Ethernet CRC) */
  11284. +#define E1000_TXD_CMD_IC 0x04000000 /* Insert Checksum */
  11285. +#define E1000_TXD_CMD_RS 0x08000000 /* Report Status */
  11286. +#define E1000_TXD_CMD_RPS 0x10000000 /* Report Packet Sent */
  11287. +#define E1000_TXD_CMD_DEXT 0x20000000 /* Descriptor extension (0 = legacy) */
  11288. +#define E1000_TXD_CMD_VLE 0x40000000 /* Add VLAN tag */
  11289. +#define E1000_TXD_CMD_IDE 0x80000000 /* Enable Tidv register */
  11290. +#define E1000_TXD_STAT_DD 0x00000001 /* Descriptor Done */
  11291. +#define E1000_TXD_STAT_EC 0x00000002 /* Excess Collisions */
  11292. +#define E1000_TXD_STAT_LC 0x00000004 /* Late Collisions */
  11293. +#define E1000_TXD_STAT_TU 0x00000008 /* Transmit underrun */
  11294. +#define E1000_TXD_CMD_TCP 0x01000000 /* TCP packet */
  11295. +#define E1000_TXD_CMD_IP 0x02000000 /* IP packet */
  11296. +#define E1000_TXD_CMD_TSE 0x04000000 /* TCP Seg enable */
  11297. +#define E1000_TXD_STAT_TC 0x00000004 /* Tx Underrun */
  11298. +
  11299. +/* Offload Context Descriptor */
  11300. +struct e1000_context_desc {
  11301. + union {
  11302. + uint32_t ip_config;
  11303. + struct {
  11304. + uint8_t ipcss; /* IP checksum start */
  11305. + uint8_t ipcso; /* IP checksum offset */
  11306. + uint16_t ipcse; /* IP checksum end */
  11307. + } ip_fields;
  11308. + } lower_setup;
  11309. + union {
  11310. + uint32_t tcp_config;
  11311. + struct {
  11312. + uint8_t tucss; /* TCP checksum start */
  11313. + uint8_t tucso; /* TCP checksum offset */
  11314. + uint16_t tucse; /* TCP checksum end */
  11315. + } tcp_fields;
  11316. + } upper_setup;
  11317. + uint32_t cmd_and_length; /* */
  11318. + union {
  11319. + uint32_t data;
  11320. + struct {
  11321. + uint8_t status; /* Descriptor status */
  11322. + uint8_t hdr_len; /* Header length */
  11323. + uint16_t mss; /* Maximum segment size */
  11324. + } fields;
  11325. + } tcp_seg_setup;
  11326. +};
  11327. +
  11328. +/* Offload data descriptor */
  11329. +struct e1000_data_desc {
  11330. + uint64_t buffer_addr; /* Address of the descriptor's buffer address */
  11331. + union {
  11332. + uint32_t data;
  11333. + struct {
  11334. + uint16_t length; /* Data buffer length */
  11335. + uint8_t typ_len_ext; /* */
  11336. + uint8_t cmd; /* */
  11337. + } flags;
  11338. + } lower;
  11339. + union {
  11340. + uint32_t data;
  11341. + struct {
  11342. + uint8_t status; /* Descriptor status */
  11343. + uint8_t popts; /* Packet Options */
  11344. + uint16_t special; /* */
  11345. + } fields;
  11346. + } upper;
  11347. +};
  11348. +
  11349. +/* Filters */
  11350. +#define E1000_NUM_UNICAST 16 /* Unicast filter entries */
  11351. +#define E1000_MC_TBL_SIZE 128 /* Multicast Filter Table (4096 bits) */
  11352. +#define E1000_VLAN_FILTER_TBL_SIZE 128 /* VLAN Filter Table (4096 bits) */
  11353. +
  11354. +
  11355. +/* Receive Address Register */
  11356. +struct e1000_rar {
  11357. + volatile uint32_t low; /* receive address low */
  11358. + volatile uint32_t high; /* receive address high */
  11359. +};
  11360. +
  11361. +/* Number of entries in the Multicast Table Array (MTA). */
  11362. +#define E1000_NUM_MTA_REGISTERS 128
  11363. +
  11364. +/* IPv4 Address Table Entry */
  11365. +struct e1000_ipv4_at_entry {
  11366. + volatile uint32_t ipv4_addr; /* IP Address (RW) */
  11367. + volatile uint32_t reserved;
  11368. +};
  11369. +
  11370. +/* Four wakeup IP addresses are supported */
  11371. +#define E1000_WAKEUP_IP_ADDRESS_COUNT_MAX 4
  11372. +#define E1000_IP4AT_SIZE E1000_WAKEUP_IP_ADDRESS_COUNT_MAX
  11373. +#define E1000_IP6AT_SIZE 1
  11374. +
  11375. +/* IPv6 Address Table Entry */
  11376. +struct e1000_ipv6_at_entry {
  11377. + volatile uint8_t ipv6_addr[16];
  11378. +};
  11379. +
  11380. +/* Flexible Filter Length Table Entry */
  11381. +struct e1000_fflt_entry {
  11382. + volatile uint32_t length; /* Flexible Filter Length (RW) */
  11383. + volatile uint32_t reserved;
  11384. +};
  11385. +
  11386. +/* Flexible Filter Mask Table Entry */
  11387. +struct e1000_ffmt_entry {
  11388. + volatile uint32_t mask; /* Flexible Filter Mask (RW) */
  11389. + volatile uint32_t reserved;
  11390. +};
  11391. +
  11392. +/* Flexible Filter Value Table Entry */
  11393. +struct e1000_ffvt_entry {
  11394. + volatile uint32_t value; /* Flexible Filter Value (RW) */
  11395. + volatile uint32_t reserved;
  11396. +};
  11397. +
  11398. +/* Four Flexible Filters are supported */
  11399. +#define E1000_FLEXIBLE_FILTER_COUNT_MAX 4
  11400. +
  11401. +/* Each Flexible Filter is at most 128 (0x80) bytes in length */
  11402. +#define E1000_FLEXIBLE_FILTER_SIZE_MAX 128
  11403. +
  11404. +#define E1000_FFLT_SIZE E1000_FLEXIBLE_FILTER_COUNT_MAX
  11405. +#define E1000_FFMT_SIZE E1000_FLEXIBLE_FILTER_SIZE_MAX
  11406. +#define E1000_FFVT_SIZE E1000_FLEXIBLE_FILTER_SIZE_MAX
  11407. +
  11408. +/* Register Set. (82543, 82544)
  11409. + *
  11410. + * Registers are defined to be 32 bits and should be accessed as 32 bit values.
  11411. + * These registers are physically located on the NIC, but are mapped into the
  11412. + * host memory address space.
  11413. + *
  11414. + * RW - register is both readable and writable
  11415. + * RO - register is read only
  11416. + * WO - register is write only
  11417. + * R/clr - register is read only and is cleared when read
  11418. + * A - register array
  11419. + */
  11420. +#define E1000_CTRL 0x00000 /* Device Control - RW */
  11421. +#define E1000_CTRL_DUP 0x00004 /* Device Control Duplicate (Shadow) - RW */
  11422. +#define E1000_STATUS 0x00008 /* Device Status - RO */
  11423. +#define E1000_EECD 0x00010 /* EEPROM/Flash Control - RW */
  11424. +#define E1000_EERD 0x00014 /* EEPROM Read - RW */
  11425. +#define E1000_CTRL_EXT 0x00018 /* Extended Device Control - RW */
  11426. +#define E1000_FLA 0x0001C /* Flash Access - RW */
  11427. +#define E1000_MDIC 0x00020 /* MDI Control - RW */
  11428. +#define E1000_FCAL 0x00028 /* Flow Control Address Low - RW */
  11429. +#define E1000_FCAH 0x0002C /* Flow Control Address High -RW */
  11430. +#define E1000_FCT 0x00030 /* Flow Control Type - RW */
  11431. +#define E1000_VET 0x00038 /* VLAN Ether Type - RW */
  11432. +#define E1000_ICR 0x000C0 /* Interrupt Cause Read - R/clr */
  11433. +#define E1000_ITR 0x000C4 /* Interrupt Throttling Rate - RW */
  11434. +#define E1000_ICS 0x000C8 /* Interrupt Cause Set - WO */
  11435. +#define E1000_IMS 0x000D0 /* Interrupt Mask Set - RW */
  11436. +#define E1000_IMC 0x000D8 /* Interrupt Mask Clear - WO */
  11437. +#define E1000_RCTL 0x00100 /* RX Control - RW */
  11438. +#define E1000_FCTTV 0x00170 /* Flow Control Transmit Timer Value - RW */
  11439. +#define E1000_TXCW 0x00178 /* TX Configuration Word - RW */
  11440. +#define E1000_RXCW 0x00180 /* RX Configuration Word - RO */
  11441. +#define E1000_TCTL 0x00400 /* TX Control - RW */
  11442. +#define E1000_TIPG 0x00410 /* TX Inter-packet gap -RW */
  11443. +#define E1000_TBT 0x00448 /* TX Burst Timer - RW */
  11444. +#define E1000_AIT 0x00458 /* Adaptive Interframe Spacing Throttle - RW */
  11445. +#define E1000_LEDCTL 0x00E00 /* LED Control - RW */
  11446. +#define E1000_PBA 0x01000 /* Packet Buffer Allocation - RW */
  11447. +#define E1000_FCRTL 0x02160 /* Flow Control Receive Threshold Low - RW */
  11448. +#define E1000_FCRTH 0x02168 /* Flow Control Receive Threshold High - RW */
  11449. +#define E1000_RDBAL 0x02800 /* RX Descriptor Base Address Low - RW */
  11450. +#define E1000_RDBAH 0x02804 /* RX Descriptor Base Address High - RW */
  11451. +#define E1000_RDLEN 0x02808 /* RX Descriptor Length - RW */
  11452. +#define E1000_RDH 0x02810 /* RX Descriptor Head - RW */
  11453. +#define E1000_RDT 0x02818 /* RX Descriptor Tail - RW */
  11454. +#define E1000_RDTR 0x02820 /* RX Delay Timer - RW */
  11455. +#define E1000_RXDCTL 0x02828 /* RX Descriptor Control - RW */
  11456. +#define E1000_RADV 0x0282C /* RX Interrupt Absolute Delay Timer - RW */
  11457. +#define E1000_RSRPD 0x02C00 /* RX Small Packet Detect - RW */
  11458. +#define E1000_TXDMAC 0x03000 /* TX DMA Control - RW */
  11459. +#define E1000_TDFH 0x03410 /* TX Data FIFO Head - RW */
  11460. +#define E1000_TDFT 0x03418 /* TX Data FIFO Tail - RW */
  11461. +#define E1000_TDFHS 0x03420 /* TX Data FIFO Head Saved - RW */
  11462. +#define E1000_TDFTS 0x03428 /* TX Data FIFO Tail Saved - RW */
  11463. +#define E1000_TDFPC 0x03430 /* TX Data FIFO Packet Count - RW */
  11464. +#define E1000_TDBAL 0x03800 /* TX Descriptor Base Address Low - RW */
  11465. +#define E1000_TDBAH 0x03804 /* TX Descriptor Base Address High - RW */
  11466. +#define E1000_TDLEN 0x03808 /* TX Descriptor Length - RW */
  11467. +#define E1000_TDH 0x03810 /* TX Descriptor Head - RW */
  11468. +#define E1000_TDT 0x03818 /* TX Descripotr Tail - RW */
  11469. +#define E1000_TIDV 0x03820 /* TX Interrupt Delay Value - RW */
  11470. +#define E1000_TXDCTL 0x03828 /* TX Descriptor Control - RW */
  11471. +#define E1000_TADV 0x0382C /* TX Interrupt Absolute Delay Val - RW */
  11472. +#define E1000_TSPMT 0x03830 /* TCP Segmentation PAD & Min Threshold - RW */
  11473. +#define E1000_CRCERRS 0x04000 /* CRC Error Count - R/clr */
  11474. +#define E1000_ALGNERRC 0x04004 /* Alignment Error Count - R/clr */
  11475. +#define E1000_SYMERRS 0x04008 /* Symbol Error Count - R/clr */
  11476. +#define E1000_RXERRC 0x0400C /* Receive Error Count - R/clr */
  11477. +#define E1000_MPC 0x04010 /* Missed Packet Count - R/clr */
  11478. +#define E1000_SCC 0x04014 /* Single Collision Count - R/clr */
  11479. +#define E1000_ECOL 0x04018 /* Excessive Collision Count - R/clr */
  11480. +#define E1000_MCC 0x0401C /* Multiple Collision Count - R/clr */
  11481. +#define E1000_LATECOL 0x04020 /* Late Collision Count - R/clr */
  11482. +#define E1000_COLC 0x04028 /* Collision Count - R/clr */
  11483. +#define E1000_DC 0x04030 /* Defer Count - R/clr */
  11484. +#define E1000_TNCRS 0x04034 /* TX-No CRS - R/clr */
  11485. +#define E1000_SEC 0x04038 /* Sequence Error Count - R/clr */
  11486. +#define E1000_CEXTERR 0x0403C /* Carrier Extension Error Count - R/clr */
  11487. +#define E1000_RLEC 0x04040 /* Receive Length Error Count - R/clr */
  11488. +#define E1000_XONRXC 0x04048 /* XON RX Count - R/clr */
  11489. +#define E1000_XONTXC 0x0404C /* XON TX Count - R/clr */
  11490. +#define E1000_XOFFRXC 0x04050 /* XOFF RX Count - R/clr */
  11491. +#define E1000_XOFFTXC 0x04054 /* XOFF TX Count - R/clr */
  11492. +#define E1000_FCRUC 0x04058 /* Flow Control RX Unsupported Count- R/clr */
  11493. +#define E1000_PRC64 0x0405C /* Packets RX (64 bytes) - R/clr */
  11494. +#define E1000_PRC127 0x04060 /* Packets RX (65-127 bytes) - R/clr */
  11495. +#define E1000_PRC255 0x04064 /* Packets RX (128-255 bytes) - R/clr */
  11496. +#define E1000_PRC511 0x04068 /* Packets RX (255-511 bytes) - R/clr */
  11497. +#define E1000_PRC1023 0x0406C /* Packets RX (512-1023 bytes) - R/clr */
  11498. +#define E1000_PRC1522 0x04070 /* Packets RX (1024-1522 bytes) - R/clr */
  11499. +#define E1000_GPRC 0x04074 /* Good Packets RX Count - R/clr */
  11500. +#define E1000_BPRC 0x04078 /* Broadcast Packets RX Count - R/clr */
  11501. +#define E1000_MPRC 0x0407C /* Multicast Packets RX Count - R/clr */
  11502. +#define E1000_GPTC 0x04080 /* Good Packets TX Count - R/clr */
  11503. +#define E1000_GORCL 0x04088 /* Good Octets RX Count Low - R/clr */
  11504. +#define E1000_GORCH 0x0408C /* Good Octets RX Count High - R/clr */
  11505. +#define E1000_GOTCL 0x04090 /* Good Octets TX Count Low - R/clr */
  11506. +#define E1000_GOTCH 0x04094 /* Good Octets TX Count High - R/clr */
  11507. +#define E1000_RNBC 0x040A0 /* RX No Buffers Count - R/clr */
  11508. +#define E1000_RUC 0x040A4 /* RX Undersize Count - R/clr */
  11509. +#define E1000_RFC 0x040A8 /* RX Fragment Count - R/clr */
  11510. +#define E1000_ROC 0x040AC /* RX Oversize Count - R/clr */
  11511. +#define E1000_RJC 0x040B0 /* RX Jabber Count - R/clr */
  11512. +#define E1000_MGTPRC 0x040B4 /* Management Packets RX Count - R/clr */
  11513. +#define E1000_MGTPDC 0x040B8 /* Management Packets Dropped Count - R/clr */
  11514. +#define E1000_MGTPTC 0x040BC /* Management Packets TX Count - R/clr */
  11515. +#define E1000_TORL 0x040C0 /* Total Octets RX Low - R/clr */
  11516. +#define E1000_TORH 0x040C4 /* Total Octets RX High - R/clr */
  11517. +#define E1000_TOTL 0x040C8 /* Total Octets TX Low - R/clr */
  11518. +#define E1000_TOTH 0x040CC /* Total Octets TX High - R/clr */
  11519. +#define E1000_TPR 0x040D0 /* Total Packets RX - R/clr */
  11520. +#define E1000_TPT 0x040D4 /* Total Packets TX - R/clr */
  11521. +#define E1000_PTC64 0x040D8 /* Packets TX (64 bytes) - R/clr */
  11522. +#define E1000_PTC127 0x040DC /* Packets TX (65-127 bytes) - R/clr */
  11523. +#define E1000_PTC255 0x040E0 /* Packets TX (128-255 bytes) - R/clr */
  11524. +#define E1000_PTC511 0x040E4 /* Packets TX (256-511 bytes) - R/clr */
  11525. +#define E1000_PTC1023 0x040E8 /* Packets TX (512-1023 bytes) - R/clr */
  11526. +#define E1000_PTC1522 0x040EC /* Packets TX (1024-1522 Bytes) - R/clr */
  11527. +#define E1000_MPTC 0x040F0 /* Multicast Packets TX Count - R/clr */
  11528. +#define E1000_BPTC 0x040F4 /* Broadcast Packets TX Count - R/clr */
  11529. +#define E1000_TSCTC 0x040F8 /* TCP Segmentation Context TX - R/clr */
  11530. +#define E1000_TSCTFC 0x040FC /* TCP Segmentation Context TX Fail - R/clr */
  11531. +#define E1000_RXCSUM 0x05000 /* RX Checksum Control - RW */
  11532. +#define E1000_MTA 0x05200 /* Multicast Table Array - RW Array */
  11533. +#define E1000_RA 0x05400 /* Receive Address - RW Array */
  11534. +#define E1000_VFTA 0x05600 /* VLAN Filter Table Array - RW Array */
  11535. +#define E1000_WUC 0x05800 /* Wakeup Control - RW */
  11536. +#define E1000_WUFC 0x05808 /* Wakeup Filter Control - RW */
  11537. +#define E1000_WUS 0x05810 /* Wakeup Status - RO */
  11538. +#define E1000_MANC 0x05820 /* Management Control - RW */
  11539. +#define E1000_IPAV 0x05838 /* IP Address Valid - RW */
  11540. +#define E1000_IP4AT 0x05840 /* IPv4 Address Table - RW Array */
  11541. +#define E1000_IP6AT 0x05880 /* IPv6 Address Table - RW Array */
  11542. +#define E1000_WUPL 0x05900 /* Wakeup Packet Length - RW */
  11543. +#define E1000_WUPM 0x05A00 /* Wakeup Packet Memory - RO A */
  11544. +#define E1000_FFLT 0x05F00 /* Flexible Filter Length Table - RW Array */
  11545. +#define E1000_FFMT 0x09000 /* Flexible Filter Mask Table - RW Array */
  11546. +#define E1000_FFVT 0x09800 /* Flexible Filter Value Table - RW Array */
  11547. +
  11548. +/* Register Set (82542)
  11549. + *
  11550. + * Some of the 82542 registers are located at different offsets than they are
  11551. + * in more current versions of the 8254x. Despite the difference in location,
  11552. + * the registers function in the same manner.
  11553. + */
  11554. +#define E1000_82542_CTRL E1000_CTRL
  11555. +#define E1000_82542_CTRL_DUP E1000_CTRL_DUP
  11556. +#define E1000_82542_STATUS E1000_STATUS
  11557. +#define E1000_82542_EECD E1000_EECD
  11558. +#define E1000_82542_EERD E1000_EERD
  11559. +#define E1000_82542_CTRL_EXT E1000_CTRL_EXT
  11560. +#define E1000_82542_FLA E1000_FLA
  11561. +#define E1000_82542_MDIC E1000_MDIC
  11562. +#define E1000_82542_FCAL E1000_FCAL
  11563. +#define E1000_82542_FCAH E1000_FCAH
  11564. +#define E1000_82542_FCT E1000_FCT
  11565. +#define E1000_82542_VET E1000_VET
  11566. +#define E1000_82542_RA 0x00040
  11567. +#define E1000_82542_ICR E1000_ICR
  11568. +#define E1000_82542_ITR E1000_ITR
  11569. +#define E1000_82542_ICS E1000_ICS
  11570. +#define E1000_82542_IMS E1000_IMS
  11571. +#define E1000_82542_IMC E1000_IMC
  11572. +#define E1000_82542_RCTL E1000_RCTL
  11573. +#define E1000_82542_RDTR 0x00108
  11574. +#define E1000_82542_RDBAL 0x00110
  11575. +#define E1000_82542_RDBAH 0x00114
  11576. +#define E1000_82542_RDLEN 0x00118
  11577. +#define E1000_82542_RDH 0x00120
  11578. +#define E1000_82542_RDT 0x00128
  11579. +#define E1000_82542_FCRTH 0x00160
  11580. +#define E1000_82542_FCRTL 0x00168
  11581. +#define E1000_82542_FCTTV E1000_FCTTV
  11582. +#define E1000_82542_TXCW E1000_TXCW
  11583. +#define E1000_82542_RXCW E1000_RXCW
  11584. +#define E1000_82542_MTA 0x00200
  11585. +#define E1000_82542_TCTL E1000_TCTL
  11586. +#define E1000_82542_TIPG E1000_TIPG
  11587. +#define E1000_82542_TDBAL 0x00420
  11588. +#define E1000_82542_TDBAH 0x00424
  11589. +#define E1000_82542_TDLEN 0x00428
  11590. +#define E1000_82542_TDH 0x00430
  11591. +#define E1000_82542_TDT 0x00438
  11592. +#define E1000_82542_TIDV 0x00440
  11593. +#define E1000_82542_TBT E1000_TBT
  11594. +#define E1000_82542_AIT E1000_AIT
  11595. +#define E1000_82542_VFTA 0x00600
  11596. +#define E1000_82542_LEDCTL E1000_LEDCTL
  11597. +#define E1000_82542_PBA E1000_PBA
  11598. +#define E1000_82542_RXDCTL E1000_RXDCTL
  11599. +#define E1000_82542_RADV E1000_RADV
  11600. +#define E1000_82542_RSRPD E1000_RSRPD
  11601. +#define E1000_82542_TXDMAC E1000_TXDMAC
  11602. +#define E1000_82542_TDFHS E1000_TDFHS
  11603. +#define E1000_82542_TDFTS E1000_TDFTS
  11604. +#define E1000_82542_TDFPC E1000_TDFPC
  11605. +#define E1000_82542_TXDCTL E1000_TXDCTL
  11606. +#define E1000_82542_TADV E1000_TADV
  11607. +#define E1000_82542_TSPMT E1000_TSPMT
  11608. +#define E1000_82542_CRCERRS E1000_CRCERRS
  11609. +#define E1000_82542_ALGNERRC E1000_ALGNERRC
  11610. +#define E1000_82542_SYMERRS E1000_SYMERRS
  11611. +#define E1000_82542_RXERRC E1000_RXERRC
  11612. +#define E1000_82542_MPC E1000_MPC
  11613. +#define E1000_82542_SCC E1000_SCC
  11614. +#define E1000_82542_ECOL E1000_ECOL
  11615. +#define E1000_82542_MCC E1000_MCC
  11616. +#define E1000_82542_LATECOL E1000_LATECOL
  11617. +#define E1000_82542_COLC E1000_COLC
  11618. +#define E1000_82542_DC E1000_DC
  11619. +#define E1000_82542_TNCRS E1000_TNCRS
  11620. +#define E1000_82542_SEC E1000_SEC
  11621. +#define E1000_82542_CEXTERR E1000_CEXTERR
  11622. +#define E1000_82542_RLEC E1000_RLEC
  11623. +#define E1000_82542_XONRXC E1000_XONRXC
  11624. +#define E1000_82542_XONTXC E1000_XONTXC
  11625. +#define E1000_82542_XOFFRXC E1000_XOFFRXC
  11626. +#define E1000_82542_XOFFTXC E1000_XOFFTXC
  11627. +#define E1000_82542_FCRUC E1000_FCRUC
  11628. +#define E1000_82542_PRC64 E1000_PRC64
  11629. +#define E1000_82542_PRC127 E1000_PRC127
  11630. +#define E1000_82542_PRC255 E1000_PRC255
  11631. +#define E1000_82542_PRC511 E1000_PRC511
  11632. +#define E1000_82542_PRC1023 E1000_PRC1023
  11633. +#define E1000_82542_PRC1522 E1000_PRC1522
  11634. +#define E1000_82542_GPRC E1000_GPRC
  11635. +#define E1000_82542_BPRC E1000_BPRC
  11636. +#define E1000_82542_MPRC E1000_MPRC
  11637. +#define E1000_82542_GPTC E1000_GPTC
  11638. +#define E1000_82542_GORCL E1000_GORCL
  11639. +#define E1000_82542_GORCH E1000_GORCH
  11640. +#define E1000_82542_GOTCL E1000_GOTCL
  11641. +#define E1000_82542_GOTCH E1000_GOTCH
  11642. +#define E1000_82542_RNBC E1000_RNBC
  11643. +#define E1000_82542_RUC E1000_RUC
  11644. +#define E1000_82542_RFC E1000_RFC
  11645. +#define E1000_82542_ROC E1000_ROC
  11646. +#define E1000_82542_RJC E1000_RJC
  11647. +#define E1000_82542_MGTPRC E1000_MGTPRC
  11648. +#define E1000_82542_MGTPDC E1000_MGTPDC
  11649. +#define E1000_82542_MGTPTC E1000_MGTPTC
  11650. +#define E1000_82542_TORL E1000_TORL
  11651. +#define E1000_82542_TORH E1000_TORH
  11652. +#define E1000_82542_TOTL E1000_TOTL
  11653. +#define E1000_82542_TOTH E1000_TOTH
  11654. +#define E1000_82542_TPR E1000_TPR
  11655. +#define E1000_82542_TPT E1000_TPT
  11656. +#define E1000_82542_PTC64 E1000_PTC64
  11657. +#define E1000_82542_PTC127 E1000_PTC127
  11658. +#define E1000_82542_PTC255 E1000_PTC255
  11659. +#define E1000_82542_PTC511 E1000_PTC511
  11660. +#define E1000_82542_PTC1023 E1000_PTC1023
  11661. +#define E1000_82542_PTC1522 E1000_PTC1522
  11662. +#define E1000_82542_MPTC E1000_MPTC
  11663. +#define E1000_82542_BPTC E1000_BPTC
  11664. +#define E1000_82542_TSCTC E1000_TSCTC
  11665. +#define E1000_82542_TSCTFC E1000_TSCTFC
  11666. +#define E1000_82542_RXCSUM E1000_RXCSUM
  11667. +#define E1000_82542_WUC E1000_WUC
  11668. +#define E1000_82542_WUFC E1000_WUFC
  11669. +#define E1000_82542_WUS E1000_WUS
  11670. +#define E1000_82542_MANC E1000_MANC
  11671. +#define E1000_82542_IPAV E1000_IPAV
  11672. +#define E1000_82542_IP4AT E1000_IP4AT
  11673. +#define E1000_82542_IP6AT E1000_IP6AT
  11674. +#define E1000_82542_WUPL E1000_WUPL
  11675. +#define E1000_82542_WUPM E1000_WUPM
  11676. +#define E1000_82542_FFLT E1000_FFLT
  11677. +#define E1000_82542_TDFH 0x08010
  11678. +#define E1000_82542_TDFT 0x08018
  11679. +#define E1000_82542_FFMT E1000_FFMT
  11680. +#define E1000_82542_FFVT E1000_FFVT
  11681. +
  11682. +/* Statistics counters collected by the MAC */
  11683. +struct e1000_hw_stats {
  11684. + uint64_t crcerrs;
  11685. + uint64_t algnerrc;
  11686. + uint64_t symerrs;
  11687. + uint64_t rxerrc;
  11688. + uint64_t mpc;
  11689. + uint64_t scc;
  11690. + uint64_t ecol;
  11691. + uint64_t mcc;
  11692. + uint64_t latecol;
  11693. + uint64_t colc;
  11694. + uint64_t dc;
  11695. + uint64_t tncrs;
  11696. + uint64_t sec;
  11697. + uint64_t cexterr;
  11698. + uint64_t rlec;
  11699. + uint64_t xonrxc;
  11700. + uint64_t xontxc;
  11701. + uint64_t xoffrxc;
  11702. + uint64_t xofftxc;
  11703. + uint64_t fcruc;
  11704. + uint64_t prc64;
  11705. + uint64_t prc127;
  11706. + uint64_t prc255;
  11707. + uint64_t prc511;
  11708. + uint64_t prc1023;
  11709. + uint64_t prc1522;
  11710. + uint64_t gprc;
  11711. + uint64_t bprc;
  11712. + uint64_t mprc;
  11713. + uint64_t gptc;
  11714. + uint64_t gorcl;
  11715. + uint64_t gorch;
  11716. + uint64_t gotcl;
  11717. + uint64_t gotch;
  11718. + uint64_t rnbc;
  11719. + uint64_t ruc;
  11720. + uint64_t rfc;
  11721. + uint64_t roc;
  11722. + uint64_t rjc;
  11723. + uint64_t mgprc;
  11724. + uint64_t mgpdc;
  11725. + uint64_t mgptc;
  11726. + uint64_t torl;
  11727. + uint64_t torh;
  11728. + uint64_t totl;
  11729. + uint64_t toth;
  11730. + uint64_t tpr;
  11731. + uint64_t tpt;
  11732. + uint64_t ptc64;
  11733. + uint64_t ptc127;
  11734. + uint64_t ptc255;
  11735. + uint64_t ptc511;
  11736. + uint64_t ptc1023;
  11737. + uint64_t ptc1522;
  11738. + uint64_t mptc;
  11739. + uint64_t bptc;
  11740. + uint64_t tsctc;
  11741. + uint64_t tsctfc;
  11742. +};
  11743. +
  11744. +/* Structure containing variables used by the shared code (e1000_hw.c) */
  11745. +struct e1000_hw {
  11746. + struct pci_device *pdev;
  11747. + uint8_t *hw_addr;
  11748. + e1000_mac_type mac_type;
  11749. + e1000_phy_type phy_type;
  11750. +#if 0
  11751. + uint32_t phy_init_script;
  11752. +#endif
  11753. + e1000_media_type media_type;
  11754. + e1000_fc_type fc;
  11755. +#if 0
  11756. + e1000_bus_speed bus_speed;
  11757. + e1000_bus_width bus_width;
  11758. + e1000_bus_type bus_type;
  11759. +#endif
  11760. + struct e1000_eeprom_info eeprom;
  11761. +#if 0
  11762. + e1000_ms_type master_slave;
  11763. + e1000_ms_type original_master_slave;
  11764. + e1000_ffe_config ffe_config_state;
  11765. +#endif
  11766. + uint32_t io_base;
  11767. + uint32_t phy_id;
  11768. +#ifdef LINUX_DRIVER
  11769. + uint32_t phy_revision;
  11770. +#endif
  11771. + uint32_t phy_addr;
  11772. +#if 0
  11773. + uint32_t original_fc;
  11774. +#endif
  11775. + uint32_t txcw;
  11776. + uint32_t autoneg_failed;
  11777. +#if 0
  11778. + uint32_t max_frame_size;
  11779. + uint32_t min_frame_size;
  11780. + uint32_t mc_filter_type;
  11781. + uint32_t num_mc_addrs;
  11782. + uint32_t collision_delta;
  11783. + uint32_t tx_packet_delta;
  11784. + uint32_t ledctl_default;
  11785. + uint32_t ledctl_mode1;
  11786. + uint32_t ledctl_mode2;
  11787. + uint16_t phy_spd_default;
  11788. +#endif
  11789. + uint16_t autoneg_advertised;
  11790. + uint16_t pci_cmd_word;
  11791. +#if 0
  11792. + uint16_t fc_high_water;
  11793. + uint16_t fc_low_water;
  11794. + uint16_t fc_pause_time;
  11795. + uint16_t current_ifs_val;
  11796. + uint16_t ifs_min_val;
  11797. + uint16_t ifs_max_val;
  11798. + uint16_t ifs_step_size;
  11799. + uint16_t ifs_ratio;
  11800. +#endif
  11801. + uint16_t device_id;
  11802. + uint16_t vendor_id;
  11803. +#if 0
  11804. + uint16_t subsystem_id;
  11805. + uint16_t subsystem_vendor_id;
  11806. +#endif
  11807. + uint8_t revision_id;
  11808. +#if 0
  11809. + uint8_t autoneg;
  11810. + uint8_t mdix;
  11811. + uint8_t forced_speed_duplex;
  11812. + uint8_t wait_autoneg_complete;
  11813. + uint8_t dma_fairness;
  11814. +#endif
  11815. + uint8_t mac_addr[NODE_ADDRESS_SIZE];
  11816. +#if 0
  11817. + uint8_t perm_mac_addr[NODE_ADDRESS_SIZE];
  11818. + boolean_t disable_polarity_correction;
  11819. + boolean_t speed_downgraded;
  11820. + e1000_dsp_config dsp_config_state;
  11821. + boolean_t get_link_status;
  11822. + boolean_t serdes_link_down;
  11823. +#endif
  11824. + boolean_t tbi_compatibility_en;
  11825. + boolean_t tbi_compatibility_on;
  11826. +#if 0
  11827. + boolean_t phy_reset_disable;
  11828. + boolean_t fc_send_xon;
  11829. + boolean_t fc_strict_ieee;
  11830. + boolean_t report_tx_early;
  11831. + boolean_t adaptive_ifs;
  11832. + boolean_t ifs_params_forced;
  11833. + boolean_t in_ifs_mode;
  11834. +#endif
  11835. +};
  11836. +
  11837. +
  11838. +#define E1000_EEPROM_SWDPIN0 0x0001 /* SWDPIN 0 EEPROM Value */
  11839. +#define E1000_EEPROM_LED_LOGIC 0x0020 /* Led Logic Word */
  11840. +
  11841. +/* Register Bit Masks */
  11842. +/* Device Control */
  11843. +#define E1000_CTRL_FD 0x00000001 /* Full duplex.0=half; 1=full */
  11844. +#define E1000_CTRL_BEM 0x00000002 /* Endian Mode.0=little,1=big */
  11845. +#define E1000_CTRL_PRIOR 0x00000004 /* Priority on PCI. 0=rx,1=fair */
  11846. +#define E1000_CTRL_LRST 0x00000008 /* Link reset. 0=normal,1=reset */
  11847. +#define E1000_CTRL_TME 0x00000010 /* Test mode. 0=normal,1=test */
  11848. +#define E1000_CTRL_SLE 0x00000020 /* Serial Link on 0=dis,1=en */
  11849. +#define E1000_CTRL_ASDE 0x00000020 /* Auto-speed detect enable */
  11850. +#define E1000_CTRL_SLU 0x00000040 /* Set link up (Force Link) */
  11851. +#define E1000_CTRL_ILOS 0x00000080 /* Invert Loss-Of Signal */
  11852. +#define E1000_CTRL_SPD_SEL 0x00000300 /* Speed Select Mask */
  11853. +#define E1000_CTRL_SPD_10 0x00000000 /* Force 10Mb */
  11854. +#define E1000_CTRL_SPD_100 0x00000100 /* Force 100Mb */
  11855. +#define E1000_CTRL_SPD_1000 0x00000200 /* Force 1Gb */
  11856. +#define E1000_CTRL_BEM32 0x00000400 /* Big Endian 32 mode */
  11857. +#define E1000_CTRL_FRCSPD 0x00000800 /* Force Speed */
  11858. +#define E1000_CTRL_FRCDPX 0x00001000 /* Force Duplex */
  11859. +#define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */
  11860. +#define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */
  11861. +#define E1000_CTRL_SWDPIN2 0x00100000 /* SWDPIN 2 value */
  11862. +#define E1000_CTRL_SWDPIN3 0x00200000 /* SWDPIN 3 value */
  11863. +#define E1000_CTRL_SWDPIO0 0x00400000 /* SWDPIN 0 Input or output */
  11864. +#define E1000_CTRL_SWDPIO1 0x00800000 /* SWDPIN 1 input or output */
  11865. +#define E1000_CTRL_SWDPIO2 0x01000000 /* SWDPIN 2 input or output */
  11866. +#define E1000_CTRL_SWDPIO3 0x02000000 /* SWDPIN 3 input or output */
  11867. +#define E1000_CTRL_RST 0x04000000 /* Global reset */
  11868. +#define E1000_CTRL_RFCE 0x08000000 /* Receive Flow Control enable */
  11869. +#define E1000_CTRL_TFCE 0x10000000 /* Transmit flow control enable */
  11870. +#define E1000_CTRL_RTE 0x20000000 /* Routing tag enable */
  11871. +#define E1000_CTRL_VME 0x40000000 /* IEEE VLAN mode enable */
  11872. +#define E1000_CTRL_PHY_RST 0x80000000 /* PHY Reset */
  11873. +
  11874. +/* Device Status */
  11875. +#define E1000_STATUS_FD 0x00000001 /* Full duplex.0=half,1=full */
  11876. +#define E1000_STATUS_LU 0x00000002 /* Link up.0=no,1=link */
  11877. +#define E1000_STATUS_FUNC_MASK 0x0000000C /* PCI Function Mask */
  11878. +#define E1000_STATUS_FUNC_0 0x00000000 /* Function 0 */
  11879. +#define E1000_STATUS_FUNC_1 0x00000004 /* Function 1 */
  11880. +#define E1000_STATUS_TXOFF 0x00000010 /* transmission paused */
  11881. +#define E1000_STATUS_TBIMODE 0x00000020 /* TBI mode */
  11882. +#define E1000_STATUS_SPEED_MASK 0x000000C0
  11883. +#define E1000_STATUS_SPEED_10 0x00000000 /* Speed 10Mb/s */
  11884. +#define E1000_STATUS_SPEED_100 0x00000040 /* Speed 100Mb/s */
  11885. +#define E1000_STATUS_SPEED_1000 0x00000080 /* Speed 1000Mb/s */
  11886. +#define E1000_STATUS_ASDV 0x00000300 /* Auto speed detect value */
  11887. +#define E1000_STATUS_MTXCKOK 0x00000400 /* MTX clock running OK */
  11888. +#define E1000_STATUS_PCI66 0x00000800 /* In 66Mhz slot */
  11889. +#define E1000_STATUS_BUS64 0x00001000 /* In 64 bit slot */
  11890. +#define E1000_STATUS_PCIX_MODE 0x00002000 /* PCI-X mode */
  11891. +#define E1000_STATUS_PCIX_SPEED 0x0000C000 /* PCI-X bus speed */
  11892. +
  11893. +/* Constants used to intrepret the masked PCI-X bus speed. */
  11894. +#define E1000_STATUS_PCIX_SPEED_66 0x00000000 /* PCI-X bus speed 50-66 MHz */
  11895. +#define E1000_STATUS_PCIX_SPEED_100 0x00004000 /* PCI-X bus speed 66-100 MHz */
  11896. +#define E1000_STATUS_PCIX_SPEED_133 0x00008000 /* PCI-X bus speed 100-133 MHz */
  11897. +
  11898. +/* EEPROM/Flash Control */
  11899. +#define E1000_EECD_SK 0x00000001 /* EEPROM Clock */
  11900. +#define E1000_EECD_CS 0x00000002 /* EEPROM Chip Select */
  11901. +#define E1000_EECD_DI 0x00000004 /* EEPROM Data In */
  11902. +#define E1000_EECD_DO 0x00000008 /* EEPROM Data Out */
  11903. +#define E1000_EECD_FWE_MASK 0x00000030
  11904. +#define E1000_EECD_FWE_DIS 0x00000010 /* Disable FLASH writes */
  11905. +#define E1000_EECD_FWE_EN 0x00000020 /* Enable FLASH writes */
  11906. +#define E1000_EECD_FWE_SHIFT 4
  11907. +#define E1000_EECD_REQ 0x00000040 /* EEPROM Access Request */
  11908. +#define E1000_EECD_GNT 0x00000080 /* EEPROM Access Grant */
  11909. +#define E1000_EECD_PRES 0x00000100 /* EEPROM Present */
  11910. +#define E1000_EECD_SIZE 0x00000200 /* EEPROM Size (0=64 word 1=256 word) */
  11911. +#define E1000_EECD_ADDR_BITS 0x00000400 /* EEPROM Addressing bits based on type
  11912. + * (0-small, 1-large) */
  11913. +#define E1000_EECD_TYPE 0x00002000 /* EEPROM Type (1-SPI, 0-Microwire) */
  11914. +#ifndef E1000_EEPROM_GRANT_ATTEMPTS
  11915. +#define E1000_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM # attempts to gain grant */
  11916. +#endif
  11917. +
  11918. +/* EEPROM Read */
  11919. +#define E1000_EERD_START 0x00000001 /* Start Read */
  11920. +#define E1000_EERD_DONE 0x00000010 /* Read Done */
  11921. +#define E1000_EERD_ADDR_SHIFT 8
  11922. +#define E1000_EERD_ADDR_MASK 0x0000FF00 /* Read Address */
  11923. +#define E1000_EERD_DATA_SHIFT 16
  11924. +#define E1000_EERD_DATA_MASK 0xFFFF0000 /* Read Data */
  11925. +
  11926. +/* SPI EEPROM Status Register */
  11927. +#define EEPROM_STATUS_RDY_SPI 0x01
  11928. +#define EEPROM_STATUS_WEN_SPI 0x02
  11929. +#define EEPROM_STATUS_BP0_SPI 0x04
  11930. +#define EEPROM_STATUS_BP1_SPI 0x08
  11931. +#define EEPROM_STATUS_WPEN_SPI 0x80
  11932. +
  11933. +/* Extended Device Control */
  11934. +#define E1000_CTRL_EXT_GPI0_EN 0x00000001 /* Maps SDP4 to GPI0 */
  11935. +#define E1000_CTRL_EXT_GPI1_EN 0x00000002 /* Maps SDP5 to GPI1 */
  11936. +#define E1000_CTRL_EXT_PHYINT_EN E1000_CTRL_EXT_GPI1_EN
  11937. +#define E1000_CTRL_EXT_GPI2_EN 0x00000004 /* Maps SDP6 to GPI2 */
  11938. +#define E1000_CTRL_EXT_GPI3_EN 0x00000008 /* Maps SDP7 to GPI3 */
  11939. +#define E1000_CTRL_EXT_SDP4_DATA 0x00000010 /* Value of SW Defineable Pin 4 */
  11940. +#define E1000_CTRL_EXT_SDP5_DATA 0x00000020 /* Value of SW Defineable Pin 5 */
  11941. +#define E1000_CTRL_EXT_PHY_INT E1000_CTRL_EXT_SDP5_DATA
  11942. +#define E1000_CTRL_EXT_SDP6_DATA 0x00000040 /* Value of SW Defineable Pin 6 */
  11943. +#define E1000_CTRL_EXT_SDP7_DATA 0x00000080 /* Value of SW Defineable Pin 7 */
  11944. +#define E1000_CTRL_EXT_SDP4_DIR 0x00000100 /* Direction of SDP4 0=in 1=out */
  11945. +#define E1000_CTRL_EXT_SDP5_DIR 0x00000200 /* Direction of SDP5 0=in 1=out */
  11946. +#define E1000_CTRL_EXT_SDP6_DIR 0x00000400 /* Direction of SDP6 0=in 1=out */
  11947. +#define E1000_CTRL_EXT_SDP7_DIR 0x00000800 /* Direction of SDP7 0=in 1=out */
  11948. +#define E1000_CTRL_EXT_ASDCHK 0x00001000 /* Initiate an ASD sequence */
  11949. +#define E1000_CTRL_EXT_EE_RST 0x00002000 /* Reinitialize from EEPROM */
  11950. +#define E1000_CTRL_EXT_IPS 0x00004000 /* Invert Power State */
  11951. +#define E1000_CTRL_EXT_SPD_BYPS 0x00008000 /* Speed Select Bypass */
  11952. +#define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000
  11953. +#define E1000_CTRL_EXT_LINK_MODE_GMII 0x00000000
  11954. +#define E1000_CTRL_EXT_LINK_MODE_TBI 0x00C00000
  11955. +#define E1000_CTRL_EXT_WR_WMARK_MASK 0x03000000
  11956. +#define E1000_CTRL_EXT_WR_WMARK_256 0x00000000
  11957. +#define E1000_CTRL_EXT_WR_WMARK_320 0x01000000
  11958. +#define E1000_CTRL_EXT_WR_WMARK_384 0x02000000
  11959. +#define E1000_CTRL_EXT_WR_WMARK_448 0x03000000
  11960. +
  11961. +/* MDI Control */
  11962. +#define E1000_MDIC_DATA_MASK 0x0000FFFF
  11963. +#define E1000_MDIC_REG_MASK 0x001F0000
  11964. +#define E1000_MDIC_REG_SHIFT 16
  11965. +#define E1000_MDIC_PHY_MASK 0x03E00000
  11966. +#define E1000_MDIC_PHY_SHIFT 21
  11967. +#define E1000_MDIC_OP_WRITE 0x04000000
  11968. +#define E1000_MDIC_OP_READ 0x08000000
  11969. +#define E1000_MDIC_READY 0x10000000
  11970. +#define E1000_MDIC_INT_EN 0x20000000
  11971. +#define E1000_MDIC_ERROR 0x40000000
  11972. +
  11973. +/* LED Control */
  11974. +#define E1000_LEDCTL_LED0_MODE_MASK 0x0000000F
  11975. +#define E1000_LEDCTL_LED0_MODE_SHIFT 0
  11976. +#define E1000_LEDCTL_LED0_IVRT 0x00000040
  11977. +#define E1000_LEDCTL_LED0_BLINK 0x00000080
  11978. +#define E1000_LEDCTL_LED1_MODE_MASK 0x00000F00
  11979. +#define E1000_LEDCTL_LED1_MODE_SHIFT 8
  11980. +#define E1000_LEDCTL_LED1_IVRT 0x00004000
  11981. +#define E1000_LEDCTL_LED1_BLINK 0x00008000
  11982. +#define E1000_LEDCTL_LED2_MODE_MASK 0x000F0000
  11983. +#define E1000_LEDCTL_LED2_MODE_SHIFT 16
  11984. +#define E1000_LEDCTL_LED2_IVRT 0x00400000
  11985. +#define E1000_LEDCTL_LED2_BLINK 0x00800000
  11986. +#define E1000_LEDCTL_LED3_MODE_MASK 0x0F000000
  11987. +#define E1000_LEDCTL_LED3_MODE_SHIFT 24
  11988. +#define E1000_LEDCTL_LED3_IVRT 0x40000000
  11989. +#define E1000_LEDCTL_LED3_BLINK 0x80000000
  11990. +
  11991. +#define E1000_LEDCTL_MODE_LINK_10_1000 0x0
  11992. +#define E1000_LEDCTL_MODE_LINK_100_1000 0x1
  11993. +#define E1000_LEDCTL_MODE_LINK_UP 0x2
  11994. +#define E1000_LEDCTL_MODE_ACTIVITY 0x3
  11995. +#define E1000_LEDCTL_MODE_LINK_ACTIVITY 0x4
  11996. +#define E1000_LEDCTL_MODE_LINK_10 0x5
  11997. +#define E1000_LEDCTL_MODE_LINK_100 0x6
  11998. +#define E1000_LEDCTL_MODE_LINK_1000 0x7
  11999. +#define E1000_LEDCTL_MODE_PCIX_MODE 0x8
  12000. +#define E1000_LEDCTL_MODE_FULL_DUPLEX 0x9
  12001. +#define E1000_LEDCTL_MODE_COLLISION 0xA
  12002. +#define E1000_LEDCTL_MODE_BUS_SPEED 0xB
  12003. +#define E1000_LEDCTL_MODE_BUS_SIZE 0xC
  12004. +#define E1000_LEDCTL_MODE_PAUSED 0xD
  12005. +#define E1000_LEDCTL_MODE_LED_ON 0xE
  12006. +#define E1000_LEDCTL_MODE_LED_OFF 0xF
  12007. +
  12008. +/* Receive Address */
  12009. +#define E1000_RAH_AV 0x80000000 /* Receive descriptor valid */
  12010. +
  12011. +/* Interrupt Cause Read */
  12012. +#define E1000_ICR_TXDW 0x00000001 /* Transmit desc written back */
  12013. +#define E1000_ICR_TXQE 0x00000002 /* Transmit Queue empty */
  12014. +#define E1000_ICR_LSC 0x00000004 /* Link Status Change */
  12015. +#define E1000_ICR_RXSEQ 0x00000008 /* rx sequence error */
  12016. +#define E1000_ICR_RXDMT0 0x00000010 /* rx desc min. threshold (0) */
  12017. +#define E1000_ICR_RXO 0x00000040 /* rx overrun */
  12018. +#define E1000_ICR_RXT0 0x00000080 /* rx timer intr (ring 0) */
  12019. +#define E1000_ICR_MDAC 0x00000200 /* MDIO access complete */
  12020. +#define E1000_ICR_RXCFG 0x00000400 /* RX /c/ ordered set */
  12021. +#define E1000_ICR_GPI_EN0 0x00000800 /* GP Int 0 */
  12022. +#define E1000_ICR_GPI_EN1 0x00001000 /* GP Int 1 */
  12023. +#define E1000_ICR_GPI_EN2 0x00002000 /* GP Int 2 */
  12024. +#define E1000_ICR_GPI_EN3 0x00004000 /* GP Int 3 */
  12025. +#define E1000_ICR_TXD_LOW 0x00008000
  12026. +#define E1000_ICR_SRPD 0x00010000
  12027. +
  12028. +/* Interrupt Cause Set */
  12029. +#define E1000_ICS_TXDW E1000_ICR_TXDW /* Transmit desc written back */
  12030. +#define E1000_ICS_TXQE E1000_ICR_TXQE /* Transmit Queue empty */
  12031. +#define E1000_ICS_LSC E1000_ICR_LSC /* Link Status Change */
  12032. +#define E1000_ICS_RXSEQ E1000_ICR_RXSEQ /* rx sequence error */
  12033. +#define E1000_ICS_RXDMT0 E1000_ICR_RXDMT0 /* rx desc min. threshold */
  12034. +#define E1000_ICS_RXO E1000_ICR_RXO /* rx overrun */
  12035. +#define E1000_ICS_RXT0 E1000_ICR_RXT0 /* rx timer intr */
  12036. +#define E1000_ICS_MDAC E1000_ICR_MDAC /* MDIO access complete */
  12037. +#define E1000_ICS_RXCFG E1000_ICR_RXCFG /* RX /c/ ordered set */
  12038. +#define E1000_ICS_GPI_EN0 E1000_ICR_GPI_EN0 /* GP Int 0 */
  12039. +#define E1000_ICS_GPI_EN1 E1000_ICR_GPI_EN1 /* GP Int 1 */
  12040. +#define E1000_ICS_GPI_EN2 E1000_ICR_GPI_EN2 /* GP Int 2 */
  12041. +#define E1000_ICS_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */
  12042. +#define E1000_ICS_TXD_LOW E1000_ICR_TXD_LOW
  12043. +#define E1000_ICS_SRPD E1000_ICR_SRPD
  12044. +
  12045. +/* Interrupt Mask Set */
  12046. +#define E1000_IMS_TXDW E1000_ICR_TXDW /* Transmit desc written back */
  12047. +#define E1000_IMS_TXQE E1000_ICR_TXQE /* Transmit Queue empty */
  12048. +#define E1000_IMS_LSC E1000_ICR_LSC /* Link Status Change */
  12049. +#define E1000_IMS_RXSEQ E1000_ICR_RXSEQ /* rx sequence error */
  12050. +#define E1000_IMS_RXDMT0 E1000_ICR_RXDMT0 /* rx desc min. threshold */
  12051. +#define E1000_IMS_RXO E1000_ICR_RXO /* rx overrun */
  12052. +#define E1000_IMS_RXT0 E1000_ICR_RXT0 /* rx timer intr */
  12053. +#define E1000_IMS_MDAC E1000_ICR_MDAC /* MDIO access complete */
  12054. +#define E1000_IMS_RXCFG E1000_ICR_RXCFG /* RX /c/ ordered set */
  12055. +#define E1000_IMS_GPI_EN0 E1000_ICR_GPI_EN0 /* GP Int 0 */
  12056. +#define E1000_IMS_GPI_EN1 E1000_ICR_GPI_EN1 /* GP Int 1 */
  12057. +#define E1000_IMS_GPI_EN2 E1000_ICR_GPI_EN2 /* GP Int 2 */
  12058. +#define E1000_IMS_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */
  12059. +#define E1000_IMS_TXD_LOW E1000_ICR_TXD_LOW
  12060. +#define E1000_IMS_SRPD E1000_ICR_SRPD
  12061. +
  12062. +/* Interrupt Mask Clear */
  12063. +#define E1000_IMC_TXDW E1000_ICR_TXDW /* Transmit desc written back */
  12064. +#define E1000_IMC_TXQE E1000_ICR_TXQE /* Transmit Queue empty */
  12065. +#define E1000_IMC_LSC E1000_ICR_LSC /* Link Status Change */
  12066. +#define E1000_IMC_RXSEQ E1000_ICR_RXSEQ /* rx sequence error */
  12067. +#define E1000_IMC_RXDMT0 E1000_ICR_RXDMT0 /* rx desc min. threshold */
  12068. +#define E1000_IMC_RXO E1000_ICR_RXO /* rx overrun */
  12069. +#define E1000_IMC_RXT0 E1000_ICR_RXT0 /* rx timer intr */
  12070. +#define E1000_IMC_MDAC E1000_ICR_MDAC /* MDIO access complete */
  12071. +#define E1000_IMC_RXCFG E1000_ICR_RXCFG /* RX /c/ ordered set */
  12072. +#define E1000_IMC_GPI_EN0 E1000_ICR_GPI_EN0 /* GP Int 0 */
  12073. +#define E1000_IMC_GPI_EN1 E1000_ICR_GPI_EN1 /* GP Int 1 */
  12074. +#define E1000_IMC_GPI_EN2 E1000_ICR_GPI_EN2 /* GP Int 2 */
  12075. +#define E1000_IMC_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */
  12076. +#define E1000_IMC_TXD_LOW E1000_ICR_TXD_LOW
  12077. +#define E1000_IMC_SRPD E1000_ICR_SRPD
  12078. +
  12079. +/* Receive Control */
  12080. +#define E1000_RCTL_RST 0x00000001 /* Software reset */
  12081. +#define E1000_RCTL_EN 0x00000002 /* enable */
  12082. +#define E1000_RCTL_SBP 0x00000004 /* store bad packet */
  12083. +#define E1000_RCTL_UPE 0x00000008 /* unicast promiscuous enable */
  12084. +#define E1000_RCTL_MPE 0x00000010 /* multicast promiscuous enab */
  12085. +#define E1000_RCTL_LPE 0x00000020 /* long packet enable */
  12086. +#define E1000_RCTL_LBM_NO 0x00000000 /* no loopback mode */
  12087. +#define E1000_RCTL_LBM_MAC 0x00000040 /* MAC loopback mode */
  12088. +#define E1000_RCTL_LBM_SLP 0x00000080 /* serial link loopback mode */
  12089. +#define E1000_RCTL_LBM_TCVR 0x000000C0 /* tcvr loopback mode */
  12090. +#define E1000_RCTL_RDMTS_HALF 0x00000000 /* rx desc min threshold size */
  12091. +#define E1000_RCTL_RDMTS_QUAT 0x00000100 /* rx desc min threshold size */
  12092. +#define E1000_RCTL_RDMTS_EIGTH 0x00000200 /* rx desc min threshold size */
  12093. +#define E1000_RCTL_MO_SHIFT 12 /* multicast offset shift */
  12094. +#define E1000_RCTL_MO_0 0x00000000 /* multicast offset 11:0 */
  12095. +#define E1000_RCTL_MO_1 0x00001000 /* multicast offset 12:1 */
  12096. +#define E1000_RCTL_MO_2 0x00002000 /* multicast offset 13:2 */
  12097. +#define E1000_RCTL_MO_3 0x00003000 /* multicast offset 15:4 */
  12098. +#define E1000_RCTL_MDR 0x00004000 /* multicast desc ring 0 */
  12099. +#define E1000_RCTL_BAM 0x00008000 /* broadcast enable */
  12100. +/* these buffer sizes are valid if E1000_RCTL_BSEX is 0 */
  12101. +#define E1000_RCTL_SZ_2048 0x00000000 /* rx buffer size 2048 */
  12102. +#define E1000_RCTL_SZ_1024 0x00010000 /* rx buffer size 1024 */
  12103. +#define E1000_RCTL_SZ_512 0x00020000 /* rx buffer size 512 */
  12104. +#define E1000_RCTL_SZ_256 0x00030000 /* rx buffer size 256 */
  12105. +/* these buffer sizes are valid if E1000_RCTL_BSEX is 1 */
  12106. +#define E1000_RCTL_SZ_16384 0x00010000 /* rx buffer size 16384 */
  12107. +#define E1000_RCTL_SZ_8192 0x00020000 /* rx buffer size 8192 */
  12108. +#define E1000_RCTL_SZ_4096 0x00030000 /* rx buffer size 4096 */
  12109. +#define E1000_RCTL_VFE 0x00040000 /* vlan filter enable */
  12110. +#define E1000_RCTL_CFIEN 0x00080000 /* canonical form enable */
  12111. +#define E1000_RCTL_CFI 0x00100000 /* canonical form indicator */
  12112. +#define E1000_RCTL_DPF 0x00400000 /* discard pause frames */
  12113. +#define E1000_RCTL_PMCF 0x00800000 /* pass MAC control frames */
  12114. +#define E1000_RCTL_BSEX 0x02000000 /* Buffer size extension */
  12115. +
  12116. +/* Receive Descriptor */
  12117. +#define E1000_RDT_DELAY 0x0000ffff /* Delay timer (1=1024us) */
  12118. +#define E1000_RDT_FPDB 0x80000000 /* Flush descriptor block */
  12119. +#define E1000_RDLEN_LEN 0x0007ff80 /* descriptor length */
  12120. +#define E1000_RDH_RDH 0x0000ffff /* receive descriptor head */
  12121. +#define E1000_RDT_RDT 0x0000ffff /* receive descriptor tail */
  12122. +
  12123. +/* Flow Control */
  12124. +#define E1000_FCRTH_RTH 0x0000FFF8 /* Mask Bits[15:3] for RTH */
  12125. +#define E1000_FCRTH_XFCE 0x80000000 /* External Flow Control Enable */
  12126. +#define E1000_FCRTL_RTL 0x0000FFF8 /* Mask Bits[15:3] for RTL */
  12127. +#define E1000_FCRTL_XONE 0x80000000 /* Enable XON frame transmission */
  12128. +
  12129. +/* Receive Descriptor Control */
  12130. +#define E1000_RXDCTL_PTHRESH 0x0000003F /* RXDCTL Prefetch Threshold */
  12131. +#define E1000_RXDCTL_HTHRESH 0x00003F00 /* RXDCTL Host Threshold */
  12132. +#define E1000_RXDCTL_WTHRESH 0x003F0000 /* RXDCTL Writeback Threshold */
  12133. +#define E1000_RXDCTL_GRAN 0x01000000 /* RXDCTL Granularity */
  12134. +
  12135. +/* Transmit Descriptor Control */
  12136. +#define E1000_TXDCTL_PTHRESH 0x000000FF /* TXDCTL Prefetch Threshold */
  12137. +#define E1000_TXDCTL_HTHRESH 0x0000FF00 /* TXDCTL Host Threshold */
  12138. +#define E1000_TXDCTL_WTHRESH 0x00FF0000 /* TXDCTL Writeback Threshold */
  12139. +#define E1000_TXDCTL_GRAN 0x01000000 /* TXDCTL Granularity */
  12140. +#define E1000_TXDCTL_LWTHRESH 0xFE000000 /* TXDCTL Low Threshold */
  12141. +#define E1000_TXDCTL_FULL_TX_DESC_WB 0x01010000 /* GRAN=1, WTHRESH=1 */
  12142. +
  12143. +/* Transmit Configuration Word */
  12144. +#define E1000_TXCW_FD 0x00000020 /* TXCW full duplex */
  12145. +#define E1000_TXCW_HD 0x00000040 /* TXCW half duplex */
  12146. +#define E1000_TXCW_PAUSE 0x00000080 /* TXCW sym pause request */
  12147. +#define E1000_TXCW_ASM_DIR 0x00000100 /* TXCW astm pause direction */
  12148. +#define E1000_TXCW_PAUSE_MASK 0x00000180 /* TXCW pause request mask */
  12149. +#define E1000_TXCW_RF 0x00003000 /* TXCW remote fault */
  12150. +#define E1000_TXCW_NP 0x00008000 /* TXCW next page */
  12151. +#define E1000_TXCW_CW 0x0000ffff /* TxConfigWord mask */
  12152. +#define E1000_TXCW_TXC 0x40000000 /* Transmit Config control */
  12153. +#define E1000_TXCW_ANE 0x80000000 /* Auto-neg enable */
  12154. +
  12155. +/* Receive Configuration Word */
  12156. +#define E1000_RXCW_CW 0x0000ffff /* RxConfigWord mask */
  12157. +#define E1000_RXCW_NC 0x04000000 /* Receive config no carrier */
  12158. +#define E1000_RXCW_IV 0x08000000 /* Receive config invalid */
  12159. +#define E1000_RXCW_CC 0x10000000 /* Receive config change */
  12160. +#define E1000_RXCW_C 0x20000000 /* Receive config */
  12161. +#define E1000_RXCW_SYNCH 0x40000000 /* Receive config synch */
  12162. +#define E1000_RXCW_ANC 0x80000000 /* Auto-neg complete */
  12163. +
  12164. +/* Transmit Control */
  12165. +#define E1000_TCTL_RST 0x00000001 /* software reset */
  12166. +#define E1000_TCTL_EN 0x00000002 /* enable tx */
  12167. +#define E1000_TCTL_BCE 0x00000004 /* busy check enable */
  12168. +#define E1000_TCTL_PSP 0x00000008 /* pad short packets */
  12169. +#define E1000_TCTL_CT 0x00000ff0 /* collision threshold */
  12170. +#define E1000_TCTL_COLD 0x003ff000 /* collision distance */
  12171. +#define E1000_TCTL_SWXOFF 0x00400000 /* SW Xoff transmission */
  12172. +#define E1000_TCTL_PBE 0x00800000 /* Packet Burst Enable */
  12173. +#define E1000_TCTL_RTLC 0x01000000 /* Re-transmit on late collision */
  12174. +#define E1000_TCTL_NRTU 0x02000000 /* No Re-transmit on underrun */
  12175. +
  12176. +/* Receive Checksum Control */
  12177. +#define E1000_RXCSUM_PCSS_MASK 0x000000FF /* Packet Checksum Start */
  12178. +#define E1000_RXCSUM_IPOFL 0x00000100 /* IPv4 checksum offload */
  12179. +#define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */
  12180. +#define E1000_RXCSUM_IPV6OFL 0x00000400 /* IPv6 checksum offload */
  12181. +
  12182. +/* Definitions for power management and wakeup registers */
  12183. +/* Wake Up Control */
  12184. +#define E1000_WUC_APME 0x00000001 /* APM Enable */
  12185. +#define E1000_WUC_PME_EN 0x00000002 /* PME Enable */
  12186. +#define E1000_WUC_PME_STATUS 0x00000004 /* PME Status */
  12187. +#define E1000_WUC_APMPME 0x00000008 /* Assert PME on APM Wakeup */
  12188. +#define E1000_WUC_SPM 0x80000000 /* Enable SPM */
  12189. +
  12190. +/* Wake Up Filter Control */
  12191. +#define E1000_WUFC_LNKC 0x00000001 /* Link Status Change Wakeup Enable */
  12192. +#define E1000_WUFC_MAG 0x00000002 /* Magic Packet Wakeup Enable */
  12193. +#define E1000_WUFC_EX 0x00000004 /* Directed Exact Wakeup Enable */
  12194. +#define E1000_WUFC_MC 0x00000008 /* Directed Multicast Wakeup Enable */
  12195. +#define E1000_WUFC_BC 0x00000010 /* Broadcast Wakeup Enable */
  12196. +#define E1000_WUFC_ARP 0x00000020 /* ARP Request Packet Wakeup Enable */
  12197. +#define E1000_WUFC_IPV4 0x00000040 /* Directed IPv4 Packet Wakeup Enable */
  12198. +#define E1000_WUFC_IPV6 0x00000080 /* Directed IPv6 Packet Wakeup Enable */
  12199. +#define E1000_WUFC_FLX0 0x00010000 /* Flexible Filter 0 Enable */
  12200. +#define E1000_WUFC_FLX1 0x00020000 /* Flexible Filter 1 Enable */
  12201. +#define E1000_WUFC_FLX2 0x00040000 /* Flexible Filter 2 Enable */
  12202. +#define E1000_WUFC_FLX3 0x00080000 /* Flexible Filter 3 Enable */
  12203. +#define E1000_WUFC_ALL_FILTERS 0x000F00FF /* Mask for all wakeup filters */
  12204. +#define E1000_WUFC_FLX_OFFSET 16 /* Offset to the Flexible Filters bits */
  12205. +#define E1000_WUFC_FLX_FILTERS 0x000F0000 /* Mask for the 4 flexible filters */
  12206. +
  12207. +/* Wake Up Status */
  12208. +#define E1000_WUS_LNKC 0x00000001 /* Link Status Changed */
  12209. +#define E1000_WUS_MAG 0x00000002 /* Magic Packet Received */
  12210. +#define E1000_WUS_EX 0x00000004 /* Directed Exact Received */
  12211. +#define E1000_WUS_MC 0x00000008 /* Directed Multicast Received */
  12212. +#define E1000_WUS_BC 0x00000010 /* Broadcast Received */
  12213. +#define E1000_WUS_ARP 0x00000020 /* ARP Request Packet Received */
  12214. +#define E1000_WUS_IPV4 0x00000040 /* Directed IPv4 Packet Wakeup Received */
  12215. +#define E1000_WUS_IPV6 0x00000080 /* Directed IPv6 Packet Wakeup Received */
  12216. +#define E1000_WUS_FLX0 0x00010000 /* Flexible Filter 0 Match */
  12217. +#define E1000_WUS_FLX1 0x00020000 /* Flexible Filter 1 Match */
  12218. +#define E1000_WUS_FLX2 0x00040000 /* Flexible Filter 2 Match */
  12219. +#define E1000_WUS_FLX3 0x00080000 /* Flexible Filter 3 Match */
  12220. +#define E1000_WUS_FLX_FILTERS 0x000F0000 /* Mask for the 4 flexible filters */
  12221. +
  12222. +/* Management Control */
  12223. +#define E1000_MANC_SMBUS_EN 0x00000001 /* SMBus Enabled - RO */
  12224. +#define E1000_MANC_ASF_EN 0x00000002 /* ASF Enabled - RO */
  12225. +#define E1000_MANC_R_ON_FORCE 0x00000004 /* Reset on Force TCO - RO */
  12226. +#define E1000_MANC_RMCP_EN 0x00000100 /* Enable RCMP 026Fh Filtering */
  12227. +#define E1000_MANC_0298_EN 0x00000200 /* Enable RCMP 0298h Filtering */
  12228. +#define E1000_MANC_IPV4_EN 0x00000400 /* Enable IPv4 */
  12229. +#define E1000_MANC_IPV6_EN 0x00000800 /* Enable IPv6 */
  12230. +#define E1000_MANC_SNAP_EN 0x00001000 /* Accept LLC/SNAP */
  12231. +#define E1000_MANC_ARP_EN 0x00002000 /* Enable ARP Request Filtering */
  12232. +#define E1000_MANC_NEIGHBOR_EN 0x00004000 /* Enable Neighbor Discovery
  12233. + * Filtering */
  12234. +#define E1000_MANC_TCO_RESET 0x00010000 /* TCO Reset Occurred */
  12235. +#define E1000_MANC_RCV_TCO_EN 0x00020000 /* Receive TCO Packets Enabled */
  12236. +#define E1000_MANC_REPORT_STATUS 0x00040000 /* Status Reporting Enabled */
  12237. +#define E1000_MANC_SMB_REQ 0x01000000 /* SMBus Request */
  12238. +#define E1000_MANC_SMB_GNT 0x02000000 /* SMBus Grant */
  12239. +#define E1000_MANC_SMB_CLK_IN 0x04000000 /* SMBus Clock In */
  12240. +#define E1000_MANC_SMB_DATA_IN 0x08000000 /* SMBus Data In */
  12241. +#define E1000_MANC_SMB_DATA_OUT 0x10000000 /* SMBus Data Out */
  12242. +#define E1000_MANC_SMB_CLK_OUT 0x20000000 /* SMBus Clock Out */
  12243. +
  12244. +#define E1000_MANC_SMB_DATA_OUT_SHIFT 28 /* SMBus Data Out Shift */
  12245. +#define E1000_MANC_SMB_CLK_OUT_SHIFT 29 /* SMBus Clock Out Shift */
  12246. +
  12247. +/* Wake Up Packet Length */
  12248. +#define E1000_WUPL_LENGTH_MASK 0x0FFF /* Only the lower 12 bits are valid */
  12249. +
  12250. +#define E1000_MDALIGN 4096
  12251. +
  12252. +/* EEPROM Commands - Microwire */
  12253. +#define EEPROM_READ_OPCODE_MICROWIRE 0x6 /* EEPROM read opcode */
  12254. +#define EEPROM_WRITE_OPCODE_MICROWIRE 0x5 /* EEPROM write opcode */
  12255. +#define EEPROM_ERASE_OPCODE_MICROWIRE 0x7 /* EEPROM erase opcode */
  12256. +#define EEPROM_EWEN_OPCODE_MICROWIRE 0x13 /* EEPROM erase/write enable */
  12257. +#define EEPROM_EWDS_OPCODE_MICROWIRE 0x10 /* EEPROM erast/write disable */
  12258. +
  12259. +/* EEPROM Commands - SPI */
  12260. +#define EEPROM_MAX_RETRY_SPI 5000 /* Max wait of 5ms, for RDY signal */
  12261. +#define EEPROM_READ_OPCODE_SPI 0x3 /* EEPROM read opcode */
  12262. +#define EEPROM_WRITE_OPCODE_SPI 0x2 /* EEPROM write opcode */
  12263. +#define EEPROM_A8_OPCODE_SPI 0x8 /* opcode bit-3 = address bit-8 */
  12264. +#define EEPROM_WREN_OPCODE_SPI 0x6 /* EEPROM set Write Enable latch */
  12265. +#define EEPROM_WRDI_OPCODE_SPI 0x4 /* EEPROM reset Write Enable latch */
  12266. +#define EEPROM_RDSR_OPCODE_SPI 0x5 /* EEPROM read Status register */
  12267. +#define EEPROM_WRSR_OPCODE_SPI 0x1 /* EEPROM write Status register */
  12268. +
  12269. +/* EEPROM Size definitions */
  12270. +#define EEPROM_SIZE_16KB 0x1800
  12271. +#define EEPROM_SIZE_8KB 0x1400
  12272. +#define EEPROM_SIZE_4KB 0x1000
  12273. +#define EEPROM_SIZE_2KB 0x0C00
  12274. +#define EEPROM_SIZE_1KB 0x0800
  12275. +#define EEPROM_SIZE_512B 0x0400
  12276. +#define EEPROM_SIZE_128B 0x0000
  12277. +#define EEPROM_SIZE_MASK 0x1C00
  12278. +
  12279. +/* EEPROM Word Offsets */
  12280. +#define EEPROM_COMPAT 0x0003
  12281. +#define EEPROM_ID_LED_SETTINGS 0x0004
  12282. +#define EEPROM_SERDES_AMPLITUDE 0x0006 /* For SERDES output amplitude adjustment. */
  12283. +#define EEPROM_INIT_CONTROL1_REG 0x000A
  12284. +#define EEPROM_INIT_CONTROL2_REG 0x000F
  12285. +#define EEPROM_INIT_CONTROL3_PORT_B 0x0014
  12286. +#define EEPROM_INIT_CONTROL3_PORT_A 0x0024
  12287. +#define EEPROM_CFG 0x0012
  12288. +#define EEPROM_FLASH_VERSION 0x0032
  12289. +#define EEPROM_CHECKSUM_REG 0x003F
  12290. +
  12291. +/* Word definitions for ID LED Settings */
  12292. +#define ID_LED_RESERVED_0000 0x0000
  12293. +#define ID_LED_RESERVED_FFFF 0xFFFF
  12294. +#define ID_LED_DEFAULT ((ID_LED_OFF1_ON2 << 12) | \
  12295. + (ID_LED_OFF1_OFF2 << 8) | \
  12296. + (ID_LED_DEF1_DEF2 << 4) | \
  12297. + (ID_LED_DEF1_DEF2))
  12298. +#define ID_LED_DEF1_DEF2 0x1
  12299. +#define ID_LED_DEF1_ON2 0x2
  12300. +#define ID_LED_DEF1_OFF2 0x3
  12301. +#define ID_LED_ON1_DEF2 0x4
  12302. +#define ID_LED_ON1_ON2 0x5
  12303. +#define ID_LED_ON1_OFF2 0x6
  12304. +#define ID_LED_OFF1_DEF2 0x7
  12305. +#define ID_LED_OFF1_ON2 0x8
  12306. +#define ID_LED_OFF1_OFF2 0x9
  12307. +
  12308. +#define IGP_ACTIVITY_LED_MASK 0xFFFFF0FF
  12309. +#define IGP_ACTIVITY_LED_ENABLE 0x0300
  12310. +#define IGP_LED3_MODE 0x07000000
  12311. +
  12312. +
  12313. +/* Mask bits for SERDES amplitude adjustment in Word 6 of the EEPROM */
  12314. +#define EEPROM_SERDES_AMPLITUDE_MASK 0x000F
  12315. +
  12316. +/* Mask bits for fields in Word 0x0a of the EEPROM */
  12317. +#define EEPROM_WORD0A_ILOS 0x0010
  12318. +#define EEPROM_WORD0A_SWDPIO 0x01E0
  12319. +#define EEPROM_WORD0A_LRST 0x0200
  12320. +#define EEPROM_WORD0A_FD 0x0400
  12321. +#define EEPROM_WORD0A_66MHZ 0x0800
  12322. +
  12323. +/* Mask bits for fields in Word 0x0f of the EEPROM */
  12324. +#define EEPROM_WORD0F_PAUSE_MASK 0x3000
  12325. +#define EEPROM_WORD0F_PAUSE 0x1000
  12326. +#define EEPROM_WORD0F_ASM_DIR 0x2000
  12327. +#define EEPROM_WORD0F_ANE 0x0800
  12328. +#define EEPROM_WORD0F_SWPDIO_EXT 0x00F0
  12329. +
  12330. +/* For checksumming, the sum of all words in the EEPROM should equal 0xBABA. */
  12331. +#define EEPROM_SUM 0xBABA
  12332. +
  12333. +/* EEPROM Map defines (WORD OFFSETS)*/
  12334. +#define EEPROM_NODE_ADDRESS_BYTE_0 0
  12335. +#define EEPROM_PBA_BYTE_1 8
  12336. +
  12337. +#define EEPROM_RESERVED_WORD 0xFFFF
  12338. +
  12339. +/* EEPROM Map Sizes (Byte Counts) */
  12340. +#define PBA_SIZE 4
  12341. +
  12342. +/* Collision related configuration parameters */
  12343. +#define E1000_COLLISION_THRESHOLD 16
  12344. +#define E1000_CT_SHIFT 4
  12345. +#define E1000_COLLISION_DISTANCE 64
  12346. +#define E1000_FDX_COLLISION_DISTANCE E1000_COLLISION_DISTANCE
  12347. +#define E1000_HDX_COLLISION_DISTANCE E1000_COLLISION_DISTANCE
  12348. +#define E1000_COLD_SHIFT 12
  12349. +
  12350. +/* Number of Transmit and Receive Descriptors must be a multiple of 8 */
  12351. +#define REQ_TX_DESCRIPTOR_MULTIPLE 8
  12352. +#define REQ_RX_DESCRIPTOR_MULTIPLE 8
  12353. +
  12354. +/* Default values for the transmit IPG register */
  12355. +#define DEFAULT_82542_TIPG_IPGT 10
  12356. +#define DEFAULT_82543_TIPG_IPGT_FIBER 9
  12357. +#define DEFAULT_82543_TIPG_IPGT_COPPER 8
  12358. +
  12359. +#define E1000_TIPG_IPGT_MASK 0x000003FF
  12360. +#define E1000_TIPG_IPGR1_MASK 0x000FFC00
  12361. +#define E1000_TIPG_IPGR2_MASK 0x3FF00000
  12362. +
  12363. +#define DEFAULT_82542_TIPG_IPGR1 2
  12364. +#define DEFAULT_82543_TIPG_IPGR1 8
  12365. +#define E1000_TIPG_IPGR1_SHIFT 10
  12366. +
  12367. +#define DEFAULT_82542_TIPG_IPGR2 10
  12368. +#define DEFAULT_82543_TIPG_IPGR2 6
  12369. +#define E1000_TIPG_IPGR2_SHIFT 20
  12370. +
  12371. +#define E1000_TXDMAC_DPP 0x00000001
  12372. +
  12373. +/* Adaptive IFS defines */
  12374. +#define TX_THRESHOLD_START 8
  12375. +#define TX_THRESHOLD_INCREMENT 10
  12376. +#define TX_THRESHOLD_DECREMENT 1
  12377. +#define TX_THRESHOLD_STOP 190
  12378. +#define TX_THRESHOLD_DISABLE 0
  12379. +#define TX_THRESHOLD_TIMER_MS 10000
  12380. +#define MIN_NUM_XMITS 1000
  12381. +#define IFS_MAX 80
  12382. +#define IFS_STEP 10
  12383. +#define IFS_MIN 40
  12384. +#define IFS_RATIO 4
  12385. +
  12386. +/* PBA constants */
  12387. +#define E1000_PBA_16K 0x0010 /* 16KB, default TX allocation */
  12388. +#define E1000_PBA_22K 0x0016
  12389. +#define E1000_PBA_24K 0x0018
  12390. +#define E1000_PBA_30K 0x001E
  12391. +#define E1000_PBA_40K 0x0028
  12392. +#define E1000_PBA_48K 0x0030 /* 48KB, default RX allocation */
  12393. +
  12394. +/* Flow Control Constants */
  12395. +#define FLOW_CONTROL_ADDRESS_LOW 0x00C28001
  12396. +#define FLOW_CONTROL_ADDRESS_HIGH 0x00000100
  12397. +#define FLOW_CONTROL_TYPE 0x8808
  12398. +
  12399. +/* The historical defaults for the flow control values are given below. */
  12400. +#define FC_DEFAULT_HI_THRESH (0x8000) /* 32KB */
  12401. +#define FC_DEFAULT_LO_THRESH (0x4000) /* 16KB */
  12402. +#define FC_DEFAULT_TX_TIMER (0x100) /* ~130 us */
  12403. +
  12404. +/* PCIX Config space */
  12405. +#define PCIX_COMMAND_REGISTER 0xE6
  12406. +#define PCIX_STATUS_REGISTER_LO 0xE8
  12407. +#define PCIX_STATUS_REGISTER_HI 0xEA
  12408. +
  12409. +#define PCIX_COMMAND_MMRBC_MASK 0x000C
  12410. +#define PCIX_COMMAND_MMRBC_SHIFT 0x2
  12411. +#define PCIX_STATUS_HI_MMRBC_MASK 0x0060
  12412. +#define PCIX_STATUS_HI_MMRBC_SHIFT 0x5
  12413. +#define PCIX_STATUS_HI_MMRBC_4K 0x3
  12414. +#define PCIX_STATUS_HI_MMRBC_2K 0x2
  12415. +
  12416. +
  12417. +/* Number of bits required to shift right the "pause" bits from the
  12418. + * EEPROM (bits 13:12) to the "pause" (bits 8:7) field in the TXCW register.
  12419. + */
  12420. +#define PAUSE_SHIFT 5
  12421. +
  12422. +/* Number of bits required to shift left the "SWDPIO" bits from the
  12423. + * EEPROM (bits 8:5) to the "SWDPIO" (bits 25:22) field in the CTRL register.
  12424. + */
  12425. +#define SWDPIO_SHIFT 17
  12426. +
  12427. +/* Number of bits required to shift left the "SWDPIO_EXT" bits from the
  12428. + * EEPROM word F (bits 7:4) to the bits 11:8 of The Extended CTRL register.
  12429. + */
  12430. +#define SWDPIO__EXT_SHIFT 4
  12431. +
  12432. +/* Number of bits required to shift left the "ILOS" bit from the EEPROM
  12433. + * (bit 4) to the "ILOS" (bit 7) field in the CTRL register.
  12434. + */
  12435. +#define ILOS_SHIFT 3
  12436. +
  12437. +
  12438. +#define RECEIVE_BUFFER_ALIGN_SIZE (256)
  12439. +
  12440. +/* Number of milliseconds we wait for auto-negotiation to complete */
  12441. +#define LINK_UP_TIMEOUT 500
  12442. +
  12443. +#define E1000_TX_BUFFER_SIZE ((uint32_t)1514)
  12444. +
  12445. +/* The carrier extension symbol, as received by the NIC. */
  12446. +#define CARRIER_EXTENSION 0x0F
  12447. +
  12448. +/* TBI_ACCEPT macro definition:
  12449. + *
  12450. + * This macro requires:
  12451. + * adapter = a pointer to struct e1000_hw
  12452. + * status = the 8 bit status field of the RX descriptor with EOP set
  12453. + * error = the 8 bit error field of the RX descriptor with EOP set
  12454. + * length = the sum of all the length fields of the RX descriptors that
  12455. + * make up the current frame
  12456. + * last_byte = the last byte of the frame DMAed by the hardware
  12457. + * max_frame_length = the maximum frame length we want to accept.
  12458. + * min_frame_length = the minimum frame length we want to accept.
  12459. + *
  12460. + * This macro is a conditional that should be used in the interrupt
  12461. + * handler's Rx processing routine when RxErrors have been detected.
  12462. + *
  12463. + * Typical use:
  12464. + * ...
  12465. + * if (TBI_ACCEPT) {
  12466. + * accept_frame = TRUE;
  12467. + * e1000_tbi_adjust_stats(adapter, MacAddress);
  12468. + * frame_length--;
  12469. + * } else {
  12470. + * accept_frame = FALSE;
  12471. + * }
  12472. + * ...
  12473. + */
  12474. +
  12475. +#define TBI_ACCEPT(adapter, status, errors, length, last_byte) \
  12476. + ((adapter)->tbi_compatibility_on && \
  12477. + (((errors) & E1000_RXD_ERR_FRAME_ERR_MASK) == E1000_RXD_ERR_CE) && \
  12478. + ((last_byte) == CARRIER_EXTENSION) && \
  12479. + (((status) & E1000_RXD_STAT_VP) ? \
  12480. + (((length) > ((adapter)->min_frame_size - VLAN_TAG_SIZE)) && \
  12481. + ((length) <= ((adapter)->max_frame_size + 1))) : \
  12482. + (((length) > (adapter)->min_frame_size) && \
  12483. + ((length) <= ((adapter)->max_frame_size + VLAN_TAG_SIZE + 1)))))
  12484. +
  12485. +
  12486. +/* Structures, enums, and macros for the PHY */
  12487. +
  12488. +/* Bit definitions for the Management Data IO (MDIO) and Management Data
  12489. + * Clock (MDC) pins in the Device Control Register.
  12490. + */
  12491. +#define E1000_CTRL_PHY_RESET_DIR E1000_CTRL_SWDPIO0
  12492. +#define E1000_CTRL_PHY_RESET E1000_CTRL_SWDPIN0
  12493. +#define E1000_CTRL_MDIO_DIR E1000_CTRL_SWDPIO2
  12494. +#define E1000_CTRL_MDIO E1000_CTRL_SWDPIN2
  12495. +#define E1000_CTRL_MDC_DIR E1000_CTRL_SWDPIO3
  12496. +#define E1000_CTRL_MDC E1000_CTRL_SWDPIN3
  12497. +#define E1000_CTRL_PHY_RESET_DIR4 E1000_CTRL_EXT_SDP4_DIR
  12498. +#define E1000_CTRL_PHY_RESET4 E1000_CTRL_EXT_SDP4_DATA
  12499. +
  12500. +/* PHY 1000 MII Register/Bit Definitions */
  12501. +/* PHY Registers defined by IEEE */
  12502. +#define PHY_CTRL 0x00 /* Control Register */
  12503. +#define PHY_STATUS 0x01 /* Status Regiser */
  12504. +#define PHY_ID1 0x02 /* Phy Id Reg (word 1) */
  12505. +#define PHY_ID2 0x03 /* Phy Id Reg (word 2) */
  12506. +#define PHY_AUTONEG_ADV 0x04 /* Autoneg Advertisement */
  12507. +#define PHY_LP_ABILITY 0x05 /* Link Partner Ability (Base Page) */
  12508. +#define PHY_AUTONEG_EXP 0x06 /* Autoneg Expansion Reg */
  12509. +#define PHY_NEXT_PAGE_TX 0x07 /* Next Page TX */
  12510. +#define PHY_LP_NEXT_PAGE 0x08 /* Link Partner Next Page */
  12511. +#define PHY_1000T_CTRL 0x09 /* 1000Base-T Control Reg */
  12512. +#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */
  12513. +#define PHY_EXT_STATUS 0x0F /* Extended Status Reg */
  12514. +
  12515. +/* M88E1000 Specific Registers */
  12516. +#define M88E1000_PHY_SPEC_CTRL 0x10 /* PHY Specific Control Register */
  12517. +#define M88E1000_PHY_SPEC_STATUS 0x11 /* PHY Specific Status Register */
  12518. +#define M88E1000_INT_ENABLE 0x12 /* Interrupt Enable Register */
  12519. +#define M88E1000_INT_STATUS 0x13 /* Interrupt Status Register */
  12520. +#define M88E1000_EXT_PHY_SPEC_CTRL 0x14 /* Extended PHY Specific Control */
  12521. +#define M88E1000_RX_ERR_CNTR 0x15 /* Receive Error Counter */
  12522. +
  12523. +#define M88E1000_PHY_EXT_CTRL 0x1A /* PHY extend control register */
  12524. +#define M88E1000_PHY_PAGE_SELECT 0x1D /* Reg 29 for page number setting */
  12525. +#define M88E1000_PHY_GEN_CONTROL 0x1E /* Its meaning depends on reg 29 */
  12526. +#define M88E1000_PHY_VCO_REG_BIT8 0x100 /* Bits 8 & 11 are adjusted for */
  12527. +#define M88E1000_PHY_VCO_REG_BIT11 0x800 /* improved BER performance */
  12528. +
  12529. +#define IGP01E1000_IEEE_REGS_PAGE 0x0000
  12530. +#define IGP01E1000_IEEE_RESTART_AUTONEG 0x3300
  12531. +#define IGP01E1000_IEEE_FORCE_GIGA 0x0140
  12532. +
  12533. +/* IGP01E1000 Specific Registers */
  12534. +#define IGP01E1000_PHY_PORT_CONFIG 0x10 /* PHY Specific Port Config Register */
  12535. +#define IGP01E1000_PHY_PORT_STATUS 0x11 /* PHY Specific Status Register */
  12536. +#define IGP01E1000_PHY_PORT_CTRL 0x12 /* PHY Specific Control Register */
  12537. +#define IGP01E1000_PHY_LINK_HEALTH 0x13 /* PHY Link Health Register */
  12538. +#define IGP01E1000_GMII_FIFO 0x14 /* GMII FIFO Register */
  12539. +#define IGP01E1000_PHY_CHANNEL_QUALITY 0x15 /* PHY Channel Quality Register */
  12540. +#define IGP01E1000_PHY_PAGE_SELECT 0x1F /* PHY Page Select Core Register */
  12541. +
  12542. +/* IGP01E1000 AGC Registers - stores the cable length values*/
  12543. +#define IGP01E1000_PHY_AGC_A 0x1172
  12544. +#define IGP01E1000_PHY_AGC_B 0x1272
  12545. +#define IGP01E1000_PHY_AGC_C 0x1472
  12546. +#define IGP01E1000_PHY_AGC_D 0x1872
  12547. +
  12548. +/* IGP01E1000 DSP Reset Register */
  12549. +#define IGP01E1000_PHY_DSP_RESET 0x1F33
  12550. +#define IGP01E1000_PHY_DSP_SET 0x1F71
  12551. +#define IGP01E1000_PHY_DSP_FFE 0x1F35
  12552. +
  12553. +#define IGP01E1000_PHY_CHANNEL_NUM 4
  12554. +#define IGP01E1000_PHY_AGC_PARAM_A 0x1171
  12555. +#define IGP01E1000_PHY_AGC_PARAM_B 0x1271
  12556. +#define IGP01E1000_PHY_AGC_PARAM_C 0x1471
  12557. +#define IGP01E1000_PHY_AGC_PARAM_D 0x1871
  12558. +
  12559. +#define IGP01E1000_PHY_EDAC_MU_INDEX 0xC000
  12560. +#define IGP01E1000_PHY_EDAC_SIGN_EXT_9_BITS 0x8000
  12561. +
  12562. +#define IGP01E1000_PHY_ANALOG_TX_STATE 0x2890
  12563. +#define IGP01E1000_PHY_ANALOG_CLASS_A 0x2000
  12564. +#define IGP01E1000_PHY_FORCE_ANALOG_ENABLE 0x0004
  12565. +#define IGP01E1000_PHY_DSP_FFE_CM_CP 0x0069
  12566. +
  12567. +#define IGP01E1000_PHY_DSP_FFE_DEFAULT 0x002A
  12568. +/* IGP01E1000 PCS Initialization register - stores the polarity status when
  12569. + * speed = 1000 Mbps. */
  12570. +#define IGP01E1000_PHY_PCS_INIT_REG 0x00B4
  12571. +#define IGP01E1000_PHY_PCS_CTRL_REG 0x00B5
  12572. +
  12573. +#define IGP01E1000_ANALOG_REGS_PAGE 0x20C0
  12574. +
  12575. +#define MAX_PHY_REG_ADDRESS 0x1F /* 5 bit address bus (0-0x1F) */
  12576. +#define MAX_PHY_MULTI_PAGE_REG 0xF /*Registers that are equal on all pages*/
  12577. +/* PHY Control Register */
  12578. +#define MII_CR_SPEED_SELECT_MSB 0x0040 /* bits 6,13: 10=1000, 01=100, 00=10 */
  12579. +#define MII_CR_COLL_TEST_ENABLE 0x0080 /* Collision test enable */
  12580. +#define MII_CR_FULL_DUPLEX 0x0100 /* FDX =1, half duplex =0 */
  12581. +#define MII_CR_RESTART_AUTO_NEG 0x0200 /* Restart auto negotiation */
  12582. +#define MII_CR_ISOLATE 0x0400 /* Isolate PHY from MII */
  12583. +#define MII_CR_POWER_DOWN 0x0800 /* Power down */
  12584. +#define MII_CR_AUTO_NEG_EN 0x1000 /* Auto Neg Enable */
  12585. +#define MII_CR_SPEED_SELECT_LSB 0x2000 /* bits 6,13: 10=1000, 01=100, 00=10 */
  12586. +#define MII_CR_LOOPBACK 0x4000 /* 0 = normal, 1 = loopback */
  12587. +#define MII_CR_RESET 0x8000 /* 0 = normal, 1 = PHY reset */
  12588. +
  12589. +/* PHY Status Register */
  12590. +#define MII_SR_EXTENDED_CAPS 0x0001 /* Extended register capabilities */
  12591. +#define MII_SR_JABBER_DETECT 0x0002 /* Jabber Detected */
  12592. +#define MII_SR_LINK_STATUS 0x0004 /* Link Status 1 = link */
  12593. +#define MII_SR_AUTONEG_CAPS 0x0008 /* Auto Neg Capable */
  12594. +#define MII_SR_REMOTE_FAULT 0x0010 /* Remote Fault Detect */
  12595. +#define MII_SR_AUTONEG_COMPLETE 0x0020 /* Auto Neg Complete */
  12596. +#define MII_SR_PREAMBLE_SUPPRESS 0x0040 /* Preamble may be suppressed */
  12597. +#define MII_SR_EXTENDED_STATUS 0x0100 /* Ext. status info in Reg 0x0F */
  12598. +#define MII_SR_100T2_HD_CAPS 0x0200 /* 100T2 Half Duplex Capable */
  12599. +#define MII_SR_100T2_FD_CAPS 0x0400 /* 100T2 Full Duplex Capable */
  12600. +#define MII_SR_10T_HD_CAPS 0x0800 /* 10T Half Duplex Capable */
  12601. +#define MII_SR_10T_FD_CAPS 0x1000 /* 10T Full Duplex Capable */
  12602. +#define MII_SR_100X_HD_CAPS 0x2000 /* 100X Half Duplex Capable */
  12603. +#define MII_SR_100X_FD_CAPS 0x4000 /* 100X Full Duplex Capable */
  12604. +#define MII_SR_100T4_CAPS 0x8000 /* 100T4 Capable */
  12605. +
  12606. +/* Autoneg Advertisement Register */
  12607. +#define NWAY_AR_SELECTOR_FIELD 0x0001 /* indicates IEEE 802.3 CSMA/CD */
  12608. +#define NWAY_AR_10T_HD_CAPS 0x0020 /* 10T Half Duplex Capable */
  12609. +#define NWAY_AR_10T_FD_CAPS 0x0040 /* 10T Full Duplex Capable */
  12610. +#define NWAY_AR_100TX_HD_CAPS 0x0080 /* 100TX Half Duplex Capable */
  12611. +#define NWAY_AR_100TX_FD_CAPS 0x0100 /* 100TX Full Duplex Capable */
  12612. +#define NWAY_AR_100T4_CAPS 0x0200 /* 100T4 Capable */
  12613. +#define NWAY_AR_PAUSE 0x0400 /* Pause operation desired */
  12614. +#define NWAY_AR_ASM_DIR 0x0800 /* Asymmetric Pause Direction bit */
  12615. +#define NWAY_AR_REMOTE_FAULT 0x2000 /* Remote Fault detected */
  12616. +#define NWAY_AR_NEXT_PAGE 0x8000 /* Next Page ability supported */
  12617. +
  12618. +/* Link Partner Ability Register (Base Page) */
  12619. +#define NWAY_LPAR_SELECTOR_FIELD 0x0000 /* LP protocol selector field */
  12620. +#define NWAY_LPAR_10T_HD_CAPS 0x0020 /* LP is 10T Half Duplex Capable */
  12621. +#define NWAY_LPAR_10T_FD_CAPS 0x0040 /* LP is 10T Full Duplex Capable */
  12622. +#define NWAY_LPAR_100TX_HD_CAPS 0x0080 /* LP is 100TX Half Duplex Capable */
  12623. +#define NWAY_LPAR_100TX_FD_CAPS 0x0100 /* LP is 100TX Full Duplex Capable */
  12624. +#define NWAY_LPAR_100T4_CAPS 0x0200 /* LP is 100T4 Capable */
  12625. +#define NWAY_LPAR_PAUSE 0x0400 /* LP Pause operation desired */
  12626. +#define NWAY_LPAR_ASM_DIR 0x0800 /* LP Asymmetric Pause Direction bit */
  12627. +#define NWAY_LPAR_REMOTE_FAULT 0x2000 /* LP has detected Remote Fault */
  12628. +#define NWAY_LPAR_ACKNOWLEDGE 0x4000 /* LP has rx'd link code word */
  12629. +#define NWAY_LPAR_NEXT_PAGE 0x8000 /* Next Page ability supported */
  12630. +
  12631. +/* Autoneg Expansion Register */
  12632. +#define NWAY_ER_LP_NWAY_CAPS 0x0001 /* LP has Auto Neg Capability */
  12633. +#define NWAY_ER_PAGE_RXD 0x0002 /* LP is 10T Half Duplex Capable */
  12634. +#define NWAY_ER_NEXT_PAGE_CAPS 0x0004 /* LP is 10T Full Duplex Capable */
  12635. +#define NWAY_ER_LP_NEXT_PAGE_CAPS 0x0008 /* LP is 100TX Half Duplex Capable */
  12636. +#define NWAY_ER_PAR_DETECT_FAULT 0x0010 /* LP is 100TX Full Duplex Capable */
  12637. +
  12638. +/* Next Page TX Register */
  12639. +#define NPTX_MSG_CODE_FIELD 0x0001 /* NP msg code or unformatted data */
  12640. +#define NPTX_TOGGLE 0x0800 /* Toggles between exchanges
  12641. + * of different NP
  12642. + */
  12643. +#define NPTX_ACKNOWLDGE2 0x1000 /* 1 = will comply with msg
  12644. + * 0 = cannot comply with msg
  12645. + */
  12646. +#define NPTX_MSG_PAGE 0x2000 /* formatted(1)/unformatted(0) pg */
  12647. +#define NPTX_NEXT_PAGE 0x8000 /* 1 = addition NP will follow
  12648. + * 0 = sending last NP
  12649. + */
  12650. +
  12651. +/* Link Partner Next Page Register */
  12652. +#define LP_RNPR_MSG_CODE_FIELD 0x0001 /* NP msg code or unformatted data */
  12653. +#define LP_RNPR_TOGGLE 0x0800 /* Toggles between exchanges
  12654. + * of different NP
  12655. + */
  12656. +#define LP_RNPR_ACKNOWLDGE2 0x1000 /* 1 = will comply with msg
  12657. + * 0 = cannot comply with msg
  12658. + */
  12659. +#define LP_RNPR_MSG_PAGE 0x2000 /* formatted(1)/unformatted(0) pg */
  12660. +#define LP_RNPR_ACKNOWLDGE 0x4000 /* 1 = ACK / 0 = NO ACK */
  12661. +#define LP_RNPR_NEXT_PAGE 0x8000 /* 1 = addition NP will follow
  12662. + * 0 = sending last NP
  12663. + */
  12664. +
  12665. +/* 1000BASE-T Control Register */
  12666. +#define CR_1000T_ASYM_PAUSE 0x0080 /* Advertise asymmetric pause bit */
  12667. +#define CR_1000T_HD_CAPS 0x0100 /* Advertise 1000T HD capability */
  12668. +#define CR_1000T_FD_CAPS 0x0200 /* Advertise 1000T FD capability */
  12669. +#define CR_1000T_REPEATER_DTE 0x0400 /* 1=Repeater/switch device port */
  12670. + /* 0=DTE device */
  12671. +#define CR_1000T_MS_VALUE 0x0800 /* 1=Configure PHY as Master */
  12672. + /* 0=Configure PHY as Slave */
  12673. +#define CR_1000T_MS_ENABLE 0x1000 /* 1=Master/Slave manual config value */
  12674. + /* 0=Automatic Master/Slave config */
  12675. +#define CR_1000T_TEST_MODE_NORMAL 0x0000 /* Normal Operation */
  12676. +#define CR_1000T_TEST_MODE_1 0x2000 /* Transmit Waveform test */
  12677. +#define CR_1000T_TEST_MODE_2 0x4000 /* Master Transmit Jitter test */
  12678. +#define CR_1000T_TEST_MODE_3 0x6000 /* Slave Transmit Jitter test */
  12679. +#define CR_1000T_TEST_MODE_4 0x8000 /* Transmitter Distortion test */
  12680. +
  12681. +/* 1000BASE-T Status Register */
  12682. +#define SR_1000T_IDLE_ERROR_CNT 0x00FF /* Num idle errors since last read */
  12683. +#define SR_1000T_ASYM_PAUSE_DIR 0x0100 /* LP asymmetric pause direction bit */
  12684. +#define SR_1000T_LP_HD_CAPS 0x0400 /* LP is 1000T HD capable */
  12685. +#define SR_1000T_LP_FD_CAPS 0x0800 /* LP is 1000T FD capable */
  12686. +#define SR_1000T_REMOTE_RX_STATUS 0x1000 /* Remote receiver OK */
  12687. +#define SR_1000T_LOCAL_RX_STATUS 0x2000 /* Local receiver OK */
  12688. +#define SR_1000T_MS_CONFIG_RES 0x4000 /* 1=Local TX is Master, 0=Slave */
  12689. +#define SR_1000T_MS_CONFIG_FAULT 0x8000 /* Master/Slave config fault */
  12690. +#define SR_1000T_REMOTE_RX_STATUS_SHIFT 12
  12691. +#define SR_1000T_LOCAL_RX_STATUS_SHIFT 13
  12692. +#define SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT 5
  12693. +#define FFE_IDLE_ERR_COUNT_TIMEOUT_20 20
  12694. +#define FFE_IDLE_ERR_COUNT_TIMEOUT_100 100
  12695. +
  12696. +/* Extended Status Register */
  12697. +#define IEEE_ESR_1000T_HD_CAPS 0x1000 /* 1000T HD capable */
  12698. +#define IEEE_ESR_1000T_FD_CAPS 0x2000 /* 1000T FD capable */
  12699. +#define IEEE_ESR_1000X_HD_CAPS 0x4000 /* 1000X HD capable */
  12700. +#define IEEE_ESR_1000X_FD_CAPS 0x8000 /* 1000X FD capable */
  12701. +
  12702. +#define PHY_TX_POLARITY_MASK 0x0100 /* register 10h bit 8 (polarity bit) */
  12703. +#define PHY_TX_NORMAL_POLARITY 0 /* register 10h bit 8 (normal polarity) */
  12704. +
  12705. +#define AUTO_POLARITY_DISABLE 0x0010 /* register 11h bit 4 */
  12706. + /* (0=enable, 1=disable) */
  12707. +
  12708. +/* M88E1000 PHY Specific Control Register */
  12709. +#define M88E1000_PSCR_JABBER_DISABLE 0x0001 /* 1=Jabber Function disabled */
  12710. +#define M88E1000_PSCR_POLARITY_REVERSAL 0x0002 /* 1=Polarity Reversal enabled */
  12711. +#define M88E1000_PSCR_SQE_TEST 0x0004 /* 1=SQE Test enabled */
  12712. +#define M88E1000_PSCR_CLK125_DISABLE 0x0010 /* 1=CLK125 low,
  12713. + * 0=CLK125 toggling
  12714. + */
  12715. +#define M88E1000_PSCR_MDI_MANUAL_MODE 0x0000 /* MDI Crossover Mode bits 6:5 */
  12716. + /* Manual MDI configuration */
  12717. +#define M88E1000_PSCR_MDIX_MANUAL_MODE 0x0020 /* Manual MDIX configuration */
  12718. +#define M88E1000_PSCR_AUTO_X_1000T 0x0040 /* 1000BASE-T: Auto crossover,
  12719. + * 100BASE-TX/10BASE-T:
  12720. + * MDI Mode
  12721. + */
  12722. +#define M88E1000_PSCR_AUTO_X_MODE 0x0060 /* Auto crossover enabled
  12723. + * all speeds.
  12724. + */
  12725. +#define M88E1000_PSCR_10BT_EXT_DIST_ENABLE 0x0080
  12726. + /* 1=Enable Extended 10BASE-T distance
  12727. + * (Lower 10BASE-T RX Threshold)
  12728. + * 0=Normal 10BASE-T RX Threshold */
  12729. +#define M88E1000_PSCR_MII_5BIT_ENABLE 0x0100
  12730. + /* 1=5-Bit interface in 100BASE-TX
  12731. + * 0=MII interface in 100BASE-TX */
  12732. +#define M88E1000_PSCR_SCRAMBLER_DISABLE 0x0200 /* 1=Scrambler disable */
  12733. +#define M88E1000_PSCR_FORCE_LINK_GOOD 0x0400 /* 1=Force link good */
  12734. +#define M88E1000_PSCR_ASSERT_CRS_ON_TX 0x0800 /* 1=Assert CRS on Transmit */
  12735. +
  12736. +#define M88E1000_PSCR_POLARITY_REVERSAL_SHIFT 1
  12737. +#define M88E1000_PSCR_AUTO_X_MODE_SHIFT 5
  12738. +#define M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT 7
  12739. +
  12740. +/* M88E1000 PHY Specific Status Register */
  12741. +#define M88E1000_PSSR_JABBER 0x0001 /* 1=Jabber */
  12742. +#define M88E1000_PSSR_REV_POLARITY 0x0002 /* 1=Polarity reversed */
  12743. +#define M88E1000_PSSR_DOWNSHIFT 0x0020 /* 1=Downshifted */
  12744. +#define M88E1000_PSSR_MDIX 0x0040 /* 1=MDIX; 0=MDI */
  12745. +#define M88E1000_PSSR_CABLE_LENGTH 0x0380 /* 0=<50M;1=50-80M;2=80-110M;
  12746. + * 3=110-140M;4=>140M */
  12747. +#define M88E1000_PSSR_LINK 0x0400 /* 1=Link up, 0=Link down */
  12748. +#define M88E1000_PSSR_SPD_DPLX_RESOLVED 0x0800 /* 1=Speed & Duplex resolved */
  12749. +#define M88E1000_PSSR_PAGE_RCVD 0x1000 /* 1=Page received */
  12750. +#define M88E1000_PSSR_DPLX 0x2000 /* 1=Duplex 0=Half Duplex */
  12751. +#define M88E1000_PSSR_SPEED 0xC000 /* Speed, bits 14:15 */
  12752. +#define M88E1000_PSSR_10MBS 0x0000 /* 00=10Mbs */
  12753. +#define M88E1000_PSSR_100MBS 0x4000 /* 01=100Mbs */
  12754. +#define M88E1000_PSSR_1000MBS 0x8000 /* 10=1000Mbs */
  12755. +
  12756. +#define M88E1000_PSSR_REV_POLARITY_SHIFT 1
  12757. +#define M88E1000_PSSR_DOWNSHIFT_SHIFT 5
  12758. +#define M88E1000_PSSR_MDIX_SHIFT 6
  12759. +#define M88E1000_PSSR_CABLE_LENGTH_SHIFT 7
  12760. +
  12761. +/* M88E1000 Extended PHY Specific Control Register */
  12762. +#define M88E1000_EPSCR_FIBER_LOOPBACK 0x4000 /* 1=Fiber loopback */
  12763. +#define M88E1000_EPSCR_DOWN_NO_IDLE 0x8000 /* 1=Lost lock detect enabled.
  12764. + * Will assert lost lock and bring
  12765. + * link down if idle not seen
  12766. + * within 1ms in 1000BASE-T
  12767. + */
  12768. +/* Number of times we will attempt to autonegotiate before downshifting if we
  12769. + * are the master */
  12770. +#define M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK 0x0C00
  12771. +#define M88E1000_EPSCR_MASTER_DOWNSHIFT_1X 0x0000
  12772. +#define M88E1000_EPSCR_MASTER_DOWNSHIFT_2X 0x0400
  12773. +#define M88E1000_EPSCR_MASTER_DOWNSHIFT_3X 0x0800
  12774. +#define M88E1000_EPSCR_MASTER_DOWNSHIFT_4X 0x0C00
  12775. +/* Number of times we will attempt to autonegotiate before downshifting if we
  12776. + * are the slave */
  12777. +#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK 0x0300
  12778. +#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_DIS 0x0000
  12779. +#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X 0x0100
  12780. +#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_2X 0x0200
  12781. +#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_3X 0x0300
  12782. +#define M88E1000_EPSCR_TX_CLK_2_5 0x0060 /* 2.5 MHz TX_CLK */
  12783. +#define M88E1000_EPSCR_TX_CLK_25 0x0070 /* 25 MHz TX_CLK */
  12784. +#define M88E1000_EPSCR_TX_CLK_0 0x0000 /* NO TX_CLK */
  12785. +
  12786. +/* IGP01E1000 Specific Port Config Register - R/W */
  12787. +#define IGP01E1000_PSCFR_AUTO_MDIX_PAR_DETECT 0x0010
  12788. +#define IGP01E1000_PSCFR_PRE_EN 0x0020
  12789. +#define IGP01E1000_PSCFR_SMART_SPEED 0x0080
  12790. +#define IGP01E1000_PSCFR_DISABLE_TPLOOPBACK 0x0100
  12791. +#define IGP01E1000_PSCFR_DISABLE_JABBER 0x0400
  12792. +#define IGP01E1000_PSCFR_DISABLE_TRANSMIT 0x2000
  12793. +
  12794. +/* IGP01E1000 Specific Port Status Register - R/O */
  12795. +#define IGP01E1000_PSSR_AUTONEG_FAILED 0x0001 /* RO LH SC */
  12796. +#define IGP01E1000_PSSR_POLARITY_REVERSED 0x0002
  12797. +#define IGP01E1000_PSSR_CABLE_LENGTH 0x007C
  12798. +#define IGP01E1000_PSSR_FULL_DUPLEX 0x0200
  12799. +#define IGP01E1000_PSSR_LINK_UP 0x0400
  12800. +#define IGP01E1000_PSSR_MDIX 0x0800
  12801. +#define IGP01E1000_PSSR_SPEED_MASK 0xC000 /* speed bits mask */
  12802. +#define IGP01E1000_PSSR_SPEED_10MBPS 0x4000
  12803. +#define IGP01E1000_PSSR_SPEED_100MBPS 0x8000
  12804. +#define IGP01E1000_PSSR_SPEED_1000MBPS 0xC000
  12805. +#define IGP01E1000_PSSR_CABLE_LENGTH_SHIFT 0x0002 /* shift right 2 */
  12806. +#define IGP01E1000_PSSR_MDIX_SHIFT 0x000B /* shift right 11 */
  12807. +
  12808. +/* IGP01E1000 Specific Port Control Register - R/W */
  12809. +#define IGP01E1000_PSCR_TP_LOOPBACK 0x0001
  12810. +#define IGP01E1000_PSCR_CORRECT_NC_SCMBLR 0x0200
  12811. +#define IGP01E1000_PSCR_TEN_CRS_SELECT 0x0400
  12812. +#define IGP01E1000_PSCR_FLIP_CHIP 0x0800
  12813. +#define IGP01E1000_PSCR_AUTO_MDIX 0x1000
  12814. +#define IGP01E1000_PSCR_FORCE_MDI_MDIX 0x2000 /* 0-MDI, 1-MDIX */
  12815. +
  12816. +/* IGP01E1000 Specific Port Link Health Register */
  12817. +#define IGP01E1000_PLHR_SS_DOWNGRADE 0x8000
  12818. +#define IGP01E1000_PLHR_GIG_SCRAMBLER_ERROR 0x4000
  12819. +#define IGP01E1000_PLHR_GIG_REM_RCVR_NOK 0x0800 /* LH */
  12820. +#define IGP01E1000_PLHR_IDLE_ERROR_CNT_OFLOW 0x0400 /* LH */
  12821. +#define IGP01E1000_PLHR_DATA_ERR_1 0x0200 /* LH */
  12822. +#define IGP01E1000_PLHR_DATA_ERR_0 0x0100
  12823. +#define IGP01E1000_PLHR_AUTONEG_FAULT 0x0010
  12824. +#define IGP01E1000_PLHR_AUTONEG_ACTIVE 0x0008
  12825. +#define IGP01E1000_PLHR_VALID_CHANNEL_D 0x0004
  12826. +#define IGP01E1000_PLHR_VALID_CHANNEL_C 0x0002
  12827. +#define IGP01E1000_PLHR_VALID_CHANNEL_B 0x0001
  12828. +#define IGP01E1000_PLHR_VALID_CHANNEL_A 0x0000
  12829. +
  12830. +/* IGP01E1000 Channel Quality Register */
  12831. +#define IGP01E1000_MSE_CHANNEL_D 0x000F
  12832. +#define IGP01E1000_MSE_CHANNEL_C 0x00F0
  12833. +#define IGP01E1000_MSE_CHANNEL_B 0x0F00
  12834. +#define IGP01E1000_MSE_CHANNEL_A 0xF000
  12835. +
  12836. +/* IGP01E1000 DSP reset macros */
  12837. +#define DSP_RESET_ENABLE 0x0
  12838. +#define DSP_RESET_DISABLE 0x2
  12839. +#define E1000_MAX_DSP_RESETS 10
  12840. +
  12841. +/* IGP01E1000 AGC Registers */
  12842. +
  12843. +#define IGP01E1000_AGC_LENGTH_SHIFT 7 /* Coarse - 13:11, Fine - 10:7 */
  12844. +
  12845. +/* 7 bits (3 Coarse + 4 Fine) --> 128 optional values */
  12846. +#define IGP01E1000_AGC_LENGTH_TABLE_SIZE 128
  12847. +
  12848. +/* The precision of the length is +/- 10 meters */
  12849. +#define IGP01E1000_AGC_RANGE 10
  12850. +
  12851. +/* IGP01E1000 PCS Initialization register */
  12852. +/* bits 3:6 in the PCS registers stores the channels polarity */
  12853. +#define IGP01E1000_PHY_POLARITY_MASK 0x0078
  12854. +
  12855. +/* IGP01E1000 GMII FIFO Register */
  12856. +#define IGP01E1000_GMII_FLEX_SPD 0x10 /* Enable flexible speed
  12857. + * on Link-Up */
  12858. +#define IGP01E1000_GMII_SPD 0x20 /* Enable SPD */
  12859. +
  12860. +/* IGP01E1000 Analog Register */
  12861. +#define IGP01E1000_ANALOG_SPARE_FUSE_STATUS 0x20D1
  12862. +#define IGP01E1000_ANALOG_FUSE_STATUS 0x20D0
  12863. +#define IGP01E1000_ANALOG_FUSE_CONTROL 0x20DC
  12864. +#define IGP01E1000_ANALOG_FUSE_BYPASS 0x20DE
  12865. +
  12866. +#define IGP01E1000_ANALOG_FUSE_POLY_MASK 0xF000
  12867. +#define IGP01E1000_ANALOG_FUSE_FINE_MASK 0x0F80
  12868. +#define IGP01E1000_ANALOG_FUSE_COARSE_MASK 0x0070
  12869. +#define IGP01E1000_ANALOG_SPARE_FUSE_ENABLED 0x0100
  12870. +#define IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL 0x0002
  12871. +
  12872. +#define IGP01E1000_ANALOG_FUSE_COARSE_THRESH 0x0040
  12873. +#define IGP01E1000_ANALOG_FUSE_COARSE_10 0x0010
  12874. +#define IGP01E1000_ANALOG_FUSE_FINE_1 0x0080
  12875. +#define IGP01E1000_ANALOG_FUSE_FINE_10 0x0500
  12876. +
  12877. +/* Bit definitions for valid PHY IDs. */
  12878. +#define M88E1000_E_PHY_ID 0x01410C50
  12879. +#define M88E1000_I_PHY_ID 0x01410C30
  12880. +#define M88E1011_I_PHY_ID 0x01410C20
  12881. +#define IGP01E1000_I_PHY_ID 0x02A80380
  12882. +#define M88E1000_12_PHY_ID M88E1000_E_PHY_ID
  12883. +#define M88E1000_14_PHY_ID M88E1000_E_PHY_ID
  12884. +#define M88E1011_I_REV_4 0x04
  12885. +
  12886. +/* Miscellaneous PHY bit definitions. */
  12887. +#define PHY_PREAMBLE 0xFFFFFFFF
  12888. +#define PHY_SOF 0x01
  12889. +#define PHY_OP_READ 0x02
  12890. +#define PHY_OP_WRITE 0x01
  12891. +#define PHY_TURNAROUND 0x02
  12892. +#define PHY_PREAMBLE_SIZE 32
  12893. +#define MII_CR_SPEED_1000 0x0040
  12894. +#define MII_CR_SPEED_100 0x2000
  12895. +#define MII_CR_SPEED_10 0x0000
  12896. +#define E1000_PHY_ADDRESS 0x01
  12897. +#define PHY_AUTO_NEG_TIME 45 /* 4.5 Seconds */
  12898. +#define PHY_FORCE_TIME 20 /* 2.0 Seconds */
  12899. +#define PHY_REVISION_MASK 0xFFFFFFF0
  12900. +#define DEVICE_SPEED_MASK 0x00000300 /* Device Ctrl Reg Speed Mask */
  12901. +#define REG4_SPEED_MASK 0x01E0
  12902. +#define REG9_SPEED_MASK 0x0300
  12903. +#define ADVERTISE_10_HALF 0x0001
  12904. +#define ADVERTISE_10_FULL 0x0002
  12905. +#define ADVERTISE_100_HALF 0x0004
  12906. +#define ADVERTISE_100_FULL 0x0008
  12907. +#define ADVERTISE_1000_HALF 0x0010
  12908. +#define ADVERTISE_1000_FULL 0x0020
  12909. +#define AUTONEG_ADVERTISE_SPEED_DEFAULT 0x002F /* Everything but 1000-Half */
  12910. +#define AUTONEG_ADVERTISE_10_100_ALL 0x000F /* All 10/100 speeds*/
  12911. +#define AUTONEG_ADVERTISE_10_ALL 0x0003 /* 10Mbps Full & Half speeds*/
  12912. +
  12913. +#endif /* _E1000_HW_H_ */
  12914. Index: b/netboot/eepro.c
  12915. ===================================================================
  12916. --- a/netboot/eepro.c
  12917. +++ /dev/null
  12918. @@ -1,586 +0,0 @@
  12919. -/**************************************************************************
  12920. -Etherboot - BOOTP/TFTP Bootstrap Program
  12921. -Intel EEPRO/10 NIC driver for Etherboot
  12922. -Adapted from Linux eepro.c from kernel 2.2.17
  12923. -
  12924. -This board accepts a 32 pin EEPROM (29C256), however a test with a
  12925. -27C010 shows that this EPROM also works in the socket, but it's not clear
  12926. -how repeatably. The two top address pins appear to be held low, thus
  12927. -the bottom 32kB of the 27C010 is visible in the CPU's address space.
  12928. -To be sure you could put 4 copies of the code in the 27C010, then
  12929. -it doesn't matter whether the extra lines are held low or high, just
  12930. -hopefully not floating as CMOS chips don't like floating inputs.
  12931. -
  12932. -Be careful with seating the EPROM as the socket on my board actually
  12933. -has 34 pins, the top row of 2 are not used.
  12934. -***************************************************************************/
  12935. -
  12936. -/*
  12937. - * This program is free software; you can redistribute it and/or
  12938. - * modify it under the terms of the GNU General Public License as
  12939. - * published by the Free Software Foundation; either version 2, or (at
  12940. - * your option) any later version.
  12941. - */
  12942. -
  12943. -/* to get some global routines like printf */
  12944. -#include "etherboot.h"
  12945. -/* to get the interface to the body of the program */
  12946. -#include "nic.h"
  12947. -/* to get our own prototype */
  12948. -#include "cards.h"
  12949. -/* we use timer2 for microsecond waits */
  12950. -#include "timer.h"
  12951. -
  12952. -#undef DEBUG /* only after include files */
  12953. -
  12954. -/* Different 82595 chips */
  12955. -#define LAN595 0
  12956. -#define LAN595TX 1
  12957. -#define LAN595FX 2
  12958. -#define LAN595FX_10ISA 3
  12959. -
  12960. -#define SLOW_DOWN inb(0x80);
  12961. -
  12962. -/* The station (ethernet) address prefix, used for IDing the board. */
  12963. -#define SA_ADDR0 0x00 /* Etherexpress Pro/10 */
  12964. -#define SA_ADDR1 0xaa
  12965. -#define SA_ADDR2 0x00
  12966. -
  12967. -#define GetBit(x,y) ((x & (1<<y))>>y)
  12968. -
  12969. -/* EEPROM Word 0: */
  12970. -#define ee_PnP 0 /* Plug 'n Play enable bit */
  12971. -#define ee_Word1 1 /* Word 1? */
  12972. -#define ee_BusWidth 2 /* 8/16 bit */
  12973. -#define ee_FlashAddr 3 /* Flash Address */
  12974. -#define ee_FlashMask 0x7 /* Mask */
  12975. -#define ee_AutoIO 6 /* */
  12976. -#define ee_reserved0 7 /* =0! */
  12977. -#define ee_Flash 8 /* Flash there? */
  12978. -#define ee_AutoNeg 9 /* Auto Negotiation enabled? */
  12979. -#define ee_IO0 10 /* IO Address LSB */
  12980. -#define ee_IO0Mask 0x /*...*/
  12981. -#define ee_IO1 15 /* IO MSB */
  12982. -
  12983. -/* EEPROM Word 1: */
  12984. -#define ee_IntSel 0 /* Interrupt */
  12985. -#define ee_IntMask 0x7
  12986. -#define ee_LI 3 /* Link Integrity 0= enabled */
  12987. -#define ee_PC 4 /* Polarity Correction 0= enabled */
  12988. -#define ee_TPE_AUI 5 /* PortSelection 1=TPE */
  12989. -#define ee_Jabber 6 /* Jabber prevention 0= enabled */
  12990. -#define ee_AutoPort 7 /* Auto Port Selection 1= Disabled */
  12991. -#define ee_SMOUT 8 /* SMout Pin Control 0= Input */
  12992. -#define ee_PROM 9 /* Flash EPROM / PROM 0=Flash */
  12993. -#define ee_reserved1 10 /* .. 12 =0! */
  12994. -#define ee_AltReady 13 /* Alternate Ready, 0=normal */
  12995. -#define ee_reserved2 14 /* =0! */
  12996. -#define ee_Duplex 15
  12997. -
  12998. -/* Word2,3,4: */
  12999. -#define ee_IA5 0 /*bit start for individual Addr Byte 5 */
  13000. -#define ee_IA4 8 /*bit start for individual Addr Byte 5 */
  13001. -#define ee_IA3 0 /*bit start for individual Addr Byte 5 */
  13002. -#define ee_IA2 8 /*bit start for individual Addr Byte 5 */
  13003. -#define ee_IA1 0 /*bit start for individual Addr Byte 5 */
  13004. -#define ee_IA0 8 /*bit start for individual Addr Byte 5 */
  13005. -
  13006. -/* Word 5: */
  13007. -#define ee_BNC_TPE 0 /* 0=TPE */
  13008. -#define ee_BootType 1 /* 00=None, 01=IPX, 10=ODI, 11=NDIS */
  13009. -#define ee_BootTypeMask 0x3
  13010. -#define ee_NumConn 3 /* Number of Connections 0= One or Two */
  13011. -#define ee_FlashSock 4 /* Presence of Flash Socket 0= Present */
  13012. -#define ee_PortTPE 5
  13013. -#define ee_PortBNC 6
  13014. -#define ee_PortAUI 7
  13015. -#define ee_PowerMgt 10 /* 0= disabled */
  13016. -#define ee_CP 13 /* Concurrent Processing */
  13017. -#define ee_CPMask 0x7
  13018. -
  13019. -/* Word 6: */
  13020. -#define ee_Stepping 0 /* Stepping info */
  13021. -#define ee_StepMask 0x0F
  13022. -#define ee_BoardID 4 /* Manucaturer Board ID, reserved */
  13023. -#define ee_BoardMask 0x0FFF
  13024. -
  13025. -/* Word 7: */
  13026. -#define ee_INT_TO_IRQ 0 /* int to IRQ Mapping = 0x1EB8 for Pro/10+ */
  13027. -#define ee_FX_INT2IRQ 0x1EB8 /* the _only_ mapping allowed for FX chips */
  13028. -
  13029. -/*..*/
  13030. -#define ee_SIZE 0x40 /* total EEprom Size */
  13031. -#define ee_Checksum 0xBABA /* initial and final value for adding checksum */
  13032. -
  13033. -
  13034. -/* Card identification via EEprom: */
  13035. -#define ee_addr_vendor 0x10 /* Word offset for EISA Vendor ID */
  13036. -#define ee_addr_id 0x11 /* Word offset for Card ID */
  13037. -#define ee_addr_SN 0x12 /* Serial Number */
  13038. -#define ee_addr_CRC_8 0x14 /* CRC over last thee Bytes */
  13039. -
  13040. -
  13041. -#define ee_vendor_intel0 0x25 /* Vendor ID Intel */
  13042. -#define ee_vendor_intel1 0xD4
  13043. -#define ee_id_eepro10p0 0x10 /* ID for eepro/10+ */
  13044. -#define ee_id_eepro10p1 0x31
  13045. -
  13046. -/* now this section could be used by both boards: the oldies and the ee10:
  13047. - * ee10 uses tx buffer before of rx buffer and the oldies the inverse.
  13048. - * (aris)
  13049. - */
  13050. -#define RAM_SIZE 0x8000
  13051. -
  13052. -#define RCV_HEADER 8
  13053. -#define RCV_DEFAULT_RAM 0x6000
  13054. -#define RCV_RAM rcv_ram
  13055. -
  13056. -static unsigned rcv_ram = RCV_DEFAULT_RAM;
  13057. -
  13058. -#define XMT_HEADER 8
  13059. -#define XMT_RAM (RAM_SIZE - RCV_RAM)
  13060. -
  13061. -#define XMT_START ((rcv_start + RCV_RAM) % RAM_SIZE)
  13062. -
  13063. -#define RCV_LOWER_LIMIT (rcv_start >> 8)
  13064. -#define RCV_UPPER_LIMIT (((rcv_start + RCV_RAM) - 2) >> 8)
  13065. -#define XMT_LOWER_LIMIT (XMT_START >> 8)
  13066. -#define XMT_UPPER_LIMIT (((XMT_START + XMT_RAM) - 2) >> 8)
  13067. -
  13068. -#define RCV_START_PRO 0x00
  13069. -#define RCV_START_10 XMT_RAM
  13070. - /* by default the old driver */
  13071. -static unsigned rcv_start = RCV_START_PRO;
  13072. -
  13073. -#define RCV_DONE 0x0008
  13074. -#define RX_OK 0x2000
  13075. -#define RX_ERROR 0x0d81
  13076. -
  13077. -#define TX_DONE_BIT 0x0080
  13078. -#define CHAIN_BIT 0x8000
  13079. -#define XMT_STATUS 0x02
  13080. -#define XMT_CHAIN 0x04
  13081. -#define XMT_COUNT 0x06
  13082. -
  13083. -#define BANK0_SELECT 0x00
  13084. -#define BANK1_SELECT 0x40
  13085. -#define BANK2_SELECT 0x80
  13086. -
  13087. -/* Bank 0 registers */
  13088. -#define COMMAND_REG 0x00 /* Register 0 */
  13089. -#define MC_SETUP 0x03
  13090. -#define XMT_CMD 0x04
  13091. -#define DIAGNOSE_CMD 0x07
  13092. -#define RCV_ENABLE_CMD 0x08
  13093. -#define RCV_DISABLE_CMD 0x0a
  13094. -#define STOP_RCV_CMD 0x0b
  13095. -#define RESET_CMD 0x0e
  13096. -#define POWER_DOWN_CMD 0x18
  13097. -#define RESUME_XMT_CMD 0x1c
  13098. -#define SEL_RESET_CMD 0x1e
  13099. -#define STATUS_REG 0x01 /* Register 1 */
  13100. -#define RX_INT 0x02
  13101. -#define TX_INT 0x04
  13102. -#define EXEC_STATUS 0x30
  13103. -#define ID_REG 0x02 /* Register 2 */
  13104. -#define R_ROBIN_BITS 0xc0 /* round robin counter */
  13105. -#define ID_REG_MASK 0x2c
  13106. -#define ID_REG_SIG 0x24
  13107. -#define AUTO_ENABLE 0x10
  13108. -#define INT_MASK_REG 0x03 /* Register 3 */
  13109. -#define RX_STOP_MASK 0x01
  13110. -#define RX_MASK 0x02
  13111. -#define TX_MASK 0x04
  13112. -#define EXEC_MASK 0x08
  13113. -#define ALL_MASK 0x0f
  13114. -#define IO_32_BIT 0x10
  13115. -#define RCV_BAR 0x04 /* The following are word (16-bit) registers */
  13116. -#define RCV_STOP 0x06
  13117. -
  13118. -#define XMT_BAR_PRO 0x0a
  13119. -#define XMT_BAR_10 0x0b
  13120. -static unsigned xmt_bar = XMT_BAR_PRO;
  13121. -
  13122. -#define HOST_ADDRESS_REG 0x0c
  13123. -#define IO_PORT 0x0e
  13124. -#define IO_PORT_32_BIT 0x0c
  13125. -
  13126. -/* Bank 1 registers */
  13127. -#define REG1 0x01
  13128. -#define WORD_WIDTH 0x02
  13129. -#define INT_ENABLE 0x80
  13130. -#define INT_NO_REG 0x02
  13131. -#define RCV_LOWER_LIMIT_REG 0x08
  13132. -#define RCV_UPPER_LIMIT_REG 0x09
  13133. -
  13134. -#define XMT_LOWER_LIMIT_REG_PRO 0x0a
  13135. -#define XMT_UPPER_LIMIT_REG_PRO 0x0b
  13136. -#define XMT_LOWER_LIMIT_REG_10 0x0b
  13137. -#define XMT_UPPER_LIMIT_REG_10 0x0a
  13138. -static unsigned xmt_lower_limit_reg = XMT_LOWER_LIMIT_REG_PRO;
  13139. -static unsigned xmt_upper_limit_reg = XMT_UPPER_LIMIT_REG_PRO;
  13140. -
  13141. -/* Bank 2 registers */
  13142. -#define XMT_Chain_Int 0x20 /* Interrupt at the end of the transmit chain */
  13143. -#define XMT_Chain_ErrStop 0x40 /* Interrupt at the end of the chain even if there are errors */
  13144. -#define RCV_Discard_BadFrame 0x80 /* Throw bad frames away, and continue to receive others */
  13145. -#define REG2 0x02
  13146. -#define PRMSC_Mode 0x01
  13147. -#define Multi_IA 0x20
  13148. -#define REG3 0x03
  13149. -#define TPE_BIT 0x04
  13150. -#define BNC_BIT 0x20
  13151. -#define REG13 0x0d
  13152. -#define FDX 0x00
  13153. -#define A_N_ENABLE 0x02
  13154. -
  13155. -#define I_ADD_REG0 0x04
  13156. -#define I_ADD_REG1 0x05
  13157. -#define I_ADD_REG2 0x06
  13158. -#define I_ADD_REG3 0x07
  13159. -#define I_ADD_REG4 0x08
  13160. -#define I_ADD_REG5 0x09
  13161. -
  13162. -#define EEPROM_REG_PRO 0x0a
  13163. -#define EEPROM_REG_10 0x0b
  13164. -static unsigned eeprom_reg = EEPROM_REG_PRO;
  13165. -
  13166. -#define EESK 0x01
  13167. -#define EECS 0x02
  13168. -#define EEDI 0x04
  13169. -#define EEDO 0x08
  13170. -
  13171. -/* The horrible routine to read a word from the serial EEPROM. */
  13172. -/* IMPORTANT - the 82595 will be set to Bank 0 after the eeprom is read */
  13173. -
  13174. -/* The delay between EEPROM clock transitions. */
  13175. -#define eeprom_delay() { udelay(40); }
  13176. -#define EE_READ_CMD (6 << 6)
  13177. -
  13178. -/* do a full reset */
  13179. -#define eepro_full_reset(ioaddr) outb(RESET_CMD, ioaddr); udelay(40);
  13180. -
  13181. -/* do a nice reset */
  13182. -#define eepro_sel_reset(ioaddr) { \
  13183. - outb(SEL_RESET_CMD, ioaddr); \
  13184. - SLOW_DOWN; \
  13185. - SLOW_DOWN; \
  13186. - }
  13187. -
  13188. -/* clear all interrupts */
  13189. -#define eepro_clear_int(ioaddr) outb(ALL_MASK, ioaddr + STATUS_REG)
  13190. -
  13191. -/* enable rx */
  13192. -#define eepro_en_rx(ioaddr) outb(RCV_ENABLE_CMD, ioaddr)
  13193. -
  13194. -/* disable rx */
  13195. -#define eepro_dis_rx(ioaddr) outb(RCV_DISABLE_CMD, ioaddr)
  13196. -
  13197. -/* switch bank */
  13198. -#define eepro_sw2bank0(ioaddr) outb(BANK0_SELECT, ioaddr)
  13199. -#define eepro_sw2bank1(ioaddr) outb(BANK1_SELECT, ioaddr)
  13200. -#define eepro_sw2bank2(ioaddr) outb(BANK2_SELECT, ioaddr)
  13201. -
  13202. -static unsigned int rx_start, tx_start;
  13203. -static int tx_last;
  13204. -static unsigned tx_end;
  13205. -static int eepro = 0;
  13206. -static unsigned short ioaddr = 0;
  13207. -static unsigned int mem_start, mem_end = RCV_DEFAULT_RAM / 1024;
  13208. -
  13209. -#define udelay(n) waiton_timer2(((n)*TICKS_PER_MS)/1000)
  13210. -
  13211. -/**************************************************************************
  13212. -RESET - Reset adapter
  13213. -***************************************************************************/
  13214. -static void eepro_reset(struct nic *nic)
  13215. -{
  13216. - int temp_reg, i;
  13217. -
  13218. - /* put the card in its initial state */
  13219. - eepro_sw2bank2(ioaddr); /* be careful, bank2 now */
  13220. - temp_reg = inb(ioaddr + eeprom_reg);
  13221. -#ifdef DEBUG
  13222. - printf("Stepping %d\n", temp_reg >> 5);
  13223. -#endif
  13224. - if (temp_reg & 0x10) /* check the TurnOff Enable bit */
  13225. - outb(temp_reg & 0xEF, ioaddr + eeprom_reg);
  13226. - for (i = 0; i < ETH_ALEN; i++) /* fill the MAC address */
  13227. - outb(nic->node_addr[i], ioaddr + I_ADD_REG0 + i);
  13228. - temp_reg = inb(ioaddr + REG1);
  13229. - /* setup Transmit Chaining and discard bad RCV frames */
  13230. - outb(temp_reg | XMT_Chain_Int | XMT_Chain_ErrStop
  13231. - | RCV_Discard_BadFrame, ioaddr + REG1);
  13232. - temp_reg = inb(ioaddr + REG2); /* match broadcast */
  13233. - outb(temp_reg | 0x14, ioaddr + REG2);
  13234. - temp_reg = inb(ioaddr + REG3);
  13235. - outb(temp_reg & 0x3F, ioaddr + REG3); /* clear test mode */
  13236. - /* set the receiving mode */
  13237. - eepro_sw2bank1(ioaddr); /* be careful, bank1 now */
  13238. - /* initialise the RCV and XMT upper and lower limits */
  13239. - outb(RCV_LOWER_LIMIT, ioaddr + RCV_LOWER_LIMIT_REG);
  13240. - outb(RCV_UPPER_LIMIT, ioaddr + RCV_UPPER_LIMIT_REG);
  13241. - outb(XMT_LOWER_LIMIT, ioaddr + xmt_lower_limit_reg);
  13242. - outb(XMT_UPPER_LIMIT, ioaddr + xmt_upper_limit_reg);
  13243. - eepro_sw2bank0(ioaddr); /* Switch back to bank 0 */
  13244. - eepro_clear_int(ioaddr);
  13245. - /* Initialise RCV */
  13246. - outw(rx_start = (RCV_LOWER_LIMIT << 8), ioaddr + RCV_BAR);
  13247. - outw(((RCV_UPPER_LIMIT << 8) | 0xFE), ioaddr + RCV_STOP);
  13248. - /* Intialise XMT */
  13249. - outw((XMT_LOWER_LIMIT << 8), ioaddr + xmt_bar);
  13250. - eepro_sel_reset(ioaddr);
  13251. - tx_start = tx_end = (XMT_LOWER_LIMIT << 8);
  13252. - tx_last = 0;
  13253. - eepro_en_rx(ioaddr);
  13254. -}
  13255. -
  13256. -/**************************************************************************
  13257. -POLL - Wait for a frame
  13258. -***************************************************************************/
  13259. -static int eepro_poll(struct nic *nic)
  13260. -{
  13261. - int i;
  13262. - unsigned int rcv_car = rx_start;
  13263. - unsigned int rcv_event, rcv_status, rcv_next_frame, rcv_size;
  13264. -
  13265. - /* return true if there's an ethernet packet ready to read */
  13266. - /* nic->packet should contain data on return */
  13267. - /* nic->packetlen should contain length of data */
  13268. -#if 0
  13269. - if ((inb(ioaddr + STATUS_REG) & 0x40) == 0)
  13270. - return (0);
  13271. - outb(0x40, ioaddr + STATUS_REG);
  13272. -#endif
  13273. - outw(rcv_car, ioaddr + HOST_ADDRESS_REG);
  13274. - rcv_event = inw(ioaddr + IO_PORT);
  13275. - if (rcv_event != RCV_DONE)
  13276. - return (0);
  13277. - rcv_status = inw(ioaddr + IO_PORT);
  13278. - rcv_next_frame = inw(ioaddr + IO_PORT);
  13279. - rcv_size = inw(ioaddr + IO_PORT);
  13280. -#if 0
  13281. - printf("%hX %hX %d %hhX\n", rcv_status, rcv_next_frame, rcv_size,
  13282. - inb(ioaddr + STATUS_REG));
  13283. -#endif
  13284. - if ((rcv_status & (RX_OK|RX_ERROR)) != RX_OK) {
  13285. - printf("Receive error %hX\n", rcv_status);
  13286. - return (0);
  13287. - }
  13288. - rcv_size &= 0x3FFF;
  13289. - insw(ioaddr + IO_PORT, nic->packet, ((rcv_size + 3) >> 1));
  13290. -#if 0
  13291. - for (i = 0; i < 48; i++) {
  13292. - printf("%hhX", nic->packet[i]);
  13293. - putchar(i % 16 == 15 ? '\n' : ' ');
  13294. - }
  13295. -#endif
  13296. - nic->packetlen = rcv_size;
  13297. - rcv_car = rx_start + RCV_HEADER + rcv_size;
  13298. - rx_start = rcv_next_frame;
  13299. - if (rcv_car == 0)
  13300. - rcv_car = ((RCV_UPPER_LIMIT << 8) | 0xff);
  13301. - outw(rcv_car - 1, ioaddr + RCV_STOP);
  13302. - return (1);
  13303. -}
  13304. -
  13305. -/**************************************************************************
  13306. -TRANSMIT - Transmit a frame
  13307. -***************************************************************************/
  13308. -static void eepro_transmit(
  13309. - struct nic *nic,
  13310. - const char *d, /* Destination */
  13311. - unsigned int t, /* Type */
  13312. - unsigned int s, /* size */
  13313. - const char *p) /* Packet */
  13314. -{
  13315. - unsigned int status, tx_available, last, end, length;
  13316. - unsigned short type;
  13317. - int boguscount = 20;
  13318. -
  13319. - length = s + ETH_HLEN;
  13320. - if (tx_end > tx_start)
  13321. - tx_available = XMT_RAM - (tx_end - tx_start);
  13322. - else if (tx_end < tx_start)
  13323. - tx_available = tx_start - tx_end;
  13324. - else
  13325. - tx_available = XMT_RAM;
  13326. - last = tx_end;
  13327. - end = last + (((length + 3) >> 1) << 1) + XMT_HEADER;
  13328. - if (end >= (XMT_UPPER_LIMIT << 8)) {
  13329. - last = (XMT_LOWER_LIMIT << 8);
  13330. - end = last + (((length + 3) >> 1) << 1) + XMT_HEADER;
  13331. - }
  13332. - outw(last, ioaddr + HOST_ADDRESS_REG);
  13333. - outw(XMT_CMD, ioaddr + IO_PORT);
  13334. - outw(0, ioaddr + IO_PORT);
  13335. - outw(end, ioaddr + IO_PORT);
  13336. - outw(length, ioaddr + IO_PORT);
  13337. - outsw(ioaddr + IO_PORT, d, ETH_ALEN / 2);
  13338. - outsw(ioaddr + IO_PORT, nic->node_addr, ETH_ALEN / 2);
  13339. - type = htons(t);
  13340. - outsw(ioaddr + IO_PORT, &type, sizeof(type) / 2);
  13341. - outsw(ioaddr + IO_PORT, p, (s + 3) >> 1);
  13342. - /* A dummy read to flush the DRAM write pipeline */
  13343. - status = inw(ioaddr + IO_PORT);
  13344. - outw(last, ioaddr + xmt_bar);
  13345. - outb(XMT_CMD, ioaddr);
  13346. - tx_start = last;
  13347. - tx_last = last;
  13348. - tx_end = end;
  13349. -#if 0
  13350. - printf("%d %d\n", tx_start, tx_end);
  13351. -#endif
  13352. - while (boguscount > 0) {
  13353. - if (((status = inw(ioaddr + IO_PORT)) & TX_DONE_BIT) == 0) {
  13354. - udelay(40);
  13355. - boguscount--;
  13356. - continue;
  13357. - }
  13358. -#if DEBUG
  13359. - if ((status & 0x2000) == 0)
  13360. - printf("Transmit status %hX\n", status);
  13361. -#endif
  13362. - }
  13363. -}
  13364. -
  13365. -/**************************************************************************
  13366. -DISABLE - Turn off ethernet interface
  13367. -***************************************************************************/
  13368. -static void eepro_disable(struct nic *nic)
  13369. -{
  13370. - eepro_sw2bank0(ioaddr); /* Switch to bank 0 */
  13371. - /* Flush the Tx and disable Rx */
  13372. - outb(STOP_RCV_CMD, ioaddr);
  13373. - tx_start = tx_end = (XMT_LOWER_LIMIT << 8);
  13374. - tx_last = 0;
  13375. - /* Reset the 82595 */
  13376. - eepro_full_reset(ioaddr);
  13377. -}
  13378. -
  13379. -static int read_eeprom(int location)
  13380. -{
  13381. - int i;
  13382. - unsigned short retval = 0;
  13383. - int ee_addr = ioaddr + eeprom_reg;
  13384. - int read_cmd = location | EE_READ_CMD;
  13385. - int ctrl_val = EECS;
  13386. -
  13387. - if (eepro == LAN595FX_10ISA) {
  13388. - eepro_sw2bank1(ioaddr);
  13389. - outb(0x00, ioaddr + STATUS_REG);
  13390. - }
  13391. - eepro_sw2bank2(ioaddr);
  13392. - outb(ctrl_val, ee_addr);
  13393. - /* shift the read command bits out */
  13394. - for (i = 8; i >= 0; i--) {
  13395. - short outval = (read_cmd & (1 << i)) ? ctrl_val | EEDI : ctrl_val;
  13396. - outb(outval, ee_addr);
  13397. - outb(outval | EESK, ee_addr); /* EEPROM clock tick */
  13398. - eeprom_delay();
  13399. - outb(outval, ee_addr); /* finish EEPROM clock tick */
  13400. - eeprom_delay();
  13401. - }
  13402. - outb(ctrl_val, ee_addr);
  13403. - for (i = 16; i > 0; i--) {
  13404. - outb(ctrl_val | EESK, ee_addr);
  13405. - eeprom_delay();
  13406. - retval = (retval << 1) | ((inb(ee_addr) & EEDO) ? 1 : 0);
  13407. - outb(ctrl_val, ee_addr);
  13408. - eeprom_delay();
  13409. - }
  13410. - /* terminate the EEPROM access */
  13411. - ctrl_val &= ~EECS;
  13412. - outb(ctrl_val | EESK, ee_addr);
  13413. - eeprom_delay();
  13414. - outb(ctrl_val, ee_addr);
  13415. - eeprom_delay();
  13416. - eepro_sw2bank0(ioaddr);
  13417. - return (retval);
  13418. -}
  13419. -
  13420. -static int eepro_probe1(struct nic *nic)
  13421. -{
  13422. - int i, id, counter, l_eepro = 0;
  13423. - union {
  13424. - unsigned char caddr[ETH_ALEN];
  13425. - unsigned short saddr[ETH_ALEN/2];
  13426. - } station_addr;
  13427. - char *name;
  13428. -
  13429. - id = inb(ioaddr + ID_REG);
  13430. - if ((id & ID_REG_MASK) != ID_REG_SIG)
  13431. - return (0);
  13432. - counter = id & R_ROBIN_BITS;
  13433. - if (((id = inb(ioaddr + ID_REG)) & R_ROBIN_BITS) != (counter + 0x40))
  13434. - return (0);
  13435. - /* yes the 82595 has been found */
  13436. - station_addr.saddr[2] = read_eeprom(2);
  13437. - if (station_addr.saddr[2] == 0x0000 || station_addr.saddr[2] == 0xFFFF) {
  13438. - l_eepro = 3;
  13439. - eepro = LAN595FX_10ISA;
  13440. - eeprom_reg= EEPROM_REG_10;
  13441. - rcv_start = RCV_START_10;
  13442. - xmt_lower_limit_reg = XMT_LOWER_LIMIT_REG_10;
  13443. - xmt_upper_limit_reg = XMT_UPPER_LIMIT_REG_10;
  13444. - station_addr.saddr[2] = read_eeprom(2);
  13445. - }
  13446. - station_addr.saddr[1] = read_eeprom(3);
  13447. - station_addr.saddr[0] = read_eeprom(4);
  13448. - if (l_eepro)
  13449. - name = "Intel EtherExpress 10 ISA";
  13450. - else if (read_eeprom(7) == ee_FX_INT2IRQ) {
  13451. - name = "Intel EtherExpress Pro/10+ ISA";
  13452. - l_eepro = 2;
  13453. - } else if (station_addr.saddr[0] == SA_ADDR1) {
  13454. - name = "Intel EtherExpress Pro/10 ISA";
  13455. - l_eepro = 1;
  13456. - } else {
  13457. - l_eepro = 0;
  13458. - name = "Intel 82595-based LAN card";
  13459. - }
  13460. - station_addr.saddr[0] = swap16(station_addr.saddr[0]);
  13461. - station_addr.saddr[1] = swap16(station_addr.saddr[1]);
  13462. - station_addr.saddr[2] = swap16(station_addr.saddr[2]);
  13463. - for (i = 0; i < ETH_ALEN; i++) {
  13464. - nic->node_addr[i] = station_addr.caddr[i];
  13465. - }
  13466. - printf("\n%s ioaddr %#hX, addr %!", name, ioaddr, nic->node_addr);
  13467. - mem_start = RCV_LOWER_LIMIT << 8;
  13468. - if ((mem_end & 0x3F) < 3 || (mem_end & 0x3F) > 29)
  13469. - mem_end = RCV_UPPER_LIMIT << 8;
  13470. - else {
  13471. - mem_end = mem_end * 1024 + (RCV_LOWER_LIMIT << 8);
  13472. - rcv_ram = mem_end - (RCV_LOWER_LIMIT << 8);
  13473. - }
  13474. - printf(", Rx mem %dK, if %s\n", (mem_end - mem_start) >> 10,
  13475. - GetBit(read_eeprom(5), ee_BNC_TPE) ? "BNC" : "TP");
  13476. - return (1);
  13477. -}
  13478. -
  13479. -/**************************************************************************
  13480. -PROBE - Look for an adapter, this routine's visible to the outside
  13481. -***************************************************************************/
  13482. -struct nic *eepro_probe(struct nic *nic, unsigned short *probe_addrs)
  13483. -{
  13484. - unsigned short *p;
  13485. - /* same probe list as the Linux driver */
  13486. - static unsigned short ioaddrs[] = {
  13487. - 0x300, 0x210, 0x240, 0x280, 0x2C0, 0x200, 0x320, 0x340, 0x360, 0};
  13488. -
  13489. - if (probe_addrs == 0 || probe_addrs[0] == 0)
  13490. - probe_addrs = ioaddrs;
  13491. - for (p = probe_addrs; (ioaddr = *p) != 0; p++) {
  13492. - if (eepro_probe1(nic))
  13493. - break;
  13494. - }
  13495. - if (*p == 0)
  13496. - return (0);
  13497. - eepro_reset(nic);
  13498. - /* point to NIC specific routines */
  13499. - nic->reset = eepro_reset;
  13500. - nic->poll = eepro_poll;
  13501. - nic->transmit = eepro_transmit;
  13502. - nic->disable = eepro_disable;
  13503. - return (nic);
  13504. -}
  13505. Index: b/netboot/eepro100.c
  13506. ===================================================================
  13507. --- a/netboot/eepro100.c
  13508. +++ b/netboot/eepro100.c
  13509. @@ -80,8 +80,8 @@
  13510. *
  13511. * Caveats:
  13512. *
  13513. - * The etherboot framework moves the code to the 32k segment from
  13514. - * 0x98000 to 0xa0000. There is just a little room between the end of
  13515. + * The Etherboot framework moves the code to the 48k segment from
  13516. + * 0x94000 to 0xa0000. There is just a little room between the end of
  13517. * this driver and the 0xa0000 address. If you compile in too many
  13518. * features, this will overflow.
  13519. * The number under "hex" in the output of size that scrolls by while
  13520. @@ -92,17 +92,13 @@
  13521. /* The etherboot authors seem to dislike the argument ordering in
  13522. * outb macros that Linux uses. I disklike the confusion that this
  13523. * has caused even more.... This file uses the Linux argument ordering. */
  13524. -/* Sorry not us. It's inherted code from FreeBSD. [The authors] */
  13525. +/* Sorry not us. It's inherited code from FreeBSD. [The authors] */
  13526. #include "etherboot.h"
  13527. #include "nic.h"
  13528. #include "pci.h"
  13529. -#include "cards.h"
  13530. #include "timer.h"
  13531. -#undef virt_to_bus
  13532. -#define virt_to_bus(x) ((unsigned long)x)
  13533. -
  13534. static int ioaddr;
  13535. typedef unsigned char u8;
  13536. @@ -121,6 +117,18 @@
  13537. SCBEarlyRx = 20, /* Early receive byte count. */
  13538. };
  13539. +enum SCBCmdBits {
  13540. + SCBMaskCmdDone=0x8000, SCBMaskRxDone=0x4000, SCBMaskCmdIdle=0x2000,
  13541. + SCBMaskRxSuspend=0x1000, SCBMaskEarlyRx=0x0800, SCBMaskFlowCtl=0x0400,
  13542. + SCBTriggerIntr=0x0200, SCBMaskAll=0x0100,
  13543. + /* The rest are Rx and Tx commands. */
  13544. + CUStart=0x0010, CUResume=0x0020, CUStatsAddr=0x0040, CUShowStats=0x0050,
  13545. + CUCmdBase=0x0060, /* CU Base address (set to zero) . */
  13546. + CUDumpStats=0x0070, /* Dump then reset stats counters. */
  13547. + RxStart=0x0001, RxResume=0x0002, RxAbort=0x0004, RxAddrLoad=0x0006,
  13548. + RxResumeNoResources=0x0007,
  13549. +};
  13550. +
  13551. static int do_eeprom_cmd(int cmd, int cmd_len);
  13552. void hd(void *where, int n);
  13553. @@ -139,8 +147,6 @@
  13554. #define EE_WRITE_1 0x4806
  13555. #define EE_ENB (0x4800 | EE_CS)
  13556. -#define udelay(n) waiton_timer2(((n)*TICKS_PER_MS)/1000)
  13557. -
  13558. /* The EEPROM commands include the alway-set leading bit. */
  13559. #define EE_READ_CMD 6
  13560. @@ -184,9 +190,18 @@
  13561. Typically this takes 0 ticks. */
  13562. static inline void wait_for_cmd_done(int cmd_ioaddr)
  13563. {
  13564. - short wait = 100;
  13565. - do ;
  13566. - while(inb(cmd_ioaddr) && --wait >= 0);
  13567. + int wait = 0;
  13568. + int delayed_cmd;
  13569. +
  13570. + do
  13571. + if (inb(cmd_ioaddr) == 0) return;
  13572. + while(++wait <= 100);
  13573. + delayed_cmd = inb(cmd_ioaddr);
  13574. + do
  13575. + if (inb(cmd_ioaddr) == 0) break;
  13576. + while(++wait <= 10000);
  13577. + printf("Command %2.2x was not immediately accepted, %d ticks!\n",
  13578. + delayed_cmd, wait);
  13579. }
  13580. /* Elements of the dump_statistics block. This block must be lword aligned. */
  13581. @@ -212,35 +227,30 @@
  13582. /* A speedo3 TX buffer descriptor with two buffers... */
  13583. static struct TxFD {
  13584. - volatile s16 status;
  13585. - s16 command;
  13586. - u32 link; /* void * */
  13587. - u32 tx_desc_addr; /* (almost) Always points to the tx_buf_addr element. */
  13588. - s32 count; /* # of TBD (=2), Tx start thresh., etc. */
  13589. - /* This constitutes two "TBD" entries: hdr and data */
  13590. - u32 tx_buf_addr0; /* void *, header of frame to be transmitted. */
  13591. - s32 tx_buf_size0; /* Length of Tx hdr. */
  13592. - u32 tx_buf_addr1; /* void *, data to be transmitted. */
  13593. - s32 tx_buf_size1; /* Length of Tx data. */
  13594. + volatile s16 status;
  13595. + s16 command;
  13596. + u32 link; /* void * */
  13597. + u32 tx_desc_addr; /* (almost) Always points to the tx_buf_addr element. */
  13598. + s32 count; /* # of TBD (=2), Tx start thresh., etc. */
  13599. + /* This constitutes two "TBD" entries: hdr and data */
  13600. + u32 tx_buf_addr0; /* void *, header of frame to be transmitted. */
  13601. + s32 tx_buf_size0; /* Length of Tx hdr. */
  13602. + u32 tx_buf_addr1; /* void *, data to be transmitted. */
  13603. + s32 tx_buf_size1; /* Length of Tx data. */
  13604. } txfd;
  13605. struct RxFD { /* Receive frame descriptor. */
  13606. - volatile s16 status;
  13607. - s16 command;
  13608. - u32 link; /* struct RxFD * */
  13609. - u32 rx_buf_addr; /* void * */
  13610. - u16 count;
  13611. - u16 size;
  13612. - char packet[1518];
  13613. + volatile s16 status;
  13614. + s16 command;
  13615. + u32 link; /* struct RxFD * */
  13616. + u32 rx_buf_addr; /* void * */
  13617. + u16 count;
  13618. + u16 size;
  13619. + char packet[1518];
  13620. };
  13621. -#ifdef USE_LOWMEM_BUFFER
  13622. -#define rxfd ((struct RxFD *)(0x10000 - sizeof(struct RxFD)))
  13623. -#define ACCESS(x) x->
  13624. -#else
  13625. static struct RxFD rxfd;
  13626. #define ACCESS(x) x.
  13627. -#endif
  13628. static int congenb = 0; /* Enable congestion control in the DP83840. */
  13629. static int txfifo = 8; /* Tx FIFO threshold in 4 byte units, 0-15 */
  13630. @@ -256,8 +266,7 @@
  13631. u32 link;
  13632. unsigned char data[22];
  13633. } confcmd = {
  13634. - 0, CmdConfigure,
  13635. - (u32) & txfd,
  13636. + 0, 0, 0, /* filled in later */
  13637. {22, 0x08, 0, 0, 0, 0x80, 0x32, 0x03, 1, /* 1=Use MII 0=Use AUI */
  13638. 0, 0x2E, 0, 0x60, 0,
  13639. 0xf2, 0x48, 0, 0x40, 0xf2, 0x80, /* 0x40=Force full-duplex */
  13640. @@ -276,19 +285,20 @@
  13641. static int mdio_write(int phy_id, int location, int value)
  13642. {
  13643. - int val, boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
  13644. + int val, boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
  13645. - outl(0x04000000 | (location<<16) | (phy_id<<21) | value,
  13646. - ioaddr + SCBCtrlMDI);
  13647. - do {
  13648. - udelay(16);
  13649. -
  13650. - val = inl(ioaddr + SCBCtrlMDI);
  13651. - if (--boguscnt < 0) {
  13652. - printf(" mdio_write() timed out with val = %X.\n", val);
  13653. - }
  13654. - } while (! (val & 0x10000000));
  13655. - return val & 0xffff;
  13656. + outl(0x04000000 | (location<<16) | (phy_id<<21) | value,
  13657. + ioaddr + SCBCtrlMDI);
  13658. + do {
  13659. + udelay(16);
  13660. +
  13661. + val = inl(ioaddr + SCBCtrlMDI);
  13662. + if (--boguscnt < 0) {
  13663. + printf(" mdio_write() timed out with val = %X.\n", val);
  13664. + break;
  13665. + }
  13666. + } while (! (val & 0x10000000));
  13667. + return val & 0xffff;
  13668. }
  13669. /* Support function: mdio_read
  13670. @@ -298,17 +308,19 @@
  13671. */
  13672. static int mdio_read(int phy_id, int location)
  13673. {
  13674. - int val, boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
  13675. - outl(0x08000000 | (location<<16) | (phy_id<<21), ioaddr + SCBCtrlMDI);
  13676. - do {
  13677. - udelay(16);
  13678. -
  13679. - val = inl(ioaddr + SCBCtrlMDI);
  13680. - if (--boguscnt < 0) {
  13681. - printf( " mdio_read() timed out with val = %X.\n", val);
  13682. - }
  13683. - } while (! (val & 0x10000000));
  13684. - return val & 0xffff;
  13685. + int val, boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
  13686. + outl(0x08000000 | (location<<16) | (phy_id<<21), ioaddr + SCBCtrlMDI);
  13687. + do {
  13688. + udelay(16);
  13689. +
  13690. + val = inl(ioaddr + SCBCtrlMDI);
  13691. +
  13692. + if (--boguscnt < 0) {
  13693. + printf( " mdio_read() timed out with val = %X.\n", val);
  13694. + break;
  13695. + }
  13696. + } while (! (val & 0x10000000));
  13697. + return val & 0xffff;
  13698. }
  13699. /* The fixes for the code were kindly provided by Dragan Stancevic
  13700. @@ -340,25 +352,26 @@
  13701. return retval;
  13702. }
  13703. +#if 0
  13704. static inline void whereami (const char *str)
  13705. {
  13706. -#if 0
  13707. printf ("%s\n", str);
  13708. sleep (2);
  13709. -#endif
  13710. }
  13711. +#else
  13712. +#define whereami(s)
  13713. +#endif
  13714. -/* function: eepro100_reset
  13715. - * resets the card. This is used to allow Etherboot to probe the card again
  13716. - * from a "virginal" state....
  13717. - * Arguments: none
  13718. - *
  13719. - * returns: void.
  13720. - */
  13721. -
  13722. -static void eepro100_reset(struct nic *nic)
  13723. +static void eepro100_irq(struct nic *nic __unused, irq_action_t action __unused)
  13724. {
  13725. - outl(0, ioaddr + SCBPort);
  13726. + switch ( action ) {
  13727. + case DISABLE :
  13728. + break;
  13729. + case ENABLE :
  13730. + break;
  13731. + case FORCE :
  13732. + break;
  13733. + }
  13734. }
  13735. /* function: eepro100_transmit
  13736. @@ -373,61 +386,87 @@
  13737. static void eepro100_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
  13738. {
  13739. - struct eth_hdr {
  13740. - unsigned char dst_addr[ETH_ALEN];
  13741. - unsigned char src_addr[ETH_ALEN];
  13742. - unsigned short type;
  13743. - } hdr;
  13744. - unsigned short status;
  13745. - int to;
  13746. - int s1, s2;
  13747. -
  13748. - status = inw(ioaddr + SCBStatus);
  13749. - /* Acknowledge all of the current interrupt sources ASAP. */
  13750. - outw(status & 0xfc00, ioaddr + SCBStatus);
  13751. + struct eth_hdr {
  13752. + unsigned char dst_addr[ETH_ALEN];
  13753. + unsigned char src_addr[ETH_ALEN];
  13754. + unsigned short type;
  13755. + } hdr;
  13756. + unsigned short status;
  13757. + int s1, s2;
  13758. +
  13759. + status = inw(ioaddr + SCBStatus);
  13760. + /* Acknowledge all of the current interrupt sources ASAP. */
  13761. + outw(status & 0xfc00, ioaddr + SCBStatus);
  13762. #ifdef DEBUG
  13763. - printf ("transmitting type %hX packet (%d bytes). status = %hX, cmd=%hX\n",
  13764. - t, s, status, inw (ioaddr + SCBCmd));
  13765. + printf ("transmitting type %hX packet (%d bytes). status = %hX, cmd=%hX\n",
  13766. + t, s, status, inw (ioaddr + SCBCmd));
  13767. #endif
  13768. - memcpy (&hdr.dst_addr, d, ETH_ALEN);
  13769. - memcpy (&hdr.src_addr, nic->node_addr, ETH_ALEN);
  13770. + memcpy (&hdr.dst_addr, d, ETH_ALEN);
  13771. + memcpy (&hdr.src_addr, nic->node_addr, ETH_ALEN);
  13772. - hdr.type = htons (t);
  13773. + hdr.type = htons (t);
  13774. - txfd.status = 0;
  13775. - txfd.command = CmdSuspend | CmdTx | CmdTxFlex;
  13776. - txfd.link = virt_to_bus (&txfd);
  13777. - txfd.count = 0x02208000;
  13778. - txfd.tx_desc_addr = (u32)&txfd.tx_buf_addr0;
  13779. + txfd.status = 0;
  13780. + txfd.command = CmdSuspend | CmdTx | CmdTxFlex;
  13781. + txfd.link = virt_to_bus (&txfd);
  13782. + txfd.count = 0x02208000;
  13783. + txfd.tx_desc_addr = virt_to_bus(&txfd.tx_buf_addr0);
  13784. - txfd.tx_buf_addr0 = virt_to_bus (&hdr);
  13785. - txfd.tx_buf_size0 = sizeof (hdr);
  13786. + txfd.tx_buf_addr0 = virt_to_bus (&hdr);
  13787. + txfd.tx_buf_size0 = sizeof (hdr);
  13788. - txfd.tx_buf_addr1 = virt_to_bus (p);
  13789. - txfd.tx_buf_size1 = s;
  13790. + txfd.tx_buf_addr1 = virt_to_bus (p);
  13791. + txfd.tx_buf_size1 = s;
  13792. #ifdef DEBUG
  13793. - printf ("txfd: \n");
  13794. - hd (&txfd, sizeof (txfd));
  13795. + printf ("txfd: \n");
  13796. + hd (&txfd, sizeof (txfd));
  13797. #endif
  13798. - outl(virt_to_bus(&txfd), ioaddr + SCBPointer);
  13799. - outw(INT_MASK | CU_START, ioaddr + SCBCmd);
  13800. - wait_for_cmd_done(ioaddr + SCBCmd);
  13801. -
  13802. - s1 = inw (ioaddr + SCBStatus);
  13803. - load_timer2(10*TICKS_PER_MS); /* timeout 10 ms for transmit */
  13804. - while (!txfd.status && timer2_running())
  13805. - /* Wait */;
  13806. - s2 = inw (ioaddr + SCBStatus);
  13807. + outl(virt_to_bus(&txfd), ioaddr + SCBPointer);
  13808. + outw(INT_MASK | CU_START, ioaddr + SCBCmd);
  13809. + wait_for_cmd_done(ioaddr + SCBCmd);
  13810. +
  13811. + s1 = inw (ioaddr + SCBStatus);
  13812. + load_timer2(10*TICKS_PER_MS); /* timeout 10 ms for transmit */
  13813. + while (!txfd.status && timer2_running())
  13814. + /* Wait */;
  13815. + s2 = inw (ioaddr + SCBStatus);
  13816. #ifdef DEBUG
  13817. - printf ("s1 = %hX, s2 = %hX.\n", s1, s2);
  13818. + printf ("s1 = %hX, s2 = %hX.\n", s1, s2);
  13819. #endif
  13820. }
  13821. +/*
  13822. + * Sometimes the receiver stops making progress. This routine knows how to
  13823. + * get it going again, without losing packets or being otherwise nasty like
  13824. + * a chip reset would be. Previously the driver had a whole sequence
  13825. + * of if RxSuspended, if it's no buffers do one thing, if it's no resources,
  13826. + * do another, etc. But those things don't really matter. Separate logic
  13827. + * in the ISR provides for allocating buffers--the other half of operation
  13828. + * is just making sure the receiver is active. speedo_rx_soft_reset does that.
  13829. + * This problem with the old, more involved algorithm is shown up under
  13830. + * ping floods on the order of 60K packets/second on a 100Mbps fdx network.
  13831. + */
  13832. +static void
  13833. +speedo_rx_soft_reset(void)
  13834. +{
  13835. + wait_for_cmd_done(ioaddr + SCBCmd);
  13836. + /*
  13837. + * Put the hardware into a known state.
  13838. + */
  13839. + outb(RX_ABORT, ioaddr + SCBCmd);
  13840. +
  13841. + ACCESS(rxfd)rx_buf_addr = 0xffffffff;
  13842. +
  13843. + wait_for_cmd_done(ioaddr + SCBCmd);
  13844. +
  13845. + outb(RX_START, ioaddr + SCBCmd);
  13846. +}
  13847. +
  13848. /* function: eepro100_poll / eth_poll
  13849. * This recieves a packet from the network.
  13850. *
  13851. @@ -440,34 +479,87 @@
  13852. * returns the length of the packet in nic->packetlen.
  13853. */
  13854. -static int eepro100_poll(struct nic *nic)
  13855. +static int eepro100_poll(struct nic *nic, int retrieve)
  13856. {
  13857. - if (!ACCESS(rxfd)status)
  13858. - return 0;
  13859. + unsigned int status;
  13860. + status = inw(ioaddr + SCBStatus);
  13861. - /* Ok. We got a packet. Now restart the reciever.... */
  13862. - ACCESS(rxfd)status = 0;
  13863. - ACCESS(rxfd)command = 0xc000;
  13864. - outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  13865. - outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  13866. - wait_for_cmd_done(ioaddr + SCBCmd);
  13867. + if (!ACCESS(rxfd)status)
  13868. + return 0;
  13869. +
  13870. + /* There is a packet ready */
  13871. + if ( ! retrieve ) return 1;
  13872. +
  13873. + /*
  13874. + * The chip may have suspended reception for various reasons.
  13875. + * Check for that, and re-prime it should this be the case.
  13876. + */
  13877. + switch ((status >> 2) & 0xf) {
  13878. + case 0: /* Idle */
  13879. + break;
  13880. + case 1: /* Suspended */
  13881. + case 2: /* No resources (RxFDs) */
  13882. + case 9: /* Suspended with no more RBDs */
  13883. + case 10: /* No resources due to no RBDs */
  13884. + case 12: /* Ready with no RBDs */
  13885. + speedo_rx_soft_reset();
  13886. + break;
  13887. + case 3: case 5: case 6: case 7: case 8:
  13888. + case 11: case 13: case 14: case 15:
  13889. + /* these are all reserved values */
  13890. + break;
  13891. + }
  13892. +
  13893. + /* Ok. We got a packet. Now restart the reciever.... */
  13894. + ACCESS(rxfd)status = 0;
  13895. + ACCESS(rxfd)command = 0xc000;
  13896. + outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  13897. + outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  13898. + wait_for_cmd_done(ioaddr + SCBCmd);
  13899. #ifdef DEBUG
  13900. - printf ("Got a packet: Len = %d.\n", ACCESS(rxfd)count & 0x3fff);
  13901. + printf ("Got a packet: Len = %d.\n", ACCESS(rxfd)count & 0x3fff);
  13902. #endif
  13903. - nic->packetlen = ACCESS(rxfd)count & 0x3fff;
  13904. - memcpy (nic->packet, ACCESS(rxfd)packet, nic->packetlen);
  13905. + nic->packetlen = ACCESS(rxfd)count & 0x3fff;
  13906. + memcpy (nic->packet, ACCESS(rxfd)packet, nic->packetlen);
  13907. #ifdef DEBUG
  13908. - hd (nic->packet, 0x30);
  13909. + hd (nic->packet, 0x30);
  13910. #endif
  13911. - return 1;
  13912. + return 1;
  13913. }
  13914. -static void eepro100_disable(struct nic *nic)
  13915. +/* function: eepro100_disable
  13916. + * resets the card. This is used to allow Etherboot or Linux
  13917. + * to probe the card again from a "virginal" state....
  13918. + * Arguments: none
  13919. + *
  13920. + * returns: void.
  13921. + */
  13922. +static void eepro100_disable(struct dev *dev __unused)
  13923. {
  13924. - /* See if this PartialReset solves the problem with interfering with
  13925. - kernel operation after Etherboot hands over. - Ken 20001102 */
  13926. - outl(2, ioaddr + SCBPort);
  13927. +/* from eepro100_reset */
  13928. + outl(0, ioaddr + SCBPort);
  13929. +/* from eepro100_disable */
  13930. + /* See if this PartialReset solves the problem with interfering with
  13931. + kernel operation after Etherboot hands over. - Ken 20001102 */
  13932. + outl(2, ioaddr + SCBPort);
  13933. +
  13934. + /* The following is from the Intel e100 driver.
  13935. + * This hopefully solves the problem with hanging hard DOS images. */
  13936. +
  13937. + /* wait for the reset to take effect */
  13938. + udelay(20);
  13939. +
  13940. + /* Mask off our interrupt line -- it is unmasked after reset */
  13941. + {
  13942. + u16 intr_status;
  13943. + /* Disable interrupts on our PCI board by setting the mask bit */
  13944. + outw(INT_MASK, ioaddr + SCBCmd);
  13945. + intr_status = inw(ioaddr + SCBStatus);
  13946. + /* ack and clear intrs */
  13947. + outw(intr_status, ioaddr + SCBStatus);
  13948. + inw(ioaddr + SCBStatus);
  13949. + }
  13950. }
  13951. /* exported function: eepro100_probe / eth_probe
  13952. @@ -478,25 +570,30 @@
  13953. * leaves the 82557 initialized, and ready to recieve packets.
  13954. */
  13955. -struct nic *eepro100_probe(struct nic *nic, unsigned short *probeaddrs, struct pci_device *p)
  13956. +static int eepro100_probe(struct dev *dev, struct pci_device *p)
  13957. {
  13958. + struct nic *nic = (struct nic *)dev;
  13959. unsigned short sum = 0;
  13960. int i;
  13961. int read_cmd, ee_size;
  13962. - unsigned short value;
  13963. int options;
  13964. - int promisc;
  13965. + int rx_mode;
  13966. /* we cache only the first few words of the EEPROM data
  13967. be careful not to access beyond this array */
  13968. unsigned short eeprom[16];
  13969. - if (probeaddrs == 0 || probeaddrs[0] == 0)
  13970. + if (p->ioaddr == 0)
  13971. return 0;
  13972. - ioaddr = probeaddrs[0] & ~3; /* Mask the bit that says "this is an io addr" */
  13973. + ioaddr = p->ioaddr & ~3; /* Mask the bit that says "this is an io addr" */
  13974. + nic->ioaddr = ioaddr;
  13975. adjust_pci_device(p);
  13976. + /* Copy IRQ from PCI information */
  13977. + /* nic->irqno = pci->irq; */
  13978. + nic->irqno = 0;
  13979. +
  13980. if ((do_eeprom_cmd(EE_READ_CMD << 24, 27) & 0xffe0000)
  13981. == 0xffe0000) {
  13982. ee_size = 0x100;
  13983. @@ -513,123 +610,138 @@
  13984. sum += value;
  13985. }
  13986. - for (i=0;i<ETH_ALEN;i++) {
  13987. - nic->node_addr[i] = (eeprom[i/2] >> (8*(i&1))) & 0xff;
  13988. - }
  13989. - printf ("Ethernet addr: %!\n", nic->node_addr);
  13990. -
  13991. - if (sum != 0xBABA)
  13992. - printf("eepro100: Invalid EEPROM checksum %#hX, "
  13993. - "check settings before activating this device!\n", sum);
  13994. - outl(0, ioaddr + SCBPort);
  13995. - udelay (10000);
  13996. -
  13997. - whereami ("Got eeprom.");
  13998. -
  13999. - outl(virt_to_bus(&lstats), ioaddr + SCBPointer);
  14000. - outw(INT_MASK | CU_STATSADDR, ioaddr + SCBCmd);
  14001. - wait_for_cmd_done(ioaddr + SCBCmd);
  14002. -
  14003. - whereami ("set stats addr.");
  14004. - /* INIT RX stuff. */
  14005. -
  14006. - /* Base = 0 */
  14007. - outl(0, ioaddr + SCBPointer);
  14008. - outw(INT_MASK | RX_ADDR_LOAD, ioaddr + SCBCmd);
  14009. - wait_for_cmd_done(ioaddr + SCBCmd);
  14010. -
  14011. - whereami ("set rx base addr.");
  14012. -
  14013. - ACCESS(rxfd)status = 0x0001;
  14014. - ACCESS(rxfd)command = 0x0000;
  14015. - ACCESS(rxfd)link = virt_to_bus(&(ACCESS(rxfd)status));
  14016. - ACCESS(rxfd)rx_buf_addr = (int) &nic->packet;
  14017. - ACCESS(rxfd)count = 0;
  14018. - ACCESS(rxfd)size = 1528;
  14019. -
  14020. - outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  14021. - outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  14022. - wait_for_cmd_done(ioaddr + SCBCmd);
  14023. -
  14024. - whereami ("started RX process.");
  14025. -
  14026. - /* Start the reciever.... */
  14027. - ACCESS(rxfd)status = 0;
  14028. - ACCESS(rxfd)command = 0xc000;
  14029. - outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  14030. - outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  14031. -
  14032. - /* INIT TX stuff. */
  14033. -
  14034. - /* Base = 0 */
  14035. - outl(0, ioaddr + SCBPointer);
  14036. - outw(INT_MASK | CU_CMD_BASE, ioaddr + SCBCmd);
  14037. - wait_for_cmd_done(ioaddr + SCBCmd);
  14038. -
  14039. - whereami ("set TX base addr.");
  14040. -
  14041. - txfd.command = (CmdIASetup);
  14042. - txfd.status = 0x0000;
  14043. - txfd.link = virt_to_bus (&confcmd);
  14044. -
  14045. - {
  14046. - char *t = (char *)&txfd.tx_desc_addr;
  14047. + for (i=0;i<ETH_ALEN;i++) {
  14048. + nic->node_addr[i] = (eeprom[i/2] >> (8*(i&1))) & 0xff;
  14049. + }
  14050. + printf ("Ethernet addr: %!\n", nic->node_addr);
  14051. - for (i=0;i<ETH_ALEN;i++)
  14052. - t[i] = nic->node_addr[i];
  14053. - }
  14054. + if (sum != 0xBABA)
  14055. + printf("eepro100: Invalid EEPROM checksum %#hX, "
  14056. + "check settings before activating this device!\n", sum);
  14057. + outl(0, ioaddr + SCBPort);
  14058. + udelay (10000);
  14059. + whereami ("Got eeprom.");
  14060. +
  14061. + /* Base = 0 */
  14062. + outl(0, ioaddr + SCBPointer);
  14063. + outw(INT_MASK | RX_ADDR_LOAD, ioaddr + SCBCmd);
  14064. + wait_for_cmd_done(ioaddr + SCBCmd);
  14065. + whereami ("set rx base addr.");
  14066. +
  14067. + outl(virt_to_bus(&lstats), ioaddr + SCBPointer);
  14068. + outw(INT_MASK | CU_STATSADDR, ioaddr + SCBCmd);
  14069. + wait_for_cmd_done(ioaddr + SCBCmd);
  14070. + whereami ("set stats addr.");
  14071. +
  14072. + /* INIT RX stuff. */
  14073. + ACCESS(rxfd)status = 0x0001;
  14074. + ACCESS(rxfd)command = 0x0000;
  14075. + ACCESS(rxfd)link = virt_to_bus(&(ACCESS(rxfd)status));
  14076. + ACCESS(rxfd)rx_buf_addr = virt_to_bus(&nic->packet);
  14077. + ACCESS(rxfd)count = 0;
  14078. + ACCESS(rxfd)size = 1528;
  14079. +
  14080. + outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  14081. + outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  14082. + wait_for_cmd_done(ioaddr + SCBCmd);
  14083. +
  14084. + whereami ("started RX process.");
  14085. +
  14086. + /* Start the reciever.... */
  14087. + ACCESS(rxfd)status = 0;
  14088. + ACCESS(rxfd)command = 0xc000;
  14089. + outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  14090. + outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  14091. +
  14092. + /* INIT TX stuff. */
  14093. +
  14094. + /* Base = 0 */
  14095. + outl(0, ioaddr + SCBPointer);
  14096. + outw(INT_MASK | CU_CMD_BASE, ioaddr + SCBCmd);
  14097. + wait_for_cmd_done(ioaddr + SCBCmd);
  14098. +
  14099. + whereami ("set TX base addr.");
  14100. +
  14101. + txfd.command = (CmdIASetup);
  14102. + txfd.status = 0x0000;
  14103. + txfd.link = virt_to_bus (&confcmd);
  14104. +
  14105. + {
  14106. + char *t = (char *)&txfd.tx_desc_addr;
  14107. +
  14108. + for (i=0;i<ETH_ALEN;i++)
  14109. + t[i] = nic->node_addr[i];
  14110. + }
  14111. #ifdef DEBUG
  14112. - printf ("Setup_eaddr:\n");
  14113. - hd (&txfd, 0x20);
  14114. + printf ("Setup_eaddr:\n");
  14115. + hd (&txfd, 0x20);
  14116. #endif
  14117. - /* options = 0x40; */ /* 10mbps half duplex... */
  14118. - options = 0x00; /* Autosense */
  14119. -
  14120. - promisc = 0;
  14121. -
  14122. - if ( ((eeprom[6]>>8) & 0x3f) == DP83840
  14123. - || ((eeprom[6]>>8) & 0x3f) == DP83840A) {
  14124. - int mdi_reg23 = mdio_read(eeprom[6] & 0x1f, 23) | 0x0422;
  14125. - if (congenb)
  14126. - mdi_reg23 |= 0x0100;
  14127. - printf(" DP83840 specific setup, setting register 23 to %hX.\n",
  14128. - mdi_reg23);
  14129. - mdio_write(eeprom[6] & 0x1f, 23, mdi_reg23);
  14130. - }
  14131. - whereami ("Done DP8340 special setup.");
  14132. - if (options != 0) {
  14133. - mdio_write(eeprom[6] & 0x1f, 0,
  14134. - ((options & 0x20) ? 0x2000 : 0) | /* 100mbps? */
  14135. - ((options & 0x10) ? 0x0100 : 0)); /* Full duplex? */
  14136. - whereami ("set mdio_register.");
  14137. - }
  14138. + /* options = 0x40; */ /* 10mbps half duplex... */
  14139. + options = 0x00; /* Autosense */
  14140. - confcmd.command = CmdSuspend | CmdConfigure;
  14141. - confcmd.status = 0x0000;
  14142. - confcmd.link = virt_to_bus (&txfd);
  14143. - confcmd.data[1] = (txfifo << 4) | rxfifo;
  14144. - confcmd.data[4] = rxdmacount;
  14145. - confcmd.data[5] = txdmacount + 0x80;
  14146. - confcmd.data[15] = promisc ? 0x49: 0x48;
  14147. - confcmd.data[19] = (options & 0x10) ? 0xC0 : 0x80;
  14148. - confcmd.data[21] = promisc ? 0x0D: 0x05;
  14149. +#ifdef PROMISC
  14150. + rx_mode = 3;
  14151. +#elif ALLMULTI
  14152. + rx_mode = 1;
  14153. +#else
  14154. + rx_mode = 0;
  14155. +#endif
  14156. - outl(virt_to_bus(&txfd), ioaddr + SCBPointer);
  14157. - outw(INT_MASK | CU_START, ioaddr + SCBCmd);
  14158. - wait_for_cmd_done(ioaddr + SCBCmd);
  14159. + if ( ((eeprom[6]>>8) & 0x3f) == DP83840
  14160. + || ((eeprom[6]>>8) & 0x3f) == DP83840A) {
  14161. + int mdi_reg23 = mdio_read(eeprom[6] & 0x1f, 23) | 0x0422;
  14162. + if (congenb)
  14163. + mdi_reg23 |= 0x0100;
  14164. + printf(" DP83840 specific setup, setting register 23 to %hX.\n",
  14165. + mdi_reg23);
  14166. + mdio_write(eeprom[6] & 0x1f, 23, mdi_reg23);
  14167. + }
  14168. + whereami ("Done DP8340 special setup.");
  14169. + if (options != 0) {
  14170. + mdio_write(eeprom[6] & 0x1f, 0,
  14171. + ((options & 0x20) ? 0x2000 : 0) | /* 100mbps? */
  14172. + ((options & 0x10) ? 0x0100 : 0)); /* Full duplex? */
  14173. + whereami ("set mdio_register.");
  14174. + }
  14175. - whereami ("started TX thingy (config, iasetup).");
  14176. + confcmd.command = CmdSuspend | CmdConfigure;
  14177. + confcmd.status = 0x0000;
  14178. + confcmd.link = virt_to_bus (&txfd);
  14179. + confcmd.data[1] = (txfifo << 4) | rxfifo;
  14180. + confcmd.data[4] = rxdmacount;
  14181. + confcmd.data[5] = txdmacount + 0x80;
  14182. + confcmd.data[15] = (rx_mode & 2) ? 0x49: 0x48;
  14183. + confcmd.data[19] = (options & 0x10) ? 0xC0 : 0x80;
  14184. + confcmd.data[21] = (rx_mode & 1) ? 0x0D: 0x05;
  14185. +
  14186. + outl(virt_to_bus(&txfd), ioaddr + SCBPointer);
  14187. + outw(INT_MASK | CU_START, ioaddr + SCBCmd);
  14188. + wait_for_cmd_done(ioaddr + SCBCmd);
  14189. +
  14190. + whereami ("started TX thingy (config, iasetup).");
  14191. +
  14192. + load_timer2(10*TICKS_PER_MS);
  14193. + while (!txfd.status && timer2_running())
  14194. + /* Wait */;
  14195. +
  14196. + /* Read the status register once to disgard stale data */
  14197. + mdio_read(eeprom[6] & 0x1f, 1);
  14198. + /* Check to see if the network cable is plugged in.
  14199. + * This allows for faster failure if there is nothing
  14200. + * we can do.
  14201. + */
  14202. + if (!(mdio_read(eeprom[6] & 0x1f, 1) & (1 << 2))) {
  14203. + printf("Valid link not established\n");
  14204. + eepro100_disable(dev);
  14205. + return 0;
  14206. + }
  14207. - load_timer2(10*TICKS_PER_MS);
  14208. - while (!txfd.status && timer2_running())
  14209. - /* Wait */;
  14210. -
  14211. - nic->reset = eepro100_reset;
  14212. - nic->poll = eepro100_poll;
  14213. - nic->transmit = eepro100_transmit;
  14214. - nic->disable = eepro100_disable;
  14215. - return nic;
  14216. + dev->disable = eepro100_disable;
  14217. + nic->poll = eepro100_poll;
  14218. + nic->transmit = eepro100_transmit;
  14219. + nic->irq = eepro100_irq;
  14220. + return 1;
  14221. }
  14222. /*********************************************************************/
  14223. @@ -639,16 +751,59 @@
  14224. /* Hexdump a number of bytes from memory... */
  14225. void hd (void *where, int n)
  14226. {
  14227. - int i;
  14228. + int i;
  14229. - while (n > 0) {
  14230. - printf ("%X ", where);
  14231. - for (i=0;i < ( (n>16)?16:n);i++)
  14232. - printf (" %hhX", ((char *)where)[i]);
  14233. - printf ("\n");
  14234. - n -= 16;
  14235. - where += 16;
  14236. - }
  14237. + while (n > 0) {
  14238. + printf ("%X ", where);
  14239. + for (i=0;i < ( (n>16)?16:n);i++)
  14240. + printf (" %hhX", ((char *)where)[i]);
  14241. + printf ("\n");
  14242. + n -= 16;
  14243. + where += 16;
  14244. + }
  14245. }
  14246. #endif
  14247. +static struct pci_id eepro100_nics[] = {
  14248. +PCI_ROM(0x8086, 0x1029, "id1029", "Intel EtherExpressPro100 ID1029"),
  14249. +PCI_ROM(0x8086, 0x1030, "id1030", "Intel EtherExpressPro100 ID1030"),
  14250. +PCI_ROM(0x8086, 0x1031, "82801cam", "Intel 82801CAM (ICH3) Chipset Ethernet Controller"),
  14251. +PCI_ROM(0x8086, 0x1032, "eepro100-1032", "Intel PRO/100 VE Network Connection"),
  14252. +PCI_ROM(0x8086, 0x1033, "eepro100-1033", "Intel PRO/100 VM Network Connection"),
  14253. +PCI_ROM(0x8086, 0x1034, "eepro100-1034", "Intel PRO/100 VM Network Connection"),
  14254. +PCI_ROM(0x8086, 0x1035, "eepro100-1035", "Intel 82801CAM (ICH3) Chipset Ethernet Controller"),
  14255. +PCI_ROM(0x8086, 0x1036, "eepro100-1036", "Intel 82801CAM (ICH3) Chipset Ethernet Controller"),
  14256. +PCI_ROM(0x8086, 0x1037, "eepro100-1037", "Intel 82801CAM (ICH3) Chipset Ethernet Controller"),
  14257. +PCI_ROM(0x8086, 0x1038, "id1038", "Intel PRO/100 VM Network Connection"),
  14258. +PCI_ROM(0x8086, 0x1039, "82562et", "Intel PRO100 VE 82562ET"),
  14259. +PCI_ROM(0x8086, 0x103a, "id103a", "Intel Corporation 82559 InBusiness 10/100"),
  14260. +PCI_ROM(0x8086, 0x103b, "82562etb", "Intel PRO100 VE 82562ETB"),
  14261. +PCI_ROM(0x8086, 0x103c, "eepro100-103c", "Intel PRO/100 VM Network Connection"),
  14262. +PCI_ROM(0x8086, 0x103d, "eepro100-103d", "Intel PRO/100 VE Network Connection"),
  14263. +PCI_ROM(0x8086, 0x103e, "eepro100-103e", "Intel PRO/100 VM Network Connection"),
  14264. +PCI_ROM(0x8086, 0x1059, "82551qm", "Intel PRO/100 M Mobile Connection"),
  14265. +PCI_ROM(0x8086, 0x1209, "82559er", "Intel EtherExpressPro100 82559ER"),
  14266. +PCI_ROM(0x8086, 0x1227, "82865", "Intel 82865 EtherExpress PRO/100A"),
  14267. +PCI_ROM(0x8086, 0x1228, "82556", "Intel 82556 EtherExpress PRO/100 Smart"),
  14268. +PCI_ROM(0x8086, 0x1229, "eepro100", "Intel EtherExpressPro100"),
  14269. +PCI_ROM(0x8086, 0x2449, "82562em", "Intel EtherExpressPro100 82562EM"),
  14270. +PCI_ROM(0x8086, 0x2459, "82562-1", "Intel 82562 based Fast Ethernet Connection"),
  14271. +PCI_ROM(0x8086, 0x245d, "82562-2", "Intel 82562 based Fast Ethernet Connection"),
  14272. +PCI_ROM(0x8086, 0x1050, "82562ez", "Intel 82562EZ Network Connection"),
  14273. +PCI_ROM(0x8086, 0x5200, "eepro100-5200", "Intel EtherExpress PRO/100 Intelligent Server"),
  14274. +PCI_ROM(0x8086, 0x5201, "eepro100-5201", "Intel EtherExpress PRO/100 Intelligent Server"),
  14275. +};
  14276. +
  14277. +/* Cards with device ids 0x1030 to 0x103F, 0x2449, 0x2459 or 0x245D might need
  14278. + * a workaround for hardware bug on 10 mbit half duplex (see linux driver eepro100.c)
  14279. + * 2003/03/17 gbaum */
  14280. +
  14281. +
  14282. +struct pci_driver eepro100_driver = {
  14283. + .type = NIC_DRIVER,
  14284. + .name = "EEPRO100",
  14285. + .probe = eepro100_probe,
  14286. + .ids = eepro100_nics,
  14287. + .id_count = sizeof(eepro100_nics)/sizeof(eepro100_nics[0]),
  14288. + .class = 0
  14289. +};
  14290. Index: b/netboot/elf.h
  14291. ===================================================================
  14292. --- /dev/null
  14293. +++ b/netboot/elf.h
  14294. @@ -0,0 +1,234 @@
  14295. +#ifndef ELF_H
  14296. +#define ELF_H
  14297. +
  14298. +#define EI_NIDENT 16 /* Size of e_ident array. */
  14299. +
  14300. +/* Values for e_type. */
  14301. +#define ET_NONE 0 /* No file type */
  14302. +#define ET_REL 1 /* Relocatable file */
  14303. +#define ET_EXEC 2 /* Executable file */
  14304. +#define ET_DYN 3 /* Shared object file */
  14305. +#define ET_CORE 4 /* Core file */
  14306. +
  14307. +/* Values for e_machine (architecute). */
  14308. +#define EM_NONE 0 /* No machine */
  14309. +#define EM_M32 1 /* AT&T WE 32100 */
  14310. +#define EM_SPARC 2 /* SUN SPARC */
  14311. +#define EM_386 3 /* Intel 80386+ */
  14312. +#define EM_68K 4 /* Motorola m68k family */
  14313. +#define EM_88K 5 /* Motorola m88k family */
  14314. +#define EM_486 6 /* Perhaps disused */
  14315. +#define EM_860 7 /* Intel 80860 */
  14316. +#define EM_MIPS 8 /* MIPS R3000 big-endian */
  14317. +#define EM_S370 9 /* IBM System/370 */
  14318. +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
  14319. +
  14320. +#define EM_PARISC 15 /* HPPA */
  14321. +#define EM_VPP500 17 /* Fujitsu VPP500 */
  14322. +#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
  14323. +#define EM_960 19 /* Intel 80960 */
  14324. +#define EM_PPC 20 /* PowerPC */
  14325. +#define EM_PPC64 21 /* PowerPC 64-bit */
  14326. +#define EM_S390 22 /* IBM S390 */
  14327. +
  14328. +#define EM_V800 36 /* NEC V800 series */
  14329. +#define EM_FR20 37 /* Fujitsu FR20 */
  14330. +#define EM_RH32 38 /* TRW RH-32 */
  14331. +#define EM_RCE 39 /* Motorola RCE */
  14332. +#define EM_ARM 40 /* ARM */
  14333. +#define EM_FAKE_ALPHA 41 /* Digital Alpha */
  14334. +#define EM_SH 42 /* Hitachi SH */
  14335. +#define EM_SPARCV9 43 /* SPARC v9 64-bit */
  14336. +#define EM_TRICORE 44 /* Siemens Tricore */
  14337. +#define EM_ARC 45 /* Argonaut RISC Core */
  14338. +#define EM_H8_300 46 /* Hitachi H8/300 */
  14339. +#define EM_H8_300H 47 /* Hitachi H8/300H */
  14340. +#define EM_H8S 48 /* Hitachi H8S */
  14341. +#define EM_H8_500 49 /* Hitachi H8/500 */
  14342. +#define EM_IA_64 50 /* Intel Merced */
  14343. +#define EM_MIPS_X 51 /* Stanford MIPS-X */
  14344. +#define EM_COLDFIRE 52 /* Motorola Coldfire */
  14345. +#define EM_68HC12 53 /* Motorola M68HC12 */
  14346. +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
  14347. +#define EM_PCP 55 /* Siemens PCP */
  14348. +#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
  14349. +#define EM_NDR1 57 /* Denso NDR1 microprocessor */
  14350. +#define EM_STARCORE 58 /* Motorola Start*Core processor */
  14351. +#define EM_ME16 59 /* Toyota ME16 processor */
  14352. +#define EM_ST100 60 /* STMicroelectronic ST100 processor */
  14353. +#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
  14354. +#define EM_X86_64 62 /* AMD x86-64 architecture */
  14355. +#define EM_PDSP 63 /* Sony DSP Processor */
  14356. +
  14357. +#define EM_FX66 66 /* Siemens FX66 microcontroller */
  14358. +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
  14359. +#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
  14360. +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
  14361. +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
  14362. +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
  14363. +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
  14364. +#define EM_SVX 73 /* Silicon Graphics SVx */
  14365. +#define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */
  14366. +#define EM_VAX 75 /* Digital VAX */
  14367. +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
  14368. +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
  14369. +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
  14370. +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
  14371. +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
  14372. +#define EM_HUANY 81 /* Harvard University machine-independent object files */
  14373. +#define EM_PRISM 82 /* SiTera Prism */
  14374. +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
  14375. +#define EM_FR30 84 /* Fujitsu FR30 */
  14376. +#define EM_D10V 85 /* Mitsubishi D10V */
  14377. +#define EM_D30V 86 /* Mitsubishi D30V */
  14378. +#define EM_V850 87 /* NEC v850 */
  14379. +#define EM_M32R 88 /* Mitsubishi M32R */
  14380. +#define EM_MN10300 89 /* Matsushita MN10300 */
  14381. +#define EM_MN10200 90 /* Matsushita MN10200 */
  14382. +#define EM_PJ 91 /* picoJava */
  14383. +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
  14384. +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
  14385. +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
  14386. +#define EM_NUM 95
  14387. +
  14388. +/* Values for p_type. */
  14389. +#define PT_NULL 0 /* Unused entry. */
  14390. +#define PT_LOAD 1 /* Loadable segment. */
  14391. +#define PT_DYNAMIC 2 /* Dynamic linking information segment. */
  14392. +#define PT_INTERP 3 /* Pathname of interpreter. */
  14393. +#define PT_NOTE 4 /* Auxiliary information. */
  14394. +#define PT_SHLIB 5 /* Reserved (not used). */
  14395. +#define PT_PHDR 6 /* Location of program header itself. */
  14396. +
  14397. +/* Values for p_flags. */
  14398. +#define PF_X 0x1 /* Executable. */
  14399. +#define PF_W 0x2 /* Writable. */
  14400. +#define PF_R 0x4 /* Readable. */
  14401. +
  14402. +
  14403. +#define ELF_PROGRAM_RETURNS_BIT 0x8000000 /* e_flags bit 31 */
  14404. +
  14405. +#define EI_MAG0 0
  14406. +#define ELFMAG0 0x7f
  14407. +
  14408. +#define EI_MAG1 1
  14409. +#define ELFMAG1 'E'
  14410. +
  14411. +#define EI_MAG2 2
  14412. +#define ELFMAG2 'L'
  14413. +
  14414. +#define EI_MAG3 3
  14415. +#define ELFMAG3 'F'
  14416. +
  14417. +#define ELFMAG "\177ELF"
  14418. +
  14419. +#define EI_CLASS 4 /* File class byte index */
  14420. +#define ELFCLASSNONE 0 /* Invalid class */
  14421. +#define ELFCLASS32 1 /* 32-bit objects */
  14422. +#define ELFCLASS64 2 /* 64-bit objects */
  14423. +
  14424. +#define EI_DATA 5 /* Data encodeing byte index */
  14425. +#define ELFDATANONE 0 /* Invalid data encoding */
  14426. +#define ELFDATA2LSB 1 /* 2's complement little endian */
  14427. +#define ELFDATA2MSB 2 /* 2's complement big endian */
  14428. +
  14429. +#define EI_VERSION 6 /* File version byte index */
  14430. + /* Value must be EV_CURRENT */
  14431. +
  14432. +#define EV_NONE 0 /* Invalid ELF Version */
  14433. +#define EV_CURRENT 1 /* Current version */
  14434. +
  14435. +#define ELF32_PHDR_SIZE (8*4) /* Size of an elf program header */
  14436. +
  14437. +#ifndef ASSEMBLY
  14438. +/*
  14439. + * ELF definitions common to all 32-bit architectures.
  14440. + */
  14441. +
  14442. +typedef uint32_t Elf32_Addr;
  14443. +typedef uint16_t Elf32_Half;
  14444. +typedef uint32_t Elf32_Off;
  14445. +typedef int32_t Elf32_Sword;
  14446. +typedef uint32_t Elf32_Word;
  14447. +typedef uint32_t Elf32_Size;
  14448. +
  14449. +typedef uint64_t Elf64_Addr;
  14450. +typedef uint16_t Elf64_Half;
  14451. +typedef uint64_t Elf64_Off;
  14452. +typedef int32_t Elf64_Sword;
  14453. +typedef uint32_t Elf64_Word;
  14454. +typedef uint64_t Elf64_Size;
  14455. +
  14456. +/*
  14457. + * ELF header.
  14458. + */
  14459. +typedef struct {
  14460. + unsigned char e_ident[EI_NIDENT]; /* File identification. */
  14461. + Elf32_Half e_type; /* File type. */
  14462. + Elf32_Half e_machine; /* Machine architecture. */
  14463. + Elf32_Word e_version; /* ELF format version. */
  14464. + Elf32_Addr e_entry; /* Entry point. */
  14465. + Elf32_Off e_phoff; /* Program header file offset. */
  14466. + Elf32_Off e_shoff; /* Section header file offset. */
  14467. + Elf32_Word e_flags; /* Architecture-specific flags. */
  14468. + Elf32_Half e_ehsize; /* Size of ELF header in bytes. */
  14469. + Elf32_Half e_phentsize; /* Size of program header entry. */
  14470. + Elf32_Half e_phnum; /* Number of program header entries. */
  14471. + Elf32_Half e_shentsize; /* Size of section header entry. */
  14472. + Elf32_Half e_shnum; /* Number of section header entries. */
  14473. + Elf32_Half e_shstrndx; /* Section name strings section. */
  14474. +} Elf32_Ehdr;
  14475. +
  14476. +typedef struct {
  14477. + unsigned char e_ident[EI_NIDENT]; /* File identification. */
  14478. + Elf64_Half e_type; /* File type. */
  14479. + Elf64_Half e_machine; /* Machine architecture. */
  14480. + Elf64_Word e_version; /* ELF format version. */
  14481. + Elf64_Addr e_entry; /* Entry point. */
  14482. + Elf64_Off e_phoff; /* Program header file offset. */
  14483. + Elf64_Off e_shoff; /* Section header file offset. */
  14484. + Elf64_Word e_flags; /* Architecture-specific flags. */
  14485. + Elf64_Half e_ehsize; /* Size of ELF header in bytes. */
  14486. + Elf64_Half e_phentsize; /* Size of program header entry. */
  14487. + Elf64_Half e_phnum; /* Number of program header entries. */
  14488. + Elf64_Half e_shentsize; /* Size of section header entry. */
  14489. + Elf64_Half e_shnum; /* Number of section header entries. */
  14490. + Elf64_Half e_shstrndx; /* Section name strings section. */
  14491. +} Elf64_Ehdr;
  14492. +
  14493. +/*
  14494. + * Program header.
  14495. + */
  14496. +typedef struct {
  14497. + Elf32_Word p_type; /* Entry type. */
  14498. + Elf32_Off p_offset; /* File offset of contents. */
  14499. + Elf32_Addr p_vaddr; /* Virtual address (not used). */
  14500. + Elf32_Addr p_paddr; /* Physical address. */
  14501. + Elf32_Size p_filesz; /* Size of contents in file. */
  14502. + Elf32_Size p_memsz; /* Size of contents in memory. */
  14503. + Elf32_Word p_flags; /* Access permission flags. */
  14504. + Elf32_Size p_align; /* Alignment in memory and file. */
  14505. +} Elf32_Phdr;
  14506. +
  14507. +typedef struct {
  14508. + Elf64_Word p_type; /* Entry type. */
  14509. + Elf64_Word p_flags; /* Access permission flags. */
  14510. + Elf64_Off p_offset; /* File offset of contents. */
  14511. + Elf64_Addr p_vaddr; /* Virtual address (not used). */
  14512. + Elf64_Addr p_paddr; /* Physical address. */
  14513. + Elf64_Size p_filesz; /* Size of contents in file. */
  14514. + Elf64_Size p_memsz; /* Size of contents in memory. */
  14515. + Elf64_Size p_align; /* Alignment in memory and file. */
  14516. +} Elf64_Phdr;
  14517. +
  14518. +/* Standardized Elf image notes for booting... The name for all of these is ELFBoot */
  14519. +
  14520. +
  14521. +/* ELF Defines for the current architecture */
  14522. +#include "i386_elf.h"
  14523. +
  14524. +#endif /* ASSEMBLY */
  14525. +
  14526. +//#include "elf_boot.h"
  14527. +
  14528. +#endif /* ELF_H */
  14529. Index: b/netboot/endian.h
  14530. ===================================================================
  14531. --- /dev/null
  14532. +++ b/netboot/endian.h
  14533. @@ -0,0 +1,19 @@
  14534. +#ifndef ETHERBOOT_ENDIAN_H
  14535. +#define ETHERBOOT_ENDIAN_H
  14536. +
  14537. +/* Definitions for byte order, according to significance of bytes,
  14538. + from low addresses to high addresses. The value is what you get by
  14539. + putting '4' in the most significant byte, '3' in the second most
  14540. + significant byte, '2' in the second least significant byte, and '1'
  14541. + in the least significant byte, and then writing down one digit for
  14542. + each byte, starting with the byte at the lowest address at the left,
  14543. + and proceeding to the byte with the highest address at the right. */
  14544. +
  14545. +#define __LITTLE_ENDIAN 1234
  14546. +#define __BIG_ENDIAN 4321
  14547. +#define __PDP_ENDIAN 3412
  14548. +
  14549. +#include "i386_endian.h"
  14550. +
  14551. +
  14552. +#endif /* ETHERBOOT_ENDIAN_H */
  14553. Index: b/netboot/epic100.c
  14554. ===================================================================
  14555. --- a/netboot/epic100.c
  14556. +++ b/netboot/epic100.c
  14557. @@ -1,15 +1,18 @@
  14558. +
  14559. /* epic100.c: A SMC 83c170 EPIC/100 fast ethernet driver for Etherboot */
  14560. +/* 05/06/2003 timlegge Fixed relocation and implemented Multicast */
  14561. #define LINUX_OUT_MACROS
  14562. #include "etherboot.h"
  14563. +#include "pci.h"
  14564. #include "nic.h"
  14565. -#include "cards.h"
  14566. #include "timer.h"
  14567. #include "epic100.h"
  14568. -#undef virt_to_bus
  14569. -#define virt_to_bus(x) ((unsigned long)x)
  14570. +/* Condensed operations for readability */
  14571. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  14572. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  14573. #define TX_RING_SIZE 2 /* use at least 2 buffers for TX */
  14574. #define RX_RING_SIZE 2
  14575. @@ -26,23 +29,18 @@
  14576. /* The EPIC100 Rx and Tx buffer descriptors. */
  14577. struct epic_rx_desc {
  14578. - unsigned short status;
  14579. - unsigned short rxlength;
  14580. - unsigned long bufaddr;
  14581. - unsigned short buflength;
  14582. - unsigned short control;
  14583. - unsigned long next;
  14584. + unsigned long status;
  14585. + unsigned long bufaddr;
  14586. + unsigned long buflength;
  14587. + unsigned long next;
  14588. };
  14589. -
  14590. /* description of the tx descriptors control bits commonly used */
  14591. #define TD_STDFLAGS TD_LASTDESC
  14592. struct epic_tx_desc {
  14593. - unsigned short status;
  14594. - unsigned short txlength;
  14595. - unsigned long bufaddr;
  14596. - unsigned short buflength;
  14597. - unsigned short control;
  14598. + unsigned long status;
  14599. + unsigned long bufaddr;
  14600. + unsigned long buflength;
  14601. unsigned long next;
  14602. };
  14603. @@ -51,12 +49,15 @@
  14604. static void epic100_open(void);
  14605. static void epic100_init_ring(void);
  14606. -static void epic100_disable(struct nic *nic);
  14607. -static int epic100_poll(struct nic *nic);
  14608. +static void epic100_disable(struct dev *dev);
  14609. +static int epic100_poll(struct nic *nic, int retrieve);
  14610. static void epic100_transmit(struct nic *nic, const char *destaddr,
  14611. unsigned int type, unsigned int len, const char *data);
  14612. +#ifdef DEBUG_EEPROM
  14613. static int read_eeprom(int location);
  14614. +#endif
  14615. static int mii_read(int phy_id, int location);
  14616. +static void epic100_irq(struct nic *nic, irq_action_t action);
  14617. static int ioaddr;
  14618. @@ -69,6 +70,7 @@
  14619. static int mmctl ;
  14620. static int mmdata ;
  14621. static int lan0 ;
  14622. +static int mc0 ;
  14623. static int rxcon ;
  14624. static int txcon ;
  14625. static int prcdar ;
  14626. @@ -80,37 +82,27 @@
  14627. static unsigned short eeprom[64];
  14628. #endif
  14629. static signed char phys[4]; /* MII device addresses. */
  14630. -static struct epic_rx_desc rx_ring[RX_RING_SIZE];
  14631. -static struct epic_tx_desc tx_ring[TX_RING_SIZE];
  14632. -#ifdef USE_LOWMEM_BUFFER
  14633. -#define rx_packet ((char *)0x10000 - PKT_BUF_SZ * RX_RING_SIZE)
  14634. -#define tx_packet ((char *)0x10000 - PKT_BUF_SZ * RX_RING_SIZE - PKT_BUF_SZ * TX_RING_SIZE)
  14635. -#else
  14636. -static char rx_packet[PKT_BUF_SZ * RX_RING_SIZE];
  14637. -static char tx_packet[PKT_BUF_SZ * TX_RING_SIZE];
  14638. -#endif
  14639. +static struct epic_rx_desc rx_ring[RX_RING_SIZE]
  14640. + __attribute__ ((aligned(4)));
  14641. +static struct epic_tx_desc tx_ring[TX_RING_SIZE]
  14642. + __attribute__ ((aligned(4)));
  14643. +static unsigned char rx_packet[PKT_BUF_SZ * RX_RING_SIZE];
  14644. +static unsigned char tx_packet[PKT_BUF_SZ * TX_RING_SIZE];
  14645. /***********************************************************************/
  14646. /* Externally visible functions */
  14647. /***********************************************************************/
  14648. - static void
  14649. -epic100_reset(struct nic *nic)
  14650. -{
  14651. - /* Soft reset the chip. */
  14652. - outl(GC_SOFT_RESET, genctl);
  14653. -}
  14654. - struct nic*
  14655. -epic100_probe(struct nic *nic, unsigned short *probeaddrs)
  14656. + static int
  14657. +epic100_probe(struct dev *dev, struct pci_device *pci)
  14658. {
  14659. - unsigned short sum = 0;
  14660. - unsigned short value;
  14661. + struct nic *nic = (struct nic *)dev;
  14662. int i;
  14663. unsigned short* ap;
  14664. unsigned int phy, phy_idx;
  14665. - if (probeaddrs == 0 || probeaddrs[0] == 0)
  14666. + if (pci->ioaddr == 0)
  14667. return 0;
  14668. /* Ideally we would detect all network cards in slot order. That would
  14669. @@ -118,7 +110,9 @@
  14670. well with the current structure. So instead we detect just the
  14671. Epic cards in slot order. */
  14672. - ioaddr = probeaddrs[0] & ~3; /* Mask the bit that says "this is an io addr" */
  14673. + ioaddr = pci->ioaddr;
  14674. + nic->irqno = 0;
  14675. + nic->ioaddr = pci->ioaddr & ~3;
  14676. /* compute all used static epic100 registers address */
  14677. command = ioaddr + COMMAND; /* Control Register */
  14678. @@ -130,6 +124,7 @@
  14679. mmctl = ioaddr + MMCTL; /* MII Management Interface Control */
  14680. mmdata = ioaddr + MMDATA; /* MII Management Interface Data */
  14681. lan0 = ioaddr + LAN0; /* MAC address. (0x40-0x48) */
  14682. + mc0 = ioaddr + MC0; /* Multicast Control */
  14683. rxcon = ioaddr + RXCON; /* Receive Control */
  14684. txcon = ioaddr + TXCON; /* Transmit Control */
  14685. prcdar = ioaddr + PRCDAR; /* PCI Receive Current Descr Address */
  14686. @@ -160,11 +155,15 @@
  14687. }
  14688. #ifdef DEBUG_EEPROM
  14689. +{
  14690. + unsigned short sum = 0;
  14691. + unsigned short value;
  14692. for (i = 0; i < 64; i++) {
  14693. value = read_eeprom(i);
  14694. eeprom[i] = value;
  14695. sum += value;
  14696. }
  14697. +}
  14698. #if (EPIC_DEBUG > 1)
  14699. printf("EEPROM contents\n");
  14700. @@ -202,15 +201,26 @@
  14701. epic100_open();
  14702. - nic->reset = epic100_reset;
  14703. + dev->disable = epic100_disable;
  14704. nic->poll = epic100_poll;
  14705. nic->transmit = epic100_transmit;
  14706. - nic->disable = epic100_disable;
  14707. + nic->irq = epic100_irq;
  14708. - return nic;
  14709. + return 1;
  14710. }
  14711. - static void
  14712. +static void set_rx_mode(void)
  14713. +{
  14714. + unsigned char mc_filter[8];
  14715. + int i;
  14716. + memset(mc_filter, 0xff, sizeof(mc_filter));
  14717. + outl(0x0C, rxcon);
  14718. + for(i = 0; i < 4; i++)
  14719. + outw(((unsigned short *)mc_filter)[i], mc0 + i*4);
  14720. + return;
  14721. +}
  14722. +
  14723. + static void
  14724. epic100_open(void)
  14725. {
  14726. int mii_reg5;
  14727. @@ -237,11 +247,11 @@
  14728. outl(tmp, txcon);
  14729. /* Give adress of RX and TX ring to the chip */
  14730. - outl(virt_to_bus(&rx_ring), prcdar);
  14731. - outl(virt_to_bus(&tx_ring), ptcdar);
  14732. + outl(virt_to_le32desc(&rx_ring), prcdar);
  14733. + outl(virt_to_le32desc(&tx_ring), ptcdar);
  14734. /* Start the chip's Rx process: receive unicast and broadcast */
  14735. - outl(0x04, rxcon);
  14736. + set_rx_mode();
  14737. outl(CR_START_RX | CR_QUEUE_RX, command);
  14738. putchar('\n');
  14739. @@ -252,34 +262,30 @@
  14740. epic100_init_ring(void)
  14741. {
  14742. int i;
  14743. - char* p;
  14744. cur_rx = cur_tx = 0;
  14745. - p = &rx_packet[0];
  14746. for (i = 0; i < RX_RING_SIZE; i++) {
  14747. - rx_ring[i].status = RRING_OWN; /* Owned by Epic chip */
  14748. - rx_ring[i].buflength = PKT_BUF_SZ;
  14749. - rx_ring[i].bufaddr = virt_to_bus(p + (PKT_BUF_SZ * i));
  14750. - rx_ring[i].control = 0;
  14751. - rx_ring[i].next = virt_to_bus(&(rx_ring[i + 1]) );
  14752. + rx_ring[i].status = cpu_to_le32(RRING_OWN); /* Owned by Epic chip */
  14753. + rx_ring[i].buflength = cpu_to_le32(PKT_BUF_SZ);
  14754. + rx_ring[i].bufaddr = virt_to_bus(&rx_packet[i * PKT_BUF_SZ]);
  14755. + rx_ring[i].next = virt_to_le32desc(&rx_ring[i + 1]) ;
  14756. }
  14757. /* Mark the last entry as wrapping the ring. */
  14758. - rx_ring[i-1].next = virt_to_bus(&rx_ring[0]);
  14759. + rx_ring[i-1].next = virt_to_le32desc(&rx_ring[0]);
  14760. /*
  14761. *The Tx buffer descriptor is filled in as needed,
  14762. * but we do need to clear the ownership bit.
  14763. */
  14764. - p = &tx_packet[0];
  14765. for (i = 0; i < TX_RING_SIZE; i++) {
  14766. - tx_ring[i].status = 0; /* Owned by CPU */
  14767. - tx_ring[i].bufaddr = virt_to_bus(p + (PKT_BUF_SZ * i));
  14768. - tx_ring[i].control = TD_STDFLAGS;
  14769. - tx_ring[i].next = virt_to_bus(&(tx_ring[i + 1]) );
  14770. + tx_ring[i].status = 0x0000; /* Owned by CPU */
  14771. + tx_ring[i].buflength = 0x0000 | cpu_to_le32(TD_STDFLAGS << 16);
  14772. + tx_ring[i].bufaddr = virt_to_bus(&tx_packet[i * PKT_BUF_SZ]);
  14773. + tx_ring[i].next = virt_to_le32desc(&tx_ring[i + 1]);
  14774. }
  14775. - tx_ring[i-1].next = virt_to_bus(&tx_ring[0]);
  14776. + tx_ring[i-1].next = virt_to_le32desc(&tx_ring[0]);
  14777. }
  14778. /* function: epic100_transmit
  14779. @@ -296,7 +302,7 @@
  14780. unsigned int len, const char *data)
  14781. {
  14782. unsigned short nstype;
  14783. - char* txp;
  14784. + unsigned char *txp;
  14785. int entry;
  14786. /* Calculate the next Tx descriptor entry. */
  14787. @@ -310,7 +316,7 @@
  14788. return;
  14789. }
  14790. - txp = (char*)tx_ring[entry].bufaddr;
  14791. + txp = tx_packet + (entry * PKT_BUF_SZ);
  14792. memcpy(txp, destaddr, ETH_ALEN);
  14793. memcpy(txp + ETH_ALEN, nic->node_addr, ETH_ALEN);
  14794. @@ -319,26 +325,29 @@
  14795. memcpy(txp + ETH_HLEN, data, len);
  14796. len += ETH_HLEN;
  14797. -
  14798. + len &= 0x0FFF;
  14799. + while(len < ETH_ZLEN)
  14800. + txp[len++] = '\0';
  14801. /*
  14802. * Caution: the write order is important here,
  14803. * set the base address with the "ownership"
  14804. * bits last.
  14805. */
  14806. - tx_ring[entry].txlength = (len >= 60 ? len : 60);
  14807. - tx_ring[entry].buflength = len;
  14808. - tx_ring[entry].status = TRING_OWN; /* Pass ownership to the chip. */
  14809. +
  14810. + tx_ring[entry].buflength |= cpu_to_le32(len);
  14811. + tx_ring[entry].status = cpu_to_le32(len << 16) |
  14812. + cpu_to_le32(TRING_OWN); /* Pass ownership to the chip. */
  14813. cur_tx++;
  14814. /* Trigger an immediate transmit demand. */
  14815. - outl(CR_QUEUE_TX, command);
  14816. -
  14817. + outl(CR_QUEUE_TX, command);
  14818. +
  14819. load_timer2(10*TICKS_PER_MS); /* timeout 10 ms for transmit */
  14820. - while ((tx_ring[entry].status & TRING_OWN) && timer2_running())
  14821. + while ((le32_to_cpu(tx_ring[entry].status) & (TRING_OWN)) && timer2_running())
  14822. /* Wait */;
  14823. - if ((tx_ring[entry].status & TRING_OWN) != 0)
  14824. + if ((le32_to_cpu(tx_ring[entry].status) & TRING_OWN) != 0)
  14825. printf("Oops, transmitter timeout, status=%hX\n",
  14826. tx_ring[entry].status);
  14827. }
  14828. @@ -356,17 +365,19 @@
  14829. */
  14830. static int
  14831. -epic100_poll(struct nic *nic)
  14832. +epic100_poll(struct nic *nic, int retrieve)
  14833. {
  14834. int entry;
  14835. - int status;
  14836. int retcode;
  14837. -
  14838. + int status;
  14839. entry = cur_rx % RX_RING_SIZE;
  14840. - if ((status = rx_ring[entry].status & RRING_OWN) == RRING_OWN)
  14841. + if ((rx_ring[entry].status & cpu_to_le32(RRING_OWN)) == RRING_OWN)
  14842. return (0);
  14843. + if ( ! retrieve ) return 1;
  14844. +
  14845. + status = le32_to_cpu(rx_ring[entry].status);
  14846. /* We own the next entry, it's a new packet. Send it up. */
  14847. #if (EPIC_DEBUG > 4)
  14848. @@ -383,8 +394,8 @@
  14849. retcode = 0;
  14850. } else {
  14851. /* Omit the four octet CRC from the length. */
  14852. - nic->packetlen = rx_ring[entry].rxlength - 4;
  14853. - memcpy(nic->packet, (char*)rx_ring[entry].bufaddr, nic->packetlen);
  14854. + nic->packetlen = le32_to_cpu((rx_ring[entry].buflength))- 4;
  14855. + memcpy(nic->packet, &rx_packet[entry * PKT_BUF_SZ], nic->packetlen);
  14856. retcode = 1;
  14857. }
  14858. @@ -395,17 +406,30 @@
  14859. rx_ring[entry].status = RRING_OWN;
  14860. /* Restart Receiver */
  14861. - outl(CR_START_RX | CR_QUEUE_RX, command);
  14862. + outl(CR_START_RX | CR_QUEUE_RX, command);
  14863. return retcode;
  14864. }
  14865. static void
  14866. -epic100_disable(struct nic *nic)
  14867. +epic100_disable(struct dev *dev __unused)
  14868. {
  14869. + /* Soft reset the chip. */
  14870. + outl(GC_SOFT_RESET, genctl);
  14871. }
  14872. +static void epic100_irq(struct nic *nic __unused, irq_action_t action __unused)
  14873. +{
  14874. + switch ( action ) {
  14875. + case DISABLE :
  14876. + break;
  14877. + case ENABLE :
  14878. + break;
  14879. + case FORCE :
  14880. + break;
  14881. + }
  14882. +}
  14883. #ifdef DEBUG_EEPROM
  14884. /* Serial EEPROM section. */
  14885. @@ -479,3 +503,18 @@
  14886. break;
  14887. return inw(mmdata);
  14888. }
  14889. +
  14890. +
  14891. +static struct pci_id epic100_nics[] = {
  14892. +PCI_ROM(0x10b8, 0x0005, "epic100", "SMC EtherPowerII"), /* SMC 83c170 EPIC/100 */
  14893. +PCI_ROM(0x10b8, 0x0006, "smc-83c175", "SMC EPIC/C 83c175"),
  14894. +};
  14895. +
  14896. +struct pci_driver epic100_driver = {
  14897. + .type = NIC_DRIVER,
  14898. + .name = "EPIC100",
  14899. + .probe = epic100_probe,
  14900. + .ids = epic100_nics,
  14901. + .id_count = sizeof(epic100_nics)/sizeof(epic100_nics[0]),
  14902. + .class = 0,
  14903. +};
  14904. Index: b/netboot/etherboot.h
  14905. ===================================================================
  14906. --- a/netboot/etherboot.h
  14907. +++ b/netboot/etherboot.h
  14908. @@ -1,6 +1,6 @@
  14909. /*
  14910. * GRUB -- GRand Unified Bootloader
  14911. - * Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
  14912. + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
  14913. *
  14914. * This program is free software; you can redistribute it and/or modify
  14915. * it under the terms of the GNU General Public License as published by
  14916. @@ -17,528 +17,40 @@
  14917. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14918. */
  14919. -/* RULE: You must define the macro ``GRUB'' when including this header
  14920. - file in GRUB code. */
  14921. +#ifndef ETHERBOOT_H
  14922. +#define ETHERBOOT_H
  14923. -/* Based on "src/etherboot.h" in etherboot-5.0.5. */
  14924. -
  14925. -/**************************************************************************
  14926. -ETHERBOOT - BOOTP/TFTP Bootstrap Program
  14927. -
  14928. -Author: Martin Renters
  14929. - Date: Dec/93
  14930. -
  14931. -**************************************************************************/
  14932. -
  14933. -/* Include GRUB-specific macros and prototypes here. */
  14934. -#include <shared.h>
  14935. -
  14936. -/* FIXME: For now, enable the DHCP support. Perhaps I should segregate
  14937. - the DHCP support from the BOOTP support, and permit both to
  14938. - co-exist. */
  14939. -#undef NO_DHCP_SUPPORT
  14940. -
  14941. -/* In GRUB, the relocated address in Etherboot doesn't have any sense.
  14942. - Just define it as a bogus value. */
  14943. -#define RELOC 0
  14944. -
  14945. -/* FIXME: Should be an option. */
  14946. -#define BACKOFF_LIMIT 7
  14947. -
  14948. -#include <osdep.h>
  14949. -
  14950. -#define CTRL_C 3
  14951. -
  14952. -#ifndef MAX_TFTP_RETRIES
  14953. -# define MAX_TFTP_RETRIES 20
  14954. +#include "shared.h"
  14955. +#include "osdep.h"
  14956. +#include "if_ether.h"
  14957. +#include "in.h"
  14958. +
  14959. +/* Link configuration time in tenths of a second */
  14960. +#ifndef VALID_LINK_TIMEOUT
  14961. +#define VALID_LINK_TIMEOUT 100 /* 10.0 seconds */
  14962. #endif
  14963. -#ifndef MAX_BOOTP_RETRIES
  14964. -# define MAX_BOOTP_RETRIES 20
  14965. -#endif
  14966. -
  14967. -#define MAX_BOOTP_EXTLEN (ETH_FRAME_LEN - ETH_HLEN - \
  14968. - sizeof (struct bootp_t))
  14969. -
  14970. -#ifndef MAX_ARP_RETRIES
  14971. -# define MAX_ARP_RETRIES 20
  14972. -#endif
  14973. -
  14974. -#ifndef MAX_RPC_RETRIES
  14975. -# define MAX_RPC_RETRIES 20
  14976. -#endif
  14977. -
  14978. -#define TICKS_PER_SEC 18
  14979. -
  14980. -/* Inter-packet retry in ticks */
  14981. -#define TIMEOUT (10 * TICKS_PER_SEC)
  14982. -
  14983. -/* These settings have sense only if compiled with -DCONGESTED */
  14984. -/* total retransmission timeout in ticks */
  14985. -#define TFTP_TIMEOUT (30 * TICKS_PER_SEC)
  14986. -/* packet retransmission timeout in ticks */
  14987. -#define TFTP_REXMT (3 * TICKS_PER_SEC)
  14988. -
  14989. #ifndef NULL
  14990. # define NULL ((void *) 0)
  14991. #endif
  14992. -/*
  14993. - I'm moving towards the defined names in linux/if_ether.h for clarity.
  14994. - The confusion between 60/64 and 1514/1518 arose because the NS8390
  14995. - counts the 4 byte frame checksum in the incoming packet, but not
  14996. - in the outgoing packet. 60/1514 are the correct numbers for most
  14997. - if not all of the other NIC controllers. I will be retiring the
  14998. - 64/1518 defines in the lead-up to 5.0.
  14999. -*/
  15000. -
  15001. -#define ETH_ALEN 6 /* Size of Ethernet address */
  15002. -#define ETH_HLEN 14 /* Size of ethernet header */
  15003. -#define ETH_ZLEN 60 /* Minimum packet */
  15004. -/*#define ETH_MIN_PACKET 64*/
  15005. -#define ETH_FRAME_LEN 1514 /* Maximum packet */
  15006. -/*#define ETH_MAX_PACKET 1518*/
  15007. -/* Because some DHCP/BOOTP servers don't treat the maximum length the same
  15008. - as Etherboot, subtract the size of an IP header and that of an UDP
  15009. - header. */
  15010. -#define ETH_MAX_MTU (ETH_FRAME_LEN - ETH_HLEN \
  15011. - - sizeof (struct iphdr) \
  15012. - - sizeof (struct udphdr))
  15013. -
  15014. -#define ARP_CLIENT 0
  15015. -#define ARP_SERVER 1
  15016. -#define ARP_GATEWAY 2
  15017. -#define ARP_ROOTSERVER 3
  15018. -#define ARP_SWAPSERVER 4
  15019. -#define MAX_ARP ARP_SWAPSERVER+1
  15020. -
  15021. -#define RARP_REQUEST 3
  15022. -#define RARP_REPLY 4
  15023. -
  15024. -#define IP 0x0800
  15025. -#define ARP 0x0806
  15026. -#define RARP 0x8035
  15027. -
  15028. -#define BOOTP_SERVER 67
  15029. -#define BOOTP_CLIENT 68
  15030. -#define TFTP_PORT 69
  15031. -#define SUNRPC_PORT 111
  15032. -
  15033. -#define IP_UDP 17
  15034. -/* Same after going through htonl */
  15035. -#define IP_BROADCAST 0xFFFFFFFF
  15036. -
  15037. -#define ARP_REQUEST 1
  15038. -#define ARP_REPLY 2
  15039. -
  15040. -#define BOOTP_REQUEST 1
  15041. -#define BOOTP_REPLY 2
  15042. -
  15043. -#define TAG_LEN(p) (*((p) + 1))
  15044. -#define RFC1533_COOKIE 99, 130, 83, 99
  15045. -#define RFC1533_PAD 0
  15046. -#define RFC1533_NETMASK 1
  15047. -#define RFC1533_TIMEOFFSET 2
  15048. -#define RFC1533_GATEWAY 3
  15049. -#define RFC1533_TIMESERVER 4
  15050. -#define RFC1533_IEN116NS 5
  15051. -#define RFC1533_DNS 6
  15052. -#define RFC1533_LOGSERVER 7
  15053. -#define RFC1533_COOKIESERVER 8
  15054. -#define RFC1533_LPRSERVER 9
  15055. -#define RFC1533_IMPRESSSERVER 10
  15056. -#define RFC1533_RESOURCESERVER 11
  15057. -#define RFC1533_HOSTNAME 12
  15058. -#define RFC1533_BOOTFILESIZE 13
  15059. -#define RFC1533_MERITDUMPFILE 14
  15060. -#define RFC1533_DOMAINNAME 15
  15061. -#define RFC1533_SWAPSERVER 16
  15062. -#define RFC1533_ROOTPATH 17
  15063. -#define RFC1533_EXTENSIONPATH 18
  15064. -#define RFC1533_IPFORWARDING 19
  15065. -#define RFC1533_IPSOURCEROUTING 20
  15066. -#define RFC1533_IPPOLICYFILTER 21
  15067. -#define RFC1533_IPMAXREASSEMBLY 22
  15068. -#define RFC1533_IPTTL 23
  15069. -#define RFC1533_IPMTU 24
  15070. -#define RFC1533_IPMTUPLATEAU 25
  15071. -#define RFC1533_INTMTU 26
  15072. -#define RFC1533_INTLOCALSUBNETS 27
  15073. -#define RFC1533_INTBROADCAST 28
  15074. -#define RFC1533_INTICMPDISCOVER 29
  15075. -#define RFC1533_INTICMPRESPOND 30
  15076. -#define RFC1533_INTROUTEDISCOVER 31
  15077. -#define RFC1533_INTROUTESOLICIT 32
  15078. -#define RFC1533_INTSTATICROUTES 33
  15079. -#define RFC1533_LLTRAILERENCAP 34
  15080. -#define RFC1533_LLARPCACHETMO 35
  15081. -#define RFC1533_LLETHERNETENCAP 36
  15082. -#define RFC1533_TCPTTL 37
  15083. -#define RFC1533_TCPKEEPALIVETMO 38
  15084. -#define RFC1533_TCPKEEPALIVEGB 39
  15085. -#define RFC1533_NISDOMAIN 40
  15086. -#define RFC1533_NISSERVER 41
  15087. -#define RFC1533_NTPSERVER 42
  15088. -#define RFC1533_VENDOR 43
  15089. -#define RFC1533_NBNS 44
  15090. -#define RFC1533_NBDD 45
  15091. -#define RFC1533_NBNT 46
  15092. -#define RFC1533_NBSCOPE 47
  15093. -#define RFC1533_XFS 48
  15094. -#define RFC1533_XDM 49
  15095. -#ifndef NO_DHCP_SUPPORT
  15096. -#define RFC2132_REQ_ADDR 50
  15097. -#define RFC2132_MSG_TYPE 53
  15098. -#define RFC2132_SRV_ID 54
  15099. -#define RFC2132_PARAM_LIST 55
  15100. -#define RFC2132_MAX_SIZE 57
  15101. -#define RFC2132_VENDOR_CLASS_ID 60
  15102. -
  15103. -#define DHCPDISCOVER 1
  15104. -#define DHCPOFFER 2
  15105. -#define DHCPREQUEST 3
  15106. -#define DHCPACK 5
  15107. -#endif /* NO_DHCP_SUPPORT */
  15108. -
  15109. -#define RFC1533_VENDOR_MAJOR 0
  15110. -#define RFC1533_VENDOR_MINOR 0
  15111. -
  15112. -#define RFC1533_VENDOR_MAGIC 128
  15113. -#define RFC1533_VENDOR_ADDPARM 129
  15114. -#define RFC1533_VENDOR_MNUOPTS 160
  15115. -#define RFC1533_VENDOR_SELECTION 176
  15116. -#define RFC1533_VENDOR_MOTD 184
  15117. -#define RFC1533_VENDOR_NUMOFMOTD 8
  15118. -#define RFC1533_VENDOR_IMG 192
  15119. -#define RFC1533_VENDOR_NUMOFIMG 16
  15120. -
  15121. -#define RFC1533_VENDOR_CONFIGFILE 150
  15122. -
  15123. -#define RFC1533_END 255
  15124. -
  15125. -#define BOOTP_VENDOR_LEN 64
  15126. -#ifndef NO_DHCP_SUPPORT
  15127. -#define DHCP_OPT_LEN 312
  15128. -#endif /* NO_DHCP_SUPPORT */
  15129. -
  15130. -#define TFTP_DEFAULTSIZE_PACKET 512
  15131. -#define TFTP_MAX_PACKET 1432 /* 512 */
  15132. -
  15133. -#define TFTP_RRQ 1
  15134. -#define TFTP_WRQ 2
  15135. -#define TFTP_DATA 3
  15136. -#define TFTP_ACK 4
  15137. -#define TFTP_ERROR 5
  15138. -#define TFTP_OACK 6
  15139. -
  15140. -#define TFTP_CODE_EOF 1
  15141. -#define TFTP_CODE_MORE 2
  15142. -#define TFTP_CODE_ERROR 3
  15143. -#define TFTP_CODE_BOOT 4
  15144. -#define TFTP_CODE_CFG 5
  15145. -
  15146. -#define AWAIT_ARP 0
  15147. -#define AWAIT_BOOTP 1
  15148. -#define AWAIT_TFTP 2
  15149. -#define AWAIT_RARP 3
  15150. -#define AWAIT_RPC 4
  15151. -#define AWAIT_QDRAIN 5 /* drain queue, process ARP requests */
  15152. -
  15153. -typedef struct
  15154. -{
  15155. - unsigned long s_addr;
  15156. -}
  15157. -in_addr;
  15158. -
  15159. -struct arptable_t
  15160. -{
  15161. - in_addr ipaddr;
  15162. - unsigned char node[6];
  15163. -};
  15164. -
  15165. -/*
  15166. - * A pity sipaddr and tipaddr are not longword aligned or we could use
  15167. - * in_addr. No, I don't want to use #pragma packed.
  15168. - */
  15169. -struct arprequest
  15170. -{
  15171. - unsigned short hwtype;
  15172. - unsigned short protocol;
  15173. - char hwlen;
  15174. - char protolen;
  15175. - unsigned short opcode;
  15176. - char shwaddr[6];
  15177. - char sipaddr[4];
  15178. - char thwaddr[6];
  15179. - char tipaddr[4];
  15180. -};
  15181. -
  15182. -struct iphdr
  15183. -{
  15184. - char verhdrlen;
  15185. - char service;
  15186. - unsigned short len;
  15187. - unsigned short ident;
  15188. - unsigned short frags;
  15189. - char ttl;
  15190. - char protocol;
  15191. - unsigned short chksum;
  15192. - in_addr src;
  15193. - in_addr dest;
  15194. -};
  15195. -
  15196. -struct udphdr
  15197. -{
  15198. - unsigned short src;
  15199. - unsigned short dest;
  15200. - unsigned short len;
  15201. - unsigned short chksum;
  15202. -};
  15203. -
  15204. -/* Format of a bootp packet. */
  15205. -struct bootp_t
  15206. -{
  15207. - char bp_op;
  15208. - char bp_htype;
  15209. - char bp_hlen;
  15210. - char bp_hops;
  15211. - unsigned long bp_xid;
  15212. - unsigned short bp_secs;
  15213. - unsigned short unused;
  15214. - in_addr bp_ciaddr;
  15215. - in_addr bp_yiaddr;
  15216. - in_addr bp_siaddr;
  15217. - in_addr bp_giaddr;
  15218. - char bp_hwaddr[16];
  15219. - char bp_sname[64];
  15220. - char bp_file[128];
  15221. -#ifdef NO_DHCP_SUPPORT
  15222. - char bp_vend[BOOTP_VENDOR_LEN];
  15223. -#else
  15224. - char bp_vend[DHCP_OPT_LEN];
  15225. -#endif /* NO_DHCP_SUPPORT */
  15226. -};
  15227. -
  15228. -/* Format of a bootp IP packet. */
  15229. -struct bootpip_t
  15230. -{
  15231. - struct iphdr ip;
  15232. - struct udphdr udp;
  15233. - struct bootp_t bp;
  15234. -};
  15235. -
  15236. -/* Format of bootp packet with extensions. */
  15237. -struct bootpd_t
  15238. -{
  15239. - struct bootp_t bootp_reply;
  15240. - unsigned char bootp_extension[MAX_BOOTP_EXTLEN];
  15241. -};
  15242. -
  15243. -struct tftp_t
  15244. -{
  15245. - struct iphdr ip;
  15246. - struct udphdr udp;
  15247. - unsigned short opcode;
  15248. - union
  15249. - {
  15250. - char rrq[TFTP_DEFAULTSIZE_PACKET];
  15251. -
  15252. - struct
  15253. - {
  15254. - unsigned short block;
  15255. - char download[TFTP_MAX_PACKET];
  15256. - }
  15257. - data;
  15258. -
  15259. - struct
  15260. - {
  15261. - unsigned short block;
  15262. - }
  15263. - ack;
  15264. -
  15265. - struct
  15266. - {
  15267. - unsigned short errcode;
  15268. - char errmsg[TFTP_DEFAULTSIZE_PACKET];
  15269. - }
  15270. - err;
  15271. -
  15272. - struct
  15273. - {
  15274. - char data[TFTP_DEFAULTSIZE_PACKET+2];
  15275. - }
  15276. - oack;
  15277. - }
  15278. - u;
  15279. -};
  15280. -
  15281. -/* Define a smaller tftp packet solely for making requests to conserve stack
  15282. - 512 bytes should be enough. */
  15283. -struct tftpreq_t
  15284. -{
  15285. - struct iphdr ip;
  15286. - struct udphdr udp;
  15287. - unsigned short opcode;
  15288. - union
  15289. - {
  15290. - char rrq[512];
  15291. -
  15292. - struct
  15293. - {
  15294. - unsigned short block;
  15295. - }
  15296. - ack;
  15297. -
  15298. - struct
  15299. - {
  15300. - unsigned short errcode;
  15301. - char errmsg[512-2];
  15302. - }
  15303. - err;
  15304. - }
  15305. - u;
  15306. -};
  15307. -
  15308. -#define TFTP_MIN_PACKET (sizeof(struct iphdr) + sizeof(struct udphdr) + 4)
  15309. -
  15310. -struct rpc_t
  15311. -{
  15312. - struct iphdr ip;
  15313. - struct udphdr udp;
  15314. - union
  15315. - {
  15316. - char data[300]; /* longest RPC call must fit!!!! */
  15317. -
  15318. - struct
  15319. - {
  15320. - long id;
  15321. - long type;
  15322. - long rpcvers;
  15323. - long prog;
  15324. - long vers;
  15325. - long proc;
  15326. - long data[1];
  15327. - }
  15328. - call;
  15329. -
  15330. - struct
  15331. - {
  15332. - long id;
  15333. - long type;
  15334. - long rstatus;
  15335. - long verifier;
  15336. - long v2;
  15337. - long astatus;
  15338. - long data[1];
  15339. - }
  15340. - reply;
  15341. - }
  15342. - u;
  15343. -};
  15344. -
  15345. -#define PROG_PORTMAP 100000
  15346. -#define PROG_NFS 100003
  15347. -#define PROG_MOUNT 100005
  15348. -
  15349. -#define MSG_CALL 0
  15350. -#define MSG_REPLY 1
  15351. -
  15352. -#define PORTMAP_GETPORT 3
  15353. -
  15354. -#define MOUNT_ADDENTRY 1
  15355. -#define MOUNT_UMOUNTALL 4
  15356. -
  15357. -#define NFS_LOOKUP 4
  15358. -#define NFS_READ 6
  15359. -
  15360. -#define NFS_FHSIZE 32
  15361. -
  15362. -#define NFSERR_PERM 1
  15363. -#define NFSERR_NOENT 2
  15364. -#define NFSERR_ACCES 13
  15365. -
  15366. -/* Block size used for NFS read accesses. A RPC reply packet (including all
  15367. - * headers) must fit within a single Ethernet frame to avoid fragmentation.
  15368. - * Chosen to be a power of two, as most NFS servers are optimized for this. */
  15369. -#define NFS_READ_SIZE 1024
  15370. -
  15371. -#define FLOPPY_BOOT_LOCATION 0x7c00
  15372. -/* Must match offsets in loader.S */
  15373. -#define ROM_SEGMENT 0x1fa
  15374. -#define ROM_LENGTH 0x1fc
  15375. -
  15376. -#define ROM_INFO_LOCATION (FLOPPY_BOOT_LOCATION + ROM_SEGMENT)
  15377. -/* at end of floppy boot block */
  15378. -
  15379. -struct rom_info
  15380. -{
  15381. - unsigned short rom_segment;
  15382. - unsigned short rom_length;
  15383. -};
  15384. -
  15385. -static inline int
  15386. -rom_address_ok (struct rom_info *rom, int assigned_rom_segment)
  15387. -{
  15388. - return (assigned_rom_segment < 0xC000
  15389. - || assigned_rom_segment == rom->rom_segment);
  15390. -}
  15391. -
  15392. -/* Define a type for passing info to a loaded program. */
  15393. -struct ebinfo
  15394. -{
  15395. - unsigned char major, minor; /* Version */
  15396. - unsigned short flags; /* Bit flags */
  15397. -};
  15398. -
  15399. -/***************************************************************************
  15400. -External prototypes
  15401. -***************************************************************************/
  15402. -/* main.c */
  15403. -extern void print_network_configuration (void);
  15404. -extern int ifconfig (char *ip, char *sm, char *gw, char *svr);
  15405. -extern int udp_transmit (unsigned long destip, unsigned int srcsock,
  15406. - unsigned int destsock, int len, const void *buf);
  15407. -extern int await_reply (int type, int ival, void *ptr, int timeout);
  15408. -extern int decode_rfc1533 (unsigned char *, int, int, int);
  15409. -extern long rfc2131_sleep_interval (int base, int exp);
  15410. -extern void cleanup (void);
  15411. -extern int rarp (void);
  15412. -extern int bootp (void);
  15413. -extern void cleanup_net (void);
  15414. -
  15415. -/* config.c */
  15416. -extern void print_config (void);
  15417. -extern void eth_reset (void);
  15418. -extern int eth_probe (void);
  15419. -extern int eth_poll (void);
  15420. -extern void eth_transmit (const char *d, unsigned int t,
  15421. - unsigned int s, const void *p);
  15422. -extern void eth_disable (void);
  15423. -
  15424. -/* misc.c */
  15425. -extern void twiddle (void);
  15426. -extern void sleep (int secs);
  15427. -extern int getdec (char **s);
  15428. -extern void etherboot_printf (const char *, ...);
  15429. -extern int etherboot_sprintf (char *, const char *, ...);
  15430. -extern int inet_aton (char *p, in_addr *i);
  15431. -
  15432. -/***************************************************************************
  15433. -External variables
  15434. -***************************************************************************/
  15435. -/* main.c */
  15436. -extern int ip_abort;
  15437. -extern int network_ready;
  15438. -extern struct rom_info rom;
  15439. -extern struct arptable_t arptable[MAX_ARP];
  15440. -
  15441. -/* config.c */
  15442. -extern struct nic nic;
  15443. +#define gateA20_set() gateA20(1)
  15444. +#define gateA20_unset() gateA20(0)
  15445. +#define EBDEBUG 0
  15446. +/* The 'rom_info' maybe arch depended. It must be moved to some other
  15447. + * place */
  15448. +struct rom_info {
  15449. + unsigned short rom_segment;
  15450. + unsigned short rom_length;
  15451. +};
  15452. +
  15453. +extern void poll_interruptions P((void));
  15454. +
  15455. +/* For UNDI drivers */
  15456. +extern void fake_irq ( uint8_t irq );
  15457. +extern void _trivial_irq_handler_start;
  15458. +extern uint32_t get_free_base_memory ( void );
  15459. +extern void forget_base_memory ( void*, size_t );
  15460. +extern void free_unused_base_memory ( void );
  15461. -/* Local hack - define some macros to use etherboot source files "as is". */
  15462. -#ifndef GRUB
  15463. -# undef printf
  15464. -# define printf etherboot_printf
  15465. -# undef sprintf
  15466. -# define sprintf etherboot_sprintf
  15467. -#endif /* GRUB */
  15468. +#endif /* ETHERBOOT_H */
  15469. Index: b/netboot/fa311.c
  15470. ===================================================================
  15471. --- a/netboot/fa311.c
  15472. +++ /dev/null
  15473. @@ -1,421 +0,0 @@
  15474. -/*
  15475. - Driver for the National Semiconductor DP83810 Ethernet controller.
  15476. -
  15477. - Portions Copyright (C) 2001 Inprimis Technologies, Inc.
  15478. - http://www.inprimis.com/
  15479. -
  15480. - This driver is based (heavily) on the Linux driver for this chip
  15481. - which is copyright 1999-2001 by Donald Becker.
  15482. -
  15483. - This software has no warranties expressed or implied for any
  15484. - purpose.
  15485. -
  15486. - This software may be used and distributed according to the terms of
  15487. - the GNU General Public License (GPL), incorporated herein by reference.
  15488. - Drivers based on or derived from this code fall under the GPL and must
  15489. - retain the authorship, copyright and license notice. This file is not
  15490. - a complete program and may only be used when the entire operating
  15491. - system is licensed under the GPL. License for under other terms may be
  15492. - available. Contact the original author for details.
  15493. -
  15494. - The original author may be reached as becker@scyld.com, or at
  15495. - Scyld Computing Corporation
  15496. - 410 Severn Ave., Suite 210
  15497. - Annapolis MD 21403
  15498. -*/
  15499. -
  15500. -
  15501. -typedef unsigned char u8;
  15502. -typedef signed char s8;
  15503. -typedef unsigned short u16;
  15504. -typedef signed short s16;
  15505. -typedef unsigned int u32;
  15506. -typedef signed int s32;
  15507. -
  15508. -#include "etherboot.h"
  15509. -#include "nic.h"
  15510. -#include "pci.h"
  15511. -
  15512. -#undef virt_to_bus
  15513. -#define virt_to_bus(x) ((unsigned long)x)
  15514. -#define cpu_to_le32(val) (val)
  15515. -#define le32_to_cpu(val) (val)
  15516. -#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  15517. -#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  15518. -
  15519. -#define TX_RING_SIZE 1
  15520. -#define RX_RING_SIZE 4
  15521. -#define TIME_OUT 1000000
  15522. -#define PKT_BUF_SZ 1536
  15523. -
  15524. -/* Offsets to the device registers. */
  15525. -enum register_offsets {
  15526. - ChipCmd=0x00, ChipConfig=0x04, EECtrl=0x08, PCIBusCfg=0x0C,
  15527. - IntrStatus=0x10, IntrMask=0x14, IntrEnable=0x18,
  15528. - TxRingPtr=0x20, TxConfig=0x24,
  15529. - RxRingPtr=0x30, RxConfig=0x34,
  15530. - WOLCmd=0x40, PauseCmd=0x44, RxFilterAddr=0x48, RxFilterData=0x4C,
  15531. - BootRomAddr=0x50, BootRomData=0x54, StatsCtrl=0x5C, StatsData=0x60,
  15532. - RxPktErrs=0x60, RxMissed=0x68, RxCRCErrs=0x64,
  15533. -};
  15534. -
  15535. -/* Bit in ChipCmd. */
  15536. -enum ChipCmdBits {
  15537. - ChipReset=0x100, RxReset=0x20, TxReset=0x10, RxOff=0x08, RxOn=0x04,
  15538. - TxOff=0x02, TxOn=0x01,
  15539. -};
  15540. -
  15541. -/* Bits in the interrupt status/mask registers. */
  15542. -enum intr_status_bits {
  15543. - IntrRxDone=0x0001, IntrRxIntr=0x0002, IntrRxErr=0x0004, IntrRxEarly=0x0008,
  15544. - IntrRxIdle=0x0010, IntrRxOverrun=0x0020,
  15545. - IntrTxDone=0x0040, IntrTxIntr=0x0080, IntrTxErr=0x0100,
  15546. - IntrTxIdle=0x0200, IntrTxUnderrun=0x0400,
  15547. - StatsMax=0x0800, LinkChange=0x4000, WOLPkt=0x2000,
  15548. - RxResetDone=0x1000000, TxResetDone=0x2000000,
  15549. - IntrPCIErr=0x00f00000, IntrNormalSummary=0x0251, IntrAbnormalSummary=0xED20,
  15550. -};
  15551. -
  15552. -/* Bits in the RxMode register. */
  15553. -enum rx_mode_bits {
  15554. - AcceptErr=0x20, AcceptRunt=0x10, AcceptBroadcast=0xC0000000,
  15555. - AcceptMulticast=0x00200000, AcceptAllMulticast=0x20000000,
  15556. - AcceptAllPhys=0x10000000, AcceptMyPhys=0x08000000,
  15557. -};
  15558. -
  15559. -/* Bits in network_desc.status */
  15560. -enum desc_status_bits {
  15561. - DescOwn=0x80000000, DescMore=0x40000000, DescIntr=0x20000000,
  15562. - DescNoCRC=0x10000000,
  15563. - DescPktOK=0x08000000, RxTooLong=0x00400000,
  15564. -};
  15565. -
  15566. -/* The Rx and Tx buffer descriptors. */
  15567. -struct netdev_desc {
  15568. - u32 next_desc;
  15569. - s32 cmd_status;
  15570. - u32 addr;
  15571. -};
  15572. -
  15573. -static struct FA311_DEV {
  15574. - unsigned int ioaddr;
  15575. - unsigned short vendor;
  15576. - unsigned short device;
  15577. - unsigned int cur_rx;
  15578. - unsigned int cur_tx;
  15579. - unsigned int rx_buf_sz;
  15580. - volatile struct netdev_desc *rx_head_desc;
  15581. - volatile struct netdev_desc rx_ring[RX_RING_SIZE] __attribute__ ((aligned (4)));
  15582. - volatile struct netdev_desc tx_ring[TX_RING_SIZE] __attribute__ ((aligned (4)));
  15583. -} fa311_dev;
  15584. -
  15585. -static int eeprom_read(long ioaddr, int location);
  15586. -static void init_ring(struct FA311_DEV *dev);
  15587. -static void fa311_reset(struct nic *nic);
  15588. -static int fa311_poll(struct nic *nic);
  15589. -static void fa311_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p);
  15590. -static void fa311_disable(struct nic *nic);
  15591. -
  15592. -static char rx_packet[PKT_BUF_SZ * RX_RING_SIZE] __attribute__ ((aligned (4)));
  15593. -static char tx_packet[PKT_BUF_SZ * TX_RING_SIZE] __attribute__ ((aligned (4)));
  15594. -
  15595. -struct nic * fa311_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci)
  15596. -{
  15597. -int prev_eedata;
  15598. -int i;
  15599. -int duplex;
  15600. -int tx_config;
  15601. -int rx_config;
  15602. -unsigned char macaddr[6];
  15603. -unsigned char mactest;
  15604. -unsigned char pci_bus = 0;
  15605. -struct FA311_DEV* dev = &fa311_dev;
  15606. -
  15607. - if (io_addrs == 0 || *io_addrs == 0)
  15608. - return (0);
  15609. - memset(dev, 0, sizeof(*dev));
  15610. - dev->vendor = pci->vendor;
  15611. - dev->device = pci->dev_id;
  15612. - dev->ioaddr = pci->membase;
  15613. -
  15614. - /* Work around the dropped serial bit. */
  15615. - prev_eedata = eeprom_read(dev->ioaddr, 6);
  15616. - for (i = 0; i < 3; i++) {
  15617. - int eedata = eeprom_read(dev->ioaddr, i + 7);
  15618. - macaddr[i*2] = (eedata << 1) + (prev_eedata >> 15);
  15619. - macaddr[i*2+1] = eedata >> 7;
  15620. - prev_eedata = eedata;
  15621. - }
  15622. - mactest = 0;
  15623. - for (i = 0; i < 6; i++)
  15624. - mactest |= macaddr[i];
  15625. - if (mactest == 0)
  15626. - return (0);
  15627. - for (i = 0; i < 6; i++)
  15628. - nic->node_addr[i] = macaddr[i];
  15629. - printf("%! ", nic->node_addr);
  15630. -
  15631. - adjust_pci_device(pci);
  15632. -
  15633. - fa311_reset(nic);
  15634. -
  15635. - nic->reset = fa311_reset;
  15636. - nic->disable = fa311_disable;
  15637. - nic->poll = fa311_poll;
  15638. - nic->transmit = fa311_transmit;
  15639. -
  15640. - init_ring(dev);
  15641. -
  15642. - writel(virt_to_bus(dev->rx_ring), dev->ioaddr + RxRingPtr);
  15643. - writel(virt_to_bus(dev->tx_ring), dev->ioaddr + TxRingPtr);
  15644. -
  15645. - for (i = 0; i < 6; i += 2)
  15646. - {
  15647. - writel(i, dev->ioaddr + RxFilterAddr);
  15648. - writew(macaddr[i] + (macaddr[i+1] << 8),
  15649. - dev->ioaddr + RxFilterData);
  15650. - }
  15651. -
  15652. - /* Initialize other registers. */
  15653. - /* Configure for standard, in-spec Ethernet. */
  15654. - if (readl(dev->ioaddr + ChipConfig) & 0x20000000)
  15655. - { /* Full duplex */
  15656. - tx_config = 0xD0801002;
  15657. - rx_config = 0x10000020;
  15658. - }
  15659. - else
  15660. - {
  15661. - tx_config = 0x10801002;
  15662. - rx_config = 0x0020;
  15663. - }
  15664. - writel(tx_config, dev->ioaddr + TxConfig);
  15665. - writel(rx_config, dev->ioaddr + RxConfig);
  15666. -
  15667. - duplex = readl(dev->ioaddr + ChipConfig) & 0x20000000 ? 1 : 0;
  15668. - if (duplex) {
  15669. - rx_config |= 0x10000000;
  15670. - tx_config |= 0xC0000000;
  15671. - } else {
  15672. - rx_config &= ~0x10000000;
  15673. - tx_config &= ~0xC0000000;
  15674. - }
  15675. - writew(tx_config, dev->ioaddr + TxConfig);
  15676. - writew(rx_config, dev->ioaddr + RxConfig);
  15677. -
  15678. - writel(AcceptBroadcast | AcceptAllMulticast | AcceptMyPhys,
  15679. - dev->ioaddr + RxFilterAddr);
  15680. -
  15681. - writel(RxOn | TxOn, dev->ioaddr + ChipCmd);
  15682. - writel(4, dev->ioaddr + StatsCtrl); /* Clear Stats */
  15683. - return nic;
  15684. -
  15685. -}
  15686. -
  15687. -static void fa311_reset(struct nic *nic)
  15688. -{
  15689. -u32 chip_config;
  15690. -struct FA311_DEV* dev = &fa311_dev;
  15691. -
  15692. - /* Reset the chip to erase previous misconfiguration. */
  15693. - outl(ChipReset, dev->ioaddr + ChipCmd);
  15694. -
  15695. - if ((readl(dev->ioaddr + ChipConfig) & 0xe000) != 0xe000)
  15696. - {
  15697. - chip_config = readl(dev->ioaddr + ChipConfig);
  15698. - }
  15699. -}
  15700. -
  15701. -static int fa311_poll(struct nic *nic)
  15702. -{
  15703. -s32 desc_status;
  15704. -int to;
  15705. -int entry;
  15706. -int retcode;
  15707. -struct FA311_DEV* dev = &fa311_dev;
  15708. -
  15709. - retcode = 0;
  15710. - entry = dev->cur_rx;
  15711. - to = TIME_OUT;
  15712. - while (to != 0)
  15713. - {
  15714. - desc_status = dev->rx_ring[entry].cmd_status;
  15715. - if ((desc_status & DescOwn) != 0)
  15716. - break;
  15717. - else
  15718. - --to;
  15719. - }
  15720. - if (to != 0)
  15721. - {
  15722. - readl(dev->ioaddr + IntrStatus); /* clear interrrupt bits */
  15723. - /* driver owns the next entry it's a new packet. Send it up. */
  15724. - if ((desc_status & (DescMore|DescPktOK|RxTooLong)) == DescPktOK)
  15725. - {
  15726. - nic->packetlen = (desc_status & 0x0fff) - 4; /* Omit CRC size. */
  15727. - memcpy(nic->packet, (char*)(dev->rx_ring[entry].addr), nic->packetlen);
  15728. - retcode = 1;
  15729. - }
  15730. - /* Give the descriptor back to the chip */
  15731. - dev->rx_ring[entry].cmd_status = cpu_to_le32(dev->rx_buf_sz);
  15732. - dev->cur_rx++;
  15733. - if (dev->cur_rx >= RX_RING_SIZE)
  15734. - dev->cur_rx = 0;
  15735. - dev->rx_head_desc = &dev->rx_ring[dev->cur_rx];
  15736. - }
  15737. - /* Restart Rx engine if stopped. */
  15738. - writel(RxOn, dev->ioaddr + ChipCmd);
  15739. - return retcode;
  15740. -}
  15741. -
  15742. -static void fa311_transmit(struct nic *nic, const char *destaddr, unsigned int type, unsigned int len, const char *data)
  15743. -{
  15744. -unsigned short nstype;
  15745. -s32 desc_status;
  15746. -int to;
  15747. -int entry;
  15748. -char* txp;
  15749. -unsigned char* s;
  15750. -struct FA311_DEV* dev = &fa311_dev;
  15751. -
  15752. - /* Calculate the next Tx descriptor entry. */
  15753. - entry = dev->cur_tx;
  15754. - txp = (char*)(dev->tx_ring[entry].addr);
  15755. -
  15756. - memcpy(txp, destaddr, ETH_ALEN);
  15757. - memcpy(txp + ETH_ALEN, nic->node_addr, ETH_ALEN);
  15758. - nstype = htons(type);
  15759. - memcpy(txp + 12, (char*)&nstype, 2);
  15760. - memcpy(txp + ETH_HLEN, data, len);
  15761. - len += ETH_HLEN;
  15762. - /* pad frame */
  15763. - if (len < ETH_ZLEN)
  15764. - {
  15765. - s = (unsigned char*)(txp+len);
  15766. - while (s < (unsigned char*)(txp+ETH_ZLEN))
  15767. - *s++ = 0;
  15768. - len = ETH_ZLEN;
  15769. - }
  15770. - dev->tx_ring[entry].cmd_status = cpu_to_le32(DescOwn | len);
  15771. - dev->cur_tx++;
  15772. - if (dev->cur_tx >= TX_RING_SIZE)
  15773. - dev->cur_tx = 0;
  15774. -
  15775. - /* Wake the potentially-idle transmit channel. */
  15776. - writel(TxOn, dev->ioaddr + ChipCmd);
  15777. -
  15778. - /* wait for tranmission to complete */
  15779. - to = TIME_OUT;
  15780. - while (to != 0)
  15781. - {
  15782. - desc_status = dev->tx_ring[entry].cmd_status;
  15783. - if ((desc_status & DescOwn) == 0)
  15784. - break;
  15785. - else
  15786. - --to;
  15787. - }
  15788. -
  15789. - readl(dev->ioaddr + IntrStatus); /* clear interrrupt bits */
  15790. - return;
  15791. -}
  15792. -
  15793. -static void fa311_disable(struct nic *nic)
  15794. -{
  15795. -struct FA311_DEV* dev = &fa311_dev;
  15796. -
  15797. - /* Stop the chip's Tx and Rx processes. */
  15798. - writel(RxOff | TxOff, dev->ioaddr + ChipCmd);
  15799. -}
  15800. -
  15801. -
  15802. -/* Read the EEPROM and MII Management Data I/O (MDIO) interfaces.
  15803. - The EEPROM code is for the common 93c06/46 EEPROMs with 6 bit addresses. */
  15804. -
  15805. -/* Delay between EEPROM clock transitions.
  15806. - No extra delay is needed with 33Mhz PCI, but future 66Mhz access may need
  15807. - a delay. Note that pre-2.0.34 kernels had a cache-alignment bug that
  15808. - made udelay() unreliable.
  15809. - The old method of using an ISA access as a delay, __SLOW_DOWN_IO__, is
  15810. - depricated.
  15811. -*/
  15812. -#define eeprom_delay(ee_addr) inl(ee_addr)
  15813. -
  15814. -enum EEPROM_Ctrl_Bits {
  15815. - EE_ShiftClk=0x04, EE_DataIn=0x01, EE_ChipSelect=0x08, EE_DataOut=0x02,
  15816. -};
  15817. -#define EE_Write0 (EE_ChipSelect)
  15818. -#define EE_Write1 (EE_ChipSelect | EE_DataIn)
  15819. -
  15820. -/* The EEPROM commands include the alway-set leading bit. */
  15821. -enum EEPROM_Cmds {
  15822. - EE_WriteCmd=(5 << 6), EE_ReadCmd=(6 << 6), EE_EraseCmd=(7 << 6),
  15823. -};
  15824. -
  15825. -
  15826. -static int eeprom_read(long addr, int location)
  15827. -{
  15828. - int i;
  15829. - int retval = 0;
  15830. - int ee_addr = addr + EECtrl;
  15831. - int read_cmd = location | EE_ReadCmd;
  15832. - writel(EE_Write0, ee_addr);
  15833. -
  15834. - /* Shift the read command bits out. */
  15835. - for (i = 10; i >= 0; i--) {
  15836. - short dataval = (read_cmd & (1 << i)) ? EE_Write1 : EE_Write0;
  15837. - writel(dataval, ee_addr);
  15838. - eeprom_delay(ee_addr);
  15839. - writel(dataval | EE_ShiftClk, ee_addr);
  15840. - eeprom_delay(ee_addr);
  15841. - }
  15842. - writel(EE_ChipSelect, ee_addr);
  15843. - eeprom_delay(ee_addr);
  15844. -
  15845. - for (i = 0; i < 16; i++) {
  15846. - writel(EE_ChipSelect | EE_ShiftClk, ee_addr);
  15847. - eeprom_delay(ee_addr);
  15848. - retval |= (readl(ee_addr) & EE_DataOut) ? 1 << i : 0;
  15849. - writel(EE_ChipSelect, ee_addr);
  15850. - eeprom_delay(ee_addr);
  15851. - }
  15852. -
  15853. - /* Terminate the EEPROM access. */
  15854. - writel(EE_Write0, ee_addr);
  15855. - writel(0, ee_addr);
  15856. - return retval;
  15857. -}
  15858. -
  15859. -/* Initialize the Rx and Tx rings, along with various 'dev' bits. */
  15860. -static void init_ring(struct FA311_DEV *dev)
  15861. -{
  15862. - int i;
  15863. -
  15864. - dev->cur_rx = 0;
  15865. - dev->cur_tx = 0;
  15866. -
  15867. - dev->rx_buf_sz = PKT_BUF_SZ;
  15868. - dev->rx_head_desc = &dev->rx_ring[0];
  15869. -
  15870. - /* Initialize all Rx descriptors. */
  15871. - for (i = 0; i < RX_RING_SIZE; i++) {
  15872. - dev->rx_ring[i].next_desc = virt_to_le32desc(&dev->rx_ring[i+1]);
  15873. - dev->rx_ring[i].cmd_status = DescOwn;
  15874. - }
  15875. - /* Mark the last entry as wrapping the ring. */
  15876. - dev->rx_ring[i-1].next_desc = virt_to_le32desc(&dev->rx_ring[0]);
  15877. -
  15878. - /* Fill in the Rx buffers. Handle allocation failure gracefully. */
  15879. - for (i = 0; i < RX_RING_SIZE; i++) {
  15880. - dev->rx_ring[i].addr = (u32)(&rx_packet[PKT_BUF_SZ * i]);
  15881. - dev->rx_ring[i].cmd_status = cpu_to_le32(dev->rx_buf_sz);
  15882. - }
  15883. -
  15884. - for (i = 0; i < TX_RING_SIZE; i++) {
  15885. - dev->tx_ring[i].next_desc = virt_to_le32desc(&dev->tx_ring[i+1]);
  15886. - dev->tx_ring[i].cmd_status = 0;
  15887. - }
  15888. - dev->tx_ring[i-1].next_desc = virt_to_le32desc(&dev->tx_ring[0]);
  15889. -
  15890. - for (i = 0; i < TX_RING_SIZE; i++)
  15891. - dev->tx_ring[i].addr = (u32)(&tx_packet[PKT_BUF_SZ * i]);
  15892. - return;
  15893. -}
  15894. -
  15895. Index: b/netboot/forcedeth.c
  15896. ===================================================================
  15897. --- /dev/null
  15898. +++ b/netboot/forcedeth.c
  15899. @@ -0,0 +1,1039 @@
  15900. +/**************************************************************************
  15901. +* forcedeth.c -- Etherboot device driver for the NVIDIA nForce
  15902. +* media access controllers.
  15903. +*
  15904. +* Note: This driver is based on the Linux driver that was based on
  15905. +* a cleanroom reimplementation which was based on reverse
  15906. +* engineered documentation written by Carl-Daniel Hailfinger
  15907. +* and Andrew de Quincey. It's neither supported nor endorsed
  15908. +* by NVIDIA Corp. Use at your own risk.
  15909. +*
  15910. +* Written 2004 by Timothy Legge <tlegge@rogers.com>
  15911. +*
  15912. +* This program is free software; you can redistribute it and/or modify
  15913. +* it under the terms of the GNU General Public License as published by
  15914. +* the Free Software Foundation; either version 2 of the License, or
  15915. +* (at your option) any later version.
  15916. +*
  15917. +* This program is distributed in the hope that it will be useful,
  15918. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  15919. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15920. +* GNU General Public License for more details.
  15921. +*
  15922. +* You should have received a copy of the GNU General Public License
  15923. +* along with this program; if not, write to the Free Software
  15924. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15925. +*
  15926. +* Portions of this code based on:
  15927. +* forcedeth: Ethernet driver for NVIDIA nForce media access controllers:
  15928. +*
  15929. +* (C) 2003 Manfred Spraul
  15930. +* See Linux Driver for full information
  15931. +*
  15932. +* Linux Driver Version 0.22, 19 Jan 2004
  15933. +*
  15934. +*
  15935. +* REVISION HISTORY:
  15936. +* ================
  15937. +* v1.0 01-31-2004 timlegge Initial port of Linux driver
  15938. +* v1.1 02-03-2004 timlegge Large Clean up, first release
  15939. +*
  15940. +* Indent Options: indent -kr -i8
  15941. +***************************************************************************/
  15942. +
  15943. +/* to get some global routines like printf */
  15944. +#include "etherboot.h"
  15945. +/* to get the interface to the body of the program */
  15946. +#include "nic.h"
  15947. +/* to get the PCI support functions, if this is a PCI NIC */
  15948. +#include "pci.h"
  15949. +/* Include timer support functions */
  15950. +#include "timer.h"
  15951. +
  15952. +#define drv_version "v1.1"
  15953. +#define drv_date "02-03-2004"
  15954. +
  15955. +//#define TFTM_DEBUG
  15956. +#ifdef TFTM_DEBUG
  15957. +#define dprintf(x) printf x
  15958. +#else
  15959. +#define dprintf(x)
  15960. +#endif
  15961. +
  15962. +typedef unsigned char u8;
  15963. +typedef signed char s8;
  15964. +typedef unsigned short u16;
  15965. +typedef signed short s16;
  15966. +typedef unsigned int u32;
  15967. +typedef signed int s32;
  15968. +
  15969. +/* Condensed operations for readability. */
  15970. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  15971. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  15972. +
  15973. +unsigned long BASE;
  15974. +/* NIC specific static variables go here */
  15975. +
  15976. +
  15977. +/*
  15978. + * Hardware access:
  15979. + */
  15980. +
  15981. +#define DEV_NEED_LASTPACKET1 0x0001
  15982. +#define DEV_IRQMASK_1 0x0002
  15983. +#define DEV_IRQMASK_2 0x0004
  15984. +#define DEV_NEED_TIMERIRQ 0x0008
  15985. +
  15986. +enum {
  15987. + NvRegIrqStatus = 0x000,
  15988. +#define NVREG_IRQSTAT_MIIEVENT 0040
  15989. +#define NVREG_IRQSTAT_MASK 0x1ff
  15990. + NvRegIrqMask = 0x004,
  15991. +#define NVREG_IRQ_RX 0x0002
  15992. +#define NVREG_IRQ_RX_NOBUF 0x0004
  15993. +#define NVREG_IRQ_TX_ERR 0x0008
  15994. +#define NVREG_IRQ_TX2 0x0010
  15995. +#define NVREG_IRQ_TIMER 0x0020
  15996. +#define NVREG_IRQ_LINK 0x0040
  15997. +#define NVREG_IRQ_TX1 0x0100
  15998. +#define NVREG_IRQMASK_WANTED_1 0x005f
  15999. +#define NVREG_IRQMASK_WANTED_2 0x0147
  16000. +#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))
  16001. +
  16002. + NvRegUnknownSetupReg6 = 0x008,
  16003. +#define NVREG_UNKSETUP6_VAL 3
  16004. +
  16005. +/*
  16006. + * NVREG_POLL_DEFAULT is the interval length of the timer source on the nic
  16007. + * NVREG_POLL_DEFAULT=97 would result in an interval length of 1 ms
  16008. + */
  16009. + NvRegPollingInterval = 0x00c,
  16010. +#define NVREG_POLL_DEFAULT 970
  16011. + NvRegMisc1 = 0x080,
  16012. +#define NVREG_MISC1_HD 0x02
  16013. +#define NVREG_MISC1_FORCE 0x3b0f3c
  16014. +
  16015. + NvRegTransmitterControl = 0x084,
  16016. +#define NVREG_XMITCTL_START 0x01
  16017. + NvRegTransmitterStatus = 0x088,
  16018. +#define NVREG_XMITSTAT_BUSY 0x01
  16019. +
  16020. + NvRegPacketFilterFlags = 0x8c,
  16021. +#define NVREG_PFF_ALWAYS 0x7F0008
  16022. +#define NVREG_PFF_PROMISC 0x80
  16023. +#define NVREG_PFF_MYADDR 0x20
  16024. +
  16025. + NvRegOffloadConfig = 0x90,
  16026. +#define NVREG_OFFLOAD_HOMEPHY 0x601
  16027. +#define NVREG_OFFLOAD_NORMAL 0x5ee
  16028. + NvRegReceiverControl = 0x094,
  16029. +#define NVREG_RCVCTL_START 0x01
  16030. + NvRegReceiverStatus = 0x98,
  16031. +#define NVREG_RCVSTAT_BUSY 0x01
  16032. +
  16033. + NvRegRandomSeed = 0x9c,
  16034. +#define NVREG_RNDSEED_MASK 0x00ff
  16035. +#define NVREG_RNDSEED_FORCE 0x7f00
  16036. +
  16037. + NvRegUnknownSetupReg1 = 0xA0,
  16038. +#define NVREG_UNKSETUP1_VAL 0x16070f
  16039. + NvRegUnknownSetupReg2 = 0xA4,
  16040. +#define NVREG_UNKSETUP2_VAL 0x16
  16041. + NvRegMacAddrA = 0xA8,
  16042. + NvRegMacAddrB = 0xAC,
  16043. + NvRegMulticastAddrA = 0xB0,
  16044. +#define NVREG_MCASTADDRA_FORCE 0x01
  16045. + NvRegMulticastAddrB = 0xB4,
  16046. + NvRegMulticastMaskA = 0xB8,
  16047. + NvRegMulticastMaskB = 0xBC,
  16048. +
  16049. + NvRegTxRingPhysAddr = 0x100,
  16050. + NvRegRxRingPhysAddr = 0x104,
  16051. + NvRegRingSizes = 0x108,
  16052. +#define NVREG_RINGSZ_TXSHIFT 0
  16053. +#define NVREG_RINGSZ_RXSHIFT 16
  16054. + NvRegUnknownTransmitterReg = 0x10c,
  16055. + NvRegLinkSpeed = 0x110,
  16056. +#define NVREG_LINKSPEED_FORCE 0x10000
  16057. +#define NVREG_LINKSPEED_10 10
  16058. +#define NVREG_LINKSPEED_100 100
  16059. +#define NVREG_LINKSPEED_1000 1000
  16060. + NvRegUnknownSetupReg5 = 0x130,
  16061. +#define NVREG_UNKSETUP5_BIT31 (1<<31)
  16062. + NvRegUnknownSetupReg3 = 0x134,
  16063. +#define NVREG_UNKSETUP3_VAL1 0x200010
  16064. + NvRegTxRxControl = 0x144,
  16065. +#define NVREG_TXRXCTL_KICK 0x0001
  16066. +#define NVREG_TXRXCTL_BIT1 0x0002
  16067. +#define NVREG_TXRXCTL_BIT2 0x0004
  16068. +#define NVREG_TXRXCTL_IDLE 0x0008
  16069. +#define NVREG_TXRXCTL_RESET 0x0010
  16070. + NvRegMIIStatus = 0x180,
  16071. +#define NVREG_MIISTAT_ERROR 0x0001
  16072. +#define NVREG_MIISTAT_LINKCHANGE 0x0008
  16073. +#define NVREG_MIISTAT_MASK 0x000f
  16074. +#define NVREG_MIISTAT_MASK2 0x000f
  16075. + NvRegUnknownSetupReg4 = 0x184,
  16076. +#define NVREG_UNKSETUP4_VAL 8
  16077. +
  16078. + NvRegAdapterControl = 0x188,
  16079. +#define NVREG_ADAPTCTL_START 0x02
  16080. +#define NVREG_ADAPTCTL_LINKUP 0x04
  16081. +#define NVREG_ADAPTCTL_PHYVALID 0x4000
  16082. +#define NVREG_ADAPTCTL_RUNNING 0x100000
  16083. +#define NVREG_ADAPTCTL_PHYSHIFT 24
  16084. + NvRegMIISpeed = 0x18c,
  16085. +#define NVREG_MIISPEED_BIT8 (1<<8)
  16086. +#define NVREG_MIIDELAY 5
  16087. + NvRegMIIControl = 0x190,
  16088. +#define NVREG_MIICTL_INUSE 0x10000
  16089. +#define NVREG_MIICTL_WRITE 0x08000
  16090. +#define NVREG_MIICTL_ADDRSHIFT 5
  16091. + NvRegMIIData = 0x194,
  16092. + NvRegWakeUpFlags = 0x200,
  16093. +#define NVREG_WAKEUPFLAGS_VAL 0x7770
  16094. +#define NVREG_WAKEUPFLAGS_BUSYSHIFT 24
  16095. +#define NVREG_WAKEUPFLAGS_ENABLESHIFT 16
  16096. +#define NVREG_WAKEUPFLAGS_D3SHIFT 12
  16097. +#define NVREG_WAKEUPFLAGS_D2SHIFT 8
  16098. +#define NVREG_WAKEUPFLAGS_D1SHIFT 4
  16099. +#define NVREG_WAKEUPFLAGS_D0SHIFT 0
  16100. +#define NVREG_WAKEUPFLAGS_ACCEPT_MAGPAT 0x01
  16101. +#define NVREG_WAKEUPFLAGS_ACCEPT_WAKEUPPAT 0x02
  16102. +#define NVREG_WAKEUPFLAGS_ACCEPT_LINKCHANGE 0x04
  16103. +
  16104. + NvRegPatternCRC = 0x204,
  16105. + NvRegPatternMask = 0x208,
  16106. + NvRegPowerCap = 0x268,
  16107. +#define NVREG_POWERCAP_D3SUPP (1<<30)
  16108. +#define NVREG_POWERCAP_D2SUPP (1<<26)
  16109. +#define NVREG_POWERCAP_D1SUPP (1<<25)
  16110. + NvRegPowerState = 0x26c,
  16111. +#define NVREG_POWERSTATE_POWEREDUP 0x8000
  16112. +#define NVREG_POWERSTATE_VALID 0x0100
  16113. +#define NVREG_POWERSTATE_MASK 0x0003
  16114. +#define NVREG_POWERSTATE_D0 0x0000
  16115. +#define NVREG_POWERSTATE_D1 0x0001
  16116. +#define NVREG_POWERSTATE_D2 0x0002
  16117. +#define NVREG_POWERSTATE_D3 0x0003
  16118. +};
  16119. +
  16120. +
  16121. +
  16122. +#define NV_TX_LASTPACKET (1<<0)
  16123. +#define NV_TX_RETRYERROR (1<<3)
  16124. +#define NV_TX_LASTPACKET1 (1<<8)
  16125. +#define NV_TX_DEFERRED (1<<10)
  16126. +#define NV_TX_CARRIERLOST (1<<11)
  16127. +#define NV_TX_LATECOLLISION (1<<12)
  16128. +#define NV_TX_UNDERFLOW (1<<13)
  16129. +#define NV_TX_ERROR (1<<14)
  16130. +#define NV_TX_VALID (1<<15)
  16131. +
  16132. +#define NV_RX_DESCRIPTORVALID (1<<0)
  16133. +#define NV_RX_MISSEDFRAME (1<<1)
  16134. +#define NV_RX_SUBSTRACT1 (1<<3)
  16135. +#define NV_RX_ERROR1 (1<<7)
  16136. +#define NV_RX_ERROR2 (1<<8)
  16137. +#define NV_RX_ERROR3 (1<<9)
  16138. +#define NV_RX_ERROR4 (1<<10)
  16139. +#define NV_RX_CRCERR (1<<11)
  16140. +#define NV_RX_OVERFLOW (1<<12)
  16141. +#define NV_RX_FRAMINGERR (1<<13)
  16142. +#define NV_RX_ERROR (1<<14)
  16143. +#define NV_RX_AVAIL (1<<15)
  16144. +
  16145. +/* Miscelaneous hardware related defines: */
  16146. +#define NV_PCI_REGSZ 0x270
  16147. +
  16148. +/* various timeout delays: all in usec */
  16149. +#define NV_TXRX_RESET_DELAY 4
  16150. +#define NV_TXSTOP_DELAY1 10
  16151. +#define NV_TXSTOP_DELAY1MAX 500000
  16152. +#define NV_TXSTOP_DELAY2 100
  16153. +#define NV_RXSTOP_DELAY1 10
  16154. +#define NV_RXSTOP_DELAY1MAX 500000
  16155. +#define NV_RXSTOP_DELAY2 100
  16156. +#define NV_SETUP5_DELAY 5
  16157. +#define NV_SETUP5_DELAYMAX 50000
  16158. +#define NV_POWERUP_DELAY 5
  16159. +#define NV_POWERUP_DELAYMAX 5000
  16160. +#define NV_MIIBUSY_DELAY 50
  16161. +#define NV_MIIPHY_DELAY 10
  16162. +#define NV_MIIPHY_DELAYMAX 10000
  16163. +
  16164. +#define NV_WAKEUPPATTERNS 5
  16165. +#define NV_WAKEUPMASKENTRIES 4
  16166. +
  16167. +/* General driver defaults */
  16168. +#define NV_WATCHDOG_TIMEO (2*HZ)
  16169. +#define DEFAULT_MTU 1500 /* also maximum supported, at least for now */
  16170. +
  16171. +#define RX_RING 4
  16172. +#define TX_RING 2
  16173. +/* limited to 1 packet until we understand NV_TX_LASTPACKET */
  16174. +#define TX_LIMIT_STOP 10
  16175. +#define TX_LIMIT_START 5
  16176. +
  16177. +/* rx/tx mac addr + type + vlan + align + slack*/
  16178. +#define RX_NIC_BUFSIZE (DEFAULT_MTU + 64)
  16179. +/* even more slack */
  16180. +#define RX_ALLOC_BUFSIZE (DEFAULT_MTU + 128)
  16181. +
  16182. +#define OOM_REFILL (1+HZ/20)
  16183. +#define POLL_WAIT (1+HZ/100)
  16184. +
  16185. +struct ring_desc {
  16186. + u32 PacketBuffer;
  16187. + u16 Length;
  16188. + u16 Flags;
  16189. +};
  16190. +
  16191. +
  16192. +/* Define the TX Descriptor */
  16193. +static struct ring_desc tx_ring[TX_RING];
  16194. +
  16195. +/* Create a static buffer of size RX_BUF_SZ for each
  16196. +TX Descriptor. All descriptors point to a
  16197. +part of this buffer */
  16198. +static unsigned char txb[TX_RING * RX_NIC_BUFSIZE];
  16199. +
  16200. +/* Define the TX Descriptor */
  16201. +static struct ring_desc rx_ring[RX_RING];
  16202. +
  16203. +/* Create a static buffer of size RX_BUF_SZ for each
  16204. +RX Descriptor All descriptors point to a
  16205. +part of this buffer */
  16206. +static unsigned char rxb[RX_RING * RX_NIC_BUFSIZE];
  16207. +
  16208. +/* Private Storage for the NIC */
  16209. +struct forcedeth_private {
  16210. + /* General data:
  16211. + * Locking: spin_lock(&np->lock); */
  16212. + int in_shutdown;
  16213. + u32 linkspeed;
  16214. + int duplex;
  16215. + int phyaddr;
  16216. +
  16217. + /* General data: RO fields */
  16218. + u8 *ring_addr;
  16219. + u32 orig_mac[2];
  16220. + u32 irqmask;
  16221. + /* rx specific fields.
  16222. + * Locking: Within irq hander or disable_irq+spin_lock(&np->lock);
  16223. + */
  16224. + struct ring_desc *rx_ring;
  16225. + unsigned int cur_rx, refill_rx;
  16226. + struct sk_buff *rx_skbuff[RX_RING];
  16227. + u32 rx_dma[RX_RING];
  16228. + unsigned int rx_buf_sz;
  16229. +
  16230. + /*
  16231. + * tx specific fields.
  16232. + */
  16233. + struct ring_desc *tx_ring;
  16234. + unsigned int next_tx, nic_tx;
  16235. + struct sk_buff *tx_skbuff[TX_RING];
  16236. + u32 tx_dma[TX_RING];
  16237. + u16 tx_flags;
  16238. +} npx;
  16239. +
  16240. +static struct forcedeth_private *np;
  16241. +
  16242. +static inline void pci_push(u8 * base)
  16243. +{
  16244. + /* force out pending posted writes */
  16245. + readl(base);
  16246. +}
  16247. +static int reg_delay(int offset, u32 mask,
  16248. + u32 target, int delay, int delaymax, const char *msg)
  16249. +{
  16250. + u8 *base = (u8 *) BASE;
  16251. +
  16252. + pci_push(base);
  16253. + do {
  16254. + udelay(delay);
  16255. + delaymax -= delay;
  16256. + if (delaymax < 0) {
  16257. + if (msg)
  16258. + printf(msg);
  16259. + return 1;
  16260. + }
  16261. + } while ((readl(base + offset) & mask) != target);
  16262. + return 0;
  16263. +}
  16264. +
  16265. +#define MII_READ (-1)
  16266. +#define MII_PHYSID1 0x02 /* PHYS ID 1 */
  16267. +#define MII_PHYSID2 0x03 /* PHYS ID 2 */
  16268. +#define MII_BMCR 0x00 /* Basic mode control register */
  16269. +#define MII_BMSR 0x01 /* Basic mode status register */
  16270. +#define MII_ADVERTISE 0x04 /* Advertisement control reg */
  16271. +#define MII_LPA 0x05 /* Link partner ability reg */
  16272. +
  16273. +#define BMSR_ANEGCOMPLETE 0x0020 /* Auto-negotiation complete */
  16274. +
  16275. +/* Link partner ability register. */
  16276. +#define LPA_SLCT 0x001f /* Same as advertise selector */
  16277. +#define LPA_10HALF 0x0020 /* Can do 10mbps half-duplex */
  16278. +#define LPA_10FULL 0x0040 /* Can do 10mbps full-duplex */
  16279. +#define LPA_100HALF 0x0080 /* Can do 100mbps half-duplex */
  16280. +#define LPA_100FULL 0x0100 /* Can do 100mbps full-duplex */
  16281. +#define LPA_100BASE4 0x0200 /* Can do 100mbps 4k packets */
  16282. +#define LPA_RESV 0x1c00 /* Unused... */
  16283. +#define LPA_RFAULT 0x2000 /* Link partner faulted */
  16284. +#define LPA_LPACK 0x4000 /* Link partner acked us */
  16285. +#define LPA_NPAGE 0x8000 /* Next page bit */
  16286. +
  16287. +/* mii_rw: read/write a register on the PHY.
  16288. + *
  16289. + * Caller must guarantee serialization
  16290. + */
  16291. +static int mii_rw(struct nic *nic __unused, int addr, int miireg,
  16292. + int value)
  16293. +{
  16294. + u8 *base = (u8 *) BASE;
  16295. + int was_running;
  16296. + u32 reg;
  16297. + int retval;
  16298. +
  16299. + writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus);
  16300. + was_running = 0;
  16301. + reg = readl(base + NvRegAdapterControl);
  16302. + if (reg & NVREG_ADAPTCTL_RUNNING) {
  16303. + was_running = 1;
  16304. + writel(reg & ~NVREG_ADAPTCTL_RUNNING,
  16305. + base + NvRegAdapterControl);
  16306. + }
  16307. + reg = readl(base + NvRegMIIControl);
  16308. + if (reg & NVREG_MIICTL_INUSE) {
  16309. + writel(NVREG_MIICTL_INUSE, base + NvRegMIIControl);
  16310. + udelay(NV_MIIBUSY_DELAY);
  16311. + }
  16312. +
  16313. + reg =
  16314. + NVREG_MIICTL_INUSE | (addr << NVREG_MIICTL_ADDRSHIFT) | miireg;
  16315. + if (value != MII_READ) {
  16316. + writel(value, base + NvRegMIIData);
  16317. + reg |= NVREG_MIICTL_WRITE;
  16318. + }
  16319. + writel(reg, base + NvRegMIIControl);
  16320. +
  16321. + if (reg_delay(NvRegMIIControl, NVREG_MIICTL_INUSE, 0,
  16322. + NV_MIIPHY_DELAY, NV_MIIPHY_DELAYMAX, NULL)) {
  16323. + dprintf(("mii_rw of reg %d at PHY %d timed out.\n",
  16324. + miireg, addr));
  16325. + retval = -1;
  16326. + } else if (value != MII_READ) {
  16327. + /* it was a write operation - fewer failures are detectable */
  16328. + dprintf(("mii_rw wrote 0x%x to reg %d at PHY %d\n",
  16329. + value, miireg, addr));
  16330. + retval = 0;
  16331. + } else if (readl(base + NvRegMIIStatus) & NVREG_MIISTAT_ERROR) {
  16332. + dprintf(("mii_rw of reg %d at PHY %d failed.\n",
  16333. + miireg, addr));
  16334. + retval = -1;
  16335. + } else {
  16336. + /* FIXME: why is that required? */
  16337. + udelay(50);
  16338. + retval = readl(base + NvRegMIIData);
  16339. + dprintf(("mii_rw read from reg %d at PHY %d: 0x%x.\n",
  16340. + miireg, addr, retval));
  16341. + }
  16342. + if (was_running) {
  16343. + reg = readl(base + NvRegAdapterControl);
  16344. + writel(reg | NVREG_ADAPTCTL_RUNNING,
  16345. + base + NvRegAdapterControl);
  16346. + }
  16347. + return retval;
  16348. +}
  16349. +
  16350. +static void start_rx(struct nic *nic __unused)
  16351. +{
  16352. + u8 *base = (u8 *) BASE;
  16353. +
  16354. + dprintf(("start_rx\n"));
  16355. + /* Already running? Stop it. */
  16356. + if (readl(base + NvRegReceiverControl) & NVREG_RCVCTL_START) {
  16357. + writel(0, base + NvRegReceiverControl);
  16358. + pci_push(base);
  16359. + }
  16360. + writel(np->linkspeed, base + NvRegLinkSpeed);
  16361. + pci_push(base);
  16362. + writel(NVREG_RCVCTL_START, base + NvRegReceiverControl);
  16363. + pci_push(base);
  16364. +}
  16365. +
  16366. +static void stop_rx(void)
  16367. +{
  16368. + u8 *base = (u8 *) BASE;
  16369. +
  16370. + dprintf(("stop_rx\n"));
  16371. + writel(0, base + NvRegReceiverControl);
  16372. + reg_delay(NvRegReceiverStatus, NVREG_RCVSTAT_BUSY, 0,
  16373. + NV_RXSTOP_DELAY1, NV_RXSTOP_DELAY1MAX,
  16374. + "stop_rx: ReceiverStatus remained busy");
  16375. +
  16376. + udelay(NV_RXSTOP_DELAY2);
  16377. + writel(0, base + NvRegLinkSpeed);
  16378. +}
  16379. +
  16380. +static void start_tx(struct nic *nic __unused)
  16381. +{
  16382. + u8 *base = (u8 *) BASE;
  16383. +
  16384. + dprintf(("start_tx\n"));
  16385. + writel(NVREG_XMITCTL_START, base + NvRegTransmitterControl);
  16386. + pci_push(base);
  16387. +}
  16388. +
  16389. +static void stop_tx(void)
  16390. +{
  16391. + u8 *base = (u8 *) BASE;
  16392. +
  16393. + dprintf(("stop_tx\n"));
  16394. + writel(0, base + NvRegTransmitterControl);
  16395. + reg_delay(NvRegTransmitterStatus, NVREG_XMITSTAT_BUSY, 0,
  16396. + NV_TXSTOP_DELAY1, NV_TXSTOP_DELAY1MAX,
  16397. + "stop_tx: TransmitterStatus remained busy");
  16398. +
  16399. + udelay(NV_TXSTOP_DELAY2);
  16400. + writel(0, base + NvRegUnknownTransmitterReg);
  16401. +}
  16402. +
  16403. +
  16404. +static void txrx_reset(struct nic *nic __unused)
  16405. +{
  16406. + u8 *base = (u8 *) BASE;
  16407. +
  16408. + dprintf(("txrx_reset\n"));
  16409. + writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET,
  16410. + base + NvRegTxRxControl);
  16411. + pci_push(base);
  16412. + udelay(NV_TXRX_RESET_DELAY);
  16413. + writel(NVREG_TXRXCTL_BIT2, base + NvRegTxRxControl);
  16414. + pci_push(base);
  16415. +}
  16416. +
  16417. +/*
  16418. + * alloc_rx: fill rx ring entries.
  16419. + * Return 1 if the allocations for the skbs failed and the
  16420. + * rx engine is without Available descriptors
  16421. + */
  16422. +static int alloc_rx(struct nic *nic __unused)
  16423. +{
  16424. + unsigned int refill_rx = np->refill_rx;
  16425. + int i;
  16426. + //while (np->cur_rx != refill_rx) {
  16427. + for (i = 0; i < RX_RING; i++) {
  16428. + //int nr = refill_rx % RX_RING;
  16429. + rx_ring[i].PacketBuffer =
  16430. + virt_to_le32desc(&rxb[i * RX_NIC_BUFSIZE]);
  16431. + rx_ring[i].Length = cpu_to_le16(RX_NIC_BUFSIZE);
  16432. + wmb();
  16433. + rx_ring[i].Flags = cpu_to_le16(NV_RX_AVAIL);
  16434. + /* printf("alloc_rx: Packet %d marked as Available\n",
  16435. + refill_rx); */
  16436. + refill_rx++;
  16437. + }
  16438. + np->refill_rx = refill_rx;
  16439. + if (np->cur_rx - refill_rx == RX_RING)
  16440. + return 1;
  16441. + return 0;
  16442. +}
  16443. +
  16444. +static int update_linkspeed(struct nic *nic)
  16445. +{
  16446. + int adv, lpa, newdup;
  16447. + u32 newls;
  16448. + adv = mii_rw(nic, np->phyaddr, MII_ADVERTISE, MII_READ);
  16449. + lpa = mii_rw(nic, np->phyaddr, MII_LPA, MII_READ);
  16450. + dprintf(("update_linkspeed: PHY advertises 0x%hX, lpa 0x%hX.\n",
  16451. + adv, lpa));
  16452. +
  16453. + /* FIXME: handle parallel detection properly, handle gigabit ethernet */
  16454. + lpa = lpa & adv;
  16455. + if (lpa & LPA_100FULL) {
  16456. + newls = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_100;
  16457. + newdup = 1;
  16458. + } else if (lpa & LPA_100HALF) {
  16459. + newls = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_100;
  16460. + newdup = 0;
  16461. + } else if (lpa & LPA_10FULL) {
  16462. + newls = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_10;
  16463. + newdup = 1;
  16464. + } else if (lpa & LPA_10HALF) {
  16465. + newls = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_10;
  16466. + newdup = 0;
  16467. + } else {
  16468. + printf("bad ability %hX - falling back to 10HD.\n", lpa);
  16469. + newls = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_10;
  16470. + newdup = 0;
  16471. + }
  16472. + if (np->duplex != newdup || np->linkspeed != newls) {
  16473. + np->duplex = newdup;
  16474. + np->linkspeed = newls;
  16475. + return 1;
  16476. + }
  16477. + return 0;
  16478. +}
  16479. +
  16480. +
  16481. +
  16482. +static int init_ring(struct nic *nic)
  16483. +{
  16484. + int i;
  16485. +
  16486. + np->next_tx = np->nic_tx = 0;
  16487. + for (i = 0; i < TX_RING; i++) {
  16488. + tx_ring[i].Flags = 0;
  16489. + }
  16490. +
  16491. + np->cur_rx = 0;
  16492. + np->refill_rx = 0;
  16493. + for (i = 0; i < RX_RING; i++) {
  16494. + rx_ring[i].Flags = 0;
  16495. + }
  16496. + return alloc_rx(nic);
  16497. +}
  16498. +
  16499. +static void set_multicast(struct nic *nic)
  16500. +{
  16501. +
  16502. + u8 *base = (u8 *) BASE;
  16503. + u32 addr[2];
  16504. + u32 mask[2];
  16505. + u32 pff;
  16506. + u32 alwaysOff[2];
  16507. + u32 alwaysOn[2];
  16508. +
  16509. + memset(addr, 0, sizeof(addr));
  16510. + memset(mask, 0, sizeof(mask));
  16511. +
  16512. + pff = NVREG_PFF_MYADDR;
  16513. +
  16514. + alwaysOn[0] = alwaysOn[1] = alwaysOff[0] = alwaysOff[1] = 0;
  16515. +
  16516. + addr[0] = alwaysOn[0];
  16517. + addr[1] = alwaysOn[1];
  16518. + mask[0] = alwaysOn[0] | alwaysOff[0];
  16519. + mask[1] = alwaysOn[1] | alwaysOff[1];
  16520. +
  16521. + addr[0] |= NVREG_MCASTADDRA_FORCE;
  16522. + pff |= NVREG_PFF_ALWAYS;
  16523. + stop_rx();
  16524. + writel(addr[0], base + NvRegMulticastAddrA);
  16525. + writel(addr[1], base + NvRegMulticastAddrB);
  16526. + writel(mask[0], base + NvRegMulticastMaskA);
  16527. + writel(mask[1], base + NvRegMulticastMaskB);
  16528. + writel(pff, base + NvRegPacketFilterFlags);
  16529. + start_rx(nic);
  16530. +}
  16531. +
  16532. +/**************************************************************************
  16533. +RESET - Reset the NIC to prepare for use
  16534. +***************************************************************************/
  16535. +static int forcedeth_reset(struct nic *nic)
  16536. +{
  16537. + u8 *base = (u8 *) BASE;
  16538. + int ret, oom, i;
  16539. + ret = 0;
  16540. + dprintf(("forcedeth: open\n"));
  16541. +
  16542. + /* 1) erase previous misconfiguration */
  16543. + /* 4.1-1: stop adapter: ignored, 4.3 seems to be overkill */
  16544. + writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA);
  16545. + writel(0, base + NvRegMulticastAddrB);
  16546. + writel(0, base + NvRegMulticastMaskA);
  16547. + writel(0, base + NvRegMulticastMaskB);
  16548. + writel(0, base + NvRegPacketFilterFlags);
  16549. + writel(0, base + NvRegAdapterControl);
  16550. + writel(0, base + NvRegLinkSpeed);
  16551. + writel(0, base + NvRegUnknownTransmitterReg);
  16552. + txrx_reset(nic);
  16553. + writel(0, base + NvRegUnknownSetupReg6);
  16554. +
  16555. + /* 2) initialize descriptor rings */
  16556. + np->in_shutdown = 0;
  16557. + oom = init_ring(nic);
  16558. +
  16559. + /* 3) set mac address */
  16560. + {
  16561. + u32 mac[2];
  16562. +
  16563. + mac[0] =
  16564. + (nic->node_addr[0] << 0) + (nic->node_addr[1] << 8) +
  16565. + (nic->node_addr[2] << 16) + (nic->node_addr[3] << 24);
  16566. + mac[1] =
  16567. + (nic->node_addr[4] << 0) + (nic->node_addr[5] << 8);
  16568. +
  16569. + writel(mac[0], base + NvRegMacAddrA);
  16570. + writel(mac[1], base + NvRegMacAddrB);
  16571. + }
  16572. +
  16573. + /* 4) continue setup */
  16574. + np->linkspeed = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_10;
  16575. + np->duplex = 0;
  16576. + writel(NVREG_UNKSETUP3_VAL1, base + NvRegUnknownSetupReg3);
  16577. + writel(0, base + NvRegTxRxControl);
  16578. + pci_push(base);
  16579. + writel(NVREG_TXRXCTL_BIT1, base + NvRegTxRxControl);
  16580. +
  16581. + reg_delay(NvRegUnknownSetupReg5, NVREG_UNKSETUP5_BIT31,
  16582. + NVREG_UNKSETUP5_BIT31, NV_SETUP5_DELAY,
  16583. + NV_SETUP5_DELAYMAX,
  16584. + "open: SetupReg5, Bit 31 remained off\n");
  16585. + writel(0, base + NvRegUnknownSetupReg4);
  16586. +
  16587. + /* 5) Find a suitable PHY */
  16588. + writel(NVREG_MIISPEED_BIT8 | NVREG_MIIDELAY, base + NvRegMIISpeed);
  16589. + for (i = 1; i < 32; i++) {
  16590. + int id1, id2;
  16591. +
  16592. + id1 = mii_rw(nic, i, MII_PHYSID1, MII_READ);
  16593. + if (id1 < 0)
  16594. + continue;
  16595. + id2 = mii_rw(nic, i, MII_PHYSID2, MII_READ);
  16596. + if (id2 < 0)
  16597. + continue;
  16598. + dprintf(("open: Found PHY %04x:%04x at address %d.\n",
  16599. + id1, id2, i));
  16600. + np->phyaddr = i;
  16601. +
  16602. + update_linkspeed(nic);
  16603. +
  16604. + break;
  16605. + }
  16606. + if (i == 32) {
  16607. + printf("open: failing due to lack of suitable PHY.\n");
  16608. + ret = -1;
  16609. + goto out_drain;
  16610. + }
  16611. +
  16612. + printf("%d-Mbs Link, %s-Duplex\n",
  16613. + np->linkspeed & NVREG_LINKSPEED_10 ? 10 : 100,
  16614. + np->duplex ? "Full" : "Half");
  16615. + /* 6) continue setup */
  16616. + writel(NVREG_MISC1_FORCE | (np->duplex ? 0 : NVREG_MISC1_HD),
  16617. + base + NvRegMisc1);
  16618. + writel(readl(base + NvRegTransmitterStatus),
  16619. + base + NvRegTransmitterStatus);
  16620. + writel(NVREG_PFF_ALWAYS, base + NvRegPacketFilterFlags);
  16621. + writel(NVREG_OFFLOAD_NORMAL, base + NvRegOffloadConfig);
  16622. +
  16623. + writel(readl(base + NvRegReceiverStatus),
  16624. + base + NvRegReceiverStatus);
  16625. +
  16626. + /* FIXME: I cheated and used the calculator to get a random number */
  16627. + i = 75963081;
  16628. + writel(NVREG_RNDSEED_FORCE | (i & NVREG_RNDSEED_MASK),
  16629. + base + NvRegRandomSeed);
  16630. + writel(NVREG_UNKSETUP1_VAL, base + NvRegUnknownSetupReg1);
  16631. + writel(NVREG_UNKSETUP2_VAL, base + NvRegUnknownSetupReg2);
  16632. + writel(NVREG_POLL_DEFAULT, base + NvRegPollingInterval);
  16633. + writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6);
  16634. + writel((np->
  16635. + phyaddr << NVREG_ADAPTCTL_PHYSHIFT) |
  16636. + NVREG_ADAPTCTL_PHYVALID, base + NvRegAdapterControl);
  16637. + writel(NVREG_UNKSETUP4_VAL, base + NvRegUnknownSetupReg4);
  16638. + writel(NVREG_WAKEUPFLAGS_VAL, base + NvRegWakeUpFlags);
  16639. +
  16640. + /* 7) start packet processing */
  16641. + writel((u32) virt_to_le32desc(&rx_ring[0]),
  16642. + base + NvRegRxRingPhysAddr);
  16643. + writel((u32) virt_to_le32desc(&tx_ring[0]),
  16644. + base + NvRegTxRingPhysAddr);
  16645. +
  16646. +
  16647. + writel(((RX_RING - 1) << NVREG_RINGSZ_RXSHIFT) +
  16648. + ((TX_RING - 1) << NVREG_RINGSZ_TXSHIFT),
  16649. + base + NvRegRingSizes);
  16650. +
  16651. + i = readl(base + NvRegPowerState);
  16652. + if ((i & NVREG_POWERSTATE_POWEREDUP) == 0) {
  16653. + writel(NVREG_POWERSTATE_POWEREDUP | i,
  16654. + base + NvRegPowerState);
  16655. + }
  16656. + pci_push(base);
  16657. + udelay(10);
  16658. + writel(readl(base + NvRegPowerState) | NVREG_POWERSTATE_VALID,
  16659. + base + NvRegPowerState);
  16660. + writel(NVREG_ADAPTCTL_RUNNING, base + NvRegAdapterControl);
  16661. +
  16662. + writel(0, base + NvRegIrqMask);
  16663. + pci_push(base);
  16664. + writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
  16665. + pci_push(base);
  16666. + writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus);
  16667. + writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
  16668. + pci_push(base);
  16669. +/*
  16670. + writel(np->irqmask, base + NvRegIrqMask);
  16671. +*/
  16672. + writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA);
  16673. + writel(0, base + NvRegMulticastAddrB);
  16674. + writel(0, base + NvRegMulticastMaskA);
  16675. + writel(0, base + NvRegMulticastMaskB);
  16676. + writel(NVREG_PFF_ALWAYS | NVREG_PFF_MYADDR,
  16677. + base + NvRegPacketFilterFlags);
  16678. +
  16679. + set_multicast(nic);
  16680. + //start_rx(nic);
  16681. + start_tx(nic);
  16682. +
  16683. + if (!
  16684. + (mii_rw(nic, np->phyaddr, MII_BMSR, MII_READ) &
  16685. + BMSR_ANEGCOMPLETE)) {
  16686. + printf("no link during initialization.\n");
  16687. + }
  16688. +
  16689. + udelay(10000);
  16690. + out_drain:
  16691. + return ret;
  16692. +}
  16693. +
  16694. +//extern void hex_dump(const char *data, const unsigned int len);
  16695. +
  16696. +/**************************************************************************
  16697. +POLL - Wait for a frame
  16698. +***************************************************************************/
  16699. +static int forcedeth_poll(struct nic *nic, int retrieve)
  16700. +{
  16701. + /* return true if there's an ethernet packet ready to read */
  16702. + /* nic->packet should contain data on return */
  16703. + /* nic->packetlen should contain length of data */
  16704. +
  16705. + struct ring_desc *prd;
  16706. + int len;
  16707. + int i;
  16708. +
  16709. + i = np->cur_rx % RX_RING;
  16710. + prd = &rx_ring[i];
  16711. +
  16712. + if ( ! (prd->Flags & cpu_to_le16(NV_RX_DESCRIPTORVALID)) ) {
  16713. + return 0;
  16714. + }
  16715. +
  16716. + if ( ! retrieve ) return 1;
  16717. +
  16718. + /* got a valid packet - forward it to the network core */
  16719. + len = cpu_to_le16(prd->Length);
  16720. + nic->packetlen = len;
  16721. + //hex_dump(rxb + (i * RX_NIC_BUFSIZE), len);
  16722. + memcpy(nic->packet, rxb +
  16723. + (i * RX_NIC_BUFSIZE), nic->packetlen);
  16724. +
  16725. + wmb();
  16726. + np->cur_rx++;
  16727. + alloc_rx(nic);
  16728. + return 1;
  16729. +}
  16730. +
  16731. +
  16732. +/**************************************************************************
  16733. +TRANSMIT - Transmit a frame
  16734. +***************************************************************************/
  16735. +static void forcedeth_transmit(struct nic *nic, const char *d, /* Destination */
  16736. + unsigned int t, /* Type */
  16737. + unsigned int s, /* size */
  16738. + const char *p)
  16739. +{ /* Packet */
  16740. + /* send the packet to destination */
  16741. + u8 *ptxb;
  16742. + u16 nstype;
  16743. + //u16 status;
  16744. + u8 *base = (u8 *) BASE;
  16745. + int nr = np->next_tx % TX_RING;
  16746. +
  16747. + /* point to the current txb incase multiple tx_rings are used */
  16748. + ptxb = txb + (nr * RX_NIC_BUFSIZE);
  16749. + //np->tx_skbuff[nr] = ptxb;
  16750. +
  16751. + /* copy the packet to ring buffer */
  16752. + memcpy(ptxb, d, ETH_ALEN); /* dst */
  16753. + memcpy(ptxb + ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  16754. + nstype = htons((u16) t); /* type */
  16755. + memcpy(ptxb + 2 * ETH_ALEN, (u8 *) & nstype, 2); /* type */
  16756. + memcpy(ptxb + ETH_HLEN, p, s);
  16757. +
  16758. + s += ETH_HLEN;
  16759. + while (s < ETH_ZLEN) /* pad to min length */
  16760. + ptxb[s++] = '\0';
  16761. +
  16762. + tx_ring[nr].PacketBuffer = (u32) virt_to_le32desc(ptxb);
  16763. + tx_ring[nr].Length = cpu_to_le16(s - 1);
  16764. +
  16765. + wmb();
  16766. + tx_ring[nr].Flags = np->tx_flags;
  16767. +
  16768. + writel(NVREG_TXRXCTL_KICK, base + NvRegTxRxControl);
  16769. + pci_push(base);
  16770. + tx_ring[nr].Flags = np->tx_flags;
  16771. + np->next_tx++;
  16772. +}
  16773. +
  16774. +/**************************************************************************
  16775. +DISABLE - Turn off ethernet interface
  16776. +***************************************************************************/
  16777. +static void forcedeth_disable(struct dev *dev __unused)
  16778. +{
  16779. + /* put the card in its initial state */
  16780. + /* This function serves 3 purposes.
  16781. + * This disables DMA and interrupts so we don't receive
  16782. + * unexpected packets or interrupts from the card after
  16783. + * etherboot has finished.
  16784. + * This frees resources so etherboot may use
  16785. + * this driver on another interface
  16786. + * This allows etherboot to reinitialize the interface
  16787. + * if something is something goes wrong.
  16788. + */
  16789. + u8 *base = (u8 *) BASE;
  16790. + np->in_shutdown = 1;
  16791. + stop_tx();
  16792. + stop_rx();
  16793. +
  16794. + /* disable interrupts on the nic or we will lock up */
  16795. + writel(0, base + NvRegIrqMask);
  16796. + pci_push(base);
  16797. + dprintf(("Irqmask is zero again\n"));
  16798. +
  16799. + /* specia op:o write back the misordered MAC address - otherwise
  16800. + * the next probe_nic would see a wrong address.
  16801. + */
  16802. + writel(np->orig_mac[0], base + NvRegMacAddrA);
  16803. + writel(np->orig_mac[1], base + NvRegMacAddrB);
  16804. +}
  16805. +
  16806. +/**************************************************************************
  16807. +IRQ - Enable, Disable, or Force interrupts
  16808. +***************************************************************************/
  16809. +static void forcedeth_irq(struct nic *nic __unused, irq_action_t action __unused)
  16810. +{
  16811. + switch ( action ) {
  16812. + case DISABLE :
  16813. + break;
  16814. + case ENABLE :
  16815. + break;
  16816. + case FORCE :
  16817. + break;
  16818. + }
  16819. +}
  16820. +
  16821. +/**************************************************************************
  16822. +PROBE - Look for an adapter, this routine's visible to the outside
  16823. +***************************************************************************/
  16824. +#define IORESOURCE_MEM 0x00000200
  16825. +#define board_found 1
  16826. +#define valid_link 0
  16827. +static int forcedeth_probe(struct dev *dev, struct pci_device *pci)
  16828. +{
  16829. + struct nic *nic = (struct nic *) dev;
  16830. + unsigned long addr;
  16831. + int sz;
  16832. + u8 *base;
  16833. +
  16834. + if (pci->ioaddr == 0)
  16835. + return 0;
  16836. +
  16837. + printf("forcedeth.c: Found %s, vendor=0x%hX, device=0x%hX\n",
  16838. + pci->name, pci->vendor, pci->dev_id);
  16839. +
  16840. + nic->irqno = 0;
  16841. + nic->ioaddr = pci->ioaddr & ~3;
  16842. +
  16843. + /* point to private storage */
  16844. + np = &npx;
  16845. +
  16846. + adjust_pci_device(pci);
  16847. +
  16848. + addr = pci_bar_start(pci, PCI_BASE_ADDRESS_0);
  16849. + sz = pci_bar_size(pci, PCI_BASE_ADDRESS_0);
  16850. +
  16851. + /* BASE is used throughout to address the card */
  16852. + BASE = (unsigned long) ioremap(addr, sz);
  16853. + if (!BASE)
  16854. + return 0;
  16855. + //rx_ring[0] = rx_ring;
  16856. + //tx_ring[0] = tx_ring;
  16857. +
  16858. + /* read the mac address */
  16859. + base = (u8 *) BASE;
  16860. + np->orig_mac[0] = readl(base + NvRegMacAddrA);
  16861. + np->orig_mac[1] = readl(base + NvRegMacAddrB);
  16862. +
  16863. + nic->node_addr[0] = (np->orig_mac[1] >> 8) & 0xff;
  16864. + nic->node_addr[1] = (np->orig_mac[1] >> 0) & 0xff;
  16865. + nic->node_addr[2] = (np->orig_mac[0] >> 24) & 0xff;
  16866. + nic->node_addr[3] = (np->orig_mac[0] >> 16) & 0xff;
  16867. + nic->node_addr[4] = (np->orig_mac[0] >> 8) & 0xff;
  16868. + nic->node_addr[5] = (np->orig_mac[0] >> 0) & 0xff;
  16869. +#ifdef LINUX
  16870. + if (!is_valid_ether_addr(dev->dev_addr)) {
  16871. + /*
  16872. + * Bad mac address. At least one bios sets the mac address
  16873. + * to 01:23:45:67:89:ab
  16874. + */
  16875. + printk(KERN_ERR
  16876. + "%s: Invalid Mac address detected: %02x:%02x:%02x:%02x:%02x:%02x\n",
  16877. + pci_name(pci_dev), dev->dev_addr[0],
  16878. + dev->dev_addr[1], dev->dev_addr[2],
  16879. + dev->dev_addr[3], dev->dev_addr[4],
  16880. + dev->dev_addr[5]);
  16881. + printk(KERN_ERR
  16882. + "Please complain to your hardware vendor. Switching to a random MAC.\n");
  16883. + dev->dev_addr[0] = 0x00;
  16884. + dev->dev_addr[1] = 0x00;
  16885. + dev->dev_addr[2] = 0x6c;
  16886. + get_random_bytes(&dev->dev_addr[3], 3);
  16887. + }
  16888. +#endif
  16889. + printf("%s: MAC Address %!, ", pci->name, nic->node_addr);
  16890. +
  16891. + np->tx_flags =
  16892. + cpu_to_le16(NV_TX_LASTPACKET | NV_TX_LASTPACKET1 |
  16893. + NV_TX_VALID);
  16894. + switch (pci->dev_id) {
  16895. + case 0x01C3: // nforce
  16896. + np->irqmask = NVREG_IRQMASK_WANTED_2;
  16897. + np->irqmask |= NVREG_IRQ_TIMER;
  16898. + break;
  16899. + case 0x0066: // nforce2
  16900. + np->tx_flags |= cpu_to_le16(NV_TX_LASTPACKET1);
  16901. + np->irqmask = NVREG_IRQMASK_WANTED_2;
  16902. + np->irqmask |= NVREG_IRQ_TIMER;
  16903. + break;
  16904. + case 0x00D6: // nforce3
  16905. + np->tx_flags |= cpu_to_le16(NV_TX_LASTPACKET1);
  16906. + np->irqmask = NVREG_IRQMASK_WANTED_2;
  16907. + np->irqmask |= NVREG_IRQ_TIMER;
  16908. +
  16909. + }
  16910. + dprintf(("%s: forcedeth.c: subsystem: %hX:%hX bound to %s\n",
  16911. + pci->name, pci->vendor, pci->dev_id, pci->name));
  16912. +
  16913. + forcedeth_reset(nic);
  16914. +// if (board_found && valid_link)
  16915. + /* point to NIC specific routines */
  16916. + dev->disable = forcedeth_disable;
  16917. + nic->poll = forcedeth_poll;
  16918. + nic->transmit = forcedeth_transmit;
  16919. + nic->irq = forcedeth_irq;
  16920. + return 1;
  16921. +// }
  16922. + /* else */
  16923. +}
  16924. +
  16925. +static struct pci_id forcedeth_nics[] = {
  16926. + PCI_ROM(0x10de, 0x01C3, "nforce", "nForce Ethernet Controller"),
  16927. + PCI_ROM(0x10de, 0x0066, "nforce2", "nForce2 Ethernet Controller"),
  16928. + PCI_ROM(0x10de, 0x00D6, "nforce3", "nForce3 Ethernet Controller"),
  16929. +};
  16930. +
  16931. +struct pci_driver forcedeth_driver = {
  16932. + .type = NIC_DRIVER,
  16933. + .name = "forcedeth",
  16934. + .probe = forcedeth_probe,
  16935. + .ids = forcedeth_nics,
  16936. + .id_count = sizeof(forcedeth_nics) / sizeof(forcedeth_nics[0]),
  16937. + .class = 0,
  16938. +};
  16939. Index: b/netboot/fsys_tftp.c
  16940. ===================================================================
  16941. --- a/netboot/fsys_tftp.c
  16942. +++ b/netboot/fsys_tftp.c
  16943. @@ -29,14 +29,15 @@
  16944. /* #define TFTP_DEBUG 1 */
  16945. #include <filesys.h>
  16946. +#include <shared.h>
  16947. -#define GRUB 1
  16948. -#include <etherboot.h>
  16949. -#include <nic.h>
  16950. +#include "grub.h"
  16951. +#include "tftp.h"
  16952. +#include "nic.h"
  16953. static int retry;
  16954. static unsigned short iport = 2000;
  16955. -static unsigned short oport;
  16956. +static unsigned short oport = 0;
  16957. static unsigned short block, prevblock;
  16958. static int bcounter;
  16959. static struct tftp_t tp, saved_tp;
  16960. @@ -46,6 +47,172 @@
  16961. static unsigned short len, saved_len;
  16962. static char *buf;
  16963. +/**
  16964. + * tftp_read
  16965. + *
  16966. + * Read file with _name_, data handled by _fnc_. In fact, grub never
  16967. + * use it, we just use it to read dhcp config file.
  16968. + */
  16969. +static int await_tftp(int ival, void *ptr __unused,
  16970. + unsigned short ptype __unused, struct iphdr *ip,
  16971. + struct udphdr *udp)
  16972. +{
  16973. + if (!udp) {
  16974. + return 0;
  16975. + }
  16976. + if (arptable[ARP_CLIENT].ipaddr.s_addr != ip->dest.s_addr)
  16977. + return 0;
  16978. + if (ntohs(udp->dest) != ival)
  16979. + return 0;
  16980. + return 1;
  16981. +}
  16982. +
  16983. +int tftp_file_read(const char *name, int (*fnc)(unsigned char *, unsigned int, unsigned int, int))
  16984. +{
  16985. + struct tftpreq_t tp;
  16986. + struct tftp_t *tr;
  16987. + int rc;
  16988. +
  16989. + retry = 0;
  16990. + block = 0;
  16991. + prevblock = 0;
  16992. + bcounter = 0;
  16993. +
  16994. +
  16995. + rx_qdrain();
  16996. +
  16997. + tp.opcode = htons(TFTP_RRQ);
  16998. + /* Warning: the following assumes the layout of bootp_t.
  16999. + But that's fixed by the IP, UDP and BOOTP specs. */
  17000. + len = sizeof(tp.ip) + sizeof(tp.udp) + sizeof(tp.opcode) +
  17001. + sprintf((char *)tp.u.rrq, "%s%coctet%cblksize%c%d",
  17002. + name, 0, 0, 0, TFTP_MAX_PACKET) + 1;
  17003. + if (!udp_transmit(arptable[ARP_SERVER].ipaddr.s_addr, ++iport,
  17004. + TFTP_PORT, len, &tp))
  17005. + return (0);
  17006. + for (;;)
  17007. + {
  17008. + long timeout;
  17009. +#ifdef CONGESTED
  17010. + timeout = rfc2131_sleep_interval(block?TFTP_REXMT: TIMEOUT, retry);
  17011. +#else
  17012. + timeout = rfc2131_sleep_interval(TIMEOUT, retry);
  17013. +#endif
  17014. + if (!await_reply(await_tftp, iport, NULL, timeout))
  17015. + {
  17016. + if (!block && retry++ < MAX_TFTP_RETRIES)
  17017. + { /* maybe initial request was lost */
  17018. + if (!udp_transmit(arptable[ARP_SERVER].ipaddr.s_addr,
  17019. + ++iport, TFTP_PORT, len, &tp))
  17020. + return (0);
  17021. + continue;
  17022. + }
  17023. +#ifdef CONGESTED
  17024. + if (block && ((retry += TFTP_REXMT) < TFTP_TIMEOUT))
  17025. + { /* we resend our last ack */
  17026. +#ifdef MDEBUG
  17027. + printf("<REXMT>\n");
  17028. +#endif
  17029. + udp_transmit(arptable[ARP_SERVER].ipaddr.s_addr,
  17030. + iport, oport,
  17031. + TFTP_MIN_PACKET, &tp);
  17032. + continue;
  17033. + }
  17034. +#endif
  17035. + break; /* timeout */
  17036. + }
  17037. + tr = (struct tftp_t *)&nic.packet[ETH_HLEN];
  17038. + if (tr->opcode == ntohs(TFTP_ERROR))
  17039. + {
  17040. + printf("TFTP error %d (%s)\n",
  17041. + ntohs(tr->u.err.errcode),
  17042. + tr->u.err.errmsg);
  17043. + break;
  17044. + }
  17045. +
  17046. + if (tr->opcode == ntohs(TFTP_OACK)) {
  17047. + char *p = tr->u.oack.data, *e;
  17048. +
  17049. + if (prevblock) /* shouldn't happen */
  17050. + continue; /* ignore it */
  17051. + len = ntohs(tr->udp.len) - sizeof(struct udphdr) - 2;
  17052. + if (len > TFTP_MAX_PACKET)
  17053. + goto noak;
  17054. + e = p + len;
  17055. + while (*p != '\0' && p < e) {
  17056. +/* if (!strcasecmp("blksize", p)) { */
  17057. + if (!grub_strcmp("blksize", p)) {
  17058. + p += 8;
  17059. +/* if ((packetsize = strtoul(p, &p, 10)) < */
  17060. + if ((packetsize = getdec(&p)) < TFTP_DEFAULTSIZE_PACKET)
  17061. + goto noak;
  17062. + while (p < e && *p) p++;
  17063. + if (p < e)
  17064. + p++;
  17065. + }
  17066. + else {
  17067. + noak:
  17068. + tp.opcode = htons(TFTP_ERROR);
  17069. + tp.u.err.errcode = 8;
  17070. +/*
  17071. + * Warning: the following assumes the layout of bootp_t.
  17072. + * But that's fixed by the IP, UDP and BOOTP specs.
  17073. + */
  17074. + len = sizeof(tp.ip) + sizeof(tp.udp) + sizeof(tp.opcode) + sizeof(tp.u.err.errcode) +
  17075. +/*
  17076. + * Normally bad form to omit the format string, but in this case
  17077. + * the string we are copying from is fixed. sprintf is just being
  17078. + * used as a strcpy and strlen.
  17079. + */
  17080. + sprintf((char *)tp.u.err.errmsg,
  17081. + "RFC1782 error") + 1;
  17082. + udp_transmit(arptable[ARP_SERVER].ipaddr.s_addr,
  17083. + iport, ntohs(tr->udp.src),
  17084. + len, &tp);
  17085. + return (0);
  17086. + }
  17087. + }
  17088. + if (p > e)
  17089. + goto noak;
  17090. + block = tp.u.ack.block = 0; /* this ensures, that */
  17091. + /* the packet does not get */
  17092. + /* processed as data! */
  17093. + }
  17094. + else if (tr->opcode == htons(TFTP_DATA)) {
  17095. + len = ntohs(tr->udp.len) - sizeof(struct udphdr) - 4;
  17096. + if (len > packetsize) /* shouldn't happen */
  17097. + continue; /* ignore it */
  17098. + block = ntohs(tp.u.ack.block = tr->u.data.block); }
  17099. + else {/* neither TFTP_OACK nor TFTP_DATA */
  17100. + break;
  17101. + }
  17102. +
  17103. + if ((block || bcounter) && (block != (unsigned short)(prevblock+1))) {
  17104. + /* Block order should be continuous */
  17105. + tp.u.ack.block = htons(block = prevblock);
  17106. + }
  17107. + tp.opcode = htons(TFTP_ACK);
  17108. + oport = ntohs(tr->udp.src);
  17109. + udp_transmit(arptable[ARP_SERVER].ipaddr.s_addr, iport,
  17110. + oport, TFTP_MIN_PACKET, &tp); /* ack */
  17111. + if ((unsigned short)(block-prevblock) != 1) {
  17112. + /* Retransmission or OACK, don't process via callback
  17113. + * and don't change the value of prevblock. */
  17114. + continue;
  17115. + }
  17116. + prevblock = block;
  17117. + retry = 0; /* It's the right place to zero the timer? */
  17118. + if ((rc = fnc(tr->u.data.download,
  17119. + ++bcounter, len, len < packetsize)) <= 0)
  17120. + return(rc);
  17121. + if (len < packetsize) { /* End of data --- fnc should not have returned */
  17122. + printf("tftp download complete, but\n");
  17123. + return (1);
  17124. + }
  17125. + }
  17126. + return (0);
  17127. +}
  17128. +
  17129. /* Fill the buffer by receiving the data via the TFTP protocol. */
  17130. static int
  17131. buf_fill (int abort)
  17132. @@ -65,9 +232,9 @@
  17133. timeout = rfc2131_sleep_interval (TIMEOUT, retry);
  17134. #endif
  17135. - if (! await_reply (AWAIT_TFTP, iport, NULL, timeout))
  17136. + if (! await_reply (await_tftp, iport, NULL, timeout))
  17137. {
  17138. - if (ip_abort)
  17139. + if (user_abort)
  17140. return 0;
  17141. if (! block && retry++ < MAX_TFTP_RETRIES)
  17142. @@ -270,13 +437,7 @@
  17143. buf_read = 0;
  17144. saved_filepos = 0;
  17145. - /* Clear out the Rx queue first. It contains nothing of interest,
  17146. - * except possibly ARP requests from the DHCP/TFTP server. We use
  17147. - * polling throughout Etherboot, so some time may have passed since we
  17148. - * last polled the receive queue, which may now be filled with
  17149. - * broadcast packets. This will cause the reply to the packets we are
  17150. - * about to send to be lost immediately. Not very clever. */
  17151. - await_reply (AWAIT_QDRAIN, 0, NULL, 0);
  17152. + rx_qdrain();
  17153. #ifdef TFTP_DEBUG
  17154. grub_printf ("send_rrq ()\n");
  17155. Index: b/netboot/grub.h
  17156. ===================================================================
  17157. --- /dev/null
  17158. +++ b/netboot/grub.h
  17159. @@ -0,0 +1,171 @@
  17160. +#ifndef GRUB_H
  17161. +#define GRUB_H
  17162. +
  17163. +#include "osdep.h"
  17164. +#include "byteswap.h"
  17165. +#include "in.h"
  17166. +#include "ip.h"
  17167. +#include "udp.h"
  17168. +#include "if_ether.h"
  17169. +#include "latch.h"
  17170. +#include "io.h"
  17171. +#include "nic.h"
  17172. +#include <shared.h>
  17173. +
  17174. +#define K_ESC '\033'
  17175. +#define K_EOF '\04' /* Ctrl-D */
  17176. +#define K_INTR '\03' /* Ctrl-C */
  17177. +
  17178. +#ifndef MAX_RPC_RETRIES
  17179. +#define MAX_RPC_RETRIES 20
  17180. +#endif
  17181. +
  17182. +
  17183. +/* Inter-packet retry in ticks */
  17184. +#ifndef TIMEOUT
  17185. +#define TIMEOUT (10*TICKS_PER_SEC)
  17186. +#endif
  17187. +
  17188. +#ifndef NULL
  17189. +#define NULL ((void *)0)
  17190. +#endif
  17191. +
  17192. +
  17193. +#define ARP_CLIENT 0
  17194. +#define ARP_SERVER 1
  17195. +#define ARP_GATEWAY 2
  17196. +#define MAX_ARP ARP_GATEWAY+1
  17197. +
  17198. +#define IGMP_SERVER 0
  17199. +#define MAX_IGMP IGMP_SERVER+1
  17200. +
  17201. +#define RARP_REQUEST 3
  17202. +#define RARP_REPLY 4
  17203. +
  17204. +
  17205. +#define MULTICAST_MASK 0xF0000000
  17206. +#define MULTICAST_NETWORK 0xE0000000
  17207. +
  17208. +struct arptable_t {
  17209. + in_addr ipaddr;
  17210. + uint8_t node[6];
  17211. +};
  17212. +
  17213. +struct igmptable_t {
  17214. + in_addr group;
  17215. + unsigned long time;
  17216. +};
  17217. +
  17218. +#define KERNEL_BUF (BOOTP_DATA_ADDR->bootp_reply.bp_file)
  17219. +
  17220. +#define FLOPPY_BOOT_LOCATION 0x7c00
  17221. +/* Must match offsets in loader.S */
  17222. +#define ROM_SEGMENT 0x1fa
  17223. +#define ROM_LENGTH 0x1fc
  17224. +
  17225. +#define ROM_INFO_LOCATION (FLOPPY_BOOT_LOCATION+ROM_SEGMENT)
  17226. +/* at end of floppy boot block */
  17227. +
  17228. +
  17229. +
  17230. +/* Define a type for passing info to a loaded program */
  17231. +struct ebinfo {
  17232. + uint8_t major, minor; /* Version */
  17233. + uint16_t flags; /* Bit flags */
  17234. +};
  17235. +
  17236. +/***************************************************************************
  17237. +External prototypes
  17238. +***************************************************************************/
  17239. +extern void rx_qdrain P((void));
  17240. +extern int tftp P((const char *name, int (*)(unsigned char *, unsigned int, unsigned int, int)));
  17241. +extern int ip_transmit P((int len, const void *buf));
  17242. +extern void build_ip_hdr P((unsigned long destip, int ttl, int protocol,
  17243. + int option_len, int len, const void *buf));
  17244. +extern void build_udp_hdr P((unsigned long destip,
  17245. + unsigned int srcsock, unsigned int destsock, int ttl,
  17246. + int len, const void *buf));
  17247. +extern int udp_transmit P((unsigned long destip, unsigned int srcsock,
  17248. + unsigned int destsock, int len, const void *buf));
  17249. +typedef int (*reply_t)(int ival, void *ptr, unsigned short ptype, struct iphdr *ip, struct udphdr *udp);
  17250. +extern int await_reply P((reply_t reply, int ival, void *ptr, long timeout));
  17251. +extern int decode_rfc1533 P((unsigned char *, unsigned int, unsigned int, int));
  17252. +extern void join_group(int slot, unsigned long group);
  17253. +extern void leave_group(int slot);
  17254. +#define RAND_MAX 2147483647L
  17255. +extern uint16_t ipchksum P((const void *ip, unsigned long len));
  17256. +extern uint16_t add_ipchksums P((unsigned long offset, uint16_t sum, uint16_t new));
  17257. +extern int32_t random P((void));
  17258. +extern long rfc2131_sleep_interval P((long base, int exp));
  17259. +extern long rfc1112_sleep_interval P((long base, int exp));
  17260. +#ifndef DOWNLOAD_PROTO_TFTP
  17261. +#define tftp(fname, load_block) 0
  17262. +#endif
  17263. +extern void cleanup P((void));
  17264. +
  17265. +/* misc.c */
  17266. +extern void twiddle P((void));
  17267. +extern void sleep P((int secs));
  17268. +extern void interruptible_sleep P((int secs));
  17269. +extern void poll_interruptions P((void));
  17270. +extern int strcasecmp P((const char *a, const char *b));
  17271. +extern char *substr P((const char *a, const char *b));
  17272. +extern unsigned long strtoul P((const char *p, const char **, int base));
  17273. +extern void printf P((const char *, ...));
  17274. +extern int sprintf P((char *, const char *, ...));
  17275. +extern int inet_aton P((char *p, in_addr *i));
  17276. +extern void putchar P((int));
  17277. +extern int getchar P((void));
  17278. +extern int iskey P((void));
  17279. +
  17280. +extern void grub_printf(const char *, ...);
  17281. +extern char config_file[128];
  17282. +extern void etherboot_printf(const char *, ...);
  17283. +extern int etherboot_sprintf(char *, const char *, ...);
  17284. +extern int getdec(char **s);
  17285. +extern void cleanup_net(void);
  17286. +extern void print_network_configuration (void);
  17287. +extern int ifconfig (char *, char *, char *, char *);
  17288. +extern struct arptable_t arptable[MAX_ARP];
  17289. +
  17290. +#undef printf
  17291. +#undef sprintf
  17292. +#define printf etherboot_printf
  17293. +#define sprintf etherboot_sprintf
  17294. +
  17295. +#ifdef DEBUG
  17296. +#define EnterFunction(func) printf("Enter: " func "\n");
  17297. +#define LeaveFunction(func) printf("Leave: " func "\n");
  17298. +#else
  17299. +#define EnterFunction(func)
  17300. +#define LeaveFunction(func)
  17301. +#endif
  17302. +
  17303. +/*
  17304. + * Some codes from etherboot use a level in DEBUG. Define it to be
  17305. + * zero means no debug info output, that will make them silence in
  17306. + * compiling. Up it as you want.
  17307. + */
  17308. +#ifndef DEBUG
  17309. +# define DEBUG 0
  17310. +#endif
  17311. +
  17312. +/*#define RPC_DEBUG*/
  17313. +
  17314. +extern char *hostname;
  17315. +
  17316. +extern int hostnamelen;
  17317. +/* Whether network is ready */
  17318. +extern int network_ready;
  17319. +
  17320. +/* User aborted in await_reply if not zero */
  17321. +extern int user_abort;
  17322. +
  17323. +extern int rarp(void);
  17324. +extern int grub_eth_probe(void);
  17325. +extern int bootp(void);
  17326. +
  17327. +extern int dhcp(void);
  17328. +
  17329. +extern struct nic nic;
  17330. +#endif /* GRUB_H */
  17331. Index: b/netboot/i386_byteswap.h
  17332. ===================================================================
  17333. --- /dev/null
  17334. +++ b/netboot/i386_byteswap.h
  17335. @@ -0,0 +1,46 @@
  17336. +#ifndef ETHERBOOT_BITS_BYTESWAP_H
  17337. +#define ETHERBOOT_BITS_BYTESWAP_H
  17338. +
  17339. +#include "types.h"
  17340. +static inline uint16_t __i386_bswap_16(uint16_t x)
  17341. +{
  17342. + __asm__("xchgb %b0,%h0\n\t"
  17343. + : "=q" (x)
  17344. + : "0" (x));
  17345. + return x;
  17346. +}
  17347. +
  17348. +static inline uint32_t __i386_bswap_32(uint32_t x)
  17349. +{
  17350. + __asm__("xchgb %b0,%h0\n\t"
  17351. + "rorl $16,%0\n\t"
  17352. + "xchgb %b0,%h0"
  17353. + : "=q" (x)
  17354. + : "0" (x));
  17355. + return x;
  17356. +}
  17357. +
  17358. +
  17359. +#define __bswap_constant_16(x) \
  17360. + ((uint16_t)((((uint16_t)(x) & 0x00ff) << 8) | \
  17361. + (((uint16_t)(x) & 0xff00) >> 8)))
  17362. +
  17363. +#define __bswap_constant_32(x) \
  17364. + ((uint32_t)((((uint32_t)(x) & 0x000000ffU) << 24) | \
  17365. + (((uint32_t)(x) & 0x0000ff00U) << 8) | \
  17366. + (((uint32_t)(x) & 0x00ff0000U) >> 8) | \
  17367. + (((uint32_t)(x) & 0xff000000U) >> 24)))
  17368. +
  17369. +#define __bswap_16(x) \
  17370. + (__builtin_constant_p(x) ? \
  17371. + __bswap_constant_16(x) : \
  17372. + __i386_bswap_16(x))
  17373. +
  17374. +
  17375. +#define __bswap_32(x) \
  17376. + (__builtin_constant_p(x) ? \
  17377. + __bswap_constant_32(x) : \
  17378. + __i386_bswap_32(x))
  17379. +
  17380. +
  17381. +#endif /* ETHERBOOT_BITS_BYTESWAP_H */
  17382. Index: b/netboot/i386_elf.h
  17383. ===================================================================
  17384. --- /dev/null
  17385. +++ b/netboot/i386_elf.h
  17386. @@ -0,0 +1,91 @@
  17387. +#ifndef I386_BITS_ELF_H
  17388. +#define I386_BITS_ELF_H
  17389. +
  17390. +#include "cpu.h"
  17391. +
  17392. +#ifdef CONFIG_X86_64
  17393. +/* ELF Defines for the 64bit version of the current architecture */
  17394. +#define EM_CURRENT_64 EM_X86_64
  17395. +#define EM_CURRENT_64_PRESENT ( \
  17396. + CPU_FEATURE_P(cpu_info.x86_capability, LM) && \
  17397. + CPU_FEATURE_P(cpu_info.x86_capability, PAE) && \
  17398. + CPU_FEATURE_P(cpu_info.x86_capability, PSE))
  17399. +
  17400. +#define ELF_CHECK_X86_64_ARCH(x) \
  17401. + (EM_CURRENT_64_PRESENT && ((x).e_machine == EM_X86_64))
  17402. +#define __unused_i386
  17403. +#else
  17404. +#define ELF_CHECK_X86_64_ARCH(x) 0
  17405. +#define __unused_i386 __unused
  17406. +#endif
  17407. +
  17408. +
  17409. +/* ELF Defines for the current architecture */
  17410. +#define EM_CURRENT EM_386
  17411. +#define ELFDATA_CURRENT ELFDATA2LSB
  17412. +
  17413. +#define ELF_CHECK_I386_ARCH(x) \
  17414. + (((x).e_machine == EM_386) || ((x).e_machine == EM_486))
  17415. +
  17416. +#define ELF_CHECK_ARCH(x) \
  17417. + ((ELF_CHECK_I386_ARCH(x) || ELF_CHECK_X86_64_ARCH(x)) && \
  17418. + ((x).e_entry <= 0xffffffffUL))
  17419. +
  17420. +#ifdef IMAGE_FREEBSD
  17421. +/*
  17422. + * FreeBSD has this rather strange "feature" of its design.
  17423. + * At some point in its evolution, FreeBSD started to rely
  17424. + * externally on private/static/debug internal symbol information.
  17425. + * That is, some of the interfaces that software uses to access
  17426. + * and work with the FreeBSD kernel are made available not
  17427. + * via the shared library symbol information (the .DYNAMIC section)
  17428. + * but rather the debug symbols. This means that any symbol, not
  17429. + * just publicly defined symbols can be (and are) used by system
  17430. + * tools to make the system work. (such as top, swapinfo, swapon,
  17431. + * etc)
  17432. + *
  17433. + * Even worse, however, is the fact that standard ELF loaders do
  17434. + * not know how to load the symbols since they are not within
  17435. + * an ELF PT_LOAD section. The kernel needs these symbols to
  17436. + * operate so the following changes/additions to the boot
  17437. + * loading of EtherBoot have been made to get the kernel to load.
  17438. + * All of the changes are within IMAGE_FREEBSD such that the
  17439. + * extra/changed code only compiles when FREEBSD support is
  17440. + * enabled.
  17441. + */
  17442. +
  17443. +/*
  17444. + * Section header for FreeBSD (debug symbol kludge!) support
  17445. + */
  17446. +typedef struct {
  17447. + Elf32_Word sh_name; /* Section name (index into the
  17448. + section header string table). */
  17449. + Elf32_Word sh_type; /* Section type. */
  17450. + Elf32_Word sh_flags; /* Section flags. */
  17451. + Elf32_Addr sh_addr; /* Address in memory image. */
  17452. + Elf32_Off sh_offset; /* Offset in file. */
  17453. + Elf32_Size sh_size; /* Size in bytes. */
  17454. + Elf32_Word sh_link; /* Index of a related section. */
  17455. + Elf32_Word sh_info; /* Depends on section type. */
  17456. + Elf32_Size sh_addralign; /* Alignment in bytes. */
  17457. + Elf32_Size sh_entsize; /* Size of each entry in section. */
  17458. +} Elf32_Shdr;
  17459. +
  17460. +/* sh_type */
  17461. +#define SHT_SYMTAB 2 /* symbol table section */
  17462. +#define SHT_STRTAB 3 /* string table section */
  17463. +
  17464. +/*
  17465. + * Module information subtypes (for the metadata that we need to build)
  17466. + */
  17467. +#define MODINFO_END 0x0000 /* End of list */
  17468. +#define MODINFO_NAME 0x0001 /* Name of module (string) */
  17469. +#define MODINFO_TYPE 0x0002 /* Type of module (string) */
  17470. +#define MODINFO_METADATA 0x8000 /* Module-specfic */
  17471. +
  17472. +#define MODINFOMD_SSYM 0x0003 /* start of symbols */
  17473. +#define MODINFOMD_ESYM 0x0004 /* end of symbols */
  17474. +
  17475. +#endif /* IMAGE_FREEBSD */
  17476. +
  17477. +#endif /* I386_BITS_ELF_H */
  17478. Index: b/netboot/i386_endian.h
  17479. ===================================================================
  17480. --- /dev/null
  17481. +++ b/netboot/i386_endian.h
  17482. @@ -0,0 +1,6 @@
  17483. +#ifndef ETHERBOOT_BITS_ENDIAN_H
  17484. +#define ETHERBOOT_BITS_ENDIAN_H
  17485. +
  17486. +#define __BYTE_ORDER __LITTLE_ENDIAN
  17487. +
  17488. +#endif /* ETHERBOOT_BITS_ENDIAN_H */
  17489. Index: b/netboot/i386_timer.c
  17490. ===================================================================
  17491. --- /dev/null
  17492. +++ b/netboot/i386_timer.c
  17493. @@ -0,0 +1,192 @@
  17494. +/* A couple of routines to implement a low-overhead timer for drivers */
  17495. +
  17496. + /*
  17497. + * This program is free software; you can redistribute it and/or
  17498. + * modify it under the terms of the GNU General Public License as
  17499. + * published by the Free Software Foundation; either version 2, or (at
  17500. + * your option) any later version.
  17501. + */
  17502. +#include "grub.h"
  17503. +#include "osdep.h"
  17504. +#include "io.h"
  17505. +#include "timer.h"
  17506. +#include "latch.h"
  17507. +
  17508. +void __load_timer2(unsigned int ticks)
  17509. +{
  17510. + /*
  17511. + * Now let's take care of PPC channel 2
  17512. + *
  17513. + * Set the Gate high, program PPC channel 2 for mode 0,
  17514. + * (interrupt on terminal count mode), binary count,
  17515. + * load 5 * LATCH count, (LSB and MSB) to begin countdown.
  17516. + *
  17517. + * Note some implementations have a bug where the high bits byte
  17518. + * of channel 2 is ignored.
  17519. + */
  17520. + /* Set up the timer gate, turn off the speaker */
  17521. + /* Set the Gate high, disable speaker */
  17522. + outb((inb(PPC_PORTB) & ~PPCB_SPKR) | PPCB_T2GATE, PPC_PORTB);
  17523. + /* binary, mode 0, LSB/MSB, Ch 2 */
  17524. + outb(TIMER2_SEL|WORD_ACCESS|MODE0|BINARY_COUNT, TIMER_MODE_PORT);
  17525. + /* LSB of ticks */
  17526. + outb(ticks & 0xFF, TIMER2_PORT);
  17527. + /* MSB of ticks */
  17528. + outb(ticks >> 8, TIMER2_PORT);
  17529. +}
  17530. +
  17531. +static int __timer2_running(void)
  17532. +{
  17533. + return ((inb(PPC_PORTB) & PPCB_T2OUT) == 0);
  17534. +}
  17535. +
  17536. +#if !defined(CONFIG_TSC_CURRTICKS)
  17537. +void setup_timers(void)
  17538. +{
  17539. + return;
  17540. +}
  17541. +
  17542. +void load_timer2(unsigned int ticks)
  17543. +{
  17544. + return __load_timer2(ticks);
  17545. +}
  17546. +
  17547. +int timer2_running(void)
  17548. +{
  17549. + return __timer2_running();
  17550. +}
  17551. +
  17552. +void ndelay(unsigned int nsecs)
  17553. +{
  17554. + waiton_timer2((nsecs * CLOCK_TICK_RATE)/1000000000);
  17555. +}
  17556. +void udelay(unsigned int usecs)
  17557. +{
  17558. + waiton_timer2((usecs * TICKS_PER_MS)/1000);
  17559. +}
  17560. +#endif /* !defined(CONFIG_TSC_CURRTICKS) */
  17561. +
  17562. +#if defined(CONFIG_TSC_CURRTICKS)
  17563. +
  17564. +#define rdtsc(low,high) \
  17565. + __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
  17566. +
  17567. +#define rdtscll(val) \
  17568. + __asm__ __volatile__ ("rdtsc" : "=A" (val))
  17569. +
  17570. +
  17571. +/* Number of clock ticks to time with the rtc */
  17572. +#define LATCH 0xFF
  17573. +
  17574. +#define LATCHES_PER_SEC ((CLOCK_TICK_RATE + (LATCH/2))/LATCH)
  17575. +#define TICKS_PER_LATCH ((LATCHES_PER_SEC + (TICKS_PER_SEC/2))/TICKS_PER_SEC)
  17576. +
  17577. +static void sleep_latch(void)
  17578. +{
  17579. + __load_timer2(LATCH);
  17580. + while(__timer2_running());
  17581. +}
  17582. +
  17583. +/* ------ Calibrate the TSC -------
  17584. + * Time how long it takes to excute a loop that runs in known time.
  17585. + * And find the convertion needed to get to CLOCK_TICK_RATE
  17586. + */
  17587. +
  17588. +
  17589. +static unsigned long long calibrate_tsc(void)
  17590. +{
  17591. + unsigned long startlow, starthigh;
  17592. + unsigned long endlow, endhigh;
  17593. +
  17594. + rdtsc(startlow,starthigh);
  17595. + sleep_latch();
  17596. + rdtsc(endlow,endhigh);
  17597. +
  17598. + /* 64-bit subtract - gcc just messes up with long longs */
  17599. + __asm__("subl %2,%0\n\t"
  17600. + "sbbl %3,%1"
  17601. + :"=a" (endlow), "=d" (endhigh)
  17602. + :"g" (startlow), "g" (starthigh),
  17603. + "0" (endlow), "1" (endhigh));
  17604. +
  17605. + /* Error: ECPUTOOFAST */
  17606. + if (endhigh)
  17607. + goto bad_ctc;
  17608. +
  17609. + endlow *= TICKS_PER_LATCH;
  17610. + return endlow;
  17611. +
  17612. + /*
  17613. + * The CTC wasn't reliable: we got a hit on the very first read,
  17614. + * or the CPU was so fast/slow that the quotient wouldn't fit in
  17615. + * 32 bits..
  17616. + */
  17617. +bad_ctc:
  17618. + printf("bad_ctc\n");
  17619. + return 0;
  17620. +}
  17621. +
  17622. +static unsigned long clocks_per_tick;
  17623. +void setup_timers(void)
  17624. +{
  17625. + if (!clocks_per_tick) {
  17626. + clocks_per_tick = calibrate_tsc();
  17627. + /* Display the CPU Mhz to easily test if the calibration was bad */
  17628. + printf("CPU %ld Mhz\n", (clocks_per_tick/1000 * TICKS_PER_SEC)/1000);
  17629. + }
  17630. +}
  17631. +
  17632. +unsigned long currticks(void)
  17633. +{
  17634. + unsigned long clocks_high, clocks_low;
  17635. + unsigned long currticks;
  17636. + /* Read the Time Stamp Counter */
  17637. + rdtsc(clocks_low, clocks_high);
  17638. +
  17639. + /* currticks = clocks / clocks_per_tick; */
  17640. + __asm__("divl %1"
  17641. + :"=a" (currticks)
  17642. + :"r" (clocks_per_tick), "0" (clocks_low), "d" (clocks_high));
  17643. +
  17644. +
  17645. + return currticks;
  17646. +}
  17647. +
  17648. +static unsigned long long timer_timeout;
  17649. +static int __timer_running(void)
  17650. +{
  17651. + unsigned long long now;
  17652. + rdtscll(now);
  17653. + return now < timer_timeout;
  17654. +}
  17655. +
  17656. +void udelay(unsigned int usecs)
  17657. +{
  17658. + unsigned long long now;
  17659. + rdtscll(now);
  17660. + timer_timeout = now + usecs * ((clocks_per_tick * TICKS_PER_SEC)/(1000*1000));
  17661. + while(__timer_running());
  17662. +}
  17663. +void ndelay(unsigned int nsecs)
  17664. +{
  17665. + unsigned long long now;
  17666. + rdtscll(now);
  17667. + timer_timeout = now + nsecs * ((clocks_per_tick * TICKS_PER_SEC)/(1000*1000*1000));
  17668. + while(__timer_running());
  17669. +}
  17670. +
  17671. +void load_timer2(unsigned int timer2_ticks)
  17672. +{
  17673. + unsigned long long now;
  17674. + unsigned long clocks;
  17675. + rdtscll(now);
  17676. + clocks = timer2_ticks * ((clocks_per_tick * TICKS_PER_SEC)/CLOCK_TICK_RATE);
  17677. + timer_timeout = now + clocks;
  17678. +}
  17679. +
  17680. +int timer2_running(void)
  17681. +{
  17682. + return __timer_running();
  17683. +}
  17684. +
  17685. +#endif /* RTC_CURRTICKS */
  17686. Index: b/netboot/i82586.c
  17687. ===================================================================
  17688. --- a/netboot/i82586.c
  17689. +++ /dev/null
  17690. @@ -1,825 +0,0 @@
  17691. -/**************************************************************************
  17692. -Etherboot - BOOTP/TFTP Bootstrap Program
  17693. -i82586 NIC driver for Etherboot
  17694. -Ken Yap, January 1998
  17695. -***************************************************************************/
  17696. -
  17697. -/*
  17698. - * This program is free software; you can redistribute it and/or
  17699. - * modify it under the terms of the GNU General Public License as
  17700. - * published by the Free Software Foundation; either version 2, or (at
  17701. - * your option) any later version.
  17702. - */
  17703. -
  17704. -#include "etherboot.h"
  17705. -#include "nic.h"
  17706. -#include "cards.h"
  17707. -#include "timer.h"
  17708. -
  17709. -#define udelay(n) waiton_timer2(((n)*TICKS_PER_MS)/1000)
  17710. -
  17711. -/* Sources of information:
  17712. -
  17713. - Donald Becker's excellent 3c507 driver in Linux
  17714. - Intel 82596 data sheet (yes, 82596; it has a 586 compatibility mode)
  17715. -*/
  17716. -
  17717. -/* Code below mostly stolen wholesale from 3c507.c driver in Linux */
  17718. -
  17719. -/*
  17720. - Details of the i82586.
  17721. -
  17722. - You'll really need the databook to understand the details of this part,
  17723. - but the outline is that the i82586 has two separate processing units.
  17724. - Both are started from a list of three configuration tables, of which only
  17725. - the last, the System Control Block (SCB), is used after reset-time. The SCB
  17726. - has the following fields:
  17727. - Status word
  17728. - Command word
  17729. - Tx/Command block addr.
  17730. - Rx block addr.
  17731. - The command word accepts the following controls for the Tx and Rx units:
  17732. - */
  17733. -
  17734. -#define CUC_START 0x0100
  17735. -#define CUC_RESUME 0x0200
  17736. -#define CUC_SUSPEND 0x0300
  17737. -#define RX_START 0x0010
  17738. -#define RX_RESUME 0x0020
  17739. -#define RX_SUSPEND 0x0030
  17740. -
  17741. -/* The Rx unit uses a list of frame descriptors and a list of data buffer
  17742. - descriptors. We use full-sized (1518 byte) data buffers, so there is
  17743. - a one-to-one pairing of frame descriptors to buffer descriptors.
  17744. -
  17745. - The Tx ("command") unit executes a list of commands that look like:
  17746. - Status word Written by the 82586 when the command is done.
  17747. - Command word Command in lower 3 bits, post-command action in upper 3
  17748. - Link word The address of the next command.
  17749. - Parameters (as needed).
  17750. -
  17751. - Some definitions related to the Command Word are:
  17752. - */
  17753. -#define CMD_EOL 0x8000 /* The last command of the list, stop. */
  17754. -#define CMD_SUSP 0x4000 /* Suspend after doing cmd. */
  17755. -#define CMD_INTR 0x2000 /* Interrupt after doing cmd. */
  17756. -
  17757. -enum commands {
  17758. - CmdNOp = 0, CmdSASetup = 1, CmdConfigure = 2, CmdMulticastList = 3,
  17759. - CmdTx = 4, CmdTDR = 5, CmdDump = 6, CmdDiagnose = 7};
  17760. -
  17761. -/*
  17762. - Details of the EtherLink16 Implementation
  17763. -
  17764. - The 3c507 and NI5210 are generic shared-memory i82586 implementations.
  17765. - 3c507: The host can map 16K, 32K, 48K, or 64K of the 64K memory into
  17766. - 0x0[CD][08]0000, or all 64K into 0xF[02468]0000.
  17767. - NI5210: The host can map 8k or 16k at 0x[CDE][048C]000 but we
  17768. - assume 8k because to have 16k you cannot put a ROM on the NIC.
  17769. - */
  17770. -
  17771. -/* Offsets from the base I/O address. */
  17772. -
  17773. -#ifdef INCLUDE_3C507
  17774. -
  17775. -#define SA_DATA 0 /* Station address data, or 3Com signature. */
  17776. -#define MISC_CTRL 6 /* Switch the SA_DATA banks, and bus config bits. */
  17777. -#define RESET_IRQ 10 /* Reset the latched IRQ line. */
  17778. -#define I82586_ATTN 11 /* Frob the 82586 Channel Attention line. */
  17779. -#define ROM_CONFIG 13
  17780. -#define MEM_CONFIG 14
  17781. -#define IRQ_CONFIG 15
  17782. -#define EL16_IO_EXTENT 16
  17783. -
  17784. -/* The ID port is used at boot-time to locate the ethercard. */
  17785. -#define ID_PORT 0x100
  17786. -
  17787. -#endif
  17788. -
  17789. -#ifdef INCLUDE_NI5210
  17790. -
  17791. -#define NI52_RESET 0 /* writing to this address, resets the i82586 */
  17792. -#define I82586_ATTN 1 /* channel attention, kick the 586 */
  17793. -
  17794. -#endif
  17795. -
  17796. -#ifdef INCLUDE_EXOS205
  17797. -
  17798. -#define EXOS205_RESET 0 /* writing to this address, resets the i82586 */
  17799. -#define I82586_ATTN 1 /* channel attention, kick the 586 */
  17800. -
  17801. -#endif
  17802. -
  17803. -/* Offsets to registers in the mailbox (SCB). */
  17804. -#define iSCB_STATUS 0x8
  17805. -#define iSCB_CMD 0xA
  17806. -#define iSCB_CBL 0xC /* Command BLock offset. */
  17807. -#define iSCB_RFA 0xE /* Rx Frame Area offset. */
  17808. -
  17809. -/* Since the 3c507 maps the shared memory window so that the last byte is
  17810. -at 82586 address FFFF, the first byte is at 82586 address 0, 16K, 32K, or
  17811. -48K corresponding to window sizes of 64K, 48K, 32K and 16K respectively.
  17812. -We can account for this be setting the 'SBC Base' entry in the ISCP table
  17813. -below for all the 16 bit offset addresses, and also adding the 'SCB Base'
  17814. -value to all 24 bit physical addresses (in the SCP table and the TX and RX
  17815. -Buffer Descriptors).
  17816. - -Mark
  17817. -*/
  17818. -
  17819. -/*
  17820. - What follows in 'init_words[]' is the "program" that is downloaded to the
  17821. - 82586 memory. It's mostly tables and command blocks, and starts at the
  17822. - reset address 0xfffff6. This is designed to be similar to the EtherExpress,
  17823. - thus the unusual location of the SCB at 0x0008.
  17824. -
  17825. - Even with the additional "don't care" values, doing it this way takes less
  17826. - program space than initializing the individual tables, and I feel it's much
  17827. - cleaner.
  17828. -
  17829. - The databook is particularly useless for the first two structures, I had
  17830. - to use the Crynwr driver as an example.
  17831. -
  17832. - The memory setup is as follows:
  17833. -*/
  17834. -
  17835. -#define CONFIG_CMD 0x18
  17836. -#define SET_SA_CMD 0x24
  17837. -#define SA_OFFSET 0x2A
  17838. -#define IDLELOOP 0x30
  17839. -#define TDR_CMD 0x38
  17840. -#define TDR_TIME 0x3C
  17841. -#define DUMP_CMD 0x40
  17842. -#define DIAG_CMD 0x48
  17843. -#define SET_MC_CMD 0x4E
  17844. -#define DUMP_DATA 0x56 /* A 170 byte buffer for dump and Set-MC into. */
  17845. -
  17846. -#define TX_BUF_START 0x0100
  17847. -#define TX_BUF_SIZE (1518+14+20+16) /* packet+header+TBD */
  17848. -
  17849. -#define RX_BUF_START 0x1000
  17850. -#define RX_BUF_SIZE (1518+14+18) /* packet+header+RBD */
  17851. -#define RX_BUF_END (mem_end - mem_start - 20)
  17852. -
  17853. -/*
  17854. - That's it: only 86 bytes to set up the beast, including every extra
  17855. - command available. The 170 byte buffer at DUMP_DATA is shared between the
  17856. - Dump command (called only by the diagnostic program) and the SetMulticastList
  17857. - command.
  17858. -
  17859. - To complete the memory setup you only have to write the station address at
  17860. - SA_OFFSET and create the Tx & Rx buffer lists.
  17861. -
  17862. - The Tx command chain and buffer list is setup as follows:
  17863. - A Tx command table, with the data buffer pointing to...
  17864. - A Tx data buffer descriptor. The packet is in a single buffer, rather than
  17865. - chaining together several smaller buffers.
  17866. - A NoOp command, which initially points to itself,
  17867. - And the packet data.
  17868. -
  17869. - A transmit is done by filling in the Tx command table and data buffer,
  17870. - re-writing the NoOp command, and finally changing the offset of the last
  17871. - command to point to the current Tx command. When the Tx command is finished,
  17872. - it jumps to the NoOp, when it loops until the next Tx command changes the
  17873. - "link offset" in the NoOp. This way the 82586 never has to go through the
  17874. - slow restart sequence.
  17875. -
  17876. - The Rx buffer list is set up in the obvious ring structure. We have enough
  17877. - memory (and low enough interrupt latency) that we can avoid the complicated
  17878. - Rx buffer linked lists by alway associating a full-size Rx data buffer with
  17879. - each Rx data frame.
  17880. -
  17881. - I currently use one transmit buffer starting at TX_BUF_START (0x0100), and
  17882. - use the rest of memory, from RX_BUF_START to RX_BUF_END, for Rx buffers.
  17883. -
  17884. - */
  17885. -
  17886. -static unsigned short init_words[] = {
  17887. - /* System Configuration Pointer (SCP). */
  17888. -#if defined(INCLUDE_3C507)
  17889. - 0x0000, /* Set bus size to 16 bits. */
  17890. -#else
  17891. - 0x0001, /* Set bus size to 8 bits */
  17892. -#endif
  17893. - 0,0, /* pad words. */
  17894. - 0x0000,0x0000, /* ISCP phys addr, set in init_82586_mem(). */
  17895. -
  17896. - /* Intermediate System Configuration Pointer (ISCP). */
  17897. - 0x0001, /* Status word that's cleared when init is done. */
  17898. - 0x0008,0,0, /* SCB offset, (skip, skip) */
  17899. -
  17900. - /* System Control Block (SCB). */
  17901. - 0,0xf000|RX_START|CUC_START, /* SCB status and cmd. */
  17902. - CONFIG_CMD, /* Command list pointer, points to Configure. */
  17903. - RX_BUF_START, /* Rx block list. */
  17904. - 0,0,0,0, /* Error count: CRC, align, buffer, overrun. */
  17905. -
  17906. - /* 0x0018: Configure command. Change to put MAC data with packet. */
  17907. - 0, CmdConfigure, /* Status, command. */
  17908. - SET_SA_CMD, /* Next command is Set Station Addr. */
  17909. - 0x0804, /* "4" bytes of config data, 8 byte FIFO. */
  17910. - 0x2e40, /* Magic values, including MAC data location. */
  17911. - 0, /* Unused pad word. */
  17912. -
  17913. - /* 0x0024: Setup station address command. */
  17914. - 0, CmdSASetup,
  17915. - SET_MC_CMD, /* Next command. */
  17916. - 0xaa00,0xb000,0x0bad, /* Station address (to be filled in) */
  17917. -
  17918. - /* 0x0030: NOP, looping back to itself. Point to first Tx buffer to Tx. */
  17919. - 0, CmdNOp, IDLELOOP, 0 /* pad */,
  17920. -
  17921. - /* 0x0038: A unused Time-Domain Reflectometer command. */
  17922. - 0, CmdTDR, IDLELOOP, 0,
  17923. -
  17924. - /* 0x0040: An unused Dump State command. */
  17925. - 0, CmdDump, IDLELOOP, DUMP_DATA,
  17926. -
  17927. - /* 0x0048: An unused Diagnose command. */
  17928. - 0, CmdDiagnose, IDLELOOP,
  17929. -
  17930. - /* 0x004E: An empty set-multicast-list command. */
  17931. - 0, CmdMulticastList, IDLELOOP, 0,
  17932. -};
  17933. -
  17934. -/* NIC specific static variables go here */
  17935. -
  17936. -static unsigned short ioaddr, irq, scb_base;
  17937. -static Address mem_start, mem_end;
  17938. -static unsigned short rx_head, rx_tail;
  17939. -
  17940. -#define read_mem(m,s) fmemcpy((char *)s, m, sizeof(s))
  17941. -
  17942. -static void setup_rx_buffers(struct nic *nic)
  17943. -{
  17944. - Address write_ptr;
  17945. - unsigned short cur_rx_buf;
  17946. - static unsigned short rx_cmd[16] = {
  17947. - 0x0000, /* Rx status */
  17948. - 0x0000, /* Rx command, only and last */
  17949. - RX_BUF_START, /* Link (will be adjusted) */
  17950. - RX_BUF_START + 22, /* Buffer offset (will be adjusted) */
  17951. - 0x0000, 0x0000, 0x0000, /* Pad for dest addr */
  17952. - 0x0000, 0x0000, 0x0000, /* Pad for source addr */
  17953. - 0x0000, /* Pad for protocol */
  17954. - 0x0000, /* Buffer: Actual count */
  17955. - -1, /* Buffer: Next (none) */
  17956. - RX_BUF_START + 0x20, /* Buffer: Address low (+ scb_base) (will be adjusted) */
  17957. - 0x0000, /* Buffer: Address high */
  17958. - 0x8000 | (RX_BUF_SIZE - 0x20)
  17959. - };
  17960. -
  17961. - cur_rx_buf = rx_head = RX_BUF_START;
  17962. - do { /* While there is room for one more buffer */
  17963. - write_ptr = mem_start + cur_rx_buf;
  17964. - /* adjust some contents */
  17965. - rx_cmd[1] = 0x0000;
  17966. - rx_cmd[2] = cur_rx_buf + RX_BUF_SIZE;
  17967. - rx_cmd[3] = cur_rx_buf + 22;
  17968. - rx_cmd[13] = cur_rx_buf + 0x20 + scb_base;
  17969. - memcpy((char *)write_ptr, (char *)rx_cmd, sizeof(rx_cmd));
  17970. - rx_tail = cur_rx_buf;
  17971. - cur_rx_buf += RX_BUF_SIZE;
  17972. - } while (cur_rx_buf <= RX_BUF_END - RX_BUF_SIZE);
  17973. - /* Terminate the list by setting the EOL bit and wrap ther pointer
  17974. - to make the list a ring. */
  17975. - write_ptr = mem_start + rx_tail;
  17976. - rx_cmd[1] = 0xC000;
  17977. - rx_cmd[2] = rx_head;
  17978. - memcpy((char *)write_ptr, (char *)rx_cmd, sizeof(unsigned short) * 3);
  17979. -}
  17980. -
  17981. -static void ack_status(void)
  17982. -{
  17983. - unsigned short cmd, status;
  17984. - unsigned short *shmem = (short *)mem_start;
  17985. -
  17986. - cmd = (status = shmem[iSCB_STATUS>>1]) & 0xf000;
  17987. - if (status & 0x100) /* CU suspended? */
  17988. - cmd |= CUC_RESUME;
  17989. - if ((status & 0x200) == 0) /* CU not active? */
  17990. - cmd |= CUC_START;
  17991. - if (status & 0x010) /* RU suspended? */
  17992. - cmd |= RX_RESUME;
  17993. - else if ((status & 0x040) == 0) /* RU not active? */
  17994. - cmd |= RX_START;
  17995. - if (cmd == 0) /* Nothing to do */
  17996. - return;
  17997. - shmem[iSCB_CMD>>1] = cmd;
  17998. -#if defined(DEBUG)
  17999. - printf("Status %hX Command %hX\n", status, cmd);
  18000. -#endif
  18001. - outb(0, ioaddr + I82586_ATTN);
  18002. -}
  18003. -
  18004. -/**************************************************************************
  18005. -RESET - Reset adapter
  18006. -***************************************************************************/
  18007. -
  18008. -static void i82586_reset(struct nic *nic)
  18009. -{
  18010. - unsigned long time;
  18011. - unsigned short *shmem = (short *)mem_start;
  18012. -
  18013. - /* put the card in its initial state */
  18014. -
  18015. -#ifdef INCLUDE_3C507
  18016. - /* Enable loopback to protect the wire while starting up,
  18017. - and hold the 586 in reset during the memory initialisation. */
  18018. - outb(0x20, ioaddr + MISC_CTRL);
  18019. -#endif
  18020. -
  18021. - /* Fix the ISCP address and base. */
  18022. - init_words[3] = scb_base;
  18023. - init_words[7] = scb_base;
  18024. -
  18025. - /* Write the words at 0xfff6. */
  18026. - /* Write the words at 0x0000. */
  18027. - /* Fill in the station address. */
  18028. - memcpy((char *)(mem_end - 10), (char *)init_words, 10);
  18029. - memcpy((char *)mem_start, (char *)&init_words[5], sizeof(init_words) - 10);
  18030. - memcpy((char *)mem_start + SA_OFFSET, nic->node_addr, ETH_ALEN);
  18031. - setup_rx_buffers(nic);
  18032. -
  18033. -#ifdef INCLUDE_3C507
  18034. - /* Start the 586 by releasing the reset line, but leave loopback. */
  18035. - outb(0xA0, ioaddr + MISC_CTRL);
  18036. -#endif
  18037. -
  18038. - /* This was time consuming to track down; you need to give two channel
  18039. - attention signals to reliably start up the i82586. */
  18040. - outb(0, ioaddr + I82586_ATTN);
  18041. - time = currticks() + TICKS_PER_SEC; /* allow 1 second to init */
  18042. - while (
  18043. - shmem[iSCB_STATUS>>1] == 0)
  18044. - {
  18045. - if (currticks() > time)
  18046. - {
  18047. - printf("i82586 initialisation timed out with status %hX, cmd %hX\n",
  18048. - shmem[iSCB_STATUS>>1], shmem[iSCB_CMD>>1]);
  18049. - break;
  18050. - }
  18051. - }
  18052. - /* Issue channel-attn -- the 82586 won't start. */
  18053. - outb(0, ioaddr + I82586_ATTN);
  18054. -
  18055. -#ifdef INCLUDE_3C507
  18056. - /* Disable loopback. */
  18057. - outb(0x80, ioaddr + MISC_CTRL);
  18058. -#endif
  18059. -#if defined(DEBUG)
  18060. - printf("i82586 status %hX, cmd %hX\n",
  18061. - shmem[iSCB_STATUS>>1], shmem[iSCB_CMD>>1]);
  18062. -#endif
  18063. -}
  18064. -
  18065. -/**************************************************************************
  18066. - POLL - Wait for a frame
  18067. - ***************************************************************************/
  18068. -static int i82586_poll(struct nic *nic)
  18069. -{
  18070. - int status;
  18071. - unsigned short rfd_cmd, next_rx_frame, data_buffer_addr,
  18072. - frame_status, pkt_len;
  18073. - unsigned short *shmem = (short *)mem_start + rx_head;
  18074. -
  18075. - /* return true if there's an ethernet packet ready to read */
  18076. - if (
  18077. - ((frame_status = shmem[0]) & 0x8000) == 0)
  18078. - return (0); /* nope */
  18079. - rfd_cmd = shmem[1];
  18080. - next_rx_frame = shmem[2];
  18081. - data_buffer_addr = shmem[3];
  18082. - pkt_len = shmem[11];
  18083. - status = 0;
  18084. - if (rfd_cmd != 0 || data_buffer_addr != rx_head + 22
  18085. - || (pkt_len & 0xC000) != 0xC000)
  18086. - printf("\nRx frame corrupt, discarded");
  18087. - else if ((frame_status & 0x2000) == 0)
  18088. - printf("\nRx frame had error");
  18089. - else
  18090. - {
  18091. - /* We have a frame, copy it to our buffer */
  18092. - pkt_len &= 0x3FFF;
  18093. - memcpy(nic->packet, (char *)mem_start + rx_head + 0x20, pkt_len);
  18094. - /* Only packets not from ourself */
  18095. - if (memcmp(nic->packet + ETH_ALEN, nic->node_addr, ETH_ALEN) != 0)
  18096. - {
  18097. - nic->packetlen = pkt_len;
  18098. - status = 1;
  18099. - }
  18100. - }
  18101. - /* Clear the status word and set EOL on Rx frame */
  18102. - shmem[0] = 0;
  18103. - shmem[1] = 0xC000;
  18104. - *(short *)(mem_start + rx_tail + 2) = 0;
  18105. - rx_tail = rx_head;
  18106. - rx_head = next_rx_frame;
  18107. - ack_status();
  18108. - return (status);
  18109. -}
  18110. -
  18111. -/**************************************************************************
  18112. - TRANSMIT - Transmit a frame
  18113. - ***************************************************************************/
  18114. -static void i82586_transmit(
  18115. - struct nic *nic,
  18116. - const char *d, /* Destination */
  18117. - unsigned int t, /* Type */
  18118. - unsigned int s, /* size */
  18119. - const char *p) /* Packet */
  18120. -{
  18121. - Address bptr;
  18122. - unsigned short type, z;
  18123. - static unsigned short tx_cmd[11] = {
  18124. - 0x0, /* Tx status */
  18125. - CmdTx, /* Tx command */
  18126. - TX_BUF_START+16, /* Next command is a NoOp */
  18127. - TX_BUF_START+8, /* Data Buffer offset */
  18128. - 0x8000, /* | with size */
  18129. - 0xffff, /* No next data buffer */
  18130. - TX_BUF_START+22, /* + scb_base */
  18131. - 0x0, /* Buffer address high bits (always zero) */
  18132. - 0x0, /* Nop status */
  18133. - CmdNOp, /* Nop command */
  18134. - TX_BUF_START+16 /* Next is myself */
  18135. - };
  18136. - unsigned short *shmem = (short *)mem_start + TX_BUF_START;
  18137. -
  18138. - /* send the packet to destination */
  18139. - /* adjust some contents */
  18140. - type = htons(t);
  18141. - if (s < ETH_ZLEN)
  18142. - s = ETH_ZLEN;
  18143. - tx_cmd[4] = (s + ETH_HLEN) | 0x8000;
  18144. - tx_cmd[6] = TX_BUF_START + 22 + scb_base;
  18145. - bptr = mem_start + TX_BUF_START;
  18146. - memcpy((char *)bptr, (char *)tx_cmd, sizeof(tx_cmd));
  18147. - bptr += sizeof(tx_cmd);
  18148. - memcpy((char *)bptr, d, ETH_ALEN);
  18149. - bptr += ETH_ALEN;
  18150. - memcpy((char *)bptr, nic->node_addr, ETH_ALEN);
  18151. - bptr += ETH_ALEN;
  18152. - memcpy((char *)bptr, (char *)&type, sizeof(type));
  18153. - bptr += sizeof(type);
  18154. - memcpy((char *)bptr, p, s);
  18155. - /* Change the offset in the IDLELOOP */
  18156. - *(unsigned short *)(mem_start + IDLELOOP + 4) = TX_BUF_START;
  18157. - /* Wait for transmit completion */
  18158. - while (
  18159. - (shmem[0] & 0x2000) == 0)
  18160. - ;
  18161. - /* Change the offset in the IDLELOOP back and
  18162. - change the final loop to point here */
  18163. - *(unsigned short *)(mem_start + IDLELOOP + 4) = IDLELOOP;
  18164. - *(unsigned short *)(mem_start + TX_BUF_START + 20) = IDLELOOP;
  18165. - ack_status();
  18166. -}
  18167. -
  18168. -/**************************************************************************
  18169. - DISABLE - Turn off ethernet interface
  18170. - ***************************************************************************/
  18171. -static void i82586_disable(struct nic *nic)
  18172. -{
  18173. - unsigned short *shmem = (short *)mem_start;
  18174. -
  18175. -#if 0
  18176. - /* Flush the Tx and disable Rx. */
  18177. - shmem[iSCB_CMD>>1] = RX_SUSPEND | CUC_SUSPEND;
  18178. - outb(0, ioaddr + I82586_ATTN);
  18179. -#ifdef INCLUDE_NI5210
  18180. - outb(0, ioaddr + NI52_RESET);
  18181. -#endif
  18182. -#endif /* 0 */
  18183. -}
  18184. -
  18185. -#ifdef INCLUDE_3C507
  18186. -
  18187. -static int t507_probe1(struct nic *nic, unsigned short ioaddr)
  18188. -{
  18189. - int i;
  18190. - Address size;
  18191. - char mem_config;
  18192. - char if_port;
  18193. -
  18194. - if (inb(ioaddr) != '*' || inb(ioaddr+1) != '3'
  18195. - || inb(ioaddr+2) != 'C' || inb(ioaddr+3) != 'O')
  18196. - return (0);
  18197. - irq = inb(ioaddr + IRQ_CONFIG) & 0x0f;
  18198. - mem_config = inb(ioaddr + MEM_CONFIG);
  18199. - if (mem_config & 0x20)
  18200. - {
  18201. - size = 65536L;
  18202. - mem_start = 0xf00000L + (mem_config & 0x08 ? 0x080000L
  18203. - : (((Address)mem_config & 0x3) << 17));
  18204. - }
  18205. - else
  18206. - {
  18207. - size = ((((Address)mem_config & 0x3) + 1) << 14);
  18208. - mem_start = 0x0c0000L + (((Address)mem_config & 0x18) << 12);
  18209. - }
  18210. - mem_end = mem_start + size;
  18211. - scb_base = 65536L - size;
  18212. - if_port = inb(ioaddr + ROM_CONFIG) & 0x80;
  18213. - /* Get station address */
  18214. - outb(0x01, ioaddr + MISC_CTRL);
  18215. - for (i = 0; i < ETH_ALEN; ++i)
  18216. - {
  18217. - nic->node_addr[i] = inb(ioaddr+i);
  18218. - }
  18219. - printf("\n3c507 ioaddr %#hX, IRQ %d, mem [%#X-%#X], %sternal xcvr, addr %!\n",
  18220. - ioaddr, irq, mem_start, mem_end, if_port ? "in" : "ex", nic->node_addr);
  18221. - return (1);
  18222. -}
  18223. -
  18224. -/**************************************************************************
  18225. -PROBE - Look for an adapter, this routine's visible to the outside
  18226. -***************************************************************************/
  18227. -
  18228. -struct nic *t507_probe(struct nic *nic, unsigned short *probe_addrs)
  18229. -{
  18230. - static unsigned char init_ID_done = 0;
  18231. - unsigned short lrs_state = 0xff;
  18232. - static unsigned short io_addrs[] = { 0x300, 0x320, 0x340, 0x280, 0 };
  18233. - unsigned short *p;
  18234. - int i;
  18235. -
  18236. - if (init_ID_done == 0)
  18237. - {
  18238. - /* Send the ID sequence to the ID_PORT to enable the board */
  18239. - outb(0x00, ID_PORT);
  18240. - for (i = 0; i < 255; ++i)
  18241. - {
  18242. - outb(lrs_state, ID_PORT);
  18243. - lrs_state <<= 1;
  18244. - if (lrs_state & 0x100)
  18245. - lrs_state ^= 0xe7;
  18246. - }
  18247. - outb(0x00, ID_PORT);
  18248. - init_ID_done = 1;
  18249. - }
  18250. - /* if probe_addrs is 0, then routine can use a hardwired default */
  18251. - if (probe_addrs == 0)
  18252. - probe_addrs = io_addrs;
  18253. - for (p = probe_addrs; (ioaddr = *p) != 0; ++p)
  18254. - if (t507_probe1(nic, ioaddr))
  18255. - break;
  18256. - if (ioaddr != 0)
  18257. - {
  18258. - /* point to NIC specific routines */
  18259. - i82586_reset(nic);
  18260. - nic->reset = i82586_reset;
  18261. - nic->poll = i82586_poll;
  18262. - nic->transmit = i82586_transmit;
  18263. - nic->disable = i82586_disable;
  18264. - return nic;
  18265. - }
  18266. - /* else */
  18267. - {
  18268. - return 0;
  18269. - }
  18270. -}
  18271. -
  18272. -#endif
  18273. -
  18274. -#ifdef INCLUDE_NI5210
  18275. -
  18276. -static int ni5210_probe2(void)
  18277. -{
  18278. - unsigned short i;
  18279. - unsigned short shmem[10];
  18280. -
  18281. - /* Fix the ISCP address and base. */
  18282. - init_words[3] = scb_base;
  18283. - init_words[7] = scb_base;
  18284. -
  18285. - /* Write the words at 0xfff6. */
  18286. - /* Write the words at 0x0000. */
  18287. - memcpy((char *)(mem_end - 10), (char *)init_words, 10);
  18288. - memcpy((char *)mem_start, (char *)&init_words[5], sizeof(init_words) - 10);
  18289. - if (*(unsigned short *)mem_start != 1)
  18290. - return (0);
  18291. - outb(0, ioaddr + NI52_RESET);
  18292. - outb(0, ioaddr + I82586_ATTN);
  18293. - udelay(32);
  18294. - i = 50;
  18295. - while (
  18296. - shmem[iSCB_STATUS>>1] == 0)
  18297. - {
  18298. - if (--i == 0)
  18299. - {
  18300. - printf("i82586 initialisation timed out with status %hX, cmd %hX\n",
  18301. - shmem[iSCB_STATUS>>1], shmem[iSCB_CMD>>1]);
  18302. - break;
  18303. - }
  18304. - }
  18305. - /* Issue channel-attn -- the 82586 won't start. */
  18306. - outb(0, ioaddr + I82586_ATTN);
  18307. - if (*(unsigned short *)mem_start != 0)
  18308. - return (0);
  18309. - return (1);
  18310. -}
  18311. -
  18312. -static int ni5210_probe1(struct nic *nic)
  18313. -{
  18314. - int i;
  18315. - static Address mem_addrs[] = {
  18316. - 0xc0000, 0xc4000, 0xc8000, 0xcc000,
  18317. - 0xd0000, 0xd4000, 0xd8000, 0xdc000,
  18318. - 0xe0000, 0xe4000, 0xe8000, 0xec000,
  18319. - 0 };
  18320. - Address *p;
  18321. -
  18322. - if (inb(ioaddr + 6) != 0x0 || inb(ioaddr + 7) != 0x55)
  18323. - return (0);
  18324. - scb_base = -8192; /* assume 8k memory */
  18325. - for (p = mem_addrs; (mem_start = *p) != 0; ++p)
  18326. - if (mem_end = mem_start + 8192, ni5210_probe2())
  18327. - break;
  18328. - if (mem_start == 0)
  18329. - return (0);
  18330. - /* Get station address */
  18331. - for (i = 0; i < ETH_ALEN; ++i)
  18332. - {
  18333. - nic->node_addr[i] = inb(ioaddr+i);
  18334. - }
  18335. - printf("\nNI5210 ioaddr %#hX, mem [%#X-%#X], addr %!\n",
  18336. - ioaddr, mem_start, mem_end, nic->node_addr);
  18337. - return (1);
  18338. -}
  18339. -
  18340. -struct nic *ni5210_probe(struct nic *nic, unsigned short *probe_addrs)
  18341. -{
  18342. - /* missing entries are addresses usually already used */
  18343. - static unsigned short io_addrs[] = {
  18344. - 0x200, 0x208, 0x210, 0x218, 0x220, 0x228, 0x230, 0x238,
  18345. - 0x240, 0x248, 0x250, 0x258, 0x260, 0x268, 0x270, /*Par*/
  18346. - 0x280, 0x288, 0x290, 0x298, 0x2A0, 0x2A8, 0x2B0, 0x2B8,
  18347. - 0x2C0, 0x2C8, 0x2D0, 0x2D8, 0x2E0, 0x2E8, 0x2F0, /*Ser*/
  18348. - 0x300, 0x308, 0x310, 0x318, 0x320, 0x328, 0x330, 0x338,
  18349. - 0x340, 0x348, 0x350, 0x358, 0x360, 0x368, 0x370, /*Par*/
  18350. - 0x380, 0x388, 0x390, 0x398, 0x3A0, 0x3A8, /*Vid,Par*/
  18351. - 0x3C0, 0x3C8, 0x3D0, 0x3D8, 0x3E0, 0x3E8, /*Ser*/
  18352. - 0x0
  18353. - };
  18354. - unsigned short *p;
  18355. - int i;
  18356. -
  18357. - /* if probe_addrs is 0, then routine can use a hardwired default */
  18358. - if (probe_addrs == 0)
  18359. - probe_addrs = io_addrs;
  18360. - for (p = probe_addrs; (ioaddr = *p) != 0; ++p)
  18361. - if (ni5210_probe1(nic))
  18362. - break;
  18363. - if (ioaddr != 0)
  18364. - {
  18365. - /* point to NIC specific routines */
  18366. - i82586_reset(nic);
  18367. - nic->reset = i82586_reset;
  18368. - nic->poll = i82586_poll;
  18369. - nic->transmit = i82586_transmit;
  18370. - nic->disable = i82586_disable;
  18371. - return nic;
  18372. - }
  18373. - /* else */
  18374. - {
  18375. - return 0;
  18376. - }
  18377. -}
  18378. -#endif
  18379. -
  18380. -#ifdef INCLUDE_EXOS205
  18381. -
  18382. -/*
  18383. - * Code to download to I186 in EXOS205
  18384. - */
  18385. -
  18386. -static unsigned char exos_i186_init[] =
  18387. -{
  18388. -0x08,0x00,0x14,0x00,0x00,0x00,0xaa,0xfa,0x33,0xc0,0xba,0xfe,0xff,0xef,0xb8,0xf8,
  18389. -0xff,0xe7,0xa0,0xb8,0x7c,0x00,0xe7,0xa4,0xb8,0xbc,0x80,0xe7,0xa8,0x8c,0xc8,0x8e,
  18390. -0xd8,0xbb,0x2f,0x0e,0xc6,0x07,0xa5,0x33,0xc9,0xeb,0x00,0xeb,0x00,0xeb,0x00,0xe2,
  18391. -0xf8,0xbe,0x2c,0x0e,0xba,0x02,0x05,0x33,0xdb,0xb9,0x03,0x00,0xec,0x24,0x0f,0x8a,
  18392. -0xe0,0x02,0xd8,0x42,0x42,0xec,0x02,0xd8,0xd0,0xe0,0xd0,0xe0,0xd0,0xe0,0xd0,0xe0,
  18393. -0x0a,0xc4,0x88,0x04,0x42,0x42,0x46,0xe2,0xe3,0x8a,0xe3,0xd0,0xec,0xd0,0xec,0xd0,
  18394. -0xec,0xd0,0xec,0x80,0xe3,0x0f,0x02,0xe3,0x80,0xf4,0x05,0xec,0x3a,0xe0,0x74,0x05,
  18395. -0xc6,0x04,0x5a,0xeb,0xfe,0xc6,0x04,0x55,0x33,0xc0,0x8e,0xd8,0xbe,0x38,0x00,0xc7,
  18396. -0x04,0xce,0x0e,0x46,0x46,0xc7,0x04,0x00,0xff,0xfb,0xba,0x3c,0x00,0xb8,0x03,0x00,
  18397. -0xef,0x33,0xdb,0x33,0xc9,0xbd,0x04,0x0f,0x90,0x90,0x90,0x90,0xe2,0xfa,0x43,0x2e,
  18398. -0x89,0x5e,0x00,0xeb,0xf3,0x52,0xba,0x00,0x06,0xef,0x50,0x53,0x55,0xbd,0xf8,0x0e,
  18399. -0x2e,0x8b,0x5e,0x00,0x43,0x2e,0x89,0x5e,0x00,0xba,0x22,0x00,0xb8,0x00,0x80,0xef,
  18400. -0x5d,0x5b,0x58,0x5a,0xcf,0x49,0x4e,0x54,0x52,0x20,0x63,0x6e,0x74,0x2d,0x3e,0x00,
  18401. -0x00,0x4c,0x4f,0x4f,0x50,0x20,0x63,0x6e,0x74,0x2d,0x3e,0x00,0x00,0x00,0x00,0x00,
  18402. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18403. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18404. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18405. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18406. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18407. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18408. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18409. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18410. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18411. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18412. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18413. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18414. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18415. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18416. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xea,0x30,0x0e,0x00,0xff,0x00,0x00,0x00,0x00,
  18417. -0x00,0x00,0x00,0x00,0x00,0x00,00
  18418. -};
  18419. -
  18420. -/* These offsets are from the end of the i186 download code */
  18421. -
  18422. -#define OFFSET_SEMA 0x1D1
  18423. -#define OFFSET_ADDR 0x1D7
  18424. -
  18425. -static int exos205_probe2(void)
  18426. -{
  18427. - unsigned short i;
  18428. - unsigned short shmem[10];
  18429. -
  18430. - /* Fix the ISCP address and base. */
  18431. - init_words[3] = scb_base;
  18432. - init_words[7] = scb_base;
  18433. -
  18434. - /* Write the words at 0xfff6. */
  18435. - /* Write the words at 0x0000. */
  18436. - memcpy((char *)(mem_end - 10), (char *)init_words, 10);
  18437. - memcpy((char *)mem_start, (char *)&init_words[5], sizeof(init_words) - 10);
  18438. - if (*(unsigned short *)mem_start != 1)
  18439. - return (0);
  18440. - outb(0, ioaddr + EXOS205_RESET);
  18441. - outb(0, ioaddr + I82586_ATTN);
  18442. - i = 50;
  18443. - while (
  18444. - shmem[iSCB_STATUS>>1] == 0)
  18445. - {
  18446. - if (--i == 0)
  18447. - {
  18448. - printf("i82586 initialisation timed out with status %hX, cmd %hX\n",
  18449. - shmem[iSCB_STATUS>>1], shmem[iSCB_CMD>>1]);
  18450. - break;
  18451. - }
  18452. - }
  18453. - /* Issue channel-attn -- the 82586 won't start. */
  18454. - outb(0, ioaddr + I82586_ATTN);
  18455. - if (*(unsigned short *)mem_start != 0)
  18456. - return (0);
  18457. - return (1);
  18458. -}
  18459. -
  18460. -static int exos205_probe1(struct nic *nic)
  18461. -{
  18462. - int i;
  18463. - /* If you know the other addresses please let me know */
  18464. - static Address mem_addrs[] = {
  18465. - 0xcc000, 0 };
  18466. - Address *p;
  18467. -
  18468. - scb_base = -16384; /* assume 8k memory */
  18469. - for (p = mem_addrs; (mem_start = *p) != 0; ++p)
  18470. - if (mem_end = mem_start + 16384, exos205_probe2())
  18471. - break;
  18472. - if (mem_start == 0)
  18473. - return (0);
  18474. - /* Get station address */
  18475. - for (i = 0; i < ETH_ALEN; ++i)
  18476. - {
  18477. - nic->node_addr[i] = inb(ioaddr+i);
  18478. - }
  18479. - printf("\nEXOS205 ioaddr %#hX, mem [%#X-%#X], addr %!\n",
  18480. - ioaddr, mem_start, mem_end, nic->node_addr);
  18481. - return (1);
  18482. -}
  18483. -
  18484. -struct nic *exos205_probe(struct nic *nic, unsigned short *probe_addrs)
  18485. -{
  18486. - /* If you know the other addresses, please let me know */
  18487. - static unsigned short io_addrs[] = {
  18488. - 0x310, 0x0
  18489. - };
  18490. - unsigned short *p;
  18491. - int i;
  18492. -
  18493. - /* if probe_addrs is 0, then routine can use a hardwired default */
  18494. - if (probe_addrs == 0)
  18495. - probe_addrs = io_addrs;
  18496. - for (p = probe_addrs; (ioaddr = *p) != 0; ++p)
  18497. - if (exos205_probe1(nic))
  18498. - break;
  18499. - if (ioaddr != 0)
  18500. - {
  18501. - /* point to NIC specific routines */
  18502. - i82586_reset(nic);
  18503. - nic->reset = i82586_reset;
  18504. - nic->poll = i82586_poll;
  18505. - nic->transmit = i82586_transmit;
  18506. - nic->disable = i82586_disable;
  18507. - return nic;
  18508. - }
  18509. - /* else */
  18510. - {
  18511. - return 0;
  18512. - }
  18513. -}
  18514. -
  18515. -#endif
  18516. Index: b/netboot/if_arp.h
  18517. ===================================================================
  18518. --- /dev/null
  18519. +++ b/netboot/if_arp.h
  18520. @@ -0,0 +1,29 @@
  18521. +#ifndef _IF_ARP_H
  18522. +#define _IF_ARP_H
  18523. +
  18524. +#include "types.h"
  18525. +
  18526. +#define ARP_REQUEST 1
  18527. +#define ARP_REPLY 2
  18528. +
  18529. +#ifndef MAX_ARP_RETRIES
  18530. +#define MAX_ARP_RETRIES 20
  18531. +#endif
  18532. +
  18533. +/*
  18534. + * A pity sipaddr and tipaddr are not longword aligned or we could use
  18535. + * in_addr. No, I don't want to use #pragma packed.
  18536. + */
  18537. +struct arprequest {
  18538. + uint16_t hwtype;
  18539. + uint16_t protocol;
  18540. + uint8_t hwlen;
  18541. + uint8_t protolen;
  18542. + uint16_t opcode;
  18543. + uint8_t shwaddr[6];
  18544. + uint8_t sipaddr[4];
  18545. + uint8_t thwaddr[6];
  18546. + uint8_t tipaddr[4];
  18547. +};
  18548. +
  18549. +#endif /* _IF_ARP_H */
  18550. Index: b/netboot/if_ether.h
  18551. ===================================================================
  18552. --- /dev/null
  18553. +++ b/netboot/if_ether.h
  18554. @@ -0,0 +1,21 @@
  18555. +#ifndef _IF_ETHER_H
  18556. +#define _IF_ETHER_H
  18557. +
  18558. +/*
  18559. + I'm moving towards the defined names in linux/if_ether.h for clarity.
  18560. + The confusion between 60/64 and 1514/1518 arose because the NS8390
  18561. + counts the 4 byte frame checksum in the incoming packet, but not
  18562. + in the outgoing packet. 60/1514 are the correct numbers for most
  18563. + if not all of the other NIC controllers.
  18564. +*/
  18565. +
  18566. +#define ETH_ALEN 6 /* Size of Ethernet address */
  18567. +#define ETH_HLEN 14 /* Size of ethernet header */
  18568. +#define ETH_ZLEN 60 /* Minimum packet */
  18569. +#define ETH_FRAME_LEN 1514 /* Maximum packet */
  18570. +#define ETH_DATA_ALIGN 2 /* Amount needed to align the data after an ethernet header */
  18571. +#ifndef ETH_MAX_MTU
  18572. +#define ETH_MAX_MTU (ETH_FRAME_LEN-ETH_HLEN)
  18573. +#endif
  18574. +
  18575. +#endif /* _IF_ETHER_H */
  18576. Index: b/netboot/igmp.h
  18577. ===================================================================
  18578. --- /dev/null
  18579. +++ b/netboot/igmp.h
  18580. @@ -0,0 +1,27 @@
  18581. +#ifndef _IGMP_H
  18582. +#define _IGMP_H
  18583. +
  18584. +/* Max interval between IGMP packets */
  18585. +#define IGMP_INTERVAL (10*TICKS_PER_SEC)
  18586. +#define IGMPv1_ROUTER_PRESENT_TIMEOUT (400*TICKS_PER_SEC)
  18587. +
  18588. +#define IGMP_QUERY 0x11
  18589. +#define IGMPv1_REPORT 0x12
  18590. +#define IGMPv2_REPORT 0x16
  18591. +#define IGMP_LEAVE 0x17
  18592. +#define GROUP_ALL_HOSTS 0xe0000001 /* 224.0.0.1 Host byte order */
  18593. +
  18594. +struct igmp {
  18595. + uint8_t type;
  18596. + uint8_t response_time;
  18597. + uint16_t chksum;
  18598. + in_addr group;
  18599. +};
  18600. +
  18601. +struct igmp_ip_t { /* Format of an igmp ip packet */
  18602. + struct iphdr ip;
  18603. + uint8_t router_alert[4]; /* Router alert option */
  18604. + struct igmp igmp;
  18605. +};
  18606. +
  18607. +#endif /* _IGMP_H */
  18608. Index: b/netboot/in.h
  18609. ===================================================================
  18610. --- /dev/null
  18611. +++ b/netboot/in.h
  18612. @@ -0,0 +1,21 @@
  18613. +#ifndef _IN_H
  18614. +#define _IN_H
  18615. +
  18616. +#include "types.h"
  18617. +
  18618. +#define IP 0x0800
  18619. +#define ARP 0x0806
  18620. +#define RARP 0x8035
  18621. +
  18622. +#define IP_ICMP 1
  18623. +#define IP_IGMP 2
  18624. +#define IP_UDP 17
  18625. +
  18626. +/* Same after going through htonl */
  18627. +#define IP_BROADCAST 0xFFFFFFFF
  18628. +
  18629. +typedef struct {
  18630. + uint32_t s_addr;
  18631. +} in_addr;
  18632. +
  18633. +#endif /* _IN_H */
  18634. Index: b/netboot/io.h
  18635. ===================================================================
  18636. --- /dev/null
  18637. +++ b/netboot/io.h
  18638. @@ -0,0 +1,239 @@
  18639. +#ifndef IO_H
  18640. +#define IO_H
  18641. +
  18642. +
  18643. +/* Amount of relocation etherboot is experiencing */
  18644. +extern unsigned long virt_offset;
  18645. +
  18646. +/* Don't require identity mapped physical memory,
  18647. + * osloader.c is the only valid user at the moment.
  18648. + */
  18649. +unsigned long virt_to_phys(volatile const void *virt_addr);
  18650. +void *phys_to_virt(unsigned long phys_addr);
  18651. +
  18652. +/* virt_to_bus converts an addresss inside of etherboot [_start, _end]
  18653. + * into a memory access cards can use.
  18654. + */
  18655. +#define virt_to_bus virt_to_phys
  18656. +
  18657. +
  18658. +/* bus_to_virt reverses virt_to_bus, the address must be output
  18659. + * from virt_to_bus to be valid. This function does not work on
  18660. + * all bus addresses.
  18661. + */
  18662. +#define bus_to_virt phys_to_virt
  18663. +
  18664. +/* ioremap converts a random 32bit bus address into something
  18665. + * etherboot can access.
  18666. + */
  18667. +static inline void *ioremap(unsigned long bus_addr, unsigned long length __unused)
  18668. +{
  18669. + return bus_to_virt(bus_addr);
  18670. +}
  18671. +
  18672. +/* iounmap cleans up anything ioremap had to setup */
  18673. +static inline void iounmap(void *virt_addr __unused)
  18674. +{
  18675. + return;
  18676. +}
  18677. +
  18678. +/*
  18679. + * This file contains the definitions for the x86 IO instructions
  18680. + * inb/inw/inl/outb/outw/outl and the "string versions" of the same
  18681. + * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
  18682. + * versions of the single-IO instructions (inb_p/inw_p/..).
  18683. + *
  18684. + * This file is not meant to be obfuscating: it's just complicated
  18685. + * to (a) handle it all in a way that makes gcc able to optimize it
  18686. + * as well as possible and (b) trying to avoid writing the same thing
  18687. + * over and over again with slight variations and possibly making a
  18688. + * mistake somewhere.
  18689. + */
  18690. +
  18691. +/*
  18692. + * Thanks to James van Artsdalen for a better timing-fix than
  18693. + * the two short jumps: using outb's to a nonexistent port seems
  18694. + * to guarantee better timings even on fast machines.
  18695. + *
  18696. + * On the other hand, I'd like to be sure of a non-existent port:
  18697. + * I feel a bit unsafe about using 0x80 (should be safe, though)
  18698. + *
  18699. + * Linus
  18700. + */
  18701. +
  18702. +#ifdef SLOW_IO_BY_JUMPING
  18703. +#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
  18704. +#else
  18705. +#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
  18706. +#endif
  18707. +
  18708. +#ifdef REALLY_SLOW_IO
  18709. +#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
  18710. +#else
  18711. +#define SLOW_DOWN_IO __SLOW_DOWN_IO
  18712. +#endif
  18713. +
  18714. +/*
  18715. + * readX/writeX() are used to access memory mapped devices. On some
  18716. + * architectures the memory mapped IO stuff needs to be accessed
  18717. + * differently. On the x86 architecture, we just read/write the
  18718. + * memory location directly.
  18719. + */
  18720. +#define readb(addr) (*(volatile unsigned char *) (addr))
  18721. +#define readw(addr) (*(volatile unsigned short *) (addr))
  18722. +#define readl(addr) (*(volatile unsigned int *) (addr))
  18723. +
  18724. +#define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b))
  18725. +#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b))
  18726. +#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b))
  18727. +
  18728. +#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
  18729. +#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
  18730. +
  18731. +/*
  18732. + * Force strict CPU ordering.
  18733. + * And yes, this is required on UP too when we're talking
  18734. + * to devices.
  18735. + *
  18736. + * For now, "wmb()" doesn't actually do anything, as all
  18737. + * Intel CPU's follow what Intel calls a *Processor Order*,
  18738. + * in which all writes are seen in the program order even
  18739. + * outside the CPU.
  18740. + *
  18741. + * I expect future Intel CPU's to have a weaker ordering,
  18742. + * but I'd also expect them to finally get their act together
  18743. + * and add some real memory barriers if so.
  18744. + *
  18745. + * Some non intel clones support out of order store. wmb() ceases to be a
  18746. + * nop for these.
  18747. + */
  18748. +
  18749. +#define mb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
  18750. +#define rmb() mb()
  18751. +#define wmb() mb();
  18752. +
  18753. +
  18754. +/*
  18755. + * Talk about misusing macros..
  18756. + */
  18757. +
  18758. +#define __OUT1(s,x) \
  18759. +extern void __out##s(unsigned x value, unsigned short port); \
  18760. +extern inline void __out##s(unsigned x value, unsigned short port) {
  18761. +
  18762. +#define __OUT2(s,s1,s2) \
  18763. +__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
  18764. +
  18765. +#define __OUT(s,s1,x) \
  18766. +__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
  18767. +__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \
  18768. +__OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
  18769. +__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; }
  18770. +
  18771. +#define __IN1(s,x) \
  18772. +extern unsigned x __in##s(unsigned short port); \
  18773. +extern inline unsigned x __in##s(unsigned short port) { unsigned x _v;
  18774. +
  18775. +#define __IN2(s,s1,s2) \
  18776. +__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
  18777. +
  18778. +#define __IN(s,s1,x,i...) \
  18779. +__IN1(s,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
  18780. +__IN1(s##c,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); return _v; } \
  18781. +__IN1(s##_p,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
  18782. +__IN1(s##c_p,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; }
  18783. +
  18784. +#define __INS(s) \
  18785. +extern void ins##s(unsigned short port, void * addr, unsigned long count); \
  18786. +extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
  18787. +{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
  18788. +: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
  18789. +
  18790. +#define __OUTS(s) \
  18791. +extern void outs##s(unsigned short port, const void * addr, unsigned long count); \
  18792. +extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
  18793. +{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
  18794. +: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
  18795. +
  18796. +__IN(b,"", char)
  18797. +__IN(w,"",short)
  18798. +__IN(l,"", long)
  18799. +
  18800. +__OUT(b,"b",char)
  18801. +__OUT(w,"w",short)
  18802. +__OUT(l,,int)
  18803. +
  18804. +__INS(b)
  18805. +__INS(w)
  18806. +__INS(l)
  18807. +
  18808. +__OUTS(b)
  18809. +__OUTS(w)
  18810. +__OUTS(l)
  18811. +
  18812. +/*
  18813. + * Note that due to the way __builtin_constant_p() works, you
  18814. + * - can't use it inside a inline function (it will never be true)
  18815. + * - you don't have to worry about side effects within the __builtin..
  18816. + */
  18817. +#define outb(val,port) \
  18818. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18819. + __outbc((val),(port)) : \
  18820. + __outb((val),(port)))
  18821. +
  18822. +#define inb(port) \
  18823. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18824. + __inbc(port) : \
  18825. + __inb(port))
  18826. +
  18827. +#define outb_p(val,port) \
  18828. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18829. + __outbc_p((val),(port)) : \
  18830. + __outb_p((val),(port)))
  18831. +
  18832. +#define inb_p(port) \
  18833. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18834. + __inbc_p(port) : \
  18835. + __inb_p(port))
  18836. +
  18837. +#define outw(val,port) \
  18838. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18839. + __outwc((val),(port)) : \
  18840. + __outw((val),(port)))
  18841. +
  18842. +#define inw(port) \
  18843. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18844. + __inwc(port) : \
  18845. + __inw(port))
  18846. +
  18847. +#define outw_p(val,port) \
  18848. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18849. + __outwc_p((val),(port)) : \
  18850. + __outw_p((val),(port)))
  18851. +
  18852. +#define inw_p(port) \
  18853. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18854. + __inwc_p(port) : \
  18855. + __inw_p(port))
  18856. +
  18857. +#define outl(val,port) \
  18858. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18859. + __outlc((val),(port)) : \
  18860. + __outl((val),(port)))
  18861. +
  18862. +#define inl(port) \
  18863. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18864. + __inlc(port) : \
  18865. + __inl(port))
  18866. +
  18867. +#define outl_p(val,port) \
  18868. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18869. + __outlc_p((val),(port)) : \
  18870. + __outl_p((val),(port)))
  18871. +
  18872. +#define inl_p(port) \
  18873. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18874. + __inlc_p(port) : \
  18875. + __inl_p(port))
  18876. +
  18877. +#endif /* ETHERBOOT_IO_H */
  18878. Index: b/netboot/ip.h
  18879. ===================================================================
  18880. --- /dev/null
  18881. +++ b/netboot/ip.h
  18882. @@ -0,0 +1,36 @@
  18883. +#ifndef _IP_H
  18884. +#define _IP_H
  18885. +
  18886. +/* We need 'uint16_t' */
  18887. +#include "types.h"
  18888. +/* We need 'in_addr' */
  18889. +#include "in.h"
  18890. +
  18891. +struct iphdr {
  18892. + uint8_t verhdrlen;
  18893. + uint8_t service;
  18894. + uint16_t len;
  18895. + uint16_t ident;
  18896. + uint16_t frags;
  18897. + uint8_t ttl;
  18898. + uint8_t protocol;
  18899. + uint16_t chksum;
  18900. + in_addr src;
  18901. + in_addr dest;
  18902. +};
  18903. +
  18904. +extern void build_ip_hdr(unsigned long __destip, int __ttl, int __protocol,
  18905. + int __option_len, int __len, const void * __buf);
  18906. +
  18907. +extern int ip_transmit(int __len, const void * __buf);
  18908. +
  18909. +extern uint16_t ipchksum(const void * __data, unsigned long __length);
  18910. +
  18911. +extern uint16_t add_ipchksums(unsigned long __offset, uint16_t __sum,
  18912. + uint16_t __new);
  18913. +
  18914. +
  18915. +
  18916. +
  18917. +
  18918. +#endif /* _IP_H */
  18919. Index: b/netboot/isa.h
  18920. ===================================================================
  18921. --- /dev/null
  18922. +++ b/netboot/isa.h
  18923. @@ -0,0 +1,27 @@
  18924. +#if !defined(ISA_H) && defined(CONFIG_ISA)
  18925. +#define ISA_H
  18926. +
  18927. +struct dev;
  18928. +
  18929. +#define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
  18930. + ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
  18931. + ((((c)-'A'+1)&0x1f)<<8))
  18932. +
  18933. +#define GENERIC_ISAPNP_VENDOR ISAPNP_VENDOR('P','N','P')
  18934. +
  18935. +struct isa_driver
  18936. +{
  18937. + int type;
  18938. + const char *name;
  18939. + int (*probe)(struct dev *, unsigned short *);
  18940. + unsigned short *ioaddrs;
  18941. +};
  18942. +
  18943. +#define __isa_driver __attribute__ ((unused,__section__(".drivers.isa")))
  18944. +extern const struct isa_driver isa_drivers[];
  18945. +extern const struct isa_driver isa_drivers_end[];
  18946. +
  18947. +#define ISA_ROM(IMAGE, DESCRIPTION)
  18948. +
  18949. +#endif /* ISA_H */
  18950. +
  18951. Index: b/netboot/lance.c
  18952. ===================================================================
  18953. --- a/netboot/lance.c
  18954. +++ /dev/null
  18955. @@ -1,564 +0,0 @@
  18956. -/**************************************************************************
  18957. -Etherboot - BOOTP/TFTP Bootstrap Program
  18958. -LANCE NIC driver for Etherboot
  18959. -Large portions borrowed from the Linux LANCE driver by Donald Becker
  18960. -Ken Yap, July 1997
  18961. -***************************************************************************/
  18962. -
  18963. -/*
  18964. - * This program is free software; you can redistribute it and/or
  18965. - * modify it under the terms of the GNU General Public License as
  18966. - * published by the Free Software Foundation; either version 2, or (at
  18967. - * your option) any later version.
  18968. - */
  18969. -
  18970. -/* to get some global routines like printf */
  18971. -#include "etherboot.h"
  18972. -/* to get the interface to the body of the program */
  18973. -#include "nic.h"
  18974. -#ifdef INCLUDE_LANCE
  18975. -#include "pci.h"
  18976. -#endif
  18977. -#include "cards.h"
  18978. -
  18979. -/* Offsets from base I/O address */
  18980. -#if defined(INCLUDE_NE2100) || defined(INCLUDE_LANCE)
  18981. -#define LANCE_ETH_ADDR 0x0
  18982. -#define LANCE_DATA 0x10
  18983. -#define LANCE_ADDR 0x12
  18984. -#define LANCE_RESET 0x14
  18985. -#define LANCE_BUS_IF 0x16
  18986. -#define LANCE_TOTAL_SIZE 0x18
  18987. -#endif
  18988. -#ifdef INCLUDE_NI6510
  18989. -#define LANCE_ETH_ADDR 0x8
  18990. -#define LANCE_DATA 0x0
  18991. -#define LANCE_ADDR 0x2
  18992. -#define LANCE_RESET 0x4
  18993. -#define LANCE_BUS_IF 0x6
  18994. -#define LANCE_TOTAL_SIZE 0x10
  18995. -#endif
  18996. -
  18997. -/* lance_poll() now can use multiple Rx buffers to prevent packet loss. Set
  18998. - * Set LANCE_LOG_RX_BUFFERS to 0..7 for 1, 2, 4, 8, 16, 32, 64 or 128 Rx
  18999. - * buffers. Usually 4 (=16 Rx buffers) is a good value. (Andreas Neuhaus)
  19000. - * Decreased to 2 (=4 Rx buffers) (Ken Yap, 20010305) */
  19001. -
  19002. -#define LANCE_LOG_RX_BUFFERS 2 /* Use 2^2=4 Rx buffers */
  19003. -
  19004. -#define RX_RING_SIZE (1 << (LANCE_LOG_RX_BUFFERS))
  19005. -#define RX_RING_MOD_MASK (RX_RING_SIZE - 1)
  19006. -#define RX_RING_LEN_BITS ((LANCE_LOG_RX_BUFFERS) << 29)
  19007. -
  19008. -struct lance_init_block
  19009. -{
  19010. - unsigned short mode;
  19011. - unsigned char phys_addr[ETH_ALEN];
  19012. - unsigned long filter[2];
  19013. - Address rx_ring;
  19014. - Address tx_ring;
  19015. -};
  19016. -
  19017. -struct lance_rx_head
  19018. -{
  19019. - union {
  19020. - Address base;
  19021. - unsigned char addr[4];
  19022. - } u;
  19023. - short buf_length; /* 2s complement */
  19024. - short msg_length;
  19025. -};
  19026. -
  19027. -struct lance_tx_head
  19028. -{
  19029. - union {
  19030. - Address base;
  19031. - unsigned char addr[4];
  19032. - } u;
  19033. - short buf_length; /* 2s complement */
  19034. - short misc;
  19035. -};
  19036. -
  19037. -struct lance_interface
  19038. -{
  19039. - struct lance_init_block init_block;
  19040. - struct lance_rx_head rx_ring[RX_RING_SIZE];
  19041. - struct lance_tx_head tx_ring;
  19042. - unsigned char rbuf[RX_RING_SIZE][ETH_FRAME_LEN+4];
  19043. - unsigned char tbuf[ETH_FRAME_LEN];
  19044. - /*
  19045. - * Do not alter the order of the struct members above;
  19046. - * the hardware depends on the correct alignment.
  19047. - */
  19048. - int rx_idx;
  19049. -};
  19050. -
  19051. -#define LANCE_MUST_PAD 0x00000001
  19052. -#define LANCE_ENABLE_AUTOSELECT 0x00000002
  19053. -#define LANCE_SELECT_PHONELINE 0x00000004
  19054. -#define LANCE_MUST_UNRESET 0x00000008
  19055. -
  19056. -/* A mapping from the chip ID number to the part number and features.
  19057. - These are from the datasheets -- in real life the '970 version
  19058. - reportedly has the same ID as the '965. */
  19059. -static const struct lance_chip_type
  19060. -{
  19061. - int id_number;
  19062. - const char *name;
  19063. - int flags;
  19064. -} chip_table[] = {
  19065. - {0x0000, "LANCE 7990", /* Ancient lance chip. */
  19066. - LANCE_MUST_PAD + LANCE_MUST_UNRESET},
  19067. - {0x0003, "PCnet/ISA 79C960", /* 79C960 PCnet/ISA. */
  19068. - LANCE_ENABLE_AUTOSELECT},
  19069. - {0x2260, "PCnet/ISA+ 79C961", /* 79C961 PCnet/ISA+, Plug-n-Play. */
  19070. - LANCE_ENABLE_AUTOSELECT},
  19071. - {0x2420, "PCnet/PCI 79C970", /* 79C970 or 79C974 PCnet-SCSI, PCI. */
  19072. - LANCE_ENABLE_AUTOSELECT},
  19073. - /* Bug: the PCnet/PCI actually uses the PCnet/VLB ID number, so just call
  19074. - it the PCnet32. */
  19075. - {0x2430, "PCnet32", /* 79C965 PCnet for VL bus. */
  19076. - LANCE_ENABLE_AUTOSELECT},
  19077. - {0x2621, "PCnet/PCI-II 79C970A", /* 79C970A PCInetPCI II. */
  19078. - LANCE_ENABLE_AUTOSELECT},
  19079. - {0x2625, "PCnet-FAST III 79C973", /* 79C973 PCInet-FAST III. */
  19080. - LANCE_ENABLE_AUTOSELECT},
  19081. - {0x2626, "PCnet/HomePNA 79C978",
  19082. - LANCE_ENABLE_AUTOSELECT|LANCE_SELECT_PHONELINE},
  19083. - {0x0, "PCnet (unknown)",
  19084. - LANCE_ENABLE_AUTOSELECT},
  19085. -};
  19086. -
  19087. -/* Define a macro for converting program addresses to real addresses */
  19088. -#undef virt_to_bus
  19089. -#define virt_to_bus(x) ((unsigned long)x)
  19090. -
  19091. -static int chip_version;
  19092. -static int lance_version;
  19093. -static unsigned short ioaddr;
  19094. -#ifndef INCLUDE_LANCE
  19095. -static int dma;
  19096. -#endif
  19097. -static struct lance_interface *lp;
  19098. -
  19099. -/* additional 8 bytes for 8-byte alignment space */
  19100. -#ifdef USE_LOWMEM_BUFFER
  19101. -#define lance ((char *)0x10000 - (sizeof(struct lance_interface)+8))
  19102. -#else
  19103. -static char lance[sizeof(struct lance_interface)+8];
  19104. -#endif
  19105. -
  19106. -#ifndef INCLUDE_LANCE
  19107. -/* DMA defines and helper routines */
  19108. -
  19109. -/* DMA controller registers */
  19110. -#define DMA1_CMD_REG 0x08 /* command register (w) */
  19111. -#define DMA1_STAT_REG 0x08 /* status register (r) */
  19112. -#define DMA1_REQ_REG 0x09 /* request register (w) */
  19113. -#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */
  19114. -#define DMA1_MODE_REG 0x0B /* mode register (w) */
  19115. -#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */
  19116. -#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */
  19117. -#define DMA1_RESET_REG 0x0D /* Master Clear (w) */
  19118. -#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */
  19119. -#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */
  19120. -
  19121. -#define DMA2_CMD_REG 0xD0 /* command register (w) */
  19122. -#define DMA2_STAT_REG 0xD0 /* status register (r) */
  19123. -#define DMA2_REQ_REG 0xD2 /* request register (w) */
  19124. -#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */
  19125. -#define DMA2_MODE_REG 0xD6 /* mode register (w) */
  19126. -#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */
  19127. -#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */
  19128. -#define DMA2_RESET_REG 0xDA /* Master Clear (w) */
  19129. -#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */
  19130. -#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */
  19131. -
  19132. -
  19133. -#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */
  19134. -#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
  19135. -#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */
  19136. -
  19137. -/* enable/disable a specific DMA channel */
  19138. -static void enable_dma(unsigned int dmanr)
  19139. -{
  19140. - if (dmanr <= 3)
  19141. - outb_p(dmanr, DMA1_MASK_REG);
  19142. - else
  19143. - outb_p(dmanr & 3, DMA2_MASK_REG);
  19144. -}
  19145. -
  19146. -static void disable_dma(unsigned int dmanr)
  19147. -{
  19148. - if (dmanr <= 3)
  19149. - outb_p(dmanr | 4, DMA1_MASK_REG);
  19150. - else
  19151. - outb_p((dmanr & 3) | 4, DMA2_MASK_REG);
  19152. -}
  19153. -
  19154. -/* set mode (above) for a specific DMA channel */
  19155. -static void set_dma_mode(unsigned int dmanr, char mode)
  19156. -{
  19157. - if (dmanr <= 3)
  19158. - outb_p(mode | dmanr, DMA1_MODE_REG);
  19159. - else
  19160. - outb_p(mode | (dmanr&3), DMA2_MODE_REG);
  19161. -}
  19162. -#endif /* !INCLUDE_LANCE */
  19163. -
  19164. -/**************************************************************************
  19165. -RESET - Reset adapter
  19166. -***************************************************************************/
  19167. -static void lance_reset(struct nic *nic)
  19168. -{
  19169. - int i;
  19170. - Address l;
  19171. -
  19172. - /* Reset the LANCE */
  19173. - (void)inw(ioaddr+LANCE_RESET);
  19174. - /* Un-Reset the LANCE, needed only for the NE2100 */
  19175. - if (chip_table[lance_version].flags & LANCE_MUST_UNRESET)
  19176. - outw(0, ioaddr+LANCE_RESET);
  19177. - if (chip_table[lance_version].flags & LANCE_ENABLE_AUTOSELECT)
  19178. - {
  19179. - /* This is 79C960 specific; Turn on auto-select of media
  19180. - (AUI, BNC). */
  19181. - outw(0x2, ioaddr+LANCE_ADDR);
  19182. - /* Don't touch 10base2 power bit. */
  19183. - outw(inw(ioaddr+LANCE_BUS_IF) | 0x2, ioaddr+LANCE_BUS_IF);
  19184. - }
  19185. - /* HomePNA cards need to explicitly pick the phoneline interface.
  19186. - * Some of these cards have ethernet interfaces as well, this
  19187. - * code might require some modification for those.
  19188. - */
  19189. - if (chip_table[lance_version].flags & LANCE_SELECT_PHONELINE) {
  19190. - short media, check ;
  19191. - /* this is specific to HomePNA cards... */
  19192. - outw(49, ioaddr+0x12) ;
  19193. - media = inw(ioaddr+0x16) ;
  19194. -#ifdef DEBUG
  19195. - printf("media was %d\n", media) ;
  19196. -#endif
  19197. - media &= ~3 ;
  19198. - media |= 1 ;
  19199. -#ifdef DEBUG
  19200. - printf("media changed to %d\n", media) ;
  19201. -#endif
  19202. - media &= ~3 ;
  19203. - media |= 1 ;
  19204. - outw(49, ioaddr+0x12) ;
  19205. - outw(media, ioaddr+0x16) ;
  19206. - outw(49, ioaddr+0x12) ;
  19207. - check = inw(ioaddr+0x16) ;
  19208. -#ifdef DEBUG
  19209. - printf("check %s, media was set properly\n",
  19210. - check == media ? "passed" : "FAILED" ) ;
  19211. -#endif
  19212. - }
  19213. -
  19214. - /* Re-initialise the LANCE, and start it when done. */
  19215. - /* Set station address */
  19216. - for (i = 0; i < ETH_ALEN; ++i)
  19217. - lp->init_block.phys_addr[i] = nic->node_addr[i];
  19218. - /* Preset the receive ring headers */
  19219. - for (i=0; i<RX_RING_SIZE; i++) {
  19220. - lp->rx_ring[i].buf_length = -ETH_FRAME_LEN-4;
  19221. - /* OWN */
  19222. - lp->rx_ring[i].u.base = virt_to_bus(lp->rbuf[i]) & 0xffffff;
  19223. - /* we set the top byte as the very last thing */
  19224. - lp->rx_ring[i].u.addr[3] = 0x80;
  19225. - }
  19226. - lp->rx_idx = 0;
  19227. - lp->init_block.mode = 0x0; /* enable Rx and Tx */
  19228. - l = (Address)virt_to_bus(&lp->init_block);
  19229. - outw(0x1, ioaddr+LANCE_ADDR);
  19230. - (void)inw(ioaddr+LANCE_ADDR);
  19231. - outw((short)l, ioaddr+LANCE_DATA);
  19232. - outw(0x2, ioaddr+LANCE_ADDR);
  19233. - (void)inw(ioaddr+LANCE_ADDR);
  19234. - outw((short)(l >> 16), ioaddr+LANCE_DATA);
  19235. - outw(0x4, ioaddr+LANCE_ADDR);
  19236. - (void)inw(ioaddr+LANCE_ADDR);
  19237. - outw(0x915, ioaddr+LANCE_DATA);
  19238. - outw(0x0, ioaddr+LANCE_ADDR);
  19239. - (void)inw(ioaddr+LANCE_ADDR);
  19240. - outw(0x4, ioaddr+LANCE_DATA); /* stop */
  19241. - outw(0x1, ioaddr+LANCE_DATA); /* init */
  19242. - for (i = 10000; i > 0; --i)
  19243. - if (inw(ioaddr+LANCE_DATA) & 0x100)
  19244. - break;
  19245. -#ifdef DEBUG
  19246. - if (i <= 0)
  19247. - printf("Init timed out\n");
  19248. -#endif
  19249. - /* Apparently clearing the InitDone bit here triggers a bug
  19250. - in the '974. (Mark Stockton) */
  19251. - outw(0x2, ioaddr+LANCE_DATA); /* start */
  19252. -}
  19253. -
  19254. -/**************************************************************************
  19255. -POLL - Wait for a frame
  19256. -***************************************************************************/
  19257. -static int lance_poll(struct nic *nic)
  19258. -{
  19259. - int status;
  19260. -
  19261. - status = lp->rx_ring[lp->rx_idx].u.base >> 24;
  19262. - if (status & 0x80)
  19263. - return (0);
  19264. -#ifdef DEBUG
  19265. - printf("LANCE packet received rx_ring.u.base %X mcnt %hX csr0 %hX\n",
  19266. - lp->rx_ring[lp->rx_idx].u.base, lp->rx_ring[lp->rx_idx].msg_length,
  19267. - inw(ioaddr+LANCE_DATA));
  19268. -#endif
  19269. - if (status == 0x3)
  19270. - memcpy(nic->packet, lp->rbuf[lp->rx_idx], nic->packetlen = lp->rx_ring[lp->rx_idx].msg_length);
  19271. - /* Andrew Boyd of QNX reports that some revs of the 79C765
  19272. - clear the buffer length */
  19273. - lp->rx_ring[lp->rx_idx].buf_length = -ETH_FRAME_LEN-4;
  19274. - lp->rx_ring[lp->rx_idx].u.addr[3] |= 0x80; /* prime for next receive */
  19275. -
  19276. - /* I'm not sure if the following is still ok with multiple Rx buffers, but it works */
  19277. - outw(0x0, ioaddr+LANCE_ADDR);
  19278. - (void)inw(ioaddr+LANCE_ADDR);
  19279. - outw(0x500, ioaddr+LANCE_DATA); /* clear receive + InitDone */
  19280. -
  19281. - /* Switch to the next Rx ring buffer */
  19282. - lp->rx_idx = (lp->rx_idx + 1) & RX_RING_MOD_MASK;
  19283. -
  19284. - return (status == 0x3);
  19285. -}
  19286. -
  19287. -/**************************************************************************
  19288. -TRANSMIT - Transmit a frame
  19289. -***************************************************************************/
  19290. -static void lance_transmit(
  19291. - struct nic *nic,
  19292. - const char *d, /* Destination */
  19293. - unsigned int t, /* Type */
  19294. - unsigned int s, /* size */
  19295. - const char *p) /* Packet */
  19296. -{
  19297. - unsigned long time;
  19298. -
  19299. - /* copy the packet to ring buffer */
  19300. - memcpy(lp->tbuf, d, ETH_ALEN); /* dst */
  19301. - memcpy(&lp->tbuf[ETH_ALEN], nic->node_addr, ETH_ALEN); /* src */
  19302. - lp->tbuf[ETH_ALEN+ETH_ALEN] = t >> 8; /* type */
  19303. - lp->tbuf[ETH_ALEN+ETH_ALEN+1] = t; /* type */
  19304. - memcpy(&lp->tbuf[ETH_HLEN], p, s);
  19305. - s += ETH_HLEN;
  19306. - if (chip_table[chip_version].flags & LANCE_MUST_PAD)
  19307. - while (s < ETH_ZLEN) /* pad to min length */
  19308. - lp->tbuf[s++] = 0;
  19309. - lp->tx_ring.buf_length = -s;
  19310. - lp->tx_ring.misc = 0x0;
  19311. - /* OWN, STP, ENP */
  19312. - lp->tx_ring.u.base = virt_to_bus(lp->tbuf) & 0xffffff;
  19313. - /* we set the top byte as the very last thing */
  19314. - lp->tx_ring.u.addr[3] = 0x83;
  19315. - /* Trigger an immediate send poll */
  19316. - outw(0x0, ioaddr+LANCE_ADDR);
  19317. - (void)inw(ioaddr+LANCE_ADDR); /* as in the datasheets... */
  19318. - /* Klaus Espenlaub: the value below was 0x48, but that enabled the
  19319. - * interrupt line, causing a hang if for some reasone the interrupt
  19320. - * controller had the LANCE interrupt enabled. I have no idea why
  19321. - * nobody ran into this before... */
  19322. - outw(0x08, ioaddr+LANCE_DATA);
  19323. - /* wait for transmit complete */
  19324. - time = currticks() + TICKS_PER_SEC; /* wait one second */
  19325. - while (currticks() < time && (lp->tx_ring.u.base & 0x80000000) != 0)
  19326. - ;
  19327. - if ((lp->tx_ring.u.base & 0x80000000) != 0)
  19328. - printf("LANCE timed out on transmit\n");
  19329. - (void)inw(ioaddr+LANCE_ADDR);
  19330. - outw(0x200, ioaddr+LANCE_DATA); /* clear transmit + InitDone */
  19331. -#ifdef DEBUG
  19332. - printf("tx_ring.u.base %X tx_ring.buf_length %hX tx_ring.misc %hX csr0 %hX\n",
  19333. - lp->tx_ring.u.base, lp->tx_ring.buf_length, lp->tx_ring.misc,
  19334. - inw(ioaddr+LANCE_DATA));
  19335. -#endif
  19336. -}
  19337. -
  19338. -static void lance_disable(struct nic *nic)
  19339. -{
  19340. - (void)inw(ioaddr+LANCE_RESET);
  19341. - if (chip_table[lance_version].flags & LANCE_MUST_UNRESET)
  19342. - outw(0, ioaddr+LANCE_RESET);
  19343. -
  19344. - outw(0, ioaddr+LANCE_ADDR);
  19345. - outw(0x0004, ioaddr+LANCE_DATA); /* stop the LANCE */
  19346. -
  19347. -#ifndef INCLUDE_LANCE
  19348. - disable_dma(dma);
  19349. -#endif
  19350. -}
  19351. -
  19352. -#ifdef INCLUDE_LANCE
  19353. -static int lance_probe1(struct nic *nic, struct pci_device *pci)
  19354. -#else
  19355. -static int lance_probe1(struct nic *nic)
  19356. -#endif
  19357. -{
  19358. - int reset_val ;
  19359. - unsigned int i;
  19360. - Address l;
  19361. - short dma_channels;
  19362. -#ifndef INCLUDE_LANCE
  19363. - static const char dmas[] = { 5, 6, 7, 3 };
  19364. -#endif
  19365. -
  19366. - reset_val = inw(ioaddr+LANCE_RESET);
  19367. - outw(reset_val, ioaddr+LANCE_RESET);
  19368. -#if 1 /* Klaus Espenlaub -- was #ifdef INCLUDE_NE2100*/
  19369. - outw(0x0, ioaddr+LANCE_ADDR); /* Switch to window 0 */
  19370. - if (inw(ioaddr+LANCE_DATA) != 0x4)
  19371. - return (-1);
  19372. -#endif
  19373. - outw(88, ioaddr+LANCE_ADDR); /* Get the version of the chip */
  19374. - if (inw(ioaddr+LANCE_ADDR) != 88)
  19375. - lance_version = 0;
  19376. - else
  19377. - {
  19378. - chip_version = inw(ioaddr+LANCE_DATA);
  19379. - outw(89, ioaddr+LANCE_ADDR);
  19380. - chip_version |= inw(ioaddr+LANCE_DATA) << 16;
  19381. - if ((chip_version & 0xfff) != 0x3)
  19382. - return (-1);
  19383. - chip_version = (chip_version >> 12) & 0xffff;
  19384. - for (lance_version = 1; chip_table[lance_version].id_number != 0; ++lance_version)
  19385. - if (chip_table[lance_version].id_number == chip_version)
  19386. - break;
  19387. - }
  19388. - /* make sure data structure is 8-byte aligned */
  19389. - l = ((Address)lance + 7) & ~7;
  19390. - lp = (struct lance_interface *)l;
  19391. - lp->init_block.mode = 0x3; /* disable Rx and Tx */
  19392. - lp->init_block.filter[0] = lp->init_block.filter[1] = 0x0;
  19393. - /* using multiple Rx buffer and a single Tx buffer */
  19394. - lp->init_block.rx_ring = (virt_to_bus(&lp->rx_ring) & 0xffffff) | RX_RING_LEN_BITS;
  19395. - lp->init_block.tx_ring = virt_to_bus(&lp->tx_ring) & 0xffffff;
  19396. - l = virt_to_bus(&lp->init_block);
  19397. - outw(0x1, ioaddr+LANCE_ADDR);
  19398. - (void)inw(ioaddr+LANCE_ADDR);
  19399. - outw((unsigned short)l, ioaddr+LANCE_DATA);
  19400. - outw(0x2, ioaddr+LANCE_ADDR);
  19401. - (void)inw(ioaddr+LANCE_ADDR);
  19402. - outw((unsigned short)(l >> 16), ioaddr+LANCE_DATA);
  19403. - outw(0x4, ioaddr+LANCE_ADDR);
  19404. - (void)inw(ioaddr+LANCE_ADDR);
  19405. - outw(0x915, ioaddr+LANCE_DATA);
  19406. - outw(0x0, ioaddr+LANCE_ADDR);
  19407. - (void)inw(ioaddr+LANCE_ADDR);
  19408. - /* Get station address */
  19409. - for (i = 0; i < ETH_ALEN; ++i) {
  19410. - nic->node_addr[i] = inb(ioaddr+LANCE_ETH_ADDR+i);
  19411. - }
  19412. -#ifndef INCLUDE_LANCE
  19413. - /* now probe for DMA channel */
  19414. - dma_channels = ((inb(DMA1_STAT_REG) >> 4) & 0xf) |
  19415. - (inb(DMA2_STAT_REG) & 0xf0);
  19416. - /* need to fix when PCI provides DMA info */
  19417. - for (i = 0; i < (sizeof(dmas)/sizeof(dmas[0])); ++i)
  19418. - {
  19419. - int j;
  19420. -
  19421. - dma = dmas[i];
  19422. - /* Don't enable a permanently busy DMA channel,
  19423. - or the machine will hang */
  19424. - if (dma_channels & (1 << dma))
  19425. - continue;
  19426. - outw(0x7f04, ioaddr+LANCE_DATA); /* clear memory error bits */
  19427. - set_dma_mode(dma, DMA_MODE_CASCADE);
  19428. - enable_dma(dma);
  19429. - outw(0x1, ioaddr+LANCE_DATA); /* init */
  19430. - for (j = 100; j > 0; --j)
  19431. - if (inw(ioaddr+LANCE_DATA) & 0x900)
  19432. - break;
  19433. - if (inw(ioaddr+LANCE_DATA) & 0x100)
  19434. - break;
  19435. - else
  19436. - disable_dma(dma);
  19437. - }
  19438. - if (i >= (sizeof(dmas)/sizeof(dmas[0])))
  19439. - dma = 0;
  19440. - printf("\n%s base %#X, DMA %d, addr %!\n",
  19441. - chip_table[lance_version].name, ioaddr, dma, nic->node_addr);
  19442. -#else
  19443. - printf(" %s base %#hX, addr %!\n", chip_table[lance_version].name, ioaddr, nic->node_addr);
  19444. -#endif
  19445. - if (chip_table[chip_version].flags & LANCE_ENABLE_AUTOSELECT) {
  19446. - /* Turn on auto-select of media (10baseT or BNC) so that the
  19447. - * user watch the LEDs. */
  19448. - outw(0x0002, ioaddr+LANCE_ADDR);
  19449. - /* Don't touch 10base2 power bit. */
  19450. - outw(inw(ioaddr+LANCE_BUS_IF) | 0x0002, ioaddr+LANCE_BUS_IF);
  19451. - }
  19452. - return (lance_version);
  19453. -}
  19454. -
  19455. -/**************************************************************************
  19456. -PROBE - Look for an adapter, this routine's visible to the outside
  19457. -***************************************************************************/
  19458. -
  19459. -#ifdef INCLUDE_LANCE
  19460. -struct nic *lancepci_probe(struct nic *nic, unsigned short *probe_addrs, struct pci_device *pci)
  19461. -#endif
  19462. -#ifdef INCLUDE_NE2100
  19463. -struct nic *ne2100_probe(struct nic *nic, unsigned short *probe_addrs)
  19464. -#endif
  19465. -#ifdef INCLUDE_NI6510
  19466. -struct nic *ni6510_probe(struct nic *nic, unsigned short *probe_addrs)
  19467. -#endif
  19468. -{
  19469. - unsigned short *p;
  19470. -#ifndef INCLUDE_LANCE
  19471. - static unsigned short io_addrs[] = { 0x300, 0x320, 0x340, 0x360, 0 };
  19472. -#endif
  19473. -
  19474. - /* if probe_addrs is 0, then routine can use a hardwired default */
  19475. - if (probe_addrs == 0) {
  19476. -#ifdef INCLUDE_LANCE
  19477. - return 0;
  19478. -#else
  19479. - probe_addrs = io_addrs;
  19480. -#endif
  19481. - }
  19482. - for (p = probe_addrs; (ioaddr = *p) != 0; ++p)
  19483. - {
  19484. - char offset15, offset14 = inb(ioaddr + 14);
  19485. - unsigned short pci_cmd;
  19486. -
  19487. -#ifdef INCLUDE_NE2100
  19488. - if ((offset14 == 0x52 || offset14 == 0x57) &&
  19489. - ((offset15 = inb(ioaddr + 15)) == 0x57 || offset15 == 0x44))
  19490. - if (lance_probe1(nic) >= 0)
  19491. - break;
  19492. -#endif
  19493. -#ifdef INCLUDE_NI6510
  19494. - if ((offset14 == 0x00 || offset14 == 0x52) &&
  19495. - ((offset15 = inb(ioaddr + 15)) == 0x55 || offset15 == 0x44))
  19496. - if (lance_probe1(nic) >= 0)
  19497. - break;
  19498. -#endif
  19499. -#ifdef INCLUDE_LANCE
  19500. - adjust_pci_device(pci);
  19501. - if (lance_probe1(nic, pci) >= 0)
  19502. - break;
  19503. -#endif
  19504. - }
  19505. - /* if board found */
  19506. - if (ioaddr != 0)
  19507. - {
  19508. - /* point to NIC specific routines */
  19509. - lance_reset(nic);
  19510. - nic->reset = lance_reset;
  19511. - nic->poll = lance_poll;
  19512. - nic->transmit = lance_transmit;
  19513. - nic->disable = lance_disable;
  19514. - return nic;
  19515. - }
  19516. -
  19517. - /* no board found */
  19518. - return 0;
  19519. -}
  19520. Index: b/netboot/latch.h
  19521. ===================================================================
  19522. --- /dev/null
  19523. +++ b/netboot/latch.h
  19524. @@ -0,0 +1,10 @@
  19525. +#ifndef LATCH_H
  19526. +#define LATCH_H
  19527. +
  19528. +#define TICKS_PER_SEC 18
  19529. +
  19530. +/* For different calibrators of the TSC move the declaration of
  19531. + * sleep_latch and the definitions of it's length here...
  19532. + */
  19533. +
  19534. +#endif /* LATCH_H */
  19535. Index: b/netboot/linux-asm-io.h
  19536. ===================================================================
  19537. --- a/netboot/linux-asm-io.h
  19538. +++ /dev/null
  19539. @@ -1,187 +0,0 @@
  19540. -#ifndef _ASM_IO_H
  19541. -#define _ASM_IO_H
  19542. -
  19543. -/*
  19544. - * This file contains the definitions for the x86 IO instructions
  19545. - * inb/inw/inl/outb/outw/outl and the "string versions" of the same
  19546. - * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
  19547. - * versions of the single-IO instructions (inb_p/inw_p/..).
  19548. - *
  19549. - * This file is not meant to be obfuscating: it's just complicated
  19550. - * to (a) handle it all in a way that makes gcc able to optimize it
  19551. - * as well as possible and (b) trying to avoid writing the same thing
  19552. - * over and over again with slight variations and possibly making a
  19553. - * mistake somewhere.
  19554. - */
  19555. -
  19556. -/*
  19557. - * Thanks to James van Artsdalen for a better timing-fix than
  19558. - * the two short jumps: using outb's to a nonexistent port seems
  19559. - * to guarantee better timings even on fast machines.
  19560. - *
  19561. - * On the other hand, I'd like to be sure of a non-existent port:
  19562. - * I feel a bit unsafe about using 0x80 (should be safe, though)
  19563. - *
  19564. - * Linus
  19565. - */
  19566. -
  19567. -#ifdef SLOW_IO_BY_JUMPING
  19568. -#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
  19569. -#else
  19570. -#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
  19571. -#endif
  19572. -
  19573. -#ifdef REALLY_SLOW_IO
  19574. -#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
  19575. -#else
  19576. -#define SLOW_DOWN_IO __SLOW_DOWN_IO
  19577. -#endif
  19578. -
  19579. -/*
  19580. - * readX/writeX() are used to access memory mapped devices. On some
  19581. - * architectures the memory mapped IO stuff needs to be accessed
  19582. - * differently. On the x86 architecture, we just read/write the
  19583. - * memory location directly.
  19584. - */
  19585. -#define readb(addr) (*(volatile unsigned char *) (addr))
  19586. -#define readw(addr) (*(volatile unsigned short *) (addr))
  19587. -#define readl(addr) (*(volatile unsigned int *) (addr))
  19588. -
  19589. -#define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b))
  19590. -#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b))
  19591. -#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b))
  19592. -
  19593. -#define memset_io(a,b,c) memset((void *)(a),(b),(c))
  19594. -#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
  19595. -#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
  19596. -
  19597. -/*
  19598. - * Again, i386 does not require mem IO specific function.
  19599. - */
  19600. -
  19601. -#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(b),(c),(d))
  19602. -
  19603. -/*
  19604. - * Talk about misusing macros..
  19605. - */
  19606. -
  19607. -#define __OUT1(s,x) \
  19608. -extern void __out##s(unsigned x value, unsigned short port); \
  19609. -extern inline void __out##s(unsigned x value, unsigned short port) {
  19610. -
  19611. -#define __OUT2(s,s1,s2) \
  19612. -__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
  19613. -
  19614. -#define __OUT(s,s1,x) \
  19615. -__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
  19616. -__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \
  19617. -__OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
  19618. -__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; }
  19619. -
  19620. -#define __IN1(s,x) \
  19621. -extern unsigned x __in##s(unsigned short port); \
  19622. -extern inline unsigned x __in##s(unsigned short port) { unsigned x _v;
  19623. -
  19624. -#define __IN2(s,s1,s2) \
  19625. -__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
  19626. -
  19627. -#define __IN(s,s1,x,i...) \
  19628. -__IN1(s,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
  19629. -__IN1(s##c,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); return _v; } \
  19630. -__IN1(s##_p,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
  19631. -__IN1(s##c_p,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; }
  19632. -
  19633. -#define __INS(s) \
  19634. -extern void ins##s(unsigned short port, void * addr, unsigned long count); \
  19635. -extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
  19636. -{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
  19637. -: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
  19638. -
  19639. -#define __OUTS(s) \
  19640. -extern void outs##s(unsigned short port, const void * addr, unsigned long count); \
  19641. -extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
  19642. -{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
  19643. -: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
  19644. -
  19645. -__IN(b,"", char)
  19646. -__IN(w,"",short)
  19647. -__IN(l,"", long)
  19648. -
  19649. -__OUT(b,"b",char)
  19650. -__OUT(w,"w",short)
  19651. -__OUT(l,,int)
  19652. -
  19653. -__INS(b)
  19654. -__INS(w)
  19655. -__INS(l)
  19656. -
  19657. -__OUTS(b)
  19658. -__OUTS(w)
  19659. -__OUTS(l)
  19660. -
  19661. -/*
  19662. - * Note that due to the way __builtin_constant_p() works, you
  19663. - * - can't use it inside a inline function (it will never be true)
  19664. - * - you don't have to worry about side effects within the __builtin..
  19665. - */
  19666. -#define outb(val,port) \
  19667. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19668. - __outbc((val),(port)) : \
  19669. - __outb((val),(port)))
  19670. -
  19671. -#define inb(port) \
  19672. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19673. - __inbc(port) : \
  19674. - __inb(port))
  19675. -
  19676. -#define outb_p(val,port) \
  19677. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19678. - __outbc_p((val),(port)) : \
  19679. - __outb_p((val),(port)))
  19680. -
  19681. -#define inb_p(port) \
  19682. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19683. - __inbc_p(port) : \
  19684. - __inb_p(port))
  19685. -
  19686. -#define outw(val,port) \
  19687. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19688. - __outwc((val),(port)) : \
  19689. - __outw((val),(port)))
  19690. -
  19691. -#define inw(port) \
  19692. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19693. - __inwc(port) : \
  19694. - __inw(port))
  19695. -
  19696. -#define outw_p(val,port) \
  19697. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19698. - __outwc_p((val),(port)) : \
  19699. - __outw_p((val),(port)))
  19700. -
  19701. -#define inw_p(port) \
  19702. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19703. - __inwc_p(port) : \
  19704. - __inw_p(port))
  19705. -
  19706. -#define outl(val,port) \
  19707. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19708. - __outlc((val),(port)) : \
  19709. - __outl((val),(port)))
  19710. -
  19711. -#define inl(port) \
  19712. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19713. - __inlc(port) : \
  19714. - __inl(port))
  19715. -
  19716. -#define outl_p(val,port) \
  19717. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19718. - __outlc_p((val),(port)) : \
  19719. - __outl_p((val),(port)))
  19720. -
  19721. -#define inl_p(port) \
  19722. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19723. - __inlc_p(port) : \
  19724. - __inl_p(port))
  19725. -
  19726. -#endif
  19727. Index: b/netboot/linux-asm-string.h
  19728. ===================================================================
  19729. --- a/netboot/linux-asm-string.h
  19730. +++ /dev/null
  19731. @@ -1,291 +0,0 @@
  19732. -/*
  19733. - * Taken from Linux /usr/include/asm/string.h
  19734. - * All except memcpy, memmove, memset and memcmp removed.
  19735. - */
  19736. -
  19737. -#ifndef _I386_STRING_H_
  19738. -#define _I386_STRING_H_
  19739. -
  19740. -/*
  19741. - * This string-include defines all string functions as inline
  19742. - * functions. Use gcc. It also assumes ds=es=data space, this should be
  19743. - * normal. Most of the string-functions are rather heavily hand-optimized,
  19744. - * see especially strtok,strstr,str[c]spn. They should work, but are not
  19745. - * very easy to understand. Everything is done entirely within the register
  19746. - * set, making the functions fast and clean. String instructions have been
  19747. - * used through-out, making for "slightly" unclear code :-)
  19748. - *
  19749. - * NO Copyright (C) 1991, 1992 Linus Torvalds,
  19750. - * consider these trivial functions to be PD.
  19751. - */
  19752. -
  19753. -typedef int size_t;
  19754. -
  19755. -extern void *__memcpy(void * to, const void * from, size_t n);
  19756. -extern void *__constant_memcpy(void * to, const void * from, size_t n);
  19757. -extern void *memmove(void * dest,const void * src, size_t n);
  19758. -extern void *__memset_generic(void * s, char c,size_t count);
  19759. -extern void *__constant_c_memset(void * s, unsigned long c, size_t count);
  19760. -extern void *__constant_c_and_count_memset(void * s, unsigned long pattern, size_t count);
  19761. -
  19762. -
  19763. -extern inline void * __memcpy(void * to, const void * from, size_t n)
  19764. -{
  19765. -int d0, d1, d2;
  19766. -__asm__ __volatile__(
  19767. - "cld\n\t"
  19768. - "rep ; movsl\n\t"
  19769. - "testb $2,%b4\n\t"
  19770. - "je 1f\n\t"
  19771. - "movsw\n"
  19772. - "1:\ttestb $1,%b4\n\t"
  19773. - "je 2f\n\t"
  19774. - "movsb\n"
  19775. - "2:"
  19776. - : "=&c" (d0), "=&D" (d1), "=&S" (d2)
  19777. - :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
  19778. - : "memory");
  19779. -return (to);
  19780. -}
  19781. -
  19782. -/*
  19783. - * This looks horribly ugly, but the compiler can optimize it totally,
  19784. - * as the count is constant.
  19785. - */
  19786. -extern inline void * __constant_memcpy(void * to, const void * from, size_t n)
  19787. -{
  19788. - switch (n) {
  19789. - case 0:
  19790. - return to;
  19791. - case 1:
  19792. - *(unsigned char *)to = *(const unsigned char *)from;
  19793. - return to;
  19794. - case 2:
  19795. - *(unsigned short *)to = *(const unsigned short *)from;
  19796. - return to;
  19797. - case 3:
  19798. - *(unsigned short *)to = *(const unsigned short *)from;
  19799. - *(2+(unsigned char *)to) = *(2+(const unsigned char *)from);
  19800. - return to;
  19801. - case 4:
  19802. - *(unsigned long *)to = *(const unsigned long *)from;
  19803. - return to;
  19804. - case 6: /* for Ethernet addresses */
  19805. - *(unsigned long *)to = *(const unsigned long *)from;
  19806. - *(2+(unsigned short *)to) = *(2+(const unsigned short *)from);
  19807. - return to;
  19808. - case 8:
  19809. - *(unsigned long *)to = *(const unsigned long *)from;
  19810. - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
  19811. - return to;
  19812. - case 12:
  19813. - *(unsigned long *)to = *(const unsigned long *)from;
  19814. - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
  19815. - *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
  19816. - return to;
  19817. - case 16:
  19818. - *(unsigned long *)to = *(const unsigned long *)from;
  19819. - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
  19820. - *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
  19821. - *(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
  19822. - return to;
  19823. - case 20:
  19824. - *(unsigned long *)to = *(const unsigned long *)from;
  19825. - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
  19826. - *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
  19827. - *(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
  19828. - *(4+(unsigned long *)to) = *(4+(const unsigned long *)from);
  19829. - return to;
  19830. - }
  19831. -#define COMMON(x) \
  19832. -__asm__ __volatile__( \
  19833. - "cld\n\t" \
  19834. - "rep ; movsl" \
  19835. - x \
  19836. - : "=&c" (d0), "=&D" (d1), "=&S" (d2) \
  19837. - : "0" (n/4),"1" ((long) to),"2" ((long) from) \
  19838. - : "memory");
  19839. -{
  19840. - int d0, d1, d2;
  19841. - switch (n % 4) {
  19842. - case 0: COMMON(""); return to;
  19843. - case 1: COMMON("\n\tmovsb"); return to;
  19844. - case 2: COMMON("\n\tmovsw"); return to;
  19845. - default: COMMON("\n\tmovsw\n\tmovsb"); return to;
  19846. - }
  19847. -}
  19848. -
  19849. -#undef COMMON
  19850. -}
  19851. -
  19852. -#define __HAVE_ARCH_MEMCPY
  19853. -#define memcpy(t, f, n) \
  19854. -(__builtin_constant_p(n) ? \
  19855. - __constant_memcpy((t),(f),(n)) : \
  19856. - __memcpy((t),(f),(n)))
  19857. -
  19858. -#define __HAVE_ARCH_MEMMOVE
  19859. -extern inline void * memmove(void * dest,const void * src, size_t n)
  19860. -{
  19861. -int d0, d1, d2;
  19862. -if (dest<src)
  19863. -__asm__ __volatile__(
  19864. - "cld\n\t"
  19865. - "rep\n\t"
  19866. - "movsb"
  19867. - : "=&c" (d0), "=&S" (d1), "=&D" (d2)
  19868. - :"0" (n),"1" (src),"2" (dest)
  19869. - : "memory");
  19870. -else
  19871. -__asm__ __volatile__(
  19872. - "std\n\t"
  19873. - "rep\n\t"
  19874. - "movsb\n\t"
  19875. - "cld"
  19876. - : "=&c" (d0), "=&S" (d1), "=&D" (d2)
  19877. - :"0" (n),
  19878. - "1" (n-1+(const char *)src),
  19879. - "2" (n-1+(char *)dest)
  19880. - :"memory");
  19881. -return dest;
  19882. -}
  19883. -
  19884. -#define memcmp __builtin_memcmp
  19885. -
  19886. -extern inline void * __memset_generic(void * s, char c,size_t count)
  19887. -{
  19888. -int d0, d1;
  19889. -__asm__ __volatile__(
  19890. - "cld\n\t"
  19891. - "rep\n\t"
  19892. - "stosb"
  19893. - : "=&c" (d0), "=&D" (d1)
  19894. - :"a" (c),"1" (s),"0" (count)
  19895. - :"memory");
  19896. -return s;
  19897. -}
  19898. -
  19899. -/* we might want to write optimized versions of these later */
  19900. -#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count))
  19901. -
  19902. -/*
  19903. - * memset(x,0,y) is a reasonably common thing to do, so we want to fill
  19904. - * things 32 bits at a time even when we don't know the size of the
  19905. - * area at compile-time..
  19906. - */
  19907. -extern inline void * __constant_c_memset(void * s, unsigned long c, size_t count)
  19908. -{
  19909. -int d0, d1;
  19910. -__asm__ __volatile__(
  19911. - "cld\n\t"
  19912. - "rep ; stosl\n\t"
  19913. - "testb $2,%b3\n\t"
  19914. - "je 1f\n\t"
  19915. - "stosw\n"
  19916. - "1:\ttestb $1,%b3\n\t"
  19917. - "je 2f\n\t"
  19918. - "stosb\n"
  19919. - "2:"
  19920. - : "=&c" (d0), "=&D" (d1)
  19921. - :"a" (c), "q" (count), "0" (count/4), "1" ((long) s)
  19922. - :"memory");
  19923. -return (s);
  19924. -}
  19925. -
  19926. -/*
  19927. - * This looks horribly ugly, but the compiler can optimize it totally,
  19928. - * as we by now know that both pattern and count is constant..
  19929. - */
  19930. -extern inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count)
  19931. -{
  19932. - switch (count) {
  19933. - case 0:
  19934. - return s;
  19935. - case 1:
  19936. - *(unsigned char *)s = pattern;
  19937. - return s;
  19938. - case 2:
  19939. - *(unsigned short *)s = pattern;
  19940. - return s;
  19941. - case 3:
  19942. - *(unsigned short *)s = pattern;
  19943. - *(2+(unsigned char *)s) = pattern;
  19944. - return s;
  19945. - case 4:
  19946. - *(unsigned long *)s = pattern;
  19947. - return s;
  19948. - }
  19949. -#define COMMON(x) \
  19950. -__asm__ __volatile__("cld\n\t" \
  19951. - "rep ; stosl" \
  19952. - x \
  19953. - : "=&c" (d0), "=&D" (d1) \
  19954. - : "a" (pattern),"0" (count/4),"1" ((long) s) \
  19955. - : "memory")
  19956. -{
  19957. - int d0, d1;
  19958. - switch (count % 4) {
  19959. - case 0: COMMON(""); return s;
  19960. - case 1: COMMON("\n\tstosb"); return s;
  19961. - case 2: COMMON("\n\tstosw"); return s;
  19962. - default: COMMON("\n\tstosw\n\tstosb"); return s;
  19963. - }
  19964. -}
  19965. -
  19966. -#undef COMMON
  19967. -}
  19968. -
  19969. -#define __constant_c_x_memset(s, c, count) \
  19970. -(__builtin_constant_p(count) ? \
  19971. - __constant_c_and_count_memset((s),(c),(count)) : \
  19972. - __constant_c_memset((s),(c),(count)))
  19973. -
  19974. -#define __memset(s, c, count) \
  19975. -(__builtin_constant_p(count) ? \
  19976. - __constant_count_memset((s),(c),(count)) : \
  19977. - __memset_generic((s),(c),(count)))
  19978. -
  19979. -#define __HAVE_ARCH_MEMSET
  19980. -#define memset(s, c, count) \
  19981. -(__builtin_constant_p(c) ? \
  19982. - __constant_c_x_memset((s),(c),(count)) : \
  19983. - __memset((s),(c),(count)))
  19984. -
  19985. -#define __HAVE_ARCH_STRNCMP
  19986. -static inline int strncmp(const char * cs,const char * ct,size_t count)
  19987. -{
  19988. -register int __res;
  19989. -int d0, d1, d2;
  19990. -__asm__ __volatile__(
  19991. - "1:\tdecl %3\n\t"
  19992. - "js 2f\n\t"
  19993. - "lodsb\n\t"
  19994. - "scasb\n\t"
  19995. - "jne 3f\n\t"
  19996. - "testb %%al,%%al\n\t"
  19997. - "jne 1b\n"
  19998. - "2:\txorl %%eax,%%eax\n\t"
  19999. - "jmp 4f\n"
  20000. - "3:\tsbbl %%eax,%%eax\n\t"
  20001. - "orb $1,%%al\n"
  20002. - "4:"
  20003. - :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
  20004. - :"1" (cs),"2" (ct),"3" (count));
  20005. -return __res;
  20006. -}
  20007. -
  20008. -#define __HAVE_ARCH_STRLEN
  20009. -static inline size_t strlen(const char * s)
  20010. -{
  20011. -int d0;
  20012. -register int __res;
  20013. -__asm__ __volatile__(
  20014. - "repne\n\t"
  20015. - "scasb\n\t"
  20016. - "notl %0\n\t"
  20017. - "decl %0"
  20018. - :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff));
  20019. -return __res;
  20020. -}
  20021. -
  20022. -#endif
  20023. Index: b/netboot/little_bswap.h
  20024. ===================================================================
  20025. --- /dev/null
  20026. +++ b/netboot/little_bswap.h
  20027. @@ -0,0 +1,17 @@
  20028. +#ifndef ETHERBOOT_LITTLE_BSWAP_H
  20029. +#define ETHERBOOT_LITTLE_BSWAP_H
  20030. +
  20031. +#define ntohl(x) __bswap_32(x)
  20032. +#define htonl(x) __bswap_32(x)
  20033. +#define ntohs(x) __bswap_16(x)
  20034. +#define htons(x) __bswap_16(x)
  20035. +#define cpu_to_le32(x) (x)
  20036. +#define cpu_to_le16(x) (x)
  20037. +#define cpu_to_be32(x) __bswap_32(x)
  20038. +#define cpu_to_be16(x) __bswap_16(x)
  20039. +#define le32_to_cpu(x) (x)
  20040. +#define le16_to_cpu(x) (x)
  20041. +#define be32_to_cpu(x) __bswap_32(x)
  20042. +#define be16_to_cpu(x) __bswap_16(x)
  20043. +
  20044. +#endif /* ETHERBOOT_LITTLE_BSWAP_H */
  20045. Index: b/netboot/mii.h
  20046. ===================================================================
  20047. --- /dev/null
  20048. +++ b/netboot/mii.h
  20049. @@ -0,0 +1,105 @@
  20050. +/*
  20051. + * linux/mii.h: definitions for MII-compatible transceivers
  20052. + * Originally drivers/net/sunhme.h.
  20053. + *
  20054. + * Copyright (C) 1996, 1999, 2001 David S. Miller (davem@redhat.com)
  20055. + *
  20056. + * Copied Form Linux 2.4.25 an unneeded items removed by:
  20057. + * Timothy Legge (timlegge at etherboot dot org)
  20058. + *
  20059. + * 03/26/2004
  20060. + */
  20061. +
  20062. +/* Generic MII registers. */
  20063. +
  20064. +#define MII_BMCR 0x00 /* Basic mode control register */
  20065. +#define MII_BMSR 0x01 /* Basic mode status register */
  20066. +#define MII_PHYSID1 0x02 /* PHYS ID 1 */
  20067. +#define MII_PHYSID2 0x03 /* PHYS ID 2 */
  20068. +#define MII_ADVERTISE 0x04 /* Advertisement control reg */
  20069. +#define MII_LPA 0x05 /* Link partner ability reg */
  20070. +#define MII_EXPANSION 0x06 /* Expansion register */
  20071. +#define MII_DCOUNTER 0x12 /* Disconnect counter */
  20072. +#define MII_FCSCOUNTER 0x13 /* False carrier counter */
  20073. +#define MII_NWAYTEST 0x14 /* N-way auto-neg test reg */
  20074. +#define MII_RERRCOUNTER 0x15 /* Receive error counter */
  20075. +#define MII_SREVISION 0x16 /* Silicon revision */
  20076. +#define MII_RESV1 0x17 /* Reserved... */
  20077. +#define MII_LBRERROR 0x18 /* Lpback, rx, bypass error */
  20078. +#define MII_PHYADDR 0x19 /* PHY address */
  20079. +#define MII_RESV2 0x1a /* Reserved... */
  20080. +#define MII_TPISTATUS 0x1b /* TPI status for 10mbps */
  20081. +#define MII_NCONFIG 0x1c /* Network interface config */
  20082. +
  20083. +/* Basic mode control register. */
  20084. +#define BMCR_RESV 0x007f /* Unused... */
  20085. +#define BMCR_CTST 0x0080 /* Collision test */
  20086. +#define BMCR_FULLDPLX 0x0100 /* Full duplex */
  20087. +#define BMCR_ANRESTART 0x0200 /* Auto negotiation restart */
  20088. +#define BMCR_ISOLATE 0x0400 /* Disconnect DP83840 from MII */
  20089. +#define BMCR_PDOWN 0x0800 /* Powerdown the DP83840 */
  20090. +#define BMCR_ANENABLE 0x1000 /* Enable auto negotiation */
  20091. +#define BMCR_SPEED100 0x2000 /* Select 100Mbps */
  20092. +#define BMCR_LOOPBACK 0x4000 /* TXD loopback bits */
  20093. +#define BMCR_RESET 0x8000 /* Reset the DP83840 */
  20094. +
  20095. +/* Basic mode status register. */
  20096. +#define BMSR_ERCAP 0x0001 /* Ext-reg capability */
  20097. +#define BMSR_JCD 0x0002 /* Jabber detected */
  20098. +#define BMSR_LSTATUS 0x0004 /* Link status */
  20099. +#define BMSR_ANEGCAPABLE 0x0008 /* Able to do auto-negotiation */
  20100. +#define BMSR_RFAULT 0x0010 /* Remote fault detected */
  20101. +#define BMSR_ANEGCOMPLETE 0x0020 /* Auto-negotiation complete */
  20102. +#define BMSR_RESV 0x07c0 /* Unused... */
  20103. +#define BMSR_10HALF 0x0800 /* Can do 10mbps, half-duplex */
  20104. +#define BMSR_10FULL 0x1000 /* Can do 10mbps, full-duplex */
  20105. +#define BMSR_100HALF 0x2000 /* Can do 100mbps, half-duplex */
  20106. +#define BMSR_100FULL 0x4000 /* Can do 100mbps, full-duplex */
  20107. +#define BMSR_100BASE4 0x8000 /* Can do 100mbps, 4k packets */
  20108. +
  20109. +/* Advertisement control register. */
  20110. +#define ADVERTISE_SLCT 0x001f /* Selector bits */
  20111. +#define ADVERTISE_CSMA 0x0001 /* Only selector supported */
  20112. +#define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */
  20113. +#define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */
  20114. +#define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */
  20115. +#define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */
  20116. +#define ADVERTISE_100BASE4 0x0200 /* Try for 100mbps 4k packets */
  20117. +#define ADVERTISE_RESV 0x1c00 /* Unused... */
  20118. +#define ADVERTISE_RFAULT 0x2000 /* Say we can detect faults */
  20119. +#define ADVERTISE_LPACK 0x4000 /* Ack link partners response */
  20120. +#define ADVERTISE_NPAGE 0x8000 /* Next page bit */
  20121. +
  20122. +#define ADVERTISE_FULL (ADVERTISE_100FULL | ADVERTISE_10FULL | \
  20123. + ADVERTISE_CSMA)
  20124. +#define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \
  20125. + ADVERTISE_100HALF | ADVERTISE_100FULL)
  20126. +
  20127. +/* Link partner ability register. */
  20128. +#define LPA_SLCT 0x001f /* Same as advertise selector */
  20129. +#define LPA_10HALF 0x0020 /* Can do 10mbps half-duplex */
  20130. +#define LPA_10FULL 0x0040 /* Can do 10mbps full-duplex */
  20131. +#define LPA_100HALF 0x0080 /* Can do 100mbps half-duplex */
  20132. +#define LPA_100FULL 0x0100 /* Can do 100mbps full-duplex */
  20133. +#define LPA_100BASE4 0x0200 /* Can do 100mbps 4k packets */
  20134. +#define LPA_RESV 0x1c00 /* Unused... */
  20135. +#define LPA_RFAULT 0x2000 /* Link partner faulted */
  20136. +#define LPA_LPACK 0x4000 /* Link partner acked us */
  20137. +#define LPA_NPAGE 0x8000 /* Next page bit */
  20138. +
  20139. +#define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
  20140. +#define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
  20141. +
  20142. +/* Expansion register for auto-negotiation. */
  20143. +#define EXPANSION_NWAY 0x0001 /* Can do N-way auto-nego */
  20144. +#define EXPANSION_LCWP 0x0002 /* Got new RX page code word */
  20145. +#define EXPANSION_ENABLENPAGE 0x0004 /* This enables npage words */
  20146. +#define EXPANSION_NPCAPABLE 0x0008 /* Link partner supports npage */
  20147. +#define EXPANSION_MFAULTS 0x0010 /* Multiple faults detected */
  20148. +#define EXPANSION_RESV 0xffe0 /* Unused... */
  20149. +
  20150. +/* N-way test register. */
  20151. +#define NWAYTEST_RESV1 0x00ff /* Unused... */
  20152. +#define NWAYTEST_LOOPBACK 0x0100 /* Enable loopback for N-way */
  20153. +#define NWAYTEST_RESV2 0xfe00 /* Unused... */
  20154. +
  20155. Index: b/netboot/misc.c
  20156. ===================================================================
  20157. --- a/netboot/misc.c
  20158. +++ b/netboot/misc.c
  20159. @@ -19,37 +19,90 @@
  20160. /* Based on "src/misc.c" in etherboot-5.0.5. */
  20161. -#define GRUB 1
  20162. -#include <etherboot.h>
  20163. +#include "grub.h"
  20164. +#include "timer.h"
  20165. -void
  20166. -sleep (int secs)
  20167. +#include "nic.h"
  20168. +
  20169. +/**************************************************************************
  20170. +RANDOM - compute a random number between 0 and 2147483647L or 2147483562?
  20171. +**************************************************************************/
  20172. +int32_t random(void)
  20173. {
  20174. - unsigned long tmo = currticks () + secs;
  20175. + static int32_t seed = 0;
  20176. + int32_t q;
  20177. + if (!seed) /* Initialize linear congruential generator */
  20178. + seed = currticks() + *(int32_t *)&arptable[ARP_CLIENT].node
  20179. + + ((int16_t *)arptable[ARP_CLIENT].node)[2];
  20180. + /* simplified version of the LCG given in Bruce Schneier's
  20181. + "Applied Cryptography" */
  20182. + q = seed/53668;
  20183. + if ((seed = 40014*(seed-53668*q) - 12211*q) < 0) seed += 2147483563L;
  20184. + return seed;
  20185. +}
  20186. - while (currticks () < tmo)
  20187. - ;
  20188. +/**************************************************************************
  20189. +POLL INTERRUPTIONS
  20190. +**************************************************************************/
  20191. +void poll_interruptions(void)
  20192. +{
  20193. + if (checkkey() != -1 && ASCII_CHAR(getkey()) == K_INTR) {
  20194. + user_abort++;
  20195. + }
  20196. }
  20197. -void
  20198. -twiddle (void)
  20199. +/**************************************************************************
  20200. +SLEEP
  20201. +**************************************************************************/
  20202. +void sleep(int secs)
  20203. {
  20204. - static unsigned long lastticks = 0;
  20205. - static int count = 0;
  20206. - static const char tiddles[]="-\\|/";
  20207. - unsigned long ticks;
  20208. + unsigned long tmo;
  20209. - if (debug)
  20210. - {
  20211. - if ((ticks = currticks ()) == lastticks)
  20212. - return;
  20213. -
  20214. - lastticks = ticks;
  20215. - grub_putchar (tiddles[(count++) & 3]);
  20216. - grub_putchar ('\b');
  20217. - }
  20218. + for (tmo = currticks()+secs*TICKS_PER_SEC; currticks() < tmo; ) {
  20219. + poll_interruptions();
  20220. + }
  20221. +}
  20222. +
  20223. +/**************************************************************************
  20224. +INTERRUPTIBLE SLEEP
  20225. +**************************************************************************/
  20226. +void interruptible_sleep(int secs)
  20227. +{
  20228. + printf("<sleep>\n");
  20229. + return sleep(secs);
  20230. +}
  20231. +
  20232. +/**************************************************************************
  20233. +TWIDDLE
  20234. +**************************************************************************/
  20235. +void twiddle(void)
  20236. +{
  20237. +#ifdef BAR_PROGRESS
  20238. + static int count=0;
  20239. + static const char tiddles[]="-\\|/";
  20240. + static unsigned long lastticks = 0;
  20241. + unsigned long ticks;
  20242. +#endif
  20243. +#ifdef FREEBSD_PXEEMU
  20244. + extern char pxeemu_nbp_active;
  20245. + if(pxeemu_nbp_active != 0)
  20246. + return;
  20247. +#endif
  20248. +#ifdef BAR_PROGRESS
  20249. + /* Limit the maximum rate at which characters are printed */
  20250. + ticks = currticks();
  20251. + if ((lastticks + (TICKS_PER_SEC/18)) > ticks)
  20252. + return;
  20253. + lastticks = ticks;
  20254. +
  20255. + putchar(tiddles[(count++)&3]);
  20256. + putchar('\b');
  20257. +#else
  20258. + //putchar('.');
  20259. +#endif /* BAR_PROGRESS */
  20260. }
  20261. +
  20262. /* Because Etherboot uses its own formats for the printf family,
  20263. define separate definitions from GRUB. */
  20264. /**************************************************************************
  20265. @@ -264,3 +317,5 @@
  20266. return ret;
  20267. }
  20268. +
  20269. +
  20270. Index: b/netboot/natsemi.c
  20271. ===================================================================
  20272. --- a/netboot/natsemi.c
  20273. +++ b/netboot/natsemi.c
  20274. @@ -47,15 +47,15 @@
  20275. /* Revision History */
  20276. /*
  20277. + 13 Dec 2003 timlegge 1.1 Enabled Multicast Support
  20278. 29 May 2001 mdc 1.0
  20279. Initial Release. Tested with Netgear FA311 and FA312 boards
  20280. -*/
  20281. +*/
  20282. /* Includes */
  20283. #include "etherboot.h"
  20284. #include "nic.h"
  20285. #include "pci.h"
  20286. -#include "cards.h"
  20287. /* defines */
  20288. @@ -71,21 +71,18 @@
  20289. #define NUM_RX_DESC 4 /* Number of Rx descriptor registers. */
  20290. -typedef unsigned char u8;
  20291. -typedef signed char s8;
  20292. -typedef unsigned short u16;
  20293. -typedef signed short s16;
  20294. -typedef unsigned int u32;
  20295. -typedef signed int s32;
  20296. +typedef uint8_t u8;
  20297. +typedef int8_t s8;
  20298. +typedef uint16_t u16;
  20299. +typedef int16_t s16;
  20300. +typedef uint32_t u32;
  20301. +typedef int32_t s32;
  20302. /* helpful macroes if on a big_endian machine for changing byte order.
  20303. not strictly needed on Intel */
  20304. -#define le16_to_cpu(val) (val)
  20305. -#define cpu_to_le32(val) (val)
  20306. #define get_unaligned(ptr) (*(ptr))
  20307. #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
  20308. #define get_u16(ptr) (*(u16 *)(ptr))
  20309. -#define virt_to_bus(x) ((unsigned long)x)
  20310. #define virt_to_le32desc(addr) virt_to_bus(addr)
  20311. enum pcistuff {
  20312. @@ -161,7 +158,8 @@
  20313. AcceptMulticast = 0x00200000,
  20314. AcceptAllMulticast = 0x20000000,
  20315. AcceptAllPhys = 0x10000000,
  20316. - AcceptMyPhys = 0x08000000
  20317. + AcceptMyPhys = 0x08000000,
  20318. + RxFilterEnable = 0x80000000
  20319. };
  20320. typedef struct _BufferDesc {
  20321. @@ -207,17 +205,12 @@
  20322. static BufferDesc txd __attribute__ ((aligned(4)));
  20323. static BufferDesc rxd[NUM_RX_DESC] __attribute__ ((aligned(4)));
  20324. -#ifdef USE_LOWMEM_BUFFER
  20325. -#define txb ((char *)0x10000 - TX_BUF_SIZE)
  20326. -#define rxb ((char *)0x10000 - NUM_RX_DESC*RX_BUF_SIZE - TX_BUF_SIZE)
  20327. -#else
  20328. static unsigned char txb[TX_BUF_SIZE] __attribute__ ((aligned(4)));
  20329. static unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE] __attribute__ ((aligned(4)));
  20330. -#endif
  20331. /* Function Prototypes */
  20332. -struct nic *natsemi_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci);
  20333. +static int natsemi_probe(struct dev *dev, struct pci_device *pci);
  20334. static int eeprom_read(long addr, int location);
  20335. static int mdio_read(int phy_id, int location);
  20336. static void natsemi_init(struct nic *nic);
  20337. @@ -228,8 +221,9 @@
  20338. static void natsemi_set_rx_mode(struct nic *nic);
  20339. static void natsemi_check_duplex(struct nic *nic);
  20340. static void natsemi_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p);
  20341. -static int natsemi_poll(struct nic *nic);
  20342. -static void natsemi_disable(struct nic *nic);
  20343. +static int natsemi_poll(struct nic *nic, int retrieve);
  20344. +static void natsemi_disable(struct dev *dev);
  20345. +static void natsemi_irq(struct nic *nic, irq_action_t action);
  20346. /*
  20347. * Function: natsemi_probe
  20348. @@ -245,24 +239,28 @@
  20349. * Returns: struct nic *: pointer to NIC data structure
  20350. */
  20351. -struct nic *
  20352. -natsemi_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci)
  20353. +static int
  20354. +natsemi_probe(struct dev *dev, struct pci_device *pci)
  20355. {
  20356. + struct nic *nic = (struct nic *)dev;
  20357. int i;
  20358. int prev_eedata;
  20359. u32 tmp;
  20360. - if (io_addrs == 0 || *io_addrs == 0)
  20361. - return NULL;
  20362. + if (pci->ioaddr == 0)
  20363. + return 0;
  20364. +
  20365. + adjust_pci_device(pci);
  20366. /* initialize some commonly used globals */
  20367. - ioaddr = *io_addrs & ~3;
  20368. + nic->irqno = 0;
  20369. + nic->ioaddr = pci->ioaddr & ~3;
  20370. +
  20371. + ioaddr = pci->ioaddr & ~3;
  20372. vendor = pci->vendor;
  20373. dev_id = pci->dev_id;
  20374. nic_name = pci->name;
  20375. -
  20376. - adjust_pci_device(pci);
  20377. /* natsemi has a non-standard PM control register
  20378. * in PCI config space. Some boards apparently need
  20379. @@ -317,12 +315,12 @@
  20380. /* initialize device */
  20381. natsemi_init(nic);
  20382. - nic->reset = natsemi_init;
  20383. + dev->disable = natsemi_disable;
  20384. nic->poll = natsemi_poll;
  20385. nic->transmit = natsemi_transmit;
  20386. - nic->disable = natsemi_disable;
  20387. + nic->irq = natsemi_irq;
  20388. - return nic;
  20389. + return 1;
  20390. }
  20391. /* Read the EEPROM and MII Management Data I/O (MDIO) interfaces.
  20392. @@ -452,7 +450,7 @@
  20393. * Returns: void.
  20394. */
  20395. static void
  20396. -natsemi_reset(struct nic *nic)
  20397. +natsemi_reset(struct nic *nic __unused)
  20398. {
  20399. outl(ChipReset, ioaddr + ChipCmd);
  20400. @@ -504,14 +502,14 @@
  20401. */
  20402. static void
  20403. -natsemi_init_txd(struct nic *nic)
  20404. +natsemi_init_txd(struct nic *nic __unused)
  20405. {
  20406. txd.link = (u32) 0;
  20407. txd.cmdsts = (u32) 0;
  20408. - txd.bufptr = (u32) &txb[0];
  20409. + txd.bufptr = virt_to_bus(&txb[0]);
  20410. /* load Transmit Descriptor Register */
  20411. - outl((u32) &txd, ioaddr + TxRingPtr);
  20412. + outl(virt_to_bus(&txd), ioaddr + TxRingPtr);
  20413. if (natsemi_debug > 1)
  20414. printf("natsemi_init_txd: TX descriptor register loaded with: %X\n",
  20415. inl(ioaddr + TxRingPtr));
  20416. @@ -527,7 +525,7 @@
  20417. */
  20418. static void
  20419. -natsemi_init_rxd(struct nic *nic)
  20420. +natsemi_init_rxd(struct nic *nic __unused)
  20421. {
  20422. int i;
  20423. @@ -535,16 +533,16 @@
  20424. /* init RX descriptor */
  20425. for (i = 0; i < NUM_RX_DESC; i++) {
  20426. - rxd[i].link = (i+1 < NUM_RX_DESC) ? (u32) &rxd[i+1] : (u32) &rxd[0];
  20427. + rxd[i].link = virt_to_bus((i+1 < NUM_RX_DESC) ? &rxd[i+1] : &rxd[0]);
  20428. rxd[i].cmdsts = (u32) RX_BUF_SIZE;
  20429. - rxd[i].bufptr = (u32) &rxb[i*RX_BUF_SIZE];
  20430. + rxd[i].bufptr = virt_to_bus(&rxb[i*RX_BUF_SIZE]);
  20431. if (natsemi_debug > 1)
  20432. printf("natsemi_init_rxd: rxd[%d]=%X link=%X cmdsts=%X bufptr=%X\n",
  20433. i, &rxd[i], rxd[i].link, rxd[i].cmdsts, rxd[i].bufptr);
  20434. }
  20435. /* load Receive Descriptor Register */
  20436. - outl((u32) &rxd[0], ioaddr + RxRingPtr);
  20437. + outl(virt_to_bus(&rxd[0]), ioaddr + RxRingPtr);
  20438. if (natsemi_debug > 1)
  20439. printf("natsemi_init_rxd: RX descriptor register loaded with: %X\n",
  20440. @@ -562,14 +560,15 @@
  20441. * Returns: void.
  20442. */
  20443. -static void natsemi_set_rx_mode(struct nic *nic)
  20444. +static void natsemi_set_rx_mode(struct nic *nic __unused)
  20445. {
  20446. - u32 rx_mode = AcceptBroadcast | AcceptMyPhys;
  20447. + u32 rx_mode = RxFilterEnable | AcceptBroadcast |
  20448. + AcceptAllMulticast | AcceptMyPhys;
  20449. outl(rx_mode, ioaddr + RxFilterAddr);
  20450. }
  20451. -static void natsemi_check_duplex(struct nic *nic)
  20452. +static void natsemi_check_duplex(struct nic *nic __unused)
  20453. {
  20454. int duplex = inl(ioaddr + ChipConfig) & 0x20000000 ? 1 : 0;
  20455. @@ -607,14 +606,14 @@
  20456. unsigned int s, /* size */
  20457. const char *p) /* Packet */
  20458. {
  20459. - u32 status, to, nstype;
  20460. + u32 to, nstype;
  20461. volatile u32 tx_status;
  20462. /* Stop the transmitter */
  20463. outl(TxOff, ioaddr + ChipCmd);
  20464. /* load Transmit Descriptor Register */
  20465. - outl((u32) &txd, ioaddr + TxRingPtr);
  20466. + outl(virt_to_bus(&txd), ioaddr + TxRingPtr);
  20467. if (natsemi_debug > 1)
  20468. printf("natsemi_transmit: TX descriptor register loaded with: %X\n",
  20469. inl(ioaddr + TxRingPtr));
  20470. @@ -636,7 +635,7 @@
  20471. txb[s++] = '\0';
  20472. /* set the transmit buffer descriptor and enable Transmit State Machine */
  20473. - txd.bufptr = (u32) &txb[0];
  20474. + txd.bufptr = virt_to_bus(&txb[0]);
  20475. txd.cmdsts = (u32) OWN | s;
  20476. /* restart the transmitter */
  20477. @@ -647,7 +646,7 @@
  20478. to = currticks() + TX_TIMEOUT;
  20479. - while (((tx_status=txd.cmdsts) & OWN) && (currticks() < to))
  20480. + while (((tx_status=txd.cmdsts & OWN) && (currticks() < to))
  20481. /* wait */ ;
  20482. if (currticks() >= to) {
  20483. @@ -674,7 +673,7 @@
  20484. */
  20485. static int
  20486. -natsemi_poll(struct nic *nic)
  20487. +natsemi_poll(struct nic *nic, int retrieve)
  20488. {
  20489. u32 rx_status = rxd[cur_rx].cmdsts;
  20490. int retstat = 0;
  20491. @@ -685,6 +684,8 @@
  20492. if (!(rx_status & OWN))
  20493. return retstat;
  20494. + if ( ! retrieve ) return 1;
  20495. +
  20496. if (natsemi_debug > 1)
  20497. printf("natsemi_poll: got a packet: cur_rx:%d, status:%X\n",
  20498. cur_rx, rx_status);
  20499. @@ -704,7 +705,7 @@
  20500. /* return the descriptor and buffer to receive ring */
  20501. rxd[cur_rx].cmdsts = RX_BUF_SIZE;
  20502. - rxd[cur_rx].bufptr = (u32) &rxb[cur_rx*RX_BUF_SIZE];
  20503. + rxd[cur_rx].bufptr = virt_to_bus(&rxb[cur_rx*RX_BUF_SIZE]);
  20504. if (++cur_rx == NUM_RX_DESC)
  20505. cur_rx = 0;
  20506. @@ -725,8 +726,12 @@
  20507. */
  20508. static void
  20509. -natsemi_disable(struct nic *nic)
  20510. +natsemi_disable(struct dev *dev)
  20511. {
  20512. + struct nic *nic = (struct nic *)dev;
  20513. + /* merge reset and disable */
  20514. + natsemi_init(nic);
  20515. +
  20516. /* Disable interrupts using the mask. */
  20517. outl(0, ioaddr + IntrMask);
  20518. outl(0, ioaddr + IntrEnable);
  20519. @@ -737,3 +742,39 @@
  20520. /* Restore PME enable bit */
  20521. outl(SavedClkRun, ioaddr + ClkRun);
  20522. }
  20523. +
  20524. +/* Function: natsemi_irq
  20525. + *
  20526. + * Description: Enable, Disable, or Force interrupts
  20527. + *
  20528. + * Arguments: struct nic *nic: NIC data structure
  20529. + * irq_action_t action: requested action to perform
  20530. + *
  20531. + * Returns: void.
  20532. + */
  20533. +
  20534. +static void
  20535. +natsemi_irq(struct nic *nic __unused, irq_action_t action __unused)
  20536. +{
  20537. + switch ( action ) {
  20538. + case DISABLE :
  20539. + break;
  20540. + case ENABLE :
  20541. + break;
  20542. + case FORCE :
  20543. + break;
  20544. + }
  20545. +}
  20546. +
  20547. +static struct pci_id natsemi_nics[] = {
  20548. +PCI_ROM(0x100b, 0x0020, "dp83815", "DP83815"),
  20549. +};
  20550. +
  20551. +struct pci_driver natsemi_driver = {
  20552. + .type = NIC_DRIVER,
  20553. + .name = "NATSEMI",
  20554. + .probe = natsemi_probe,
  20555. + .ids = natsemi_nics,
  20556. + .id_count = sizeof(natsemi_nics)/sizeof(natsemi_nics[0]),
  20557. + .class = 0,
  20558. +};
  20559. Index: b/netboot/nfs.h
  20560. ===================================================================
  20561. --- /dev/null
  20562. +++ b/netboot/nfs.h
  20563. @@ -0,0 +1,63 @@
  20564. +#ifndef _NFS_H
  20565. +#define _NFS_H
  20566. +
  20567. +#define SUNRPC_PORT 111
  20568. +
  20569. +#define PROG_PORTMAP 100000
  20570. +#define PROG_NFS 100003
  20571. +#define PROG_MOUNT 100005
  20572. +
  20573. +#define MSG_CALL 0
  20574. +#define MSG_REPLY 1
  20575. +
  20576. +#define PORTMAP_GETPORT 3
  20577. +
  20578. +#define MOUNT_ADDENTRY 1
  20579. +#define MOUNT_UMOUNTALL 4
  20580. +
  20581. +#define NFS_LOOKUP 4
  20582. +#define NFS_READLINK 5
  20583. +#define NFS_READ 6
  20584. +
  20585. +#define NFS_FHSIZE 32
  20586. +
  20587. +#define NFSERR_PERM 1
  20588. +#define NFSERR_NOENT 2
  20589. +#define NFSERR_ACCES 13
  20590. +#define NFSERR_ISDIR 21
  20591. +#define NFSERR_INVAL 22
  20592. +
  20593. +/* Block size used for NFS read accesses. A RPC reply packet (including all
  20594. + * headers) must fit within a single Ethernet frame to avoid fragmentation.
  20595. + * Chosen to be a power of two, as most NFS servers are optimized for this. */
  20596. +#define NFS_READ_SIZE 1024
  20597. +
  20598. +#define NFS_MAXLINKDEPTH 16
  20599. +
  20600. +struct rpc_t {
  20601. + struct iphdr ip;
  20602. + struct udphdr udp;
  20603. + union {
  20604. + uint8_t data[300]; /* longest RPC call must fit!!!! */
  20605. + struct {
  20606. + uint32_t id;
  20607. + uint32_t type;
  20608. + uint32_t rpcvers;
  20609. + uint32_t prog;
  20610. + uint32_t vers;
  20611. + uint32_t proc;
  20612. + uint32_t data[1];
  20613. + } call;
  20614. + struct {
  20615. + uint32_t id;
  20616. + uint32_t type;
  20617. + uint32_t rstatus;
  20618. + uint32_t verifier;
  20619. + uint32_t v2;
  20620. + uint32_t astatus;
  20621. + uint32_t data[1];
  20622. + } reply;
  20623. + } u;
  20624. +};
  20625. +
  20626. +#endif /* _NFS_H */
  20627. Index: b/netboot/ni5010.c
  20628. ===================================================================
  20629. --- a/netboot/ni5010.c
  20630. +++ /dev/null
  20631. @@ -1,371 +0,0 @@
  20632. -/**************************************************************************
  20633. -Etherboot - BOOTP/TFTP Bootstrap Program
  20634. -Driver for NI5010.
  20635. -Code freely taken from Jan-Pascal van Best and Andreas Mohr's
  20636. -Linux NI5010 driver.
  20637. -***************************************************************************/
  20638. -
  20639. -/*
  20640. - * This program is free software; you can redistribute it and/or
  20641. - * modify it under the terms of the GNU General Public License as
  20642. - * published by the Free Software Foundation; either version 2, or (at
  20643. - * your option) any later version.
  20644. - */
  20645. -
  20646. -/* to get some global routines like printf */
  20647. -#include "etherboot.h"
  20648. -/* to get the interface to the body of the program */
  20649. -#include "nic.h"
  20650. -/* to get our own prototype */
  20651. -#include "cards.h"
  20652. -
  20653. -/* ni5010.h file included verbatim */
  20654. -/*
  20655. - * Racal-Interlan ni5010 Ethernet definitions
  20656. - *
  20657. - * This is an extension to the Linux operating system, and is covered by the
  20658. - * same Gnu Public License that covers that work.
  20659. - *
  20660. - * copyrights (c) 1996 by Jan-Pascal van Best (jvbest@wi.leidenuniv.nl)
  20661. - *
  20662. - * I have done a look in the following sources:
  20663. - * crynwr-packet-driver by Russ Nelson
  20664. - */
  20665. -
  20666. -#define NI5010_BUFSIZE 2048 /* number of bytes in a buffer */
  20667. -
  20668. -#define NI5010_MAGICVAL0 0x00 /* magic-values for ni5010 card */
  20669. -#define NI5010_MAGICVAL1 0x55
  20670. -#define NI5010_MAGICVAL2 0xAA
  20671. -
  20672. -#define SA_ADDR0 0x02
  20673. -#define SA_ADDR1 0x07
  20674. -#define SA_ADDR2 0x01
  20675. -
  20676. -/* The number of low I/O ports used by the ni5010 ethercard. */
  20677. -#define NI5010_IO_EXTENT 32
  20678. -
  20679. -#define PRINTK(x) if (NI5010_DEBUG) printk x
  20680. -#define PRINTK2(x) if (NI5010_DEBUG>=2) printk x
  20681. -#define PRINTK3(x) if (NI5010_DEBUG>=3) printk x
  20682. -
  20683. -/* The various IE command registers */
  20684. -#define EDLC_XSTAT (ioaddr + 0x00) /* EDLC transmit csr */
  20685. -#define EDLC_XCLR (ioaddr + 0x00) /* EDLC transmit "Clear IRQ" */
  20686. -#define EDLC_XMASK (ioaddr + 0x01) /* EDLC transmit "IRQ Masks" */
  20687. -#define EDLC_RSTAT (ioaddr + 0x02) /* EDLC receive csr */
  20688. -#define EDLC_RCLR (ioaddr + 0x02) /* EDLC receive "Clear IRQ" */
  20689. -#define EDLC_RMASK (ioaddr + 0x03) /* EDLC receive "IRQ Masks" */
  20690. -#define EDLC_XMODE (ioaddr + 0x04) /* EDLC transmit Mode */
  20691. -#define EDLC_RMODE (ioaddr + 0x05) /* EDLC receive Mode */
  20692. -#define EDLC_RESET (ioaddr + 0x06) /* EDLC RESET register */
  20693. -#define EDLC_TDR1 (ioaddr + 0x07) /* "Time Domain Reflectometry" reg1 */
  20694. -#define EDLC_ADDR (ioaddr + 0x08) /* EDLC station address, 6 bytes */
  20695. - /* 0x0E doesn't exist for r/w */
  20696. -#define EDLC_TDR2 (ioaddr + 0x0f) /* "Time Domain Reflectometry" reg2 */
  20697. -#define IE_GP (ioaddr + 0x10) /* GP pointer (word register) */
  20698. - /* 0x11 is 2nd byte of GP Pointer */
  20699. -#define IE_RCNT (ioaddr + 0x10) /* Count of bytes in rcv'd packet */
  20700. - /* 0x11 is 2nd byte of "Byte Count" */
  20701. -#define IE_MMODE (ioaddr + 0x12) /* Memory Mode register */
  20702. -#define IE_DMA_RST (ioaddr + 0x13) /* IE DMA Reset. write only */
  20703. -#define IE_ISTAT (ioaddr + 0x13) /* IE Interrupt Status. read only */
  20704. -#define IE_RBUF (ioaddr + 0x14) /* IE Receive Buffer port */
  20705. -#define IE_XBUF (ioaddr + 0x15) /* IE Transmit Buffer port */
  20706. -#define IE_SAPROM (ioaddr + 0x16) /* window on station addr prom */
  20707. -#define IE_RESET (ioaddr + 0x17) /* any write causes Board Reset */
  20708. -
  20709. -/* bits in EDLC_XSTAT, interrupt clear on write, status when read */
  20710. -#define XS_TPOK 0x80 /* transmit packet successful */
  20711. -#define XS_CS 0x40 /* carrier sense */
  20712. -#define XS_RCVD 0x20 /* transmitted packet received */
  20713. -#define XS_SHORT 0x10 /* transmission media is shorted */
  20714. -#define XS_UFLW 0x08 /* underflow. iff failed board */
  20715. -#define XS_COLL 0x04 /* collision occurred */
  20716. -#define XS_16COLL 0x02 /* 16th collision occurred */
  20717. -#define XS_PERR 0x01 /* parity error */
  20718. -
  20719. -#define XS_CLR_UFLW 0x08 /* clear underflow */
  20720. -#define XS_CLR_COLL 0x04 /* clear collision */
  20721. -#define XS_CLR_16COLL 0x02 /* clear 16th collision */
  20722. -#define XS_CLR_PERR 0x01 /* clear parity error */
  20723. -
  20724. -/* bits in EDLC_XMASK, mask/enable transmit interrupts. register is r/w */
  20725. -#define XM_TPOK 0x80 /* =1 to enable Xmt Pkt OK interrupts */
  20726. -#define XM_RCVD 0x20 /* =1 to enable Xmt Pkt Rcvd ints */
  20727. -#define XM_UFLW 0x08 /* =1 to enable Xmt Underflow ints */
  20728. -#define XM_COLL 0x04 /* =1 to enable Xmt Collision ints */
  20729. -#define XM_COLL16 0x02 /* =1 to enable Xmt 16th Coll ints */
  20730. -#define XM_PERR 0x01 /* =1 to enable Xmt Parity Error ints */
  20731. - /* note: always clear this bit */
  20732. -#define XM_ALL (XM_TPOK | XM_RCVD | XM_UFLW | XM_COLL | XM_COLL16)
  20733. -
  20734. -/* bits in EDLC_RSTAT, interrupt clear on write, status when read */
  20735. -#define RS_PKT_OK 0x80 /* received good packet */
  20736. -#define RS_RST_PKT 0x10 /* RESET packet received */
  20737. -#define RS_RUNT 0x08 /* Runt Pkt rcvd. Len < 64 Bytes */
  20738. -#define RS_ALIGN 0x04 /* Alignment error. not 8 bit aligned */
  20739. -#define RS_CRC_ERR 0x02 /* Bad CRC on rcvd pkt */
  20740. -#define RS_OFLW 0x01 /* overflow for rcv FIFO */
  20741. -#define RS_VALID_BITS ( RS_PKT_OK | RS_RST_PKT | RS_RUNT | RS_ALIGN | RS_CRC_ERR | RS_OFLW )
  20742. - /* all valid RSTAT bits */
  20743. -
  20744. -#define RS_CLR_PKT_OK 0x80 /* clear rcvd packet interrupt */
  20745. -#define RS_CLR_RST_PKT 0x10 /* clear RESET packet received */
  20746. -#define RS_CLR_RUNT 0x08 /* clear Runt Pckt received */
  20747. -#define RS_CLR_ALIGN 0x04 /* clear Alignment error */
  20748. -#define RS_CLR_CRC_ERR 0x02 /* clear CRC error */
  20749. -#define RS_CLR_OFLW 0x01 /* clear rcv FIFO Overflow */
  20750. -
  20751. -/* bits in EDLC_RMASK, mask/enable receive interrupts. register is r/w */
  20752. -#define RM_PKT_OK 0x80 /* =1 to enable rcvd good packet ints */
  20753. -#define RM_RST_PKT 0x10 /* =1 to enable RESET packet ints */
  20754. -#define RM_RUNT 0x08 /* =1 to enable Runt Pkt rcvd ints */
  20755. -#define RM_ALIGN 0x04 /* =1 to enable Alignment error ints */
  20756. -#define RM_CRC_ERR 0x02 /* =1 to enable Bad CRC error ints */
  20757. -#define RM_OFLW 0x01 /* =1 to enable overflow error ints */
  20758. -
  20759. -/* bits in EDLC_RMODE, set Receive Packet mode. register is r/w */
  20760. -#define RMD_TEST 0x80 /* =1 for Chip testing. normally 0 */
  20761. -#define RMD_ADD_SIZ 0x10 /* =1 5-byte addr match. normally 0 */
  20762. -#define RMD_EN_RUNT 0x08 /* =1 enable runt rcv. normally 0 */
  20763. -#define RMD_EN_RST 0x04 /* =1 to rcv RESET pkt. normally 0 */
  20764. -
  20765. -#define RMD_PROMISC 0x03 /* receive *all* packets. unusual */
  20766. -#define RMD_MULTICAST 0x02 /* receive multicasts too. unusual */
  20767. -#define RMD_BROADCAST 0x01 /* receive broadcasts & normal. usual */
  20768. -#define RMD_NO_PACKETS 0x00 /* don't receive any packets. unusual */
  20769. -
  20770. -/* bits in EDLC_XMODE, set Transmit Packet mode. register is r/w */
  20771. -#define XMD_COLL_CNT 0xf0 /* coll's since success. read-only */
  20772. -#define XMD_IG_PAR 0x08 /* =1 to ignore parity. ALWAYS set */
  20773. -#define XMD_T_MODE 0x04 /* =1 to power xcvr. ALWAYS set this */
  20774. -#define XMD_LBC 0x02 /* =1 for loopback. normally set */
  20775. -#define XMD_DIS_C 0x01 /* =1 disables contention. normally 0 */
  20776. -
  20777. -/* bits in EDLC_RESET, write only */
  20778. -#define RS_RESET 0x80 /* =1 to hold EDLC in reset state */
  20779. -
  20780. -/* bits in IE_MMODE, write only */
  20781. -#define MM_EN_DMA 0x80 /* =1 begin DMA xfer, Cplt clrs it */
  20782. -#define MM_EN_RCV 0x40 /* =1 allows Pkt rcv. clr'd by rcv */
  20783. -#define MM_EN_XMT 0x20 /* =1 begin Xmt pkt. Cplt clrs it */
  20784. -#define MM_BUS_PAGE 0x18 /* =00 ALWAYS. Used when MUX=1 */
  20785. -#define MM_NET_PAGE 0x06 /* =00 ALWAYS. Used when MUX=0 */
  20786. -#define MM_MUX 0x01 /* =1 means Rcv Buff on system bus */
  20787. - /* =0 means Xmt Buff on system bus */
  20788. -
  20789. -/* bits in IE_ISTAT, read only */
  20790. -#define IS_TDIAG 0x80 /* =1 if Diagnostic problem */
  20791. -#define IS_EN_RCV 0x20 /* =1 until frame is rcv'd cplt */
  20792. -#define IS_EN_XMT 0x10 /* =1 until frame is xmt'd cplt */
  20793. -#define IS_EN_DMA 0x08 /* =1 until DMA is cplt or aborted */
  20794. -#define IS_DMA_INT 0x04 /* =0 iff DMA done interrupt. */
  20795. -#define IS_R_INT 0x02 /* =0 iff unmasked Rcv interrupt */
  20796. -#define IS_X_INT 0x01 /* =0 iff unmasked Xmt interrupt */
  20797. -
  20798. -/* NIC specific static variables go here */
  20799. -
  20800. -static unsigned short ioaddr = 0;
  20801. -static unsigned int bufsize_rcv = 0;
  20802. -
  20803. -#if 0
  20804. -static void show_registers(void)
  20805. -{
  20806. - printf("XSTAT %hhX ", inb(EDLC_XSTAT));
  20807. - printf("XMASK %hhX ", inb(EDLC_XMASK));
  20808. - printf("RSTAT %hhX ", inb(EDLC_RSTAT));
  20809. - printf("RMASK %hhX ", inb(EDLC_RMASK));
  20810. - printf("RMODE %hhX ", inb(EDLC_RMODE));
  20811. - printf("XMODE %hhX ", inb(EDLC_XMODE));
  20812. - printf("ISTAT %hhX\n", inb(IE_ISTAT));
  20813. -}
  20814. -#endif
  20815. -
  20816. -static void reset_receiver(void)
  20817. -{
  20818. - outw(0, IE_GP); /* Receive packet at start of buffer */
  20819. - outb(RS_VALID_BITS, EDLC_RCLR); /* Clear all pending Rcv interrupts */
  20820. - outb(MM_EN_RCV, IE_MMODE); /* Enable rcv */
  20821. -}
  20822. -
  20823. -/**************************************************************************
  20824. -RESET - Reset adapter
  20825. -***************************************************************************/
  20826. -static void ni5010_reset(struct nic *nic)
  20827. -{
  20828. - int i;
  20829. -
  20830. - /* Reset the hardware here. Don't forget to set the station address. */
  20831. - outb(RS_RESET, EDLC_RESET); /* Hold up EDLC_RESET while configing board */
  20832. - outb(0, IE_RESET); /* Hardware reset of ni5010 board */
  20833. - outb(0, EDLC_XMASK); /* Disable all Xmt interrupts */
  20834. - outb(0, EDLC_RMASK); /* Disable all Rcv interrupt */
  20835. - outb(0xFF, EDLC_XCLR); /* Clear all pending Xmt interrupts */
  20836. - outb(0xFF, EDLC_RCLR); /* Clear all pending Rcv interrupts */
  20837. - outb(XMD_LBC, EDLC_XMODE); /* Only loopback xmits */
  20838. - /* Set the station address */
  20839. - for(i = 0; i < ETH_ALEN; i++)
  20840. - outb(nic->node_addr[i], EDLC_ADDR + i);
  20841. - outb(XMD_IG_PAR | XMD_T_MODE | XMD_LBC, EDLC_XMODE);
  20842. - /* Normal packet xmit mode */
  20843. - outb(RMD_BROADCAST, EDLC_RMODE);
  20844. - /* Receive broadcast and normal packets */
  20845. - reset_receiver();
  20846. - outb(0x00, EDLC_RESET); /* Un-reset the ni5010 */
  20847. -}
  20848. -
  20849. -/**************************************************************************
  20850. -POLL - Wait for a frame
  20851. -***************************************************************************/
  20852. -static int ni5010_poll(struct nic *nic)
  20853. -{
  20854. - int rcv_stat;
  20855. -
  20856. - if (((rcv_stat = inb(EDLC_RSTAT)) & RS_VALID_BITS) != RS_PKT_OK) {
  20857. - outb(rcv_stat, EDLC_RSTAT); /* Clear the status */
  20858. - return (0);
  20859. - }
  20860. - outb(rcv_stat, EDLC_RCLR); /* Clear the status */
  20861. - nic->packetlen = inw(IE_RCNT);
  20862. - /* Read packet into buffer */
  20863. - outb(MM_MUX, IE_MMODE); /* Rcv buffer to system bus */
  20864. - outw(0, IE_GP); /* Seek to beginning of packet */
  20865. - insb(IE_RBUF, nic->packet, nic->packetlen);
  20866. - return (1);
  20867. -}
  20868. -
  20869. -/**************************************************************************
  20870. -TRANSMIT - Transmit a frame
  20871. -***************************************************************************/
  20872. -static void ni5010_transmit(struct nic *nic,
  20873. - const char *d, /* Destination */
  20874. - unsigned int t, /* Type */
  20875. - unsigned int s, /* size */
  20876. - const char *p) /* Packet */
  20877. -{
  20878. - unsigned int len;
  20879. - int buf_offs, xmt_stat;
  20880. - unsigned long time;
  20881. -
  20882. - len = s + ETH_HLEN;
  20883. - if (len < ETH_ZLEN)
  20884. - len = ETH_ZLEN;
  20885. - buf_offs = NI5010_BUFSIZE - len;
  20886. - outb(0, EDLC_RMASK); /* Mask all receive interrupts */
  20887. - outb(0, IE_MMODE); /* Put Xmit buffer on system bus */
  20888. - outb(0xFF, EDLC_RCLR); /* Clear out pending rcv interrupts */
  20889. - outw(buf_offs, IE_GP); /* Point GP at start of packet */
  20890. - outsb(IE_XBUF, d, ETH_ALEN); /* Put dst in buffer */
  20891. - outsb(IE_XBUF, nic->node_addr, ETH_ALEN);/* Put src in buffer */
  20892. - outb(t >> 8, IE_XBUF);
  20893. - outb(t, IE_XBUF);
  20894. - outsb(IE_XBUF, p, s); /* Put data in buffer */
  20895. - while (s++ < ETH_ZLEN - ETH_HLEN) /* Pad to min size */
  20896. - outb(0, IE_XBUF);
  20897. - outw(buf_offs, IE_GP); /* Rewrite where packet starts */
  20898. - /* should work without that outb() (Crynwr used it) */
  20899. - /*outb(MM_MUX, IE_MMODE);*/
  20900. - /* Xmt buffer to EDLC bus */
  20901. - outb(MM_EN_XMT | MM_MUX, IE_MMODE); /* Begin transmission */
  20902. - /* wait for transmit complete */
  20903. - while (((xmt_stat = inb(IE_ISTAT)) & IS_EN_XMT) != 0)
  20904. - ;
  20905. - reset_receiver(); /* Immediately switch to receive */
  20906. -}
  20907. -
  20908. -/**************************************************************************
  20909. -DISABLE - Turn off ethernet interface
  20910. -***************************************************************************/
  20911. -static void ni5010_disable(struct nic *nic)
  20912. -{
  20913. - outb(0, IE_MMODE);
  20914. - outb(RS_RESET, EDLC_RESET);
  20915. -}
  20916. -
  20917. -static inline int rd_port(void)
  20918. -{
  20919. - inb(IE_RBUF);
  20920. - return inb(IE_SAPROM);
  20921. -}
  20922. -
  20923. -static int ni5010_probe1(struct nic *nic)
  20924. -{
  20925. - int i, boguscount = 40, data;
  20926. -
  20927. - /* The tests are from the Linux NI5010 driver
  20928. - I don't understand it all, but if it works for them... */
  20929. - if (inb(ioaddr) == 0xFF)
  20930. - return (0);
  20931. - while ((rd_port() & rd_port() & rd_port()
  20932. - & rd_port() & rd_port() & rd_port()) != 0xFF)
  20933. - {
  20934. - if (boguscount-- <= 0)
  20935. - return (0);
  20936. - }
  20937. - for (i = 0; i < 32; i++)
  20938. - if ((data = rd_port()) != 0xFF)
  20939. - break;
  20940. - if (data == 0xFF)
  20941. - return (0);
  20942. - if (data == SA_ADDR0 && rd_port() == SA_ADDR1 && rd_port() == SA_ADDR2) {
  20943. - for (i = 0; i < 4; i++)
  20944. - rd_port();
  20945. - if (rd_port() != NI5010_MAGICVAL1 || rd_port() != NI5010_MAGICVAL2)
  20946. - return (0);
  20947. - } else
  20948. - return (0);
  20949. - for (i = 0; i < ETH_ALEN; i++) {
  20950. - outw(i, IE_GP);
  20951. - nic->node_addr[i] = inb(IE_SAPROM);
  20952. - }
  20953. - printf("\nNI5010 ioaddr %#hX, addr %!\n", ioaddr, nic->node_addr);
  20954. -/* get the size of the onboard receive buffer
  20955. - * higher addresses than bufsize are wrapped into real buffer
  20956. - * i.e. data for offs. 0x801 is written to 0x1 with a 2K onboard buffer
  20957. - */
  20958. - if (bufsize_rcv == 0) {
  20959. - outb(1, IE_MMODE); /* Put Rcv buffer on system bus */
  20960. - outw(0, IE_GP); /* Point GP at start of packet */
  20961. - outb(0, IE_RBUF); /* set buffer byte 0 to 0 */
  20962. - for (i = 1; i < 0xFF; i++) {
  20963. - outw(i << 8, IE_GP); /* Point GP at packet size to be tested */
  20964. - outb(i, IE_RBUF);
  20965. - outw(0x0, IE_GP); /* Point GP at start of packet */
  20966. - data = inb(IE_RBUF);
  20967. - if (data == i) break;
  20968. - }
  20969. - bufsize_rcv = i << 8;
  20970. - outw(0, IE_GP); /* Point GP at start of packet */
  20971. - outb(0, IE_RBUF); /* set buffer byte 0 to 0 again */
  20972. - }
  20973. - printf("Bufsize rcv/xmt=%d/%d\n", bufsize_rcv, NI5010_BUFSIZE);
  20974. - return (1);
  20975. -}
  20976. -
  20977. -/**************************************************************************
  20978. -PROBE - Look for an adapter, this routine's visible to the outside
  20979. -***************************************************************************/
  20980. -struct nic *ni5010_probe(struct nic *nic, unsigned short *probe_addrs)
  20981. -{
  20982. - static unsigned short io_addrs[] = {
  20983. - 0x300, 0x320, 0x340, 0x360, 0x380, 0x3a0, 0 };
  20984. - unsigned short *p;
  20985. -
  20986. - /* if probe_addrs is 0, then use list above */
  20987. - if (probe_addrs == 0 || *probe_addrs == 0)
  20988. - probe_addrs = io_addrs;
  20989. - for (p = probe_addrs; (ioaddr = *p) != 0; p++) {
  20990. - if (ni5010_probe1(nic))
  20991. - break;
  20992. - }
  20993. - if (ioaddr == 0)
  20994. - return (0);
  20995. - ni5010_reset(nic);
  20996. - /* point to NIC specific routines */
  20997. - nic->reset = ni5010_reset;
  20998. - nic->poll = ni5010_poll;
  20999. - nic->transmit = ni5010_transmit;
  21000. - nic->disable = ni5010_disable;
  21001. - return (nic);
  21002. -}
  21003. Index: b/netboot/nic.c
  21004. ===================================================================
  21005. --- /dev/null
  21006. +++ b/netboot/nic.c
  21007. @@ -0,0 +1,1198 @@
  21008. +/**************************************************************************
  21009. +Etherboot - Network Bootstrap Program
  21010. +
  21011. +Literature dealing with the network protocols:
  21012. + ARP - RFC826
  21013. + RARP - RFC903
  21014. + IP - RFC791
  21015. + UDP - RFC768
  21016. + BOOTP - RFC951, RFC2132 (vendor extensions)
  21017. + DHCP - RFC2131, RFC2132 (options)
  21018. + TFTP - RFC1350, RFC2347 (options), RFC2348 (blocksize), RFC2349 (tsize)
  21019. + RPC - RFC1831, RFC1832 (XDR), RFC1833 (rpcbind/portmapper)
  21020. + NFS - RFC1094, RFC1813 (v3, useful for clarifications, not implemented)
  21021. + IGMP - RFC1112, RFC2113, RFC2365, RFC2236, RFC3171
  21022. +
  21023. +**************************************************************************/
  21024. +#include "etherboot.h"
  21025. +#include "grub.h"
  21026. +#include "nic.h"
  21027. +#include "elf.h" /* FOR EM_CURRENT */
  21028. +#include "bootp.h"
  21029. +#include "if_arp.h"
  21030. +#include "tftp.h"
  21031. +#include "timer.h"
  21032. +#include "ip.h"
  21033. +#include "udp.h"
  21034. +
  21035. +/* Currently no other module uses rom, but it is available */
  21036. +struct rom_info rom;
  21037. +struct arptable_t arptable[MAX_ARP];
  21038. +#if MULTICAST_LEVEL2
  21039. +unsigned long last_igmpv1 = 0;
  21040. +struct igmptable_t igmptable[MAX_IGMP];
  21041. +#endif
  21042. +static unsigned long netmask;
  21043. +/* Used by nfs.c */
  21044. +char *hostname = "";
  21045. +int hostnamelen = 0;
  21046. +static uint32_t xid;
  21047. +static unsigned char *end_of_rfc1533 = NULL;
  21048. +static const unsigned char broadcast[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
  21049. +static const in_addr zeroIP = { 0L };
  21050. +static char rfc1533_venddata[MAX_RFC1533_VENDLEN];
  21051. +static unsigned char rfc1533_cookie[4] = { RFC1533_COOKIE };
  21052. +static unsigned char rfc1533_cookie_bootp[5] = { RFC1533_COOKIE, RFC1533_END };
  21053. +static unsigned char rfc1533_cookie_dhcp[] = { RFC1533_COOKIE };
  21054. +static int dhcp_reply;
  21055. +static in_addr dhcp_server = { 0L };
  21056. +static in_addr dhcp_addr = { 0L };
  21057. +
  21058. +static const unsigned char dhcpdiscover[] = {
  21059. + RFC2132_MSG_TYPE, 1, DHCPDISCOVER,
  21060. + RFC2132_MAX_SIZE, 2, /* request as much as we can */
  21061. + ETH_MAX_MTU / 256, ETH_MAX_MTU % 256,
  21062. + /* Vendor class identifier */
  21063. + RFC2132_VENDOR_CLASS_ID, 10, 'G', 'R', 'U', 'B', 'C', 'l', 'i', 'e', 'n', 't',
  21064. + RFC2132_PARAM_LIST, 4, RFC1533_NETMASK, RFC1533_GATEWAY,
  21065. + RFC1533_HOSTNAME, RFC1533_EXTENSIONPATH, RFC1533_END
  21066. +};
  21067. +static const unsigned char dhcprequest [] = {
  21068. + RFC2132_MSG_TYPE,1,DHCPREQUEST,
  21069. + RFC2132_SRV_ID,4,0,0,0,0,
  21070. + RFC2132_REQ_ADDR,4,0,0,0,0,
  21071. + RFC2132_MAX_SIZE,2, /* request as much as we can */
  21072. + ETH_MAX_MTU / 256, ETH_MAX_MTU % 256,
  21073. + /* Vendor class identifier */
  21074. + RFC2132_VENDOR_CLASS_ID, 10, 'G', 'R', 'U', 'B', 'C', 'l', 'i', 'e', 'n', 't',
  21075. + RFC2132_PARAM_LIST,
  21076. + /* 4 standard + 2 vendortags */
  21077. + 4 + 2,
  21078. + /* Standard parameters */
  21079. + RFC1533_NETMASK, RFC1533_GATEWAY,
  21080. + RFC1533_HOSTNAME, RFC1533_EXTENSIONPATH,
  21081. + /* Etherboot vendortags */
  21082. + RFC1533_VENDOR_MAGIC,
  21083. + RFC1533_VENDOR_CONFIGFILE,
  21084. + RFC1533_END
  21085. +};
  21086. +
  21087. +/* See nic.h */
  21088. +int user_abort = 0;
  21089. +int network_ready = 0;
  21090. +
  21091. +#ifdef REQUIRE_VCI_ETHERBOOT
  21092. +int vci_etherboot;
  21093. +#endif
  21094. +
  21095. +static int dummy(void *unused __unused)
  21096. +{
  21097. + return (0);
  21098. +}
  21099. +
  21100. +/* Careful. We need an aligned buffer to avoid problems on machines
  21101. + * that care about alignment. To trivally align the ethernet data
  21102. + * (the ip hdr and arp requests) we offset the packet by 2 bytes.
  21103. + * leaving the ethernet data 16 byte aligned. Beyond this
  21104. + * we use memmove but this makes the common cast simple and fast.
  21105. + */
  21106. +static char packet[ETH_FRAME_LEN + ETH_DATA_ALIGN] __aligned;
  21107. +
  21108. +struct nic nic =
  21109. +{
  21110. + {
  21111. + 0, /* dev.disable */
  21112. + {
  21113. + 0,
  21114. + 0,
  21115. + PCI_BUS_TYPE,
  21116. + }, /* dev.devid */
  21117. + 0, /* index */
  21118. + 0, /* type */
  21119. + PROBE_FIRST, /* how_pobe */
  21120. + PROBE_NONE, /* to_probe */
  21121. + 0, /* failsafe */
  21122. + 0, /* type_index */
  21123. + {}, /* state */
  21124. + },
  21125. + (int (*)(struct nic *, int))dummy, /* poll */
  21126. + (void (*)(struct nic *, const char *,
  21127. + unsigned int, unsigned int,
  21128. + const char *))dummy, /* transmit */
  21129. + (void (*)(struct nic *, irq_action_t))dummy, /* irq */
  21130. + 0, /* flags */
  21131. + &rom, /* rom_info */
  21132. + arptable[ARP_CLIENT].node, /* node_addr */
  21133. + packet + ETH_DATA_ALIGN, /* packet */
  21134. + 0, /* packetlen */
  21135. + 0, /* ioaddr */
  21136. + 0, /* irqno */
  21137. + NULL, /* priv_data */
  21138. +};
  21139. +
  21140. +
  21141. +
  21142. +int grub_eth_probe(void)
  21143. +{
  21144. + static int probed = 0;
  21145. + struct dev *dev;
  21146. +
  21147. + EnterFunction("grub_eth_probe");
  21148. +
  21149. + if (probed)
  21150. + return 1;
  21151. +
  21152. + network_ready = 0;
  21153. + grub_memset((char *)arptable, 0, MAX_ARP * sizeof(struct arptable_t));
  21154. + dev = &nic.dev;
  21155. + dev->how_probe = -1;
  21156. + dev->type = NIC_DRIVER;
  21157. + dev->failsafe = 1;
  21158. + rom = *((struct rom_info *)ROM_INFO_LOCATION);
  21159. +
  21160. + probed = (eth_probe(dev) == PROBE_WORKED);
  21161. +
  21162. + LeaveFunction("grub_eth_probe");
  21163. + return probed;
  21164. +}
  21165. +
  21166. +int eth_probe(struct dev *dev)
  21167. +{
  21168. + return probe(dev);
  21169. +}
  21170. +
  21171. +int eth_poll(int retrieve)
  21172. +{
  21173. + return ((*nic.poll)(&nic, retrieve));
  21174. +}
  21175. +
  21176. +void eth_transmit(const char *d, unsigned int t, unsigned int s, const void *p)
  21177. +{
  21178. + (*nic.transmit)(&nic, d, t, s, p);
  21179. + if (t == IP) twiddle();
  21180. +}
  21181. +
  21182. +void eth_disable(void)
  21183. +{
  21184. +#ifdef MULTICAST_LEVEL2
  21185. + int i;
  21186. + for(i = 0; i < MAX_IGMP; i++) {
  21187. + leave_group(i);
  21188. + }
  21189. +#endif
  21190. + disable(&nic.dev);
  21191. +}
  21192. +
  21193. +void eth_irq (irq_action_t action)
  21194. +{
  21195. + (*nic.irq)(&nic,action);
  21196. +}
  21197. +
  21198. +/**************************************************************************
  21199. +IPCHKSUM - Checksum IP Header
  21200. +**************************************************************************/
  21201. +uint16_t ipchksum(const void *data, unsigned long length)
  21202. +{
  21203. + unsigned long sum;
  21204. + unsigned long i;
  21205. + const uint8_t *ptr;
  21206. +
  21207. + /* In the most straight forward way possible,
  21208. + * compute an ip style checksum.
  21209. + */
  21210. + sum = 0;
  21211. + ptr = data;
  21212. + for(i = 0; i < length; i++) {
  21213. + unsigned long value;
  21214. + value = ptr[i];
  21215. + if (i & 1) {
  21216. + value <<= 8;
  21217. + }
  21218. + /* Add the new value */
  21219. + sum += value;
  21220. + /* Wrap around the carry */
  21221. + if (sum > 0xFFFF) {
  21222. + sum = (sum + (sum >> 16)) & 0xFFFF;
  21223. + }
  21224. + }
  21225. + return (~cpu_to_le16(sum)) & 0xFFFF;
  21226. +}
  21227. +
  21228. +uint16_t add_ipchksums(unsigned long offset, uint16_t sum, uint16_t new)
  21229. +{
  21230. + unsigned long checksum;
  21231. + sum = ~sum & 0xFFFF;
  21232. + new = ~new & 0xFFFF;
  21233. + if (offset & 1) {
  21234. + /* byte swap the sum if it came from an odd offset
  21235. + * since the computation is endian independant this
  21236. + * works.
  21237. + */
  21238. + new = bswap_16(new);
  21239. + }
  21240. + checksum = sum + new;
  21241. + if (checksum > 0xFFFF) {
  21242. + checksum -= 0xFFFF;
  21243. + }
  21244. + return (~checksum) & 0xFFFF;
  21245. +}
  21246. +
  21247. +/**************************************************************************
  21248. +DEFAULT_NETMASK - Return default netmask for IP address
  21249. +**************************************************************************/
  21250. +static inline unsigned long default_netmask(void)
  21251. +{
  21252. + int net = ntohl(arptable[ARP_CLIENT].ipaddr.s_addr) >> 24;
  21253. + if (net <= 127)
  21254. + return(htonl(0xff000000));
  21255. + else if (net < 192)
  21256. + return(htonl(0xffff0000));
  21257. + else
  21258. + return(htonl(0xffffff00));
  21259. +}
  21260. +
  21261. +/**************************************************************************
  21262. +IP_TRANSMIT - Send an IP datagram
  21263. +**************************************************************************/
  21264. +static int await_arp(int ival, void *ptr,
  21265. + unsigned short ptype, struct iphdr *ip __unused, struct udphdr *udp __unused)
  21266. +{
  21267. + struct arprequest *arpreply;
  21268. + if (ptype != ARP)
  21269. + return 0;
  21270. + if (nic.packetlen < ETH_HLEN + sizeof(struct arprequest))
  21271. + return 0;
  21272. + arpreply = (struct arprequest *)&nic.packet[ETH_HLEN];
  21273. +
  21274. + if (arpreply->opcode != htons(ARP_REPLY))
  21275. + return 0;
  21276. + if (memcmp(arpreply->sipaddr, ptr, sizeof(in_addr)) != 0)
  21277. + return 0;
  21278. + memcpy(arptable[ival].node, arpreply->shwaddr, ETH_ALEN);
  21279. + return 1;
  21280. +}
  21281. +
  21282. +int ip_transmit(int len, const void *buf)
  21283. +{
  21284. + unsigned long destip;
  21285. + struct iphdr *ip;
  21286. + struct arprequest arpreq;
  21287. + int arpentry, i;
  21288. + int retry;
  21289. +
  21290. + ip = (struct iphdr *)buf;
  21291. + destip = ip->dest.s_addr;
  21292. + if (destip == IP_BROADCAST) {
  21293. + eth_transmit(broadcast, IP, len, buf);
  21294. +#ifdef MULTICAST_LEVEL1
  21295. + } else if ((destip & htonl(MULTICAST_MASK)) == htonl(MULTICAST_NETWORK)) {
  21296. + unsigned char multicast[6];
  21297. + unsigned long hdestip;
  21298. + hdestip = ntohl(destip);
  21299. + multicast[0] = 0x01;
  21300. + multicast[1] = 0x00;
  21301. + multicast[2] = 0x5e;
  21302. + multicast[3] = (hdestip >> 16) & 0x7;
  21303. + multicast[4] = (hdestip >> 8) & 0xff;
  21304. + multicast[5] = hdestip & 0xff;
  21305. + eth_transmit(multicast, IP, len, buf);
  21306. +#endif
  21307. + } else {
  21308. + if (((destip & netmask) !=
  21309. + (arptable[ARP_CLIENT].ipaddr.s_addr & netmask)) &&
  21310. + arptable[ARP_GATEWAY].ipaddr.s_addr)
  21311. + destip = arptable[ARP_GATEWAY].ipaddr.s_addr;
  21312. + for(arpentry = 0; arpentry<MAX_ARP; arpentry++)
  21313. + if (arptable[arpentry].ipaddr.s_addr == destip) break;
  21314. + if (arpentry == MAX_ARP) {
  21315. + printf("%@ is not in my arp table!\n", destip);
  21316. + return(0);
  21317. + }
  21318. + for (i = 0; i < ETH_ALEN; i++)
  21319. + if (arptable[arpentry].node[i])
  21320. + break;
  21321. + if (i == ETH_ALEN) { /* Need to do arp request */
  21322. + arpreq.hwtype = htons(1);
  21323. + arpreq.protocol = htons(IP);
  21324. + arpreq.hwlen = ETH_ALEN;
  21325. + arpreq.protolen = 4;
  21326. + arpreq.opcode = htons(ARP_REQUEST);
  21327. + memcpy(arpreq.shwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  21328. + memcpy(arpreq.sipaddr, &arptable[ARP_CLIENT].ipaddr, sizeof(in_addr));
  21329. + memset(arpreq.thwaddr, 0, ETH_ALEN);
  21330. + memcpy(arpreq.tipaddr, &destip, sizeof(in_addr));
  21331. + for (retry = 1; retry <= MAX_ARP_RETRIES; retry++) {
  21332. + long timeout;
  21333. + eth_transmit(broadcast, ARP, sizeof(arpreq),
  21334. + &arpreq);
  21335. + timeout = rfc2131_sleep_interval(TIMEOUT, retry);
  21336. + if (await_reply(await_arp, arpentry,
  21337. + arpreq.tipaddr, timeout)) goto xmit;
  21338. + }
  21339. + return(0);
  21340. + }
  21341. +xmit:
  21342. + eth_transmit(arptable[arpentry].node, IP, len, buf);
  21343. + }
  21344. + return 1;
  21345. +}
  21346. +
  21347. +void build_ip_hdr(unsigned long destip, int ttl, int protocol, int option_len,
  21348. + int len, const void *buf)
  21349. +{
  21350. + struct iphdr *ip;
  21351. + ip = (struct iphdr *)buf;
  21352. + ip->verhdrlen = 0x45;
  21353. + ip->verhdrlen += (option_len/4);
  21354. + ip->service = 0;
  21355. + ip->len = htons(len);
  21356. + ip->ident = 0;
  21357. + ip->frags = 0; /* Should we set don't fragment? */
  21358. + ip->ttl = ttl;
  21359. + ip->protocol = protocol;
  21360. + ip->chksum = 0;
  21361. + ip->src.s_addr = arptable[ARP_CLIENT].ipaddr.s_addr;
  21362. + ip->dest.s_addr = destip;
  21363. + ip->chksum = ipchksum(buf, sizeof(struct iphdr) + option_len);
  21364. +}
  21365. +
  21366. +static uint16_t udpchksum(struct iphdr *ip, struct udphdr *udp)
  21367. +{
  21368. + struct udp_pseudo_hdr pseudo;
  21369. + uint16_t checksum;
  21370. +
  21371. + /* Compute the pseudo header */
  21372. + pseudo.src.s_addr = ip->src.s_addr;
  21373. + pseudo.dest.s_addr = ip->dest.s_addr;
  21374. + pseudo.unused = 0;
  21375. + pseudo.protocol = IP_UDP;
  21376. + pseudo.len = udp->len;
  21377. +
  21378. + /* Sum the pseudo header */
  21379. + checksum = ipchksum(&pseudo, 12);
  21380. +
  21381. + /* Sum the rest of the udp packet */
  21382. + checksum = add_ipchksums(12, checksum, ipchksum(udp, ntohs(udp->len)));
  21383. + return checksum;
  21384. +}
  21385. +
  21386. +
  21387. +void build_udp_hdr(unsigned long destip,
  21388. + unsigned int srcsock, unsigned int destsock, int ttl,
  21389. + int len, const void *buf)
  21390. +{
  21391. + struct iphdr *ip;
  21392. + struct udphdr *udp;
  21393. + ip = (struct iphdr *)buf;
  21394. + build_ip_hdr(destip, ttl, IP_UDP, 0, len, buf);
  21395. + udp = (struct udphdr *)((char *)buf + sizeof(struct iphdr));
  21396. + udp->src = htons(srcsock);
  21397. + udp->dest = htons(destsock);
  21398. + udp->len = htons(len - sizeof(struct iphdr));
  21399. + udp->chksum = 0;
  21400. + if ((udp->chksum = udpchksum(ip, udp)) == 0)
  21401. + udp->chksum = 0xffff;
  21402. +}
  21403. +
  21404. +
  21405. +/**************************************************************************
  21406. +UDP_TRANSMIT - Send an UDP datagram
  21407. +**************************************************************************/
  21408. +int udp_transmit(unsigned long destip, unsigned int srcsock,
  21409. + unsigned int destsock, int len, const void *buf)
  21410. +{
  21411. + build_udp_hdr(destip, srcsock, destsock, 60, len, buf);
  21412. + return ip_transmit(len, buf);
  21413. +}
  21414. +
  21415. +/**************************************************************************
  21416. +QDRAIN - clear the nic's receive queue
  21417. +**************************************************************************/
  21418. +static int await_qdrain(int ival __unused, void *ptr __unused,
  21419. + unsigned short ptype __unused,
  21420. + struct iphdr *ip __unused, struct udphdr *udp __unused)
  21421. +{
  21422. + return 0;
  21423. +}
  21424. +
  21425. +void rx_qdrain(void)
  21426. +{
  21427. + /* Clear out the Rx queue first. It contains nothing of interest,
  21428. + * except possibly ARP requests from the DHCP/TFTP server. We use
  21429. + * polling throughout Etherboot, so some time may have passed since we
  21430. + * last polled the receive queue, which may now be filled with
  21431. + * broadcast packets. This will cause the reply to the packets we are
  21432. + * about to send to be lost immediately. Not very clever. */
  21433. + await_reply(await_qdrain, 0, NULL, 0);
  21434. +}
  21435. +
  21436. +/**
  21437. + * rarp
  21438. + *
  21439. + * Get IP address by rarp. Just copy from etherboot
  21440. + **/
  21441. +static int await_rarp(int ival, void *ptr, unsigned short ptype,
  21442. + struct iphdr *ip, struct udphdr *udp)
  21443. +{
  21444. + struct arprequest *arpreply;
  21445. + if (ptype != RARP)
  21446. + return 0;
  21447. + if (nic.packetlen < ETH_HLEN + sizeof(struct arprequest))
  21448. + return 0;
  21449. + arpreply = (struct arprequest *)&nic.packet[ETH_HLEN];
  21450. + if (arpreply->opcode != htons(RARP_REPLY))
  21451. + return 0;
  21452. + if (memcmp(arpreply->thwaddr, ptr, ETH_ALEN) == 0){
  21453. + memcpy(arptable[ARP_SERVER].node, arpreply->shwaddr, ETH_ALEN);
  21454. + memcpy(&arptable[ARP_SERVER].ipaddr, arpreply->sipaddr, sizeof(in_addr));
  21455. + memcpy(&arptable[ARP_CLIENT].ipaddr, arpreply->tipaddr, sizeof(in_addr));
  21456. + return 1;
  21457. + }
  21458. + return 0;
  21459. +}
  21460. +
  21461. +int rarp(void)
  21462. +{
  21463. + int retry;
  21464. +
  21465. + /* arp and rarp requests share the same packet structure. */
  21466. + struct arprequest rarpreq;
  21467. +
  21468. + if(!grub_eth_probe())
  21469. + return 0;
  21470. + network_ready = 0;
  21471. +
  21472. + memset(&rarpreq, 0, sizeof(rarpreq));
  21473. +
  21474. + rarpreq.hwtype = htons(1);
  21475. + rarpreq.protocol = htons(IP);
  21476. + rarpreq.hwlen = ETH_ALEN;
  21477. + rarpreq.protolen = 4;
  21478. + rarpreq.opcode = htons(RARP_REQUEST);
  21479. + memcpy(&rarpreq.shwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  21480. + /* sipaddr is already zeroed out */
  21481. + memcpy(&rarpreq.thwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  21482. + /* tipaddr is already zeroed out */
  21483. +
  21484. + for (retry = 0; retry < MAX_ARP_RETRIES; ++retry) {
  21485. + long timeout;
  21486. + eth_transmit(broadcast, RARP, sizeof(rarpreq), &rarpreq);
  21487. +
  21488. + timeout = rfc2131_sleep_interval(TIMEOUT, retry);
  21489. + if (await_reply(await_rarp, 0, rarpreq.shwaddr, timeout))
  21490. + break;
  21491. + if (user_abort)
  21492. + return 0;
  21493. + }
  21494. +
  21495. + if (retry < MAX_ARP_RETRIES) {
  21496. + network_ready = 1;
  21497. + return (1);
  21498. + }
  21499. + return (0);
  21500. +}
  21501. +
  21502. +/**
  21503. + * bootp
  21504. + *
  21505. + * Get IP address by bootp, segregate from bootp in etherboot.
  21506. + **/
  21507. +static int await_bootp(int ival __unused, void *ptr __unused,
  21508. + unsigned short ptype __unused, struct iphdr *ip __unused,
  21509. + struct udphdr *udp)
  21510. +{
  21511. + struct bootp_t *bootpreply;
  21512. + int len; /* Length of vendor */
  21513. +
  21514. + if (!udp) {
  21515. + return 0;
  21516. + }
  21517. + bootpreply = (struct bootp_t *)
  21518. + &nic.packet[ETH_HLEN + sizeof(struct iphdr) + sizeof(struct udphdr)];
  21519. + len = nic.packetlen - (ETH_HLEN + sizeof(struct iphdr) +
  21520. + sizeof(struct udphdr) + sizeof(struct bootp_t) - BOOTP_VENDOR_LEN);
  21521. + if (len < 0) {
  21522. + return 0;
  21523. + }
  21524. + if (udp->dest != htons(BOOTP_CLIENT))
  21525. + return 0;
  21526. + if (bootpreply->bp_op != BOOTP_REPLY)
  21527. + return 0;
  21528. + if (bootpreply->bp_xid != xid)
  21529. + return 0;
  21530. + if (memcmp((char *)&bootpreply->bp_siaddr, (char *)&zeroIP, sizeof(in_addr)) == 0)
  21531. + return 0;
  21532. + if ((memcmp(broadcast, bootpreply->bp_hwaddr, ETH_ALEN) != 0) &&
  21533. + (memcmp(arptable[ARP_CLIENT].node, bootpreply->bp_hwaddr, ETH_ALEN) != 0)) {
  21534. + return 0;
  21535. + }
  21536. + arptable[ARP_CLIENT].ipaddr.s_addr = bootpreply->bp_yiaddr.s_addr;
  21537. + netmask = default_netmask();
  21538. + arptable[ARP_SERVER].ipaddr.s_addr = bootpreply->bp_siaddr.s_addr;
  21539. + memset(arptable[ARP_SERVER].node, 0, ETH_ALEN); /* Kill arp */
  21540. + arptable[ARP_GATEWAY].ipaddr.s_addr = bootpreply->bp_giaddr.s_addr;
  21541. + memset(arptable[ARP_GATEWAY].node, 0, ETH_ALEN); /* Kill arp */
  21542. + /* We don't care bootpreply->bp_file, it must be 'pxegrub':-) */
  21543. + memcpy((char *)rfc1533_venddata, (char *)(bootpreply->bp_vend), len);
  21544. + decode_rfc1533(rfc1533_venddata, 0, len, 1);
  21545. + return(1);
  21546. +}
  21547. +
  21548. +int bootp(void)
  21549. +{
  21550. + int retry;
  21551. + struct bootpip_t ip;
  21552. + unsigned long starttime;
  21553. +
  21554. + EnterFunction("bootp");
  21555. +
  21556. + if(!grub_eth_probe())
  21557. + return 0;
  21558. + network_ready = 0;
  21559. +
  21560. + memset(&ip, 0, sizeof(struct bootpip_t));
  21561. + ip.bp.bp_op = BOOTP_REQUEST;
  21562. + ip.bp.bp_htype = 1;
  21563. + ip.bp.bp_hlen = ETH_ALEN;
  21564. + starttime = currticks();
  21565. + /* Use lower 32 bits of node address, more likely to be
  21566. + distinct than the time since booting */
  21567. + memcpy(&xid, &arptable[ARP_CLIENT].node[2], sizeof(xid));
  21568. + ip.bp.bp_xid = xid += htonl(starttime);
  21569. + /* bp_secs defaults to zero */
  21570. + memcpy(ip.bp.bp_hwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  21571. + memcpy(ip.bp.bp_vend, rfc1533_cookie_bootp, sizeof(rfc1533_cookie_bootp)); /* request RFC-style options */
  21572. +
  21573. + for (retry = 0; retry < MAX_BOOTP_RETRIES; ) {
  21574. + long timeout;
  21575. +
  21576. + rx_qdrain();
  21577. +
  21578. + udp_transmit(IP_BROADCAST, BOOTP_CLIENT, BOOTP_SERVER,
  21579. + sizeof(struct bootpip_t), &ip);
  21580. + timeout = rfc2131_sleep_interval(TIMEOUT, retry++);
  21581. + if (await_reply(await_bootp, 0, NULL, timeout)){
  21582. + network_ready = 1;
  21583. + return(1);
  21584. + }
  21585. + if (user_abort)
  21586. + return 0;
  21587. + ip.bp.bp_secs = htons((currticks()-starttime)/TICKS_PER_SEC);
  21588. + }
  21589. + return(0);
  21590. +}
  21591. +
  21592. +/**
  21593. + * dhcp
  21594. + *
  21595. + * Get IP address by dhcp, segregate from bootp in etherboot.
  21596. + **/
  21597. +static int await_dhcp(int ival __unused, void *ptr __unused,
  21598. + unsigned short ptype __unused, struct iphdr *ip __unused,
  21599. + struct udphdr *udp)
  21600. +{
  21601. + struct dhcp_t *dhcpreply;
  21602. + int len;
  21603. +
  21604. + if (!udp) {
  21605. + return 0;
  21606. + }
  21607. + dhcpreply = (struct dhcp_t *)
  21608. + &nic.packet[ETH_HLEN + sizeof(struct iphdr) + sizeof(struct udphdr)];
  21609. + len = nic.packetlen - (ETH_HLEN + sizeof(struct iphdr) +
  21610. + sizeof(struct udphdr) + sizeof(struct dhcp_t) - DHCP_OPT_LEN);
  21611. + if (len < 0){
  21612. + return 0;
  21613. + }
  21614. + if (udp->dest != htons(BOOTP_CLIENT))
  21615. + return 0;
  21616. + if (dhcpreply->bp_op != BOOTP_REPLY)
  21617. + return 0;
  21618. + if (dhcpreply->bp_xid != xid)
  21619. + return 0;
  21620. + if (memcmp((char *)&dhcpreply->bp_siaddr, (char *)&zeroIP, sizeof(in_addr)) == 0)
  21621. + return 0;
  21622. + if ((memcmp(broadcast, dhcpreply->bp_hwaddr, ETH_ALEN) != 0) &&
  21623. + (memcmp(arptable[ARP_CLIENT].node, dhcpreply->bp_hwaddr, ETH_ALEN) != 0)) {
  21624. + return 0;
  21625. + }
  21626. + arptable[ARP_CLIENT].ipaddr.s_addr = dhcpreply->bp_yiaddr.s_addr;
  21627. + dhcp_addr.s_addr = dhcpreply->bp_yiaddr.s_addr;
  21628. + netmask = default_netmask();
  21629. + arptable[ARP_SERVER].ipaddr.s_addr = dhcpreply->bp_siaddr.s_addr;
  21630. + memset(arptable[ARP_SERVER].node, 0, ETH_ALEN); /* Kill arp */
  21631. + arptable[ARP_GATEWAY].ipaddr.s_addr = dhcpreply->bp_giaddr.s_addr;
  21632. + memset(arptable[ARP_GATEWAY].node, 0, ETH_ALEN); /* Kill arp */
  21633. + /* We don't care bootpreply->bp_file. It must be 'pxegrub' */
  21634. + memcpy((char *)rfc1533_venddata, (char *)(dhcpreply->bp_vend), len);
  21635. + decode_rfc1533(rfc1533_venddata, 0, len, 1);
  21636. + return(1);
  21637. +}
  21638. +
  21639. +int dhcp(void)
  21640. +{
  21641. + int retry;
  21642. + int reqretry;
  21643. + struct dhcpip_t ip;
  21644. + unsigned long starttime;
  21645. +
  21646. + if(!grub_eth_probe())
  21647. + return 0;
  21648. +
  21649. + network_ready = 0;
  21650. +
  21651. + memset(&ip, 0, sizeof(struct dhcpip_t));
  21652. + ip.bp.bp_op = BOOTP_REQUEST;
  21653. + ip.bp.bp_htype = 1;
  21654. + ip.bp.bp_hlen = ETH_ALEN;
  21655. + starttime = currticks();
  21656. + /* Use lower 32 bits of node address, more likely to be
  21657. + distinct than the time since booting */
  21658. + memcpy(&xid, &arptable[ARP_CLIENT].node[2], sizeof(xid));
  21659. + ip.bp.bp_xid = xid += htonl(starttime);
  21660. + memcpy(ip.bp.bp_hwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  21661. + memcpy(ip.bp.bp_vend, rfc1533_cookie_dhcp, sizeof rfc1533_cookie_dhcp); /* request RFC-style options */
  21662. + memcpy(ip.bp.bp_vend + sizeof rfc1533_cookie_dhcp, dhcpdiscover, sizeof dhcpdiscover);
  21663. +
  21664. + for (retry = 0; retry < MAX_BOOTP_RETRIES; ) {
  21665. + long timeout;
  21666. +
  21667. + rx_qdrain();
  21668. +
  21669. + udp_transmit(IP_BROADCAST, BOOTP_CLIENT, BOOTP_SERVER,
  21670. + sizeof(struct bootpip_t), &ip);
  21671. + timeout = rfc2131_sleep_interval(TIMEOUT, retry++);
  21672. + if (await_reply(await_dhcp, 0, NULL, timeout)) {
  21673. + /* If not a DHCPOFFER then must be just a
  21674. + BOOTP reply, be backward compatible with
  21675. + BOOTP then. Jscott report a bug here, but I
  21676. + don't know how it happened */
  21677. + if (dhcp_reply != DHCPOFFER){
  21678. + network_ready = 1;
  21679. + return(1);
  21680. + }
  21681. + dhcp_reply = 0;
  21682. + memcpy(ip.bp.bp_vend, rfc1533_cookie_dhcp, sizeof rfc1533_cookie_dhcp);
  21683. + memcpy(ip.bp.bp_vend + sizeof rfc1533_cookie_dhcp, dhcprequest, sizeof dhcprequest);
  21684. + /* Beware: the magic numbers 9 and 15 depend on
  21685. + the layout of dhcprequest */
  21686. + memcpy(&ip.bp.bp_vend[9], &dhcp_server, sizeof(in_addr));
  21687. + memcpy(&ip.bp.bp_vend[15], &dhcp_addr, sizeof(in_addr));
  21688. + for (reqretry = 0; reqretry < MAX_BOOTP_RETRIES; ) {
  21689. + udp_transmit(IP_BROADCAST, BOOTP_CLIENT, BOOTP_SERVER,
  21690. + sizeof(struct bootpip_t), &ip);
  21691. + dhcp_reply=0;
  21692. + timeout = rfc2131_sleep_interval(TIMEOUT, reqretry++);
  21693. + if (await_reply(await_dhcp, 0, NULL, timeout))
  21694. + if (dhcp_reply == DHCPACK){
  21695. + network_ready = 1;
  21696. + return(1);
  21697. + }
  21698. + if (user_abort)
  21699. + return 0;
  21700. + }
  21701. + }
  21702. + if (user_abort)
  21703. + return 0;
  21704. + ip.bp.bp_secs = htons((currticks()-starttime)/TICKS_PER_SEC);
  21705. + }
  21706. + return(0);
  21707. +}
  21708. +
  21709. +#ifdef MULTICAST_LEVEL2
  21710. +static void send_igmp_reports(unsigned long now)
  21711. +{
  21712. + int i;
  21713. + for(i = 0; i < MAX_IGMP; i++) {
  21714. + if (igmptable[i].time && (now >= igmptable[i].time)) {
  21715. + struct igmp_ip_t igmp;
  21716. + igmp.router_alert[0] = 0x94;
  21717. + igmp.router_alert[1] = 0x04;
  21718. + igmp.router_alert[2] = 0;
  21719. + igmp.router_alert[3] = 0;
  21720. + build_ip_hdr(igmptable[i].group.s_addr,
  21721. + 1, IP_IGMP, sizeof(igmp.router_alert), sizeof(igmp), &igmp);
  21722. + igmp.igmp.type = IGMPv2_REPORT;
  21723. + if (last_igmpv1 &&
  21724. + (now < last_igmpv1 + IGMPv1_ROUTER_PRESENT_TIMEOUT)) {
  21725. + igmp.igmp.type = IGMPv1_REPORT;
  21726. + }
  21727. + igmp.igmp.response_time = 0;
  21728. + igmp.igmp.chksum = 0;
  21729. + igmp.igmp.group.s_addr = igmptable[i].group.s_addr;
  21730. + igmp.igmp.chksum = ipchksum(&igmp.igmp, sizeof(igmp.igmp));
  21731. + ip_transmit(sizeof(igmp), &igmp);
  21732. +#ifdef MDEBUG
  21733. + printf("Sent IGMP report to: %@\n", igmp.igmp.group.s_addr);
  21734. +#endif
  21735. + /* Don't send another igmp report until asked */
  21736. + igmptable[i].time = 0;
  21737. + }
  21738. + }
  21739. +}
  21740. +
  21741. +static void process_igmp(struct iphdr *ip, unsigned long now)
  21742. +{
  21743. + struct igmp *igmp;
  21744. + int i;
  21745. + unsigned iplen = 0;
  21746. + if (!ip || (ip->protocol == IP_IGMP) ||
  21747. + (nic.packetlen < sizeof(struct iphdr) + sizeof(struct igmp))) {
  21748. + return;
  21749. + }
  21750. + iplen = (ip->verhdrlen & 0xf)*4;
  21751. + igmp = (struct igmp *)&nic.packet[sizeof(struct iphdr)];
  21752. + if (ipchksum(igmp, ntohs(ip->len) - iplen) != 0)
  21753. + return;
  21754. + if ((igmp->type == IGMP_QUERY) &&
  21755. + (ip->dest.s_addr == htonl(GROUP_ALL_HOSTS))) {
  21756. + unsigned long interval = IGMP_INTERVAL;
  21757. + if (igmp->response_time == 0) {
  21758. + last_igmpv1 = now;
  21759. + } else {
  21760. + interval = (igmp->response_time * TICKS_PER_SEC)/10;
  21761. + }
  21762. +
  21763. +#ifdef MDEBUG
  21764. + printf("Received IGMP query for: %@\n", igmp->group.s_addr);
  21765. +#endif
  21766. + for(i = 0; i < MAX_IGMP; i++) {
  21767. + uint32_t group = igmptable[i].group.s_addr;
  21768. + if ((group == 0) || (group == igmp->group.s_addr)) {
  21769. + unsigned long time;
  21770. + time = currticks() + rfc1112_sleep_interval(interval, 0);
  21771. + if (time < igmptable[i].time) {
  21772. + igmptable[i].time = time;
  21773. + }
  21774. + }
  21775. + }
  21776. + }
  21777. + if (((igmp->type == IGMPv1_REPORT) || (igmp->type == IGMPv2_REPORT)) &&
  21778. + (ip->dest.s_addr == igmp->group.s_addr)) {
  21779. +#ifdef MDEBUG
  21780. + printf("Received IGMP report for: %@\n", igmp->group.s_addr);
  21781. +#endif
  21782. + for(i = 0; i < MAX_IGMP; i++) {
  21783. + if ((igmptable[i].group.s_addr == igmp->group.s_addr) &&
  21784. + igmptable[i].time != 0) {
  21785. + igmptable[i].time = 0;
  21786. + }
  21787. + }
  21788. + }
  21789. +}
  21790. +
  21791. +void leave_group(int slot)
  21792. +{
  21793. + /* Be very stupid and always send a leave group message if
  21794. + * I have subscribed. Imperfect but it is standards
  21795. + * compliant, easy and reliable to implement.
  21796. + *
  21797. + * The optimal group leave method is to only send leave when,
  21798. + * we were the last host to respond to a query on this group,
  21799. + * and igmpv1 compatibility is not enabled.
  21800. + */
  21801. + if (igmptable[slot].group.s_addr) {
  21802. + struct igmp_ip_t igmp;
  21803. + igmp.router_alert[0] = 0x94;
  21804. + igmp.router_alert[1] = 0x04;
  21805. + igmp.router_alert[2] = 0;
  21806. + igmp.router_alert[3] = 0;
  21807. + build_ip_hdr(htonl(GROUP_ALL_HOSTS),
  21808. + 1, IP_IGMP, sizeof(igmp.router_alert), sizeof(igmp), &igmp);
  21809. + igmp.igmp.type = IGMP_LEAVE;
  21810. + igmp.igmp.response_time = 0;
  21811. + igmp.igmp.chksum = 0;
  21812. + igmp.igmp.group.s_addr = igmptable[slot].group.s_addr;
  21813. + igmp.igmp.chksum = ipchksum(&igmp.igmp, sizeof(igmp));
  21814. + ip_transmit(sizeof(igmp), &igmp);
  21815. +#ifdef MDEBUG
  21816. + printf("Sent IGMP leave for: %@\n", igmp.igmp.group.s_addr);
  21817. +#endif
  21818. + }
  21819. + memset(&igmptable[slot], 0, sizeof(igmptable[0]));
  21820. +}
  21821. +
  21822. +void join_group(int slot, unsigned long group)
  21823. +{
  21824. + /* I have already joined */
  21825. + if (igmptable[slot].group.s_addr == group)
  21826. + return;
  21827. + if (igmptable[slot].group.s_addr) {
  21828. + leave_group(slot);
  21829. + }
  21830. + /* Only join a group if we are given a multicast ip, this way
  21831. + * code can be given a non-multicast (broadcast or unicast ip)
  21832. + * and still work...
  21833. + */
  21834. + if ((group & htonl(MULTICAST_MASK)) == htonl(MULTICAST_NETWORK)) {
  21835. + igmptable[slot].group.s_addr = group;
  21836. + igmptable[slot].time = currticks();
  21837. + }
  21838. +}
  21839. +#else
  21840. +#define send_igmp_reports(now);
  21841. +#define process_igmp(ip, now)
  21842. +#endif
  21843. +
  21844. +/**************************************************************************
  21845. +AWAIT_REPLY - Wait until we get a response for our request
  21846. +************f**************************************************************/
  21847. +int await_reply(reply_t reply, int ival, void *ptr, long timeout)
  21848. +{
  21849. + unsigned long time, now;
  21850. + struct iphdr *ip;
  21851. + unsigned iplen = 0;
  21852. + struct udphdr *udp;
  21853. + unsigned short ptype;
  21854. + int result;
  21855. +
  21856. + user_abort = 0;
  21857. +
  21858. + time = timeout + currticks();
  21859. + /* The timeout check is done below. The timeout is only checked if
  21860. + * there is no packet in the Rx queue. This assumes that eth_poll()
  21861. + * needs a negligible amount of time.
  21862. + */
  21863. + for (;;) {
  21864. + now = currticks();
  21865. + send_igmp_reports(now);
  21866. + result = eth_poll(1);
  21867. + if (result == 0) {
  21868. + /* We don't have anything */
  21869. +
  21870. + /* Check for abort key only if the Rx queue is empty -
  21871. + * as long as we have something to process, don't
  21872. + * assume that something failed. It is unlikely that
  21873. + * we have no processing time left between packets. */
  21874. + poll_interruptions();
  21875. + /* Do the timeout after at least a full queue walk. */
  21876. + if ((timeout == 0) || (currticks() > time) || user_abort == 1) {
  21877. + break;
  21878. + }
  21879. + continue;
  21880. + }
  21881. +
  21882. + /* We have something! */
  21883. +
  21884. + /* Find the Ethernet packet type */
  21885. + if (nic.packetlen >= ETH_HLEN) {
  21886. + ptype = ((unsigned short) nic.packet[12]) << 8
  21887. + | ((unsigned short) nic.packet[13]);
  21888. + } else continue; /* what else could we do with it? */
  21889. + /* Verify an IP header */
  21890. + ip = 0;
  21891. + if ((ptype == IP) && (nic.packetlen >= ETH_HLEN + sizeof(struct iphdr))) {
  21892. + unsigned ipoptlen;
  21893. + ip = (struct iphdr *)&nic.packet[ETH_HLEN];
  21894. + if ((ip->verhdrlen < 0x45) || (ip->verhdrlen > 0x4F))
  21895. + continue;
  21896. + iplen = (ip->verhdrlen & 0xf) * 4;
  21897. + if (ipchksum(ip, iplen) != 0)
  21898. + continue;
  21899. + if (ip->frags & htons(0x3FFF)) {
  21900. + static int warned_fragmentation = 0;
  21901. + if (!warned_fragmentation) {
  21902. + printf("ALERT: got a fragmented packet - reconfigure your server\n");
  21903. + warned_fragmentation = 1;
  21904. + }
  21905. + continue;
  21906. + }
  21907. + if (ntohs(ip->len) > ETH_MAX_MTU)
  21908. + continue;
  21909. +
  21910. + ipoptlen = iplen - sizeof(struct iphdr);
  21911. + if (ipoptlen) {
  21912. + /* Delete the ip options, to guarantee
  21913. + * good alignment, and make etherboot simpler.
  21914. + */
  21915. + memmove(&nic.packet[ETH_HLEN + sizeof(struct iphdr)],
  21916. + &nic.packet[ETH_HLEN + iplen],
  21917. + nic.packetlen - ipoptlen);
  21918. + nic.packetlen -= ipoptlen;
  21919. + }
  21920. + }
  21921. + udp = 0;
  21922. + if (ip && (ip->protocol == IP_UDP) &&
  21923. + (nic.packetlen >= ETH_HLEN + sizeof(struct iphdr) + sizeof(struct udphdr))) {
  21924. + udp = (struct udphdr *)&nic.packet[ETH_HLEN + sizeof(struct iphdr)];
  21925. +
  21926. + /* Make certain we have a reasonable packet length */
  21927. + if (ntohs(udp->len) > (ntohs(ip->len) - iplen))
  21928. + continue;
  21929. +
  21930. + if (udp->chksum && udpchksum(ip, udp)) {
  21931. + printf("UDP checksum error\n");
  21932. + continue;
  21933. + }
  21934. + }
  21935. + result = reply(ival, ptr, ptype, ip, udp);
  21936. + if (result > 0) {
  21937. + return result;
  21938. + }
  21939. +
  21940. + /* If it isn't a packet the upper layer wants see if there is a default
  21941. + * action. This allows us reply to arp and igmp queryies.
  21942. + */
  21943. + if ((ptype == ARP) &&
  21944. + (nic.packetlen >= ETH_HLEN + sizeof(struct arprequest))) {
  21945. + struct arprequest *arpreply;
  21946. + unsigned long tmp;
  21947. +
  21948. + arpreply = (struct arprequest *)&nic.packet[ETH_HLEN];
  21949. + memcpy(&tmp, arpreply->tipaddr, sizeof(in_addr));
  21950. + if ((arpreply->opcode == htons(ARP_REQUEST)) &&
  21951. + (tmp == arptable[ARP_CLIENT].ipaddr.s_addr)) {
  21952. + arpreply->opcode = htons(ARP_REPLY);
  21953. + memcpy(arpreply->tipaddr, arpreply->sipaddr, sizeof(in_addr));
  21954. + memcpy(arpreply->thwaddr, arpreply->shwaddr, ETH_ALEN);
  21955. + memcpy(arpreply->sipaddr, &arptable[ARP_CLIENT].ipaddr, sizeof(in_addr));
  21956. + memcpy(arpreply->shwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  21957. + eth_transmit(arpreply->thwaddr, ARP,
  21958. + sizeof(struct arprequest),
  21959. + arpreply);
  21960. +#ifdef MDEBUG
  21961. + memcpy(&tmp, arpreply->tipaddr, sizeof(in_addr));
  21962. + printf("Sent ARP reply to: %@\n",tmp);
  21963. +#endif /* MDEBUG */
  21964. + }
  21965. + }
  21966. + process_igmp(ip, now);
  21967. + }
  21968. + return(0);
  21969. +}
  21970. +
  21971. +#ifdef REQUIRE_VCI_ETHERBOOT
  21972. +/**************************************************************************
  21973. +FIND_VCI_ETHERBOOT - Looks for "Etherboot" in Vendor Encapsulated Identifiers
  21974. +On entry p points to byte count of VCI options
  21975. +**************************************************************************/
  21976. +static int find_vci_etherboot(unsigned char *p)
  21977. +{
  21978. + unsigned char *end = p + 1 + *p;
  21979. +
  21980. + for (p++; p < end; ) {
  21981. + if (*p == RFC2132_VENDOR_CLASS_ID) {
  21982. + if (strncmp("Etherboot", p + 2, sizeof("Etherboot") - 1) == 0)
  21983. + return (1);
  21984. + } else if (*p == RFC1533_END)
  21985. + return (0);
  21986. + p += TAG_LEN(p) + 2;
  21987. + }
  21988. + return (0);
  21989. +}
  21990. +#endif /* REQUIRE_VCI_ETHERBOOT */
  21991. +
  21992. +/**
  21993. + * decode_rfc1533
  21994. + *
  21995. + * Decodes RFC1533 header
  21996. + **/
  21997. +int decode_rfc1533(unsigned char *p, unsigned int block, unsigned int len, int eof)
  21998. +{
  21999. + static unsigned char *extdata = NULL, *extend = NULL;
  22000. + unsigned char *extpath = NULL;
  22001. + unsigned char *endp;
  22002. +
  22003. + if (block == 0) {
  22004. + end_of_rfc1533 = NULL;
  22005. + if (memcmp(p, rfc1533_cookie, sizeof(rfc1533_cookie)))
  22006. + return(0); /* no RFC 1533 header found */
  22007. + p += 4;
  22008. + endp = p + len;
  22009. + } else {
  22010. + if (block == 1) {
  22011. + if (memcmp(p, rfc1533_cookie, sizeof(rfc1533_cookie)))
  22012. + return(0); /* no RFC 1533 header found */
  22013. + p += 4;
  22014. + len -= 4; }
  22015. + if (extend + len <= (unsigned char *)
  22016. + rfc1533_venddata + sizeof(rfc1533_venddata)) {
  22017. + memcpy(extend, p, len);
  22018. + extend += len;
  22019. + } else {
  22020. + printf("Overflow in vendor data buffer! Aborting...\n");
  22021. + *extdata = RFC1533_END;
  22022. + return(0);
  22023. + }
  22024. + p = extdata; endp = extend;
  22025. + }
  22026. + if (!eof)
  22027. + return 1;
  22028. + while (p < endp) {
  22029. + unsigned char c = *p;
  22030. + if (c == RFC1533_PAD) {
  22031. + p++;
  22032. + continue;
  22033. + }
  22034. + else if (c == RFC1533_END) {
  22035. + end_of_rfc1533 = endp = p;
  22036. + continue;
  22037. + }
  22038. + else if (c == RFC1533_NETMASK)
  22039. + memcpy(&netmask, p+2, sizeof(in_addr));
  22040. + else if (c == RFC1533_GATEWAY) {
  22041. + /* This is a little simplistic, but it will
  22042. + usually be sufficient.
  22043. + Take only the first entry */
  22044. + if (TAG_LEN(p) >= sizeof(in_addr))
  22045. + memcpy(&arptable[ARP_GATEWAY].ipaddr, p+2, sizeof(in_addr));
  22046. + }
  22047. + else if (c == RFC1533_EXTENSIONPATH)
  22048. + extpath = p;
  22049. + else if (c == RFC2132_MSG_TYPE)
  22050. + dhcp_reply=*(p+2);
  22051. + else if (c == RFC2132_SRV_ID)
  22052. + memcpy(&dhcp_server, p+2, sizeof(in_addr));
  22053. + else if (c == RFC1533_HOSTNAME) {
  22054. + hostname = p + 2;
  22055. + hostnamelen = *(p + 1);
  22056. + }
  22057. + else if (c == RFC1533_VENDOR_CONFIGFILE){
  22058. + int l = TAG_LEN (p);
  22059. +
  22060. + /* Eliminate the trailing NULs according to RFC 2132. */
  22061. + while (*(p + 2 + l - 1) == '\000' && l > 0)
  22062. + l--;
  22063. +
  22064. + /* XXX: Should check if LEN is less than the maximum length
  22065. + of CONFIG_FILE. This kind of robustness will be a goal
  22066. + in GRUB 1.0. */
  22067. + memcpy (config_file, p + 2, l);
  22068. + config_file[l] = 0;
  22069. + }
  22070. + else {
  22071. + ;
  22072. + }
  22073. + p += TAG_LEN(p) + 2;
  22074. + }
  22075. + extdata = extend = endp;
  22076. + if (block <= 0 && extpath != NULL) {
  22077. + char fname[64];
  22078. + if (TAG_LEN(extpath) >= sizeof(fname)){
  22079. + printf("Overflow in vendor data buffer! Aborting...\n");
  22080. + *extdata = RFC1533_END;
  22081. + return(0);
  22082. + }
  22083. + memcpy(fname, extpath+2, TAG_LEN(extpath));
  22084. + fname[(int)TAG_LEN(extpath)] = '\0';
  22085. + printf("Loading BOOTP-extension file: %s\n",fname);
  22086. + tftp_file_read(fname, decode_rfc1533);
  22087. + }
  22088. + return 1; /* proceed with next block */
  22089. +}
  22090. +
  22091. +
  22092. +/* FIXME double check TWO_SECOND_DIVISOR */
  22093. +#define TWO_SECOND_DIVISOR (RAND_MAX/TICKS_PER_SEC)
  22094. +/**************************************************************************
  22095. +RFC2131_SLEEP_INTERVAL - sleep for expotentially longer times (base << exp) +- 1 sec)
  22096. +**************************************************************************/
  22097. +long rfc2131_sleep_interval(long base, int exp)
  22098. +{
  22099. + unsigned long tmo;
  22100. +#ifdef BACKOFF_LIMIT
  22101. + if (exp > BACKOFF_LIMIT)
  22102. + exp = BACKOFF_LIMIT;
  22103. +#endif
  22104. + tmo = (base << exp) + (TICKS_PER_SEC - (random()/TWO_SECOND_DIVISOR));
  22105. + return tmo;
  22106. +}
  22107. +
  22108. +#ifdef MULTICAST_LEVEL2
  22109. +/**************************************************************************
  22110. +RFC1112_SLEEP_INTERVAL - sleep for expotentially longer times, up to (base << exp)
  22111. +**************************************************************************/
  22112. +long rfc1112_sleep_interval(long base, int exp)
  22113. +{
  22114. + unsigned long divisor, tmo;
  22115. +#ifdef BACKOFF_LIMIT
  22116. + if (exp > BACKOFF_LIMIT)
  22117. + exp = BACKOFF_LIMIT;
  22118. +#endif
  22119. + divisor = RAND_MAX/(base << exp);
  22120. + tmo = random()/divisor;
  22121. + return tmo;
  22122. +}
  22123. +#endif /* MULTICAST_LEVEL_2 */
  22124. +/* ifconfig - configure network interface. */
  22125. +int
  22126. +ifconfig (char *ip, char *sm, char *gw, char *svr)
  22127. +{
  22128. + in_addr tmp;
  22129. +
  22130. + if (sm)
  22131. + {
  22132. + if (! inet_aton (sm, &tmp))
  22133. + return 0;
  22134. +
  22135. + netmask = tmp.s_addr;
  22136. + }
  22137. +
  22138. + if (ip)
  22139. + {
  22140. + if (! inet_aton (ip, &arptable[ARP_CLIENT].ipaddr))
  22141. + return 0;
  22142. +
  22143. + if (! netmask && ! sm)
  22144. + netmask = default_netmask ();
  22145. + }
  22146. +
  22147. + if (gw && ! inet_aton (gw, &arptable[ARP_GATEWAY].ipaddr))
  22148. + return 0;
  22149. +
  22150. + /* Clear out the ARP entry. */
  22151. + grub_memset (arptable[ARP_GATEWAY].node, 0, ETH_ALEN);
  22152. +
  22153. + if (svr && ! inet_aton (svr, &arptable[ARP_SERVER].ipaddr))
  22154. + return 0;
  22155. +
  22156. + /* Likewise. */
  22157. + grub_memset (arptable[ARP_SERVER].node, 0, ETH_ALEN);
  22158. +
  22159. + if (ip || sm)
  22160. + {
  22161. + if (IP_BROADCAST == (netmask | arptable[ARP_CLIENT].ipaddr.s_addr)
  22162. + || netmask == (netmask | arptable[ARP_CLIENT].ipaddr.s_addr)
  22163. + || ! netmask)
  22164. + network_ready = 0;
  22165. + else
  22166. + network_ready = 1;
  22167. + }
  22168. +
  22169. + return 1;
  22170. +}
  22171. +
  22172. +/*
  22173. + * print_network_configuration
  22174. + *
  22175. + * Output the network configuration. It may broke the graphic console now.:-(
  22176. + */
  22177. +void print_network_configuration (void)
  22178. +{
  22179. + EnterFunction("print_network_configuration");
  22180. + if (! grub_eth_probe ())
  22181. + grub_printf ("No ethernet card found.\n");
  22182. + else if (! network_ready)
  22183. + grub_printf ("Not initialized yet.\n");
  22184. + else {
  22185. + etherboot_printf ("Address: %@\n", arptable[ARP_CLIENT].ipaddr.s_addr);
  22186. + etherboot_printf ("Netmask: %@\n", netmask);
  22187. + etherboot_printf ("Server: %@\n", arptable[ARP_SERVER].ipaddr.s_addr);
  22188. + etherboot_printf ("Gateway: %@\n", arptable[ARP_GATEWAY].ipaddr.s_addr);
  22189. + }
  22190. + LeaveFunction("print_network_configuration");
  22191. +}
  22192. +
  22193. +/**
  22194. + * cleanup_net
  22195. + *
  22196. + * Mark network unusable, and disable NICs
  22197. + */
  22198. +void cleanup_net (void)
  22199. +{
  22200. + if (network_ready){
  22201. + /* Stop receiving packets. */
  22202. + eth_disable ();
  22203. + network_ready = 0;
  22204. + }
  22205. +}
  22206. Index: b/netboot/nic.h
  22207. ===================================================================
  22208. --- a/netboot/nic.h
  22209. +++ b/netboot/nic.h
  22210. @@ -8,24 +8,38 @@
  22211. #ifndef NIC_H
  22212. #define NIC_H
  22213. +#include "dev.h"
  22214. +
  22215. +typedef enum {
  22216. + DISABLE = 0,
  22217. + ENABLE,
  22218. + FORCE
  22219. +} irq_action_t;
  22220. +
  22221. /*
  22222. * Structure returned from eth_probe and passed to other driver
  22223. * functions.
  22224. */
  22225. -
  22226. struct nic
  22227. {
  22228. - void (*reset)P((struct nic *));
  22229. - int (*poll)P((struct nic *));
  22230. + struct dev dev; /* This must come first */
  22231. + int (*poll)P((struct nic *, int retrieve));
  22232. void (*transmit)P((struct nic *, const char *d,
  22233. unsigned int t, unsigned int s, const char *p));
  22234. - void (*disable)P((struct nic *));
  22235. + void (*irq)P((struct nic *, irq_action_t));
  22236. int flags; /* driver specific flags */
  22237. struct rom_info *rom_info; /* -> rom_info from main */
  22238. unsigned char *node_addr;
  22239. - char *packet;
  22240. + unsigned char *packet;
  22241. unsigned int packetlen;
  22242. + unsigned int ioaddr;
  22243. + unsigned char irqno;
  22244. void *priv_data; /* driver can hang private data here */
  22245. };
  22246. +extern int eth_probe(struct dev *dev);
  22247. +extern int eth_poll(int retrieve);
  22248. +extern void eth_transmit(const char *d, unsigned int t, unsigned int s, const void *p);
  22249. +extern void eth_disable(void);
  22250. +extern void eth_irq(irq_action_t action);
  22251. #endif /* NIC_H */
  22252. Index: b/netboot/ns83820.c
  22253. ===================================================================
  22254. --- /dev/null
  22255. +++ b/netboot/ns83820.c
  22256. @@ -0,0 +1,1020 @@
  22257. +/**************************************************************************
  22258. +* ns83820.c: Etherboot device driver for the National Semiconductor 83820
  22259. +* Written 2004 by Timothy Legge <tlegge@rogers.com>
  22260. +*
  22261. +* This program is free software; you can redistribute it and/or modify
  22262. +* it under the terms of the GNU General Public License as published by
  22263. +* the Free Software Foundation; either version 2 of the License, or
  22264. +* (at your option) any later version.
  22265. +*
  22266. +* This program is distributed in the hope that it will be useful,
  22267. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  22268. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22269. +* GNU General Public License for more details.
  22270. +*
  22271. +* You should have received a copy of the GNU General Public License
  22272. +* along with this program; if not, write to the Free Software
  22273. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22274. +*
  22275. +* Portions of this code based on:
  22276. +* ns83820.c by Benjamin LaHaise with contributions
  22277. +* for Linux kernel 2.4.x.
  22278. +*
  22279. +* Linux Driver Version 0.20, 20020610
  22280. +*
  22281. +* This development of this Etherboot driver was funded by:
  22282. +*
  22283. +* NXTV: http://www.nxtv.com/
  22284. +*
  22285. +* REVISION HISTORY:
  22286. +* ================
  22287. +*
  22288. +* v1.0 02-16-2004 timlegge Initial port of Linux driver
  22289. +* v1.1 02-19-2004 timlegge More rohbust transmit and poll
  22290. +*
  22291. +* Indent Options: indent -kr -i8
  22292. +***************************************************************************/
  22293. +
  22294. +/* to get some global routines like printf */
  22295. +#include "etherboot.h"
  22296. +/* to get the interface to the body of the program */
  22297. +#include "nic.h"
  22298. +/* to get the PCI support functions, if this is a PCI NIC */
  22299. +#include "pci.h"
  22300. +
  22301. +#if ARCH == ia64 /* Support 64-bit addressing */
  22302. +#define USE_64BIT_ADDR
  22303. +#endif
  22304. +
  22305. +//#define DDEBUG
  22306. +#ifdef DDEBUG
  22307. +#define dprintf(x) printf x
  22308. +#else
  22309. +#define dprintf(x)
  22310. +#endif
  22311. +
  22312. +typedef unsigned char u8;
  22313. +typedef signed char s8;
  22314. +typedef unsigned short u16;
  22315. +typedef signed short s16;
  22316. +typedef unsigned int u32;
  22317. +typedef signed int s32;
  22318. +
  22319. +#define HZ 100
  22320. +
  22321. +/* Condensed operations for readability. */
  22322. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  22323. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  22324. +
  22325. +/* NIC specific static variables go here */
  22326. +
  22327. +/* Global parameters. See MODULE_PARM near the bottom. */
  22328. +// static int ihr = 2;
  22329. +static int reset_phy = 0;
  22330. +static int lnksts = 0; /* CFG_LNKSTS bit polarity */
  22331. +
  22332. +#if defined(CONFIG_HIGHMEM64G) || defined(__ia64__)
  22333. +#define USE_64BIT_ADDR "+"
  22334. +#endif
  22335. +
  22336. +#if defined(USE_64BIT_ADDR)
  22337. +#define TRY_DAC 1
  22338. +#else
  22339. +#define TRY_DAC 0
  22340. +#endif
  22341. +
  22342. +/* tunables */
  22343. +#define RX_BUF_SIZE 1500 /* 8192 */
  22344. +
  22345. +/* Must not exceed ~65000. */
  22346. +#define NR_RX_DESC 64
  22347. +#define NR_TX_DESC 1
  22348. +
  22349. + /* not tunable *//* Extra 6 bytes for 64 bit alignment (divisable by 8) */
  22350. +#define REAL_RX_BUF_SIZE (RX_BUF_SIZE + 14 + 6) /* rx/tx mac addr + type */
  22351. +
  22352. +#define MIN_TX_DESC_FREE 8
  22353. +
  22354. +/* register defines */
  22355. +#define CFGCS 0x04
  22356. +
  22357. +#define CR_TXE 0x00000001
  22358. +#define CR_TXD 0x00000002
  22359. +/* Ramit : Here's a tip, don't do a RXD immediately followed by an RXE
  22360. + * The Receive engine skips one descriptor and moves
  22361. + * onto the next one!! */
  22362. +#define CR_RXE 0x00000004
  22363. +#define CR_RXD 0x00000008
  22364. +#define CR_TXR 0x00000010
  22365. +#define CR_RXR 0x00000020
  22366. +#define CR_SWI 0x00000080
  22367. +#define CR_RST 0x00000100
  22368. +
  22369. +#define PTSCR_EEBIST_FAIL 0x00000001
  22370. +#define PTSCR_EEBIST_EN 0x00000002
  22371. +#define PTSCR_EELOAD_EN 0x00000004
  22372. +#define PTSCR_RBIST_FAIL 0x000001b8
  22373. +#define PTSCR_RBIST_DONE 0x00000200
  22374. +#define PTSCR_RBIST_EN 0x00000400
  22375. +#define PTSCR_RBIST_RST 0x00002000
  22376. +
  22377. +#define MEAR_EEDI 0x00000001
  22378. +#define MEAR_EEDO 0x00000002
  22379. +#define MEAR_EECLK 0x00000004
  22380. +#define MEAR_EESEL 0x00000008
  22381. +#define MEAR_MDIO 0x00000010
  22382. +#define MEAR_MDDIR 0x00000020
  22383. +#define MEAR_MDC 0x00000040
  22384. +
  22385. +#define ISR_TXDESC3 0x40000000
  22386. +#define ISR_TXDESC2 0x20000000
  22387. +#define ISR_TXDESC1 0x10000000
  22388. +#define ISR_TXDESC0 0x08000000
  22389. +#define ISR_RXDESC3 0x04000000
  22390. +#define ISR_RXDESC2 0x02000000
  22391. +#define ISR_RXDESC1 0x01000000
  22392. +#define ISR_RXDESC0 0x00800000
  22393. +#define ISR_TXRCMP 0x00400000
  22394. +#define ISR_RXRCMP 0x00200000
  22395. +#define ISR_DPERR 0x00100000
  22396. +#define ISR_SSERR 0x00080000
  22397. +#define ISR_RMABT 0x00040000
  22398. +#define ISR_RTABT 0x00020000
  22399. +#define ISR_RXSOVR 0x00010000
  22400. +#define ISR_HIBINT 0x00008000
  22401. +#define ISR_PHY 0x00004000
  22402. +#define ISR_PME 0x00002000
  22403. +#define ISR_SWI 0x00001000
  22404. +#define ISR_MIB 0x00000800
  22405. +#define ISR_TXURN 0x00000400
  22406. +#define ISR_TXIDLE 0x00000200
  22407. +#define ISR_TXERR 0x00000100
  22408. +#define ISR_TXDESC 0x00000080
  22409. +#define ISR_TXOK 0x00000040
  22410. +#define ISR_RXORN 0x00000020
  22411. +#define ISR_RXIDLE 0x00000010
  22412. +#define ISR_RXEARLY 0x00000008
  22413. +#define ISR_RXERR 0x00000004
  22414. +#define ISR_RXDESC 0x00000002
  22415. +#define ISR_RXOK 0x00000001
  22416. +
  22417. +#define TXCFG_CSI 0x80000000
  22418. +#define TXCFG_HBI 0x40000000
  22419. +#define TXCFG_MLB 0x20000000
  22420. +#define TXCFG_ATP 0x10000000
  22421. +#define TXCFG_ECRETRY 0x00800000
  22422. +#define TXCFG_BRST_DIS 0x00080000
  22423. +#define TXCFG_MXDMA1024 0x00000000
  22424. +#define TXCFG_MXDMA512 0x00700000
  22425. +#define TXCFG_MXDMA256 0x00600000
  22426. +#define TXCFG_MXDMA128 0x00500000
  22427. +#define TXCFG_MXDMA64 0x00400000
  22428. +#define TXCFG_MXDMA32 0x00300000
  22429. +#define TXCFG_MXDMA16 0x00200000
  22430. +#define TXCFG_MXDMA8 0x00100000
  22431. +
  22432. +#define CFG_LNKSTS 0x80000000
  22433. +#define CFG_SPDSTS 0x60000000
  22434. +#define CFG_SPDSTS1 0x40000000
  22435. +#define CFG_SPDSTS0 0x20000000
  22436. +#define CFG_DUPSTS 0x10000000
  22437. +#define CFG_TBI_EN 0x01000000
  22438. +#define CFG_MODE_1000 0x00400000
  22439. +/* Ramit : Dont' ever use AUTO_1000, it never works and is buggy.
  22440. + * Read the Phy response and then configure the MAC accordingly */
  22441. +#define CFG_AUTO_1000 0x00200000
  22442. +#define CFG_PINT_CTL 0x001c0000
  22443. +#define CFG_PINT_DUPSTS 0x00100000
  22444. +#define CFG_PINT_LNKSTS 0x00080000
  22445. +#define CFG_PINT_SPDSTS 0x00040000
  22446. +#define CFG_TMRTEST 0x00020000
  22447. +#define CFG_MRM_DIS 0x00010000
  22448. +#define CFG_MWI_DIS 0x00008000
  22449. +#define CFG_T64ADDR 0x00004000
  22450. +#define CFG_PCI64_DET 0x00002000
  22451. +#define CFG_DATA64_EN 0x00001000
  22452. +#define CFG_M64ADDR 0x00000800
  22453. +#define CFG_PHY_RST 0x00000400
  22454. +#define CFG_PHY_DIS 0x00000200
  22455. +#define CFG_EXTSTS_EN 0x00000100
  22456. +#define CFG_REQALG 0x00000080
  22457. +#define CFG_SB 0x00000040
  22458. +#define CFG_POW 0x00000020
  22459. +#define CFG_EXD 0x00000010
  22460. +#define CFG_PESEL 0x00000008
  22461. +#define CFG_BROM_DIS 0x00000004
  22462. +#define CFG_EXT_125 0x00000002
  22463. +#define CFG_BEM 0x00000001
  22464. +
  22465. +#define EXTSTS_UDPPKT 0x00200000
  22466. +#define EXTSTS_TCPPKT 0x00080000
  22467. +#define EXTSTS_IPPKT 0x00020000
  22468. +
  22469. +#define SPDSTS_POLARITY (CFG_SPDSTS1 | CFG_SPDSTS0 | CFG_DUPSTS | (lnksts ? CFG_LNKSTS : 0))
  22470. +
  22471. +#define MIBC_MIBS 0x00000008
  22472. +#define MIBC_ACLR 0x00000004
  22473. +#define MIBC_FRZ 0x00000002
  22474. +#define MIBC_WRN 0x00000001
  22475. +
  22476. +#define PCR_PSEN (1 << 31)
  22477. +#define PCR_PS_MCAST (1 << 30)
  22478. +#define PCR_PS_DA (1 << 29)
  22479. +#define PCR_STHI_8 (3 << 23)
  22480. +#define PCR_STLO_4 (1 << 23)
  22481. +#define PCR_FFHI_8K (3 << 21)
  22482. +#define PCR_FFLO_4K (1 << 21)
  22483. +#define PCR_PAUSE_CNT 0xFFFE
  22484. +
  22485. +#define RXCFG_AEP 0x80000000
  22486. +#define RXCFG_ARP 0x40000000
  22487. +#define RXCFG_STRIPCRC 0x20000000
  22488. +#define RXCFG_RX_FD 0x10000000
  22489. +#define RXCFG_ALP 0x08000000
  22490. +#define RXCFG_AIRL 0x04000000
  22491. +#define RXCFG_MXDMA512 0x00700000
  22492. +#define RXCFG_DRTH 0x0000003e
  22493. +#define RXCFG_DRTH0 0x00000002
  22494. +
  22495. +#define RFCR_RFEN 0x80000000
  22496. +#define RFCR_AAB 0x40000000
  22497. +#define RFCR_AAM 0x20000000
  22498. +#define RFCR_AAU 0x10000000
  22499. +#define RFCR_APM 0x08000000
  22500. +#define RFCR_APAT 0x07800000
  22501. +#define RFCR_APAT3 0x04000000
  22502. +#define RFCR_APAT2 0x02000000
  22503. +#define RFCR_APAT1 0x01000000
  22504. +#define RFCR_APAT0 0x00800000
  22505. +#define RFCR_AARP 0x00400000
  22506. +#define RFCR_MHEN 0x00200000
  22507. +#define RFCR_UHEN 0x00100000
  22508. +#define RFCR_ULM 0x00080000
  22509. +
  22510. +#define VRCR_RUDPE 0x00000080
  22511. +#define VRCR_RTCPE 0x00000040
  22512. +#define VRCR_RIPE 0x00000020
  22513. +#define VRCR_IPEN 0x00000010
  22514. +#define VRCR_DUTF 0x00000008
  22515. +#define VRCR_DVTF 0x00000004
  22516. +#define VRCR_VTREN 0x00000002
  22517. +#define VRCR_VTDEN 0x00000001
  22518. +
  22519. +#define VTCR_PPCHK 0x00000008
  22520. +#define VTCR_GCHK 0x00000004
  22521. +#define VTCR_VPPTI 0x00000002
  22522. +#define VTCR_VGTI 0x00000001
  22523. +
  22524. +#define CR 0x00
  22525. +#define CFG 0x04
  22526. +#define MEAR 0x08
  22527. +#define PTSCR 0x0c
  22528. +#define ISR 0x10
  22529. +#define IMR 0x14
  22530. +#define IER 0x18
  22531. +#define IHR 0x1c
  22532. +#define TXDP 0x20
  22533. +#define TXDP_HI 0x24
  22534. +#define TXCFG 0x28
  22535. +#define GPIOR 0x2c
  22536. +#define RXDP 0x30
  22537. +#define RXDP_HI 0x34
  22538. +#define RXCFG 0x38
  22539. +#define PQCR 0x3c
  22540. +#define WCSR 0x40
  22541. +#define PCR 0x44
  22542. +#define RFCR 0x48
  22543. +#define RFDR 0x4c
  22544. +
  22545. +#define SRR 0x58
  22546. +
  22547. +#define VRCR 0xbc
  22548. +#define VTCR 0xc0
  22549. +#define VDR 0xc4
  22550. +#define CCSR 0xcc
  22551. +
  22552. +#define TBICR 0xe0
  22553. +#define TBISR 0xe4
  22554. +#define TANAR 0xe8
  22555. +#define TANLPAR 0xec
  22556. +#define TANER 0xf0
  22557. +#define TESR 0xf4
  22558. +
  22559. +#define TBICR_MR_AN_ENABLE 0x00001000
  22560. +#define TBICR_MR_RESTART_AN 0x00000200
  22561. +
  22562. +#define TBISR_MR_LINK_STATUS 0x00000020
  22563. +#define TBISR_MR_AN_COMPLETE 0x00000004
  22564. +
  22565. +#define TANAR_PS2 0x00000100
  22566. +#define TANAR_PS1 0x00000080
  22567. +#define TANAR_HALF_DUP 0x00000040
  22568. +#define TANAR_FULL_DUP 0x00000020
  22569. +
  22570. +#define GPIOR_GP5_OE 0x00000200
  22571. +#define GPIOR_GP4_OE 0x00000100
  22572. +#define GPIOR_GP3_OE 0x00000080
  22573. +#define GPIOR_GP2_OE 0x00000040
  22574. +#define GPIOR_GP1_OE 0x00000020
  22575. +#define GPIOR_GP3_OUT 0x00000004
  22576. +#define GPIOR_GP1_OUT 0x00000001
  22577. +
  22578. +#define LINK_AUTONEGOTIATE 0x01
  22579. +#define LINK_DOWN 0x02
  22580. +#define LINK_UP 0x04
  22581. +
  22582. +
  22583. +#define __kick_rx() writel(CR_RXE, ns->base + CR)
  22584. +
  22585. +#define kick_rx() do { \
  22586. + dprintf(("kick_rx: maybe kicking\n")); \
  22587. + writel(virt_to_le32desc(&rx_ring[ns->cur_rx]), ns->base + RXDP); \
  22588. + if (ns->next_rx == ns->next_empty) \
  22589. + printf("uh-oh: next_rx == next_empty???\n"); \
  22590. + __kick_rx(); \
  22591. +} while(0)
  22592. +
  22593. +
  22594. +#ifdef USE_64BIT_ADDR
  22595. +#define HW_ADDR_LEN 8
  22596. +#else
  22597. +#define HW_ADDR_LEN 4
  22598. +#endif
  22599. +
  22600. +#define CMDSTS_OWN 0x80000000
  22601. +#define CMDSTS_MORE 0x40000000
  22602. +#define CMDSTS_INTR 0x20000000
  22603. +#define CMDSTS_ERR 0x10000000
  22604. +#define CMDSTS_OK 0x08000000
  22605. +#define CMDSTS_LEN_MASK 0x0000ffff
  22606. +
  22607. +#define CMDSTS_DEST_MASK 0x01800000
  22608. +#define CMDSTS_DEST_SELF 0x00800000
  22609. +#define CMDSTS_DEST_MULTI 0x01000000
  22610. +
  22611. +#define DESC_SIZE 8 /* Should be cache line sized */
  22612. +
  22613. +#ifdef USE_64BIT_ADDR
  22614. +struct ring_desc {
  22615. + uint64_t link;
  22616. + uint64_t bufptr;
  22617. + u32 cmdsts;
  22618. + u32 extsts; /* Extended status field */
  22619. +};
  22620. +#else
  22621. +struct ring_desc {
  22622. + u32 link;
  22623. + u32 bufptr;
  22624. + u32 cmdsts;
  22625. + u32 extsts; /* Extended status field */
  22626. +};
  22627. +#endif
  22628. +
  22629. +/* Define the TX Descriptor */
  22630. +static struct ring_desc tx_ring[NR_TX_DESC]
  22631. + __attribute__ ((aligned(8)));
  22632. +
  22633. +/* Create a static buffer of size REAL_RX_BUF_SIZE for each
  22634. +TX Descriptor. All descriptors point to a
  22635. +part of this buffer */
  22636. +static unsigned char txb[NR_TX_DESC * REAL_RX_BUF_SIZE];
  22637. +
  22638. +/* Define the TX Descriptor */
  22639. +static struct ring_desc rx_ring[NR_RX_DESC]
  22640. + __attribute__ ((aligned(8)));
  22641. +
  22642. +/* Create a static buffer of size REAL_RX_BUF_SIZE for each
  22643. +RX Descriptor All descriptors point to a
  22644. +part of this buffer */
  22645. +static unsigned char rxb[NR_RX_DESC * REAL_RX_BUF_SIZE]
  22646. + __attribute__ ((aligned(8)));
  22647. +
  22648. +/* Private Storage for the NIC */
  22649. +struct ns83820_private {
  22650. + u8 *base;
  22651. + int up;
  22652. + long idle;
  22653. + u32 *next_rx_desc;
  22654. + u16 next_rx, next_empty;
  22655. + u32 cur_rx;
  22656. + u32 *descs;
  22657. + unsigned ihr;
  22658. + u32 CFG_cache;
  22659. + u32 MEAR_cache;
  22660. + u32 IMR_cache;
  22661. + int linkstate;
  22662. + u16 tx_done_idx;
  22663. + u16 tx_idx;
  22664. + u16 tx_intr_idx;
  22665. + u32 phy_descs;
  22666. + u32 *tx_descs;
  22667. +
  22668. +} nsx;
  22669. +static struct ns83820_private *ns;
  22670. +
  22671. +static void phy_intr(struct nic *nic __unused)
  22672. +{
  22673. + static char *speeds[] =
  22674. + { "10", "100", "1000", "1000(?)", "1000F" };
  22675. + u32 cfg, new_cfg;
  22676. + u32 tbisr, tanar, tanlpar;
  22677. + int speed, fullduplex, newlinkstate;
  22678. +
  22679. + cfg = readl(ns->base + CFG) ^ SPDSTS_POLARITY;
  22680. + if (ns->CFG_cache & CFG_TBI_EN) {
  22681. + /* we have an optical transceiver */
  22682. + tbisr = readl(ns->base + TBISR);
  22683. + tanar = readl(ns->base + TANAR);
  22684. + tanlpar = readl(ns->base + TANLPAR);
  22685. + dprintf(("phy_intr: tbisr=%hX, tanar=%hX, tanlpar=%hX\n",
  22686. + tbisr, tanar, tanlpar));
  22687. +
  22688. + if ((fullduplex = (tanlpar & TANAR_FULL_DUP)
  22689. + && (tanar & TANAR_FULL_DUP))) {
  22690. +
  22691. + /* both of us are full duplex */
  22692. + writel(readl(ns->base + TXCFG)
  22693. + | TXCFG_CSI | TXCFG_HBI | TXCFG_ATP,
  22694. + ns->base + TXCFG);
  22695. + writel(readl(ns->base + RXCFG) | RXCFG_RX_FD,
  22696. + ns->base + RXCFG);
  22697. + /* Light up full duplex LED */
  22698. + writel(readl(ns->base + GPIOR) | GPIOR_GP1_OUT,
  22699. + ns->base + GPIOR);
  22700. +
  22701. + } else if (((tanlpar & TANAR_HALF_DUP)
  22702. + && (tanar & TANAR_HALF_DUP))
  22703. + || ((tanlpar & TANAR_FULL_DUP)
  22704. + && (tanar & TANAR_HALF_DUP))
  22705. + || ((tanlpar & TANAR_HALF_DUP)
  22706. + && (tanar & TANAR_FULL_DUP))) {
  22707. +
  22708. + /* one or both of us are half duplex */
  22709. + writel((readl(ns->base + TXCFG)
  22710. + & ~(TXCFG_CSI | TXCFG_HBI)) | TXCFG_ATP,
  22711. + ns->base + TXCFG);
  22712. + writel(readl(ns->base + RXCFG) & ~RXCFG_RX_FD,
  22713. + ns->base + RXCFG);
  22714. + /* Turn off full duplex LED */
  22715. + writel(readl(ns->base + GPIOR) & ~GPIOR_GP1_OUT,
  22716. + ns->base + GPIOR);
  22717. + }
  22718. +
  22719. + speed = 4; /* 1000F */
  22720. +
  22721. + } else {
  22722. + /* we have a copper transceiver */
  22723. + new_cfg =
  22724. + ns->CFG_cache & ~(CFG_SB | CFG_MODE_1000 | CFG_SPDSTS);
  22725. +
  22726. + if (cfg & CFG_SPDSTS1)
  22727. + new_cfg |= CFG_MODE_1000;
  22728. + else
  22729. + new_cfg &= ~CFG_MODE_1000;
  22730. +
  22731. + speed = ((cfg / CFG_SPDSTS0) & 3);
  22732. + fullduplex = (cfg & CFG_DUPSTS);
  22733. +
  22734. + if (fullduplex)
  22735. + new_cfg |= CFG_SB;
  22736. +
  22737. + if ((cfg & CFG_LNKSTS) &&
  22738. + ((new_cfg ^ ns->CFG_cache) & CFG_MODE_1000)) {
  22739. + writel(new_cfg, ns->base + CFG);
  22740. + ns->CFG_cache = new_cfg;
  22741. + }
  22742. +
  22743. + ns->CFG_cache &= ~CFG_SPDSTS;
  22744. + ns->CFG_cache |= cfg & CFG_SPDSTS;
  22745. + }
  22746. +
  22747. + newlinkstate = (cfg & CFG_LNKSTS) ? LINK_UP : LINK_DOWN;
  22748. +
  22749. + if (newlinkstate & LINK_UP && ns->linkstate != newlinkstate) {
  22750. + printf("link now %s mbps, %s duplex and up.\n",
  22751. + speeds[speed], fullduplex ? "full" : "half");
  22752. + } else if (newlinkstate & LINK_DOWN
  22753. + && ns->linkstate != newlinkstate) {
  22754. + printf("link now down.\n");
  22755. + }
  22756. + ns->linkstate = newlinkstate;
  22757. +}
  22758. +static void ns83820_set_multicast(struct nic *nic __unused);
  22759. +static void ns83820_setup_rx(struct nic *nic)
  22760. +{
  22761. + unsigned i;
  22762. + ns->idle = 1;
  22763. + ns->next_rx = 0;
  22764. + ns->next_rx_desc = ns->descs;
  22765. + ns->next_empty = 0;
  22766. + ns->cur_rx = 0;
  22767. +
  22768. +
  22769. + for (i = 0; i < NR_RX_DESC; i++) {
  22770. + rx_ring[i].link = virt_to_le32desc(&rx_ring[i + 1]);
  22771. + rx_ring[i].bufptr =
  22772. + virt_to_le32desc(&rxb[i * REAL_RX_BUF_SIZE]);
  22773. + rx_ring[i].cmdsts = cpu_to_le32(REAL_RX_BUF_SIZE);
  22774. + rx_ring[i].extsts = cpu_to_le32(0);
  22775. + }
  22776. +// No need to wrap the ring
  22777. +// rx_ring[i].link = virt_to_le32desc(&rx_ring[0]);
  22778. + writel(0, ns->base + RXDP_HI);
  22779. + writel(virt_to_le32desc(&rx_ring[0]), ns->base + RXDP);
  22780. +
  22781. + dprintf(("starting receiver\n"));
  22782. +
  22783. + writel(0x0001, ns->base + CCSR);
  22784. + writel(0, ns->base + RFCR);
  22785. + writel(0x7fc00000, ns->base + RFCR);
  22786. + writel(0xffc00000, ns->base + RFCR);
  22787. +
  22788. + ns->up = 1;
  22789. +
  22790. + phy_intr(nic);
  22791. +
  22792. + /* Okay, let it rip */
  22793. + ns->IMR_cache |= ISR_PHY;
  22794. + ns->IMR_cache |= ISR_RXRCMP;
  22795. + //dev->IMR_cache |= ISR_RXERR;
  22796. + //dev->IMR_cache |= ISR_RXOK;
  22797. + ns->IMR_cache |= ISR_RXORN;
  22798. + ns->IMR_cache |= ISR_RXSOVR;
  22799. + ns->IMR_cache |= ISR_RXDESC;
  22800. + ns->IMR_cache |= ISR_RXIDLE;
  22801. + ns->IMR_cache |= ISR_TXDESC;
  22802. + ns->IMR_cache |= ISR_TXIDLE;
  22803. +
  22804. + // No reason to enable interupts...
  22805. + // writel(ns->IMR_cache, ns->base + IMR);
  22806. + // writel(1, ns->base + IER);
  22807. + ns83820_set_multicast(nic);
  22808. + kick_rx();
  22809. +}
  22810. +
  22811. +
  22812. +static void ns83820_do_reset(struct nic *nic __unused, u32 which)
  22813. +{
  22814. + dprintf(("resetting chip...\n"));
  22815. + writel(which, ns->base + CR);
  22816. + do {
  22817. +
  22818. + } while (readl(ns->base + CR) & which);
  22819. + dprintf(("okay!\n"));
  22820. +}
  22821. +
  22822. +static void ns83820_reset(struct nic *nic)
  22823. +{
  22824. + unsigned i;
  22825. + dprintf(("ns83820_reset\n"));
  22826. +
  22827. + writel(0, ns->base + PQCR);
  22828. +
  22829. + ns83820_setup_rx(nic);
  22830. +
  22831. + for (i = 0; i < NR_TX_DESC; i++) {
  22832. + tx_ring[i].link = 0;
  22833. + tx_ring[i].bufptr = 0;
  22834. + tx_ring[i].cmdsts = cpu_to_le32(0);
  22835. + tx_ring[i].extsts = cpu_to_le32(0);
  22836. + }
  22837. +
  22838. + ns->tx_idx = 0;
  22839. + ns->tx_done_idx = 0;
  22840. + writel(0, ns->base + TXDP_HI);
  22841. + return;
  22842. +}
  22843. +static void ns83820_getmac(struct nic *nic __unused, u8 * mac)
  22844. +{
  22845. + unsigned i;
  22846. + for (i = 0; i < 3; i++) {
  22847. + u32 data;
  22848. + /* Read from the perfect match memory: this is loaded by
  22849. + * the chip from the EEPROM via the EELOAD self test.
  22850. + */
  22851. + writel(i * 2, ns->base + RFCR);
  22852. + data = readl(ns->base + RFDR);
  22853. + *mac++ = data;
  22854. + *mac++ = data >> 8;
  22855. + }
  22856. +}
  22857. +
  22858. +static void ns83820_set_multicast(struct nic *nic __unused)
  22859. +{
  22860. + u8 *rfcr = ns->base + RFCR;
  22861. + u32 and_mask = 0xffffffff;
  22862. + u32 or_mask = 0;
  22863. + u32 val;
  22864. +
  22865. + /* Support Multicast */
  22866. + and_mask &= ~(RFCR_AAU | RFCR_AAM);
  22867. + or_mask |= RFCR_AAM;
  22868. + val = (readl(rfcr) & and_mask) | or_mask;
  22869. + /* Ramit : RFCR Write Fix doc says RFEN must be 0 modify other bits */
  22870. + writel(val & ~RFCR_RFEN, rfcr);
  22871. + writel(val, rfcr);
  22872. +
  22873. +}
  22874. +static void ns83820_run_bist(struct nic *nic __unused, const char *name,
  22875. + u32 enable, u32 done, u32 fail)
  22876. +{
  22877. + int timed_out = 0;
  22878. + long start;
  22879. + u32 status;
  22880. + int loops = 0;
  22881. +
  22882. + dprintf(("start %s\n", name))
  22883. +
  22884. + start = currticks();
  22885. +
  22886. + writel(enable, ns->base + PTSCR);
  22887. + for (;;) {
  22888. + loops++;
  22889. + status = readl(ns->base + PTSCR);
  22890. + if (!(status & enable))
  22891. + break;
  22892. + if (status & done)
  22893. + break;
  22894. + if (status & fail)
  22895. + break;
  22896. + if ((currticks() - start) >= HZ) {
  22897. + timed_out = 1;
  22898. + break;
  22899. + }
  22900. + }
  22901. +
  22902. + if (status & fail)
  22903. + printf("%s failed! (0x%hX & 0x%hX)\n", name, status, fail);
  22904. + else if (timed_out)
  22905. + printf("run_bist %s timed out! (%hX)\n", name, status);
  22906. + dprintf(("done %s in %d loops\n", name, loops));
  22907. +}
  22908. +
  22909. +/*************************************
  22910. +Check Link
  22911. +*************************************/
  22912. +static void ns83820_check_intr(struct nic *nic) {
  22913. + int i;
  22914. + u32 isr = readl(ns->base + ISR);
  22915. + if(ISR_PHY & isr)
  22916. + phy_intr(nic);
  22917. + if(( ISR_RXIDLE | ISR_RXDESC | ISR_RXERR) & isr)
  22918. + kick_rx();
  22919. + for (i = 0; i < NR_RX_DESC; i++) {
  22920. + if (rx_ring[i].cmdsts == CMDSTS_OWN) {
  22921. +// rx_ring[i].link = virt_to_le32desc(&rx_ring[i + 1]);
  22922. + rx_ring[i].cmdsts = cpu_to_le32(REAL_RX_BUF_SIZE);
  22923. + }
  22924. + }
  22925. +}
  22926. +/**************************************************************************
  22927. +POLL - Wait for a frame
  22928. +***************************************************************************/
  22929. +static int ns83820_poll(struct nic *nic, int retrieve)
  22930. +{
  22931. + /* return true if there's an ethernet packet ready to read */
  22932. + /* nic->packet should contain data on return */
  22933. + /* nic->packetlen should contain length of data */
  22934. + u32 cmdsts;
  22935. + int entry = ns->cur_rx;
  22936. +
  22937. + ns83820_check_intr(nic);
  22938. +
  22939. + cmdsts = le32_to_cpu(rx_ring[entry].cmdsts);
  22940. +
  22941. + if ( ! ( (CMDSTS_OWN & (cmdsts)) && (cmdsts != (CMDSTS_OWN)) ) )
  22942. + return 0;
  22943. +
  22944. + if ( ! retrieve ) return 1;
  22945. +
  22946. + if (! (CMDSTS_OK & cmdsts) )
  22947. + return 0;
  22948. +
  22949. + nic->packetlen = cmdsts & 0xffff;
  22950. + memcpy(nic->packet,
  22951. + rxb + (entry * REAL_RX_BUF_SIZE),
  22952. + nic->packetlen);
  22953. + // rx_ring[entry].link = 0;
  22954. + rx_ring[entry].cmdsts = cpu_to_le32(CMDSTS_OWN);
  22955. +
  22956. + ns->cur_rx = ++ns->cur_rx % NR_RX_DESC;
  22957. +
  22958. + if (ns->cur_rx == 0) /* We have wrapped the ring */
  22959. + kick_rx();
  22960. +
  22961. + return 1;
  22962. +}
  22963. +
  22964. +static inline void kick_tx(struct nic *nic __unused)
  22965. +{
  22966. + dprintf(("kick_tx\n"));
  22967. + writel(CR_TXE, ns->base + CR);
  22968. +}
  22969. +
  22970. +/**************************************************************************
  22971. +TRANSMIT - Transmit a frame
  22972. +***************************************************************************/
  22973. +static void ns83820_transmit(struct nic *nic, const char *d, /* Destination */
  22974. + unsigned int t, /* Type */
  22975. + unsigned int s, /* size */
  22976. + const char *p)
  22977. +{ /* Packet */
  22978. + /* send the packet to destination */
  22979. +
  22980. + u16 nstype;
  22981. + u32 cmdsts, extsts;
  22982. + int cur_tx = 0;
  22983. + u32 isr = readl(ns->base + ISR);
  22984. + if (ISR_TXIDLE & isr)
  22985. + kick_tx(nic);
  22986. + /* point to the current txb incase multiple tx_rings are used */
  22987. + memcpy(txb, d, ETH_ALEN);
  22988. + memcpy(txb + ETH_ALEN, nic->node_addr, ETH_ALEN);
  22989. + nstype = htons((u16) t);
  22990. + memcpy(txb + 2 * ETH_ALEN, (u8 *) & nstype, 2);
  22991. + memcpy(txb + ETH_HLEN, p, s);
  22992. + s += ETH_HLEN;
  22993. + s &= 0x0FFF;
  22994. + while (s < ETH_ZLEN)
  22995. + txb[s++] = '\0';
  22996. +
  22997. + /* Setup the transmit descriptor */
  22998. + extsts = 0;
  22999. + extsts |= EXTSTS_UDPPKT;
  23000. +
  23001. + tx_ring[cur_tx].bufptr = virt_to_le32desc(&txb);
  23002. + tx_ring[cur_tx].extsts = cpu_to_le32(extsts);
  23003. +
  23004. + cmdsts = cpu_to_le32(0);
  23005. + cmdsts |= cpu_to_le32(CMDSTS_OWN | s);
  23006. + tx_ring[cur_tx].cmdsts = cpu_to_le32(cmdsts);
  23007. +
  23008. + writel(virt_to_le32desc(&tx_ring[0]), ns->base + TXDP);
  23009. + kick_tx(nic);
  23010. +}
  23011. +
  23012. +/**************************************************************************
  23013. +DISABLE - Turn off ethernet interface
  23014. +***************************************************************************/
  23015. +static void ns83820_disable(struct dev *dev)
  23016. +{
  23017. + /* put the card in its initial state */
  23018. + /* This function serves 3 purposes.
  23019. + * This disables DMA and interrupts so we don't receive
  23020. + * unexpected packets or interrupts from the card after
  23021. + * etherboot has finished.
  23022. + * This frees resources so etherboot may use
  23023. + * this driver on another interface
  23024. + * This allows etherboot to reinitialize the interface
  23025. + * if something is something goes wrong.
  23026. + */
  23027. + /* disable interrupts */
  23028. + writel(0, ns->base + IMR);
  23029. + writel(0, ns->base + IER);
  23030. + readl(ns->base + IER);
  23031. +
  23032. + ns->up = 0;
  23033. +
  23034. + ns83820_do_reset((struct nic *) dev, CR_RST);
  23035. +
  23036. + ns->IMR_cache &=
  23037. + ~(ISR_RXOK | ISR_RXDESC | ISR_RXERR | ISR_RXEARLY |
  23038. + ISR_RXIDLE);
  23039. + writel(ns->IMR_cache, ns->base + IMR);
  23040. +
  23041. + /* touch the pci bus... */
  23042. + readl(ns->base + IMR);
  23043. +
  23044. + /* assumes the transmitter is already disabled and reset */
  23045. + writel(0, ns->base + RXDP_HI);
  23046. + writel(0, ns->base + RXDP);
  23047. +}
  23048. +
  23049. +/**************************************************************************
  23050. +IRQ - Enable, Disable, or Force interrupts
  23051. +***************************************************************************/
  23052. +static void ns83820_irq(struct nic *nic __unused, irq_action_t action __unused)
  23053. +{
  23054. + switch ( action ) {
  23055. + case DISABLE :
  23056. + break;
  23057. + case ENABLE :
  23058. + break;
  23059. + case FORCE :
  23060. + break;
  23061. + }
  23062. +}
  23063. +
  23064. +/**************************************************************************
  23065. +PROBE - Look for an adapter, this routine's visible to the outside
  23066. +***************************************************************************/
  23067. +
  23068. +#define board_found 1
  23069. +#define valid_link 0
  23070. +static int ns83820_probe(struct dev *dev, struct pci_device *pci)
  23071. +{
  23072. + struct nic *nic = (struct nic *) dev;
  23073. + int sz;
  23074. + long addr;
  23075. + int using_dac = 0;
  23076. +
  23077. + if (pci->ioaddr == 0)
  23078. + return 0;
  23079. +
  23080. + printf("ns83820.c: Found %s, vendor=0x%hX, device=0x%hX\n",
  23081. + pci->name, pci->vendor, pci->dev_id);
  23082. +
  23083. + /* point to private storage */
  23084. + ns = &nsx;
  23085. +
  23086. + adjust_pci_device(pci);
  23087. +
  23088. + addr = pci_bar_start(pci, PCI_BASE_ADDRESS_1);
  23089. + sz = pci_bar_size(pci, PCI_BASE_ADDRESS_1);
  23090. +
  23091. + ns->base = ioremap(addr, (1UL << 12));
  23092. +// ns->base = ioremap(addr, sz);
  23093. +
  23094. + if (!ns->base)
  23095. + return 0;
  23096. +
  23097. + nic->irqno = 0;
  23098. + nic->ioaddr = pci->ioaddr & ~3;
  23099. +
  23100. + /* disable interrupts */
  23101. + writel(0, ns->base + IMR);
  23102. + writel(0, ns->base + IER);
  23103. + readl(ns->base + IER);
  23104. +
  23105. + ns->IMR_cache = 0;
  23106. +
  23107. + ns83820_do_reset(nic, CR_RST);
  23108. +
  23109. + /* Must reset the ram bist before running it */
  23110. + writel(PTSCR_RBIST_RST, ns->base + PTSCR);
  23111. + ns83820_run_bist(nic, "sram bist", PTSCR_RBIST_EN,
  23112. + PTSCR_RBIST_DONE, PTSCR_RBIST_FAIL);
  23113. + ns83820_run_bist(nic, "eeprom bist", PTSCR_EEBIST_EN, 0,
  23114. + PTSCR_EEBIST_FAIL);
  23115. + ns83820_run_bist(nic, "eeprom load", PTSCR_EELOAD_EN, 0, 0);
  23116. +
  23117. + /* I love config registers */
  23118. + ns->CFG_cache = readl(ns->base + CFG);
  23119. +
  23120. + if ((ns->CFG_cache & CFG_PCI64_DET)) {
  23121. + printf("%s: detected 64 bit PCI data bus.\n", pci->name);
  23122. + /*dev->CFG_cache |= CFG_DATA64_EN; */
  23123. + if (!(ns->CFG_cache & CFG_DATA64_EN))
  23124. + printf
  23125. + ("%s: EEPROM did not enable 64 bit bus. Disabled.\n",
  23126. + pci->name);
  23127. + } else
  23128. + ns->CFG_cache &= ~(CFG_DATA64_EN);
  23129. +
  23130. + ns->CFG_cache &= (CFG_TBI_EN | CFG_MRM_DIS | CFG_MWI_DIS |
  23131. + CFG_T64ADDR | CFG_DATA64_EN | CFG_EXT_125 |
  23132. + CFG_M64ADDR);
  23133. + ns->CFG_cache |=
  23134. + CFG_PINT_DUPSTS | CFG_PINT_LNKSTS | CFG_PINT_SPDSTS |
  23135. + CFG_EXTSTS_EN | CFG_EXD | CFG_PESEL;
  23136. + ns->CFG_cache |= CFG_REQALG;
  23137. + ns->CFG_cache |= CFG_POW;
  23138. + ns->CFG_cache |= CFG_TMRTEST;
  23139. +
  23140. + /* When compiled with 64 bit addressing, we must always enable
  23141. + * the 64 bit descriptor format.
  23142. + */
  23143. +#ifdef USE_64BIT_ADDR
  23144. + ns->CFG_cache |= CFG_M64ADDR;
  23145. +#endif
  23146. +
  23147. +//FIXME: Enable section on dac or remove this
  23148. + if (using_dac)
  23149. + ns->CFG_cache |= CFG_T64ADDR;
  23150. +
  23151. + /* Big endian mode does not seem to do what the docs suggest */
  23152. + ns->CFG_cache &= ~CFG_BEM;
  23153. +
  23154. + /* setup optical transceiver if we have one */
  23155. + if (ns->CFG_cache & CFG_TBI_EN) {
  23156. + dprintf(("%s: enabling optical transceiver\n", pci->name));
  23157. + writel(readl(ns->base + GPIOR) | 0x3e8, ns->base + GPIOR);
  23158. +
  23159. + /* setup auto negotiation feature advertisement */
  23160. + writel(readl(ns->base + TANAR)
  23161. + | TANAR_HALF_DUP | TANAR_FULL_DUP,
  23162. + ns->base + TANAR);
  23163. +
  23164. + /* start auto negotiation */
  23165. + writel(TBICR_MR_AN_ENABLE | TBICR_MR_RESTART_AN,
  23166. + ns->base + TBICR);
  23167. + writel(TBICR_MR_AN_ENABLE, ns->base + TBICR);
  23168. + ns->linkstate = LINK_AUTONEGOTIATE;
  23169. +
  23170. + ns->CFG_cache |= CFG_MODE_1000;
  23171. + }
  23172. + writel(ns->CFG_cache, ns->base + CFG);
  23173. + dprintf(("CFG: %hX\n", ns->CFG_cache));
  23174. +
  23175. + /* FIXME: reset_phy is defaulted to 0, should we reset anyway? */
  23176. + if (reset_phy) {
  23177. + dprintf(("%s: resetting phy\n", pci->name));
  23178. + writel(ns->CFG_cache | CFG_PHY_RST, ns->base + CFG);
  23179. + writel(ns->CFG_cache, ns->base + CFG);
  23180. + }
  23181. +#if 0 /* Huh? This sets the PCI latency register. Should be done via
  23182. + * the PCI layer. FIXME.
  23183. + */
  23184. + if (readl(dev->base + SRR))
  23185. + writel(readl(dev->base + 0x20c) | 0xfe00,
  23186. + dev->base + 0x20c);
  23187. +#endif
  23188. +
  23189. + /* Note! The DMA burst size interacts with packet
  23190. + * transmission, such that the largest packet that
  23191. + * can be transmitted is 8192 - FLTH - burst size.
  23192. + * If only the transmit fifo was larger...
  23193. + */
  23194. + /* Ramit : 1024 DMA is not a good idea, it ends up banging
  23195. + * some DELL and COMPAQ SMP systems */
  23196. + writel(TXCFG_CSI | TXCFG_HBI | TXCFG_ATP | TXCFG_MXDMA512
  23197. + | ((1600 / 32) * 0x100), ns->base + TXCFG);
  23198. +
  23199. + /* Set Rx to full duplex, don't accept runt, errored, long or length
  23200. + * range errored packets. Use 512 byte DMA.
  23201. + */
  23202. + /* Ramit : 1024 DMA is not a good idea, it ends up banging
  23203. + * some DELL and COMPAQ SMP systems
  23204. + * Turn on ALP, only we are accpeting Jumbo Packets */
  23205. + writel(RXCFG_AEP | RXCFG_ARP | RXCFG_AIRL | RXCFG_RX_FD
  23206. + | RXCFG_STRIPCRC
  23207. + //| RXCFG_ALP
  23208. + | (RXCFG_MXDMA512) | 0, ns->base + RXCFG);
  23209. +
  23210. + /* Disable priority queueing */
  23211. + writel(0, ns->base + PQCR);
  23212. +
  23213. + /* Enable IP checksum validation and detetion of VLAN headers.
  23214. + * Note: do not set the reject options as at least the 0x102
  23215. + * revision of the chip does not properly accept IP fragments
  23216. + * at least for UDP.
  23217. + */
  23218. + /* Ramit : Be sure to turn on RXCFG_ARP if VLAN's are enabled, since
  23219. + * the MAC it calculates the packetsize AFTER stripping the VLAN
  23220. + * header, and if a VLAN Tagged packet of 64 bytes is received (like
  23221. + * a ping with a VLAN header) then the card, strips the 4 byte VLAN
  23222. + * tag and then checks the packet size, so if RXCFG_ARP is not enabled,
  23223. + * it discrards it!. These guys......
  23224. + */
  23225. + writel(VRCR_IPEN | VRCR_VTDEN, ns->base + VRCR);
  23226. +
  23227. + /* Enable per-packet TCP/UDP/IP checksumming */
  23228. + writel(VTCR_PPCHK, ns->base + VTCR);
  23229. +
  23230. + /* Ramit : Enable async and sync pause frames */
  23231. +// writel(0, ns->base + PCR);
  23232. + writel((PCR_PS_MCAST | PCR_PS_DA | PCR_PSEN | PCR_FFLO_4K |
  23233. + PCR_FFHI_8K | PCR_STLO_4 | PCR_STHI_8 | PCR_PAUSE_CNT),
  23234. + ns->base + PCR);
  23235. +
  23236. + /* Disable Wake On Lan */
  23237. + writel(0, ns->base + WCSR);
  23238. +
  23239. + ns83820_getmac(nic, nic->node_addr);
  23240. + printf("%! at ioaddr 0x%hX, ", nic->node_addr, ns->base);
  23241. +
  23242. + if (using_dac) {
  23243. + dprintf(("%s: using 64 bit addressing.\n", pci->name));
  23244. + }
  23245. +
  23246. + dprintf(("%s: DP83820 %d.%d: %! io=0x%hX\n",
  23247. + pci->name,
  23248. + (unsigned) readl(ns->base + SRR) >> 8,
  23249. + (unsigned) readl(ns->base + SRR) & 0xff,
  23250. + nic->node_addr, pci->ioaddr));
  23251. +
  23252. +#ifdef PHY_CODE_IS_FINISHED
  23253. + ns83820_probe_phy(dev);
  23254. +#endif
  23255. +
  23256. + ns83820_reset(nic);
  23257. + /* point to NIC specific routines */
  23258. + dev->disable = ns83820_disable;
  23259. + nic->poll = ns83820_poll;
  23260. + nic->transmit = ns83820_transmit;
  23261. + nic->irq = ns83820_irq;
  23262. + return 1;
  23263. +}
  23264. +
  23265. +static struct pci_id ns83820_nics[] = {
  23266. + PCI_ROM(0x100b, 0x0022, "ns83820", "National Semiconductor 83820"),
  23267. +};
  23268. +
  23269. +struct pci_driver ns83820_driver = {
  23270. + .type = NIC_DRIVER,
  23271. + .name = "NS83820/PCI",
  23272. + .probe = ns83820_probe,
  23273. + .ids = ns83820_nics,
  23274. + .id_count = sizeof(ns83820_nics) / sizeof(ns83820_nics[0]),
  23275. + .class = 0,
  23276. +};
  23277. Index: b/netboot/ns8390.c
  23278. ===================================================================
  23279. --- a/netboot/ns8390.c
  23280. +++ b/netboot/ns8390.c
  23281. @@ -13,11 +13,15 @@
  23282. the proper functioning of this software, nor do the authors assume any
  23283. responsibility for damages incurred with its use.
  23284. +Multicast support added by Timothy Legge (timlegge@users.sourceforge.net) 09/28/2003
  23285. +Relocation support added by Ken Yap (ken_yap@users.sourceforge.net) 28/12/02
  23286. 3c503 support added by Bill Paul (wpaul@ctr.columbia.edu) on 11/15/94
  23287. SMC8416 support added by Bill Paul (wpaul@ctr.columbia.edu) on 12/25/94
  23288. 3c503 PIO support added by Jim Hague (jim.hague@acm.org) on 2/17/98
  23289. RX overrun by Klaus Espenlaub (espenlaub@informatik.uni-ulm.de) on 3/10/99
  23290. parts taken from the Linux 8390 driver (by Donald Becker and Paul Gortmaker)
  23291. +SMC8416 PIO support added by Andrew Bettison (andrewb@zip.com.au) on 4/3/02
  23292. + based on the Linux 8390 driver (by Donald Becker and Paul Gortmaker)
  23293. **************************************************************************/
  23294. @@ -26,10 +30,16 @@
  23295. #include "ns8390.h"
  23296. #ifdef INCLUDE_NS8390
  23297. #include "pci.h"
  23298. +#else
  23299. +#include "isa.h"
  23300. #endif
  23301. -#include "cards.h"
  23302. -static unsigned char eth_vendor, eth_flags, eth_laar;
  23303. +typedef int Address;
  23304. +
  23305. +static unsigned char eth_vendor, eth_flags;
  23306. +#ifdef INCLUDE_WD
  23307. +static unsigned char eth_laar;
  23308. +#endif
  23309. static unsigned short eth_nic_base, eth_asic_base;
  23310. static unsigned char eth_memsize, eth_rx_start, eth_tx_start;
  23311. static Address eth_bmem, eth_rmem;
  23312. @@ -66,6 +76,7 @@
  23313. #endif
  23314. #if defined(INCLUDE_WD)
  23315. +#define ASIC_PIO WD_IAR
  23316. #define eth_probe wd_probe
  23317. #if defined(INCLUDE_3C503) || defined(INCLUDE_NE) || defined(INCLUDE_NS8390)
  23318. Error you must only define one of INCLUDE_WD, INCLUDE_3C503, INCLUDE_NE, INCLUDE_NS8390
  23319. @@ -101,13 +112,16 @@
  23320. #endif
  23321. #endif
  23322. -#if defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || (defined(INCLUDE_3C503) && !defined(T503_SHMEM))
  23323. +#if defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || (defined(INCLUDE_3C503) && !defined(T503_SHMEM)) || (defined(INCLUDE_WD) && defined(WD_790_PIO))
  23324. /**************************************************************************
  23325. ETH_PIO_READ - Read a frame via Programmed I/O
  23326. **************************************************************************/
  23327. static void eth_pio_read(unsigned int src, unsigned char *dst, unsigned int cnt)
  23328. {
  23329. - if (eth_flags & FLAG_16BIT) { ++cnt; cnt &= ~1; }
  23330. +#ifdef INCLUDE_WD
  23331. + outb(src & 0xff, eth_asic_base + WD_GP2);
  23332. + outb(src >> 8, eth_asic_base + WD_GP2);
  23333. +#else
  23334. outb(D8390_COMMAND_RD2 |
  23335. D8390_COMMAND_STA, eth_nic_base + D8390_P0_COMMAND);
  23336. outb(cnt, eth_nic_base + D8390_P0_RBCR0);
  23337. @@ -122,9 +136,10 @@
  23338. outb(src >> 8, eth_asic_base + _3COM_DAMSB);
  23339. outb(t503_output | _3COM_CR_START, eth_asic_base + _3COM_CR);
  23340. #endif
  23341. +#endif
  23342. if (eth_flags & FLAG_16BIT)
  23343. - cnt >>= 1;
  23344. + cnt = (cnt + 1) >> 1;
  23345. while(cnt--) {
  23346. #ifdef INCLUDE_3C503
  23347. @@ -153,7 +168,10 @@
  23348. #ifdef COMPEX_RL2000_FIX
  23349. unsigned int x;
  23350. #endif /* COMPEX_RL2000_FIX */
  23351. - if (eth_flags & FLAG_16BIT) { ++cnt; cnt &= ~1; }
  23352. +#ifdef INCLUDE_WD
  23353. + outb(dst & 0xff, eth_asic_base + WD_GP2);
  23354. + outb(dst >> 8, eth_asic_base + WD_GP2);
  23355. +#else
  23356. outb(D8390_COMMAND_RD2 |
  23357. D8390_COMMAND_STA, eth_nic_base + D8390_P0_COMMAND);
  23358. outb(D8390_ISR_RDC, eth_nic_base + D8390_P0_ISR);
  23359. @@ -170,9 +188,10 @@
  23360. outb(t503_output | _3COM_CR_DDIR | _3COM_CR_START, eth_asic_base + _3COM_CR);
  23361. #endif
  23362. +#endif
  23363. if (eth_flags & FLAG_16BIT)
  23364. - cnt >>= 1;
  23365. + cnt = (cnt + 1) >> 1;
  23366. while(cnt--)
  23367. {
  23368. @@ -201,17 +220,40 @@
  23369. if (x >= COMPEX_RL2000_TRIES)
  23370. printf("Warning: Compex RL2000 aborted wait!\n");
  23371. #endif /* COMPEX_RL2000_FIX */
  23372. +#ifndef INCLUDE_WD
  23373. while((inb(eth_nic_base + D8390_P0_ISR) & D8390_ISR_RDC)
  23374. != D8390_ISR_RDC);
  23375. #endif
  23376. +#endif
  23377. }
  23378. #else
  23379. /**************************************************************************
  23380. ETH_PIO_READ - Dummy routine when NE2000 not compiled in
  23381. **************************************************************************/
  23382. -static void eth_pio_read(unsigned int src, unsigned char *dst, unsigned int cnt) {}
  23383. +static void eth_pio_read(unsigned int src __unused, unsigned char *dst __unused, unsigned int cnt __unused) {}
  23384. #endif
  23385. +
  23386. +/**************************************************************************
  23387. +enable_multycast - Enable Multicast
  23388. +**************************************************************************/
  23389. +static void enable_multicast(unsigned short eth_nic_base)
  23390. +{
  23391. + unsigned char mcfilter[8];
  23392. + int i;
  23393. + memset(mcfilter, 0xFF, 8);
  23394. + outb(4, eth_nic_base+D8390_P0_RCR);
  23395. + outb(D8390_COMMAND_RD2 + D8390_COMMAND_PS1, eth_nic_base + D8390_P0_COMMAND);
  23396. + for(i=0;i<8;i++)
  23397. + {
  23398. + outb(mcfilter[i], eth_nic_base + 8 + i);
  23399. + if(inb(eth_nic_base + 8 + i)!=mcfilter[i])
  23400. + printf("Error SMC 83C690 Multicast filter read/write mishap %d\n",i);
  23401. + }
  23402. + outb(D8390_COMMAND_RD2 + D8390_COMMAND_PS0, eth_nic_base + D8390_P0_COMMAND);
  23403. + outb(4 | 0x08, eth_nic_base+D8390_P0_RCR);
  23404. +}
  23405. +
  23406. /**************************************************************************
  23407. NS8390_RESET - Reset adapter
  23408. **************************************************************************/
  23409. @@ -238,7 +280,14 @@
  23410. outb(eth_tx_start, eth_nic_base+D8390_P0_TPSR);
  23411. outb(eth_rx_start, eth_nic_base+D8390_P0_PSTART);
  23412. #ifdef INCLUDE_WD
  23413. - if (eth_flags & FLAG_790) outb(0, eth_nic_base + 0x09);
  23414. + if (eth_flags & FLAG_790) {
  23415. +#ifdef WD_790_PIO
  23416. + outb(0x10, eth_asic_base + 0x06); /* disable interrupts, enable PIO */
  23417. + outb(0x01, eth_nic_base + 0x09); /* enable ring read auto-wrap */
  23418. +#else
  23419. + outb(0, eth_nic_base + 0x09);
  23420. +#endif
  23421. + }
  23422. #endif
  23423. outb(eth_memsize, eth_nic_base+D8390_P0_PSTOP);
  23424. outb(eth_memsize - 1, eth_nic_base+D8390_P0_BOUND);
  23425. @@ -266,8 +315,10 @@
  23426. outb(D8390_COMMAND_PS0 |
  23427. D8390_COMMAND_RD2 | D8390_COMMAND_STA, eth_nic_base+D8390_P0_COMMAND);
  23428. outb(0xFF, eth_nic_base+D8390_P0_ISR);
  23429. - outb(0, eth_nic_base+D8390_P0_TCR);
  23430. - outb(4, eth_nic_base+D8390_P0_RCR); /* allow broadcast frames */
  23431. + outb(0, eth_nic_base+D8390_P0_TCR); /* transmitter on */
  23432. + outb(4, eth_nic_base+D8390_P0_RCR); /* allow rx broadcast frames */
  23433. +
  23434. + enable_multicast(eth_nic_base);
  23435. #ifdef INCLUDE_3C503
  23436. /*
  23437. @@ -281,7 +332,7 @@
  23438. #endif
  23439. }
  23440. -static int ns8390_poll(struct nic *nic);
  23441. +static int ns8390_poll(struct nic *nic, int retrieve);
  23442. #ifndef INCLUDE_3C503
  23443. /**************************************************************************
  23444. @@ -324,7 +375,7 @@
  23445. /* clear the RX ring, acknowledge overrun interrupt */
  23446. eth_drain_receiver = 1;
  23447. - while (ns8390_poll(nic))
  23448. + while (ns8390_poll(nic, 1))
  23449. /* Nothing */;
  23450. eth_drain_receiver = 0;
  23451. outb(D8390_ISR_OVW, eth_nic_base+D8390_P0_ISR);
  23452. @@ -344,50 +395,54 @@
  23453. unsigned int s, /* size */
  23454. const char *p) /* Packet */
  23455. {
  23456. +#if defined(INCLUDE_3C503) || (defined(INCLUDE_WD) && ! defined(WD_790_PIO))
  23457. + Address eth_vmem = bus_to_virt(eth_bmem);
  23458. +#endif
  23459. #ifdef INCLUDE_3C503
  23460. if (!(eth_flags & FLAG_PIO)) {
  23461. - memcpy((char *)eth_bmem, d, ETH_ALEN); /* dst */
  23462. - memcpy((char *)eth_bmem+ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  23463. - *((char *)eth_bmem+12) = t>>8; /* type */
  23464. - *((char *)eth_bmem+13) = t;
  23465. - memcpy((char *)eth_bmem+ETH_HLEN, p, s);
  23466. + memcpy((char *)eth_vmem, d, ETH_ALEN); /* dst */
  23467. + memcpy((char *)eth_vmem+ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  23468. + *((char *)eth_vmem+12) = t>>8; /* type */
  23469. + *((char *)eth_vmem+13) = t;
  23470. + memcpy((char *)eth_vmem+ETH_HLEN, p, s);
  23471. s += ETH_HLEN;
  23472. - while (s < ETH_ZLEN) *((char *)eth_bmem+(s++)) = 0;
  23473. + while (s < ETH_ZLEN) *((char *)eth_vmem+(s++)) = 0;
  23474. }
  23475. #endif
  23476. #ifdef INCLUDE_WD
  23477. - /* Memory interface */
  23478. if (eth_flags & FLAG_16BIT) {
  23479. outb(eth_laar | WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
  23480. inb(0x84);
  23481. }
  23482. +#ifndef WD_790_PIO
  23483. + /* Memory interface */
  23484. if (eth_flags & FLAG_790) {
  23485. outb(WD_MSR_MENB, eth_asic_base + WD_MSR);
  23486. inb(0x84);
  23487. }
  23488. inb(0x84);
  23489. - memcpy((char *)eth_bmem, d, ETH_ALEN); /* dst */
  23490. - memcpy((char *)eth_bmem+ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  23491. - *((char *)eth_bmem+12) = t>>8; /* type */
  23492. - *((char *)eth_bmem+13) = t;
  23493. - memcpy((char *)eth_bmem+ETH_HLEN, p, s);
  23494. + memcpy((char *)eth_vmem, d, ETH_ALEN); /* dst */
  23495. + memcpy((char *)eth_vmem+ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  23496. + *((char *)eth_vmem+12) = t>>8; /* type */
  23497. + *((char *)eth_vmem+13) = t;
  23498. + memcpy((char *)eth_vmem+ETH_HLEN, p, s);
  23499. s += ETH_HLEN;
  23500. - while (s < ETH_ZLEN) *((char *)eth_bmem+(s++)) = 0;
  23501. + while (s < ETH_ZLEN) *((char *)eth_vmem+(s++)) = 0;
  23502. if (eth_flags & FLAG_790) {
  23503. outb(0, eth_asic_base + WD_MSR);
  23504. inb(0x84);
  23505. }
  23506. - if (eth_flags & FLAG_16BIT) {
  23507. - outb(eth_laar & ~WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
  23508. - inb(0x84);
  23509. - }
  23510. +#else
  23511. + inb(0x84);
  23512. +#endif
  23513. #endif
  23514. #if defined(INCLUDE_3C503)
  23515. - if (eth_flags & FLAG_PIO) {
  23516. + if (eth_flags & FLAG_PIO)
  23517. #endif
  23518. -#if defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || (defined(INCLUDE_3C503) && !defined(T503_SHMEM))
  23519. +#if defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || (defined(INCLUDE_3C503) && !defined(T503_SHMEM)) || (defined(INCLUDE_WD) && defined(WD_790_PIO))
  23520. + {
  23521. /* Programmed I/O */
  23522. unsigned short type;
  23523. type = (t >> 8) | (t << 8);
  23524. @@ -398,12 +453,16 @@
  23525. eth_pio_write(p, (eth_tx_start<<8)+ETH_HLEN, s);
  23526. s += ETH_HLEN;
  23527. if (s < ETH_ZLEN) s = ETH_ZLEN;
  23528. + }
  23529. #endif
  23530. #if defined(INCLUDE_3C503)
  23531. - }
  23532. #endif
  23533. #ifdef INCLUDE_WD
  23534. + if (eth_flags & FLAG_16BIT) {
  23535. + outb(eth_laar & ~WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
  23536. + inb(0x84);
  23537. + }
  23538. if (eth_flags & FLAG_790)
  23539. outb(D8390_COMMAND_PS0 |
  23540. D8390_COMMAND_STA, eth_nic_base+D8390_P0_COMMAND);
  23541. @@ -428,7 +487,7 @@
  23542. /**************************************************************************
  23543. NS8390_POLL - Wait for a frame
  23544. **************************************************************************/
  23545. -static int ns8390_poll(struct nic *nic)
  23546. +static int ns8390_poll(struct nic *nic, int retrieve)
  23547. {
  23548. int ret = 0;
  23549. unsigned char rstat, curr, next;
  23550. @@ -453,22 +512,27 @@
  23551. outb(D8390_COMMAND_PS0, eth_nic_base+D8390_P0_COMMAND);
  23552. if (curr >= eth_memsize) curr=eth_rx_start;
  23553. if (curr == next) return(0);
  23554. +
  23555. + if ( ! retrieve ) return 1;
  23556. +
  23557. #ifdef INCLUDE_WD
  23558. if (eth_flags & FLAG_16BIT) {
  23559. outb(eth_laar | WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
  23560. inb(0x84);
  23561. }
  23562. +#ifndef WD_790_PIO
  23563. if (eth_flags & FLAG_790) {
  23564. outb(WD_MSR_MENB, eth_asic_base + WD_MSR);
  23565. inb(0x84);
  23566. }
  23567. +#endif
  23568. inb(0x84);
  23569. #endif
  23570. pktoff = next << 8;
  23571. if (eth_flags & FLAG_PIO)
  23572. eth_pio_read(pktoff, (char *)&pkthdr, 4);
  23573. else
  23574. - memcpy(&pkthdr, (char *)eth_rmem + pktoff, 4);
  23575. + memcpy(&pkthdr, bus_to_virt(eth_rmem + pktoff), 4);
  23576. pktoff += sizeof(pkthdr);
  23577. /* incoming length includes FCS so must sub 4 */
  23578. len = pkthdr.len - 4;
  23579. @@ -486,7 +550,7 @@
  23580. if (eth_flags & FLAG_PIO)
  23581. eth_pio_read(pktoff, p, frag);
  23582. else
  23583. - memcpy(p, (char *)eth_rmem + pktoff, frag);
  23584. + memcpy(p, bus_to_virt(eth_rmem + pktoff), frag);
  23585. pktoff = eth_rx_start << 8;
  23586. p += frag;
  23587. len -= frag;
  23588. @@ -495,14 +559,16 @@
  23589. if (eth_flags & FLAG_PIO)
  23590. eth_pio_read(pktoff, p, len);
  23591. else
  23592. - memcpy(p, (char *)eth_rmem + pktoff, len);
  23593. + memcpy(p, bus_to_virt(eth_rmem + pktoff), len);
  23594. ret = 1;
  23595. }
  23596. #ifdef INCLUDE_WD
  23597. +#ifndef WD_790_PIO
  23598. if (eth_flags & FLAG_790) {
  23599. outb(0, eth_asic_base + WD_MSR);
  23600. inb(0x84);
  23601. }
  23602. +#endif
  23603. if (eth_flags & FLAG_16BIT) {
  23604. outb(eth_laar & ~WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
  23605. inb(0x84);
  23606. @@ -519,31 +585,56 @@
  23607. /**************************************************************************
  23608. NS8390_DISABLE - Turn off adapter
  23609. **************************************************************************/
  23610. -static void ns8390_disable(struct nic *nic)
  23611. +static void ns8390_disable(struct dev *dev)
  23612. {
  23613. + struct nic *nic = (struct nic *)dev;
  23614. + /* reset and disable merge */
  23615. + ns8390_reset(nic);
  23616. +}
  23617. +
  23618. +/**************************************************************************
  23619. +NS8390_IRQ - Enable, Disable, or Force interrupts
  23620. +**************************************************************************/
  23621. +static void ns8390_irq(struct nic *nic __unused, irq_action_t action __unused)
  23622. +{
  23623. + switch ( action ) {
  23624. + case DISABLE :
  23625. + break;
  23626. + case ENABLE :
  23627. + break;
  23628. + case FORCE :
  23629. + break;
  23630. + }
  23631. }
  23632. /**************************************************************************
  23633. ETH_PROBE - Look for an adapter
  23634. **************************************************************************/
  23635. #ifdef INCLUDE_NS8390
  23636. -struct nic *eth_probe(struct nic *nic, unsigned short *probe_addrs,
  23637. - struct pci_device *pci)
  23638. +static int eth_probe (struct dev *dev, struct pci_device *pci)
  23639. #else
  23640. -struct nic *eth_probe(struct nic *nic, unsigned short *probe_addrs)
  23641. +static int eth_probe (struct dev *dev, unsigned short *probe_addrs __unused)
  23642. #endif
  23643. {
  23644. + struct nic *nic = (struct nic *)dev;
  23645. int i;
  23646. - struct wd_board *brd;
  23647. - unsigned short chksum;
  23648. - unsigned char c;
  23649. +#ifdef INCLUDE_NS8390
  23650. + unsigned short pci_probe_addrs[] = { pci->ioaddr, 0 };
  23651. + unsigned short *probe_addrs = pci_probe_addrs;
  23652. +#endif
  23653. eth_vendor = VENDOR_NONE;
  23654. eth_drain_receiver = 0;
  23655. + nic->irqno = 0;
  23656. +
  23657. #ifdef INCLUDE_WD
  23658. +{
  23659. /******************************************************************
  23660. Search for WD/SMC cards
  23661. ******************************************************************/
  23662. + struct wd_board *brd;
  23663. + unsigned short chksum;
  23664. + unsigned char c;
  23665. for (eth_asic_base = WD_LOW_BASE; eth_asic_base <= WD_HIGH_BASE;
  23666. eth_asic_base += 0x20) {
  23667. chksum = 0;
  23668. @@ -560,6 +651,9 @@
  23669. /* We've found a board */
  23670. eth_vendor = VENDOR_WD;
  23671. eth_nic_base = eth_asic_base + WD_NIC_ADDR;
  23672. +
  23673. + nic->ioaddr = eth_nic_base;
  23674. +
  23675. c = inb(eth_asic_base+WD_BID); /* Get board id */
  23676. for (brd = wd_boards; brd->name; brd++)
  23677. if (brd->id == c) break;
  23678. @@ -582,8 +676,9 @@
  23679. } else
  23680. eth_bmem = WD_DEFAULT_MEM;
  23681. if (brd->id == TYPE_SMC8216T || brd->id == TYPE_SMC8216C) {
  23682. - *((unsigned int *)(eth_bmem + 8192)) = (unsigned int)0;
  23683. - if (*((unsigned int *)(eth_bmem + 8192))) {
  23684. + /* from Linux driver, 8416BT detects as 8216 sometimes */
  23685. + unsigned int addr = inb(eth_asic_base + 0xb);
  23686. + if (((addr >> 4) & 3) == 0) {
  23687. brd += 2;
  23688. eth_memsize = brd->memsize;
  23689. }
  23690. @@ -592,19 +687,27 @@
  23691. for (i=0; i<ETH_ALEN; i++) {
  23692. nic->node_addr[i] = inb(i+eth_asic_base+WD_LAR);
  23693. }
  23694. - printf("\n%s base %#hx, memory %#hx, addr %!\n",
  23695. - brd->name, eth_asic_base, eth_bmem, nic->node_addr);
  23696. + printf("\n%s base %#hx", brd->name, eth_asic_base);
  23697. if (eth_flags & FLAG_790) {
  23698. +#ifdef WD_790_PIO
  23699. + printf(", PIO mode, addr %!\n", nic->node_addr);
  23700. + eth_bmem = 0;
  23701. + eth_flags |= FLAG_PIO; /* force PIO mode */
  23702. + outb(0, eth_asic_base+WD_MSR);
  23703. +#else
  23704. + printf(", memory %#x, addr %!\n", eth_bmem, nic->node_addr);
  23705. outb(WD_MSR_MENB, eth_asic_base+WD_MSR);
  23706. outb((inb(eth_asic_base+0x04) |
  23707. 0x80), eth_asic_base+0x04);
  23708. - outb((((unsigned)eth_bmem >> 13) & 0x0F) |
  23709. - (((unsigned)eth_bmem >> 11) & 0x40) |
  23710. + outb(((unsigned)(eth_bmem >> 13) & 0x0F) |
  23711. + ((unsigned)(eth_bmem >> 11) & 0x40) |
  23712. (inb(eth_asic_base+0x0B) & 0xB0), eth_asic_base+0x0B);
  23713. outb((inb(eth_asic_base+0x04) &
  23714. ~0x80), eth_asic_base+0x04);
  23715. +#endif
  23716. } else {
  23717. - outb((((unsigned)eth_bmem >> 13) & 0x3F) | 0x40, eth_asic_base+WD_MSR);
  23718. + printf(", memory %#x, addr %!\n", eth_bmem, nic->node_addr);
  23719. + outb(((unsigned)(eth_bmem >> 13) & 0x3F) | 0x40, eth_asic_base+WD_MSR);
  23720. }
  23721. if (eth_flags & FLAG_16BIT) {
  23722. if (eth_flags & FLAG_790) {
  23723. @@ -624,8 +727,14 @@
  23724. }
  23725. inb(0x84);
  23726. }
  23727. +}
  23728. #endif
  23729. #ifdef INCLUDE_3C503
  23730. +#ifdef T503_AUI
  23731. + nic->flags = 1; /* aui */
  23732. +#else
  23733. + nic->flags = 0; /* no aui */
  23734. +#endif
  23735. /******************************************************************
  23736. Search for 3Com 3c503 if no WD/SMC cards
  23737. ******************************************************************/
  23738. @@ -708,11 +817,12 @@
  23739. /* Get our ethernet address */
  23740. outb(_3COM_CR_EALO | _3COM_CR_XSEL, eth_asic_base + _3COM_CR);
  23741. + nic->ioaddr = eth_nic_base;
  23742. printf("\n3Com 3c503 base %#hx, ", eth_nic_base);
  23743. if (eth_flags & FLAG_PIO)
  23744. printf("PIO mode");
  23745. else
  23746. - printf("memory %#hx", eth_bmem);
  23747. + printf("memory %#x", eth_bmem);
  23748. for (i=0; i<ETH_ALEN; i++) {
  23749. nic->node_addr[i] = inb(eth_nic_base+i);
  23750. }
  23751. @@ -734,9 +844,9 @@
  23752. */
  23753. if (!(eth_flags & FLAG_PIO)) {
  23754. - memset((char *)eth_bmem, 0, 0x2000);
  23755. + memset(bus_to_virt(eth_bmem), 0, 0x2000);
  23756. for(i = 0; i < 0x2000; ++i)
  23757. - if (*(((char *)eth_bmem)+i)) {
  23758. + if (*((char *)(bus_to_virt(eth_bmem+i)))) {
  23759. printf ("Failed to clear 3c503 shared mem.\n");
  23760. return (0);
  23761. }
  23762. @@ -749,9 +859,11 @@
  23763. }
  23764. #endif
  23765. #if defined(INCLUDE_NE) || defined(INCLUDE_NS8390)
  23766. +{
  23767. /******************************************************************
  23768. Search for NE1000/2000 if no WD/SMC or 3com cards
  23769. ******************************************************************/
  23770. + unsigned char c;
  23771. if (eth_vendor == VENDOR_NONE) {
  23772. char romdata[16], testbuf[32];
  23773. int idx;
  23774. @@ -810,23 +922,94 @@
  23775. for (i=0; i<ETH_ALEN; i++) {
  23776. nic->node_addr[i] = romdata[i + ((eth_flags & FLAG_16BIT) ? i : 0)];
  23777. }
  23778. + nic->ioaddr = eth_nic_base;
  23779. printf("\nNE%c000 base %#hx, addr %!\n",
  23780. (eth_flags & FLAG_16BIT) ? '2' : '1', eth_nic_base,
  23781. nic->node_addr);
  23782. }
  23783. +}
  23784. #endif
  23785. if (eth_vendor == VENDOR_NONE)
  23786. return(0);
  23787. if (eth_vendor != VENDOR_3COM)
  23788. eth_rmem = eth_bmem;
  23789. ns8390_reset(nic);
  23790. - nic->reset = ns8390_reset;
  23791. - nic->poll = ns8390_poll;
  23792. +
  23793. + dev->disable = ns8390_disable;
  23794. + nic->poll = ns8390_poll;
  23795. nic->transmit = ns8390_transmit;
  23796. - nic->disable = ns8390_disable;
  23797. - return(nic);
  23798. + nic->irq = ns8390_irq;
  23799. +
  23800. + /* Based on PnP ISA map */
  23801. +#ifdef INCLUDE_WD
  23802. + dev->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
  23803. + dev->devid.device_id = htons(0x812a);
  23804. +#endif
  23805. +#ifdef INCLUDE_3C503
  23806. + dev->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
  23807. + dev->devid.device_id = htons(0x80f3);
  23808. +#endif
  23809. +#ifdef INCLUDE_NE
  23810. + dev->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
  23811. + dev->devid.device_id = htons(0x80d6);
  23812. +#endif
  23813. + return 1;
  23814. }
  23815. +#ifdef INCLUDE_WD
  23816. +static struct isa_driver wd_driver __isa_driver = {
  23817. + .type = NIC_DRIVER,
  23818. + .name = "WD",
  23819. + .probe = wd_probe,
  23820. + .ioaddrs = 0,
  23821. +};
  23822. +#endif
  23823. +
  23824. +#ifdef INCLUDE_3C503
  23825. +static struct isa_driver t503_driver __isa_driver = {
  23826. + .type = NIC_DRIVER,
  23827. + .name = "3C503",
  23828. + .probe = t503_probe,
  23829. + .ioaddrs = 0,
  23830. +};
  23831. +#endif
  23832. +
  23833. +#ifdef INCLUDE_NE
  23834. +static struct isa_driver ne_driver __isa_driver = {
  23835. + .type = NIC_DRIVER,
  23836. + .name = "NE*000",
  23837. + .probe = ne_probe,
  23838. + .ioaddrs = 0,
  23839. +};
  23840. +#endif
  23841. +
  23842. +#ifdef INCLUDE_NS8390
  23843. +static struct pci_id nepci_nics[] = {
  23844. +/* A few NE2000 PCI clones, list not exhaustive */
  23845. +PCI_ROM(0x10ec, 0x8029, "rtl8029", "Realtek 8029"),
  23846. +PCI_ROM(0x1186, 0x0300, "dlink-528", "D-Link DE-528"),
  23847. +PCI_ROM(0x1050, 0x0940, "winbond940", "Winbond NE2000-PCI"), /* Winbond 86C940 / 89C940 */
  23848. +PCI_ROM(0x1050, 0x5a5a, "winbond940f", "Winbond W89c940F"), /* Winbond 89C940F */
  23849. +PCI_ROM(0x11f6, 0x1401, "compexrl2000", "Compex ReadyLink 2000"),
  23850. +PCI_ROM(0x8e2e, 0x3000, "ktiet32p2", "KTI ET32P2"),
  23851. +PCI_ROM(0x4a14, 0x5000, "nv5000sc", "NetVin NV5000SC"),
  23852. +PCI_ROM(0x12c3, 0x0058, "holtek80232", "Holtek HT80232"),
  23853. +PCI_ROM(0x12c3, 0x5598, "holtek80229", "Holtek HT80229"),
  23854. +PCI_ROM(0x10bd, 0x0e34, "surecom-ne34", "Surecom NE34"),
  23855. +PCI_ROM(0x1106, 0x0926, "via86c926", "Via 86c926"),
  23856. +};
  23857. +
  23858. +struct pci_driver nepci_driver = {
  23859. + .type = NIC_DRIVER,
  23860. + .name = "NE2000/PCI",
  23861. + .probe = nepci_probe,
  23862. + .ids = nepci_nics,
  23863. + .id_count = sizeof(nepci_nics)/sizeof(nepci_nics[0]),
  23864. + .class = 0,
  23865. +};
  23866. +
  23867. +#endif /* INCLUDE_NS8390 */
  23868. +
  23869. /*
  23870. * Local variables:
  23871. * c-basic-offset: 8
  23872. Index: b/netboot/osdep.h
  23873. ===================================================================
  23874. --- a/netboot/osdep.h
  23875. +++ b/netboot/osdep.h
  23876. @@ -1,94 +1,18 @@
  23877. -#ifndef __OSDEP_H__
  23878. -#define __OSDEP_H__
  23879. +#ifndef _OSDEP_H
  23880. +#define _OSDEP_H
  23881. -/*
  23882. - * This program is free software; you can redistribute it and/or
  23883. - * modify it under the terms of the GNU General Public License as
  23884. - * published by the Free Software Foundation; either version 2, or (at
  23885. - * your option) any later version.
  23886. - */
  23887. +#define __unused __attribute__((unused))
  23888. +#define __aligned __attribute__((aligned(16)))
  23889. -#define __LITTLE_ENDIAN /* x86 */
  23890. -
  23891. -/* Taken from /usr/include/linux/hfs_sysdep.h */
  23892. -#if defined(__BIG_ENDIAN)
  23893. -# if !defined(__constant_htonl)
  23894. -# define __constant_htonl(x) (x)
  23895. -# endif
  23896. -# if !defined(__constant_htons)
  23897. -# define __constant_htons(x) (x)
  23898. -# endif
  23899. -#elif defined(__LITTLE_ENDIAN)
  23900. -# if !defined(__constant_htonl)
  23901. -# define __constant_htonl(x) \
  23902. - ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
  23903. - (((unsigned long int)(x) & 0x0000ff00U) << 8) | \
  23904. - (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \
  23905. - (((unsigned long int)(x) & 0xff000000U) >> 24)))
  23906. -# endif
  23907. -# if !defined(__constant_htons)
  23908. -# define __constant_htons(x) \
  23909. - ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
  23910. - (((unsigned short int)(x) & 0xff00) >> 8)))
  23911. -# endif
  23912. -#else
  23913. -# error "Don't know if bytes are big- or little-endian!"
  23914. -#endif
  23915. -
  23916. -#define ntohl(x) \
  23917. -(__builtin_constant_p(x) ? \
  23918. - __constant_htonl((x)) : \
  23919. - __swap32(x))
  23920. -#define htonl(x) \
  23921. -(__builtin_constant_p(x) ? \
  23922. - __constant_htonl((x)) : \
  23923. - __swap32(x))
  23924. -#define ntohs(x) \
  23925. -(__builtin_constant_p(x) ? \
  23926. - __constant_htons((x)) : \
  23927. - __swap16(x))
  23928. -#define htons(x) \
  23929. -(__builtin_constant_p(x) ? \
  23930. - __constant_htons((x)) : \
  23931. - __swap16(x))
  23932. -
  23933. -static inline unsigned long int __swap32(unsigned long int x)
  23934. -{
  23935. - __asm__("xchgb %b0,%h0\n\t"
  23936. - "rorl $16,%0\n\t"
  23937. - "xchgb %b0,%h0"
  23938. - : "=q" (x)
  23939. - : "0" (x));
  23940. - return x;
  23941. -}
  23942. -
  23943. -static inline unsigned short int __swap16(unsigned short int x)
  23944. -{
  23945. - __asm__("xchgb %b0,%h0"
  23946. - : "=q" (x)
  23947. - : "0" (x));
  23948. - return x;
  23949. -}
  23950. -
  23951. -/* Make routines available to all */
  23952. -#define swap32(x) __swap32(x)
  23953. -#define swap16(x) __swap16(x)
  23954. -
  23955. -#include "linux-asm-io.h"
  23956. -
  23957. -typedef unsigned long Address;
  23958. +#include "io.h"
  23959. +#include "byteswap.h"
  23960. +#include "latch.h"
  23961. /* ANSI prototyping macro */
  23962. #ifdef __STDC__
  23963. -#define P(x) x
  23964. +# define P(x) x
  23965. #else
  23966. -#define P(x) ()
  23967. +# define P(x) ()
  23968. #endif
  23969. #endif
  23970. -
  23971. -/*
  23972. - * Local variables:
  23973. - * c-basic-offset: 8
  23974. - * End:
  23975. - */
  23976. Index: b/netboot/otulip.c
  23977. ===================================================================
  23978. --- a/netboot/otulip.c
  23979. +++ /dev/null
  23980. @@ -1,374 +0,0 @@
  23981. -/*
  23982. - Etherboot DEC Tulip driver
  23983. - adapted by Ken Yap from
  23984. -
  23985. - FreeBSD netboot DEC 21143 driver
  23986. -
  23987. - Author: David Sharp
  23988. - date: Nov/98
  23989. -
  23990. - Known to work on DEC DE500 using 21143-PC chipset.
  23991. - Even on cards with the same chipset there can be
  23992. - incompatablity problems with the way media selection
  23993. - and status LED settings are done. See comments below.
  23994. -
  23995. - Some code fragments were taken from verious places,
  23996. - Ken Yap's etherboot, FreeBSD's if_de.c, and various
  23997. - Linux related files. DEC's manuals for the 21143 and
  23998. - SROM format were very helpful. The Linux de driver
  23999. - development page has a number of links to useful
  24000. - related information. Have a look at:
  24001. - ftp://cesdis.gsfc.nasa.gov/pub/linux/drivers/tulip-devel.html
  24002. -
  24003. -*/
  24004. -
  24005. -#include "etherboot.h"
  24006. -#include "nic.h"
  24007. -#include "pci.h"
  24008. -#include "cards.h"
  24009. -#include "otulip.h"
  24010. -
  24011. -static unsigned short vendor, dev_id;
  24012. -static unsigned short ioaddr;
  24013. -static unsigned int *membase;
  24014. -static unsigned char srom[1024];
  24015. -
  24016. -#define BUFLEN 1536 /* must be longword divisable */
  24017. - /* buffers must be longword aligned */
  24018. -
  24019. -/* transmit descriptor and buffer */
  24020. -static struct txdesc txd;
  24021. -
  24022. -/* receive descriptor(s) and buffer(s) */
  24023. -#define NRXD 4
  24024. -static struct rxdesc rxd[NRXD];
  24025. -static int rxd_tail = 0;
  24026. -#ifdef USE_LOWMEM_BUFFER
  24027. -#define rxb ((char *)0x10000 - NRXD * BUFLEN)
  24028. -#define txb ((char *)0x10000 - NRXD * BUFLEN - BUFLEN)
  24029. -#else
  24030. -static unsigned char rxb[NRXD * BUFLEN];
  24031. -static unsigned char txb[BUFLEN];
  24032. -#endif
  24033. -
  24034. -static unsigned char ehdr[ETH_HLEN]; /* buffer for ethernet header */
  24035. -
  24036. -enum tulip_offsets {
  24037. - CSR0=0, CSR1=0x08, CSR2=0x10, CSR3=0x18, CSR4=0x20, CSR5=0x28,
  24038. - CSR6=0x30, CSR7=0x38, CSR8=0x40, CSR9=0x48, CSR10=0x50, CSR11=0x58,
  24039. - CSR12=0x60, CSR13=0x68, CSR14=0x70, CSR15=0x78 };
  24040. -
  24041. -
  24042. -/***************************************************************************/
  24043. -/* 21143 specific stuff */
  24044. -/***************************************************************************/
  24045. -
  24046. -/* XXX assume 33MHz PCI bus, this is not very accurate and should be
  24047. - used only with gross over estimations of required delay times unless
  24048. - you tune UADJUST to your specific processor and I/O subsystem */
  24049. -
  24050. -#define UADJUST 870
  24051. -static void udelay(unsigned long usec) {
  24052. - unsigned long i;
  24053. - for (i=((usec*UADJUST)/33)+1; i>0; i--) (void) TULIP_CSR_READ(csr_0);
  24054. -}
  24055. -
  24056. -/* The following srom related code was taken from FreeBSD's if_de.c */
  24057. -/* with minor alterations to make it work here. the Linux code is */
  24058. -/* better but this was easier to use */
  24059. -
  24060. -static void delay_300ns(void)
  24061. -{
  24062. - int idx;
  24063. - for (idx = (300 / 33) + 1; idx > 0; idx--)
  24064. - (void) TULIP_CSR_READ(csr_busmode);
  24065. -}
  24066. -
  24067. -#define EMIT do { TULIP_CSR_WRITE(csr_srom_mii, csr); delay_300ns(); } while (0)
  24068. -
  24069. -static void srom_idle(void)
  24070. -{
  24071. - unsigned bit, csr;
  24072. -
  24073. - csr = SROMSEL ; EMIT;
  24074. - csr = SROMSEL | SROMRD; EMIT;
  24075. - csr ^= SROMCS; EMIT;
  24076. - csr ^= SROMCLKON; EMIT;
  24077. - /*
  24078. - * Write 25 cycles of 0 which will force the SROM to be idle.
  24079. - */
  24080. - for (bit = 3 + SROM_BITWIDTH + 16; bit > 0; bit--) {
  24081. - csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
  24082. - csr ^= SROMCLKON; EMIT; /* clock high; data valid */
  24083. - }
  24084. - csr ^= SROMCLKOFF; EMIT;
  24085. - csr ^= SROMCS; EMIT;
  24086. - csr = 0; EMIT;
  24087. -}
  24088. -
  24089. -static void srom_read(void)
  24090. -{
  24091. - unsigned idx;
  24092. - const unsigned bitwidth = SROM_BITWIDTH;
  24093. - const unsigned cmdmask = (SROMCMD_RD << bitwidth);
  24094. - const unsigned msb = 1 << (bitwidth + 3 - 1);
  24095. - unsigned lastidx = (1 << bitwidth) - 1;
  24096. -
  24097. - srom_idle();
  24098. -
  24099. - for (idx = 0; idx <= lastidx; idx++) {
  24100. - unsigned lastbit, data, bits, bit, csr;
  24101. - csr = SROMSEL ; EMIT;
  24102. - csr = SROMSEL | SROMRD; EMIT;
  24103. - csr ^= SROMCSON; EMIT;
  24104. - csr ^= SROMCLKON; EMIT;
  24105. -
  24106. - lastbit = 0;
  24107. - for (bits = idx|cmdmask, bit = bitwidth + 3; bit > 0; bit--, bits <<= 1)
  24108. - {
  24109. - const unsigned thisbit = bits & msb;
  24110. - csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
  24111. - if (thisbit != lastbit) {
  24112. - csr ^= SROMDOUT; EMIT; /* clock low; invert data */
  24113. - } else {
  24114. - EMIT;
  24115. - }
  24116. - csr ^= SROMCLKON; EMIT; /* clock high; data valid */
  24117. - lastbit = thisbit;
  24118. - }
  24119. - csr ^= SROMCLKOFF; EMIT;
  24120. -
  24121. - for (data = 0, bits = 0; bits < 16; bits++) {
  24122. - data <<= 1;
  24123. - csr ^= SROMCLKON; EMIT; /* clock high; data valid */
  24124. - data |= TULIP_CSR_READ(csr_srom_mii) & SROMDIN ? 1 : 0;
  24125. - csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
  24126. - }
  24127. - srom[idx*2] = data & 0xFF;
  24128. - srom[idx*2+1] = data >> 8;
  24129. - csr = SROMSEL | SROMRD; EMIT;
  24130. - csr = 0; EMIT;
  24131. - }
  24132. - srom_idle();
  24133. -}
  24134. -
  24135. -/**************************************************************************
  24136. -ETH_RESET - Reset adapter
  24137. -***************************************************************************/
  24138. -static void tulip_reset(struct nic *nic)
  24139. -{
  24140. - int x,cnt=2;
  24141. -
  24142. - outl(0x00000001, ioaddr + CSR0);
  24143. - udelay(1000);
  24144. - /* turn off reset and set cache align=16lword, burst=unlimit */
  24145. - outl(0x01A08000, ioaddr + CSR0);
  24146. -
  24147. - /* for some reason the media selection does not take
  24148. - the first time se it is repeated. */
  24149. -
  24150. - while(cnt--) {
  24151. - /* stop TX,RX processes */
  24152. - if (cnt == 1)
  24153. - outl(0x32404000, ioaddr + CSR6);
  24154. - else
  24155. - outl(0x32000040, ioaddr + CSR6);
  24156. -
  24157. - /* XXX - media selection is vendor specific and hard coded right
  24158. - here. This should be fixed to use the hints in the SROM and
  24159. - allow media selection by the user at runtime. MII support
  24160. - should also be added. Support for chips other than the
  24161. - 21143 should be added here as well */
  24162. -
  24163. - /* start set to 10Mbps half-duplex */
  24164. -
  24165. - /* setup SIA */
  24166. - outl(0x0, ioaddr + CSR13); /* reset SIA */
  24167. - outl(0x7f3f, ioaddr + CSR14);
  24168. - outl(0x8000008, ioaddr + CSR15);
  24169. - outl(0x0, ioaddr + CSR13);
  24170. - outl(0x1, ioaddr + CSR13);
  24171. - outl(0x2404000, ioaddr + CSR6);
  24172. -
  24173. - /* initalize GP */
  24174. - outl(0x8af0008, ioaddr + CSR15);
  24175. - outl(0x50008, ioaddr + CSR15);
  24176. -
  24177. - /* end set to 10Mbps half-duplex */
  24178. -
  24179. - if (vendor == PCI_VENDOR_ID_MACRONIX && dev_id == PCI_DEVICE_ID_MX987x5) {
  24180. - /* do stuff for MX98715 */
  24181. - outl(0x01a80000, ioaddr + CSR6);
  24182. - outl(0xFFFFFFFF, ioaddr + CSR14);
  24183. - outl(0x00001000, ioaddr + CSR12);
  24184. - }
  24185. -
  24186. - outl(0x0, ioaddr + CSR7); /* disable interrupts */
  24187. -
  24188. - /* construct setup packet which is used by the 21143 to
  24189. - program its CAM to recognize interesting MAC addresses */
  24190. -
  24191. - memset(&txd, 0, sizeof(struct txdesc));
  24192. - txd.buf1addr = &txb[0];
  24193. - txd.buf2addr = &txb[0]; /* just in case */
  24194. - txd.buf1sz = 192; /* setup packet must be 192 bytes */
  24195. - txd.buf2sz = 0;
  24196. - txd.control = 0x020; /* setup packet */
  24197. - txd.status = 0x80000000; /* give ownership to 21143 */
  24198. -
  24199. - /* construct perfect filter frame */
  24200. - /* with mac address as first match */
  24201. - /* and broadcast address for all others */
  24202. -
  24203. - for(x=0;x<192;x++) txb[x] = 0xff;
  24204. - txb[0] = nic->node_addr[0];
  24205. - txb[1] = nic->node_addr[1];
  24206. - txb[4] = nic->node_addr[2];
  24207. - txb[5] = nic->node_addr[3];
  24208. - txb[8] = nic->node_addr[4];
  24209. - txb[9] = nic->node_addr[5];
  24210. - outl((unsigned long)&txd, ioaddr + CSR4); /* set xmit buf */
  24211. - outl(0x2406000, ioaddr + CSR6); /* start transmiter */
  24212. -
  24213. - udelay(50000); /* wait for the setup packet to be processed */
  24214. -
  24215. - }
  24216. -
  24217. - /* setup receive descriptor */
  24218. - {
  24219. - int x;
  24220. - for(x=0;x<NRXD;x++) {
  24221. - memset(&rxd[x], 0, sizeof(struct rxdesc));
  24222. - rxd[x].buf1addr = &rxb[x * BUFLEN];
  24223. - rxd[x].buf2addr = 0; /* not used */
  24224. - rxd[x].buf1sz = BUFLEN;
  24225. - rxd[x].buf2sz = 0; /* not used */
  24226. - rxd[x].control = 0x0;
  24227. - rxd[x].status = 0x80000000; /* give ownership it to 21143 */
  24228. - }
  24229. - rxd[NRXD - 1].control = 0x008; /* Set Receive end of ring on la
  24230. -st descriptor */
  24231. - rxd_tail = 0;
  24232. - }
  24233. -
  24234. - /* tell DC211XX where to find rx descriptor list */
  24235. - outl((unsigned long)&rxd[0], ioaddr + CSR3);
  24236. - /* start the receiver */
  24237. - outl(0x2406002, ioaddr + CSR6);
  24238. -
  24239. -}
  24240. -
  24241. -/**************************************************************************
  24242. -ETH_TRANSMIT - Transmit a frame
  24243. -***************************************************************************/
  24244. -static const char padmap[] = {
  24245. - 0, 3, 2, 1};
  24246. -
  24247. -static void tulip_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
  24248. -{
  24249. - unsigned long time;
  24250. -
  24251. - /* setup ethernet header */
  24252. -
  24253. - memcpy(ehdr, d, ETH_ALEN);
  24254. - memcpy(&ehdr[ETH_ALEN], nic->node_addr, ETH_ALEN);
  24255. - ehdr[ETH_ALEN*2] = (t >> 8) & 0xff;
  24256. - ehdr[ETH_ALEN*2+1] = t & 0xff;
  24257. -
  24258. - /* setup the transmit descriptor */
  24259. -
  24260. - memset(&txd, 0, sizeof(struct txdesc));
  24261. -
  24262. - txd.buf1addr = &ehdr[0]; /* ethernet header */
  24263. - txd.buf1sz = ETH_HLEN;
  24264. -
  24265. - txd.buf2addr = p; /* packet to transmit */
  24266. - txd.buf2sz = s;
  24267. -
  24268. - txd.control = 0x188; /* LS+FS+TER */
  24269. -
  24270. - txd.status = 0x80000000; /* give it to 21143 */
  24271. -
  24272. - outl(inl(ioaddr + CSR6) & ~0x00004000, ioaddr + CSR6);
  24273. - outl((unsigned long)&txd, ioaddr + CSR4);
  24274. - outl(inl(ioaddr + CSR6) | 0x00004000, ioaddr + CSR6);
  24275. -
  24276. -/* Wait for transmit to complete before returning. not well tested.
  24277. -
  24278. - time = currticks();
  24279. - while(txd.status & 0x80000000) {
  24280. - if (currticks() - time > 20) {
  24281. - printf("transmit timeout.\n");
  24282. - break;
  24283. - }
  24284. - }
  24285. -*/
  24286. -
  24287. -}
  24288. -
  24289. -/**************************************************************************
  24290. -ETH_POLL - Wait for a frame
  24291. -***************************************************************************/
  24292. -static int tulip_poll(struct nic *nic)
  24293. -{
  24294. - if (rxd[rxd_tail].status & 0x80000000) return 0;
  24295. -
  24296. - nic->packetlen = (rxd[rxd_tail].status & 0x3FFF0000) >> 16;
  24297. -
  24298. - /* copy packet to working buffer */
  24299. - /* XXX - this copy could be avoided with a little more work
  24300. - but for now we are content with it because the optimised
  24301. - memcpy(, , ) is quite fast */
  24302. -
  24303. - memcpy(nic->packet, rxb + rxd_tail * BUFLEN, nic->packetlen);
  24304. -
  24305. - /* return the descriptor and buffer to recieve ring */
  24306. - rxd[rxd_tail].status = 0x80000000;
  24307. - rxd_tail++;
  24308. - if (rxd_tail == NRXD) rxd_tail = 0;
  24309. -
  24310. - return 1;
  24311. -}
  24312. -
  24313. -static void tulip_disable(struct nic *nic)
  24314. -{
  24315. - /* nothing for the moment */
  24316. -}
  24317. -
  24318. -/**************************************************************************
  24319. -ETH_PROBE - Look for an adapter
  24320. -***************************************************************************/
  24321. -struct nic *otulip_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci)
  24322. -{
  24323. - int i;
  24324. -
  24325. - if (io_addrs == 0 || *io_addrs == 0)
  24326. - return (0);
  24327. - vendor = pci->vendor;
  24328. - dev_id = pci->dev_id;
  24329. - ioaddr = *io_addrs;
  24330. - membase = (unsigned int *)pci->membase;
  24331. -
  24332. - /* wakeup chip */
  24333. - pcibios_write_config_dword(pci->bus,pci->devfn,0x40,0x00000000);
  24334. -
  24335. - /* Stop the chip's Tx and Rx processes. */
  24336. - /* outl(inl(ioaddr + CSR6) & ~0x2002, ioaddr + CSR6); */
  24337. - /* Clear the missed-packet counter. */
  24338. - /* (volatile int)inl(ioaddr + CSR8); */
  24339. -
  24340. - srom_read();
  24341. -
  24342. - for (i=0; i < ETH_ALEN; i++)
  24343. - nic->node_addr[i] = srom[20+i];
  24344. -
  24345. - printf("Tulip %! at ioaddr %#hX\n", nic->node_addr, ioaddr);
  24346. -
  24347. - tulip_reset(nic);
  24348. -
  24349. - nic->reset = tulip_reset;
  24350. - nic->poll = tulip_poll;
  24351. - nic->transmit = tulip_transmit;
  24352. - nic->disable = tulip_disable;
  24353. - return nic;
  24354. -}
  24355. Index: b/netboot/otulip.h
  24356. ===================================================================
  24357. --- a/netboot/otulip.h
  24358. +++ /dev/null
  24359. @@ -1,76 +0,0 @@
  24360. -/* mostly stolen from FreeBSD if_de.c, if_devar.h */
  24361. -
  24362. -#define TULIP_CSR_READ(csr) (membase[csr*2])
  24363. -#define CSR_READ(csr) (membase[csr*2])
  24364. -#define TULIP_CSR_WRITE(csr, val) (membase[csr*2] = val)
  24365. -#define CSR_WRITE(csr, val) (membase[csr*2] = val)
  24366. -
  24367. -#define csr_0 0
  24368. -#define csr_1 1
  24369. -#define csr_2 2
  24370. -#define csr_3 3
  24371. -#define csr_4 4
  24372. -#define csr_5 5
  24373. -#define csr_6 6
  24374. -#define csr_7 7
  24375. -#define csr_8 8
  24376. -#define csr_9 9
  24377. -#define csr_10 10
  24378. -#define csr_11 11
  24379. -#define csr_12 12
  24380. -#define csr_13 13
  24381. -#define csr_14 14
  24382. -#define csr_15 15
  24383. -
  24384. -#define csr_busmode csr_0
  24385. -#define csr_txpoll csr_1
  24386. -#define csr_rxpoll csr_2
  24387. -#define csr_rxlist csr_3
  24388. -#define csr_txlist csr_4
  24389. -#define csr_status csr_5
  24390. -#define csr_command csr_6
  24391. -#define csr_intr csr_7
  24392. -#define csr_missed_frames csr_8
  24393. -#define csr_enetrom csr_9 /* 21040 */
  24394. -#define csr_reserved csr_10 /* 21040 */
  24395. -#define csr_full_duplex csr_11 /* 21040 */
  24396. -#define csr_bootrom csr_10 /* 21041/21140A/?? */
  24397. -#define csr_gp csr_12 /* 21140* */
  24398. -#define csr_watchdog csr_15 /* 21140* */
  24399. -#define csr_gp_timer csr_11 /* 21041/21140* */
  24400. -#define csr_srom_mii csr_9 /* 21041/21140* */
  24401. -#define csr_sia_status csr_12 /* 2104x */
  24402. -#define csr_sia_connectivity csr_13 /* 2104x */
  24403. -#define csr_sia_tx_rx csr_14 /* 2104x */
  24404. -#define csr_sia_general csr_15 /* 2104x */
  24405. -
  24406. -#define SROMSEL 0x0800
  24407. -#define SROMCS 0x0001
  24408. -#define SROMCLKON 0x0002
  24409. -#define SROMCLKOFF 0x0002
  24410. -#define SROMRD 0x4000
  24411. -#define SROMWR 0x2000
  24412. -#define SROM_BITWIDTH 6
  24413. -#define SROMCMD_RD 6
  24414. -#define SROMCSON 0x0001
  24415. -#define SROMDOUT 0x0004
  24416. -#define SROMDIN 0x0008
  24417. -
  24418. -
  24419. -struct txdesc {
  24420. - unsigned long status; /* owner, status */
  24421. - unsigned long buf1sz:11, /* size of buffer 1 */
  24422. - buf2sz:11, /* size of buffer 2 */
  24423. - control:10; /* control bits */
  24424. - const unsigned char *buf1addr; /* buffer 1 address */
  24425. - const unsigned char *buf2addr; /* buffer 2 address */
  24426. -};
  24427. -
  24428. -struct rxdesc {
  24429. - unsigned long status; /* owner, status */
  24430. - unsigned long buf1sz:11, /* size of buffer 1 */
  24431. - buf2sz:11, /* size of buffer 2 */
  24432. - control:10; /* control bits */
  24433. - unsigned char *buf1addr; /* buffer 1 address */
  24434. - unsigned char *buf2addr; /* buffer 2 address */
  24435. -};
  24436. Index: b/netboot/pci.c
  24437. ===================================================================
  24438. --- a/netboot/pci.c
  24439. +++ b/netboot/pci.c
  24440. @@ -1,15 +1,3 @@
  24441. -/*
  24442. -** Support for NE2000 PCI clones added David Monro June 1997
  24443. -** Generalised to other NICs by Ken Yap July 1997
  24444. -**
  24445. -** Most of this is taken from:
  24446. -**
  24447. -** /usr/src/linux/drivers/pci/pci.c
  24448. -** /usr/src/linux/include/linux/pci.h
  24449. -** /usr/src/linux/arch/i386/bios32.c
  24450. -** /usr/src/linux/include/linux/bios32.h
  24451. -** /usr/src/linux/drivers/net/ne.c
  24452. -*/
  24453. /*
  24454. * This program is free software; you can redistribute it and/or
  24455. @@ -18,402 +6,294 @@
  24456. * your option) any later version.
  24457. */
  24458. -#include "etherboot.h"
  24459. +#include "grub.h"
  24460. #include "pci.h"
  24461. -/*#define DEBUG 1*/
  24462. -#define DEBUG 0
  24463. -
  24464. -#ifdef CONFIG_PCI_DIRECT
  24465. -#define PCIBIOS_SUCCESSFUL 0x00
  24466. -
  24467. -/*
  24468. - * Functions for accessing PCI configuration space with type 1 accesses
  24469. - */
  24470. -
  24471. -#define CONFIG_CMD(bus, device_fn, where) (0x80000000 | (bus << 16) | (device_fn << 8) | (where & ~3))
  24472. -
  24473. -int pcibios_read_config_byte(unsigned int bus, unsigned int device_fn,
  24474. - unsigned int where, unsigned char *value)
  24475. +unsigned long virt_offset = 0;
  24476. +unsigned long virt_to_phys(volatile const void *virt_addr)
  24477. {
  24478. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  24479. - *value = inb(0xCFC + (where&3));
  24480. - return PCIBIOS_SUCCESSFUL;
  24481. + return ((unsigned long)virt_addr) + virt_offset;
  24482. }
  24483. -int pcibios_read_config_word (unsigned int bus,
  24484. - unsigned int device_fn, unsigned int where, unsigned short *value)
  24485. +void *phys_to_virt(unsigned long phys_addr)
  24486. {
  24487. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  24488. - *value = inw(0xCFC + (where&2));
  24489. - return PCIBIOS_SUCCESSFUL;
  24490. + return (void *)(phys_addr - virt_offset);
  24491. }
  24492. -int pcibios_read_config_dword (unsigned int bus, unsigned int device_fn,
  24493. - unsigned int where, unsigned int *value)
  24494. -{
  24495. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  24496. - *value = inl(0xCFC);
  24497. - return PCIBIOS_SUCCESSFUL;
  24498. -}
  24499. +#ifdef INCLUDE_3C595
  24500. +extern struct pci_driver t595_driver;
  24501. +#endif /* INCLUDE_3C595 */
  24502. -int pcibios_write_config_byte (unsigned int bus, unsigned int device_fn,
  24503. - unsigned int where, unsigned char value)
  24504. -{
  24505. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  24506. - outb(value, 0xCFC + (where&3));
  24507. - return PCIBIOS_SUCCESSFUL;
  24508. -}
  24509. +#ifdef INCLUDE_3C90X
  24510. +extern struct pci_driver a3c90x_driver;
  24511. +#endif /* INCLUDE_3C90X */
  24512. -int pcibios_write_config_word (unsigned int bus, unsigned int device_fn,
  24513. - unsigned int where, unsigned short value)
  24514. -{
  24515. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  24516. - outw(value, 0xCFC + (where&2));
  24517. - return PCIBIOS_SUCCESSFUL;
  24518. -}
  24519. +#ifdef INCLUDE_DAVICOM
  24520. +extern struct pci_driver davicom_driver;
  24521. +#endif /* INCLUDE_DAVICOM */
  24522. -int pcibios_write_config_dword (unsigned int bus, unsigned int device_fn, unsigned int where, unsigned int value)
  24523. -{
  24524. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  24525. - outl(value, 0xCFC);
  24526. - return PCIBIOS_SUCCESSFUL;
  24527. -}
  24528. +#ifdef INCLUDE_E1000
  24529. +extern struct pci_driver e1000_driver;
  24530. +#endif /* INCLUDE_E1000 */
  24531. -#undef CONFIG_CMD
  24532. +#ifdef INCLUDE_EEPRO100
  24533. +extern struct pci_driver eepro100_driver;
  24534. +#endif /* INCLUDE_EEPRO100 */
  24535. -#else /* CONFIG_PCI_DIRECT not defined */
  24536. +#ifdef INCLUDE_EPIC100
  24537. +extern struct pci_driver epic100_driver;
  24538. +#endif /* INCLUDE_EPIC100 */
  24539. -static struct {
  24540. - unsigned long address;
  24541. - unsigned short segment;
  24542. -} bios32_indirect = { 0, KERN_CODE_SEG };
  24543. -
  24544. -static long pcibios_entry;
  24545. -static struct {
  24546. - unsigned long address;
  24547. - unsigned short segment;
  24548. -} pci_indirect = { 0, KERN_CODE_SEG };
  24549. +#ifdef INCLUDE_FORCEDETH
  24550. +extern struct pci_driver forcedeth_driver;
  24551. +#endif /* INCLUDE_FORCEDETH */
  24552. -static unsigned long bios32_service(unsigned long service)
  24553. -{
  24554. - unsigned char return_code; /* %al */
  24555. - unsigned long address; /* %ebx */
  24556. - unsigned long length; /* %ecx */
  24557. - unsigned long entry; /* %edx */
  24558. - unsigned long flags;
  24559. -
  24560. - save_flags(flags);
  24561. - __asm__(
  24562. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  24563. - "lcall (%%edi)"
  24564. -#else
  24565. - "lcall *(%%edi)"
  24566. -#endif
  24567. - : "=a" (return_code),
  24568. - "=b" (address),
  24569. - "=c" (length),
  24570. - "=d" (entry)
  24571. - : "0" (service),
  24572. - "1" (0),
  24573. - "D" (&bios32_indirect));
  24574. - restore_flags(flags);
  24575. -
  24576. - switch (return_code) {
  24577. - case 0:
  24578. - return address + entry;
  24579. - case 0x80: /* Not present */
  24580. - printf("bios32_service(%d) : not present\n", service);
  24581. - return 0;
  24582. - default: /* Shouldn't happen */
  24583. - printf("bios32_service(%d) : returned %#X, mail drew@colorado.edu\n",
  24584. - service, return_code);
  24585. - return 0;
  24586. - }
  24587. -}
  24588. +#ifdef INCLUDE_NATSEMI
  24589. +extern struct pci_driver natsemi_driver;
  24590. +#endif /* INCLUDE_NATSEMI */
  24591. -int pcibios_read_config_byte(unsigned int bus,
  24592. - unsigned int device_fn, unsigned int where, unsigned char *value)
  24593. -{
  24594. - unsigned long ret;
  24595. - unsigned long bx = (bus << 8) | device_fn;
  24596. - unsigned long flags;
  24597. -
  24598. - save_flags(flags);
  24599. - __asm__(
  24600. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  24601. - "lcall (%%esi)\n\t"
  24602. -#else
  24603. - "lcall *(%%esi)\n\t"
  24604. -#endif
  24605. - "jc 1f\n\t"
  24606. - "xor %%ah, %%ah\n"
  24607. - "1:"
  24608. - : "=c" (*value),
  24609. - "=a" (ret)
  24610. - : "1" (PCIBIOS_READ_CONFIG_BYTE),
  24611. - "b" (bx),
  24612. - "D" ((long) where),
  24613. - "S" (&pci_indirect));
  24614. - restore_flags(flags);
  24615. - return (int) (ret & 0xff00) >> 8;
  24616. -}
  24617. +#ifdef INCLUDE_NS83820
  24618. +extern struct pci_driver ns83820_driver;
  24619. +#endif /* INCLUDE_NS83820 */
  24620. -int pcibios_read_config_word(unsigned int bus,
  24621. - unsigned int device_fn, unsigned int where, unsigned short *value)
  24622. -{
  24623. - unsigned long ret;
  24624. - unsigned long bx = (bus << 8) | device_fn;
  24625. - unsigned long flags;
  24626. -
  24627. - save_flags(flags);
  24628. - __asm__(
  24629. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  24630. - "lcall (%%esi)\n\t"
  24631. -#else
  24632. - "lcall *(%%esi)\n\t"
  24633. -#endif
  24634. - "jc 1f\n\t"
  24635. - "xor %%ah, %%ah\n"
  24636. - "1:"
  24637. - : "=c" (*value),
  24638. - "=a" (ret)
  24639. - : "1" (PCIBIOS_READ_CONFIG_WORD),
  24640. - "b" (bx),
  24641. - "D" ((long) where),
  24642. - "S" (&pci_indirect));
  24643. - restore_flags(flags);
  24644. - return (int) (ret & 0xff00) >> 8;
  24645. -}
  24646. +#ifdef INCLUDE_NS8390
  24647. +extern struct pci_driver nepci_driver;
  24648. +#endif /* INCLUDE_NS8390 */
  24649. -int pcibios_read_config_dword(unsigned int bus,
  24650. - unsigned int device_fn, unsigned int where, unsigned int *value)
  24651. -{
  24652. - unsigned long ret;
  24653. - unsigned long bx = (bus << 8) | device_fn;
  24654. - unsigned long flags;
  24655. -
  24656. - save_flags(flags);
  24657. - __asm__(
  24658. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  24659. - "lcall (%%esi)\n\t"
  24660. -#else
  24661. - "lcall *(%%esi)\n\t"
  24662. -#endif
  24663. - "jc 1f\n\t"
  24664. - "xor %%ah, %%ah\n"
  24665. - "1:"
  24666. - : "=c" (*value),
  24667. - "=a" (ret)
  24668. - : "1" (PCIBIOS_READ_CONFIG_DWORD),
  24669. - "b" (bx),
  24670. - "D" ((long) where),
  24671. - "S" (&pci_indirect));
  24672. - restore_flags(flags);
  24673. - return (int) (ret & 0xff00) >> 8;
  24674. -}
  24675. +#ifdef INCLUDE_PCNET32
  24676. +extern struct pci_driver pcnet32_driver;
  24677. +#endif /* INCLUDE_PCNET32 */
  24678. -int pcibios_write_config_byte (unsigned int bus,
  24679. - unsigned int device_fn, unsigned int where, unsigned char value)
  24680. -{
  24681. - unsigned long ret;
  24682. - unsigned long bx = (bus << 8) | device_fn;
  24683. - unsigned long flags;
  24684. -
  24685. - save_flags(flags); cli();
  24686. - __asm__(
  24687. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  24688. - "lcall (%%esi)\n\t"
  24689. -#else
  24690. - "lcall *(%%esi)\n\t"
  24691. -#endif
  24692. - "jc 1f\n\t"
  24693. - "xor %%ah, %%ah\n"
  24694. - "1:"
  24695. - : "=a" (ret)
  24696. - : "0" (PCIBIOS_WRITE_CONFIG_BYTE),
  24697. - "c" (value),
  24698. - "b" (bx),
  24699. - "D" ((long) where),
  24700. - "S" (&pci_indirect));
  24701. - restore_flags(flags);
  24702. - return (int) (ret & 0xff00) >> 8;
  24703. -}
  24704. +#ifdef INCLUDE_PNIC
  24705. +extern struct pci_driver pnic_driver;
  24706. +#endif /* INCLUDE_PNIC */
  24707. -int pcibios_write_config_word (unsigned int bus,
  24708. - unsigned int device_fn, unsigned int where, unsigned short value)
  24709. -{
  24710. - unsigned long ret;
  24711. - unsigned long bx = (bus << 8) | device_fn;
  24712. - unsigned long flags;
  24713. -
  24714. - save_flags(flags); cli();
  24715. - __asm__(
  24716. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  24717. - "lcall (%%esi)\n\t"
  24718. -#else
  24719. - "lcall *(%%esi)\n\t"
  24720. -#endif
  24721. - "jc 1f\n\t"
  24722. - "xor %%ah, %%ah\n"
  24723. - "1:"
  24724. - : "=a" (ret)
  24725. - : "0" (PCIBIOS_WRITE_CONFIG_WORD),
  24726. - "c" (value),
  24727. - "b" (bx),
  24728. - "D" ((long) where),
  24729. - "S" (&pci_indirect));
  24730. - restore_flags(flags);
  24731. - return (int) (ret & 0xff00) >> 8;
  24732. -}
  24733. +#ifdef INCLUDE_RTL8139
  24734. +extern struct pci_driver rtl8139_driver;
  24735. +#endif /* INCLUDE_RTL8139 */
  24736. -int pcibios_write_config_dword (unsigned int bus,
  24737. - unsigned int device_fn, unsigned int where, unsigned int value)
  24738. -{
  24739. - unsigned long ret;
  24740. - unsigned long bx = (bus << 8) | device_fn;
  24741. - unsigned long flags;
  24742. -
  24743. - save_flags(flags); cli();
  24744. - __asm__(
  24745. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  24746. - "lcall (%%esi)\n\t"
  24747. -#else
  24748. - "lcall *(%%esi)\n\t"
  24749. -#endif
  24750. - "jc 1f\n\t"
  24751. - "xor %%ah, %%ah\n"
  24752. - "1:"
  24753. - : "=a" (ret)
  24754. - : "0" (PCIBIOS_WRITE_CONFIG_DWORD),
  24755. - "c" (value),
  24756. - "b" (bx),
  24757. - "D" ((long) where),
  24758. - "S" (&pci_indirect));
  24759. - restore_flags(flags);
  24760. - return (int) (ret & 0xff00) >> 8;
  24761. -}
  24762. +#ifdef INCLUDE_SIS900
  24763. +extern struct pci_driver sis900_driver;
  24764. +extern struct pci_driver sis_bridge_driver;
  24765. +#endif /* INCLUDE_SIS900 */
  24766. -static void check_pcibios(void)
  24767. -{
  24768. - unsigned long signature;
  24769. - unsigned char present_status;
  24770. - unsigned char major_revision;
  24771. - unsigned char minor_revision;
  24772. - unsigned long flags;
  24773. - int pack;
  24774. -
  24775. - if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
  24776. - pci_indirect.address = pcibios_entry;
  24777. -
  24778. - save_flags(flags);
  24779. - __asm__(
  24780. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  24781. - "lcall (%%edi)\n\t"
  24782. -#else
  24783. - "lcall *(%%edi)\n\t"
  24784. -#endif
  24785. - "jc 1f\n\t"
  24786. - "xor %%ah, %%ah\n"
  24787. - "1:\tshl $8, %%eax\n\t"
  24788. - "movw %%bx, %%ax"
  24789. - : "=d" (signature),
  24790. - "=a" (pack)
  24791. - : "1" (PCIBIOS_PCI_BIOS_PRESENT),
  24792. - "D" (&pci_indirect)
  24793. - : "bx", "cx");
  24794. - restore_flags(flags);
  24795. -
  24796. - present_status = (pack >> 16) & 0xff;
  24797. - major_revision = (pack >> 8) & 0xff;
  24798. - minor_revision = pack & 0xff;
  24799. - if (present_status || (signature != PCI_SIGNATURE)) {
  24800. - printf("ERROR: BIOS32 says PCI BIOS, but no PCI "
  24801. - "BIOS????\n");
  24802. - pcibios_entry = 0;
  24803. - }
  24804. -#if DEBUG
  24805. - if (pcibios_entry) {
  24806. - printf ("pcibios_init : PCI BIOS revision %hhX.%hhX"
  24807. - " entry at %#X\n", major_revision,
  24808. - minor_revision, pcibios_entry);
  24809. - }
  24810. -#endif
  24811. - }
  24812. -}
  24813. +#ifdef INCLUDE_SUNDANCE
  24814. +extern struct pci_driver sundance_driver;
  24815. +#endif /* INCLUDE_SUNDANCE */
  24816. -static void pcibios_init(void)
  24817. -{
  24818. - union bios32 *check;
  24819. - unsigned char sum;
  24820. - int i, length;
  24821. - unsigned long bios32_entry = 0;
  24822. -
  24823. - /*
  24824. - * Follow the standard procedure for locating the BIOS32 Service
  24825. - * directory by scanning the permissible address range from
  24826. - * 0xe0000 through 0xfffff for a valid BIOS32 structure.
  24827. - *
  24828. - */
  24829. +#ifdef INCLUDE_TG3
  24830. +extern struct pci_driver tg3_driver;
  24831. +#endif /* INCLUDE_TG3 */
  24832. +
  24833. +#ifdef INCLUDE_TLAN
  24834. +extern struct pci_driver tlan_driver;
  24835. +#endif /* INCLUDE_TLAN */
  24836. +
  24837. +#ifdef INCLUDE_TULIP
  24838. +extern struct pci_driver tulip_driver;
  24839. +#endif /* INCLUDE_TULIP */
  24840. +
  24841. +#ifdef INCLUDE_UNDI
  24842. +extern struct pci_driver undi_driver;
  24843. +#endif /* INCLUDE_UNDI */
  24844. +
  24845. +#ifdef INCLUDE_VIA_RHINE
  24846. +extern struct pci_driver rhine_driver;
  24847. +#endif/* INCLUDE_VIA_RHINE */
  24848. +
  24849. +#ifdef INCLUDE_W89C840
  24850. +extern struct pci_driver w89c840_driver;
  24851. +#endif /* INCLUDE_W89C840 */
  24852. +
  24853. +#ifdef INCLUDE_R8169
  24854. +extern struct pci_driver r8169_driver;
  24855. +#endif /* INCLUDE_R8169 */
  24856. +
  24857. +static const struct pci_driver *pci_drivers[] = {
  24858. +
  24859. +#ifdef INCLUDE_3C595
  24860. + &t595_driver,
  24861. +#endif /* INCLUDE_3C595 */
  24862. +
  24863. +#ifdef INCLUDE_3C90X
  24864. + &a3c90x_driver,
  24865. +#endif /* INCLUDE_3C90X */
  24866. +
  24867. +#ifdef INCLUDE_DAVICOM
  24868. + &davicom_driver,
  24869. +#endif /* INCLUDE_DAVICOM */
  24870. +
  24871. +#ifdef INCLUDE_E1000
  24872. + &e1000_driver,
  24873. +#endif /* INCLUDE_E1000 */
  24874. +
  24875. +#ifdef INCLUDE_EEPRO100
  24876. + &eepro100_driver,
  24877. +#endif /* INCLUDE_EEPRO100 */
  24878. +
  24879. +#ifdef INCLUDE_EPIC100
  24880. + &epic100_driver,
  24881. +#endif /* INCLUDE_EPIC100 */
  24882. +
  24883. +#ifdef INCLUDE_FORCEDETH
  24884. + &forcedeth_driver,
  24885. +#endif /* INCLUDE_FORCEDETH */
  24886. +
  24887. +#ifdef INCLUDE_NATSEMI
  24888. + &natsemi_driver,
  24889. +#endif /* INCLUDE_NATSEMI */
  24890. +
  24891. +#ifdef INCLUDE_NS83820
  24892. + &ns83820_driver,
  24893. +#endif /* INCLUDE_NS83820 */
  24894. +
  24895. +#ifdef INCLUDE_NS8390
  24896. + &nepci_driver,
  24897. +#endif /* INCLUDE_NS8390 */
  24898. +
  24899. +#ifdef INCLUDE_PCNET32
  24900. + &pcnet32_driver,
  24901. +#endif /* INCLUDE_PCNET32 */
  24902. +
  24903. +#ifdef INCLUDE_PNIC
  24904. + &pnic_driver,
  24905. +#endif /* INCLUDE_PNIC */
  24906. - for (check = (union bios32 *) 0xe0000; check <= (union bios32 *) 0xffff0; ++check) {
  24907. - if (check->fields.signature != BIOS32_SIGNATURE)
  24908. +#ifdef INCLUDE_RTL8139
  24909. + &rtl8139_driver,
  24910. +#endif /* INCLUDE_RTL8139 */
  24911. +
  24912. +#ifdef INCLUDE_SIS900
  24913. + &sis900_driver,
  24914. + &sis_bridge_driver,
  24915. +#endif /* INCLUDE_SIS900 */
  24916. +
  24917. +#ifdef INCLUDE_SUNDANCE
  24918. + &sundance_driver,
  24919. +#endif /* INCLUDE_SUNDANCE */
  24920. +
  24921. +#ifdef INCLUDE_TG3
  24922. + & tg3_driver,
  24923. +#endif /* INCLUDE_TG3 */
  24924. +
  24925. +#ifdef INCLUDE_TLAN
  24926. + &tlan_driver,
  24927. +#endif /* INCLUDE_TLAN */
  24928. +
  24929. +#ifdef INCLUDE_TULIP
  24930. + & tulip_driver,
  24931. +#endif /* INCLUDE_TULIP */
  24932. +
  24933. +#ifdef INCLUDE_VIA_RHINE
  24934. + &rhine_driver,
  24935. +#endif/* INCLUDE_VIA_RHINE */
  24936. +
  24937. +#ifdef INCLUDE_W89C840
  24938. + &w89c840_driver,
  24939. +#endif /* INCLUDE_W89C840 */
  24940. +
  24941. +#ifdef INCLUDE_R8169
  24942. + &r8169_driver,
  24943. +#endif /* INCLUDE_R8169 */
  24944. +
  24945. +/* We must be the last one */
  24946. +#ifdef INCLUDE_UNDI
  24947. + &undi_driver,
  24948. +#endif /* INCLUDE_UNDI */
  24949. +
  24950. + 0
  24951. +};
  24952. +
  24953. +static void scan_drivers(
  24954. + int type,
  24955. + uint32_t class, uint16_t vendor, uint16_t device,
  24956. + const struct pci_driver *last_driver, struct pci_device *dev)
  24957. +{
  24958. + const struct pci_driver *skip_driver = last_driver;
  24959. + /* Assume there is only one match of the correct type */
  24960. + const struct pci_driver *driver;
  24961. + int i, j;
  24962. +
  24963. + for(j = 0; pci_drivers[j] != 0; j++){
  24964. + driver = pci_drivers[j];
  24965. + if (driver->type != type)
  24966. continue;
  24967. - length = check->fields.length * 16;
  24968. - if (!length)
  24969. + if (skip_driver) {
  24970. + if (skip_driver == driver)
  24971. + skip_driver = 0;
  24972. continue;
  24973. - sum = 0;
  24974. - for (i = 0; i < length ; ++i)
  24975. - sum += check->chars[i];
  24976. - if (sum != 0)
  24977. + }
  24978. + for(i = 0; i < driver->id_count; i++) {
  24979. + if ((vendor == driver->ids[i].vendor) &&
  24980. + (device == driver->ids[i].dev_id)) {
  24981. +
  24982. + dev->driver = driver;
  24983. + dev->name = driver->ids[i].name;
  24984. +
  24985. + goto out;
  24986. + }
  24987. + }
  24988. + }
  24989. + if (!class) {
  24990. + goto out;
  24991. + }
  24992. + for(j = 0; pci_drivers[j] != 0; j++){
  24993. + driver = pci_drivers[j];
  24994. + if (driver->type != type)
  24995. continue;
  24996. - if (check->fields.revision != 0) {
  24997. - printf("pcibios_init : unsupported revision %d at %#X, mail drew@colorado.edu\n",
  24998. - check->fields.revision, check);
  24999. + if (skip_driver) {
  25000. + if (skip_driver == driver)
  25001. + skip_driver = 0;
  25002. continue;
  25003. }
  25004. -#if DEBUG
  25005. - printf("pcibios_init : BIOS32 Service Directory "
  25006. - "structure at %#X\n", check);
  25007. -#endif
  25008. - if (!bios32_entry) {
  25009. - if (check->fields.entry >= 0x100000) {
  25010. - printf("pcibios_init: entry in high "
  25011. - "memory, giving up\n");
  25012. - return;
  25013. - } else {
  25014. - bios32_entry = check->fields.entry;
  25015. -#if DEBUG
  25016. - printf("pcibios_init : BIOS32 Service Directory"
  25017. - " entry at %#X\n", bios32_entry);
  25018. -#endif
  25019. - bios32_indirect.address = bios32_entry;
  25020. - }
  25021. + if (last_driver == driver)
  25022. + continue;
  25023. + if ((class >> 8) == driver->class) {
  25024. + dev->driver = driver;
  25025. + dev->name = driver->name;
  25026. + goto out;
  25027. }
  25028. }
  25029. - if (bios32_entry)
  25030. - check_pcibios();
  25031. + out:
  25032. + return;
  25033. }
  25034. -#endif /* CONFIG_PCI_DIRECT not defined*/
  25035. -static void scan_bus(struct pci_device *pcidev)
  25036. +void scan_pci_bus(int type, struct pci_device *dev)
  25037. {
  25038. - unsigned int devfn, l, bus, buses;
  25039. + unsigned int first_bus, first_devfn;
  25040. + const struct pci_driver *first_driver;
  25041. + unsigned int devfn, bus, buses;
  25042. unsigned char hdr_type = 0;
  25043. - unsigned short vendor, device;
  25044. - unsigned int membase, ioaddr, romaddr;
  25045. - int i, reg;
  25046. - unsigned int pci_ioaddr = 0;
  25047. -
  25048. + uint32_t class;
  25049. + uint16_t vendor, device;
  25050. + uint32_t l, membase, ioaddr, romaddr;
  25051. + int reg;
  25052. +
  25053. + EnterFunction("scan_pci_bus");
  25054. + first_bus = 0;
  25055. + first_devfn = 0;
  25056. + first_driver = 0;
  25057. + if (dev->driver) {
  25058. + first_driver = dev->driver;
  25059. + first_bus = dev->bus;
  25060. + first_devfn = dev->devfn;
  25061. + /* Re read the header type on a restart */
  25062. + pcibios_read_config_byte(first_bus, first_devfn & ~0x7,
  25063. + PCI_HEADER_TYPE, &hdr_type);
  25064. + dev->driver = 0;
  25065. + dev->bus = 0;
  25066. + dev->devfn = 0;
  25067. + }
  25068. +
  25069. /* Scan all PCI buses, until we find our card.
  25070. - * We could be smart only scan the required busses but that
  25071. + * We could be smart only scan the required buses but that
  25072. * is error prone, and tricky.
  25073. - * By scanning all possible pci busses in order we should find
  25074. + * By scanning all possible pci buses in order we should find
  25075. * our card eventually.
  25076. */
  25077. buses=256;
  25078. - for (bus = 0; bus < buses; ++bus) {
  25079. - for (devfn = 0; devfn < 0xff; ++devfn) {
  25080. + for (bus = first_bus; bus < buses; ++bus) {
  25081. + for (devfn = first_devfn; devfn < 0xff; ++devfn, first_driver = 0) {
  25082. if (PCI_FUNC (devfn) == 0)
  25083. pcibios_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type);
  25084. else if (!(hdr_type & 0x80)) /* not a multi-function device */
  25085. @@ -421,61 +301,90 @@
  25086. pcibios_read_config_dword(bus, devfn, PCI_VENDOR_ID, &l);
  25087. /* some broken boards return 0 if a slot is empty: */
  25088. if (l == 0xffffffff || l == 0x00000000) {
  25089. - hdr_type = 0;
  25090. continue;
  25091. }
  25092. vendor = l & 0xffff;
  25093. device = (l >> 16) & 0xffff;
  25094. + pcibios_read_config_dword(bus, devfn, PCI_REVISION, &l);
  25095. + class = (l >> 8) & 0xffffff;
  25096. #if DEBUG
  25097. - printf("bus %hhX, function %hhX, vendor %hX, device %hX\n",
  25098. - bus, devfn, vendor, device);
  25099. + {
  25100. + int i;
  25101. + printf("%hhx:%hhx.%hhx [%hX/%hX] ---- ",
  25102. + bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
  25103. + vendor, device);
  25104. +#if DEBUG > 1
  25105. + for(i = 0; i < 256; i++) {
  25106. + unsigned char byte;
  25107. + if ((i & 0xf) == 0) {
  25108. + printf("%hhx: ", i);
  25109. + }
  25110. + pcibios_read_config_byte(bus, devfn, i, &byte);
  25111. + printf("%hhx ", byte);
  25112. + if ((i & 0xf) == 0xf) {
  25113. + printf("\n");
  25114. + }
  25115. + }
  25116. +#endif
  25117. +
  25118. + }
  25119. +#endif
  25120. + scan_drivers(type, class, vendor, device, first_driver, dev);
  25121. + if (!dev->driver){
  25122. +#if DEBUG
  25123. + printf("No driver fit.\n");
  25124. #endif
  25125. - for (i = 0; pcidev[i].vendor != 0; i++) {
  25126. - if (vendor != pcidev[i].vendor
  25127. - || device != pcidev[i].dev_id)
  25128. + continue;
  25129. + }
  25130. +#if DEBUG
  25131. + printf("Get Driver:\n");
  25132. +#endif
  25133. + dev->devfn = devfn;
  25134. + dev->bus = bus;
  25135. + dev->class = class;
  25136. + dev->vendor = vendor;
  25137. + dev->dev_id = device;
  25138. +
  25139. +
  25140. + /* Get the ROM base address */
  25141. + pcibios_read_config_dword(bus, devfn,
  25142. + PCI_ROM_ADDRESS, &romaddr);
  25143. + romaddr >>= 10;
  25144. + dev->romaddr = romaddr;
  25145. +
  25146. + /* Get the ``membase'' */
  25147. + pcibios_read_config_dword(bus, devfn,
  25148. + PCI_BASE_ADDRESS_1, &membase);
  25149. + dev->membase = membase;
  25150. +
  25151. + /* Get the ``ioaddr'' */
  25152. + for (reg = PCI_BASE_ADDRESS_0; reg <= PCI_BASE_ADDRESS_5; reg += 4) {
  25153. + pcibios_read_config_dword(bus, devfn, reg, &ioaddr);
  25154. + if ((ioaddr & PCI_BASE_ADDRESS_IO_MASK) == 0 || (ioaddr & PCI_BASE_ADDRESS_SPACE_IO) == 0)
  25155. continue;
  25156. - pcidev[i].devfn = devfn;
  25157. - pcidev[i].bus = bus;
  25158. - for (reg = PCI_BASE_ADDRESS_0; reg <= PCI_BASE_ADDRESS_5; reg += 4) {
  25159. - pcibios_read_config_dword(bus, devfn, reg, &ioaddr);
  25160. -
  25161. - if ((ioaddr & PCI_BASE_ADDRESS_IO_MASK) == 0 || (ioaddr & PCI_BASE_ADDRESS_SPACE_IO) == 0)
  25162. - continue;
  25163. - /* Strip the I/O address out of the returned value */
  25164. - ioaddr &= PCI_BASE_ADDRESS_IO_MASK;
  25165. - /* Get the memory base address */
  25166. - pcibios_read_config_dword(bus, devfn,
  25167. - PCI_BASE_ADDRESS_1, &membase);
  25168. - /* Get the ROM base address */
  25169. - pcibios_read_config_dword(bus, devfn, PCI_ROM_ADDRESS, &romaddr);
  25170. - romaddr >>= 10;
  25171. - printf("Found %s at %#hx, ROM address %#hx\n",
  25172. - pcidev[i].name, ioaddr, romaddr);
  25173. - /* Take the first one or the one that matches in boot ROM address */
  25174. - if (pci_ioaddr == 0 || romaddr == ((unsigned long) rom.rom_segment << 4)) {
  25175. - pcidev[i].membase = membase;
  25176. - pcidev[i].ioaddr = ioaddr;
  25177. - return;
  25178. - }
  25179. - }
  25180. +
  25181. +
  25182. + /* Strip the I/O address out of the returned value */
  25183. + ioaddr &= PCI_BASE_ADDRESS_IO_MASK;
  25184. +
  25185. + /* Take the first one or the one that matches in boot ROM address */
  25186. + dev->ioaddr = ioaddr;
  25187. }
  25188. +#if DEBUG > 2
  25189. + printf("Found %s ROM address %#hx\n",
  25190. + dev->name, romaddr);
  25191. +#endif
  25192. + LeaveFunction("scan_pci_bus");
  25193. + return;
  25194. }
  25195. + first_devfn = 0;
  25196. }
  25197. + first_bus = 0;
  25198. + LeaveFunction("scan_pci_bus");
  25199. }
  25200. -void eth_pci_init(struct pci_device *pcidev)
  25201. -{
  25202. -#ifndef CONFIG_PCI_DIRECT
  25203. - pcibios_init();
  25204. - if (!pcibios_entry) {
  25205. - printf("pci_init: no BIOS32 detected\n");
  25206. - return;
  25207. - }
  25208. -#endif
  25209. - scan_bus(pcidev);
  25210. - /* return values are in pcidev structures */
  25211. -}
  25212. +
  25213. /*
  25214. * Set device to be a busmaster in case BIOS neglected to do so.
  25215. @@ -489,13 +398,134 @@
  25216. pcibios_read_config_word(p->bus, p->devfn, PCI_COMMAND, &pci_command);
  25217. new_command = pci_command | PCI_COMMAND_MASTER|PCI_COMMAND_IO;
  25218. if (pci_command != new_command) {
  25219. - printf("The PCI BIOS has not enabled this device!\nUpdating PCI command %hX->%hX. pci_bus %hhX pci_device_fn %hhX\n",
  25220. +#if DEBUG > 0
  25221. + printf(
  25222. + "The PCI BIOS has not enabled this device!\n"
  25223. + "Updating PCI command %hX->%hX. pci_bus %hhX pci_device_fn %hhX\n",
  25224. pci_command, new_command, p->bus, p->devfn);
  25225. +#endif
  25226. pcibios_write_config_word(p->bus, p->devfn, PCI_COMMAND, new_command);
  25227. }
  25228. pcibios_read_config_byte(p->bus, p->devfn, PCI_LATENCY_TIMER, &pci_latency);
  25229. if (pci_latency < 32) {
  25230. - printf("PCI latency timer (CFLT) is unreasonably low at %d. Setting to 32 clocks.\n", pci_latency);
  25231. +#if DEBUG > 0
  25232. + printf("PCI latency timer (CFLT) is unreasonably low at %d. Setting to 32 clocks.\n",
  25233. + pci_latency);
  25234. +#endif
  25235. pcibios_write_config_byte(p->bus, p->devfn, PCI_LATENCY_TIMER, 32);
  25236. }
  25237. }
  25238. +
  25239. +/*
  25240. + * Find the start of a pci resource.
  25241. + */
  25242. +unsigned long pci_bar_start(struct pci_device *dev, unsigned int index)
  25243. +{
  25244. + uint32_t lo, hi;
  25245. + unsigned long bar;
  25246. + pci_read_config_dword(dev, index, &lo);
  25247. + if (lo & PCI_BASE_ADDRESS_SPACE_IO) {
  25248. + bar = lo & PCI_BASE_ADDRESS_IO_MASK;
  25249. + } else {
  25250. + bar = 0;
  25251. + if ((lo & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64) {
  25252. + pci_read_config_dword(dev, index + 4, &hi);
  25253. + if (hi) {
  25254. + if (sizeof(unsigned long) > sizeof(uint32_t)) {
  25255. + bar = hi;
  25256. + /* It's REALLY interesting:-) */
  25257. + bar <<=32;
  25258. + }
  25259. + else {
  25260. + printf("Unhandled 64bit BAR\n");
  25261. + return -1UL;
  25262. + }
  25263. + }
  25264. + }
  25265. + bar |= lo & PCI_BASE_ADDRESS_MEM_MASK;
  25266. + }
  25267. + return bar + pcibios_bus_base(dev->bus);
  25268. +}
  25269. +
  25270. +/*
  25271. + * Find the size of a pci resource.
  25272. + */
  25273. +unsigned long pci_bar_size(struct pci_device *dev, unsigned int bar)
  25274. +{
  25275. + uint32_t start, size;
  25276. + /* Save the original bar */
  25277. + pci_read_config_dword(dev, bar, &start);
  25278. + /* Compute which bits can be set */
  25279. + pci_write_config_dword(dev, bar, ~0);
  25280. + pci_read_config_dword(dev, bar, &size);
  25281. + /* Restore the original size */
  25282. + pci_write_config_dword(dev, bar, start);
  25283. + /* Find the significant bits */
  25284. + if (start & PCI_BASE_ADDRESS_SPACE_IO) {
  25285. + size &= PCI_BASE_ADDRESS_IO_MASK;
  25286. + } else {
  25287. + size &= PCI_BASE_ADDRESS_MEM_MASK;
  25288. + }
  25289. + /* Find the lowest bit set */
  25290. + size = size & ~(size - 1);
  25291. + return size;
  25292. +}
  25293. +
  25294. +/**
  25295. + * pci_find_capability - query for devices' capabilities
  25296. + * @dev: PCI device to query
  25297. + * @cap: capability code
  25298. + *
  25299. + * Tell if a device supports a given PCI capability.
  25300. + * Returns the address of the requested capability structure within the
  25301. + * device's PCI configuration space or 0 in case the device does not
  25302. + * support it. Possible values for @cap:
  25303. + *
  25304. + * %PCI_CAP_ID_PM Power Management
  25305. + *
  25306. + * %PCI_CAP_ID_AGP Accelerated Graphics Port
  25307. + *
  25308. + * %PCI_CAP_ID_VPD Vital Product Data
  25309. + *
  25310. + * %PCI_CAP_ID_SLOTID Slot Identification
  25311. + *
  25312. + * %PCI_CAP_ID_MSI Message Signalled Interrupts
  25313. + *
  25314. + * %PCI_CAP_ID_CHSWP CompactPCI HotSwap
  25315. + */
  25316. +int pci_find_capability(struct pci_device *dev, int cap)
  25317. +{
  25318. + uint16_t status;
  25319. + uint8_t pos, id;
  25320. + uint8_t hdr_type;
  25321. + int ttl = 48;
  25322. +
  25323. + pci_read_config_word(dev, PCI_STATUS, &status);
  25324. + if (!(status & PCI_STATUS_CAP_LIST))
  25325. + return 0;
  25326. + pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type);
  25327. + switch (hdr_type & 0x7F) {
  25328. + case PCI_HEADER_TYPE_NORMAL:
  25329. + case PCI_HEADER_TYPE_BRIDGE:
  25330. + default:
  25331. + pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &pos);
  25332. + break;
  25333. + case PCI_HEADER_TYPE_CARDBUS:
  25334. + pci_read_config_byte(dev, PCI_CB_CAPABILITY_LIST, &pos);
  25335. + break;
  25336. + }
  25337. + while (ttl-- && pos >= 0x40) {
  25338. + pos &= ~3;
  25339. + pci_read_config_byte(dev, pos + PCI_CAP_LIST_ID, &id);
  25340. +#if DEBUG > 0
  25341. + printf("Capability: %d\n", id);
  25342. +#endif
  25343. + if (id == 0xff)
  25344. + break;
  25345. + if (id == cap)
  25346. + return pos;
  25347. + pci_read_config_byte(dev, pos + PCI_CAP_LIST_NEXT, &pos);
  25348. + }
  25349. + return 0;
  25350. +}
  25351. +
  25352. Index: b/netboot/pci.h
  25353. ===================================================================
  25354. --- a/netboot/pci.h
  25355. +++ b/netboot/pci.h
  25356. @@ -1,4 +1,4 @@
  25357. -#ifndef PCI_H
  25358. +#if !defined(PCI_H) && defined(CONFIG_PCI)
  25359. #define PCI_H
  25360. /*
  25361. @@ -21,10 +21,19 @@
  25362. * your option) any later version.
  25363. */
  25364. +#include "pci_ids.h"
  25365. +
  25366. #define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
  25367. #define PCI_COMMAND_MEM 0x2 /* Enable response in mem space */
  25368. #define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */
  25369. #define PCI_LATENCY_TIMER 0x0d /* 8 bits */
  25370. +#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */
  25371. +#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */
  25372. +#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */
  25373. +#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */
  25374. +#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */
  25375. +#define PCI_COMMAND_SERR 0x100 /* Enable SERR */
  25376. +#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */
  25377. #define PCIBIOS_PCI_FUNCTION_ID 0xb1XX
  25378. #define PCIBIOS_PCI_BIOS_PRESENT 0xb101
  25379. @@ -42,10 +51,37 @@
  25380. #define PCI_DEVICE_ID 0x02 /* 16 bits */
  25381. #define PCI_COMMAND 0x04 /* 16 bits */
  25382. +#define PCI_STATUS 0x06 /* 16 bits */
  25383. +#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */
  25384. +#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */
  25385. +#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */
  25386. +#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */
  25387. +#define PCI_STATUS_PARITY 0x100 /* Detected parity error */
  25388. +#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */
  25389. +#define PCI_STATUS_DEVSEL_FAST 0x000
  25390. +#define PCI_STATUS_DEVSEL_MEDIUM 0x200
  25391. +#define PCI_STATUS_DEVSEL_SLOW 0x400
  25392. +#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */
  25393. +#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */
  25394. +#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */
  25395. +#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */
  25396. +#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */
  25397. +
  25398. #define PCI_REVISION 0x08 /* 8 bits */
  25399. +#define PCI_REVISION_ID 0x08 /* 8 bits */
  25400. +#define PCI_CLASS_REVISION 0x08 /* 32 bits */
  25401. #define PCI_CLASS_CODE 0x0b /* 8 bits */
  25402. #define PCI_SUBCLASS_CODE 0x0a /* 8 bits */
  25403. #define PCI_HEADER_TYPE 0x0e /* 8 bits */
  25404. +#define PCI_HEADER_TYPE_NORMAL 0
  25405. +#define PCI_HEADER_TYPE_BRIDGE 1
  25406. +#define PCI_HEADER_TYPE_CARDBUS 2
  25407. +
  25408. +
  25409. +/* Header type 0 (normal devices) */
  25410. +#define PCI_CARDBUS_CIS 0x28
  25411. +#define PCI_SUBSYSTEM_VENDOR_ID 0x2c
  25412. +#define PCI_SUBSYSTEM_ID 0x2e
  25413. #define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
  25414. #define PCI_BASE_ADDRESS_1 0x14 /* 32 bits */
  25415. @@ -54,15 +90,155 @@
  25416. #define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */
  25417. #define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */
  25418. +#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
  25419. +#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */
  25420. +#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */
  25421. +#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */
  25422. +
  25423. #ifndef PCI_BASE_ADDRESS_IO_MASK
  25424. #define PCI_BASE_ADDRESS_IO_MASK (~0x03)
  25425. #endif
  25426. +#ifndef PCI_BASE_ADDRESS_MEM_MASK
  25427. +#define PCI_BASE_ADDRESS_MEM_MASK (~0x0f)
  25428. +#endif
  25429. #define PCI_BASE_ADDRESS_SPACE_IO 0x01
  25430. #define PCI_ROM_ADDRESS 0x30 /* 32 bits */
  25431. #define PCI_ROM_ADDRESS_ENABLE 0x01 /* Write 1 to enable ROM,
  25432. bits 31..11 are address,
  25433. 10..2 are reserved */
  25434. +#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */
  25435. +
  25436. +#define PCI_INTERRUPT_LINE 0x3c /* IRQ number (0-15) */
  25437. +#define PCI_INTERRUPT_PIN 0x3d /* IRQ pin on PCI bus (A-D) */
  25438. +
  25439. +/* Header type 1 (PCI-to-PCI bridges) */
  25440. +#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */
  25441. +#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */
  25442. +#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */
  25443. +#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */
  25444. +#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */
  25445. +#define PCI_IO_LIMIT 0x1d
  25446. +#define PCI_IO_RANGE_TYPE_MASK 0x0f /* I/O bridging type */
  25447. +#define PCI_IO_RANGE_TYPE_16 0x00
  25448. +#define PCI_IO_RANGE_TYPE_32 0x01
  25449. +#define PCI_IO_RANGE_MASK ~0x0f
  25450. +#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */
  25451. +#define PCI_MEMORY_BASE 0x20 /* Memory range behind */
  25452. +#define PCI_MEMORY_LIMIT 0x22
  25453. +#define PCI_MEMORY_RANGE_TYPE_MASK 0x0f
  25454. +#define PCI_MEMORY_RANGE_MASK ~0x0f
  25455. +#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */
  25456. +#define PCI_PREF_MEMORY_LIMIT 0x26
  25457. +#define PCI_PREF_RANGE_TYPE_MASK 0x0f
  25458. +#define PCI_PREF_RANGE_TYPE_32 0x00
  25459. +#define PCI_PREF_RANGE_TYPE_64 0x01
  25460. +#define PCI_PREF_RANGE_MASK ~0x0f
  25461. +#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */
  25462. +#define PCI_PREF_LIMIT_UPPER32 0x2c
  25463. +#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */
  25464. +#define PCI_IO_LIMIT_UPPER16 0x32
  25465. +/* 0x34 same as for htype 0 */
  25466. +/* 0x35-0x3b is reserved */
  25467. +#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */
  25468. +/* 0x3c-0x3d are same as for htype 0 */
  25469. +#define PCI_BRIDGE_CONTROL 0x3e
  25470. +#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */
  25471. +#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */
  25472. +#define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */
  25473. +#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */
  25474. +#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */
  25475. +#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */
  25476. +#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */
  25477. +
  25478. +#define PCI_CB_CAPABILITY_LIST 0x14
  25479. +
  25480. +/* Capability lists */
  25481. +
  25482. +#define PCI_CAP_LIST_ID 0 /* Capability ID */
  25483. +#define PCI_CAP_ID_PM 0x01 /* Power Management */
  25484. +#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */
  25485. +#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */
  25486. +#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */
  25487. +#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */
  25488. +#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */
  25489. +#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */
  25490. +#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */
  25491. +#define PCI_CAP_SIZEOF 4
  25492. +
  25493. +/* Power Management Registers */
  25494. +
  25495. +#define PCI_PM_PMC 2 /* PM Capabilities Register */
  25496. +#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */
  25497. +#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */
  25498. +#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */
  25499. +#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */
  25500. +#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */
  25501. +#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */
  25502. +#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */
  25503. +#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */
  25504. +#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */
  25505. +#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */
  25506. +#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */
  25507. +#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */
  25508. +#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */
  25509. +#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */
  25510. +#define PCI_PM_CTRL 4 /* PM control and status register */
  25511. +#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */
  25512. +#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */
  25513. +#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */
  25514. +#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */
  25515. +#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */
  25516. +#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */
  25517. +#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */
  25518. +#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */
  25519. +#define PCI_PM_DATA_REGISTER 7 /* (??) */
  25520. +#define PCI_PM_SIZEOF 8
  25521. +
  25522. +/* AGP registers */
  25523. +
  25524. +#define PCI_AGP_VERSION 2 /* BCD version number */
  25525. +#define PCI_AGP_RFU 3 /* Rest of capability flags */
  25526. +#define PCI_AGP_STATUS 4 /* Status register */
  25527. +#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */
  25528. +#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */
  25529. +#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */
  25530. +#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */
  25531. +#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */
  25532. +#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */
  25533. +#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */
  25534. +#define PCI_AGP_COMMAND 8 /* Control register */
  25535. +#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */
  25536. +#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */
  25537. +#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */
  25538. +#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */
  25539. +#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */
  25540. +#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */
  25541. +#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */
  25542. +#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */
  25543. +#define PCI_AGP_SIZEOF 12
  25544. +
  25545. +/* Slot Identification */
  25546. +
  25547. +#define PCI_SID_ESR 2 /* Expansion Slot Register */
  25548. +#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */
  25549. +#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */
  25550. +#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */
  25551. +
  25552. +/* Message Signalled Interrupts registers */
  25553. +
  25554. +#define PCI_MSI_FLAGS 2 /* Various flags */
  25555. +#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */
  25556. +#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */
  25557. +#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */
  25558. +#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */
  25559. +#define PCI_MSI_RFU 3 /* Rest of capability flags */
  25560. +#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */
  25561. +#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */
  25562. +#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */
  25563. +#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
  25564. +
  25565. +#define PCI_SLOT(devfn) ((devfn) >> 3)
  25566. #define PCI_FUNC(devfn) ((devfn) & 0x07)
  25567. #define BIOS32_SIGNATURE (('_' << 0) + ('3' << 8) + ('2' << 16) + ('_' << 24))
  25568. @@ -85,108 +261,97 @@
  25569. char chars[16];
  25570. };
  25571. -#define KERN_CODE_SEG 0x8 /* This _MUST_ match start.S */
  25572. -
  25573. -/* Stuff for asm */
  25574. -#define save_flags(x) \
  25575. -__asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */ :"memory")
  25576. -
  25577. -#define cli() __asm__ __volatile__ ("cli": : :"memory")
  25578. -
  25579. -#define restore_flags(x) \
  25580. -__asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
  25581. -
  25582. -#define PCI_VENDOR_ID_ADMTEK 0x1317
  25583. -#define PCI_DEVICE_ID_ADMTEK_0985 0x0985
  25584. -#define PCI_VENDOR_ID_REALTEK 0x10ec
  25585. -#define PCI_DEVICE_ID_REALTEK_8029 0x8029
  25586. -#define PCI_DEVICE_ID_REALTEK_8139 0x8139
  25587. -#define PCI_VENDOR_ID_WINBOND2 0x1050
  25588. -#define PCI_DEVICE_ID_WINBOND2_89C940 0x0940
  25589. -#define PCI_DEVICE_ID_WINBOND2_89C840 0x0840
  25590. -#define PCI_VENDOR_ID_COMPEX 0x11f6
  25591. -#define PCI_DEVICE_ID_COMPEX_RL2000 0x1401
  25592. -#define PCI_DEVICE_ID_COMPEX_RL100ATX 0x2011
  25593. -#define PCI_VENDOR_ID_KTI 0x8e2e
  25594. -#define PCI_DEVICE_ID_KTI_ET32P2 0x3000
  25595. -#define PCI_VENDOR_ID_NETVIN 0x4a14
  25596. -#define PCI_DEVICE_ID_NETVIN_NV5000SC 0x5000
  25597. -#define PCI_VENDOR_ID_HOLTEK 0x12c3
  25598. -#define PCI_DEVICE_ID_HOLTEK_HT80232 0x0058
  25599. -#define PCI_VENDOR_ID_3COM 0x10b7
  25600. -#define PCI_DEVICE_ID_3COM_3C590 0x5900
  25601. -#define PCI_DEVICE_ID_3COM_3C595 0x5950
  25602. -#define PCI_DEVICE_ID_3COM_3C595_1 0x5951
  25603. -#define PCI_DEVICE_ID_3COM_3C595_2 0x5952
  25604. -#define PCI_DEVICE_ID_3COM_3C900TPO 0x9000
  25605. -#define PCI_DEVICE_ID_3COM_3C900COMBO 0x9001
  25606. -#define PCI_DEVICE_ID_3COM_3C905TX 0x9050
  25607. -#define PCI_DEVICE_ID_3COM_3C905T4 0x9051
  25608. -#define PCI_DEVICE_ID_3COM_3C905B_TX 0x9055
  25609. -#define PCI_DEVICE_ID_3COM_3C905C_TXM 0x9200
  25610. -#define PCI_VENDOR_ID_INTEL 0x8086
  25611. -#define PCI_DEVICE_ID_INTEL_82557 0x1229
  25612. -#define PCI_DEVICE_ID_INTEL_82559ER 0x1209
  25613. -#define PCI_DEVICE_ID_INTEL_ID1029 0x1029
  25614. -#define PCI_DEVICE_ID_INTEL_ID1030 0x1030
  25615. -#define PCI_DEVICE_ID_INTEL_82562 0x2449
  25616. -#define PCI_VENDOR_ID_AMD 0x1022
  25617. -#define PCI_DEVICE_ID_AMD_LANCE 0x2000
  25618. -#define PCI_VENDOR_ID_AMD_HOMEPNA 0x1022
  25619. -#define PCI_DEVICE_ID_AMD_HOMEPNA 0x2001
  25620. -#define PCI_VENDOR_ID_SMC_1211 0x1113
  25621. -#define PCI_DEVICE_ID_SMC_1211 0x1211
  25622. -#define PCI_VENDOR_ID_DEC 0x1011
  25623. -#define PCI_DEVICE_ID_DEC_TULIP 0x0002
  25624. -#define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009
  25625. -#define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014
  25626. -#define PCI_DEVICE_ID_DEC_21142 0x0019
  25627. -#define PCI_VENDOR_ID_SMC 0x10B8
  25628. -#ifndef PCI_DEVICE_ID_SMC_EPIC100
  25629. -# define PCI_DEVICE_ID_SMC_EPIC100 0x0005
  25630. -#endif
  25631. -#define PCI_VENDOR_ID_MACRONIX 0x10d9
  25632. -#define PCI_DEVICE_ID_MX987x5 0x0531
  25633. -#define PCI_VENDOR_ID_LINKSYS 0x11AD
  25634. -#define PCI_DEVICE_ID_LC82C115 0xC115
  25635. -#define PCI_VENDOR_ID_VIATEC 0x1106
  25636. -#define PCI_DEVICE_ID_VIA_RHINE_I 0x3043
  25637. -#define PCI_DEVICE_ID_VIA_VT6102 0x3065
  25638. -#define PCI_DEVICE_ID_VIA_86C100A 0x6100
  25639. -#define PCI_VENDOR_ID_DAVICOM 0x1282
  25640. -#define PCI_DEVICE_ID_DM9009 0x9009
  25641. -#define PCI_DEVICE_ID_DM9102 0x9102
  25642. -#define PCI_VENDOR_ID_SIS 0x1039
  25643. -#define PCI_DEVICE_ID_SIS900 0x0900
  25644. -#define PCI_DEVICE_ID_SIS7016 0x7016
  25645. -#define PCI_VENDOR_ID_DLINK 0x1186
  25646. -#define PCI_DEVICE_ID_DFE530TXP 0x1300
  25647. -#define PCI_VENDOR_ID_NS 0x100B
  25648. -#define PCI_DEVICE_ID_DP83815 0x0020
  25649. -#define PCI_VENDOR_ID_OLICOM 0x108d
  25650. -#define PCI_DEVICE_ID_OLICOM_OC3136 0x0001
  25651. -#define PCI_DEVICE_ID_OLICOM_OC2315 0x0011
  25652. -#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
  25653. -#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
  25654. -#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
  25655. -#define PCI_DEVICE_ID_OLICOM_OC6151 0x0021
  25656. +struct pci_device;
  25657. +struct dev;
  25658. +typedef int (*pci_probe_t)(struct dev *, struct pci_device *);
  25659. struct pci_device {
  25660. - unsigned short vendor, dev_id;
  25661. - const char *name;
  25662. - unsigned int membase;
  25663. - unsigned short ioaddr;
  25664. - unsigned char devfn;
  25665. - unsigned char bus;
  25666. + uint32_t class;
  25667. + uint16_t vendor, dev_id;
  25668. + const char *name;
  25669. + /* membase and ioaddr are silly and depricated */
  25670. + unsigned int membase;
  25671. + unsigned int ioaddr;
  25672. + unsigned int romaddr;
  25673. + unsigned char irq;
  25674. + unsigned char devfn;
  25675. + unsigned char bus;
  25676. + unsigned char use_specified;
  25677. + const struct pci_driver *driver;
  25678. +};
  25679. +
  25680. +extern void scan_pci_bus(int type, struct pci_device *dev);
  25681. +extern void find_pci(int type, struct pci_device *dev);
  25682. +
  25683. +extern int pcibios_read_config_byte(unsigned int bus, unsigned int device_fn, unsigned int where, uint8_t *value);
  25684. +extern int pcibios_write_config_byte (unsigned int bus, unsigned int device_fn, unsigned int where, uint8_t value);
  25685. +extern int pcibios_read_config_word(unsigned int bus, unsigned int device_fn, unsigned int where, uint16_t *value);
  25686. +extern int pcibios_write_config_word (unsigned int bus, unsigned int device_fn, unsigned int where, uint16_t value);
  25687. +extern int pcibios_read_config_dword(unsigned int bus, unsigned int device_fn, unsigned int where, uint32_t *value);
  25688. +extern int pcibios_write_config_dword(unsigned int bus, unsigned int device_fn, unsigned int where, uint32_t value);
  25689. +extern unsigned long pcibios_bus_base(unsigned int bus);
  25690. +extern void adjust_pci_device(struct pci_device *p);
  25691. +
  25692. +
  25693. +static inline int
  25694. +pci_read_config_byte(struct pci_device *dev, unsigned int where, uint8_t *value)
  25695. +{
  25696. + return pcibios_read_config_byte(dev->bus, dev->devfn, where, value);
  25697. +}
  25698. +static inline int
  25699. +pci_write_config_byte(struct pci_device *dev, unsigned int where, uint8_t value)
  25700. +{
  25701. + return pcibios_write_config_byte(dev->bus, dev->devfn, where, value);
  25702. +}
  25703. +static inline int
  25704. +pci_read_config_word(struct pci_device *dev, unsigned int where, uint16_t *value)
  25705. +{
  25706. + return pcibios_read_config_word(dev->bus, dev->devfn, where, value);
  25707. +}
  25708. +static inline int
  25709. +pci_write_config_word(struct pci_device *dev, unsigned int where, uint16_t value)
  25710. +{
  25711. + return pcibios_write_config_word(dev->bus, dev->devfn, where, value);
  25712. +}
  25713. +static inline int
  25714. +pci_read_config_dword(struct pci_device *dev, unsigned int where, uint32_t *value)
  25715. +{
  25716. + return pcibios_read_config_dword(dev->bus, dev->devfn, where, value);
  25717. +}
  25718. +static inline int
  25719. +pci_write_config_dword(struct pci_device *dev, unsigned int where, uint32_t value)
  25720. +{
  25721. + return pcibios_write_config_dword(dev->bus, dev->devfn, where, value);
  25722. +}
  25723. +
  25724. +/* Helper functions to find the size of a pci bar */
  25725. +extern unsigned long pci_bar_start(struct pci_device *dev, unsigned int bar);
  25726. +extern unsigned long pci_bar_size(struct pci_device *dev, unsigned int bar);
  25727. +/* Helper function to find pci capabilities */
  25728. +extern int pci_find_capability(struct pci_device *dev, int cap);
  25729. +struct pci_id {
  25730. + unsigned short vendor, dev_id;
  25731. + const char *name;
  25732. +};
  25733. +
  25734. +struct dev;
  25735. +/* Most pci drivers will use this */
  25736. +struct pci_driver {
  25737. + int type;
  25738. + const char *name;
  25739. + pci_probe_t probe;
  25740. + struct pci_id *ids;
  25741. + int id_count;
  25742. +
  25743. +/* On a few occasions the hardware is standardized enough that
  25744. + * we only need to know the class of the device and not the exact
  25745. + * type to drive the device correctly. If this is the case
  25746. + * set a class value other than 0.
  25747. + */
  25748. + unsigned short class;
  25749. };
  25750. -extern void eth_pci_init(struct pci_device *);
  25751. +#define PCI_ROM(VENDOR_ID, DEVICE_ID, IMAGE, DESCRIPTION) \
  25752. + { VENDOR_ID, DEVICE_ID, IMAGE, }
  25753. -extern int pcibios_read_config_byte(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned char *value);
  25754. -extern int pcibios_write_config_byte (unsigned int bus, unsigned int device_fn, unsigned int where, unsigned char value);
  25755. -extern int pcibios_read_config_word(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned short *value);
  25756. -extern int pcibios_write_config_word (unsigned int bus, unsigned int device_fn, unsigned int where, unsigned short value);
  25757. -extern int pcibios_read_config_dword(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned int *value);
  25758. -extern int pcibios_write_config_dword(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned int value);
  25759. -void adjust_pci_device(struct pci_device *p);
  25760. #endif /* PCI_H */
  25761. Index: b/netboot/pci_ids.h
  25762. ===================================================================
  25763. --- /dev/null
  25764. +++ b/netboot/pci_ids.h
  25765. @@ -0,0 +1,1809 @@
  25766. +/*
  25767. + * PCI Class, Vendor and Device IDs
  25768. + *
  25769. + * Please keep sorted.
  25770. + */
  25771. +
  25772. +/* Device classes and subclasses */
  25773. +
  25774. +#define PCI_CLASS_NOT_DEFINED 0x0000
  25775. +#define PCI_CLASS_NOT_DEFINED_VGA 0x0001
  25776. +
  25777. +#define PCI_BASE_CLASS_STORAGE 0x01
  25778. +#define PCI_CLASS_STORAGE_SCSI 0x0100
  25779. +#define PCI_CLASS_STORAGE_IDE 0x0101
  25780. +#define PCI_CLASS_STORAGE_FLOPPY 0x0102
  25781. +#define PCI_CLASS_STORAGE_IPI 0x0103
  25782. +#define PCI_CLASS_STORAGE_RAID 0x0104
  25783. +#define PCI_CLASS_STORAGE_OTHER 0x0180
  25784. +
  25785. +#define PCI_BASE_CLASS_NETWORK 0x02
  25786. +#define PCI_CLASS_NETWORK_ETHERNET 0x0200
  25787. +#define PCI_CLASS_NETWORK_TOKEN_RING 0x0201
  25788. +#define PCI_CLASS_NETWORK_FDDI 0x0202
  25789. +#define PCI_CLASS_NETWORK_ATM 0x0203
  25790. +#define PCI_CLASS_NETWORK_OTHER 0x0280
  25791. +
  25792. +#define PCI_BASE_CLASS_DISPLAY 0x03
  25793. +#define PCI_CLASS_DISPLAY_VGA 0x0300
  25794. +#define PCI_CLASS_DISPLAY_XGA 0x0301
  25795. +#define PCI_CLASS_DISPLAY_3D 0x0302
  25796. +#define PCI_CLASS_DISPLAY_OTHER 0x0380
  25797. +
  25798. +#define PCI_BASE_CLASS_MULTIMEDIA 0x04
  25799. +#define PCI_CLASS_MULTIMEDIA_VIDEO 0x0400
  25800. +#define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401
  25801. +#define PCI_CLASS_MULTIMEDIA_PHONE 0x0402
  25802. +#define PCI_CLASS_MULTIMEDIA_OTHER 0x0480
  25803. +
  25804. +#define PCI_BASE_CLASS_MEMORY 0x05
  25805. +#define PCI_CLASS_MEMORY_RAM 0x0500
  25806. +#define PCI_CLASS_MEMORY_FLASH 0x0501
  25807. +#define PCI_CLASS_MEMORY_OTHER 0x0580
  25808. +
  25809. +#define PCI_BASE_CLASS_BRIDGE 0x06
  25810. +#define PCI_CLASS_BRIDGE_HOST 0x0600
  25811. +#define PCI_CLASS_BRIDGE_ISA 0x0601
  25812. +#define PCI_CLASS_BRIDGE_EISA 0x0602
  25813. +#define PCI_CLASS_BRIDGE_MC 0x0603
  25814. +#define PCI_CLASS_BRIDGE_PCI 0x0604
  25815. +#define PCI_CLASS_BRIDGE_PCMCIA 0x0605
  25816. +#define PCI_CLASS_BRIDGE_NUBUS 0x0606
  25817. +#define PCI_CLASS_BRIDGE_CARDBUS 0x0607
  25818. +#define PCI_CLASS_BRIDGE_RACEWAY 0x0608
  25819. +#define PCI_CLASS_BRIDGE_OTHER 0x0680
  25820. +
  25821. +#define PCI_BASE_CLASS_COMMUNICATION 0x07
  25822. +#define PCI_CLASS_COMMUNICATION_SERIAL 0x0700
  25823. +#define PCI_CLASS_COMMUNICATION_PARALLEL 0x0701
  25824. +#define PCI_CLASS_COMMUNICATION_MULTISERIAL 0x0702
  25825. +#define PCI_CLASS_COMMUNICATION_MODEM 0x0703
  25826. +#define PCI_CLASS_COMMUNICATION_OTHER 0x0780
  25827. +
  25828. +#define PCI_BASE_CLASS_SYSTEM 0x08
  25829. +#define PCI_CLASS_SYSTEM_PIC 0x0800
  25830. +#define PCI_CLASS_SYSTEM_DMA 0x0801
  25831. +#define PCI_CLASS_SYSTEM_TIMER 0x0802
  25832. +#define PCI_CLASS_SYSTEM_RTC 0x0803
  25833. +#define PCI_CLASS_SYSTEM_PCI_HOTPLUG 0x0804
  25834. +#define PCI_CLASS_SYSTEM_OTHER 0x0880
  25835. +
  25836. +#define PCI_BASE_CLASS_INPUT 0x09
  25837. +#define PCI_CLASS_INPUT_KEYBOARD 0x0900
  25838. +#define PCI_CLASS_INPUT_PEN 0x0901
  25839. +#define PCI_CLASS_INPUT_MOUSE 0x0902
  25840. +#define PCI_CLASS_INPUT_SCANNER 0x0903
  25841. +#define PCI_CLASS_INPUT_GAMEPORT 0x0904
  25842. +#define PCI_CLASS_INPUT_OTHER 0x0980
  25843. +
  25844. +#define PCI_BASE_CLASS_DOCKING 0x0a
  25845. +#define PCI_CLASS_DOCKING_GENERIC 0x0a00
  25846. +#define PCI_CLASS_DOCKING_OTHER 0x0a80
  25847. +
  25848. +#define PCI_BASE_CLASS_PROCESSOR 0x0b
  25849. +#define PCI_CLASS_PROCESSOR_386 0x0b00
  25850. +#define PCI_CLASS_PROCESSOR_486 0x0b01
  25851. +#define PCI_CLASS_PROCESSOR_PENTIUM 0x0b02
  25852. +#define PCI_CLASS_PROCESSOR_ALPHA 0x0b10
  25853. +#define PCI_CLASS_PROCESSOR_POWERPC 0x0b20
  25854. +#define PCI_CLASS_PROCESSOR_MIPS 0x0b30
  25855. +#define PCI_CLASS_PROCESSOR_CO 0x0b40
  25856. +
  25857. +#define PCI_BASE_CLASS_SERIAL 0x0c
  25858. +#define PCI_CLASS_SERIAL_FIREWIRE 0x0c00
  25859. +#define PCI_CLASS_SERIAL_ACCESS 0x0c01
  25860. +#define PCI_CLASS_SERIAL_SSA 0x0c02
  25861. +#define PCI_CLASS_SERIAL_USB 0x0c03
  25862. +#define PCI_CLASS_SERIAL_FIBER 0x0c04
  25863. +#define PCI_CLASS_SERIAL_SMBUS 0x0c05
  25864. +
  25865. +#define PCI_BASE_CLASS_INTELLIGENT 0x0e
  25866. +#define PCI_CLASS_INTELLIGENT_I2O 0x0e00
  25867. +
  25868. +#define PCI_BASE_CLASS_SATELLITE 0x0f
  25869. +#define PCI_CLASS_SATELLITE_TV 0x0f00
  25870. +#define PCI_CLASS_SATELLITE_AUDIO 0x0f01
  25871. +#define PCI_CLASS_SATELLITE_VOICE 0x0f03
  25872. +#define PCI_CLASS_SATELLITE_DATA 0x0f04
  25873. +
  25874. +#define PCI_BASE_CLASS_CRYPT 0x10
  25875. +#define PCI_CLASS_CRYPT_NETWORK 0x1000
  25876. +#define PCI_CLASS_CRYPT_ENTERTAINMENT 0x1001
  25877. +#define PCI_CLASS_CRYPT_OTHER 0x1080
  25878. +
  25879. +#define PCI_BASE_CLASS_SIGNAL_PROCESSING 0x11
  25880. +#define PCI_CLASS_SP_DPIO 0x1100
  25881. +#define PCI_CLASS_SP_OTHER 0x1180
  25882. +
  25883. +#define PCI_CLASS_OTHERS 0xff
  25884. +
  25885. +/* Vendors and devices. Sort key: vendor first, device next. */
  25886. +
  25887. +#define PCI_VENDOR_ID_DYNALINK 0x0675
  25888. +#define PCI_DEVICE_ID_DYNALINK_IS64PH 0x1702
  25889. +
  25890. +#define PCI_VENDOR_ID_BERKOM 0x0871
  25891. +#define PCI_DEVICE_ID_BERKOM_A1T 0xffa1
  25892. +#define PCI_DEVICE_ID_BERKOM_T_CONCEPT 0xffa2
  25893. +#define PCI_DEVICE_ID_BERKOM_A4T 0xffa4
  25894. +#define PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO 0xffa8
  25895. +
  25896. +#define PCI_VENDOR_ID_COMPAQ 0x0e11
  25897. +#define PCI_DEVICE_ID_COMPAQ_TOKENRING 0x0508
  25898. +#define PCI_DEVICE_ID_COMPAQ_1280 0x3033
  25899. +#define PCI_DEVICE_ID_COMPAQ_TRIFLEX 0x4000
  25900. +#define PCI_DEVICE_ID_COMPAQ_6010 0x6010
  25901. +#define PCI_DEVICE_ID_COMPAQ_SMART2P 0xae10
  25902. +#define PCI_DEVICE_ID_COMPAQ_NETEL100 0xae32
  25903. +#define PCI_DEVICE_ID_COMPAQ_NETEL10 0xae34
  25904. +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3I 0xae35
  25905. +#define PCI_DEVICE_ID_COMPAQ_NETEL100D 0xae40
  25906. +#define PCI_DEVICE_ID_COMPAQ_NETEL100PI 0xae43
  25907. +#define PCI_DEVICE_ID_COMPAQ_NETEL100I 0xb011
  25908. +#define PCI_DEVICE_ID_COMPAQ_CISS 0xb060
  25909. +#define PCI_DEVICE_ID_COMPAQ_CISSB 0xb178
  25910. +#define PCI_DEVICE_ID_COMPAQ_THUNDER 0xf130
  25911. +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3B 0xf150
  25912. +
  25913. +#define PCI_VENDOR_ID_NCR 0x1000
  25914. +#define PCI_VENDOR_ID_LSI_LOGIC 0x1000
  25915. +#define PCI_DEVICE_ID_NCR_53C810 0x0001
  25916. +#define PCI_DEVICE_ID_NCR_53C820 0x0002
  25917. +#define PCI_DEVICE_ID_NCR_53C825 0x0003
  25918. +#define PCI_DEVICE_ID_NCR_53C815 0x0004
  25919. +#define PCI_DEVICE_ID_LSI_53C810AP 0x0005
  25920. +#define PCI_DEVICE_ID_NCR_53C860 0x0006
  25921. +#define PCI_DEVICE_ID_LSI_53C1510 0x000a
  25922. +#define PCI_DEVICE_ID_NCR_53C896 0x000b
  25923. +#define PCI_DEVICE_ID_NCR_53C895 0x000c
  25924. +#define PCI_DEVICE_ID_NCR_53C885 0x000d
  25925. +#define PCI_DEVICE_ID_NCR_53C875 0x000f
  25926. +#define PCI_DEVICE_ID_NCR_53C1510 0x0010
  25927. +#define PCI_DEVICE_ID_LSI_53C895A 0x0012
  25928. +#define PCI_DEVICE_ID_LSI_53C875A 0x0013
  25929. +#define PCI_DEVICE_ID_LSI_53C1010_33 0x0020
  25930. +#define PCI_DEVICE_ID_LSI_53C1010_66 0x0021
  25931. +#define PCI_DEVICE_ID_LSI_53C1030 0x0030
  25932. +#define PCI_DEVICE_ID_LSI_53C1035 0x0040
  25933. +#define PCI_DEVICE_ID_NCR_53C875J 0x008f
  25934. +#define PCI_DEVICE_ID_LSI_FC909 0x0621
  25935. +#define PCI_DEVICE_ID_LSI_FC929 0x0622
  25936. +#define PCI_DEVICE_ID_LSI_FC929_LAN 0x0623
  25937. +#define PCI_DEVICE_ID_LSI_FC919 0x0624
  25938. +#define PCI_DEVICE_ID_LSI_FC919_LAN 0x0625
  25939. +#define PCI_DEVICE_ID_NCR_YELLOWFIN 0x0701
  25940. +#define PCI_DEVICE_ID_LSI_61C102 0x0901
  25941. +#define PCI_DEVICE_ID_LSI_63C815 0x1000
  25942. +
  25943. +#define PCI_VENDOR_ID_ATI 0x1002
  25944. +/* Mach64 */
  25945. +#define PCI_DEVICE_ID_ATI_68800 0x4158
  25946. +#define PCI_DEVICE_ID_ATI_215CT222 0x4354
  25947. +#define PCI_DEVICE_ID_ATI_210888CX 0x4358
  25948. +#define PCI_DEVICE_ID_ATI_215ET222 0x4554
  25949. +/* Mach64 / Rage */
  25950. +#define PCI_DEVICE_ID_ATI_215GB 0x4742
  25951. +#define PCI_DEVICE_ID_ATI_215GD 0x4744
  25952. +#define PCI_DEVICE_ID_ATI_215GI 0x4749
  25953. +#define PCI_DEVICE_ID_ATI_215GP 0x4750
  25954. +#define PCI_DEVICE_ID_ATI_215GQ 0x4751
  25955. +#define PCI_DEVICE_ID_ATI_215XL 0x4752
  25956. +#define PCI_DEVICE_ID_ATI_215GT 0x4754
  25957. +#define PCI_DEVICE_ID_ATI_215GTB 0x4755
  25958. +#define PCI_DEVICE_ID_ATI_215_IV 0x4756
  25959. +#define PCI_DEVICE_ID_ATI_215_IW 0x4757
  25960. +#define PCI_DEVICE_ID_ATI_215_IZ 0x475A
  25961. +#define PCI_DEVICE_ID_ATI_210888GX 0x4758
  25962. +#define PCI_DEVICE_ID_ATI_215_LB 0x4c42
  25963. +#define PCI_DEVICE_ID_ATI_215_LD 0x4c44
  25964. +#define PCI_DEVICE_ID_ATI_215_LG 0x4c47
  25965. +#define PCI_DEVICE_ID_ATI_215_LI 0x4c49
  25966. +#define PCI_DEVICE_ID_ATI_215_LM 0x4c4D
  25967. +#define PCI_DEVICE_ID_ATI_215_LN 0x4c4E
  25968. +#define PCI_DEVICE_ID_ATI_215_LR 0x4c52
  25969. +#define PCI_DEVICE_ID_ATI_215_LS 0x4c53
  25970. +#define PCI_DEVICE_ID_ATI_264_LT 0x4c54
  25971. +/* Mach64 VT */
  25972. +#define PCI_DEVICE_ID_ATI_264VT 0x5654
  25973. +#define PCI_DEVICE_ID_ATI_264VU 0x5655
  25974. +#define PCI_DEVICE_ID_ATI_264VV 0x5656
  25975. +/* Rage128 Pro GL */
  25976. +#define PCI_DEVICE_ID_ATI_Rage128_PA 0x5041
  25977. +#define PCI_DEVICE_ID_ATI_Rage128_PB 0x5042
  25978. +#define PCI_DEVICE_ID_ATI_Rage128_PC 0x5043
  25979. +#define PCI_DEVICE_ID_ATI_Rage128_PD 0x5044
  25980. +#define PCI_DEVICE_ID_ATI_Rage128_PE 0x5045
  25981. +#define PCI_DEVICE_ID_ATI_RAGE128_PF 0x5046
  25982. +/* Rage128 Pro VR */
  25983. +#define PCI_DEVICE_ID_ATI_RAGE128_PG 0x5047
  25984. +#define PCI_DEVICE_ID_ATI_RAGE128_PH 0x5048
  25985. +#define PCI_DEVICE_ID_ATI_RAGE128_PI 0x5049
  25986. +#define PCI_DEVICE_ID_ATI_RAGE128_PJ 0x504A
  25987. +#define PCI_DEVICE_ID_ATI_RAGE128_PK 0x504B
  25988. +#define PCI_DEVICE_ID_ATI_RAGE128_PL 0x504C
  25989. +#define PCI_DEVICE_ID_ATI_RAGE128_PM 0x504D
  25990. +#define PCI_DEVICE_ID_ATI_RAGE128_PN 0x504E
  25991. +#define PCI_DEVICE_ID_ATI_RAGE128_PO 0x504F
  25992. +#define PCI_DEVICE_ID_ATI_RAGE128_PP 0x5050
  25993. +#define PCI_DEVICE_ID_ATI_RAGE128_PQ 0x5051
  25994. +#define PCI_DEVICE_ID_ATI_RAGE128_PR 0x5052
  25995. +#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452
  25996. +#define PCI_DEVICE_ID_ATI_RAGE128_PS 0x5053
  25997. +#define PCI_DEVICE_ID_ATI_RAGE128_PT 0x5054
  25998. +#define PCI_DEVICE_ID_ATI_RAGE128_PU 0x5055
  25999. +#define PCI_DEVICE_ID_ATI_RAGE128_PV 0x5056
  26000. +#define PCI_DEVICE_ID_ATI_RAGE128_PW 0x5057
  26001. +#define PCI_DEVICE_ID_ATI_RAGE128_PX 0x5058
  26002. +/* Rage128 GL */
  26003. +#define PCI_DEVICE_ID_ATI_RAGE128_RE 0x5245
  26004. +#define PCI_DEVICE_ID_ATI_RAGE128_RF 0x5246
  26005. +#define PCI_DEVICE_ID_ATI_RAGE128_RG 0x534b
  26006. +#define PCI_DEVICE_ID_ATI_RAGE128_RH 0x534c
  26007. +#define PCI_DEVICE_ID_ATI_RAGE128_RI 0x534d
  26008. +/* Rage128 VR */
  26009. +#define PCI_DEVICE_ID_ATI_RAGE128_RK 0x524b
  26010. +#define PCI_DEVICE_ID_ATI_RAGE128_RL 0x524c
  26011. +#define PCI_DEVICE_ID_ATI_RAGE128_RM 0x5345
  26012. +#define PCI_DEVICE_ID_ATI_RAGE128_RN 0x5346
  26013. +#define PCI_DEVICE_ID_ATI_RAGE128_RO 0x5347
  26014. +/* Rage128 M3 */
  26015. +#define PCI_DEVICE_ID_ATI_RAGE128_LE 0x4c45
  26016. +#define PCI_DEVICE_ID_ATI_RAGE128_LF 0x4c46
  26017. +/* Rage128 Pro Ultra */
  26018. +#define PCI_DEVICE_ID_ATI_RAGE128_U1 0x5446
  26019. +#define PCI_DEVICE_ID_ATI_RAGE128_U2 0x544C
  26020. +#define PCI_DEVICE_ID_ATI_RAGE128_U3 0x5452
  26021. +/* Radeon M4 */
  26022. +#define PCI_DEVICE_ID_ATI_RADEON_LE 0x4d45
  26023. +#define PCI_DEVICE_ID_ATI_RADEON_LF 0x4d46
  26024. +/* Radeon NV-100 */
  26025. +#define PCI_DEVICE_ID_ATI_RADEON_N1 0x5159
  26026. +#define PCI_DEVICE_ID_ATI_RADEON_N2 0x515a
  26027. +/* Radeon */
  26028. +#define PCI_DEVICE_ID_ATI_RADEON_RA 0x5144
  26029. +#define PCI_DEVICE_ID_ATI_RADEON_RB 0x5145
  26030. +#define PCI_DEVICE_ID_ATI_RADEON_RC 0x5146
  26031. +#define PCI_DEVICE_ID_ATI_RADEON_RD 0x5147
  26032. +
  26033. +#define PCI_VENDOR_ID_VLSI 0x1004
  26034. +#define PCI_DEVICE_ID_VLSI_82C592 0x0005
  26035. +#define PCI_DEVICE_ID_VLSI_82C593 0x0006
  26036. +#define PCI_DEVICE_ID_VLSI_82C594 0x0007
  26037. +#define PCI_DEVICE_ID_VLSI_82C597 0x0009
  26038. +#define PCI_DEVICE_ID_VLSI_82C541 0x000c
  26039. +#define PCI_DEVICE_ID_VLSI_82C543 0x000d
  26040. +#define PCI_DEVICE_ID_VLSI_82C532 0x0101
  26041. +#define PCI_DEVICE_ID_VLSI_82C534 0x0102
  26042. +#define PCI_DEVICE_ID_VLSI_82C535 0x0104
  26043. +#define PCI_DEVICE_ID_VLSI_82C147 0x0105
  26044. +#define PCI_DEVICE_ID_VLSI_VAS96011 0x0702
  26045. +
  26046. +#define PCI_VENDOR_ID_ADL 0x1005
  26047. +#define PCI_DEVICE_ID_ADL_2301 0x2301
  26048. +
  26049. +#define PCI_VENDOR_ID_NS 0x100b
  26050. +#define PCI_DEVICE_ID_NS_87415 0x0002
  26051. +#define PCI_DEVICE_ID_NS_87560_LIO 0x000e
  26052. +#define PCI_DEVICE_ID_NS_87560_USB 0x0012
  26053. +#define PCI_DEVICE_ID_NS_83815 0x0020
  26054. +#define PCI_DEVICE_ID_DP83815 0x0020
  26055. +#define PCI_DEVICE_ID_NS_83820 0x0022
  26056. +#define PCI_DEVICE_ID_NS_87410 0xd001
  26057. +
  26058. +#define PCI_VENDOR_ID_TSENG 0x100c
  26059. +#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202
  26060. +#define PCI_DEVICE_ID_TSENG_W32P_b 0x3205
  26061. +#define PCI_DEVICE_ID_TSENG_W32P_c 0x3206
  26062. +#define PCI_DEVICE_ID_TSENG_W32P_d 0x3207
  26063. +#define PCI_DEVICE_ID_TSENG_ET6000 0x3208
  26064. +
  26065. +#define PCI_VENDOR_ID_WEITEK 0x100e
  26066. +#define PCI_DEVICE_ID_WEITEK_P9000 0x9001
  26067. +#define PCI_DEVICE_ID_WEITEK_P9100 0x9100
  26068. +
  26069. +#define PCI_VENDOR_ID_DEC 0x1011
  26070. +#define PCI_DEVICE_ID_DEC_BRD 0x0001
  26071. +#define PCI_DEVICE_ID_DEC_TULIP 0x0002
  26072. +#define PCI_DEVICE_ID_DEC_TGA 0x0004
  26073. +#define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009
  26074. +#define PCI_DEVICE_ID_DEC_TGA2 0x000D
  26075. +#define PCI_DEVICE_ID_DEC_FDDI 0x000F
  26076. +#define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014
  26077. +#define PCI_DEVICE_ID_DEC_21142 0x0019
  26078. +#define PCI_DEVICE_ID_DEC_21052 0x0021
  26079. +#define PCI_DEVICE_ID_DEC_21150 0x0022
  26080. +#define PCI_DEVICE_ID_DEC_21152 0x0024
  26081. +#define PCI_DEVICE_ID_DEC_21153 0x0025
  26082. +#define PCI_DEVICE_ID_DEC_21154 0x0026
  26083. +#define PCI_DEVICE_ID_DEC_21285 0x1065
  26084. +#define PCI_DEVICE_ID_COMPAQ_42XX 0x0046
  26085. +
  26086. +#define PCI_VENDOR_ID_CIRRUS 0x1013
  26087. +#define PCI_DEVICE_ID_CIRRUS_7548 0x0038
  26088. +#define PCI_DEVICE_ID_CIRRUS_5430 0x00a0
  26089. +#define PCI_DEVICE_ID_CIRRUS_5434_4 0x00a4
  26090. +#define PCI_DEVICE_ID_CIRRUS_5434_8 0x00a8
  26091. +#define PCI_DEVICE_ID_CIRRUS_5436 0x00ac
  26092. +#define PCI_DEVICE_ID_CIRRUS_5446 0x00b8
  26093. +#define PCI_DEVICE_ID_CIRRUS_5480 0x00bc
  26094. +#define PCI_DEVICE_ID_CIRRUS_5462 0x00d0
  26095. +#define PCI_DEVICE_ID_CIRRUS_5464 0x00d4
  26096. +#define PCI_DEVICE_ID_CIRRUS_5465 0x00d6
  26097. +#define PCI_DEVICE_ID_CIRRUS_6729 0x1100
  26098. +#define PCI_DEVICE_ID_CIRRUS_6832 0x1110
  26099. +#define PCI_DEVICE_ID_CIRRUS_7542 0x1200
  26100. +#define PCI_DEVICE_ID_CIRRUS_7543 0x1202
  26101. +#define PCI_DEVICE_ID_CIRRUS_7541 0x1204
  26102. +
  26103. +#define PCI_VENDOR_ID_IBM 0x1014
  26104. +#define PCI_DEVICE_ID_IBM_FIRE_CORAL 0x000a
  26105. +#define PCI_DEVICE_ID_IBM_TR 0x0018
  26106. +#define PCI_DEVICE_ID_IBM_82G2675 0x001d
  26107. +#define PCI_DEVICE_ID_IBM_MCA 0x0020
  26108. +#define PCI_DEVICE_ID_IBM_82351 0x0022
  26109. +#define PCI_DEVICE_ID_IBM_PYTHON 0x002d
  26110. +#define PCI_DEVICE_ID_IBM_SERVERAID 0x002e
  26111. +#define PCI_DEVICE_ID_IBM_TR_WAKE 0x003e
  26112. +#define PCI_DEVICE_ID_IBM_MPIC 0x0046
  26113. +#define PCI_DEVICE_ID_IBM_3780IDSP 0x007d
  26114. +#define PCI_DEVICE_ID_IBM_CHUKAR 0x0096
  26115. +#define PCI_DEVICE_ID_IBM_405GP 0x0156
  26116. +#define PCI_DEVICE_ID_IBM_SERVERAIDI960 0x01bd
  26117. +#define PCI_DEVICE_ID_IBM_MPIC_2 0xffff
  26118. +
  26119. +#define PCI_VENDOR_ID_COMPEX2 0x101a // pci.ids says "AT&T GIS (NCR)"
  26120. +#define PCI_DEVICE_ID_COMPEX2_100VG 0x0005
  26121. +
  26122. +#define PCI_VENDOR_ID_WD 0x101c
  26123. +#define PCI_DEVICE_ID_WD_7197 0x3296
  26124. +
  26125. +#define PCI_VENDOR_ID_AMI 0x101e
  26126. +#define PCI_DEVICE_ID_AMI_MEGARAID3 0x1960
  26127. +#define PCI_DEVICE_ID_AMI_MEGARAID 0x9010
  26128. +#define PCI_DEVICE_ID_AMI_MEGARAID2 0x9060
  26129. +
  26130. +#define PCI_VENDOR_ID_AMD 0x1022
  26131. +
  26132. +#define PCI_DEVICE_ID_AMD_LANCE 0x2000
  26133. +#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001
  26134. +#define PCI_DEVICE_ID_AMD_HOMEPNA 0x2001
  26135. +#define PCI_DEVICE_ID_AMD_SCSI 0x2020
  26136. +#define PCI_DEVICE_ID_AMD_FE_GATE_7006 0x7006
  26137. +#define PCI_DEVICE_ID_AMD_FE_GATE_7007 0x7007
  26138. +#define PCI_DEVICE_ID_AMD_FE_GATE_700C 0x700C
  26139. +#define PCI_DEVIDE_ID_AMD_FE_GATE_700D 0x700D
  26140. +#define PCI_DEVICE_ID_AMD_FE_GATE_700E 0x700E
  26141. +#define PCI_DEVICE_ID_AMD_FE_GATE_700F 0x700F
  26142. +#define PCI_DEVICE_ID_AMD_COBRA_7400 0x7400
  26143. +#define PCI_DEVICE_ID_AMD_COBRA_7401 0x7401
  26144. +#define PCI_DEVICE_ID_AMD_COBRA_7403 0x7403
  26145. +#define PCI_DEVICE_ID_AMD_COBRA_7404 0x7404
  26146. +#define PCI_DEVICE_ID_AMD_VIPER_7408 0x7408
  26147. +#define PCI_DEVICE_ID_AMD_VIPER_7409 0x7409
  26148. +#define PCI_DEVICE_ID_AMD_VIPER_740B 0x740B
  26149. +#define PCI_DEVICE_ID_AMD_VIPER_740C 0x740C
  26150. +#define PCI_DEVICE_ID_AMD_VIPER_7410 0x7410
  26151. +#define PCI_DEVICE_ID_AMD_VIPER_7411 0x7411
  26152. +#define PCI_DEVICE_ID_AMD_VIPER_7413 0x7413
  26153. +#define PCI_DEVICE_ID_AMD_VIPER_7414 0x7414
  26154. +#define PCI_DEVICE_ID_AMD_VIPER_7440 0x7440
  26155. +#define PCI_DEVICE_ID_AMD_VIPER_7441 0x7441
  26156. +#define PCI_DEVICE_ID_AMD_VIPER_7443 0x7443
  26157. +#define PCI_DEVICE_ID_AMD_VIPER_7448 0x7448
  26158. +#define PCI_DEVICE_ID_AMD_VIPER_7449 0x7449
  26159. +
  26160. +#define PCI_VENDOR_ID_TRIDENT 0x1023
  26161. +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000
  26162. +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_NX 0x2001
  26163. +#define PCI_DEVICE_ID_TRIDENT_9320 0x9320
  26164. +#define PCI_DEVICE_ID_TRIDENT_9388 0x9388
  26165. +#define PCI_DEVICE_ID_TRIDENT_9397 0x9397
  26166. +#define PCI_DEVICE_ID_TRIDENT_939A 0x939A
  26167. +#define PCI_DEVICE_ID_TRIDENT_9520 0x9520
  26168. +#define PCI_DEVICE_ID_TRIDENT_9525 0x9525
  26169. +#define PCI_DEVICE_ID_TRIDENT_9420 0x9420
  26170. +#define PCI_DEVICE_ID_TRIDENT_9440 0x9440
  26171. +#define PCI_DEVICE_ID_TRIDENT_9660 0x9660
  26172. +#define PCI_DEVICE_ID_TRIDENT_9750 0x9750
  26173. +#define PCI_DEVICE_ID_TRIDENT_9850 0x9850
  26174. +#define PCI_DEVICE_ID_TRIDENT_9880 0x9880
  26175. +#define PCI_DEVICE_ID_TRIDENT_8400 0x8400
  26176. +#define PCI_DEVICE_ID_TRIDENT_8420 0x8420
  26177. +#define PCI_DEVICE_ID_TRIDENT_8500 0x8500
  26178. +
  26179. +#define PCI_VENDOR_ID_AI 0x1025
  26180. +#define PCI_DEVICE_ID_AI_M1435 0x1435
  26181. +
  26182. +#define PCI_VENDOR_ID_DELL 0x1028
  26183. +
  26184. +#define PCI_VENDOR_ID_MATROX 0x102B
  26185. +#define PCI_DEVICE_ID_MATROX_MGA_2 0x0518
  26186. +#define PCI_DEVICE_ID_MATROX_MIL 0x0519
  26187. +#define PCI_DEVICE_ID_MATROX_MYS 0x051A
  26188. +#define PCI_DEVICE_ID_MATROX_MIL_2 0x051b
  26189. +#define PCI_DEVICE_ID_MATROX_MIL_2_AGP 0x051f
  26190. +#define PCI_DEVICE_ID_MATROX_MGA_IMP 0x0d10
  26191. +#define PCI_DEVICE_ID_MATROX_G100_MM 0x1000
  26192. +#define PCI_DEVICE_ID_MATROX_G100_AGP 0x1001
  26193. +#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520
  26194. +#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521
  26195. +#define PCI_DEVICE_ID_MATROX_G400 0x0525
  26196. +#define PCI_DEVICE_ID_MATROX_G550 0x2527
  26197. +#define PCI_DEVICE_ID_MATROX_VIA 0x4536
  26198. +
  26199. +#define PCI_VENDOR_ID_CT 0x102c
  26200. +#define PCI_DEVICE_ID_CT_65545 0x00d8
  26201. +#define PCI_DEVICE_ID_CT_65548 0x00dc
  26202. +#define PCI_DEVICE_ID_CT_65550 0x00e0
  26203. +#define PCI_DEVICE_ID_CT_65554 0x00e4
  26204. +#define PCI_DEVICE_ID_CT_65555 0x00e5
  26205. +
  26206. +#define PCI_VENDOR_ID_MIRO 0x1031
  26207. +#define PCI_DEVICE_ID_MIRO_36050 0x5601
  26208. +
  26209. +#define PCI_VENDOR_ID_NEC 0x1033
  26210. +#define PCI_DEVICE_ID_NEC_PCX2 0x0046
  26211. +#define PCI_DEVICE_ID_NEC_NILE4 0x005a
  26212. +#define PCI_DEVICE_ID_NEC_VRC5476 0x009b
  26213. +
  26214. +#define PCI_VENDOR_ID_FD 0x1036
  26215. +#define PCI_DEVICE_ID_FD_36C70 0x0000
  26216. +
  26217. +#define PCI_VENDOR_ID_SIS 0x1039
  26218. +#define PCI_VENDOR_ID_SI 0x1039
  26219. +#define PCI_DEVICE_ID_SI_5591_AGP 0x0001
  26220. +#define PCI_DEVICE_ID_SI_6202 0x0002
  26221. +#define PCI_DEVICE_ID_SI_503 0x0008
  26222. +#define PCI_DEVICE_ID_SI_ACPI 0x0009
  26223. +#define PCI_DEVICE_ID_SI_5597_VGA 0x0200
  26224. +#define PCI_DEVICE_ID_SI_6205 0x0205
  26225. +#define PCI_DEVICE_ID_SI_501 0x0406
  26226. +#define PCI_DEVICE_ID_SI_496 0x0496
  26227. +#define PCI_DEVICE_ID_SI_300 0x0300
  26228. +#define PCI_DEVICE_ID_SI_315H 0x0310
  26229. +#define PCI_DEVICE_ID_SI_315 0x0315
  26230. +#define PCI_DEVICE_ID_SI_315PRO 0x0325
  26231. +#define PCI_DEVICE_ID_SI_530 0x0530
  26232. +#define PCI_DEVICE_ID_SI_540 0x0540
  26233. +#define PCI_DEVICE_ID_SI_550 0x0550
  26234. +#define PCI_DEVICE_ID_SI_601 0x0601
  26235. +#define PCI_DEVICE_ID_SI_620 0x0620
  26236. +#define PCI_DEVICE_ID_SI_630 0x0630
  26237. +#define PCI_DEVICE_ID_SI_635 0x0635
  26238. +#define PCI_DEVICE_ID_SI_640 0x0640
  26239. +#define PCI_DEVICE_ID_SI_645 0x0645
  26240. +#define PCI_DEVICE_ID_SI_650 0x0650
  26241. +#define PCI_DEVICE_ID_SI_730 0x0730
  26242. +#define PCI_DEVICE_ID_SI_735 0x0735
  26243. +#define PCI_DEVICE_ID_SI_740 0x0740
  26244. +#define PCI_DEVICE_ID_SI_745 0x0745
  26245. +#define PCI_DEVICE_ID_SI_750 0x0750
  26246. +#define PCI_DEVICE_ID_SI_900 0x0900
  26247. +#define PCI_DEVICE_ID_SIS900 0x0900
  26248. +#define PCI_DEVICE_ID_SI_5107 0x5107
  26249. +#define PCI_DEVICE_ID_SI_5300 0x5300
  26250. +#define PCI_DEVICE_ID_SI_540_VGA 0x5300
  26251. +#define PCI_DEVICE_ID_SI_550_VGA 0x5315
  26252. +#define PCI_DEVICE_ID_SI_5511 0x5511
  26253. +#define PCI_DEVICE_ID_SI_5513 0x5513
  26254. +#define PCI_DEVICE_ID_SI_5571 0x5571
  26255. +#define PCI_DEVICE_ID_SI_5591 0x5591
  26256. +#define PCI_DEVICE_ID_SI_5597 0x5597
  26257. +#define PCI_DEVICE_ID_SI_5598 0x5598
  26258. +#define PCI_DEVICE_ID_SI_5600 0x5600
  26259. +#define PCI_DEVICE_ID_SI_6300 0x6300
  26260. +#define PCI_DEVICE_ID_SI_630_VGA 0x6300
  26261. +#define PCI_DEVICE_ID_SI_6306 0x6306
  26262. +#define PCI_DEVICE_ID_SI_6326 0x6326
  26263. +#define PCI_DEVICE_ID_SI_7001 0x7001
  26264. +#define PCI_DEVICE_ID_SI_7016 0x7016
  26265. +#define PCI_DEVICE_ID_SIS7016 0x7016
  26266. +#define PCI_DEVICE_ID_SI_730_VGA 0x7300
  26267. +
  26268. +#define PCI_VENDOR_ID_HP 0x103c
  26269. +#define PCI_DEVICE_ID_HP_DONNER_GFX 0x1008
  26270. +#define PCI_DEVICE_ID_HP_TACHYON 0x1028
  26271. +#define PCI_DEVICE_ID_HP_TACHLITE 0x1029
  26272. +#define PCI_DEVICE_ID_HP_J2585A 0x1030
  26273. +#define PCI_DEVICE_ID_HP_J2585B 0x1031
  26274. +#define PCI_DEVICE_ID_HP_SAS 0x1048
  26275. +#define PCI_DEVICE_ID_HP_DIVA1 0x1049
  26276. +#define PCI_DEVICE_ID_HP_DIVA2 0x104A
  26277. +#define PCI_DEVICE_ID_HP_SP2_0 0x104B
  26278. +
  26279. +#define PCI_VENDOR_ID_PCTECH 0x1042
  26280. +#define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000
  26281. +#define PCI_DEVICE_ID_PCTECH_RZ1001 0x1001
  26282. +#define PCI_DEVICE_ID_PCTECH_SAMURAI_0 0x3000
  26283. +#define PCI_DEVICE_ID_PCTECH_SAMURAI_1 0x3010
  26284. +#define PCI_DEVICE_ID_PCTECH_SAMURAI_IDE 0x3020
  26285. +
  26286. +#define PCI_VENDOR_ID_ASUSTEK 0x1043
  26287. +#define PCI_DEVICE_ID_ASUSTEK_0675 0x0675
  26288. +
  26289. +#define PCI_VENDOR_ID_DPT 0x1044
  26290. +#define PCI_DEVICE_ID_DPT 0xa400
  26291. +
  26292. +#define PCI_VENDOR_ID_OPTI 0x1045
  26293. +#define PCI_DEVICE_ID_OPTI_92C178 0xc178
  26294. +#define PCI_DEVICE_ID_OPTI_82C557 0xc557
  26295. +#define PCI_DEVICE_ID_OPTI_82C558 0xc558
  26296. +#define PCI_DEVICE_ID_OPTI_82C621 0xc621
  26297. +#define PCI_DEVICE_ID_OPTI_82C700 0xc700
  26298. +#define PCI_DEVICE_ID_OPTI_82C701 0xc701
  26299. +#define PCI_DEVICE_ID_OPTI_82C814 0xc814
  26300. +#define PCI_DEVICE_ID_OPTI_82C822 0xc822
  26301. +#define PCI_DEVICE_ID_OPTI_82C861 0xc861
  26302. +#define PCI_DEVICE_ID_OPTI_82C825 0xd568
  26303. +
  26304. +#define PCI_VENDOR_ID_ELSA 0x1048
  26305. +#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000
  26306. +#define PCI_DEVICE_ID_ELSA_QS3000 0x3000
  26307. +
  26308. +#define PCI_VENDOR_ID_ELSA 0x1048
  26309. +#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000
  26310. +#define PCI_DEVICE_ID_ELSA_QS3000 0x3000
  26311. +
  26312. +#define PCI_VENDOR_ID_SGS 0x104a
  26313. +#define PCI_DEVICE_ID_SGS_2000 0x0008
  26314. +#define PCI_DEVICE_ID_SGS_1764 0x0009
  26315. +
  26316. +#define PCI_VENDOR_ID_BUSLOGIC 0x104B
  26317. +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140
  26318. +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER 0x1040
  26319. +#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130
  26320. +
  26321. +#define PCI_VENDOR_ID_TI 0x104c
  26322. +#define PCI_DEVICE_ID_TI_TVP4010 0x3d04
  26323. +#define PCI_DEVICE_ID_TI_TVP4020 0x3d07
  26324. +#define PCI_DEVICE_ID_TI_1130 0xac12
  26325. +#define PCI_DEVICE_ID_TI_1031 0xac13
  26326. +#define PCI_DEVICE_ID_TI_1131 0xac15
  26327. +#define PCI_DEVICE_ID_TI_1250 0xac16
  26328. +#define PCI_DEVICE_ID_TI_1220 0xac17
  26329. +#define PCI_DEVICE_ID_TI_1221 0xac19
  26330. +#define PCI_DEVICE_ID_TI_1210 0xac1a
  26331. +#define PCI_DEVICE_ID_TI_1410 0xac50
  26332. +#define PCI_DEVICE_ID_TI_1450 0xac1b
  26333. +#define PCI_DEVICE_ID_TI_1225 0xac1c
  26334. +#define PCI_DEVICE_ID_TI_1251A 0xac1d
  26335. +#define PCI_DEVICE_ID_TI_1211 0xac1e
  26336. +#define PCI_DEVICE_ID_TI_1251B 0xac1f
  26337. +#define PCI_DEVICE_ID_TI_4410 0xac41
  26338. +#define PCI_DEVICE_ID_TI_4451 0xac42
  26339. +#define PCI_DEVICE_ID_TI_1420 0xac51
  26340. +
  26341. +#define PCI_VENDOR_ID_SONY 0x104d
  26342. +#define PCI_DEVICE_ID_SONY_CXD3222 0x8039
  26343. +
  26344. +#define PCI_VENDOR_ID_OAK 0x104e
  26345. +#define PCI_DEVICE_ID_OAK_OTI107 0x0107
  26346. +
  26347. +/* Winbond have two vendor IDs! See 0x10ad as well */
  26348. +#define PCI_VENDOR_ID_WINBOND2 0x1050
  26349. +#define PCI_DEVICE_ID_WINBOND2_89C840 0x0840
  26350. +#define PCI_DEVICE_ID_WINBOND2_89C940 0x0940
  26351. +#define PCI_DEVICE_ID_WINBOND2_89C940F 0x5a5a
  26352. +#define PCI_DEVICE_ID_WINBOND2_6692 0x6692
  26353. +
  26354. +#define PCI_VENDOR_ID_ANIGMA 0x1051
  26355. +#define PCI_DEVICE_ID_ANIGMA_MC145575 0x0100
  26356. +
  26357. +#define PCI_VENDOR_ID_EFAR 0x1055
  26358. +#define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130
  26359. +#define PCI_DEVICE_ID_EFAR_SLC90E66_0 0x9460
  26360. +#define PCI_DEVICE_ID_EFAR_SLC90E66_2 0x9462
  26361. +#define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463
  26362. +
  26363. +#define PCI_VENDOR_ID_MOTOROLA 0x1057
  26364. +#define PCI_VENDOR_ID_MOTOROLA_OOPS 0x1507
  26365. +#define PCI_DEVICE_ID_MOTOROLA_MPC105 0x0001
  26366. +#define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002
  26367. +#define PCI_DEVICE_ID_MOTOROLA_RAVEN 0x4801
  26368. +#define PCI_DEVICE_ID_MOTOROLA_FALCON 0x4802
  26369. +#define PCI_DEVICE_ID_MOTOROLA_CPX8216 0x4806
  26370. +
  26371. +#define PCI_VENDOR_ID_PROMISE 0x105a
  26372. +#define PCI_DEVICE_ID_PROMISE_20265 0x0d30
  26373. +#define PCI_DEVICE_ID_PROMISE_20267 0x4d30
  26374. +#define PCI_DEVICE_ID_PROMISE_20246 0x4d33
  26375. +#define PCI_DEVICE_ID_PROMISE_20262 0x4d38
  26376. +#define PCI_DEVICE_ID_PROMISE_20268 0x4d68
  26377. +#define PCI_DEVICE_ID_PROMISE_20268R 0x6268
  26378. +#define PCI_DEVICE_ID_PROMISE_20269 0x4d69
  26379. +#define PCI_DEVICE_ID_PROMISE_20275 0x1275
  26380. +#define PCI_DEVICE_ID_PROMISE_5300 0x5300
  26381. +
  26382. +#define PCI_VENDOR_ID_N9 0x105d
  26383. +#define PCI_DEVICE_ID_N9_I128 0x2309
  26384. +#define PCI_DEVICE_ID_N9_I128_2 0x2339
  26385. +#define PCI_DEVICE_ID_N9_I128_T2R 0x493d
  26386. +
  26387. +#define PCI_VENDOR_ID_UMC 0x1060
  26388. +#define PCI_DEVICE_ID_UMC_UM8673F 0x0101
  26389. +#define PCI_DEVICE_ID_UMC_UM8891A 0x0891
  26390. +#define PCI_DEVICE_ID_UMC_UM8886BF 0x673a
  26391. +#define PCI_DEVICE_ID_UMC_UM8886A 0x886a
  26392. +#define PCI_DEVICE_ID_UMC_UM8881F 0x8881
  26393. +#define PCI_DEVICE_ID_UMC_UM8886F 0x8886
  26394. +#define PCI_DEVICE_ID_UMC_UM9017F 0x9017
  26395. +#define PCI_DEVICE_ID_UMC_UM8886N 0xe886
  26396. +#define PCI_DEVICE_ID_UMC_UM8891N 0xe891
  26397. +
  26398. +#define PCI_VENDOR_ID_X 0x1061
  26399. +#define PCI_DEVICE_ID_X_AGX016 0x0001
  26400. +
  26401. +#define PCI_VENDOR_ID_MYLEX 0x1069
  26402. +#define PCI_DEVICE_ID_MYLEX_DAC960_P 0x0001
  26403. +#define PCI_DEVICE_ID_MYLEX_DAC960_PD 0x0002
  26404. +#define PCI_DEVICE_ID_MYLEX_DAC960_PG 0x0010
  26405. +#define PCI_DEVICE_ID_MYLEX_DAC960_LA 0x0020
  26406. +#define PCI_DEVICE_ID_MYLEX_DAC960_LP 0x0050
  26407. +#define PCI_DEVICE_ID_MYLEX_DAC960_BA 0xBA56
  26408. +
  26409. +#define PCI_VENDOR_ID_PICOP 0x1066
  26410. +#define PCI_DEVICE_ID_PICOP_PT86C52X 0x0001
  26411. +#define PCI_DEVICE_ID_PICOP_PT80C524 0x8002
  26412. +
  26413. +#define PCI_VENDOR_ID_APPLE 0x106b
  26414. +#define PCI_DEVICE_ID_APPLE_BANDIT 0x0001
  26415. +#define PCI_DEVICE_ID_APPLE_GC 0x0002
  26416. +#define PCI_DEVICE_ID_APPLE_HYDRA 0x000e
  26417. +#define PCI_DEVICE_ID_APPLE_UNI_N_FW 0x0018
  26418. +#define PCI_DEVICE_ID_APPLE_KL_USB 0x0019
  26419. +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020
  26420. +#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021
  26421. +#define PCI_DEVICE_ID_APPLE_UNI_N_FW2 0x0030
  26422. +
  26423. +#define PCI_VENDOR_ID_YAMAHA 0x1073
  26424. +#define PCI_DEVICE_ID_YAMAHA_724 0x0004
  26425. +#define PCI_DEVICE_ID_YAMAHA_724F 0x000d
  26426. +#define PCI_DEVICE_ID_YAMAHA_740 0x000a
  26427. +#define PCI_DEVICE_ID_YAMAHA_740C 0x000c
  26428. +#define PCI_DEVICE_ID_YAMAHA_744 0x0010
  26429. +#define PCI_DEVICE_ID_YAMAHA_754 0x0012
  26430. +
  26431. +#define PCI_VENDOR_ID_NEXGEN 0x1074
  26432. +#define PCI_DEVICE_ID_NEXGEN_82C501 0x4e78
  26433. +
  26434. +#define PCI_VENDOR_ID_QLOGIC 0x1077
  26435. +#define PCI_DEVICE_ID_QLOGIC_ISP1020 0x1020
  26436. +#define PCI_DEVICE_ID_QLOGIC_ISP1022 0x1022
  26437. +#define PCI_DEVICE_ID_QLOGIC_ISP2100 0x2100
  26438. +#define PCI_DEVICE_ID_QLOGIC_ISP2200 0x2200
  26439. +
  26440. +#define PCI_VENDOR_ID_CYRIX 0x1078
  26441. +#define PCI_DEVICE_ID_CYRIX_5510 0x0000
  26442. +#define PCI_DEVICE_ID_CYRIX_PCI_MASTER 0x0001
  26443. +#define PCI_DEVICE_ID_CYRIX_5520 0x0002
  26444. +#define PCI_DEVICE_ID_CYRIX_5530_LEGACY 0x0100
  26445. +#define PCI_DEVICE_ID_CYRIX_5530_SMI 0x0101
  26446. +#define PCI_DEVICE_ID_CYRIX_5530_IDE 0x0102
  26447. +#define PCI_DEVICE_ID_CYRIX_5530_AUDIO 0x0103
  26448. +#define PCI_DEVICE_ID_CYRIX_5530_VIDEO 0x0104
  26449. +
  26450. +#define PCI_VENDOR_ID_LEADTEK 0x107d
  26451. +#define PCI_DEVICE_ID_LEADTEK_805 0x0000
  26452. +
  26453. +#define PCI_VENDOR_ID_INTERPHASE 0x107e
  26454. +#define PCI_DEVICE_ID_INTERPHASE_5526 0x0004
  26455. +#define PCI_DEVICE_ID_INTERPHASE_55x6 0x0005
  26456. +#define PCI_DEVICE_ID_INTERPHASE_5575 0x0008
  26457. +
  26458. +#define PCI_VENDOR_ID_CONTAQ 0x1080
  26459. +#define PCI_DEVICE_ID_CONTAQ_82C599 0x0600
  26460. +#define PCI_DEVICE_ID_CONTAQ_82C693 0xc693
  26461. +
  26462. +#define PCI_VENDOR_ID_FOREX 0x1083
  26463. +
  26464. +#define PCI_VENDOR_ID_OLICOM 0x108d
  26465. +#define PCI_DEVICE_ID_OLICOM_OC3136 0x0001
  26466. +#define PCI_DEVICE_ID_OLICOM_OC2315 0x0011
  26467. +#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
  26468. +#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
  26469. +#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
  26470. +#define PCI_DEVICE_ID_OLICOM_OC6151 0x0021
  26471. +
  26472. +#define PCI_VENDOR_ID_SUN 0x108e
  26473. +#define PCI_DEVICE_ID_SUN_EBUS 0x1000
  26474. +#define PCI_DEVICE_ID_SUN_HAPPYMEAL 0x1001
  26475. +#define PCI_DEVICE_ID_SUN_RIO_EBUS 0x1100
  26476. +#define PCI_DEVICE_ID_SUN_RIO_GEM 0x1101
  26477. +#define PCI_DEVICE_ID_SUN_RIO_1394 0x1102
  26478. +#define PCI_DEVICE_ID_SUN_RIO_USB 0x1103
  26479. +#define PCI_DEVICE_ID_SUN_GEM 0x2bad
  26480. +#define PCI_DEVICE_ID_SUN_SIMBA 0x5000
  26481. +#define PCI_DEVICE_ID_SUN_PBM 0x8000
  26482. +#define PCI_DEVICE_ID_SUN_SCHIZO 0x8001
  26483. +#define PCI_DEVICE_ID_SUN_SABRE 0xa000
  26484. +#define PCI_DEVICE_ID_SUN_HUMMINGBIRD 0xa001
  26485. +
  26486. +#define PCI_VENDOR_ID_CMD 0x1095
  26487. +#define PCI_DEVICE_ID_CMD_640 0x0640
  26488. +#define PCI_DEVICE_ID_CMD_643 0x0643
  26489. +#define PCI_DEVICE_ID_CMD_646 0x0646
  26490. +#define PCI_DEVICE_ID_CMD_647 0x0647
  26491. +#define PCI_DEVICE_ID_CMD_648 0x0648
  26492. +#define PCI_DEVICE_ID_CMD_649 0x0649
  26493. +#define PCI_DEVICE_ID_CMD_670 0x0670
  26494. +#define PCI_DEVICE_ID_CMD_680 0x0680
  26495. +
  26496. +#define PCI_VENDOR_ID_VISION 0x1098
  26497. +#define PCI_DEVICE_ID_VISION_QD8500 0x0001
  26498. +#define PCI_DEVICE_ID_VISION_QD8580 0x0002
  26499. +
  26500. +#define PCI_VENDOR_ID_BROOKTREE 0x109e
  26501. +#define PCI_DEVICE_ID_BROOKTREE_848 0x0350
  26502. +#define PCI_DEVICE_ID_BROOKTREE_849A 0x0351
  26503. +#define PCI_DEVICE_ID_BROOKTREE_878_1 0x036e
  26504. +#define PCI_DEVICE_ID_BROOKTREE_878 0x0878
  26505. +#define PCI_DEVICE_ID_BROOKTREE_8474 0x8474
  26506. +
  26507. +#define PCI_VENDOR_ID_SIERRA 0x10a8
  26508. +#define PCI_DEVICE_ID_SIERRA_STB 0x0000
  26509. +
  26510. +#define PCI_VENDOR_ID_SGI 0x10a9
  26511. +#define PCI_DEVICE_ID_SGI_IOC3 0x0003
  26512. +
  26513. +#define PCI_VENDOR_ID_ACC 0x10aa
  26514. +#define PCI_DEVICE_ID_ACC_2056 0x0000
  26515. +
  26516. +#define PCI_VENDOR_ID_WINBOND 0x10ad
  26517. +#define PCI_DEVICE_ID_WINBOND_83769 0x0001
  26518. +#define PCI_DEVICE_ID_WINBOND_82C105 0x0105
  26519. +#define PCI_DEVICE_ID_WINBOND_83C553 0x0565
  26520. +
  26521. +#define PCI_VENDOR_ID_DATABOOK 0x10b3
  26522. +#define PCI_DEVICE_ID_DATABOOK_87144 0xb106
  26523. +
  26524. +#define PCI_VENDOR_ID_PLX 0x10b5
  26525. +#define PCI_DEVICE_ID_PLX_R685 0x1030
  26526. +#define PCI_DEVICE_ID_PLX_ROMULUS 0x106a
  26527. +#define PCI_DEVICE_ID_PLX_SPCOM800 0x1076
  26528. +#define PCI_DEVICE_ID_PLX_1077 0x1077
  26529. +#define PCI_DEVICE_ID_PLX_SPCOM200 0x1103
  26530. +#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151
  26531. +#define PCI_DEVICE_ID_PLX_R753 0x1152
  26532. +#define PCI_DEVICE_ID_PLX_9050 0x9050
  26533. +#define PCI_DEVICE_ID_PLX_9060 0x9060
  26534. +#define PCI_DEVICE_ID_PLX_9060ES 0x906E
  26535. +#define PCI_DEVICE_ID_PLX_9060SD 0x906D
  26536. +#define PCI_DEVICE_ID_PLX_9080 0x9080
  26537. +#define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001
  26538. +
  26539. +#define PCI_VENDOR_ID_MADGE 0x10b6
  26540. +#define PCI_DEVICE_ID_MADGE_MK2 0x0002
  26541. +#define PCI_DEVICE_ID_MADGE_C155S 0x1001
  26542. +
  26543. +#define PCI_VENDOR_ID_3COM 0x10b7
  26544. +#define PCI_DEVICE_ID_3COM_3C985 0x0001
  26545. +#define PCI_DEVICE_ID_3COM_3C339 0x3390
  26546. +#define PCI_DEVICE_ID_3COM_3C590 0x5900
  26547. +#define PCI_DEVICE_ID_3COM_3C595 0x5950
  26548. +#define PCI_DEVICE_ID_3COM_3C595TX 0x5950
  26549. +#define PCI_DEVICE_ID_3COM_3C595_1 0x5951
  26550. +#define PCI_DEVICE_ID_3COM_3C595T4 0x5951
  26551. +#define PCI_DEVICE_ID_3COM_3C595_2 0x5952
  26552. +#define PCI_DEVICE_ID_3COM_3C595MII 0x5952
  26553. +#define PCI_DEVICE_ID_3COM_3C900TPO 0x9000
  26554. +#define PCI_DEVICE_ID_3COM_3C900COMBO 0x9001
  26555. +#define PCI_DEVICE_ID_3COM_3C905TX 0x9050
  26556. +#define PCI_DEVICE_ID_3COM_3C905T4 0x9051
  26557. +#define PCI_DEVICE_ID_3COM_3C905B_TX 0x9055
  26558. +#define PCI_DEVICE_ID_3COM_3C905C_TXM 0x9200
  26559. +
  26560. +#define PCI_VENDOR_ID_SMC 0x10b8
  26561. +#define PCI_DEVICE_ID_SMC_EPIC100 0x0005
  26562. +
  26563. +#define PCI_VENDOR_ID_SUNDANCE 0x13F0
  26564. +#define PCI_DEVICE_ID_SUNDANCE_ALTA 0x0201
  26565. +
  26566. +#define PCI_VENDOR_ID_AL 0x10b9
  26567. +#define PCI_DEVICE_ID_AL_M1445 0x1445
  26568. +#define PCI_DEVICE_ID_AL_M1449 0x1449
  26569. +#define PCI_DEVICE_ID_AL_M1451 0x1451
  26570. +#define PCI_DEVICE_ID_AL_M1461 0x1461
  26571. +#define PCI_DEVICE_ID_AL_M1489 0x1489
  26572. +#define PCI_DEVICE_ID_AL_M1511 0x1511
  26573. +#define PCI_DEVICE_ID_AL_M1513 0x1513
  26574. +#define PCI_DEVICE_ID_AL_M1521 0x1521
  26575. +#define PCI_DEVICE_ID_AL_M1523 0x1523
  26576. +#define PCI_DEVICE_ID_AL_M1531 0x1531
  26577. +#define PCI_DEVICE_ID_AL_M1533 0x1533
  26578. +#define PCI_DEVICE_ID_AL_M1541 0x1541
  26579. +#define PCI_DEVICE_ID_AL_M1621 0x1621
  26580. +#define PCI_DEVICE_ID_AL_M1631 0x1631
  26581. +#define PCI_DEVICE_ID_AL_M1641 0x1641
  26582. +#define PCI_DEVICE_ID_AL_M1647 0x1647
  26583. +#define PCI_DEVICE_ID_AL_M1651 0x1651
  26584. +#define PCI_DEVICE_ID_AL_M1543 0x1543
  26585. +#define PCI_DEVICE_ID_AL_M3307 0x3307
  26586. +#define PCI_DEVICE_ID_AL_M4803 0x5215
  26587. +#define PCI_DEVICE_ID_AL_M5219 0x5219
  26588. +#define PCI_DEVICE_ID_AL_M5229 0x5229
  26589. +#define PCI_DEVICE_ID_AL_M5237 0x5237
  26590. +#define PCI_DEVICE_ID_AL_M5243 0x5243
  26591. +#define PCI_DEVICE_ID_AL_M5451 0x5451
  26592. +#define PCI_DEVICE_ID_AL_M7101 0x7101
  26593. +
  26594. +#define PCI_VENDOR_ID_MITSUBISHI 0x10ba
  26595. +
  26596. +#define PCI_VENDOR_ID_SURECOM 0x10bd
  26597. +#define PCI_DEVICE_ID_SURECOM_NE34 0x0e34
  26598. +
  26599. +#define PCI_VENDOR_ID_NEOMAGIC 0x10c8
  26600. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_NM2070 0x0001
  26601. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128V 0x0002
  26602. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128ZV 0x0003
  26603. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_NM2160 0x0004
  26604. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICMEDIA_256AV 0x0005
  26605. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128ZVPLUS 0x0083
  26606. +
  26607. +#define PCI_VENDOR_ID_ASP 0x10cd
  26608. +#define PCI_DEVICE_ID_ASP_ABP940 0x1200
  26609. +#define PCI_DEVICE_ID_ASP_ABP940U 0x1300
  26610. +#define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
  26611. +
  26612. +#define PCI_VENDOR_ID_MACRONIX 0x10d9
  26613. +#define PCI_DEVICE_ID_MACRONIX_MX98713 0x0512
  26614. +#define PCI_DEVICE_ID_MX987x3 0x0512
  26615. +#define PCI_DEVICE_ID_MACRONIX_MX987x5 0x0531
  26616. +#define PCI_DEVICE_ID_MX987x5 0x0531
  26617. +
  26618. +#define PCI_VENDOR_ID_TCONRAD 0x10da
  26619. +#define PCI_DEVICE_ID_TCONRAD_TOKENRING 0x0508
  26620. +
  26621. +#define PCI_VENDOR_ID_CERN 0x10dc
  26622. +#define PCI_DEVICE_ID_CERN_SPSB_PMC 0x0001
  26623. +#define PCI_DEVICE_ID_CERN_SPSB_PCI 0x0002
  26624. +#define PCI_DEVICE_ID_CERN_HIPPI_DST 0x0021
  26625. +#define PCI_DEVICE_ID_CERN_HIPPI_SRC 0x0022
  26626. +
  26627. +#define PCI_VENDOR_ID_NVIDIA 0x10de
  26628. +#define PCI_DEVICE_ID_NVIDIA_TNT 0x0020
  26629. +#define PCI_DEVICE_ID_NVIDIA_TNT2 0x0028
  26630. +#define PCI_DEVICE_ID_NVIDIA_UTNT2 0x0029
  26631. +#define PCI_DEVICE_ID_NVIDIA_VTNT2 0x002C
  26632. +#define PCI_DEVICE_ID_NVIDIA_UVTNT2 0x002D
  26633. +#define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0
  26634. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100
  26635. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101
  26636. +#define PCI_DEVICE_ID_NVIDIA_QUADRO 0x0103
  26637. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX 0x0110
  26638. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2 0x0111
  26639. +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR 0x0113
  26640. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS 0x0150
  26641. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2 0x0151
  26642. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA 0x0152
  26643. +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO 0x0153
  26644. +
  26645. +#define PCI_VENDOR_ID_IMS 0x10e0
  26646. +#define PCI_DEVICE_ID_IMS_8849 0x8849
  26647. +#define PCI_DEVICE_ID_IMS_TT128 0x9128
  26648. +#define PCI_DEVICE_ID_IMS_TT3D 0x9135
  26649. +
  26650. +#define PCI_VENDOR_ID_TEKRAM2 0x10e1
  26651. +#define PCI_DEVICE_ID_TEKRAM2_690c 0x690c
  26652. +
  26653. +#define PCI_VENDOR_ID_TUNDRA 0x10e3
  26654. +#define PCI_DEVICE_ID_TUNDRA_CA91C042 0x0000
  26655. +
  26656. +#define PCI_VENDOR_ID_AMCC 0x10e8
  26657. +#define PCI_DEVICE_ID_AMCC_MYRINET 0x8043
  26658. +#define PCI_DEVICE_ID_AMCC_PARASTATION 0x8062
  26659. +#define PCI_DEVICE_ID_AMCC_S5933 0x807d
  26660. +#define PCI_DEVICE_ID_AMCC_S5933_HEPC3 0x809c
  26661. +
  26662. +#define PCI_VENDOR_ID_INTERG 0x10ea
  26663. +#define PCI_DEVICE_ID_INTERG_1680 0x1680
  26664. +#define PCI_DEVICE_ID_INTERG_1682 0x1682
  26665. +#define PCI_DEVICE_ID_INTERG_2000 0x2000
  26666. +#define PCI_DEVICE_ID_INTERG_2010 0x2010
  26667. +#define PCI_DEVICE_ID_INTERG_5000 0x5000
  26668. +#define PCI_DEVICE_ID_INTERG_5050 0x5050
  26669. +
  26670. +#define PCI_VENDOR_ID_REALTEK 0x10ec
  26671. +#define PCI_DEVICE_ID_REALTEK_8029 0x8029
  26672. +#define PCI_DEVICE_ID_REALTEK_8129 0x8129
  26673. +#define PCI_DEVICE_ID_REALTEK_8139 0x8139
  26674. +
  26675. +#define PCI_VENDOR_ID_XILINX 0x10ee
  26676. +#define PCI_DEVICE_ID_TURBOPAM 0x4020
  26677. +
  26678. +#define PCI_VENDOR_ID_TRUEVISION 0x10fa
  26679. +#define PCI_DEVICE_ID_TRUEVISION_T1000 0x000c
  26680. +
  26681. +#define PCI_VENDOR_ID_INIT 0x1101
  26682. +#define PCI_DEVICE_ID_INIT_320P 0x9100
  26683. +#define PCI_DEVICE_ID_INIT_360P 0x9500
  26684. +
  26685. +#define PCI_VENDOR_ID_CREATIVE 0x1102 // duplicate: ECTIVA
  26686. +#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002
  26687. +
  26688. +#define PCI_VENDOR_ID_ECTIVA 0x1102 // duplicate: CREATIVE
  26689. +#define PCI_DEVICE_ID_ECTIVA_EV1938 0x8938
  26690. +
  26691. +#define PCI_VENDOR_ID_TTI 0x1103
  26692. +#define PCI_DEVICE_ID_TTI_HPT343 0x0003
  26693. +#define PCI_DEVICE_ID_TTI_HPT366 0x0004
  26694. +
  26695. +#define PCI_VENDOR_ID_VIA 0x1106
  26696. +#define PCI_VENDOR_ID_VIATEC 0x1106
  26697. +#define PCI_DEVICE_ID_VIA_8363_0 0x0305
  26698. +#define PCI_DEVICE_ID_VIA_8371_0 0x0391
  26699. +#define PCI_DEVICE_ID_VIA_8501_0 0x0501
  26700. +#define PCI_DEVICE_ID_VIA_82C505 0x0505
  26701. +#define PCI_DEVICE_ID_VIA_82C561 0x0561
  26702. +#define PCI_DEVICE_ID_VIA_82C586_1 0x0571
  26703. +#define PCI_DEVICE_ID_VIA_82C576 0x0576
  26704. +#define PCI_DEVICE_ID_VIA_82C585 0x0585
  26705. +#define PCI_DEVICE_ID_VIA_82C586_0 0x0586
  26706. +#define PCI_DEVICE_ID_VIA_82C595 0x0595
  26707. +#define PCI_DEVICE_ID_VIA_82C596 0x0596
  26708. +#define PCI_DEVICE_ID_VIA_82C597_0 0x0597
  26709. +#define PCI_DEVICE_ID_VIA_82C598_0 0x0598
  26710. +#define PCI_DEVICE_ID_VIA_8601_0 0x0601
  26711. +#define PCI_DEVICE_ID_VIA_8605_0 0x0605
  26712. +#define PCI_DEVICE_ID_VIA_82C680 0x0680
  26713. +#define PCI_DEVICE_ID_VIA_82C686 0x0686
  26714. +#define PCI_DEVICE_ID_VIA_82C691 0x0691
  26715. +#define PCI_DEVICE_ID_VIA_82C693 0x0693
  26716. +#define PCI_DEVICE_ID_VIA_82C693_1 0x0698
  26717. +#define PCI_DEVICE_ID_VIA_82C926 0x0926
  26718. +#define PCI_DEVICE_ID_VIA_82C576_1 0x1571
  26719. +#define PCI_DEVICE_ID_VIA_82C595_97 0x1595
  26720. +#define PCI_DEVICE_ID_VIA_82C586_2 0x3038
  26721. +#define PCI_DEVICE_ID_VIA_82C586_3 0x3040
  26722. +#define PCI_DEVICE_ID_VIA_RHINE_I 0x3043
  26723. +#define PCI_DEVICE_ID_VIA_6305 0x3044
  26724. +#define PCI_DEVICE_ID_VIA_82C596_3 0x3050
  26725. +#define PCI_DEVICE_ID_VIA_82C596B_3 0x3051
  26726. +#define PCI_DEVICE_ID_VIA_82C686_4 0x3057
  26727. +#define PCI_DEVICE_ID_VIA_82C686_5 0x3058
  26728. +#define PCI_DEVICE_ID_VIA_8233_5 0x3059
  26729. +#define PCI_DEVICE_ID_VIA_8233_7 0x3065
  26730. +#define PCI_DEVICE_ID_VIA_VT6102 0x3065
  26731. +#define PCI_DEVICE_ID_VIA_82C686_6 0x3068
  26732. +#define PCI_DEVICE_ID_VIA_8233_0 0x3074
  26733. +#define PCI_DEVICE_ID_VIA_VT6105 0x3106
  26734. +#define PCI_DEVICE_ID_VIA_8233C_0 0x3109
  26735. +#define PCI_DEVICE_ID_VIA_8633_0 0x3091
  26736. +#define PCI_DEVICE_ID_VIA_8367_0 0x3099
  26737. +#define PCI_DEVICE_ID_VIA_86C100A 0x6100
  26738. +#define PCI_DEVICE_ID_VIA_8231 0x8231
  26739. +#define PCI_DEVICE_ID_VIA_8231_4 0x8235
  26740. +#define PCI_DEVICE_ID_VIA_8365_1 0x8305
  26741. +#define PCI_DEVICE_ID_VIA_8371_1 0x8391
  26742. +#define PCI_DEVICE_ID_VIA_8501_1 0x8501
  26743. +#define PCI_DEVICE_ID_VIA_82C597_1 0x8597
  26744. +#define PCI_DEVICE_ID_VIA_82C598_1 0x8598
  26745. +#define PCI_DEVICE_ID_VIA_8601_1 0x8601
  26746. +#define PCI_DEVICE_ID_VIA_8505_1 0X8605
  26747. +#define PCI_DEVICE_ID_VIA_8633_1 0xB091
  26748. +#define PCI_DEVICE_ID_VIA_8367_1 0xB099
  26749. +
  26750. +#define PCI_VENDOR_ID_SIEMENS 0x110A
  26751. +#define PCI_DEVICE_ID_SIEMENS_DSCC4 0x2102
  26752. +
  26753. +#define PCI_VENDOR_ID_SMC2 0x1113
  26754. +#define PCI_DEVICE_ID_SMC2_1211TX 0x1211
  26755. +#define PCI_DEVICE_ID_SMC2_1211 0x1211
  26756. +#define PCI_DEVICE_ID_SMC2_1216 0x1216
  26757. +
  26758. +#define PCI_VENDOR_ID_VORTEX 0x1119
  26759. +#define PCI_DEVICE_ID_VORTEX_GDT60x0 0x0000
  26760. +#define PCI_DEVICE_ID_VORTEX_GDT6000B 0x0001
  26761. +#define PCI_DEVICE_ID_VORTEX_GDT6x10 0x0002
  26762. +#define PCI_DEVICE_ID_VORTEX_GDT6x20 0x0003
  26763. +#define PCI_DEVICE_ID_VORTEX_GDT6530 0x0004
  26764. +#define PCI_DEVICE_ID_VORTEX_GDT6550 0x0005
  26765. +#define PCI_DEVICE_ID_VORTEX_GDT6x17 0x0006
  26766. +#define PCI_DEVICE_ID_VORTEX_GDT6x27 0x0007
  26767. +#define PCI_DEVICE_ID_VORTEX_GDT6537 0x0008
  26768. +#define PCI_DEVICE_ID_VORTEX_GDT6557 0x0009
  26769. +#define PCI_DEVICE_ID_VORTEX_GDT6x15 0x000a
  26770. +#define PCI_DEVICE_ID_VORTEX_GDT6x25 0x000b
  26771. +#define PCI_DEVICE_ID_VORTEX_GDT6535 0x000c
  26772. +#define PCI_DEVICE_ID_VORTEX_GDT6555 0x000d
  26773. +#define PCI_DEVICE_ID_VORTEX_GDT6x17RP 0x0100
  26774. +#define PCI_DEVICE_ID_VORTEX_GDT6x27RP 0x0101
  26775. +#define PCI_DEVICE_ID_VORTEX_GDT6537RP 0x0102
  26776. +#define PCI_DEVICE_ID_VORTEX_GDT6557RP 0x0103
  26777. +#define PCI_DEVICE_ID_VORTEX_GDT6x11RP 0x0104
  26778. +#define PCI_DEVICE_ID_VORTEX_GDT6x21RP 0x0105
  26779. +#define PCI_DEVICE_ID_VORTEX_GDT6x17RP1 0x0110
  26780. +#define PCI_DEVICE_ID_VORTEX_GDT6x27RP1 0x0111
  26781. +#define PCI_DEVICE_ID_VORTEX_GDT6537RP1 0x0112
  26782. +#define PCI_DEVICE_ID_VORTEX_GDT6557RP1 0x0113
  26783. +#define PCI_DEVICE_ID_VORTEX_GDT6x11RP1 0x0114
  26784. +#define PCI_DEVICE_ID_VORTEX_GDT6x21RP1 0x0115
  26785. +#define PCI_DEVICE_ID_VORTEX_GDT6x17RP2 0x0120
  26786. +#define PCI_DEVICE_ID_VORTEX_GDT6x27RP2 0x0121
  26787. +#define PCI_DEVICE_ID_VORTEX_GDT6537RP2 0x0122
  26788. +#define PCI_DEVICE_ID_VORTEX_GDT6557RP2 0x0123
  26789. +#define PCI_DEVICE_ID_VORTEX_GDT6x11RP2 0x0124
  26790. +#define PCI_DEVICE_ID_VORTEX_GDT6x21RP2 0x0125
  26791. +
  26792. +#define PCI_VENDOR_ID_EF 0x111a
  26793. +#define PCI_DEVICE_ID_EF_ATM_FPGA 0x0000
  26794. +#define PCI_DEVICE_ID_EF_ATM_ASIC 0x0002
  26795. +
  26796. +#define PCI_VENDOR_ID_IDT 0x111d
  26797. +#define PCI_DEVICE_ID_IDT_IDT77201 0x0001
  26798. +
  26799. +#define PCI_VENDOR_ID_FORE 0x1127
  26800. +#define PCI_DEVICE_ID_FORE_PCA200PC 0x0210
  26801. +#define PCI_DEVICE_ID_FORE_PCA200E 0x0300
  26802. +
  26803. +#define PCI_VENDOR_ID_IMAGINGTECH 0x112f
  26804. +#define PCI_DEVICE_ID_IMAGINGTECH_ICPCI 0x0000
  26805. +
  26806. +#define PCI_VENDOR_ID_PHILIPS 0x1131
  26807. +#define PCI_DEVICE_ID_PHILIPS_SAA7145 0x7145
  26808. +#define PCI_DEVICE_ID_PHILIPS_SAA7146 0x7146
  26809. +#define PCI_DEVICE_ID_PHILIPS_SAA9730 0x9730
  26810. +
  26811. +#define PCI_VENDOR_ID_EICON 0x1133
  26812. +#define PCI_DEVICE_ID_EICON_DIVA20PRO 0xe001
  26813. +#define PCI_DEVICE_ID_EICON_DIVA20 0xe002
  26814. +#define PCI_DEVICE_ID_EICON_DIVA20PRO_U 0xe003
  26815. +#define PCI_DEVICE_ID_EICON_DIVA20_U 0xe004
  26816. +#define PCI_DEVICE_ID_EICON_DIVA201 0xe005
  26817. +#define PCI_DEVICE_ID_EICON_MAESTRA 0xe010
  26818. +#define PCI_DEVICE_ID_EICON_MAESTRAQ 0xe012
  26819. +#define PCI_DEVICE_ID_EICON_MAESTRAQ_U 0xe013
  26820. +#define PCI_DEVICE_ID_EICON_MAESTRAP 0xe014
  26821. +
  26822. +#define PCI_VENDOR_ID_CYCLONE 0x113c
  26823. +#define PCI_DEVICE_ID_CYCLONE_SDK 0x0001
  26824. +
  26825. +#define PCI_VENDOR_ID_ALLIANCE 0x1142
  26826. +#define PCI_DEVICE_ID_ALLIANCE_PROMOTIO 0x3210
  26827. +#define PCI_DEVICE_ID_ALLIANCE_PROVIDEO 0x6422
  26828. +#define PCI_DEVICE_ID_ALLIANCE_AT24 0x6424
  26829. +#define PCI_DEVICE_ID_ALLIANCE_AT3D 0x643d
  26830. +
  26831. +#define PCI_VENDOR_ID_SYSKONNECT 0x1148
  26832. +#define PCI_DEVICE_ID_SYSKONNECT_FP 0x4000
  26833. +#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200
  26834. +#define PCI_DEVICE_ID_SYSKONNECT_GE 0x4300
  26835. +
  26836. +#define PCI_VENDOR_ID_VMIC 0x114a
  26837. +#define PCI_DEVICE_ID_VMIC_VME 0x7587
  26838. +
  26839. +#define PCI_VENDOR_ID_DIGI 0x114f
  26840. +#define PCI_DEVICE_ID_DIGI_EPC 0x0002
  26841. +#define PCI_DEVICE_ID_DIGI_RIGHTSWITCH 0x0003
  26842. +#define PCI_DEVICE_ID_DIGI_XEM 0x0004
  26843. +#define PCI_DEVICE_ID_DIGI_XR 0x0005
  26844. +#define PCI_DEVICE_ID_DIGI_CX 0x0006
  26845. +#define PCI_DEVICE_ID_DIGI_XRJ 0x0009
  26846. +#define PCI_DEVICE_ID_DIGI_EPCJ 0x000a
  26847. +#define PCI_DEVICE_ID_DIGI_XR_920 0x0027
  26848. +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_E 0x0070
  26849. +#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071
  26850. +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072
  26851. +#define PCI_DEVICE_ID_DIGI_DF_M_A 0x0073
  26852. +
  26853. +#define PCI_VENDOR_ID_MUTECH 0x1159
  26854. +#define PCI_DEVICE_ID_MUTECH_MV1000 0x0001
  26855. +
  26856. +#define PCI_VENDOR_ID_XIRCOM 0x115d
  26857. +#define PCI_DEVICE_ID_XIRCOM_X3201_ETH 0x0003
  26858. +#define PCI_DEVICE_ID_XIRCOM_X3201_MDM 0x0103
  26859. +
  26860. +#define PCI_VENDOR_ID_RENDITION 0x1163
  26861. +#define PCI_DEVICE_ID_RENDITION_VERITE 0x0001
  26862. +#define PCI_DEVICE_ID_RENDITION_VERITE2100 0x2000
  26863. +
  26864. +#define PCI_VENDOR_ID_SERVERWORKS 0x1166
  26865. +#define PCI_DEVICE_ID_SERVERWORKS_HE 0x0008
  26866. +#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009
  26867. +#define PCI_DEVICE_ID_SERVERWORKS_CIOB30 0x0010
  26868. +#define PCI_DEVICE_ID_SERVERWORKS_CMIC_HE 0x0011
  26869. +#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200
  26870. +#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201
  26871. +#define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211
  26872. +#define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212
  26873. +#define PCI_DEVICE_ID_SERVERWORKS_OSB4USB 0x0220
  26874. +#define PCI_DEVICE_ID_SERVERWORKS_CSB5USB PCI_DEVICE_ID_SERVERWORKS_OSB4USB
  26875. +#define PCI_DEVICE_ID_SERVERWORKS_CSB5ISA 0x0230
  26876. +
  26877. +#define PCI_VENDOR_ID_SBE 0x1176
  26878. +#define PCI_DEVICE_ID_SBE_WANXL100 0x0301
  26879. +#define PCI_DEVICE_ID_SBE_WANXL200 0x0302
  26880. +#define PCI_DEVICE_ID_SBE_WANXL400 0x0104
  26881. +
  26882. +#define PCI_VENDOR_ID_TOSHIBA 0x1179
  26883. +#define PCI_DEVICE_ID_TOSHIBA_601 0x0601
  26884. +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95 0x060a
  26885. +#define PCI_DEVICE_ID_TOSHIBA_TOPIC97 0x060f
  26886. +
  26887. +#define PCI_VENDOR_ID_RICOH 0x1180
  26888. +#define PCI_DEVICE_ID_RICOH_RL5C465 0x0465
  26889. +#define PCI_DEVICE_ID_RICOH_RL5C466 0x0466
  26890. +#define PCI_DEVICE_ID_RICOH_RL5C475 0x0475
  26891. +#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476
  26892. +#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478
  26893. +
  26894. +#define PCI_VENDOR_ID_DLINK 0x1186
  26895. +#define PCI_DEVICE_ID_DFE530TXP 0x1300
  26896. +#define PCI_DEVICE_ID_DFE530TXS 0x1002
  26897. +
  26898. +#define PCI_VENDOR_ID_ARTOP 0x1191
  26899. +#define PCI_DEVICE_ID_ARTOP_ATP8400 0x0004
  26900. +#define PCI_DEVICE_ID_ARTOP_ATP850UF 0x0005
  26901. +#define PCI_DEVICE_ID_ARTOP_ATP860 0x0006
  26902. +#define PCI_DEVICE_ID_ARTOP_ATP860R 0x0007
  26903. +#define PCI_DEVICE_ID_ARTOP_AEC7610 0x8002
  26904. +#define PCI_DEVICE_ID_ARTOP_AEC7612UW 0x8010
  26905. +#define PCI_DEVICE_ID_ARTOP_AEC7612U 0x8020
  26906. +#define PCI_DEVICE_ID_ARTOP_AEC7612S 0x8030
  26907. +#define PCI_DEVICE_ID_ARTOP_AEC7612D 0x8040
  26908. +#define PCI_DEVICE_ID_ARTOP_AEC7612SUW 0x8050
  26909. +#define PCI_DEVICE_ID_ARTOP_8060 0x8060
  26910. +
  26911. +#define PCI_VENDOR_ID_ZEITNET 0x1193
  26912. +#define PCI_DEVICE_ID_ZEITNET_1221 0x0001
  26913. +#define PCI_DEVICE_ID_ZEITNET_1225 0x0002
  26914. +
  26915. +#define PCI_VENDOR_ID_OMEGA 0x119b
  26916. +#define PCI_DEVICE_ID_OMEGA_82C092G 0x1221
  26917. +
  26918. +#define PCI_VENDOR_ID_FUJITSU_ME 0x119e
  26919. +#define PCI_DEVICE_ID_FUJITSU_FS155 0x0001
  26920. +#define PCI_DEVICE_ID_FUJITSU_FS50 0x0003
  26921. +
  26922. +#define PCI_SUBVENDOR_ID_KEYSPAN 0x11a9
  26923. +#define PCI_SUBDEVICE_ID_KEYSPAN_SX2 0x5334
  26924. +
  26925. +#define PCI_VENDOR_ID_GALILEO 0x11ab
  26926. +#define PCI_DEVICE_ID_GALILEO_GT64011 0x4146
  26927. +#define PCI_DEVICE_ID_GALILEO_GT64111 0x4146
  26928. +#define PCI_DEVICE_ID_GALILEO_GT96100 0x9652
  26929. +#define PCI_DEVICE_ID_GALILEO_GT96100A 0x9653
  26930. +
  26931. +#define PCI_VENDOR_ID_LINKSYS 0x11ad
  26932. +#define PCI_VENDOR_ID_LITEON 0x11ad
  26933. +#define PCI_DEVICE_ID_LITEON_LNE100TX 0x0002
  26934. +#define PCI_DEVICE_ID_LC82C115 0xC115
  26935. +
  26936. +#define PCI_VENDOR_ID_V3 0x11b0
  26937. +#define PCI_DEVICE_ID_V3_V960 0x0001
  26938. +#define PCI_DEVICE_ID_V3_V350 0x0001
  26939. +#define PCI_DEVICE_ID_V3_V961 0x0002
  26940. +#define PCI_DEVICE_ID_V3_V351 0x0002
  26941. +
  26942. +#define PCI_VENDOR_ID_NP 0x11bc
  26943. +#define PCI_DEVICE_ID_NP_PCI_FDDI 0x0001
  26944. +
  26945. +#define PCI_VENDOR_ID_ATT 0x11c1
  26946. +#define PCI_DEVICE_ID_ATT_L56XMF 0x0440
  26947. +#define PCI_DEVICE_ID_ATT_VENUS_MODEM 0x480
  26948. +
  26949. +#define PCI_VENDOR_ID_SPECIALIX 0x11cb
  26950. +#define PCI_DEVICE_ID_SPECIALIX_IO8 0x2000
  26951. +#define PCI_DEVICE_ID_SPECIALIX_XIO 0x4000
  26952. +#define PCI_DEVICE_ID_SPECIALIX_RIO 0x8000
  26953. +#define PCI_SUBDEVICE_ID_SPECIALIX_SPEED4 0xa004
  26954. +
  26955. +#define PCI_VENDOR_ID_AURAVISION 0x11d1
  26956. +#define PCI_DEVICE_ID_AURAVISION_VXP524 0x01f7
  26957. +
  26958. +#define PCI_VENDOR_ID_ANALOG_DEVICES 0x11d4
  26959. +#define PCI_DEVICE_ID_AD1889JS 0x1889
  26960. +
  26961. +#define PCI_VENDOR_ID_IKON 0x11d5
  26962. +#define PCI_DEVICE_ID_IKON_10115 0x0115
  26963. +#define PCI_DEVICE_ID_IKON_10117 0x0117
  26964. +
  26965. +#define PCI_VENDOR_ID_ZORAN 0x11de
  26966. +#define PCI_DEVICE_ID_ZORAN_36057 0x6057
  26967. +#define PCI_DEVICE_ID_ZORAN_36120 0x6120
  26968. +
  26969. +#define PCI_VENDOR_ID_KINETIC 0x11f4
  26970. +#define PCI_DEVICE_ID_KINETIC_2915 0x2915
  26971. +
  26972. +#define PCI_VENDOR_ID_COMPEX 0x11f6
  26973. +#define PCI_DEVICE_ID_COMPEX_ENET100VG4 0x0112
  26974. +#define PCI_DEVICE_ID_COMPEX_RL2000 0x1401
  26975. +#define PCI_DEVICE_ID_COMPEX_RL100ATX 0x2011
  26976. +
  26977. +#define PCI_VENDOR_ID_RP 0x11fe
  26978. +#define PCI_DEVICE_ID_RP32INTF 0x0001
  26979. +#define PCI_DEVICE_ID_RP8INTF 0x0002
  26980. +#define PCI_DEVICE_ID_RP16INTF 0x0003
  26981. +#define PCI_DEVICE_ID_RP4QUAD 0x0004
  26982. +#define PCI_DEVICE_ID_RP8OCTA 0x0005
  26983. +#define PCI_DEVICE_ID_RP8J 0x0006
  26984. +#define PCI_DEVICE_ID_RPP4 0x000A
  26985. +#define PCI_DEVICE_ID_RPP8 0x000B
  26986. +#define PCI_DEVICE_ID_RP8M 0x000C
  26987. +
  26988. +#define PCI_VENDOR_ID_CYCLADES 0x120e
  26989. +#define PCI_DEVICE_ID_CYCLOM_Y_Lo 0x0100
  26990. +#define PCI_DEVICE_ID_CYCLOM_Y_Hi 0x0101
  26991. +#define PCI_DEVICE_ID_CYCLOM_4Y_Lo 0x0102
  26992. +#define PCI_DEVICE_ID_CYCLOM_4Y_Hi 0x0103
  26993. +#define PCI_DEVICE_ID_CYCLOM_8Y_Lo 0x0104
  26994. +#define PCI_DEVICE_ID_CYCLOM_8Y_Hi 0x0105
  26995. +#define PCI_DEVICE_ID_CYCLOM_Z_Lo 0x0200
  26996. +#define PCI_DEVICE_ID_CYCLOM_Z_Hi 0x0201
  26997. +#define PCI_DEVICE_ID_PC300_RX_2 0x0300
  26998. +#define PCI_DEVICE_ID_PC300_RX_1 0x0301
  26999. +#define PCI_DEVICE_ID_PC300_TE_2 0x0310
  27000. +#define PCI_DEVICE_ID_PC300_TE_1 0x0311
  27001. +
  27002. +#define PCI_VENDOR_ID_ESSENTIAL 0x120f
  27003. +#define PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER 0x0001
  27004. +
  27005. +#define PCI_VENDOR_ID_O2 0x1217
  27006. +#define PCI_DEVICE_ID_O2_6729 0x6729
  27007. +#define PCI_DEVICE_ID_O2_6730 0x673a
  27008. +#define PCI_DEVICE_ID_O2_6832 0x6832
  27009. +#define PCI_DEVICE_ID_O2_6836 0x6836
  27010. +
  27011. +#define PCI_VENDOR_ID_3DFX 0x121a
  27012. +#define PCI_DEVICE_ID_3DFX_VOODOO 0x0001
  27013. +#define PCI_DEVICE_ID_3DFX_VOODOO2 0x0002
  27014. +#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003
  27015. +#define PCI_DEVICE_ID_3DFX_VOODOO3 0x0005
  27016. +
  27017. +#define PCI_VENDOR_ID_SIGMADES 0x1236
  27018. +#define PCI_DEVICE_ID_SIGMADES_6425 0x6401
  27019. +
  27020. +#define PCI_VENDOR_ID_CCUBE 0x123f
  27021. +
  27022. +#define PCI_VENDOR_ID_AVM 0x1244
  27023. +#define PCI_DEVICE_ID_AVM_B1 0x0700
  27024. +#define PCI_DEVICE_ID_AVM_C4 0x0800
  27025. +#define PCI_DEVICE_ID_AVM_A1 0x0a00
  27026. +#define PCI_DEVICE_ID_AVM_A1_V2 0x0e00
  27027. +#define PCI_DEVICE_ID_AVM_C2 0x1100
  27028. +#define PCI_DEVICE_ID_AVM_T1 0x1200
  27029. +
  27030. +#define PCI_VENDOR_ID_DIPIX 0x1246
  27031. +
  27032. +#define PCI_VENDOR_ID_STALLION 0x124d
  27033. +#define PCI_DEVICE_ID_STALLION_ECHPCI832 0x0000
  27034. +#define PCI_DEVICE_ID_STALLION_ECHPCI864 0x0002
  27035. +#define PCI_DEVICE_ID_STALLION_EIOPCI 0x0003
  27036. +
  27037. +#define PCI_VENDOR_ID_OPTIBASE 0x1255
  27038. +#define PCI_DEVICE_ID_OPTIBASE_FORGE 0x1110
  27039. +#define PCI_DEVICE_ID_OPTIBASE_FUSION 0x1210
  27040. +#define PCI_DEVICE_ID_OPTIBASE_VPLEX 0x2110
  27041. +#define PCI_DEVICE_ID_OPTIBASE_VPLEXCC 0x2120
  27042. +#define PCI_DEVICE_ID_OPTIBASE_VQUEST 0x2130
  27043. +
  27044. +#define PCI_VENDOR_ID_ESS 0x125d
  27045. +#define PCI_DEVICE_ID_ESS_ESS1968 0x1968
  27046. +#define PCI_DEVICE_ID_ESS_AUDIOPCI 0x1969
  27047. +#define PCI_DEVICE_ID_ESS_ESS1978 0x1978
  27048. +
  27049. +#define PCI_VENDOR_ID_HARRIS 0x1260
  27050. +#define PCI_DEVICE_ID_HARRIS_PRISM2 0x3873
  27051. +
  27052. +#define PCI_VENDOR_ID_SATSAGEM 0x1267
  27053. +#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016
  27054. +#define PCI_DEVICE_ID_SATSAGEM_PCR2101 0x5352
  27055. +#define PCI_DEVICE_ID_SATSAGEM_TELSATTURBO 0x5a4b
  27056. +
  27057. +#define PCI_VENDOR_ID_HUGHES 0x1273
  27058. +#define PCI_DEVICE_ID_HUGHES_DIRECPC 0x0002
  27059. +
  27060. +#define PCI_VENDOR_ID_ENSONIQ 0x1274
  27061. +#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880
  27062. +#define PCI_DEVICE_ID_ENSONIQ_ES1370 0x5000
  27063. +#define PCI_DEVICE_ID_ENSONIQ_ES1371 0x1371
  27064. +
  27065. +#define PCI_VENDOR_ID_ROCKWELL 0x127A
  27066. +
  27067. +#define PCI_VENDOR_ID_DAVICOM 0x1282
  27068. +#define PCI_DEVICE_ID_DM9009 0x9009
  27069. +#define PCI_DEVICE_ID_DM9102 0x9102
  27070. +
  27071. +#define PCI_VENDOR_ID_ITE 0x1283
  27072. +#define PCI_DEVICE_ID_ITE_IT8172G_AUDIO 0x0801
  27073. +#define PCI_DEVICE_ID_ITE_IT8172G 0x8172
  27074. +#define PCI_DEVICE_ID_ITE_8872 0x8872
  27075. +
  27076. +
  27077. +/* formerly Platform Tech */
  27078. +#define PCI_VENDOR_ID_ESS_OLD 0x1285
  27079. +#define PCI_DEVICE_ID_ESS_ESS0100 0x0100
  27080. +
  27081. +#define PCI_VENDOR_ID_ALTEON 0x12ae
  27082. +#define PCI_DEVICE_ID_ALTEON_ACENIC 0x0001
  27083. +
  27084. +#define PCI_VENDOR_ID_USR 0x12B9
  27085. +
  27086. +#define PCI_VENDOR_ID_HOLTEK 0x12c3
  27087. +#define PCI_DEVICE_ID_HOLTEK_HT80232 0x0058
  27088. +
  27089. +#define PCI_SUBVENDOR_ID_CONNECT_TECH 0x12c4
  27090. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232 0x0001
  27091. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_232 0x0002
  27092. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_232 0x0003
  27093. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485 0x0004
  27094. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_4_4 0x0005
  27095. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485 0x0006
  27096. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485_2_2 0x0007
  27097. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_485 0x0008
  27098. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_2_6 0x0009
  27099. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH081101V1 0x000A
  27100. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1 0x000B
  27101. +
  27102. +#define PCI_VENDOR_ID_PICTUREL 0x12c5
  27103. +#define PCI_DEVICE_ID_PICTUREL_PCIVST 0x0081
  27104. +
  27105. +#define PCI_VENDOR_ID_NVIDIA_SGS 0x12d2
  27106. +#define PCI_DEVICE_ID_NVIDIA_SGS_RIVA128 0x0018
  27107. +
  27108. +#define PCI_SUBVENDOR_ID_CHASE_PCIFAST 0x12E0
  27109. +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST4 0x0031
  27110. +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST8 0x0021
  27111. +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16 0x0011
  27112. +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16FMC 0x0041
  27113. +#define PCI_SUBVENDOR_ID_CHASE_PCIRAS 0x124D
  27114. +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS4 0xF001
  27115. +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS8 0xF010
  27116. +
  27117. +#define PCI_VENDOR_ID_AUREAL 0x12eb
  27118. +#define PCI_DEVICE_ID_AUREAL_VORTEX_1 0x0001
  27119. +#define PCI_DEVICE_ID_AUREAL_VORTEX_2 0x0002
  27120. +
  27121. +#define PCI_VENDOR_ID_CBOARDS 0x1307
  27122. +#define PCI_DEVICE_ID_CBOARDS_DAS1602_16 0x0001
  27123. +
  27124. +#define PCI_VENDOR_ID_SIIG 0x131f
  27125. +#define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000
  27126. +#define PCI_DEVICE_ID_SIIG_1S_10x_650 0x1001
  27127. +#define PCI_DEVICE_ID_SIIG_1S_10x_850 0x1002
  27128. +#define PCI_DEVICE_ID_SIIG_1S1P_10x_550 0x1010
  27129. +#define PCI_DEVICE_ID_SIIG_1S1P_10x_650 0x1011
  27130. +#define PCI_DEVICE_ID_SIIG_1S1P_10x_850 0x1012
  27131. +#define PCI_DEVICE_ID_SIIG_1P_10x 0x1020
  27132. +#define PCI_DEVICE_ID_SIIG_2P_10x 0x1021
  27133. +#define PCI_DEVICE_ID_SIIG_2S_10x_550 0x1030
  27134. +#define PCI_DEVICE_ID_SIIG_2S_10x_650 0x1031
  27135. +#define PCI_DEVICE_ID_SIIG_2S_10x_850 0x1032
  27136. +#define PCI_DEVICE_ID_SIIG_2S1P_10x_550 0x1034
  27137. +#define PCI_DEVICE_ID_SIIG_2S1P_10x_650 0x1035
  27138. +#define PCI_DEVICE_ID_SIIG_2S1P_10x_850 0x1036
  27139. +#define PCI_DEVICE_ID_SIIG_4S_10x_550 0x1050
  27140. +#define PCI_DEVICE_ID_SIIG_4S_10x_650 0x1051
  27141. +#define PCI_DEVICE_ID_SIIG_4S_10x_850 0x1052
  27142. +#define PCI_DEVICE_ID_SIIG_1S_20x_550 0x2000
  27143. +#define PCI_DEVICE_ID_SIIG_1S_20x_650 0x2001
  27144. +#define PCI_DEVICE_ID_SIIG_1S_20x_850 0x2002
  27145. +#define PCI_DEVICE_ID_SIIG_1P_20x 0x2020
  27146. +#define PCI_DEVICE_ID_SIIG_2P_20x 0x2021
  27147. +#define PCI_DEVICE_ID_SIIG_2S_20x_550 0x2030
  27148. +#define PCI_DEVICE_ID_SIIG_2S_20x_650 0x2031
  27149. +#define PCI_DEVICE_ID_SIIG_2S_20x_850 0x2032
  27150. +#define PCI_DEVICE_ID_SIIG_2P1S_20x_550 0x2040
  27151. +#define PCI_DEVICE_ID_SIIG_2P1S_20x_650 0x2041
  27152. +#define PCI_DEVICE_ID_SIIG_2P1S_20x_850 0x2042
  27153. +#define PCI_DEVICE_ID_SIIG_1S1P_20x_550 0x2010
  27154. +#define PCI_DEVICE_ID_SIIG_1S1P_20x_650 0x2011
  27155. +#define PCI_DEVICE_ID_SIIG_1S1P_20x_850 0x2012
  27156. +#define PCI_DEVICE_ID_SIIG_4S_20x_550 0x2050
  27157. +#define PCI_DEVICE_ID_SIIG_4S_20x_650 0x2051
  27158. +#define PCI_DEVICE_ID_SIIG_4S_20x_850 0x2052
  27159. +#define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060
  27160. +#define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061
  27161. +#define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062
  27162. +
  27163. +#define PCI_VENDOR_ID_ADMTEK 0x1317
  27164. +#define PCI_DEVICE_ID_ADMTEK_0985 0x0985
  27165. +
  27166. +#define PCI_VENDOR_ID_DOMEX 0x134a
  27167. +#define PCI_DEVICE_ID_DOMEX_DMX3191D 0x0001
  27168. +
  27169. +#define PCI_VENDOR_ID_QUATECH 0x135C
  27170. +#define PCI_DEVICE_ID_QUATECH_QSC100 0x0010
  27171. +#define PCI_DEVICE_ID_QUATECH_DSC100 0x0020
  27172. +#define PCI_DEVICE_ID_QUATECH_DSC200 0x0030
  27173. +#define PCI_DEVICE_ID_QUATECH_QSC200 0x0040
  27174. +#define PCI_DEVICE_ID_QUATECH_ESC100D 0x0050
  27175. +#define PCI_DEVICE_ID_QUATECH_ESC100M 0x0060
  27176. +
  27177. +#define PCI_VENDOR_ID_SEALEVEL 0x135e
  27178. +#define PCI_DEVICE_ID_SEALEVEL_U530 0x7101
  27179. +#define PCI_DEVICE_ID_SEALEVEL_UCOMM2 0x7201
  27180. +#define PCI_DEVICE_ID_SEALEVEL_UCOMM422 0x7402
  27181. +#define PCI_DEVICE_ID_SEALEVEL_UCOMM232 0x7202
  27182. +#define PCI_DEVICE_ID_SEALEVEL_COMM4 0x7401
  27183. +#define PCI_DEVICE_ID_SEALEVEL_COMM8 0x7801
  27184. +
  27185. +#define PCI_VENDOR_ID_HYPERCOPE 0x1365
  27186. +#define PCI_DEVICE_ID_HYPERCOPE_PLX 0x9050
  27187. +#define PCI_SUBDEVICE_ID_HYPERCOPE_OLD_ERGO 0x0104
  27188. +#define PCI_SUBDEVICE_ID_HYPERCOPE_ERGO 0x0106
  27189. +#define PCI_SUBDEVICE_ID_HYPERCOPE_METRO 0x0107
  27190. +#define PCI_SUBDEVICE_ID_HYPERCOPE_CHAMP2 0x0108
  27191. +#define PCI_SUBDEVICE_ID_HYPERCOPE_PLEXUS 0x0109
  27192. +
  27193. +#define PCI_VENDOR_ID_KAWASAKI 0x136b
  27194. +#define PCI_DEVICE_ID_MCHIP_KL5A72002 0xff01
  27195. +
  27196. +#define PCI_VENDOR_ID_LMC 0x1376
  27197. +#define PCI_DEVICE_ID_LMC_HSSI 0x0003
  27198. +#define PCI_DEVICE_ID_LMC_DS3 0x0004
  27199. +#define PCI_DEVICE_ID_LMC_SSI 0x0005
  27200. +#define PCI_DEVICE_ID_LMC_T1 0x0006
  27201. +
  27202. +#define PCI_VENDOR_ID_NETGEAR 0x1385
  27203. +#define PCI_DEVICE_ID_NETGEAR_MA301 0x4100
  27204. +#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a
  27205. +#define PCI_DEVICE_ID_NETGEAR_GA622 0x622a
  27206. +
  27207. +#define PCI_VENDOR_ID_APPLICOM 0x1389
  27208. +#define PCI_DEVICE_ID_APPLICOM_PCIGENERIC 0x0001
  27209. +#define PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN 0x0002
  27210. +#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003
  27211. +
  27212. +#define PCI_VENDOR_ID_MOXA 0x1393
  27213. +#define PCI_DEVICE_ID_MOXA_C104 0x1040
  27214. +#define PCI_DEVICE_ID_MOXA_C168 0x1680
  27215. +#define PCI_DEVICE_ID_MOXA_CP204J 0x2040
  27216. +#define PCI_DEVICE_ID_MOXA_C218 0x2180
  27217. +#define PCI_DEVICE_ID_MOXA_C320 0x3200
  27218. +
  27219. +#define PCI_VENDOR_ID_CCD 0x1397
  27220. +#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0
  27221. +#define PCI_DEVICE_ID_CCD_B000 0xb000
  27222. +#define PCI_DEVICE_ID_CCD_B006 0xb006
  27223. +#define PCI_DEVICE_ID_CCD_B007 0xb007
  27224. +#define PCI_DEVICE_ID_CCD_B008 0xb008
  27225. +#define PCI_DEVICE_ID_CCD_B009 0xb009
  27226. +#define PCI_DEVICE_ID_CCD_B00A 0xb00a
  27227. +#define PCI_DEVICE_ID_CCD_B00B 0xb00b
  27228. +#define PCI_DEVICE_ID_CCD_B00C 0xb00c
  27229. +#define PCI_DEVICE_ID_CCD_B100 0xb100
  27230. +
  27231. +#define PCI_VENDOR_ID_MICROGATE 0x13c0
  27232. +#define PCI_DEVICE_ID_MICROGATE_USC 0x0010
  27233. +#define PCI_DEVICE_ID_MICROGATE_SCC 0x0020
  27234. +#define PCI_DEVICE_ID_MICROGATE_SCA 0x0030
  27235. +
  27236. +#define PCI_VENDOR_ID_3WARE 0x13C1
  27237. +#define PCI_DEVICE_ID_3WARE_1000 0x1000
  27238. +
  27239. +#define PCI_VENDOR_ID_ABOCOM 0x13D1
  27240. +#define PCI_DEVICE_ID_ABOCOM_2BD1 0x2BD1
  27241. +
  27242. +#define PCI_VENDOR_ID_CMEDIA 0x13f6
  27243. +#define PCI_DEVICE_ID_CMEDIA_CM8338A 0x0100
  27244. +#define PCI_DEVICE_ID_CMEDIA_CM8338B 0x0101
  27245. +#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111
  27246. +#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112
  27247. +
  27248. +#define PCI_VENDOR_ID_LAVA 0x1407
  27249. +#define PCI_DEVICE_ID_LAVA_DSERIAL 0x0100 /* 2x 16550 */
  27250. +#define PCI_DEVICE_ID_LAVA_QUATRO_A 0x0101 /* 2x 16550, half of 4 port */
  27251. +#define PCI_DEVICE_ID_LAVA_QUATRO_B 0x0102 /* 2x 16550, half of 4 port */
  27252. +#define PCI_DEVICE_ID_LAVA_PORT_PLUS 0x0200 /* 2x 16650 */
  27253. +#define PCI_DEVICE_ID_LAVA_QUAD_A 0x0201 /* 2x 16650, half of 4 port */
  27254. +#define PCI_DEVICE_ID_LAVA_QUAD_B 0x0202 /* 2x 16650, half of 4 port */
  27255. +#define PCI_DEVICE_ID_LAVA_SSERIAL 0x0500 /* 1x 16550 */
  27256. +#define PCI_DEVICE_ID_LAVA_PORT_650 0x0600 /* 1x 16650 */
  27257. +#define PCI_DEVICE_ID_LAVA_PARALLEL 0x8000
  27258. +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_A 0x8002 /* The Lava Dual Parallel is */
  27259. +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_B 0x8003 /* two PCI devices on a card */
  27260. +#define PCI_DEVICE_ID_LAVA_BOCA_IOPPAR 0x8800
  27261. +
  27262. +#define PCI_VENDOR_ID_TIMEDIA 0x1409
  27263. +#define PCI_DEVICE_ID_TIMEDIA_1889 0x7168
  27264. +
  27265. +#define PCI_VENDOR_ID_OXSEMI 0x1415
  27266. +#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403
  27267. +#define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501
  27268. +#define PCI_DEVICE_ID_OXSEMI_16PCI952 0x950A
  27269. +#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511
  27270. +#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513
  27271. +
  27272. +#define PCI_VENDOR_ID_AIRONET 0x14b9
  27273. +#define PCI_DEVICE_ID_AIRONET_4800_1 0x0001
  27274. +#define PCI_DEVICE_ID_AIRONET_4800 0x4500 // values switched? see
  27275. +#define PCI_DEVICE_ID_AIRONET_4500 0x4800 // drivers/net/aironet4500_card.c
  27276. +
  27277. +#define PCI_VENDOR_ID_TITAN 0x14D2
  27278. +#define PCI_DEVICE_ID_TITAN_010L 0x8001
  27279. +#define PCI_DEVICE_ID_TITAN_100L 0x8010
  27280. +#define PCI_DEVICE_ID_TITAN_110L 0x8011
  27281. +#define PCI_DEVICE_ID_TITAN_200L 0x8020
  27282. +#define PCI_DEVICE_ID_TITAN_210L 0x8021
  27283. +#define PCI_DEVICE_ID_TITAN_400L 0x8040
  27284. +#define PCI_DEVICE_ID_TITAN_800L 0x8080
  27285. +#define PCI_DEVICE_ID_TITAN_100 0xA001
  27286. +#define PCI_DEVICE_ID_TITAN_200 0xA005
  27287. +#define PCI_DEVICE_ID_TITAN_400 0xA003
  27288. +#define PCI_DEVICE_ID_TITAN_800B 0xA004
  27289. +
  27290. +#define PCI_VENDOR_ID_PANACOM 0x14d4
  27291. +#define PCI_DEVICE_ID_PANACOM_QUADMODEM 0x0400
  27292. +#define PCI_DEVICE_ID_PANACOM_DUALMODEM 0x0402
  27293. +
  27294. +#define PCI_VENDOR_ID_BROADCOM 0x14e4
  27295. +#define PCI_DEVICE_ID_TIGON3_5700 0x1644
  27296. +#define PCI_DEVICE_ID_TIGON3_5701 0x1645
  27297. +#define PCI_DEVICE_ID_TIGON3_5702 0x1646
  27298. +#define PCI_DEVICE_ID_TIGON3_5703 0x1647
  27299. +#define PCI_DEVICE_ID_TIGON3_5704 0x1648
  27300. +#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d
  27301. +#define PCI_DEVICE_ID_TIGON3_5705 0x1653
  27302. +#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654
  27303. +#define PCI_DEVICE_ID_TIGON3_5705M 0x165d
  27304. +#define PCI_DEVICE_ID_TIGON3_5705M_2 0x165e
  27305. +#define PCI_DEVICE_ID_TIGON3_5782 0x1696
  27306. +#define PCI_DEVICE_ID_TIGON3_5788 0x169c
  27307. +#define PCI_DEVICE_ID_TIGON3_5702X 0x16a6
  27308. +#define PCI_DEVICE_ID_TIGON3_5703X 0x16a7
  27309. +#define PCI_DEVICE_ID_TIGON3_5704S 0x16a8
  27310. +#define PCI_DEVICE_ID_TIGON3_5702A3 0x16c6
  27311. +#define PCI_DEVICE_ID_TIGON3_5703A3 0x16c7
  27312. +#define PCI_DEVICE_ID_TIGON3_5901 0x170d
  27313. +#define PCI_DEVICE_ID_TIGON3_5901_2 0x170e
  27314. +
  27315. +#define PCI_VENDOR_ID_SYBA 0x1592
  27316. +#define PCI_DEVICE_ID_SYBA_2P_EPP 0x0782
  27317. +#define PCI_DEVICE_ID_SYBA_1P_ECP 0x0783
  27318. +
  27319. +#define PCI_VENDOR_ID_MORETON 0x15aa
  27320. +#define PCI_DEVICE_ID_RASTEL_2PORT 0x2000
  27321. +
  27322. +#define PCI_VENDOR_ID_ZOLTRIX 0x15b0
  27323. +#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0
  27324. +
  27325. +#define PCI_VENDOR_ID_PDC 0x15e9
  27326. +#define PCI_DEVICE_ID_PDC_1841 0x1841
  27327. +
  27328. +#define PCI_VENDOR_ID_SYMPHONY 0x1c1c
  27329. +#define PCI_DEVICE_ID_SYMPHONY_101 0x0001
  27330. +
  27331. +#define PCI_VENDOR_ID_TEKRAM 0x1de1
  27332. +#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29
  27333. +
  27334. +#define PCI_VENDOR_ID_3DLABS 0x3d3d
  27335. +#define PCI_DEVICE_ID_3DLABS_300SX 0x0001
  27336. +#define PCI_DEVICE_ID_3DLABS_500TX 0x0002
  27337. +#define PCI_DEVICE_ID_3DLABS_DELTA 0x0003
  27338. +#define PCI_DEVICE_ID_3DLABS_PERMEDIA 0x0004
  27339. +#define PCI_DEVICE_ID_3DLABS_MX 0x0006
  27340. +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2 0x0007
  27341. +#define PCI_DEVICE_ID_3DLABS_GAMMA 0x0008
  27342. +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2V 0x0009
  27343. +
  27344. +#define PCI_VENDOR_ID_AVANCE 0x4005
  27345. +#define PCI_DEVICE_ID_AVANCE_ALG2064 0x2064
  27346. +#define PCI_DEVICE_ID_AVANCE_2302 0x2302
  27347. +
  27348. +#define PCI_VENDOR_ID_AKS 0x416c
  27349. +#define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100
  27350. +#define PCI_DEVICE_ID_AKS_CPC 0x0200
  27351. +
  27352. +#define PCI_VENDOR_ID_NETVIN 0x4a14
  27353. +#define PCI_DEVICE_ID_NETVIN_NV5000SC 0x5000
  27354. +
  27355. +#define PCI_VENDOR_ID_S3 0x5333
  27356. +#define PCI_DEVICE_ID_S3_PLATO_PXS 0x0551
  27357. +#define PCI_DEVICE_ID_S3_ViRGE 0x5631
  27358. +#define PCI_DEVICE_ID_S3_TRIO 0x8811
  27359. +#define PCI_DEVICE_ID_S3_AURORA64VP 0x8812
  27360. +#define PCI_DEVICE_ID_S3_TRIO64UVP 0x8814
  27361. +#define PCI_DEVICE_ID_S3_ViRGE_VX 0x883d
  27362. +#define PCI_DEVICE_ID_S3_868 0x8880
  27363. +#define PCI_DEVICE_ID_S3_928 0x88b0
  27364. +#define PCI_DEVICE_ID_S3_864_1 0x88c0
  27365. +#define PCI_DEVICE_ID_S3_864_2 0x88c1
  27366. +#define PCI_DEVICE_ID_S3_964_1 0x88d0
  27367. +#define PCI_DEVICE_ID_S3_964_2 0x88d1
  27368. +#define PCI_DEVICE_ID_S3_968 0x88f0
  27369. +#define PCI_DEVICE_ID_S3_TRIO64V2 0x8901
  27370. +#define PCI_DEVICE_ID_S3_PLATO_PXG 0x8902
  27371. +#define PCI_DEVICE_ID_S3_ViRGE_DXGX 0x8a01
  27372. +#define PCI_DEVICE_ID_S3_ViRGE_GX2 0x8a10
  27373. +#define PCI_DEVICE_ID_S3_ViRGE_MX 0x8c01
  27374. +#define PCI_DEVICE_ID_S3_ViRGE_MXP 0x8c02
  27375. +#define PCI_DEVICE_ID_S3_ViRGE_MXPMV 0x8c03
  27376. +#define PCI_DEVICE_ID_S3_SONICVIBES 0xca00
  27377. +
  27378. +#define PCI_VENDOR_ID_DCI 0x6666
  27379. +#define PCI_DEVICE_ID_DCI_PCCOM4 0x0001
  27380. +#define PCI_DEVICE_ID_DCI_PCCOM8 0x0002
  27381. +
  27382. +#define PCI_VENDOR_ID_GENROCO 0x5555
  27383. +#define PCI_DEVICE_ID_GENROCO_HFP832 0x0003
  27384. +
  27385. +#define PCI_VENDOR_ID_INTEL 0x8086
  27386. +#define PCI_DEVICE_ID_INTEL_21145 0x0039
  27387. +#define PCI_DEVICE_ID_INTEL_82375 0x0482
  27388. +#define PCI_DEVICE_ID_INTEL_82424 0x0483
  27389. +#define PCI_DEVICE_ID_INTEL_82378 0x0484
  27390. +#define PCI_DEVICE_ID_INTEL_82430 0x0486
  27391. +#define PCI_DEVICE_ID_INTEL_82434 0x04a3
  27392. +#define PCI_DEVICE_ID_INTEL_I960 0x0960
  27393. +#define PCI_DEVICE_ID_INTEL_82542 0x1000
  27394. +#define PCI_DEVICE_ID_INTEL_82543GC_FIBER 0x1001
  27395. +#define PCI_DEVICE_ID_INTEL_82543GC_COPPER 0x1004
  27396. +#define PCI_DEVICE_ID_INTEL_82544EI_COPPER 0x1008
  27397. +#define PCI_DEVICE_ID_INTEL_82544EI_FIBER 0x1009
  27398. +#define PCI_DEVICE_ID_INTEL_82544GC_COPPER 0x100C
  27399. +#define PCI_DEVICE_ID_INTEL_82544GC_LOM 0x100D
  27400. +#define PCI_DEVICE_ID_INTEL_82540EM 0x100E
  27401. +#define PCI_DEVICE_ID_INTEL_82545EM_COPPER 0x100F
  27402. +#define PCI_DEVICE_ID_INTEL_82546EB_COPPER 0x1010
  27403. +#define PCI_DEVICE_ID_INTEL_82545EM_FIBER 0x1011
  27404. +#define PCI_DEVICE_ID_INTEL_82546EB_FIBER 0x1012
  27405. +#define PCI_DEVICE_ID_INTEL_82540EM_LOM 0x1015
  27406. +#define PCI_DEVICE_ID_INTEL_ID1029 0x1029
  27407. +#define PCI_DEVICE_ID_INTEL_ID1030 0x1030
  27408. +#define PCI_DEVICE_ID_INTEL_ID1031 0x1031
  27409. +#define PCI_DEVICE_ID_INTEL_ID1038 0x1038
  27410. +#define PCI_DEVICE_ID_INTEL_ID1039 0x1039
  27411. +#define PCI_DEVICE_ID_INTEL_ID103A 0x103A
  27412. +#define PCI_DEVICE_ID_INTEL_82562ET 0x1031
  27413. +#define PCI_DEVICE_ID_INTEL_82559ER 0x1209
  27414. +#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221
  27415. +#define PCI_DEVICE_ID_INTEL_82092AA_1 0x1222
  27416. +#define PCI_DEVICE_ID_INTEL_7116 0x1223
  27417. +#define PCI_DEVICE_ID_INTEL_82596 0x1226
  27418. +#define PCI_DEVICE_ID_INTEL_82865 0x1227
  27419. +#define PCI_DEVICE_ID_INTEL_82557 0x1229
  27420. +#define PCI_DEVICE_ID_INTEL_82437 0x122d
  27421. +#define PCI_DEVICE_ID_INTEL_82371FB_0 0x122e
  27422. +#define PCI_DEVICE_ID_INTEL_82371FB_1 0x1230
  27423. +#define PCI_DEVICE_ID_INTEL_82371MX 0x1234
  27424. +#define PCI_DEVICE_ID_INTEL_82437MX 0x1235
  27425. +#define PCI_DEVICE_ID_INTEL_82441 0x1237
  27426. +#define PCI_DEVICE_ID_INTEL_82380FB 0x124b
  27427. +#define PCI_DEVICE_ID_INTEL_82439 0x1250
  27428. +#define PCI_DEVICE_ID_INTEL_80960_RP 0x1960
  27429. +#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410
  27430. +#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411
  27431. +#define PCI_DEVICE_ID_INTEL_82801AA_2 0x2412
  27432. +#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413
  27433. +#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415
  27434. +#define PCI_DEVICE_ID_INTEL_82801AA_6 0x2416
  27435. +#define PCI_DEVICE_ID_INTEL_82801AA_8 0x2418
  27436. +#define PCI_DEVICE_ID_INTEL_82801AB_0 0x2420
  27437. +#define PCI_DEVICE_ID_INTEL_82801AB_1 0x2421
  27438. +#define PCI_DEVICE_ID_INTEL_82801AB_2 0x2422
  27439. +#define PCI_DEVICE_ID_INTEL_82801AB_3 0x2423
  27440. +#define PCI_DEVICE_ID_INTEL_82801AB_5 0x2425
  27441. +#define PCI_DEVICE_ID_INTEL_82801AB_6 0x2426
  27442. +#define PCI_DEVICE_ID_INTEL_82801AB_8 0x2428
  27443. +#define PCI_DEVICE_ID_INTEL_82801BA_0 0x2440
  27444. +#define PCI_DEVICE_ID_INTEL_82801BA_1 0x2442
  27445. +#define PCI_DEVICE_ID_INTEL_82801BA_2 0x2443
  27446. +#define PCI_DEVICE_ID_INTEL_82801BA_3 0x2444
  27447. +#define PCI_DEVICE_ID_INTEL_82801BA_4 0x2445
  27448. +#define PCI_DEVICE_ID_INTEL_82801BA_5 0x2446
  27449. +#define PCI_DEVICE_ID_INTEL_82801BA_6 0x2448
  27450. +#define PCI_DEVICE_ID_INTEL_82801BA_7 0x2449
  27451. +#define PCI_DEVICE_ID_INTEL_82562 0x2449
  27452. +#define PCI_DEVICE_ID_INTEL_82801BA_8 0x244a
  27453. +#define PCI_DEVICE_ID_INTEL_82801BA_9 0x244b
  27454. +#define PCI_DEVICE_ID_INTEL_82801BA_10 0x244c
  27455. +#define PCI_DEVICE_ID_INTEL_82801BA_11 0x244e
  27456. +#define PCI_DEVICE_ID_INTEL_82801CA_0 0x2480
  27457. +#define PCI_DEVICE_ID_INTEL_82801CA_2 0x2482
  27458. +#define PCI_DEVICE_ID_INTEL_82801CA_3 0x2483
  27459. +#define PCI_DEVICE_ID_INTEL_82801CA_4 0x2484
  27460. +#define PCI_DEVICE_ID_INTEL_82801CA_5 0x2485
  27461. +#define PCI_DEVICE_ID_INTEL_82801CA_6 0x2486
  27462. +#define PCI_DEVICE_ID_INTEL_82801CA_7 0x2487
  27463. +#define PCI_DEVICE_ID_INTEL_82801CA_10 0x248a
  27464. +#define PCI_DEVICE_ID_INTEL_82801CA_11 0x248b
  27465. +#define PCI_DEVICE_ID_INTEL_82801CA_12 0x248c
  27466. +#define PCI_DEVICE_ID_INTEL_80310 0x530d
  27467. +#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000
  27468. +#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010
  27469. +#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020
  27470. +#define PCI_DEVICE_ID_INTEL_82437VX 0x7030
  27471. +#define PCI_DEVICE_ID_INTEL_82439TX 0x7100
  27472. +#define PCI_DEVICE_ID_INTEL_82371AB_0 0x7110
  27473. +#define PCI_DEVICE_ID_INTEL_82371AB 0x7111
  27474. +#define PCI_DEVICE_ID_INTEL_82371AB_2 0x7112
  27475. +#define PCI_DEVICE_ID_INTEL_82371AB_3 0x7113
  27476. +#define PCI_DEVICE_ID_INTEL_82810_MC1 0x7120
  27477. +#define PCI_DEVICE_ID_INTEL_82810_IG1 0x7121
  27478. +#define PCI_DEVICE_ID_INTEL_82810_MC3 0x7122
  27479. +#define PCI_DEVICE_ID_INTEL_82810_IG3 0x7123
  27480. +#define PCI_DEVICE_ID_INTEL_82443LX_0 0x7180
  27481. +#define PCI_DEVICE_ID_INTEL_82443LX_1 0x7181
  27482. +#define PCI_DEVICE_ID_INTEL_82443BX_0 0x7190
  27483. +#define PCI_DEVICE_ID_INTEL_82443BX_1 0x7191
  27484. +#define PCI_DEVICE_ID_INTEL_82443BX_2 0x7192
  27485. +#define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198
  27486. +#define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199
  27487. +#define PCI_DEVICE_ID_INTEL_82443MX_2 0x719a
  27488. +#define PCI_DEVICE_ID_INTEL_82443MX_3 0x719b
  27489. +#define PCI_DEVICE_ID_INTEL_82372FB_0 0x7600
  27490. +#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601
  27491. +#define PCI_DEVICE_ID_INTEL_82372FB_2 0x7602
  27492. +#define PCI_DEVICE_ID_INTEL_82372FB_3 0x7603
  27493. +#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4
  27494. +#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5
  27495. +#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca
  27496. +
  27497. +#define PCI_VENDOR_ID_COMPUTONE 0x8e0e
  27498. +#define PCI_DEVICE_ID_COMPUTONE_IP2EX 0x0291
  27499. +#define PCI_DEVICE_ID_COMPUTONE_PG 0x0302
  27500. +#define PCI_SUBVENDOR_ID_COMPUTONE 0x8e0e
  27501. +#define PCI_SUBDEVICE_ID_COMPUTONE_PG4 0x0001
  27502. +#define PCI_SUBDEVICE_ID_COMPUTONE_PG8 0x0002
  27503. +#define PCI_SUBDEVICE_ID_COMPUTONE_PG6 0x0003
  27504. +
  27505. +#define PCI_VENDOR_ID_KTI 0x8e2e
  27506. +#define PCI_DEVICE_ID_KTI_ET32P2 0x3000
  27507. +
  27508. +#define PCI_VENDOR_ID_ADAPTEC 0x9004
  27509. +#define PCI_DEVICE_ID_ADAPTEC_7810 0x1078
  27510. +#define PCI_DEVICE_ID_ADAPTEC_7821 0x2178
  27511. +#define PCI_DEVICE_ID_ADAPTEC_38602 0x3860
  27512. +#define PCI_DEVICE_ID_ADAPTEC_7850 0x5078
  27513. +#define PCI_DEVICE_ID_ADAPTEC_7855 0x5578
  27514. +#define PCI_DEVICE_ID_ADAPTEC_5800 0x5800
  27515. +#define PCI_DEVICE_ID_ADAPTEC_3860 0x6038
  27516. +#define PCI_DEVICE_ID_ADAPTEC_1480A 0x6075
  27517. +#define PCI_DEVICE_ID_ADAPTEC_7860 0x6078
  27518. +#define PCI_DEVICE_ID_ADAPTEC_7861 0x6178
  27519. +#define PCI_DEVICE_ID_ADAPTEC_7870 0x7078
  27520. +#define PCI_DEVICE_ID_ADAPTEC_7871 0x7178
  27521. +#define PCI_DEVICE_ID_ADAPTEC_7872 0x7278
  27522. +#define PCI_DEVICE_ID_ADAPTEC_7873 0x7378
  27523. +#define PCI_DEVICE_ID_ADAPTEC_7874 0x7478
  27524. +#define PCI_DEVICE_ID_ADAPTEC_7895 0x7895
  27525. +#define PCI_DEVICE_ID_ADAPTEC_7880 0x8078
  27526. +#define PCI_DEVICE_ID_ADAPTEC_7881 0x8178
  27527. +#define PCI_DEVICE_ID_ADAPTEC_7882 0x8278
  27528. +#define PCI_DEVICE_ID_ADAPTEC_7883 0x8378
  27529. +#define PCI_DEVICE_ID_ADAPTEC_7884 0x8478
  27530. +#define PCI_DEVICE_ID_ADAPTEC_7885 0x8578
  27531. +#define PCI_DEVICE_ID_ADAPTEC_7886 0x8678
  27532. +#define PCI_DEVICE_ID_ADAPTEC_7887 0x8778
  27533. +#define PCI_DEVICE_ID_ADAPTEC_7888 0x8878
  27534. +#define PCI_DEVICE_ID_ADAPTEC_1030 0x8b78
  27535. +
  27536. +#define PCI_VENDOR_ID_ADAPTEC2 0x9005
  27537. +#define PCI_DEVICE_ID_ADAPTEC2_2940U2 0x0010
  27538. +#define PCI_DEVICE_ID_ADAPTEC2_2930U2 0x0011
  27539. +#define PCI_DEVICE_ID_ADAPTEC2_7890B 0x0013
  27540. +#define PCI_DEVICE_ID_ADAPTEC2_7890 0x001f
  27541. +#define PCI_DEVICE_ID_ADAPTEC2_3940U2 0x0050
  27542. +#define PCI_DEVICE_ID_ADAPTEC2_3950U2D 0x0051
  27543. +#define PCI_DEVICE_ID_ADAPTEC2_7896 0x005f
  27544. +#define PCI_DEVICE_ID_ADAPTEC2_7892A 0x0080
  27545. +#define PCI_DEVICE_ID_ADAPTEC2_7892B 0x0081
  27546. +#define PCI_DEVICE_ID_ADAPTEC2_7892D 0x0083
  27547. +#define PCI_DEVICE_ID_ADAPTEC2_7892P 0x008f
  27548. +#define PCI_DEVICE_ID_ADAPTEC2_7899A 0x00c0
  27549. +#define PCI_DEVICE_ID_ADAPTEC2_7899B 0x00c1
  27550. +#define PCI_DEVICE_ID_ADAPTEC2_7899D 0x00c3
  27551. +#define PCI_DEVICE_ID_ADAPTEC2_7899P 0x00cf
  27552. +
  27553. +#define PCI_VENDOR_ID_ATRONICS 0x907f
  27554. +#define PCI_DEVICE_ID_ATRONICS_2015 0x2015
  27555. +
  27556. +#define PCI_VENDOR_ID_HOLTEK2 0x9412
  27557. +#define PCI_DEVICE_ID_HOLTEK2_6565 0x6565
  27558. +
  27559. +#define PCI_VENDOR_ID_NETMOS 0x9710
  27560. +#define PCI_DEVICE_ID_NETMOS_9735 0x9735
  27561. +#define PCI_DEVICE_ID_NETMOS_9835 0x9835
  27562. +
  27563. +#define PCI_SUBVENDOR_ID_EXSYS 0xd84d
  27564. +#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014
  27565. +
  27566. +#define PCI_VENDOR_ID_TIGERJET 0xe159
  27567. +#define PCI_DEVICE_ID_TIGERJET_300 0x0001
  27568. +#define PCI_DEVICE_ID_TIGERJET_100 0x0002
  27569. +
  27570. +#define PCI_VENDOR_ID_ARK 0xedd8
  27571. +#define PCI_DEVICE_ID_ARK_STING 0xa091
  27572. +#define PCI_DEVICE_ID_ARK_STINGARK 0xa099
  27573. +#define PCI_DEVICE_ID_ARK_2000MT 0xa0a1
  27574. +
  27575. Index: b/netboot/pci_io.c
  27576. ===================================================================
  27577. --- /dev/null
  27578. +++ b/netboot/pci_io.c
  27579. @@ -0,0 +1,431 @@
  27580. +/*
  27581. +** Support for NE2000 PCI clones added David Monro June 1997
  27582. +** Generalised to other NICs by Ken Yap July 1997
  27583. +**
  27584. +** Most of this is taken from:
  27585. +**
  27586. +** /usr/src/linux/drivers/pci/pci.c
  27587. +** /usr/src/linux/include/linux/pci.h
  27588. +** /usr/src/linux/arch/i386/bios32.c
  27589. +** /usr/src/linux/include/linux/bios32.h
  27590. +** /usr/src/linux/drivers/net/ne.c
  27591. +*/
  27592. +#define PCBIOS
  27593. +#include "grub.h"
  27594. +#include "pci.h"
  27595. +
  27596. +#ifdef CONFIG_PCI_DIRECT
  27597. +#define PCIBIOS_SUCCESSFUL 0x00
  27598. +
  27599. +#define DEBUG 0
  27600. +
  27601. +/*
  27602. + * Functions for accessing PCI configuration space with type 1 accesses
  27603. + */
  27604. +
  27605. +#define CONFIG_CMD(bus, device_fn, where) (0x80000000 | (bus << 16) | (device_fn << 8) | (where & ~3))
  27606. +
  27607. +int pcibios_read_config_byte(unsigned int bus, unsigned int device_fn,
  27608. + unsigned int where, uint8_t *value)
  27609. +{
  27610. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  27611. + *value = inb(0xCFC + (where&3));
  27612. + return PCIBIOS_SUCCESSFUL;
  27613. +}
  27614. +
  27615. +int pcibios_read_config_word (unsigned int bus,
  27616. + unsigned int device_fn, unsigned int where, uint16_t *value)
  27617. +{
  27618. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  27619. + *value = inw(0xCFC + (where&2));
  27620. + return PCIBIOS_SUCCESSFUL;
  27621. +}
  27622. +
  27623. +int pcibios_read_config_dword (unsigned int bus, unsigned int device_fn,
  27624. + unsigned int where, uint32_t *value)
  27625. +{
  27626. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  27627. + *value = inl(0xCFC);
  27628. + return PCIBIOS_SUCCESSFUL;
  27629. +}
  27630. +
  27631. +int pcibios_write_config_byte (unsigned int bus, unsigned int device_fn,
  27632. + unsigned int where, uint8_t value)
  27633. +{
  27634. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  27635. + outb(value, 0xCFC + (where&3));
  27636. + return PCIBIOS_SUCCESSFUL;
  27637. +}
  27638. +
  27639. +int pcibios_write_config_word (unsigned int bus, unsigned int device_fn,
  27640. + unsigned int where, uint16_t value)
  27641. +{
  27642. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  27643. + outw(value, 0xCFC + (where&2));
  27644. + return PCIBIOS_SUCCESSFUL;
  27645. +}
  27646. +
  27647. +int pcibios_write_config_dword (unsigned int bus, unsigned int device_fn, unsigned int where, uint32_t value)
  27648. +{
  27649. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  27650. + outl(value, 0xCFC);
  27651. + return PCIBIOS_SUCCESSFUL;
  27652. +}
  27653. +
  27654. +#undef CONFIG_CMD
  27655. +
  27656. +#else /* CONFIG_PCI_DIRECT not defined */
  27657. +
  27658. +#if !defined(PCBIOS)
  27659. +#error "The pcibios can only be used when the PCBIOS support is compiled in"
  27660. +#endif
  27661. +
  27662. +
  27663. +#define KERN_CODE_SEG 0X8
  27664. +/* Stuff for asm */
  27665. +#define save_flags(x) \
  27666. +__asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */ :"memory")
  27667. +
  27668. +#define cli() __asm__ __volatile__ ("cli": : :"memory")
  27669. +
  27670. +#define restore_flags(x) \
  27671. +__asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
  27672. +
  27673. +
  27674. +
  27675. +static struct {
  27676. + unsigned long address;
  27677. + unsigned short segment;
  27678. +} bios32_indirect = { 0, KERN_CODE_SEG };
  27679. +
  27680. +static long pcibios_entry = 0;
  27681. +static struct {
  27682. + unsigned long address;
  27683. + unsigned short segment;
  27684. +} pci_indirect = { 0, KERN_CODE_SEG };
  27685. +
  27686. +static unsigned long bios32_service(unsigned long service)
  27687. +{
  27688. + unsigned char return_code; /* %al */
  27689. + unsigned long address; /* %ebx */
  27690. + unsigned long length; /* %ecx */
  27691. + unsigned long entry; /* %edx */
  27692. + unsigned long flags;
  27693. +
  27694. + save_flags(flags);
  27695. + __asm__(
  27696. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  27697. + "lcall (%%edi)"
  27698. +#else
  27699. + "lcall *(%%edi)"
  27700. +#endif
  27701. + : "=a" (return_code),
  27702. + "=b" (address),
  27703. + "=c" (length),
  27704. + "=d" (entry)
  27705. + : "0" (service),
  27706. + "1" (0),
  27707. + "D" (&bios32_indirect));
  27708. + restore_flags(flags);
  27709. +
  27710. + switch (return_code) {
  27711. + case 0:
  27712. + return address + entry;
  27713. + case 0x80: /* Not present */
  27714. + printf("bios32_service(%d) : not present\n", service);
  27715. + return 0;
  27716. + default: /* Shouldn't happen */
  27717. + printf("bios32_service(%d) : returned %#X, mail drew@colorado.edu\n",
  27718. + service, return_code);
  27719. + return 0;
  27720. + }
  27721. +}
  27722. +
  27723. +int pcibios_read_config_byte(unsigned int bus,
  27724. + unsigned int device_fn, unsigned int where, uint8_t *value)
  27725. +{
  27726. + unsigned long ret;
  27727. + unsigned long bx = (bus << 8) | device_fn;
  27728. + unsigned long flags;
  27729. +
  27730. + save_flags(flags);
  27731. + __asm__(
  27732. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  27733. + "lcall (%%esi)\n\t"
  27734. +#else
  27735. + "lcall *(%%esi)\n\t"
  27736. +#endif
  27737. + "jc 1f\n\t"
  27738. + "xor %%ah, %%ah\n"
  27739. + "1:"
  27740. + : "=c" (*value),
  27741. + "=a" (ret)
  27742. + : "1" (PCIBIOS_READ_CONFIG_BYTE),
  27743. + "b" (bx),
  27744. + "D" ((long) where),
  27745. + "S" (&pci_indirect));
  27746. + restore_flags(flags);
  27747. + return (int) (ret & 0xff00) >> 8;
  27748. +}
  27749. +
  27750. +int pcibios_read_config_word(unsigned int bus,
  27751. + unsigned int device_fn, unsigned int where, uint16_t *value)
  27752. +{
  27753. + unsigned long ret;
  27754. + unsigned long bx = (bus << 8) | device_fn;
  27755. + unsigned long flags;
  27756. +
  27757. + save_flags(flags);
  27758. + __asm__(
  27759. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  27760. + "lcall (%%esi)\n\t"
  27761. +#else
  27762. + "lcall *(%%esi)\n\t"
  27763. +#endif
  27764. + "jc 1f\n\t"
  27765. + "xor %%ah, %%ah\n"
  27766. + "1:"
  27767. + : "=c" (*value),
  27768. + "=a" (ret)
  27769. + : "1" (PCIBIOS_READ_CONFIG_WORD),
  27770. + "b" (bx),
  27771. + "D" ((long) where),
  27772. + "S" (&pci_indirect));
  27773. + restore_flags(flags);
  27774. + return (int) (ret & 0xff00) >> 8;
  27775. +}
  27776. +
  27777. +int pcibios_read_config_dword(unsigned int bus,
  27778. + unsigned int device_fn, unsigned int where, uint32_t *value)
  27779. +{
  27780. + unsigned long ret;
  27781. + unsigned long bx = (bus << 8) | device_fn;
  27782. + unsigned long flags;
  27783. +
  27784. + save_flags(flags);
  27785. + __asm__(
  27786. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  27787. + "lcall (%%esi)\n\t"
  27788. +#else
  27789. + "lcall *(%%esi)\n\t"
  27790. +#endif
  27791. + "jc 1f\n\t"
  27792. + "xor %%ah, %%ah\n"
  27793. + "1:"
  27794. + : "=c" (*value),
  27795. + "=a" (ret)
  27796. + : "1" (PCIBIOS_READ_CONFIG_DWORD),
  27797. + "b" (bx),
  27798. + "D" ((long) where),
  27799. + "S" (&pci_indirect));
  27800. + restore_flags(flags);
  27801. + return (int) (ret & 0xff00) >> 8;
  27802. +}
  27803. +
  27804. +int pcibios_write_config_byte (unsigned int bus,
  27805. + unsigned int device_fn, unsigned int where, uint8_t value)
  27806. +{
  27807. + unsigned long ret;
  27808. + unsigned long bx = (bus << 8) | device_fn;
  27809. + unsigned long flags;
  27810. +
  27811. + save_flags(flags); cli();
  27812. + __asm__(
  27813. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  27814. + "lcall (%%esi)\n\t"
  27815. +#else
  27816. + "lcall *(%%esi)\n\t"
  27817. +#endif
  27818. + "jc 1f\n\t"
  27819. + "xor %%ah, %%ah\n"
  27820. + "1:"
  27821. + : "=a" (ret)
  27822. + : "0" (PCIBIOS_WRITE_CONFIG_BYTE),
  27823. + "c" (value),
  27824. + "b" (bx),
  27825. + "D" ((long) where),
  27826. + "S" (&pci_indirect));
  27827. + restore_flags(flags);
  27828. + return (int) (ret & 0xff00) >> 8;
  27829. +}
  27830. +
  27831. +int pcibios_write_config_word (unsigned int bus,
  27832. + unsigned int device_fn, unsigned int where, uint16_t value)
  27833. +{
  27834. + unsigned long ret;
  27835. + unsigned long bx = (bus << 8) | device_fn;
  27836. + unsigned long flags;
  27837. +
  27838. + save_flags(flags); cli();
  27839. + __asm__(
  27840. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  27841. + "lcall (%%esi)\n\t"
  27842. +#else
  27843. + "lcall *(%%esi)\n\t"
  27844. +#endif
  27845. + "jc 1f\n\t"
  27846. + "xor %%ah, %%ah\n"
  27847. + "1:"
  27848. + : "=a" (ret)
  27849. + : "0" (PCIBIOS_WRITE_CONFIG_WORD),
  27850. + "c" (value),
  27851. + "b" (bx),
  27852. + "D" ((long) where),
  27853. + "S" (&pci_indirect));
  27854. + restore_flags(flags);
  27855. + return (int) (ret & 0xff00) >> 8;
  27856. +}
  27857. +
  27858. +int pcibios_write_config_dword (unsigned int bus,
  27859. + unsigned int device_fn, unsigned int where, uint32_t value)
  27860. +{
  27861. + unsigned long ret;
  27862. + unsigned long bx = (bus << 8) | device_fn;
  27863. + unsigned long flags;
  27864. +
  27865. + save_flags(flags); cli();
  27866. + __asm__(
  27867. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  27868. + "lcall (%%esi)\n\t"
  27869. +#else
  27870. + "lcall *(%%esi)\n\t"
  27871. +#endif
  27872. + "jc 1f\n\t"
  27873. + "xor %%ah, %%ah\n"
  27874. + "1:"
  27875. + : "=a" (ret)
  27876. + : "0" (PCIBIOS_WRITE_CONFIG_DWORD),
  27877. + "c" (value),
  27878. + "b" (bx),
  27879. + "D" ((long) where),
  27880. + "S" (&pci_indirect));
  27881. + restore_flags(flags);
  27882. + return (int) (ret & 0xff00) >> 8;
  27883. +}
  27884. +
  27885. +static void check_pcibios(void)
  27886. +{
  27887. + unsigned long signature;
  27888. + unsigned char present_status;
  27889. + unsigned char major_revision;
  27890. + unsigned char minor_revision;
  27891. + unsigned long flags;
  27892. + int pack;
  27893. +
  27894. + if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
  27895. + pci_indirect.address = pcibios_entry;
  27896. +
  27897. + save_flags(flags);
  27898. + __asm__(
  27899. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  27900. + "lcall (%%edi)\n\t"
  27901. +#else
  27902. + "lcall *(%%edi)\n\t"
  27903. +#endif
  27904. + "jc 1f\n\t"
  27905. + "xor %%ah, %%ah\n"
  27906. + "1:\tshl $8, %%eax\n\t"
  27907. + "movw %%bx, %%ax"
  27908. + : "=d" (signature),
  27909. + "=a" (pack)
  27910. + : "1" (PCIBIOS_PCI_BIOS_PRESENT),
  27911. + "D" (&pci_indirect)
  27912. + : "bx", "cx");
  27913. + restore_flags(flags);
  27914. +
  27915. + present_status = (pack >> 16) & 0xff;
  27916. + major_revision = (pack >> 8) & 0xff;
  27917. + minor_revision = pack & 0xff;
  27918. + if (present_status || (signature != PCI_SIGNATURE)) {
  27919. + printf("ERROR: BIOS32 says PCI BIOS, but no PCI "
  27920. + "BIOS????\n");
  27921. + pcibios_entry = 0;
  27922. + }
  27923. +#if DEBUG
  27924. + if (pcibios_entry) {
  27925. + printf ("pcibios_init : PCI BIOS revision %hhX.%hhX"
  27926. + " entry at %#X\n", major_revision,
  27927. + minor_revision, pcibios_entry);
  27928. + }
  27929. +#endif
  27930. + }
  27931. +}
  27932. +
  27933. +static void pcibios_init(void)
  27934. +{
  27935. + union bios32 *check;
  27936. + unsigned char sum;
  27937. + int i, length;
  27938. + unsigned long bios32_entry = 0;
  27939. +
  27940. + EnterFunction("pcibios_init");
  27941. + /*
  27942. + * Follow the standard procedure for locating the BIOS32 Service
  27943. + * directory by scanning the permissible address range from
  27944. + * 0xe0000 through 0xfffff for a valid BIOS32 structure.
  27945. + *
  27946. + */
  27947. +
  27948. + for (check = (union bios32 *) 0xe0000; check <= (union bios32 *) 0xffff0; ++check) {
  27949. + if (check->fields.signature != BIOS32_SIGNATURE)
  27950. + continue;
  27951. + length = check->fields.length * 16;
  27952. + if (!length)
  27953. + continue;
  27954. + sum = 0;
  27955. + for (i = 0; i < length ; ++i)
  27956. + sum += check->chars[i];
  27957. + if (sum != 0)
  27958. + continue;
  27959. + if (check->fields.revision != 0) {
  27960. + printf("pcibios_init : unsupported revision %d at %#X, mail drew@colorado.edu\n",
  27961. + check->fields.revision, check);
  27962. + continue;
  27963. + }
  27964. +#if DEBUG
  27965. + printf("pcibios_init : BIOS32 Service Directory "
  27966. + "structure at %#X\n", check);
  27967. +#endif
  27968. + if (!bios32_entry) {
  27969. + if (check->fields.entry >= 0x100000) {
  27970. + printf("pcibios_init: entry in high "
  27971. + "memory, giving up\n");
  27972. + return;
  27973. + } else {
  27974. + bios32_entry = check->fields.entry;
  27975. +#if DEBUG
  27976. + printf("pcibios_init : BIOS32 Service Directory"
  27977. + " entry at %#X\n", bios32_entry);
  27978. +#endif
  27979. + bios32_indirect.address = bios32_entry;
  27980. + }
  27981. + }
  27982. + }
  27983. + if (bios32_entry)
  27984. + check_pcibios();
  27985. + LeaveFunction("pcibios_init");
  27986. +}
  27987. +
  27988. +#endif /* CONFIG_PCI_DIRECT not defined*/
  27989. +
  27990. +unsigned long pcibios_bus_base(unsigned int bus __unused)
  27991. +{
  27992. + /* architecturally this must be 0 */
  27993. + return 0;
  27994. +}
  27995. +
  27996. +void find_pci(int type, struct pci_device *dev)
  27997. +{
  27998. + EnterFunction("find_pci");
  27999. +#ifndef CONFIG_PCI_DIRECT
  28000. + if (!pcibios_entry) {
  28001. + pcibios_init();
  28002. + }
  28003. + if (!pcibios_entry) {
  28004. + printf("pci_init: no BIOS32 detected\n");
  28005. + return;
  28006. + }
  28007. +#endif
  28008. + LeaveFunction("find_pci");
  28009. + return scan_pci_bus(type, dev);
  28010. +}
  28011. Index: b/netboot/pcnet32.c
  28012. ===================================================================
  28013. --- /dev/null
  28014. +++ b/netboot/pcnet32.c
  28015. @@ -0,0 +1,1004 @@
  28016. +/**************************************************************************
  28017. +*
  28018. +* pcnet32.c -- Etherboot device driver for the AMD PCnet32
  28019. +* Written 2003-2003 by Timothy Legge <tlegge@rogers.com>
  28020. +*
  28021. +* This program is free software; you can redistribute it and/or modify
  28022. +* it under the terms of the GNU General Public License as published by
  28023. +* the Free Software Foundation; either version 2 of the License, or
  28024. +* (at your option) any later version.
  28025. +*
  28026. +* This program is distributed in the hope that it will be useful,
  28027. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  28028. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28029. +* GNU General Public License for more details.
  28030. +*
  28031. +* You should have received a copy of the GNU General Public License
  28032. +* along with this program; if not, write to the Free Software
  28033. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  28034. +*
  28035. +* Portions of this code based on:
  28036. +* pcnet32.c: An AMD PCnet32 ethernet driver for linux:
  28037. +*
  28038. +* (C) 1996-1999 Thomas Bogendoerfer
  28039. +* See Linux Driver for full information
  28040. +*
  28041. +* The transmit and poll functions were written with reference to:
  28042. +* lance.c - LANCE NIC driver for Etherboot written by Ken Yap
  28043. +*
  28044. +* Linux Driver Version 1.27a, 10.02.2002
  28045. +*
  28046. +*
  28047. +* REVISION HISTORY:
  28048. +* ================
  28049. +* v1.0 08-06-2003 timlegge Initial port of Linux driver
  28050. +* v1.1 08-23-2003 timlegge Add multicast support
  28051. +* v1.2 01-17-2004 timlegge Initial driver output cleanup
  28052. +* v1.3 03-29-2004 timlegge More driver cleanup
  28053. +*
  28054. +* Indent Options: indent -kr -i8
  28055. +***************************************************************************/
  28056. +
  28057. +/* to get some global routines like printf */
  28058. +#include "etherboot.h"
  28059. +/* to get the interface to the body of the program */
  28060. +#include "nic.h"
  28061. +/* to get the PCI support functions, if this is a PCI NIC */
  28062. +#include "pci.h"
  28063. +/* Include the time functions */
  28064. +#include "timer.h"
  28065. +#include "mii.h"
  28066. +/* void hex_dump(const char *data, const unsigned int len); */
  28067. +
  28068. +/* Etherboot Specific definations */
  28069. +#define drv_version "v1.3"
  28070. +#define drv_date "03-29-2004"
  28071. +
  28072. +typedef unsigned char u8;
  28073. +typedef signed char s8;
  28074. +typedef unsigned short u16;
  28075. +typedef signed short s16;
  28076. +typedef unsigned int u32;
  28077. +typedef signed int s32;
  28078. +
  28079. +static u32 ioaddr; /* Globally used for the card's io address */
  28080. +
  28081. +#ifdef EDEBUG
  28082. +#define dprintf(x) printf x
  28083. +#else
  28084. +#define dprintf(x)
  28085. +#endif
  28086. +
  28087. +/* Condensed operations for readability. */
  28088. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  28089. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  28090. +
  28091. +/* End Etherboot Specific */
  28092. +
  28093. +int cards_found /* __initdata */ ;
  28094. +
  28095. +#ifdef REMOVE
  28096. +/* FIXME: Remove these they are probably pointless */
  28097. +
  28098. +/*
  28099. + * VLB I/O addresses
  28100. + */
  28101. +static unsigned int pcnet32_portlist[] /*__initdata */ =
  28102. +{ 0x300, 0x320, 0x340, 0x360, 0 };
  28103. +
  28104. +static int pcnet32_debug = 1;
  28105. +static int tx_start = 1; /* Mapping -- 0:20, 1:64, 2:128, 3:~220 (depends on chip vers) */
  28106. +static int pcnet32vlb; /* check for VLB cards ? */
  28107. +
  28108. +static struct net_device *pcnet32_dev;
  28109. +
  28110. +static int max_interrupt_work = 80;
  28111. +static int rx_copybreak = 200;
  28112. +#endif
  28113. +#define PCNET32_PORT_AUI 0x00
  28114. +#define PCNET32_PORT_10BT 0x01
  28115. +#define PCNET32_PORT_GPSI 0x02
  28116. +#define PCNET32_PORT_MII 0x03
  28117. +
  28118. +#define PCNET32_PORT_PORTSEL 0x03
  28119. +#define PCNET32_PORT_ASEL 0x04
  28120. +#define PCNET32_PORT_100 0x40
  28121. +#define PCNET32_PORT_FD 0x80
  28122. +
  28123. +#define PCNET32_DMA_MASK 0xffffffff
  28124. +
  28125. +/*
  28126. + * table to translate option values from tulip
  28127. + * to internal options
  28128. + */
  28129. +static unsigned char options_mapping[] = {
  28130. + PCNET32_PORT_ASEL, /* 0 Auto-select */
  28131. + PCNET32_PORT_AUI, /* 1 BNC/AUI */
  28132. + PCNET32_PORT_AUI, /* 2 AUI/BNC */
  28133. + PCNET32_PORT_ASEL, /* 3 not supported */
  28134. + PCNET32_PORT_10BT | PCNET32_PORT_FD, /* 4 10baseT-FD */
  28135. + PCNET32_PORT_ASEL, /* 5 not supported */
  28136. + PCNET32_PORT_ASEL, /* 6 not supported */
  28137. + PCNET32_PORT_ASEL, /* 7 not supported */
  28138. + PCNET32_PORT_ASEL, /* 8 not supported */
  28139. + PCNET32_PORT_MII, /* 9 MII 10baseT */
  28140. + PCNET32_PORT_MII | PCNET32_PORT_FD, /* 10 MII 10baseT-FD */
  28141. + PCNET32_PORT_MII, /* 11 MII (autosel) */
  28142. + PCNET32_PORT_10BT, /* 12 10BaseT */
  28143. + PCNET32_PORT_MII | PCNET32_PORT_100, /* 13 MII 100BaseTx */
  28144. + PCNET32_PORT_MII | PCNET32_PORT_100 | PCNET32_PORT_FD, /* 14 MII 100BaseTx-FD */
  28145. + PCNET32_PORT_ASEL /* 15 not supported */
  28146. +};
  28147. +
  28148. +#define MAX_UNITS 8 /* More are supported, limit only on options */
  28149. +static int options[MAX_UNITS];
  28150. +static int full_duplex[MAX_UNITS];
  28151. +
  28152. +/*
  28153. + * Theory of Operation
  28154. + *
  28155. + * This driver uses the same software structure as the normal lance
  28156. + * driver. So look for a verbose description in lance.c. The differences
  28157. + * to the normal lance driver is the use of the 32bit mode of PCnet32
  28158. + * and PCnetPCI chips. Because these chips are 32bit chips, there is no
  28159. + * 16MB limitation and we don't need bounce buffers.
  28160. + */
  28161. +
  28162. +
  28163. +
  28164. +/*
  28165. + * Set the number of Tx and Rx buffers, using Log_2(# buffers).
  28166. + * Reasonable default values are 4 Tx buffers, and 16 Rx buffers.
  28167. + * That translates to 2 (4 == 2^^2) and 4 (16 == 2^^4).
  28168. + */
  28169. +#ifndef PCNET32_LOG_TX_BUFFERS
  28170. +#define PCNET32_LOG_TX_BUFFERS 1
  28171. +#define PCNET32_LOG_RX_BUFFERS 2
  28172. +#endif
  28173. +
  28174. +#define TX_RING_SIZE (1 << (PCNET32_LOG_TX_BUFFERS))
  28175. +#define TX_RING_MOD_MASK (TX_RING_SIZE - 1)
  28176. +/* FIXME: Fix this to allow multiple tx_ring descriptors */
  28177. +#define TX_RING_LEN_BITS 0x0000 /*PCNET32_LOG_TX_BUFFERS) << 12) */
  28178. +
  28179. +#define RX_RING_SIZE (1 << (PCNET32_LOG_RX_BUFFERS))
  28180. +#define RX_RING_MOD_MASK (RX_RING_SIZE - 1)
  28181. +#define RX_RING_LEN_BITS ((PCNET32_LOG_RX_BUFFERS) << 4)
  28182. +
  28183. +#define PKT_BUF_SZ 1544
  28184. +
  28185. +/* Offsets from base I/O address. */
  28186. +#define PCNET32_WIO_RDP 0x10
  28187. +#define PCNET32_WIO_RAP 0x12
  28188. +#define PCNET32_WIO_RESET 0x14
  28189. +#define PCNET32_WIO_BDP 0x16
  28190. +
  28191. +#define PCNET32_DWIO_RDP 0x10
  28192. +#define PCNET32_DWIO_RAP 0x14
  28193. +#define PCNET32_DWIO_RESET 0x18
  28194. +#define PCNET32_DWIO_BDP 0x1C
  28195. +
  28196. +#define PCNET32_TOTAL_SIZE 0x20
  28197. +
  28198. +/* Buffers for the tx and Rx */
  28199. +
  28200. +/* Create a static buffer of size PKT_BUF_SZ for each
  28201. +TX Descriptor. All descriptors point to a
  28202. +part of this buffer */
  28203. +static unsigned char txb[PKT_BUF_SZ * TX_RING_SIZE];
  28204. +// __attribute__ ((aligned(16)));
  28205. +
  28206. +/* Create a static buffer of size PKT_BUF_SZ for each
  28207. +RX Descriptor All descriptors point to a
  28208. +part of this buffer */
  28209. +static unsigned char rxb[RX_RING_SIZE * PKT_BUF_SZ];
  28210. +// __attribute__ ((aligned(16)));
  28211. +
  28212. +/* The PCNET32 Rx and Tx ring descriptors. */
  28213. +struct pcnet32_rx_head {
  28214. + u32 base;
  28215. + s16 buf_length;
  28216. + s16 status;
  28217. + u32 msg_length;
  28218. + u32 reserved;
  28219. +};
  28220. +
  28221. +struct pcnet32_tx_head {
  28222. + u32 base;
  28223. + s16 length;
  28224. + s16 status;
  28225. + u32 misc;
  28226. + u32 reserved;
  28227. +};
  28228. +
  28229. +/* The PCNET32 32-Bit initialization block, described in databook. */
  28230. +struct pcnet32_init_block {
  28231. + u16 mode;
  28232. + u16 tlen_rlen;
  28233. + u8 phys_addr[6];
  28234. + u16 reserved;
  28235. + u32 filter[2];
  28236. + /* Receive and transmit ring base, along with extra bits. */
  28237. + u32 rx_ring;
  28238. + u32 tx_ring;
  28239. +};
  28240. +/* PCnet32 access functions */
  28241. +struct pcnet32_access {
  28242. + u16(*read_csr) (unsigned long, int);
  28243. + void (*write_csr) (unsigned long, int, u16);
  28244. + u16(*read_bcr) (unsigned long, int);
  28245. + void (*write_bcr) (unsigned long, int, u16);
  28246. + u16(*read_rap) (unsigned long);
  28247. + void (*write_rap) (unsigned long, u16);
  28248. + void (*reset) (unsigned long);
  28249. +};
  28250. +
  28251. +/* Define the TX Descriptor */
  28252. +static struct pcnet32_tx_head tx_ring[TX_RING_SIZE]
  28253. + __attribute__ ((aligned(16)));
  28254. +
  28255. +
  28256. +/* Define the RX Descriptor */
  28257. +static struct pcnet32_rx_head rx_ring[RX_RING_SIZE]
  28258. + __attribute__ ((aligned(16)));
  28259. +
  28260. +/* May need to be moved to mii.h */
  28261. +struct mii_if_info {
  28262. + int phy_id;
  28263. + int advertising;
  28264. + unsigned int full_duplex:1; /* is full duplex? */
  28265. +};
  28266. +
  28267. +/*
  28268. + * The first three fields of pcnet32_private are read by the ethernet device
  28269. + * so we allocate the structure should be allocated by pci_alloc_consistent().
  28270. + */
  28271. +#define MII_CNT 4
  28272. +struct pcnet32_private {
  28273. + struct pcnet32_init_block init_block;
  28274. + struct pci_dev *pci_dev; /* Pointer to the associated pci device structure */
  28275. + const char *name;
  28276. + /* The saved address of a sent-in-place packet/buffer, for skfree(). */
  28277. + struct sk_buff *tx_skbuff[TX_RING_SIZE];
  28278. + struct sk_buff *rx_skbuff[RX_RING_SIZE];
  28279. + struct pcnet32_access a;
  28280. + unsigned int cur_rx, cur_tx; /* The next free ring entry */
  28281. + char tx_full;
  28282. + int options;
  28283. + int shared_irq:1, /* shared irq possible */
  28284. + ltint:1, /* enable TxDone-intr inhibitor */
  28285. + dxsuflo:1, /* disable transmit stop on uflo */
  28286. + mii:1; /* mii port available */
  28287. + struct mii_if_info mii_if;
  28288. + unsigned char phys[MII_CNT];
  28289. + struct net_device *next;
  28290. + int full_duplex:1;
  28291. +} lpx;
  28292. +
  28293. +static struct pcnet32_private *lp;
  28294. +
  28295. +static int mdio_read(struct nic *nic __unused, int phy_id, int reg_num);
  28296. +#if 0
  28297. +static void mdio_write(struct nic *nic __unused, int phy_id, int reg_num,
  28298. + int val);
  28299. +#endif
  28300. +enum pci_flags_bit {
  28301. + PCI_USES_IO = 1, PCI_USES_MEM = 2, PCI_USES_MASTER = 4,
  28302. + PCI_ADDR0 = 0x10 << 0, PCI_ADDR1 = 0x10 << 1, PCI_ADDR2 =
  28303. + 0x10 << 2, PCI_ADDR3 = 0x10 << 3,
  28304. +};
  28305. +
  28306. +
  28307. +static u16 pcnet32_wio_read_csr(unsigned long addr, int index)
  28308. +{
  28309. + outw(index, addr + PCNET32_WIO_RAP);
  28310. + return inw(addr + PCNET32_WIO_RDP);
  28311. +}
  28312. +
  28313. +static void pcnet32_wio_write_csr(unsigned long addr, int index, u16 val)
  28314. +{
  28315. + outw(index, addr + PCNET32_WIO_RAP);
  28316. + outw(val, addr + PCNET32_WIO_RDP);
  28317. +}
  28318. +
  28319. +static u16 pcnet32_wio_read_bcr(unsigned long addr, int index)
  28320. +{
  28321. + outw(index, addr + PCNET32_WIO_RAP);
  28322. + return inw(addr + PCNET32_WIO_BDP);
  28323. +}
  28324. +
  28325. +static void pcnet32_wio_write_bcr(unsigned long addr, int index, u16 val)
  28326. +{
  28327. + outw(index, addr + PCNET32_WIO_RAP);
  28328. + outw(val, addr + PCNET32_WIO_BDP);
  28329. +}
  28330. +
  28331. +static u16 pcnet32_wio_read_rap(unsigned long addr)
  28332. +{
  28333. + return inw(addr + PCNET32_WIO_RAP);
  28334. +}
  28335. +
  28336. +static void pcnet32_wio_write_rap(unsigned long addr, u16 val)
  28337. +{
  28338. + outw(val, addr + PCNET32_WIO_RAP);
  28339. +}
  28340. +
  28341. +static void pcnet32_wio_reset(unsigned long addr)
  28342. +{
  28343. + inw(addr + PCNET32_WIO_RESET);
  28344. +}
  28345. +
  28346. +static int pcnet32_wio_check(unsigned long addr)
  28347. +{
  28348. + outw(88, addr + PCNET32_WIO_RAP);
  28349. + return (inw(addr + PCNET32_WIO_RAP) == 88);
  28350. +}
  28351. +
  28352. +static struct pcnet32_access pcnet32_wio = {
  28353. + read_csr:pcnet32_wio_read_csr,
  28354. + write_csr:pcnet32_wio_write_csr,
  28355. + read_bcr:pcnet32_wio_read_bcr,
  28356. + write_bcr:pcnet32_wio_write_bcr,
  28357. + read_rap:pcnet32_wio_read_rap,
  28358. + write_rap:pcnet32_wio_write_rap,
  28359. + reset:pcnet32_wio_reset
  28360. +};
  28361. +
  28362. +static u16 pcnet32_dwio_read_csr(unsigned long addr, int index)
  28363. +{
  28364. + outl(index, addr + PCNET32_DWIO_RAP);
  28365. + return (inl(addr + PCNET32_DWIO_RDP) & 0xffff);
  28366. +}
  28367. +
  28368. +static void pcnet32_dwio_write_csr(unsigned long addr, int index, u16 val)
  28369. +{
  28370. + outl(index, addr + PCNET32_DWIO_RAP);
  28371. + outl(val, addr + PCNET32_DWIO_RDP);
  28372. +}
  28373. +
  28374. +static u16 pcnet32_dwio_read_bcr(unsigned long addr, int index)
  28375. +{
  28376. + outl(index, addr + PCNET32_DWIO_RAP);
  28377. + return (inl(addr + PCNET32_DWIO_BDP) & 0xffff);
  28378. +}
  28379. +
  28380. +static void pcnet32_dwio_write_bcr(unsigned long addr, int index, u16 val)
  28381. +{
  28382. + outl(index, addr + PCNET32_DWIO_RAP);
  28383. + outl(val, addr + PCNET32_DWIO_BDP);
  28384. +}
  28385. +
  28386. +static u16 pcnet32_dwio_read_rap(unsigned long addr)
  28387. +{
  28388. + return (inl(addr + PCNET32_DWIO_RAP) & 0xffff);
  28389. +}
  28390. +
  28391. +static void pcnet32_dwio_write_rap(unsigned long addr, u16 val)
  28392. +{
  28393. + outl(val, addr + PCNET32_DWIO_RAP);
  28394. +}
  28395. +
  28396. +static void pcnet32_dwio_reset(unsigned long addr)
  28397. +{
  28398. + inl(addr + PCNET32_DWIO_RESET);
  28399. +}
  28400. +
  28401. +static int pcnet32_dwio_check(unsigned long addr)
  28402. +{
  28403. + outl(88, addr + PCNET32_DWIO_RAP);
  28404. + return ((inl(addr + PCNET32_DWIO_RAP) & 0xffff) == 88);
  28405. +}
  28406. +
  28407. +static struct pcnet32_access pcnet32_dwio = {
  28408. + read_csr:pcnet32_dwio_read_csr,
  28409. + write_csr:pcnet32_dwio_write_csr,
  28410. + read_bcr:pcnet32_dwio_read_bcr,
  28411. + write_bcr:pcnet32_dwio_write_bcr,
  28412. + read_rap:pcnet32_dwio_read_rap,
  28413. + write_rap:pcnet32_dwio_write_rap,
  28414. + reset:pcnet32_dwio_reset
  28415. +};
  28416. +
  28417. +
  28418. +/* Initialize the PCNET32 Rx and Tx rings. */
  28419. +static int pcnet32_init_ring(struct nic *nic)
  28420. +{
  28421. + int i;
  28422. +
  28423. + lp->tx_full = 0;
  28424. + lp->cur_rx = lp->cur_tx = 0;
  28425. +
  28426. + for (i = 0; i < RX_RING_SIZE; i++) {
  28427. + rx_ring[i].base = (u32) virt_to_le32desc(&rxb[i]);
  28428. + rx_ring[i].buf_length = le16_to_cpu(-PKT_BUF_SZ);
  28429. + rx_ring[i].status = le16_to_cpu(0x8000);
  28430. + }
  28431. +
  28432. + /* The Tx buffer address is filled in as needed, but we do need to clear
  28433. + the upper ownership bit. */
  28434. + for (i = 0; i < TX_RING_SIZE; i++) {
  28435. + tx_ring[i].base = 0;
  28436. + tx_ring[i].status = 0;
  28437. + }
  28438. +
  28439. +
  28440. + lp->init_block.tlen_rlen =
  28441. + le16_to_cpu(TX_RING_LEN_BITS | RX_RING_LEN_BITS);
  28442. + for (i = 0; i < 6; i++)
  28443. + lp->init_block.phys_addr[i] = nic->node_addr[i];
  28444. + lp->init_block.rx_ring = (u32) virt_to_le32desc(&rx_ring[0]);
  28445. + lp->init_block.tx_ring = (u32) virt_to_le32desc(&tx_ring[0]);
  28446. + return 0;
  28447. +}
  28448. +
  28449. +/**************************************************************************
  28450. +RESET - Reset adapter
  28451. +***************************************************************************/
  28452. +static void pcnet32_reset(struct nic *nic)
  28453. +{
  28454. + /* put the card in its initial state */
  28455. + u16 val;
  28456. + int i;
  28457. +
  28458. + /* Reset the PCNET32 */
  28459. + lp->a.reset(ioaddr);
  28460. +
  28461. + /* switch pcnet32 to 32bit mode */
  28462. + lp->a.write_bcr(ioaddr, 20, 2);
  28463. +
  28464. + /* set/reset autoselect bit */
  28465. + val = lp->a.read_bcr(ioaddr, 2) & ~2;
  28466. + if (lp->options & PCNET32_PORT_ASEL)
  28467. + val |= 2;
  28468. + lp->a.write_bcr(ioaddr, 2, val);
  28469. + /* handle full duplex setting */
  28470. + if (lp->full_duplex) {
  28471. + val = lp->a.read_bcr(ioaddr, 9) & ~3;
  28472. + if (lp->options & PCNET32_PORT_FD) {
  28473. + val |= 1;
  28474. + if (lp->options ==
  28475. + (PCNET32_PORT_FD | PCNET32_PORT_AUI))
  28476. + val |= 2;
  28477. + } else if (lp->options & PCNET32_PORT_ASEL) {
  28478. + /* workaround of xSeries250, turn on for 79C975 only */
  28479. + i = ((lp->a.
  28480. + read_csr(ioaddr,
  28481. + 88) | (lp->a.read_csr(ioaddr,
  28482. + 89) << 16)) >>
  28483. + 12) & 0xffff;
  28484. + if (i == 0x2627)
  28485. + val |= 3;
  28486. + }
  28487. + lp->a.write_bcr(ioaddr, 9, val);
  28488. + }
  28489. +
  28490. + /* set/reset GPSI bit in test register */
  28491. + val = lp->a.read_csr(ioaddr, 124) & ~0x10;
  28492. + if ((lp->options & PCNET32_PORT_PORTSEL) == PCNET32_PORT_GPSI)
  28493. + val |= 0x10;
  28494. + lp->a.write_csr(ioaddr, 124, val);
  28495. +
  28496. + if (lp->mii && !(lp->options & PCNET32_PORT_ASEL)) {
  28497. + val = lp->a.read_bcr(ioaddr, 32) & ~0x38; /* disable Auto Negotiation, set 10Mpbs, HD */
  28498. + if (lp->options & PCNET32_PORT_FD)
  28499. + val |= 0x10;
  28500. + if (lp->options & PCNET32_PORT_100)
  28501. + val |= 0x08;
  28502. + lp->a.write_bcr(ioaddr, 32, val);
  28503. + } else {
  28504. + if (lp->options & PCNET32_PORT_ASEL) { /* enable auto negotiate, setup, disable fd */
  28505. + val = lp->a.read_bcr(ioaddr, 32) & ~0x98;
  28506. + val |= 0x20;
  28507. + lp->a.write_bcr(ioaddr, 32, val);
  28508. + }
  28509. + }
  28510. +
  28511. +#ifdef DO_DXSUFLO
  28512. + if (lp->dxsuflo) { /* Disable transmit stop on underflow */
  28513. + val = lp->a.read_csr(ioaddr, 3);
  28514. + val |= 0x40;
  28515. + lp->a.write_csr(ioaddr, 3, val);
  28516. + }
  28517. +#endif
  28518. +
  28519. + if (lp->ltint) { /* Enable TxDone-intr inhibitor */
  28520. + val = lp->a.read_csr(ioaddr, 5);
  28521. + val |= (1 << 14);
  28522. + lp->a.write_csr(ioaddr, 5, val);
  28523. + }
  28524. + lp->init_block.mode =
  28525. + le16_to_cpu((lp->options & PCNET32_PORT_PORTSEL) << 7);
  28526. + lp->init_block.filter[0] = 0xffffffff;
  28527. + lp->init_block.filter[1] = 0xffffffff;
  28528. +
  28529. + pcnet32_init_ring(nic);
  28530. +
  28531. +
  28532. + /* Re-initialize the PCNET32, and start it when done. */
  28533. + lp->a.write_csr(ioaddr, 1,
  28534. + (virt_to_bus(&lp->init_block)) & 0xffff);
  28535. + lp->a.write_csr(ioaddr, 2, (virt_to_bus(&lp->init_block)) >> 16);
  28536. + lp->a.write_csr(ioaddr, 4, 0x0915);
  28537. + lp->a.write_csr(ioaddr, 0, 0x0001);
  28538. +
  28539. +
  28540. + i = 0;
  28541. + while (i++ < 100)
  28542. + if (lp->a.read_csr(ioaddr, 0) & 0x0100)
  28543. + break;
  28544. + /*
  28545. + * We used to clear the InitDone bit, 0x0100, here but Mark Stockton
  28546. + * reports that doing so triggers a bug in the '974.
  28547. + */
  28548. + lp->a.write_csr(ioaddr, 0, 0x0042);
  28549. +
  28550. + dprintf(("pcnet32 open, csr0 %hX.\n", lp->a.read_csr(ioaddr, 0)));
  28551. +
  28552. +}
  28553. +
  28554. +/**************************************************************************
  28555. +POLL - Wait for a frame
  28556. +***************************************************************************/
  28557. +static int pcnet32_poll(struct nic *nic __unused, int retrieve)
  28558. +{
  28559. + /* return true if there's an ethernet packet ready to read */
  28560. + /* nic->packet should contain data on return */
  28561. + /* nic->packetlen should contain length of data */
  28562. +
  28563. + int status;
  28564. + int entry;
  28565. +
  28566. + entry = lp->cur_rx & RX_RING_MOD_MASK;
  28567. + status = ((short) le16_to_cpu(rx_ring[entry].status) >> 8);
  28568. +
  28569. + if (status < 0)
  28570. + return 0;
  28571. +
  28572. + if ( ! retrieve ) return 1;
  28573. +
  28574. + if (status == 0x03) {
  28575. + nic->packetlen =
  28576. + (le32_to_cpu(rx_ring[entry].msg_length) & 0xfff) - 4;
  28577. + memcpy(nic->packet, &rxb[entry], nic->packetlen);
  28578. +
  28579. + /* Andrew Boyd of QNX reports that some revs of the 79C765
  28580. + * clear the buffer length */
  28581. + rx_ring[entry].buf_length = le16_to_cpu(-PKT_BUF_SZ);
  28582. + rx_ring[entry].status |= le16_to_cpu(0x8000); /* prime for next receive */
  28583. + /* Switch to the next Rx ring buffer */
  28584. + lp->cur_rx++;
  28585. +
  28586. + } else {
  28587. + return 0;
  28588. + }
  28589. +
  28590. + return 1;
  28591. +}
  28592. +
  28593. +/**************************************************************************
  28594. +TRANSMIT - Transmit a frame
  28595. +***************************************************************************/
  28596. +static void pcnet32_transmit(struct nic *nic __unused, const char *d, /* Destination */
  28597. + unsigned int t, /* Type */
  28598. + unsigned int s, /* size */
  28599. + const char *p)
  28600. +{ /* Packet */
  28601. + /* send the packet to destination */
  28602. + unsigned long time;
  28603. + u8 *ptxb;
  28604. + u16 nstype;
  28605. + u16 status;
  28606. + int entry = 0; /*lp->cur_tx & TX_RING_MOD_MASK; */
  28607. +
  28608. + status = 0x8300;
  28609. + /* point to the current txb incase multiple tx_rings are used */
  28610. + ptxb = txb + (lp->cur_tx * PKT_BUF_SZ);
  28611. +
  28612. + /* copy the packet to ring buffer */
  28613. + memcpy(ptxb, d, ETH_ALEN); /* dst */
  28614. + memcpy(ptxb + ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  28615. + nstype = htons((u16) t); /* type */
  28616. + memcpy(ptxb + 2 * ETH_ALEN, (u8 *) & nstype, 2); /* type */
  28617. + memcpy(ptxb + ETH_HLEN, p, s);
  28618. +
  28619. + s += ETH_HLEN;
  28620. + while (s < ETH_ZLEN) /* pad to min length */
  28621. + ptxb[s++] = '\0';
  28622. +
  28623. + tx_ring[entry].length = le16_to_cpu(-s);
  28624. + tx_ring[entry].misc = 0x00000000;
  28625. + tx_ring[entry].base = (u32) virt_to_le32desc(ptxb);
  28626. +
  28627. + /* we set the top byte as the very last thing */
  28628. + tx_ring[entry].status = le16_to_cpu(status);
  28629. +
  28630. +
  28631. + /* Trigger an immediate send poll */
  28632. + lp->a.write_csr(ioaddr, 0, 0x0048);
  28633. +
  28634. + /* wait for transmit complete */
  28635. + lp->cur_tx = 0; /* (lp->cur_tx + 1); */
  28636. + time = currticks() + TICKS_PER_SEC; /* wait one second */
  28637. + while (currticks() < time &&
  28638. + ((short) le16_to_cpu(tx_ring[entry].status) < 0));
  28639. +
  28640. + if ((short) le16_to_cpu(tx_ring[entry].status) < 0)
  28641. + printf("PCNET32 timed out on transmit\n");
  28642. +
  28643. + /* Stop pointing at the current txb
  28644. + * otherwise the card continues to send the packet */
  28645. + tx_ring[entry].base = 0;
  28646. +
  28647. +}
  28648. +
  28649. +/**************************************************************************
  28650. +DISABLE - Turn off ethernet interface
  28651. +***************************************************************************/
  28652. +static void pcnet32_disable(struct dev *dev __unused)
  28653. +{
  28654. + /* Stop the PCNET32 here -- it ocassionally polls memory if we don't */
  28655. + lp->a.write_csr(ioaddr, 0, 0x0004);
  28656. +
  28657. + /*
  28658. + * Switch back to 16-bit mode to avoid problesm with dumb
  28659. + * DOS packet driver after a warm reboot
  28660. + */
  28661. + lp->a.write_bcr(ioaddr, 20, 4);
  28662. +}
  28663. +
  28664. +/**************************************************************************
  28665. +IRQ - Enable, Disable, or Force interrupts
  28666. +***************************************************************************/
  28667. +static void pcnet32_irq(struct nic *nic __unused, irq_action_t action __unused)
  28668. +{
  28669. + switch ( action ) {
  28670. + case DISABLE :
  28671. + break;
  28672. + case ENABLE :
  28673. + break;
  28674. + case FORCE :
  28675. + break;
  28676. + }
  28677. +}
  28678. +
  28679. +/**************************************************************************
  28680. +PROBE - Look for an adapter, this routine's visible to the outside
  28681. +You should omit the last argument struct pci_device * for a non-PCI NIC
  28682. +***************************************************************************/
  28683. +static int pcnet32_probe(struct dev *dev, struct pci_device *pci)
  28684. +{
  28685. + struct nic *nic = (struct nic *) dev;
  28686. + int i, media;
  28687. + int fdx, mii, fset, dxsuflo, ltint;
  28688. + int chip_version;
  28689. + char *chipname;
  28690. + struct pcnet32_access *a = NULL;
  28691. + u8 promaddr[6];
  28692. +
  28693. + int shared = 1;
  28694. + if (pci->ioaddr == 0)
  28695. + return 0;
  28696. +
  28697. + /* BASE is used throughout to address the card */
  28698. + ioaddr = pci->ioaddr;
  28699. + printf("pcnet32.c: Found %s, Vendor=0x%hX Device=0x%hX\n",
  28700. + pci->name, pci->vendor, pci->dev_id);
  28701. +
  28702. + nic->irqno = 0;
  28703. + nic->ioaddr = pci->ioaddr & ~3;
  28704. +
  28705. + /* reset the chip */
  28706. + pcnet32_wio_reset(ioaddr);
  28707. +
  28708. + /* NOTE: 16-bit check is first, otherwise some older PCnet chips fail */
  28709. + if (pcnet32_wio_read_csr(ioaddr, 0) == 4
  28710. + && pcnet32_wio_check(ioaddr)) {
  28711. + a = &pcnet32_wio;
  28712. + } else {
  28713. + pcnet32_dwio_reset(ioaddr);
  28714. + if (pcnet32_dwio_read_csr(ioaddr, 0) == 4
  28715. + && pcnet32_dwio_check(ioaddr)) {
  28716. + a = &pcnet32_dwio;
  28717. + } else
  28718. + return 0;
  28719. + }
  28720. +
  28721. + chip_version =
  28722. + a->read_csr(ioaddr, 88) | (a->read_csr(ioaddr, 89) << 16);
  28723. +
  28724. + dprintf(("PCnet chip version is %0xhX\n", chip_version));
  28725. + if ((chip_version & 0xfff) != 0x003)
  28726. + return 0;
  28727. +
  28728. + /* initialize variables */
  28729. + fdx = mii = fset = dxsuflo = ltint = 0;
  28730. + chip_version = (chip_version >> 12) & 0xffff;
  28731. +
  28732. + switch (chip_version) {
  28733. + case 0x2420:
  28734. + chipname = "PCnet/PCI 79C970"; /* PCI */
  28735. + break;
  28736. + case 0x2430:
  28737. + if (shared)
  28738. + chipname = "PCnet/PCI 79C970"; /* 970 gives the wrong chip id back */
  28739. + else
  28740. + chipname = "PCnet/32 79C965"; /* 486/VL bus */
  28741. + break;
  28742. + case 0x2621:
  28743. + chipname = "PCnet/PCI II 79C970A"; /* PCI */
  28744. + fdx = 1;
  28745. + break;
  28746. + case 0x2623:
  28747. + chipname = "PCnet/FAST 79C971"; /* PCI */
  28748. + fdx = 1;
  28749. + mii = 1;
  28750. + fset = 1;
  28751. + ltint = 1;
  28752. + break;
  28753. + case 0x2624:
  28754. + chipname = "PCnet/FAST+ 79C972"; /* PCI */
  28755. + fdx = 1;
  28756. + mii = 1;
  28757. + fset = 1;
  28758. + break;
  28759. + case 0x2625:
  28760. + chipname = "PCnet/FAST III 79C973"; /* PCI */
  28761. + fdx = 1;
  28762. + mii = 1;
  28763. + break;
  28764. + case 0x2626:
  28765. + chipname = "PCnet/Home 79C978"; /* PCI */
  28766. + fdx = 1;
  28767. + /*
  28768. + * This is based on specs published at www.amd.com. This section
  28769. + * assumes that a card with a 79C978 wants to go into 1Mb HomePNA
  28770. + * mode. The 79C978 can also go into standard ethernet, and there
  28771. + * probably should be some sort of module option to select the
  28772. + * mode by which the card should operate
  28773. + */
  28774. + /* switch to home wiring mode */
  28775. + media = a->read_bcr(ioaddr, 49);
  28776. +
  28777. + printf("media reset to %#x.\n", media);
  28778. + a->write_bcr(ioaddr, 49, media);
  28779. + break;
  28780. + case 0x2627:
  28781. + chipname = "PCnet/FAST III 79C975"; /* PCI */
  28782. + fdx = 1;
  28783. + mii = 1;
  28784. + break;
  28785. + default:
  28786. + printf("PCnet version %#x, no PCnet32 chip.\n",
  28787. + chip_version);
  28788. + return 0;
  28789. + }
  28790. +
  28791. + /*
  28792. + * On selected chips turn on the BCR18:NOUFLO bit. This stops transmit
  28793. + * starting until the packet is loaded. Strike one for reliability, lose
  28794. + * one for latency - although on PCI this isnt a big loss. Older chips
  28795. + * have FIFO's smaller than a packet, so you can't do this.
  28796. + */
  28797. +
  28798. + if (fset) {
  28799. + a->write_bcr(ioaddr, 18,
  28800. + (a->read_bcr(ioaddr, 18) | 0x0800));
  28801. + a->write_csr(ioaddr, 80,
  28802. + (a->read_csr(ioaddr, 80) & 0x0C00) | 0x0c00);
  28803. + dxsuflo = 1;
  28804. + ltint = 1;
  28805. + }
  28806. +
  28807. + dprintf(("%s at %hX,", chipname, ioaddr));
  28808. +
  28809. + /* read PROM address */
  28810. + for (i = 0; i < 6; i++)
  28811. + promaddr[i] = inb(ioaddr + i);
  28812. +
  28813. + /* Update the nic structure with the MAC Address */
  28814. + for (i = 0; i < ETH_ALEN; i++) {
  28815. + nic->node_addr[i] = promaddr[i];
  28816. + }
  28817. + /* Print out some hardware info */
  28818. + printf("%s: %! at ioaddr %hX, ", pci->name, nic->node_addr,
  28819. + ioaddr);
  28820. +
  28821. + /* Set to pci bus master */
  28822. + adjust_pci_device(pci);
  28823. +
  28824. + /* point to private storage */
  28825. + lp = &lpx;
  28826. +
  28827. +#if EBDEBUG
  28828. + if (((chip_version + 1) & 0xfffe) == 0x2624) { /* Version 0x2623 or 0x2624 */
  28829. + i = a->read_csr(ioaddr, 80) & 0x0C00; /* Check tx_start_pt */
  28830. + dprintf((" tx_start_pt(0x%hX):", i));
  28831. + switch (i >> 10) {
  28832. + case 0:
  28833. + dprintf((" 20 bytes,"));
  28834. + break;
  28835. + case 1:
  28836. + dprintf((" 64 bytes,"));
  28837. + break;
  28838. + case 2:
  28839. + dprintf((" 128 bytes,"));
  28840. + break;
  28841. + case 3:
  28842. + dprintf(("~220 bytes,"));
  28843. + break;
  28844. + }
  28845. + i = a->read_bcr(ioaddr, 18); /* Check Burst/Bus control */
  28846. + dprintf((" BCR18(%hX):", i & 0xffff));
  28847. + if (i & (1 << 5))
  28848. + dprintf(("BurstWrEn "));
  28849. + if (i & (1 << 6))
  28850. + dprintf(("BurstRdEn "));
  28851. + if (i & (1 << 7))
  28852. + dprintf(("DWordIO "));
  28853. + if (i & (1 << 11))
  28854. + dprintf(("NoUFlow "));
  28855. + i = a->read_bcr(ioaddr, 25);
  28856. + dprintf((" SRAMSIZE=0x%hX,", i << 8));
  28857. + i = a->read_bcr(ioaddr, 26);
  28858. + dprintf((" SRAM_BND=0x%hX,", i << 8));
  28859. + i = a->read_bcr(ioaddr, 27);
  28860. + if (i & (1 << 14))
  28861. + dprintf(("LowLatRx"));
  28862. + }
  28863. +#endif
  28864. + lp->name = chipname;
  28865. + lp->shared_irq = shared;
  28866. + lp->full_duplex = fdx;
  28867. + lp->dxsuflo = dxsuflo;
  28868. + lp->ltint = ltint;
  28869. + lp->mii = mii;
  28870. + /* FIXME: Fix Options for only one card */
  28871. + if ((cards_found >= MAX_UNITS)
  28872. + || ((unsigned int) options[cards_found] > sizeof(options_mapping)))
  28873. + lp->options = PCNET32_PORT_ASEL;
  28874. + else
  28875. + lp->options = options_mapping[options[cards_found]];
  28876. +
  28877. + if (fdx && !(lp->options & PCNET32_PORT_ASEL) &&
  28878. + ((cards_found >= MAX_UNITS) || full_duplex[cards_found]))
  28879. + lp->options |= PCNET32_PORT_FD;
  28880. +
  28881. + if (!a) {
  28882. + printf("No access methods\n");
  28883. + return 0;
  28884. + }
  28885. + lp->a = *a;
  28886. +
  28887. + /* detect special T1/E1 WAN card by checking for MAC address */
  28888. + if (nic->node_addr[0] == 0x00 && nic->node_addr[1] == 0xe0
  28889. + && nic->node_addr[2] == 0x75)
  28890. + lp->options = PCNET32_PORT_FD | PCNET32_PORT_GPSI;
  28891. +
  28892. + lp->init_block.mode = le16_to_cpu(0x0003); /* Disable Rx and Tx. */
  28893. + lp->init_block.tlen_rlen =
  28894. + le16_to_cpu(TX_RING_LEN_BITS | RX_RING_LEN_BITS);
  28895. + for (i = 0; i < 6; i++)
  28896. + lp->init_block.phys_addr[i] = nic->node_addr[i];
  28897. + lp->init_block.filter[0] = 0xffffffff;
  28898. + lp->init_block.filter[1] = 0xffffffff;
  28899. + lp->init_block.rx_ring = virt_to_bus(&rx_ring);
  28900. + lp->init_block.tx_ring = virt_to_bus(&tx_ring);
  28901. +
  28902. + /* switch pcnet32 to 32bit mode */
  28903. + a->write_bcr(ioaddr, 20, 2);
  28904. +
  28905. +
  28906. + a->write_csr(ioaddr, 1, (virt_to_bus(&lp->init_block)) & 0xffff);
  28907. + a->write_csr(ioaddr, 2, (virt_to_bus(&lp->init_block)) >> 16);
  28908. +
  28909. + /*
  28910. + * To auto-IRQ we enable the initialization-done and DMA error
  28911. + * interrupts. For ISA boards we get a DMA error, but VLB and PCI
  28912. + * boards will work.
  28913. + */
  28914. + /* Trigger an initialization just for the interrupt. */
  28915. +
  28916. + a->write_csr(ioaddr, 0, 0x41);
  28917. + mdelay(1);
  28918. +
  28919. + cards_found++;
  28920. +
  28921. + /* point to NIC specific routines */
  28922. + pcnet32_reset(nic);
  28923. + if (1) {
  28924. + int tmp;
  28925. + int phy, phy_idx = 0;
  28926. + u16 mii_lpa;
  28927. + lp->phys[0] = 1; /* Default Setting */
  28928. + for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) {
  28929. + int mii_status = mdio_read(nic, phy, MII_BMSR);
  28930. + if (mii_status != 0xffff && mii_status != 0x0000) {
  28931. + lp->phys[phy_idx++] = phy;
  28932. + lp->mii_if.advertising =
  28933. + mdio_read(nic, phy, MII_ADVERTISE);
  28934. + if ((mii_status & 0x0040) == 0) {
  28935. + tmp = phy;
  28936. + dprintf (("MII PHY found at address %d, status "
  28937. + "%hX advertising %hX\n", phy, mii_status,
  28938. + lp->mii_if.advertising));
  28939. + }
  28940. + }
  28941. + }
  28942. + if (phy_idx == 0)
  28943. + printf("No MII transceiver found!\n");
  28944. + lp->mii_if.phy_id = lp->phys[0];
  28945. +
  28946. + lp->mii_if.advertising =
  28947. + mdio_read(nic, lp->phys[0], MII_ADVERTISE);
  28948. +
  28949. + mii_lpa = mdio_read(nic, lp->phys[0], MII_LPA);
  28950. + lp->mii_if.advertising &= mii_lpa;
  28951. + if (lp->mii_if.advertising & ADVERTISE_100FULL)
  28952. + printf("100Mbps Full-Duplex\n");
  28953. + else if (lp->mii_if.advertising & ADVERTISE_100HALF)
  28954. + printf("100Mbps Half-Duplex\n");
  28955. + else if (lp->mii_if.advertising & ADVERTISE_10FULL)
  28956. + printf("10Mbps Full-Duplex\n");
  28957. + else if (lp->mii_if.advertising & ADVERTISE_10HALF)
  28958. + printf("10Mbps Half-Duplex\n");
  28959. + else
  28960. + printf("\n");
  28961. + }
  28962. +
  28963. + nic->poll = pcnet32_poll;
  28964. + nic->transmit = pcnet32_transmit;
  28965. + dev->disable = pcnet32_disable;
  28966. + nic->irq = pcnet32_irq;
  28967. +
  28968. + return 1;
  28969. +}
  28970. +static int mdio_read(struct nic *nic __unused, int phy_id, int reg_num)
  28971. +{
  28972. + u16 val_out;
  28973. + int phyaddr;
  28974. +
  28975. + if (!lp->mii)
  28976. + return 0;
  28977. +
  28978. + phyaddr = lp->a.read_bcr(ioaddr, 33);
  28979. +
  28980. + lp->a.write_bcr(ioaddr, 33,
  28981. + ((phy_id & 0x1f) << 5) | (reg_num & 0x1f));
  28982. + val_out = lp->a.read_bcr(ioaddr, 34);
  28983. + lp->a.write_bcr(ioaddr, 33, phyaddr);
  28984. +
  28985. + return val_out;
  28986. +}
  28987. +
  28988. +#if 0
  28989. +static void mdio_write(struct nic *nic __unused, int phy_id, int reg_num,
  28990. + int val)
  28991. +{
  28992. + int phyaddr;
  28993. +
  28994. + if (!lp->mii)
  28995. + return;
  28996. +
  28997. + phyaddr = lp->a.read_bcr(ioaddr, 33);
  28998. +
  28999. + lp->a.write_bcr(ioaddr, 33,
  29000. + ((phy_id & 0x1f) << 5) | (reg_num & 0x1f));
  29001. + lp->a.write_bcr(ioaddr, 34, val);
  29002. + lp->a.write_bcr(ioaddr, 33, phyaddr);
  29003. +}
  29004. +#endif
  29005. +
  29006. +static struct pci_id pcnet32_nics[] = {
  29007. + PCI_ROM(0x1022, 0x2000, "lancepci", "AMD Lance/PCI"),
  29008. + PCI_ROM(0x1022, 0x2625, "pcnetfastiii", "AMD Lance/PCI PCNet/32"),
  29009. + PCI_ROM(0x1022, 0x2001, "amdhomepna", "AMD Lance/HomePNA"),
  29010. +};
  29011. +
  29012. +struct pci_driver pcnet32_driver = {
  29013. + .type = NIC_DRIVER,
  29014. + .name = "PCNET32/PCI",
  29015. + .probe = pcnet32_probe,
  29016. + .ids = pcnet32_nics,
  29017. + .id_count = sizeof(pcnet32_nics) / sizeof(pcnet32_nics[0]),
  29018. + .class = 0,
  29019. +};
  29020. Index: b/netboot/pic8259.c
  29021. ===================================================================
  29022. --- /dev/null
  29023. +++ b/netboot/pic8259.c
  29024. @@ -0,0 +1,267 @@
  29025. +/*
  29026. + * Basic support for controlling the 8259 Programmable Interrupt Controllers.
  29027. + *
  29028. + * Initially written by Michael Brown (mcb30).
  29029. + */
  29030. +
  29031. +#include <etherboot.h>
  29032. +#include <pic8259.h>
  29033. +
  29034. +#ifdef DEBUG_IRQ
  29035. +#define DBG(...) printf ( __VA_ARGS__ )
  29036. +#else
  29037. +#define DBG(...)
  29038. +#endif
  29039. +
  29040. +/* Current locations of trivial IRQ handler. These will change at
  29041. + * runtime when relocation is used; the handler needs to be copied to
  29042. + * base memory before being installed.
  29043. + */
  29044. +void (*trivial_irq_handler)P((void)) = _trivial_irq_handler;
  29045. +uint16_t volatile *trivial_irq_trigger_count = &_trivial_irq_trigger_count;
  29046. +segoff_t *trivial_irq_chain_to = &_trivial_irq_chain_to;
  29047. +uint8_t *trivial_irq_chain = &_trivial_irq_chain;
  29048. +irq_t trivial_irq_installed_on = IRQ_NONE;
  29049. +
  29050. +/* Previous trigger count for trivial IRQ handler */
  29051. +static uint16_t trivial_irq_previous_trigger_count = 0;
  29052. +
  29053. +/* Install a handler for the specified IRQ. Address of previous
  29054. + * handler will be stored in previous_handler. Enabled/disabled state
  29055. + * of IRQ will be preserved across call, therefore if the handler does
  29056. + * chaining, ensure that either (a) IRQ is disabled before call, or
  29057. + * (b) previous_handler points directly to the place that the handler
  29058. + * picks up its chain-to address.
  29059. + */
  29060. +
  29061. +int install_irq_handler ( irq_t irq, segoff_t *handler,
  29062. + uint8_t *previously_enabled,
  29063. + segoff_t *previous_handler ) {
  29064. + segoff_t *irq_vector = IRQ_VECTOR ( irq );
  29065. + *previously_enabled = irq_enabled ( irq );
  29066. +
  29067. + if ( irq > IRQ_MAX ) {
  29068. + DBG ( "Invalid IRQ number %d\n" );
  29069. + return 0;
  29070. + }
  29071. +
  29072. + previous_handler->segment = irq_vector->segment;
  29073. + previous_handler->offset = irq_vector->offset;
  29074. + if ( *previously_enabled ) disable_irq ( irq );
  29075. + DBG ( "Installing handler at %hx:%hx for IRQ %d, leaving %s\n",
  29076. + handler->segment, handler->offset, irq,
  29077. + ( *previously_enabled ? "enabled" : "disabled" ) );
  29078. + DBG ( "...(previous handler at %hx:%hx)\n",
  29079. + previous_handler->segment, previous_handler->offset );
  29080. + irq_vector->segment = handler->segment;
  29081. + irq_vector->offset = handler->offset;
  29082. + if ( *previously_enabled ) enable_irq ( irq );
  29083. + return 1;
  29084. +}
  29085. +
  29086. +/* Remove handler for the specified IRQ. Routine checks that another
  29087. + * handler has not been installed that chains to handler before
  29088. + * uninstalling handler. Enabled/disabled state of the IRQ will be
  29089. + * restored to that specified by previously_enabled.
  29090. + */
  29091. +
  29092. +int remove_irq_handler ( irq_t irq, segoff_t *handler,
  29093. + uint8_t *previously_enabled,
  29094. + segoff_t *previous_handler ) {
  29095. + segoff_t *irq_vector = IRQ_VECTOR ( irq );
  29096. +
  29097. + if ( irq > IRQ_MAX ) {
  29098. + DBG ( "Invalid IRQ number %d\n" );
  29099. + return 0;
  29100. + }
  29101. + if ( ( irq_vector->segment != handler->segment ) ||
  29102. + ( irq_vector->offset != handler->offset ) ) {
  29103. + DBG ( "Cannot remove handler for IRQ %d\n" );
  29104. + return 0;
  29105. + }
  29106. +
  29107. + DBG ( "Removing handler for IRQ %d\n", irq );
  29108. + disable_irq ( irq );
  29109. + irq_vector->segment = previous_handler->segment;
  29110. + irq_vector->offset = previous_handler->offset;
  29111. + if ( *previously_enabled ) enable_irq ( irq );
  29112. + return 1;
  29113. +}
  29114. +
  29115. +/* Install the trivial IRQ handler. This routine installs the
  29116. + * handler, tests it and enables the IRQ.
  29117. + */
  29118. +
  29119. +int install_trivial_irq_handler ( irq_t irq ) {
  29120. + segoff_t trivial_irq_handler_segoff = SEGOFF(trivial_irq_handler);
  29121. +
  29122. + if ( trivial_irq_installed_on != IRQ_NONE ) {
  29123. + DBG ( "Can install trivial IRQ handler only once\n" );
  29124. + return 0;
  29125. + }
  29126. + if ( SEGMENT(trivial_irq_handler) > 0xffff ) {
  29127. + DBG ( "Trivial IRQ handler not in base memory\n" );
  29128. + return 0;
  29129. + }
  29130. +
  29131. + DBG ( "Installing trivial IRQ handler on IRQ %d\n", irq );
  29132. + if ( ! install_irq_handler ( irq, &trivial_irq_handler_segoff,
  29133. + trivial_irq_chain,
  29134. + trivial_irq_chain_to ) )
  29135. + return 0;
  29136. + trivial_irq_installed_on = irq;
  29137. +
  29138. + DBG ( "Testing trivial IRQ handler\n" );
  29139. + disable_irq ( irq );
  29140. + *trivial_irq_trigger_count = 0;
  29141. + trivial_irq_previous_trigger_count = 0;
  29142. + fake_irq ( irq );
  29143. + if ( ! trivial_irq_triggered ( irq ) ) {
  29144. + DBG ( "Installation of trivial IRQ handler failed\n" );
  29145. + remove_trivial_irq_handler ( irq );
  29146. + return 0;
  29147. + }
  29148. + DBG ( "Trivial IRQ handler installed successfully\n" );
  29149. + enable_irq ( irq );
  29150. + return 1;
  29151. +}
  29152. +
  29153. +/* Remove the trivial IRQ handler.
  29154. + */
  29155. +
  29156. +int remove_trivial_irq_handler ( irq_t irq ) {
  29157. + segoff_t trivial_irq_handler_segoff = SEGOFF(trivial_irq_handler);
  29158. +
  29159. + if ( trivial_irq_installed_on == IRQ_NONE ) return 1;
  29160. + if ( irq != trivial_irq_installed_on ) {
  29161. + DBG ( "Cannot uninstall trivial IRQ handler from IRQ %d; "
  29162. + "is installed on IRQ %d\n", irq,
  29163. + trivial_irq_installed_on );
  29164. + return 0;
  29165. + }
  29166. +
  29167. + if ( ! remove_irq_handler ( irq, &trivial_irq_handler_segoff,
  29168. + trivial_irq_chain,
  29169. + trivial_irq_chain_to ) )
  29170. + return 0;
  29171. +
  29172. + if ( trivial_irq_triggered ( trivial_irq_installed_on ) ) {
  29173. + DBG ( "Sending EOI for unwanted trivial IRQ\n" );
  29174. + send_specific_eoi ( trivial_irq_installed_on );
  29175. + }
  29176. +
  29177. + trivial_irq_installed_on = IRQ_NONE;
  29178. + return 1;
  29179. +}
  29180. +
  29181. +/* Safe method to detect whether or not trivial IRQ has been
  29182. + * triggered. Using this call avoids potential race conditions. This
  29183. + * call will return success only once per trigger.
  29184. + */
  29185. +
  29186. +int trivial_irq_triggered ( irq_t irq ) {
  29187. + uint16_t trivial_irq_this_trigger_count = *trivial_irq_trigger_count;
  29188. + int triggered = ( trivial_irq_this_trigger_count -
  29189. + trivial_irq_previous_trigger_count );
  29190. +
  29191. + /* irq is not used at present, but we have it in the API for
  29192. + * future-proofing; in case we want the facility to have
  29193. + * multiple trivial IRQ handlers installed simultaneously.
  29194. + *
  29195. + * Avoid compiler warning about unused variable.
  29196. + */
  29197. + if ( irq == IRQ_NONE ) {};
  29198. +
  29199. + trivial_irq_previous_trigger_count = trivial_irq_this_trigger_count;
  29200. + return triggered ? 1 : 0;
  29201. +}
  29202. +
  29203. +/* Copy trivial IRQ handler to a new location. Typically used to copy
  29204. + * the handler into base memory; when relocation is being used we need
  29205. + * to do this before installing the handler.
  29206. + *
  29207. + * Call with target=NULL in order to restore the handler to its
  29208. + * original location.
  29209. + */
  29210. +
  29211. +int copy_trivial_irq_handler ( void *target, size_t target_size ) {
  29212. + irq_t currently_installed_on = trivial_irq_installed_on;
  29213. + uint32_t offset = ( target == NULL ? 0 :
  29214. + target - &_trivial_irq_handler_start );
  29215. +
  29216. + if (( target != NULL ) && ( target_size < TRIVIAL_IRQ_HANDLER_SIZE )) {
  29217. + DBG ( "Insufficient space to copy trivial IRQ handler\n" );
  29218. + return 0;
  29219. + }
  29220. +
  29221. + if ( currently_installed_on != IRQ_NONE ) {
  29222. + DBG ("WARNING: relocating trivial IRQ handler while in use\n");
  29223. + if ( ! remove_trivial_irq_handler ( currently_installed_on ) )
  29224. + return 0;
  29225. + }
  29226. +
  29227. + /* Do the actual copy */
  29228. + if ( target != NULL ) {
  29229. + DBG ( "Copying trivial IRQ handler to %hx:%hx\n",
  29230. + SEGMENT(target), OFFSET(target) );
  29231. + memcpy ( target, &_trivial_irq_handler_start,
  29232. + TRIVIAL_IRQ_HANDLER_SIZE );
  29233. + } else {
  29234. + DBG ( "Restoring trivial IRQ handler to original location\n" );
  29235. + }
  29236. + /* Update all the pointers to structures within the handler */
  29237. + trivial_irq_handler = ( void (*)P((void)) )
  29238. + ( (void*)_trivial_irq_handler + offset );
  29239. + trivial_irq_trigger_count = (uint16_t*)
  29240. + ( (void*)&_trivial_irq_trigger_count + offset );
  29241. + trivial_irq_chain_to = (segoff_t*)
  29242. + ( (void*)&_trivial_irq_chain_to + offset );
  29243. + trivial_irq_chain = (uint8_t*)
  29244. + ( (void*)&_trivial_irq_chain + offset );
  29245. +
  29246. + if ( currently_installed_on != IRQ_NONE ) {
  29247. + if ( ! install_trivial_irq_handler ( currently_installed_on ) )
  29248. + return 0;
  29249. + }
  29250. + return 1;
  29251. +}
  29252. +
  29253. +/* Send non-specific EOI(s). This seems to be inherently unsafe.
  29254. + */
  29255. +
  29256. +void send_nonspecific_eoi ( irq_t irq ) {
  29257. + DBG ( "Sending non-specific EOI for IRQ %d\n", irq );
  29258. + if ( irq >= IRQ_PIC_CUTOFF ) {
  29259. + outb ( ICR_EOI_NON_SPECIFIC, PIC2_ICR );
  29260. + }
  29261. + outb ( ICR_EOI_NON_SPECIFIC, PIC1_ICR );
  29262. +}
  29263. +
  29264. +/* Send specific EOI(s).
  29265. + */
  29266. +
  29267. +void send_specific_eoi ( irq_t irq ) {
  29268. + DBG ( "Sending specific EOI for IRQ %d\n", irq );
  29269. + outb ( ICR_EOI_SPECIFIC | ICR_VALUE(irq), ICR_REG(irq) );
  29270. + if ( irq >= IRQ_PIC_CUTOFF ) {
  29271. + outb ( ICR_EOI_SPECIFIC | ICR_VALUE(CHAINED_IRQ),
  29272. + ICR_REG(CHAINED_IRQ) );
  29273. + }
  29274. +}
  29275. +
  29276. +/* Dump current 8259 status: enabled IRQs and handler addresses.
  29277. + */
  29278. +
  29279. +#ifdef DEBUG_IRQ
  29280. +void dump_irq_status ( void ) {
  29281. + int irq = 0;
  29282. +
  29283. + for ( irq = 0; irq < 16; irq++ ) {
  29284. + if ( irq_enabled ( irq ) ) {
  29285. + printf ( "IRQ%d enabled, ISR at %hx:%hx\n", irq,
  29286. + IRQ_VECTOR(irq)->segment,
  29287. + IRQ_VECTOR(irq)->offset );
  29288. + }
  29289. + }
  29290. +}
  29291. +#endif
  29292. Index: b/netboot/pic8259.h
  29293. ===================================================================
  29294. --- /dev/null
  29295. +++ b/netboot/pic8259.h
  29296. @@ -0,0 +1,99 @@
  29297. +/*
  29298. + * Basic support for controlling the 8259 Programmable Interrupt Controllers.
  29299. + *
  29300. + * Initially written by Michael Brown (mcb30).
  29301. + */
  29302. +
  29303. +#ifndef PIC8259_H
  29304. +#define PIC8259_H
  29305. +
  29306. +/* For segoff_t */
  29307. +#include <segoff.h>
  29308. +
  29309. +#define IRQ_PIC_CUTOFF (8)
  29310. +
  29311. +/* 8259 register locations */
  29312. +#define PIC1_ICW1 (0x20)
  29313. +#define PIC1_OCW2 (0x20)
  29314. +#define PIC1_OCW3 (0x20)
  29315. +#define PIC1_ICR (0x20)
  29316. +#define PIC1_IRR (0x20)
  29317. +#define PIC1_ISR (0x20)
  29318. +#define PIC1_ICW2 (0x21)
  29319. +#define PIC1_ICW3 (0x21)
  29320. +#define PIC1_ICW4 (0x21)
  29321. +#define PIC1_IMR (0x21)
  29322. +#define PIC2_ICW1 (0xa0)
  29323. +#define PIC2_OCW2 (0xa0)
  29324. +#define PIC2_OCW3 (0xa0)
  29325. +#define PIC2_ICR (0xa0)
  29326. +#define PIC2_IRR (0xa0)
  29327. +#define PIC2_ISR (0xa0)
  29328. +#define PIC2_ICW2 (0xa1)
  29329. +#define PIC2_ICW3 (0xa1)
  29330. +#define PIC2_ICW4 (0xa1)
  29331. +#define PIC2_IMR (0xa1)
  29332. +
  29333. +/* Register command values */
  29334. +#define OCW3_ID (0x08)
  29335. +#define OCW3_READ_IRR (0x03)
  29336. +#define OCW3_READ_ISR (0x02)
  29337. +#define ICR_EOI_NON_SPECIFIC (0x20)
  29338. +#define ICR_EOI_NOP (0x40)
  29339. +#define ICR_EOI_SPECIFIC (0x60)
  29340. +#define ICR_EOI_SET_PRIORITY (0xc0)
  29341. +
  29342. +/* Macros to enable/disable IRQs */
  29343. +#define IMR_REG(x) ( (x) < IRQ_PIC_CUTOFF ? PIC1_IMR : PIC2_IMR )
  29344. +#define IMR_BIT(x) ( 1 << ( (x) % IRQ_PIC_CUTOFF ) )
  29345. +#define irq_enabled(x) ( ( inb ( IMR_REG(x) ) & IMR_BIT(x) ) == 0 )
  29346. +#define enable_irq(x) outb ( inb( IMR_REG(x) ) & ~IMR_BIT(x), IMR_REG(x) )
  29347. +#define disable_irq(x) outb ( inb( IMR_REG(x) ) | IMR_BIT(x), IMR_REG(x) )
  29348. +
  29349. +/* Macros for acknowledging IRQs */
  29350. +#define ICR_REG(x) ( (x) < IRQ_PIC_CUTOFF ? PIC1_ICR : PIC2_ICR )
  29351. +#define ICR_VALUE(x) ( (x) % IRQ_PIC_CUTOFF )
  29352. +#define CHAINED_IRQ 2
  29353. +
  29354. +/* Utility macros to convert IRQ numbers to INT numbers and INT vectors */
  29355. +#define IRQ_INT(x) ( (x)<IRQ_PIC_CUTOFF ? (x)+0x08 : (x)-IRQ_PIC_CUTOFF+0x70 )
  29356. +#define INT_VECTOR(x) ( (segoff_t*) phys_to_virt( 4 * (x) ) )
  29357. +#define IRQ_VECTOR(x) ( INT_VECTOR ( IRQ_INT(x) ) )
  29358. +
  29359. +/* Other constants */
  29360. +typedef uint8_t irq_t;
  29361. +#define IRQ_MAX (15)
  29362. +#define IRQ_NONE (0xff)
  29363. +
  29364. +/* Labels in assembly code (in pcbios.S)
  29365. + */
  29366. +extern void _trivial_irq_handler_start;
  29367. +extern void _trivial_irq_handler ( void );
  29368. +extern volatile uint16_t _trivial_irq_trigger_count;
  29369. +extern segoff_t _trivial_irq_chain_to;
  29370. +extern uint8_t _trivial_irq_chain;
  29371. +extern void _trivial_irq_handler_end;
  29372. +#define TRIVIAL_IRQ_HANDLER_SIZE \
  29373. + ((uint32_t)( &_trivial_irq_handler_end - &_trivial_irq_handler_start ))
  29374. +
  29375. +/* Function prototypes
  29376. + */
  29377. +int install_irq_handler ( irq_t irq, segoff_t *handler,
  29378. + uint8_t *previously_enabled,
  29379. + segoff_t *previous_handler );
  29380. +int remove_irq_handler ( irq_t irq, segoff_t *handler,
  29381. + uint8_t *previously_enabled,
  29382. + segoff_t *previous_handler );
  29383. +int install_trivial_irq_handler ( irq_t irq );
  29384. +int remove_trivial_irq_handler ( irq_t irq );
  29385. +int trivial_irq_triggered ( irq_t irq );
  29386. +int copy_trivial_irq_handler ( void *target, size_t target_size );
  29387. +void send_non_specific_eoi ( irq_t irq );
  29388. +void send_specific_eoi ( irq_t irq );
  29389. +#ifdef DEBUG_IRQ
  29390. +void dump_irq_status ( void );
  29391. +#else
  29392. +#define dump_irq_status()
  29393. +#endif
  29394. +
  29395. +#endif /* PIC8259_H */
  29396. Index: b/netboot/pnic.c
  29397. ===================================================================
  29398. --- /dev/null
  29399. +++ b/netboot/pnic.c
  29400. @@ -0,0 +1,267 @@
  29401. +/**************************************************************************
  29402. +Etherboot - BOOTP/TFTP Bootstrap Program
  29403. +Bochs Pseudo NIC driver for Etherboot
  29404. +***************************************************************************/
  29405. +
  29406. +/*
  29407. + * This program is free software; you can redistribute it and/or
  29408. + * modify it under the terms of the GNU General Public License as
  29409. + * published by the Free Software Foundation; either version 2, or (at
  29410. + * your option) any later version.
  29411. + *
  29412. + * See pnic_api.h for an explanation of the Bochs Pseudo NIC.
  29413. + */
  29414. +
  29415. +/* to get some global routines like printf */
  29416. +#include "etherboot.h"
  29417. +/* to get the interface to the body of the program */
  29418. +#include "nic.h"
  29419. +/* to get the PCI support functions, if this is a PCI NIC */
  29420. +#include "pci.h"
  29421. +
  29422. +/* PNIC API */
  29423. +#include "pnic_api.h"
  29424. +
  29425. +/* Private data structure */
  29426. +typedef struct {
  29427. + uint16_t api_version;
  29428. +} pnic_priv_data_t;
  29429. +
  29430. +/* Function prototypes */
  29431. +static int pnic_api_check ( uint16_t api_version );
  29432. +
  29433. +/* NIC specific static variables go here */
  29434. +static uint8_t tx_buffer[ETH_FRAME_LEN];
  29435. +
  29436. +/*
  29437. + * Utility functions: issue a PNIC command, retrieve result. Use
  29438. + * pnic_command_quiet if you don't want failure codes to be
  29439. + * automatically printed. Returns the PNIC status code.
  29440. + *
  29441. + * Set output_length to NULL only if you expect to receive exactly
  29442. + * output_max_length bytes, otherwise it'll complain that you didn't
  29443. + * get enough data (on the assumption that if you not interested in
  29444. + * discovering the output length then you're expecting a fixed amount
  29445. + * of data).
  29446. + */
  29447. +
  29448. +static uint16_t pnic_command_quiet ( struct nic *nic, uint16_t command,
  29449. + void *input, uint16_t input_length,
  29450. + void *output, uint16_t output_max_length,
  29451. + uint16_t *output_length ) {
  29452. + int i;
  29453. + uint16_t status;
  29454. + uint16_t _output_length;
  29455. +
  29456. + if ( input != NULL ) {
  29457. + /* Write input length */
  29458. + outw ( input_length, nic->ioaddr + PNIC_REG_LEN );
  29459. + /* Write input data */
  29460. + for ( i = 0; i < input_length; i++ ) {
  29461. + outb( ((char*)input)[i], nic->ioaddr + PNIC_REG_DATA );
  29462. + }
  29463. + }
  29464. + /* Write command */
  29465. + outw ( command, nic->ioaddr + PNIC_REG_CMD );
  29466. + /* Retrieve status */
  29467. + status = inw ( nic->ioaddr + PNIC_REG_STAT );
  29468. + /* Retrieve output length */
  29469. + _output_length = inw ( nic->ioaddr + PNIC_REG_LEN );
  29470. + if ( output_length == NULL ) {
  29471. + if ( _output_length != output_max_length ) {
  29472. + printf ( "pnic_command %#hx: wrong data length "
  29473. + "returned (expected %d, got %d)\n", command,
  29474. + output_max_length, _output_length );
  29475. + }
  29476. + } else {
  29477. + *output_length = _output_length;
  29478. + }
  29479. + if ( output != NULL ) {
  29480. + if ( _output_length > output_max_length ) {
  29481. + printf ( "pnic_command %#hx: output buffer too small "
  29482. + "(have %d, need %d)\n", command,
  29483. + output_max_length, _output_length );
  29484. + _output_length = output_max_length;
  29485. + }
  29486. + /* Retrieve output data */
  29487. + for ( i = 0; i < _output_length; i++ ) {
  29488. + ((char*)output)[i] =
  29489. + inb ( nic->ioaddr + PNIC_REG_DATA );
  29490. + }
  29491. + }
  29492. + return status;
  29493. +}
  29494. +
  29495. +static uint16_t pnic_command ( struct nic *nic, uint16_t command,
  29496. + void *input, uint16_t input_length,
  29497. + void *output, uint16_t output_max_length,
  29498. + uint16_t *output_length ) {
  29499. + pnic_priv_data_t *priv = (pnic_priv_data_t*)nic->priv_data;
  29500. + uint16_t status = pnic_command_quiet ( nic, command,
  29501. + input, input_length,
  29502. + output, output_max_length,
  29503. + output_length );
  29504. + if ( status == PNIC_STATUS_OK ) return status;
  29505. + printf ( "PNIC command %#hx (len %#hx) failed with status %#hx\n",
  29506. + command, input_length, status );
  29507. + if ( priv->api_version ) pnic_api_check(priv->api_version);
  29508. + return status;
  29509. +}
  29510. +
  29511. +/* Check API version matches that of NIC */
  29512. +static int pnic_api_check ( uint16_t api_version ) {
  29513. + if ( api_version != PNIC_API_VERSION ) {
  29514. + printf ( "Warning: API version mismatch! "
  29515. + "(NIC's is %d.%d, ours is %d.%d)\n",
  29516. + api_version >> 8, api_version & 0xff,
  29517. + PNIC_API_VERSION >> 8, PNIC_API_VERSION & 0xff );
  29518. + }
  29519. + if ( api_version < PNIC_API_VERSION ) {
  29520. + printf ( "*** You may need to update your copy of Bochs ***\n" );
  29521. + }
  29522. + return ( api_version == PNIC_API_VERSION );
  29523. +}
  29524. +
  29525. +/**************************************************************************
  29526. +POLL - Wait for a frame
  29527. +***************************************************************************/
  29528. +static int pnic_poll(struct nic *nic, int retrieve)
  29529. +{
  29530. + uint16_t length;
  29531. + uint16_t qlen;
  29532. +
  29533. + /* Check receive queue length to see if there's anything to
  29534. + * get. Necessary since once we've called PNIC_CMD_RECV we
  29535. + * have to read out the packet, otherwise it's lost forever.
  29536. + */
  29537. + if ( pnic_command ( nic, PNIC_CMD_RECV_QLEN, NULL, 0,
  29538. + &qlen, sizeof(qlen), NULL )
  29539. + != PNIC_STATUS_OK ) return ( 0 );
  29540. + if ( qlen == 0 ) return ( 0 );
  29541. +
  29542. + /* There is a packet ready. Return 1 if we're only checking. */
  29543. + if ( ! retrieve ) return ( 1 );
  29544. +
  29545. + /* Retrieve the packet */
  29546. + if ( pnic_command ( nic, PNIC_CMD_RECV, NULL, 0,
  29547. + nic->packet, ETH_FRAME_LEN, &length )
  29548. + != PNIC_STATUS_OK ) return ( 0 );
  29549. + nic->packetlen = length;
  29550. + return ( 1 );
  29551. +}
  29552. +
  29553. +/**************************************************************************
  29554. +TRANSMIT - Transmit a frame
  29555. +***************************************************************************/
  29556. +static void pnic_transmit(
  29557. + struct nic *nic,
  29558. + const char *dest, /* Destination */
  29559. + unsigned int type, /* Type */
  29560. + unsigned int size, /* size */
  29561. + const char *data) /* Packet */
  29562. +{
  29563. + unsigned int nstype = htons ( type );
  29564. +
  29565. + if ( ( ETH_HLEN + size ) >= ETH_FRAME_LEN ) {
  29566. + printf ( "pnic_transmit: packet too large\n" );
  29567. + return;
  29568. + }
  29569. +
  29570. + /* Assemble packet */
  29571. + memcpy ( tx_buffer, dest, ETH_ALEN );
  29572. + memcpy ( tx_buffer + ETH_ALEN, nic->node_addr, ETH_ALEN );
  29573. + memcpy ( tx_buffer + 2 * ETH_ALEN, &nstype, 2 );
  29574. + memcpy ( tx_buffer + ETH_HLEN, data, size );
  29575. +
  29576. + pnic_command ( nic, PNIC_CMD_XMIT, tx_buffer, ETH_HLEN + size,
  29577. + NULL, 0, NULL );
  29578. +}
  29579. +
  29580. +/**************************************************************************
  29581. +DISABLE - Turn off ethernet interface
  29582. +***************************************************************************/
  29583. +static void pnic_disable(struct dev *dev)
  29584. +{
  29585. + struct nic *nic = (struct nic *)dev;
  29586. + pnic_command ( nic, PNIC_CMD_RESET, NULL, 0, NULL, 0, NULL );
  29587. +}
  29588. +
  29589. +/**************************************************************************
  29590. +IRQ - Handle card interrupt status
  29591. +***************************************************************************/
  29592. +static void pnic_irq ( struct nic *nic, irq_action_t action )
  29593. +{
  29594. + uint8_t enabled;
  29595. +
  29596. + switch ( action ) {
  29597. + case DISABLE :
  29598. + case ENABLE :
  29599. + enabled = ( action == ENABLE ? 1 : 0 );
  29600. + pnic_command ( nic, PNIC_CMD_MASK_IRQ,
  29601. + &enabled, sizeof(enabled), NULL, 0, NULL );
  29602. + break;
  29603. + case FORCE :
  29604. + pnic_command ( nic, PNIC_CMD_FORCE_IRQ,
  29605. + NULL, 0, NULL, 0, NULL );
  29606. + break;
  29607. + }
  29608. +}
  29609. +
  29610. +/**************************************************************************
  29611. +PROBE - Look for an adapter, this routine's visible to the outside
  29612. +***************************************************************************/
  29613. +
  29614. +static int pnic_probe(struct dev *dev, struct pci_device *pci)
  29615. +{
  29616. + struct nic *nic = (struct nic *)dev;
  29617. + static pnic_priv_data_t priv;
  29618. + uint16_t status;
  29619. +
  29620. + printf(" - ");
  29621. +
  29622. + /* Clear private data structure and chain it in */
  29623. + memset ( &priv, 0, sizeof(priv) );
  29624. + nic->priv_data = &priv;
  29625. +
  29626. + /* Mask the bit that says "this is an io addr" */
  29627. + nic->ioaddr = pci->ioaddr & ~3;
  29628. + nic->irqno = pci->irq;
  29629. + /* Not sure what this does, but the rtl8139 driver does it */
  29630. + adjust_pci_device(pci);
  29631. +
  29632. + status = pnic_command_quiet( nic, PNIC_CMD_API_VER, NULL, 0,
  29633. + &priv.api_version,
  29634. + sizeof(priv.api_version), NULL );
  29635. + if ( status != PNIC_STATUS_OK ) {
  29636. + printf ( "PNIC failed installation check, code %#hx\n",
  29637. + status );
  29638. + return 0;
  29639. + }
  29640. + pnic_api_check(priv.api_version);
  29641. + status = pnic_command ( nic, PNIC_CMD_READ_MAC, NULL, 0,
  29642. + nic->node_addr, ETH_ALEN, NULL );
  29643. + printf ( "Detected Bochs Pseudo NIC MAC %! (API v%d.%d) at %#hx\n",
  29644. + nic->node_addr, priv.api_version>>8, priv.api_version&0xff,
  29645. + nic->ioaddr );
  29646. +
  29647. + /* point to NIC specific routines */
  29648. + dev->disable = pnic_disable;
  29649. + nic->poll = pnic_poll;
  29650. + nic->transmit = pnic_transmit;
  29651. + nic->irq = pnic_irq;
  29652. + return 1;
  29653. +}
  29654. +
  29655. +static struct pci_id pnic_nics[] = {
  29656. +/* genrules.pl doesn't let us use macros for PCI IDs...*/
  29657. +PCI_ROM(0xfefe, 0xefef, "pnic", "Bochs Pseudo NIC Adaptor"),
  29658. +};
  29659. +
  29660. +struct pci_driver pnic_driver = {
  29661. + .type = NIC_DRIVER,
  29662. + .name = "PNIC",
  29663. + .probe = pnic_probe,
  29664. + .ids = pnic_nics,
  29665. + .id_count = sizeof(pnic_nics)/sizeof(pnic_nics[0]),
  29666. + .class = 0,
  29667. +};
  29668. Index: b/netboot/pnic_api.h
  29669. ===================================================================
  29670. --- /dev/null
  29671. +++ b/netboot/pnic_api.h
  29672. @@ -0,0 +1,59 @@
  29673. +/*
  29674. + * Constants etc. for the Bochs/Etherboot pseudo-NIC
  29675. + *
  29676. + * This header file must be valid C and C++.
  29677. + *
  29678. + * Operation of the pseudo-NIC (PNIC) is pretty simple. To write a
  29679. + * command plus data, first write the length of the data to
  29680. + * PNIC_REG_LEN, then write the data a byte at a type to
  29681. + * PNIC_REG_DATA, then write the command code to PNIC_REG_CMD. The
  29682. + * status will be available from PNIC_REG_STAT. The length of any
  29683. + * data returned will be in PNIC_REG_LEN and can be read a byte at a
  29684. + * time from PNIC_REG_DATA.
  29685. + */
  29686. +
  29687. +/*
  29688. + * PCI parameters
  29689. + */
  29690. +#define PNIC_PCI_VENDOR 0xfefe /* Hopefully these won't clash with */
  29691. +#define PNIC_PCI_DEVICE 0xefef /* any real PCI device IDs. */
  29692. +
  29693. +/*
  29694. + * 'Hardware' register addresses, offset from io_base
  29695. + */
  29696. +#define PNIC_REG_CMD 0x00 /* Command register, 2 bytes, write only */
  29697. +#define PNIC_REG_STAT 0x00 /* Status register, 2 bytes, read only */
  29698. +#define PNIC_REG_LEN 0x02 /* Length register, 2 bytes, read-write */
  29699. +#define PNIC_REG_DATA 0x04 /* Data port, 1 byte, read-write */
  29700. +/*
  29701. + * PNIC_MAX_REG used in Bochs to claim i/o space
  29702. + */
  29703. +#define PNIC_MAX_REG 0x04
  29704. +
  29705. +/*
  29706. + * Command code definitions: write these into PNIC_REG_CMD
  29707. + */
  29708. +#define PNIC_CMD_NOOP 0x0000
  29709. +#define PNIC_CMD_API_VER 0x0001
  29710. +#define PNIC_CMD_READ_MAC 0x0002
  29711. +#define PNIC_CMD_RESET 0x0003
  29712. +#define PNIC_CMD_XMIT 0x0004
  29713. +#define PNIC_CMD_RECV 0x0005
  29714. +#define PNIC_CMD_RECV_QLEN 0x0006
  29715. +#define PNIC_CMD_MASK_IRQ 0x0007
  29716. +#define PNIC_CMD_FORCE_IRQ 0x0008
  29717. +
  29718. +/*
  29719. + * Status code definitions: read these from PNIC_REG_STAT
  29720. + *
  29721. + * We avoid using status codes that might be confused with
  29722. + * randomly-read data (e.g. 0x0000, 0xffff etc.)
  29723. + */
  29724. +#define PNIC_STATUS_OK 0x4f4b /* 'OK' */
  29725. +#define PNIC_STATUS_UNKNOWN_CMD 0x3f3f /* '??' */
  29726. +
  29727. +/*
  29728. + * Other miscellaneous information
  29729. + */
  29730. +
  29731. +#define PNIC_API_VERSION 0x0101 /* 1.1 */
  29732. Index: b/netboot/pxe.h
  29733. ===================================================================
  29734. --- /dev/null
  29735. +++ b/netboot/pxe.h
  29736. @@ -0,0 +1,521 @@
  29737. +/*
  29738. + * Copyright (c) 2000 Alfred Perlstein <alfred@freebsd.org>
  29739. + * All rights reserved.
  29740. + * Copyright (c) 2000 Paul Saab <ps@freebsd.org>
  29741. + * All rights reserved.
  29742. + * Copyright (c) 2000 John Baldwin <jhb@freebsd.org>
  29743. + * All rights reserved.
  29744. + *
  29745. + * Redistribution and use in source and binary forms, with or without
  29746. + * modification, are permitted provided that the following conditions
  29747. + * are met:
  29748. + * 1. Redistributions of source code must retain the above copyright
  29749. + * notice, this list of conditions and the following disclaimer.
  29750. + * 2. Redistributions in binary form must reproduce the above copyright
  29751. + * notice, this list of conditions and the following disclaimer in the
  29752. + * documentation and/or other materials provided with the distribution.
  29753. + *
  29754. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  29755. + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29756. + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29757. + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  29758. + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29759. + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29760. + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29761. + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29762. + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29763. + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29764. + * SUCH DAMAGE.
  29765. + *
  29766. + * $FreeBSD: src/sys/boot/i386/libi386/pxe.h,v 1.4.2.2 2000/09/10 02:52:18 ps Exp $
  29767. + */
  29768. +
  29769. +/*
  29770. + * The typedefs and structures declared in this file
  29771. + * clearly violate style(9), the reason for this is to conform to the
  29772. + * typedefs/structure-names used in the Intel literature to avoid confusion.
  29773. + *
  29774. + * It's for your own good. :)
  29775. + */
  29776. +
  29777. +/* SEGOFF16_t defined in separate header for Etherboot
  29778. + */
  29779. +#include <segoff.h>
  29780. +
  29781. +/* It seems that intel didn't think about ABI,
  29782. + * either that or 16bit ABI != 32bit ABI (which seems reasonable)
  29783. + * I have to thank Intel for the hair loss I incurred trying to figure
  29784. + * out why PXE was mis-reading structures I was passing it (at least
  29785. + * from my point of view)
  29786. + *
  29787. + * Solution: use gcc's '__attribute__ ((packed))' to correctly align
  29788. + * structures passed into PXE
  29789. + * Question: does this really work for PXE's expected ABI?
  29790. + */
  29791. +#define PACKED __attribute__ ((packed))
  29792. +
  29793. +#define S_SIZE(s) s, sizeof(s) - 1
  29794. +
  29795. +#define IP_STR "%d.%d.%d.%d"
  29796. +#define IP_ARGS(ip) \
  29797. + (int)(ip >> 24) & 0xff, (int)(ip >> 16) & 0xff, \
  29798. + (int)(ip >> 8) & 0xff, (int)ip & 0xff
  29799. +
  29800. +#define MAC_STR "%02x:%02x:%02x:%02x:%02x:%02x"
  29801. +#define MAC_ARGS(mac) \
  29802. + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
  29803. +
  29804. +#define PXENFSROOTPATH "/pxeroot"
  29805. +
  29806. +typedef struct {
  29807. + uint16_t Seg_Addr;
  29808. + uint32_t Phy_Addr;
  29809. + uint16_t Seg_Size;
  29810. +} PACKED SEGDESC_t; /* PACKED is required, otherwise gcc pads this out to 12
  29811. + bytes - mbrown@fensystems.co.uk (mcb30) 17/5/03 */
  29812. +
  29813. +typedef uint16_t SEGSEL_t;
  29814. +typedef uint16_t PXENV_STATUS_t;
  29815. +typedef uint32_t IP4_t;
  29816. +typedef uint32_t ADDR32_t;
  29817. +typedef uint16_t UDP_PORT_t;
  29818. +
  29819. +#define MAC_ADDR_LEN 16
  29820. +typedef uint8_t MAC_ADDR[MAC_ADDR_LEN];
  29821. +
  29822. +/* PXENV+ */
  29823. +typedef struct {
  29824. + uint8_t Signature[6]; /* 'PXENV+' */
  29825. + uint16_t Version; /* MSB = major, LSB = minor */
  29826. + uint8_t Length; /* structure length */
  29827. + uint8_t Checksum; /* checksum pad */
  29828. + SEGOFF16_t RMEntry; /* SEG:OFF to PXE entry point */
  29829. + /* don't use PMOffset and PMSelector (from the 2.1 PXE manual) */
  29830. + uint32_t PMOffset; /* Protected mode entry */
  29831. + SEGSEL_t PMSelector; /* Protected mode selector */
  29832. + SEGSEL_t StackSeg; /* Stack segment address */
  29833. + uint16_t StackSize; /* Stack segment size (bytes) */
  29834. + SEGSEL_t BC_CodeSeg; /* BC Code segment address */
  29835. + uint16_t BC_CodeSize; /* BC Code segment size (bytes) */
  29836. + SEGSEL_t BC_DataSeg; /* BC Data segment address */
  29837. + uint16_t BC_DataSize; /* BC Data segment size (bytes) */
  29838. + SEGSEL_t UNDIDataSeg; /* UNDI Data segment address */
  29839. + uint16_t UNDIDataSize; /* UNDI Data segment size (bytes) */
  29840. + SEGSEL_t UNDICodeSeg; /* UNDI Code segment address */
  29841. + uint16_t UNDICodeSize; /* UNDI Code segment size (bytes) */
  29842. + SEGOFF16_t PXEPtr; /* SEG:OFF to !PXE struct,
  29843. + only present when Version > 2.1 */
  29844. +} PACKED pxenv_t;
  29845. +
  29846. +/* !PXE */
  29847. +typedef struct {
  29848. + uint8_t Signature[4];
  29849. + uint8_t StructLength;
  29850. + uint8_t StructCksum;
  29851. + uint8_t StructRev;
  29852. + uint8_t reserved_1;
  29853. + SEGOFF16_t UNDIROMID;
  29854. + SEGOFF16_t BaseROMID;
  29855. + SEGOFF16_t EntryPointSP;
  29856. + SEGOFF16_t EntryPointESP;
  29857. + SEGOFF16_t StatusCallout;
  29858. + uint8_t reserved_2;
  29859. + uint8_t SegDescCn;
  29860. + SEGSEL_t FirstSelector;
  29861. + SEGDESC_t Stack;
  29862. + SEGDESC_t UNDIData;
  29863. + SEGDESC_t UNDICode;
  29864. + SEGDESC_t UNDICodeWrite;
  29865. + SEGDESC_t BC_Data;
  29866. + SEGDESC_t BC_Code;
  29867. + SEGDESC_t BC_CodeWrite;
  29868. +} PACKED pxe_t;
  29869. +
  29870. +#define PXENV_START_UNDI 0x0000
  29871. +typedef struct {
  29872. + PXENV_STATUS_t Status;
  29873. + uint16_t ax;
  29874. + uint16_t bx;
  29875. + uint16_t dx;
  29876. + uint16_t di;
  29877. + uint16_t es;
  29878. +} PACKED t_PXENV_START_UNDI;
  29879. +
  29880. +#define PXENV_UNDI_STARTUP 0x0001
  29881. +typedef struct {
  29882. + PXENV_STATUS_t Status;
  29883. +} PACKED t_PXENV_UNDI_STARTUP;
  29884. +
  29885. +#define PXENV_UNDI_CLEANUP 0x0002
  29886. +typedef struct {
  29887. + PXENV_STATUS_t Status;
  29888. +} PACKED t_PXENV_UNDI_CLEANUP;
  29889. +
  29890. +#define PXENV_UNDI_INITIALIZE 0x0003
  29891. +typedef struct {
  29892. + PXENV_STATUS_t Status;
  29893. + ADDR32_t ProtocolIni; /* Phys addr of a copy of the driver module */
  29894. + uint8_t reserved[8];
  29895. +} PACKED t_PXENV_UNDI_INITIALIZE;
  29896. +
  29897. +
  29898. +#define MAXNUM_MCADDR 8
  29899. +typedef struct {
  29900. + uint16_t MCastAddrCount;
  29901. + MAC_ADDR McastAddr[MAXNUM_MCADDR];
  29902. +} PACKED t_PXENV_UNDI_MCAST_ADDRESS;
  29903. +
  29904. +#define PXENV_UNDI_RESET_ADAPTER 0x0004
  29905. +typedef struct {
  29906. + PXENV_STATUS_t Status;
  29907. + t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
  29908. +} PACKED t_PXENV_UNDI_RESET;
  29909. +
  29910. +#define PXENV_UNDI_SHUTDOWN 0x0005
  29911. +typedef struct {
  29912. + PXENV_STATUS_t Status;
  29913. +} PACKED t_PXENV_UNDI_SHUTDOWN;
  29914. +
  29915. +#define PXENV_UNDI_OPEN 0x0006
  29916. +typedef struct {
  29917. + PXENV_STATUS_t Status;
  29918. + uint16_t OpenFlag;
  29919. + uint16_t PktFilter;
  29920. +# define FLTR_DIRECTED 0x0001
  29921. +# define FLTR_BRDCST 0x0002
  29922. +# define FLTR_PRMSCS 0x0003
  29923. +# define FLTR_SRC_RTG 0x0004
  29924. +
  29925. + t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
  29926. +} PACKED t_PXENV_UNDI_OPEN;
  29927. +
  29928. +#define PXENV_UNDI_CLOSE 0x0007
  29929. +typedef struct {
  29930. + PXENV_STATUS_t Status;
  29931. +} PACKED t_PXENV_UNDI_CLOSE;
  29932. +
  29933. +#define PXENV_UNDI_TRANSMIT 0x0008
  29934. +typedef struct {
  29935. + PXENV_STATUS_t Status;
  29936. + uint8_t Protocol;
  29937. +# define P_UNKNOWN 0
  29938. +# define P_IP 1
  29939. +# define P_ARP 2
  29940. +# define P_RARP 3
  29941. +
  29942. + uint8_t XmitFlag;
  29943. +# define XMT_DESTADDR 0x0000
  29944. +# define XMT_BROADCAST 0x0001
  29945. +
  29946. + SEGOFF16_t DestAddr;
  29947. + SEGOFF16_t TBD;
  29948. + uint32_t Reserved[2];
  29949. +} PACKED t_PXENV_UNDI_TRANSMIT;
  29950. +
  29951. +#define MAX_DATA_BLKS 8
  29952. +typedef struct {
  29953. + uint16_t ImmedLength;
  29954. + SEGOFF16_t Xmit;
  29955. + uint16_t DataBlkCount;
  29956. + struct DataBlk {
  29957. + uint8_t TDPtrType;
  29958. + uint8_t TDRsvdByte;
  29959. + uint16_t TDDataLen;
  29960. + SEGOFF16_t TDDataPtr;
  29961. + } DataBlock[MAX_DATA_BLKS];
  29962. +} PACKED t_PXENV_UNDI_TBD;
  29963. +
  29964. +#define PXENV_UNDI_SET_MCAST_ADDRESS 0x0009
  29965. +typedef struct {
  29966. + PXENV_STATUS_t Status;
  29967. + t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
  29968. +} PACKED t_PXENV_UNDI_SET_MCAST_ADDR;
  29969. +
  29970. +#define PXENV_UNDI_SET_STATION_ADDRESS 0x000A
  29971. +typedef struct {
  29972. + PXENV_STATUS_t Status;
  29973. + MAC_ADDR StationAddress; /* Temp MAC addres to use */
  29974. +} PACKED t_PXENV_UNDI_SET_STATION_ADDRESS;
  29975. +
  29976. +#define PXENV_UNDI_SET_PACKET_FILTER 0x000B
  29977. +typedef struct {
  29978. + PXENV_STATUS_t Status;
  29979. + uint8_t filter; /* see UNDI_OPEN (0x0006) */
  29980. +} PACKED t_PXENV_UNDI_SET_PACKET_FILTER;
  29981. +
  29982. +#define PXENV_UNDI_GET_INFORMATION 0x000C
  29983. +typedef struct {
  29984. + PXENV_STATUS_t Status;
  29985. + uint16_t BaseIo; /* Adapter base I/O address */
  29986. + uint16_t IntNumber; /* Adapter IRQ number */
  29987. + uint16_t MaxTranUnit; /* Adapter maximum transmit unit */
  29988. + uint16_t HwType; /* Type of protocol at the hardware addr */
  29989. +# define ETHER_TYPE 1
  29990. +# define EXP_ETHER_TYPE 2
  29991. +# define IEEE_TYPE 6
  29992. +# define ARCNET_TYPE 7
  29993. +
  29994. + uint16_t HwAddrLen; /* Length of hardware address */
  29995. + MAC_ADDR CurrentNodeAddress; /* Current hardware address */
  29996. + MAC_ADDR PermNodeAddress; /* Permanent hardware address */
  29997. + SEGSEL_t ROMAddress; /* Real mode ROM segment address */
  29998. + uint16_t RxBufCt; /* Receive queue length */
  29999. + uint16_t TxBufCt; /* Transmit queue length */
  30000. +} PACKED t_PXENV_UNDI_GET_INFORMATION;
  30001. +
  30002. +#define PXENV_UNDI_GET_STATISTICS 0x000D
  30003. +typedef struct {
  30004. + PXENV_STATUS_t Status;
  30005. + uint32_t XmitGoodFrames; /* Number of successful transmissions */
  30006. + uint32_t RcvGoodFrames; /* Number of good frames received */
  30007. + uint32_t RcvCRCErrors; /* Number of frames with CRC errors */
  30008. + uint32_t RcvResourceErrors; /* Number of frames dropped */
  30009. +} PACKED t_PXENV_UNDI_GET_STATISTICS;
  30010. +
  30011. +#define PXENV_UNDI_CLEAR_STATISTICS 0x000E
  30012. +typedef struct {
  30013. + PXENV_STATUS_t Status;
  30014. +} PACKED t_PXENV_UNDI_CLEAR_STATISTICS;
  30015. +
  30016. +#define PXENV_UNDI_INITIATE_DIAGS 0x000F
  30017. +typedef struct {
  30018. + PXENV_STATUS_t Status;
  30019. +} PACKED t_PXENV_UNDI_INITIATE_DIAGS;
  30020. +
  30021. +#define PXENV_UNDI_FORCE_INTERRUPT 0x0010
  30022. +typedef struct {
  30023. + PXENV_STATUS_t Status;
  30024. +} PACKED t_PXENV_UNDI_FORCE_INTERRUPT;
  30025. +
  30026. +#define PXENV_UNDI_GET_MCAST_ADDRESS 0x0011
  30027. +typedef struct {
  30028. + PXENV_STATUS_t Status;
  30029. + IP4_t InetAddr; /* IP mulicast address */
  30030. + MAC_ADDR MediaAddr; /* MAC multicast address */
  30031. +} PACKED t_PXENV_UNDI_GET_MCAST_ADDR;
  30032. +
  30033. +#define PXENV_UNDI_GET_NIC_TYPE 0x0012
  30034. +typedef struct {
  30035. + PXENV_STATUS_t Status;
  30036. + uint8_t NicType; /* Type of NIC */
  30037. +# define PCI_NIC 2
  30038. +# define PnP_NIC 3
  30039. +# define CardBus_NIC 4
  30040. +
  30041. + union {
  30042. + struct {
  30043. + uint16_t Vendor_ID;
  30044. + uint16_t Dev_ID;
  30045. + uint8_t Base_Class;
  30046. + uint8_t Sub_Class;
  30047. + uint8_t Prog_Intf;
  30048. + uint8_t Rev;
  30049. + uint16_t BusDevFunc;
  30050. + uint16_t SubVendor_ID;
  30051. + uint16_t SubDevice_ID;
  30052. + } pci, cardbus;
  30053. + struct {
  30054. + uint32_t EISA_Dev_ID;
  30055. + uint8_t Base_Class;
  30056. + uint8_t Sub_Class;
  30057. + uint8_t Prog_Intf;
  30058. + uint16_t CardSelNum;
  30059. + } pnp;
  30060. + } info;
  30061. +} PACKED t_PXENV_UNDI_GET_NIC_TYPE;
  30062. +
  30063. +#define PXENV_UNDI_GET_IFACE_INFO 0x0013
  30064. +typedef struct {
  30065. + PXENV_STATUS_t Status;
  30066. + uint8_t IfaceType[16]; /* Name of MAC type in ASCII. */
  30067. + uint32_t LinkSpeed; /* Defined in NDIS 2.0 spec */
  30068. + uint32_t ServiceFlags; /* Defined in NDIS 2.0 spec */
  30069. + uint32_t Reserved[4]; /* must be 0 */
  30070. +} PACKED t_PXENV_UNDI_GET_IFACE_INFO;
  30071. +
  30072. +#define PXENV_UNDI_ISR 0x0014
  30073. +typedef struct {
  30074. + PXENV_STATUS_t Status;
  30075. + uint16_t FuncFlag; /* PXENV_UNDI_ISR_OUT_xxx */
  30076. + uint16_t BufferLength; /* Length of Frame */
  30077. + uint16_t FrameLength; /* Total length of reciever frame */
  30078. + uint16_t FrameHeaderLength; /* Length of the media header in Frame */
  30079. + SEGOFF16_t Frame; /* receive buffer */
  30080. + uint8_t ProtType; /* Protocol type */
  30081. + uint8_t PktType; /* Packet Type */
  30082. +# define PXENV_UNDI_ISR_IN_START 1
  30083. +# define PXENV_UNDI_ISR_IN_PROCESS 2
  30084. +# define PXENV_UNDI_ISR_IN_GET_NEXT 3
  30085. +
  30086. + /* one of these will be returned for PXENV_UNDI_ISR_IN_START */
  30087. +# define PXENV_UNDI_ISR_OUT_OURS 0
  30088. +# define PXENV_UNDI_ISR_OUT_NOT_OURS 1
  30089. +
  30090. + /*
  30091. + * one of these will bre returnd for PXEND_UNDI_ISR_IN_PROCESS
  30092. + * and PXENV_UNDI_ISR_IN_GET_NEXT
  30093. + */
  30094. +# define PXENV_UNDI_ISR_OUT_DONE 0
  30095. +# define PXENV_UNDI_ISR_OUT_TRANSMIT 2
  30096. +# define PXENV_UNDI_ISR_OUT_RECEIVE 3
  30097. +# define PXENV_UNDI_ISR_OUT_BUSY 4
  30098. +} PACKED t_PXENV_UNDI_ISR;
  30099. +
  30100. +#define PXENV_STOP_UNDI 0x0015
  30101. +typedef struct {
  30102. + PXENV_STATUS_t Status;
  30103. +} PACKED t_PXENV_STOP_UNDI;
  30104. +
  30105. +#define PXENV_TFTP_OPEN 0x0020
  30106. +typedef struct {
  30107. + PXENV_STATUS_t Status;
  30108. + IP4_t ServerIPAddress;
  30109. + IP4_t GatewayIPAddress;
  30110. + uint8_t FileName[128];
  30111. + UDP_PORT_t TFTPPort;
  30112. + uint16_t PacketSize;
  30113. +} PACKED t_PXENV_TFTP_OPEN;
  30114. +
  30115. +#define PXENV_TFTP_CLOSE 0x0021
  30116. +typedef struct {
  30117. + PXENV_STATUS_t Status;
  30118. +} PACKED t_PXENV_TFTP_CLOSE;
  30119. +
  30120. +#define PXENV_TFTP_READ 0x0022
  30121. +typedef struct {
  30122. + PXENV_STATUS_t Status;
  30123. + uint16_t PacketNumber;
  30124. + uint16_t BufferSize;
  30125. + SEGOFF16_t Buffer;
  30126. +} PACKED t_PXENV_TFTP_READ;
  30127. +
  30128. +#define PXENV_TFTP_READ_FILE 0x0023
  30129. +typedef struct {
  30130. + PXENV_STATUS_t Status;
  30131. + uint8_t FileName[128];
  30132. + uint32_t BufferSize;
  30133. + ADDR32_t Buffer;
  30134. + IP4_t ServerIPAddress;
  30135. + IP4_t GatewayIPAdress;
  30136. + IP4_t McastIPAdress;
  30137. + UDP_PORT_t TFTPClntPort;
  30138. + UDP_PORT_t TFTPSrvPort;
  30139. + uint16_t TFTPOpenTimeOut;
  30140. + uint16_t TFTPReopenDelay;
  30141. +} PACKED t_PXENV_TFTP_READ_FILE;
  30142. +
  30143. +#define PXENV_TFTP_GET_FSIZE 0x0025
  30144. +typedef struct {
  30145. + PXENV_STATUS_t Status;
  30146. + IP4_t ServerIPAddress;
  30147. + IP4_t GatewayIPAdress;
  30148. + uint8_t FileName[128];
  30149. + uint32_t FileSize;
  30150. +} PACKED t_PXENV_TFTP_GET_FSIZE;
  30151. +
  30152. +#define PXENV_UDP_OPEN 0x0030
  30153. +typedef struct {
  30154. + PXENV_STATUS_t Status;
  30155. + IP4_t src_ip; /* IP address of this station */
  30156. +} PACKED t_PXENV_UDP_OPEN;
  30157. +
  30158. +#define PXENV_UDP_CLOSE 0x0031
  30159. +typedef struct {
  30160. + PXENV_STATUS_t status;
  30161. +} PACKED t_PXENV_UDP_CLOSE;
  30162. +
  30163. +#define PXENV_UDP_READ 0x0032
  30164. +typedef struct {
  30165. + PXENV_STATUS_t status;
  30166. + IP4_t src_ip; /* IP of sender */
  30167. + IP4_t dest_ip; /* Only accept packets sent to this IP */
  30168. + UDP_PORT_t s_port; /* UDP source port of sender */
  30169. + UDP_PORT_t d_port; /* Only accept packets sent to this port */
  30170. + uint16_t buffer_size; /* Size of the packet buffer */
  30171. + SEGOFF16_t buffer; /* SEG:OFF to the packet buffer */
  30172. +} PACKED t_PXENV_UDP_READ;
  30173. +
  30174. +#define PXENV_UDP_WRITE 0x0033
  30175. +typedef struct {
  30176. + PXENV_STATUS_t status;
  30177. + IP4_t ip; /* dest ip addr */
  30178. + IP4_t gw; /* ip gateway */
  30179. + UDP_PORT_t src_port; /* source udp port */
  30180. + UDP_PORT_t dst_port; /* destination udp port */
  30181. + uint16_t buffer_size; /* Size of the packet buffer */
  30182. + SEGOFF16_t buffer; /* SEG:OFF to the packet buffer */
  30183. +} PACKED t_PXENV_UDP_WRITE;
  30184. +
  30185. +#define PXENV_UNLOAD_STACK 0x0070
  30186. +typedef struct {
  30187. + PXENV_STATUS_t Status;
  30188. + uint8_t reserved[10];
  30189. +} PACKED t_PXENV_UNLOAD_STACK;
  30190. +
  30191. +
  30192. +#define PXENV_GET_CACHED_INFO 0x0071
  30193. +typedef struct {
  30194. + PXENV_STATUS_t Status;
  30195. + uint16_t PacketType; /* type (defined right here) */
  30196. +# define PXENV_PACKET_TYPE_DHCP_DISCOVER 1
  30197. +# define PXENV_PACKET_TYPE_DHCP_ACK 2
  30198. +# define PXENV_PACKET_TYPE_BINL_REPLY 3
  30199. + uint16_t BufferSize; /* max to copy, leave at 0 for pointer */
  30200. + SEGOFF16_t Buffer; /* copy to, leave at 0 for pointer */
  30201. + uint16_t BufferLimit; /* max size of buffer in BC dataseg ? */
  30202. +} PACKED t_PXENV_GET_CACHED_INFO;
  30203. +
  30204. +
  30205. +/* structure filled in by PXENV_GET_CACHED_INFO
  30206. + * (how we determine which IP we downloaded the initial bootstrap from)
  30207. + * words can't describe...
  30208. + */
  30209. +typedef struct {
  30210. + uint8_t opcode;
  30211. +# define BOOTP_REQ 1
  30212. +# define BOOTP_REP 2
  30213. + uint8_t Hardware; /* hardware type */
  30214. + uint8_t Hardlen; /* hardware addr len */
  30215. + uint8_t Gatehops; /* zero it */
  30216. + uint32_t ident; /* random number chosen by client */
  30217. + uint16_t seconds; /* seconds since did initial bootstrap */
  30218. + uint16_t Flags; /* seconds since did initial bootstrap */
  30219. +# define BOOTP_BCAST 0x8000 /* ? */
  30220. + IP4_t cip; /* Client IP */
  30221. + IP4_t yip; /* Your IP */
  30222. + IP4_t sip; /* IP to use for next boot stage */
  30223. + IP4_t gip; /* Relay IP ? */
  30224. + MAC_ADDR CAddr; /* Client hardware address */
  30225. + uint8_t Sname[64]; /* Server's hostname (Optional) */
  30226. + uint8_t bootfile[128]; /* boot filename */
  30227. + union {
  30228. +# if 1
  30229. +# define BOOTP_DHCPVEND 1024 /* DHCP extended vendor field size */
  30230. +# else
  30231. +# define BOOTP_DHCPVEND 312 /* DHCP standard vendor field size */
  30232. +# endif
  30233. + uint8_t d[BOOTP_DHCPVEND]; /* raw array of vendor/dhcp options */
  30234. + struct {
  30235. + uint8_t magic[4]; /* DHCP magic cookie */
  30236. +# ifndef VM_RFC1048
  30237. +# define VM_RFC1048 0x63825363L /* ? */
  30238. +# endif
  30239. + uint32_t flags; /* bootp flags/opcodes */
  30240. + uint8_t pad[56]; /* I don't think intel knows what a
  30241. + union does... */
  30242. + } v;
  30243. + } vendor;
  30244. +} PACKED BOOTPLAYER;
  30245. +
  30246. +#define PXENV_RESTART_TFTP 0x0073
  30247. +#define t_PXENV_RESTART_TFTP t_PXENV_TFTP_READ_FILE
  30248. +
  30249. +#define PXENV_START_BASE 0x0075
  30250. +typedef struct {
  30251. + PXENV_STATUS_t Status;
  30252. +} PACKED t_PXENV_START_BASE;
  30253. +
  30254. +#define PXENV_STOP_BASE 0x0076
  30255. +typedef struct {
  30256. + PXENV_STATUS_t Status;
  30257. +} PACKED t_PXENV_STOP_BASE;
  30258. Index: b/netboot/r8169.c
  30259. ===================================================================
  30260. --- /dev/null
  30261. +++ b/netboot/r8169.c
  30262. @@ -0,0 +1,854 @@
  30263. +/**************************************************************************
  30264. +* r8169.c: Etherboot device driver for the RealTek RTL-8169 Gigabit
  30265. +* Written 2003 by Timothy Legge <tlegge@rogers.com>
  30266. +*
  30267. +* This program is free software; you can redistribute it and/or modify
  30268. +* it under the terms of the GNU General Public License as published by
  30269. +* the Free Software Foundation; either version 2 of the License, or
  30270. +* (at your option) any later version.
  30271. +*
  30272. +* This program is distributed in the hope that it will be useful,
  30273. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  30274. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30275. +* GNU General Public License for more details.
  30276. +*
  30277. +* You should have received a copy of the GNU General Public License
  30278. +* along with this program; if not, write to the Free Software
  30279. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  30280. +*
  30281. +* Portions of this code based on:
  30282. +* r8169.c: A RealTek RTL-8169 Gigabit Ethernet driver
  30283. +* for Linux kernel 2.4.x.
  30284. +*
  30285. +* Written 2002 ShuChen <shuchen@realtek.com.tw>
  30286. +* See Linux Driver for full information
  30287. +*
  30288. +* Linux Driver Version 1.27a, 10.02.2002
  30289. +*
  30290. +* Thanks to:
  30291. +* Jean Chen of RealTek Semiconductor Corp. for
  30292. +* providing the evaluation NIC used to develop
  30293. +* this driver. RealTek's support for Etherboot
  30294. +* is appreciated.
  30295. +*
  30296. +* REVISION HISTORY:
  30297. +* ================
  30298. +*
  30299. +* v1.0 11-26-2003 timlegge Initial port of Linux driver
  30300. +* v1.5 01-17-2004 timlegge Initial driver output cleanup
  30301. +* v1.6 03-27-2004 timlegge Additional Cleanup
  30302. +*
  30303. +* Indent Options: indent -kr -i8
  30304. +***************************************************************************/
  30305. +
  30306. +/* to get some global routines like printf */
  30307. +#include "etherboot.h"
  30308. +/* to get the interface to the body of the program */
  30309. +#include "nic.h"
  30310. +/* to get the PCI support functions, if this is a PCI NIC */
  30311. +#include "pci.h"
  30312. +#include "timer.h"
  30313. +
  30314. +#define drv_version "v1.6"
  30315. +#define drv_date "03-27-2004"
  30316. +
  30317. +typedef unsigned char u8;
  30318. +typedef signed char s8;
  30319. +typedef unsigned short u16;
  30320. +typedef signed short s16;
  30321. +typedef unsigned int u32;
  30322. +typedef signed int s32;
  30323. +
  30324. +#define HZ 1000
  30325. +
  30326. +static u32 ioaddr;
  30327. +
  30328. +#ifdef EDEBUG
  30329. +#define dprintf(x) printf x
  30330. +#else
  30331. +#define dprintf(x)
  30332. +#endif
  30333. +
  30334. +/* Condensed operations for readability. */
  30335. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  30336. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  30337. +
  30338. +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
  30339. +
  30340. +/* media options
  30341. + _10_Half = 0x01,
  30342. + _10_Full = 0x02,
  30343. + _100_Half = 0x04,
  30344. + _100_Full = 0x08,
  30345. + _1000_Full = 0x10,
  30346. +*/
  30347. +static int media = -1;
  30348. +
  30349. +#if 0
  30350. +/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
  30351. +static int max_interrupt_work = 20;
  30352. +#endif
  30353. +
  30354. +#if 0
  30355. +/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
  30356. + The RTL chips use a 64 element hash table based on the Ethernet CRC. */
  30357. +static int multicast_filter_limit = 32;
  30358. +#endif
  30359. +
  30360. +/* MAC address length*/
  30361. +#define MAC_ADDR_LEN 6
  30362. +
  30363. +/* max supported gigabit ethernet frame size -- must be at least (dev->mtu+14+4).*/
  30364. +#define MAX_ETH_FRAME_SIZE 1536
  30365. +
  30366. +#define TX_FIFO_THRESH 256 /* In bytes */
  30367. +
  30368. +#define RX_FIFO_THRESH 7 /* 7 means NO threshold, Rx buffer level before first PCI xfer. */
  30369. +#define RX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */
  30370. +#define TX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */
  30371. +#define EarlyTxThld 0x3F /* 0x3F means NO early transmit */
  30372. +#define RxPacketMaxSize 0x0800 /* Maximum size supported is 16K-1 */
  30373. +#define InterFrameGap 0x03 /* 3 means InterFrameGap = the shortest one */
  30374. +
  30375. +#define NUM_TX_DESC 1 /* Number of Tx descriptor registers */
  30376. +#define NUM_RX_DESC 4 /* Number of Rx descriptor registers */
  30377. +#define RX_BUF_SIZE 1536 /* Rx Buffer size */
  30378. +
  30379. +#define RTL_MIN_IO_SIZE 0x80
  30380. +#define TX_TIMEOUT (6*HZ)
  30381. +
  30382. +/* write/read MMIO register */
  30383. +#define RTL_W8(reg, val8) writeb ((val8), ioaddr + (reg))
  30384. +#define RTL_W16(reg, val16) writew ((val16), ioaddr + (reg))
  30385. +#define RTL_W32(reg, val32) writel ((val32), ioaddr + (reg))
  30386. +#define RTL_R8(reg) readb (ioaddr + (reg))
  30387. +#define RTL_R16(reg) readw (ioaddr + (reg))
  30388. +#define RTL_R32(reg) ((unsigned long) readl (ioaddr + (reg)))
  30389. +
  30390. +enum RTL8169_registers {
  30391. + MAC0 = 0, /* Ethernet hardware address. */
  30392. + MAR0 = 8, /* Multicast filter. */
  30393. + TxDescStartAddr = 0x20,
  30394. + TxHDescStartAddr = 0x28,
  30395. + FLASH = 0x30,
  30396. + ERSR = 0x36,
  30397. + ChipCmd = 0x37,
  30398. + TxPoll = 0x38,
  30399. + IntrMask = 0x3C,
  30400. + IntrStatus = 0x3E,
  30401. + TxConfig = 0x40,
  30402. + RxConfig = 0x44,
  30403. + RxMissed = 0x4C,
  30404. + Cfg9346 = 0x50,
  30405. + Config0 = 0x51,
  30406. + Config1 = 0x52,
  30407. + Config2 = 0x53,
  30408. + Config3 = 0x54,
  30409. + Config4 = 0x55,
  30410. + Config5 = 0x56,
  30411. + MultiIntr = 0x5C,
  30412. + PHYAR = 0x60,
  30413. + TBICSR = 0x64,
  30414. + TBI_ANAR = 0x68,
  30415. + TBI_LPAR = 0x6A,
  30416. + PHYstatus = 0x6C,
  30417. + RxMaxSize = 0xDA,
  30418. + CPlusCmd = 0xE0,
  30419. + RxDescStartAddr = 0xE4,
  30420. + EarlyTxThres = 0xEC,
  30421. + FuncEvent = 0xF0,
  30422. + FuncEventMask = 0xF4,
  30423. + FuncPresetState = 0xF8,
  30424. + FuncForceEvent = 0xFC,
  30425. +};
  30426. +
  30427. +enum RTL8169_register_content {
  30428. + /*InterruptStatusBits */
  30429. + SYSErr = 0x8000,
  30430. + PCSTimeout = 0x4000,
  30431. + SWInt = 0x0100,
  30432. + TxDescUnavail = 0x80,
  30433. + RxFIFOOver = 0x40,
  30434. + RxUnderrun = 0x20,
  30435. + RxOverflow = 0x10,
  30436. + TxErr = 0x08,
  30437. + TxOK = 0x04,
  30438. + RxErr = 0x02,
  30439. + RxOK = 0x01,
  30440. +
  30441. + /*RxStatusDesc */
  30442. + RxRES = 0x00200000,
  30443. + RxCRC = 0x00080000,
  30444. + RxRUNT = 0x00100000,
  30445. + RxRWT = 0x00400000,
  30446. +
  30447. + /*ChipCmdBits */
  30448. + CmdReset = 0x10,
  30449. + CmdRxEnb = 0x08,
  30450. + CmdTxEnb = 0x04,
  30451. + RxBufEmpty = 0x01,
  30452. +
  30453. + /*Cfg9346Bits */
  30454. + Cfg9346_Lock = 0x00,
  30455. + Cfg9346_Unlock = 0xC0,
  30456. +
  30457. + /*rx_mode_bits */
  30458. + AcceptErr = 0x20,
  30459. + AcceptRunt = 0x10,
  30460. + AcceptBroadcast = 0x08,
  30461. + AcceptMulticast = 0x04,
  30462. + AcceptMyPhys = 0x02,
  30463. + AcceptAllPhys = 0x01,
  30464. +
  30465. + /*RxConfigBits */
  30466. + RxCfgFIFOShift = 13,
  30467. + RxCfgDMAShift = 8,
  30468. +
  30469. + /*TxConfigBits */
  30470. + TxInterFrameGapShift = 24,
  30471. + TxDMAShift = 8, /* DMA burst value (0-7) is shift this many bits */
  30472. +
  30473. + /*rtl8169_PHYstatus */
  30474. + TBI_Enable = 0x80,
  30475. + TxFlowCtrl = 0x40,
  30476. + RxFlowCtrl = 0x20,
  30477. + _1000bpsF = 0x10,
  30478. + _100bps = 0x08,
  30479. + _10bps = 0x04,
  30480. + LinkStatus = 0x02,
  30481. + FullDup = 0x01,
  30482. +
  30483. + /*GIGABIT_PHY_registers */
  30484. + PHY_CTRL_REG = 0,
  30485. + PHY_STAT_REG = 1,
  30486. + PHY_AUTO_NEGO_REG = 4,
  30487. + PHY_1000_CTRL_REG = 9,
  30488. +
  30489. + /*GIGABIT_PHY_REG_BIT */
  30490. + PHY_Restart_Auto_Nego = 0x0200,
  30491. + PHY_Enable_Auto_Nego = 0x1000,
  30492. +
  30493. + /* PHY_STAT_REG = 1; */
  30494. + PHY_Auto_Neco_Comp = 0x0020,
  30495. +
  30496. + /* PHY_AUTO_NEGO_REG = 4; */
  30497. + PHY_Cap_10_Half = 0x0020,
  30498. + PHY_Cap_10_Full = 0x0040,
  30499. + PHY_Cap_100_Half = 0x0080,
  30500. + PHY_Cap_100_Full = 0x0100,
  30501. +
  30502. + /* PHY_1000_CTRL_REG = 9; */
  30503. + PHY_Cap_1000_Full = 0x0200,
  30504. +
  30505. + PHY_Cap_Null = 0x0,
  30506. +
  30507. + /*_MediaType*/
  30508. + _10_Half = 0x01,
  30509. + _10_Full = 0x02,
  30510. + _100_Half = 0x04,
  30511. + _100_Full = 0x08,
  30512. + _1000_Full = 0x10,
  30513. +
  30514. + /*_TBICSRBit*/
  30515. + TBILinkOK = 0x02000000,
  30516. +};
  30517. +
  30518. +static struct {
  30519. + const char *name;
  30520. + u8 version; /* depend on RTL8169 docs */
  30521. + u32 RxConfigMask; /* should clear the bits supported by this chip */
  30522. +} rtl_chip_info[] = {
  30523. + {
  30524. +"RTL-8169", 0x00, 0xff7e1880,},};
  30525. +
  30526. +enum _DescStatusBit {
  30527. + OWNbit = 0x80000000,
  30528. + EORbit = 0x40000000,
  30529. + FSbit = 0x20000000,
  30530. + LSbit = 0x10000000,
  30531. +};
  30532. +
  30533. +struct TxDesc {
  30534. + u32 status;
  30535. + u32 vlan_tag;
  30536. + u32 buf_addr;
  30537. + u32 buf_Haddr;
  30538. +};
  30539. +
  30540. +struct RxDesc {
  30541. + u32 status;
  30542. + u32 vlan_tag;
  30543. + u32 buf_addr;
  30544. + u32 buf_Haddr;
  30545. +};
  30546. +
  30547. +/* The descriptors for this card are required to be aligned on
  30548. +256 byte boundaries. As the align attribute does not do more than
  30549. +16 bytes of alignment it requires some extra steps. Add 256 to the
  30550. +size of the array and the init_ring adjusts the alignment */
  30551. +
  30552. +/* Define the TX Descriptor */
  30553. +static u8 tx_ring[NUM_TX_DESC * sizeof(struct TxDesc) + 256];
  30554. +
  30555. +/* Create a static buffer of size RX_BUF_SZ for each
  30556. +TX Descriptor. All descriptors point to a
  30557. +part of this buffer */
  30558. +static unsigned char txb[NUM_TX_DESC * RX_BUF_SIZE];
  30559. +
  30560. +/* Define the RX Descriptor */
  30561. +static u8 rx_ring[NUM_RX_DESC * sizeof(struct TxDesc) + 256];
  30562. +
  30563. +/* Create a static buffer of size RX_BUF_SZ for each
  30564. +RX Descriptor All descriptors point to a
  30565. +part of this buffer */
  30566. +static unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE];
  30567. +
  30568. +struct rtl8169_private {
  30569. + void *mmio_addr; /* memory map physical address */
  30570. + int chipset;
  30571. + unsigned long cur_rx; /* Index into the Rx descriptor buffer of next Rx pkt. */
  30572. + unsigned long cur_tx; /* Index into the Tx descriptor buffer of next Rx pkt. */
  30573. + unsigned char *TxDescArrays; /* Index of Tx Descriptor buffer */
  30574. + unsigned char *RxDescArrays; /* Index of Rx Descriptor buffer */
  30575. + struct TxDesc *TxDescArray; /* Index of 256-alignment Tx Descriptor buffer */
  30576. + struct RxDesc *RxDescArray; /* Index of 256-alignment Rx Descriptor buffer */
  30577. + unsigned char *RxBufferRing[NUM_RX_DESC]; /* Index of Rx Buffer array */
  30578. + unsigned char *Tx_skbuff[NUM_TX_DESC];
  30579. +} tpx;
  30580. +
  30581. +static struct rtl8169_private *tpc;
  30582. +
  30583. +static const u16 rtl8169_intr_mask =
  30584. + SYSErr | PCSTimeout | RxUnderrun | RxOverflow | RxFIFOOver | TxErr |
  30585. + TxOK | RxErr | RxOK;
  30586. +static const unsigned int rtl8169_rx_config =
  30587. + (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift);
  30588. +
  30589. +void mdio_write(int RegAddr, int value)
  30590. +{
  30591. + int i;
  30592. +
  30593. + RTL_W32(PHYAR, 0x80000000 | (RegAddr & 0xFF) << 16 | value);
  30594. + udelay(1000);
  30595. +
  30596. + for (i = 2000; i > 0; i--) {
  30597. + /* Check if the RTL8169 has completed writing to the specified MII register */
  30598. + if (!(RTL_R32(PHYAR) & 0x80000000)) {
  30599. + break;
  30600. + } else {
  30601. + udelay(100);
  30602. + }
  30603. + }
  30604. +}
  30605. +
  30606. +int mdio_read(int RegAddr)
  30607. +{
  30608. + int i, value = -1;
  30609. +
  30610. + RTL_W32(PHYAR, 0x0 | (RegAddr & 0xFF) << 16);
  30611. + udelay(1000);
  30612. +
  30613. + for (i = 2000; i > 0; i--) {
  30614. + /* Check if the RTL8169 has completed retrieving data from the specified MII register */
  30615. + if (RTL_R32(PHYAR) & 0x80000000) {
  30616. + value = (int) (RTL_R32(PHYAR) & 0xFFFF);
  30617. + break;
  30618. + } else {
  30619. + udelay(100);
  30620. + }
  30621. + }
  30622. + return value;
  30623. +}
  30624. +
  30625. +static int rtl8169_init_board(struct pci_device *pdev)
  30626. +{
  30627. + int i;
  30628. + unsigned long rtreg_base, rtreg_len;
  30629. + u32 tmp;
  30630. +
  30631. + rtreg_base = pci_bar_start(pdev, PCI_BASE_ADDRESS_1);
  30632. + rtreg_len = pci_bar_size(pdev, PCI_BASE_ADDRESS_1);
  30633. +
  30634. + /* check for weird/broken PCI region reporting */
  30635. + if (rtreg_len < RTL_MIN_IO_SIZE) {
  30636. + printf("Invalid PCI region size(s), aborting\n");
  30637. + }
  30638. +
  30639. + adjust_pci_device(pdev);
  30640. +/* pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); */
  30641. +
  30642. + /* ioremap MMIO region */
  30643. + ioaddr = (unsigned long) ioremap(rtreg_base, rtreg_len);
  30644. + if (ioaddr == 0)
  30645. + return 0;
  30646. +
  30647. + tpc->mmio_addr = &ioaddr;
  30648. + /* Soft reset the chip. */
  30649. + RTL_W8(ChipCmd, CmdReset);
  30650. +
  30651. + /* Check that the chip has finished the reset. */
  30652. + for (i = 1000; i > 0; i--)
  30653. + if ((RTL_R8(ChipCmd) & CmdReset) == 0)
  30654. + break;
  30655. + else
  30656. + udelay(10);
  30657. +
  30658. + /* identify chip attached to board */
  30659. + tmp = RTL_R32(TxConfig);
  30660. + tmp = ((tmp & 0x7c000000) + ((tmp & 0x00800000) << 2)) >> 24;
  30661. +
  30662. + for (i = ARRAY_SIZE(rtl_chip_info) - 1; i >= 0; i--)
  30663. + if (tmp == rtl_chip_info[i].version) {
  30664. + tpc->chipset = i;
  30665. + goto match;
  30666. + }
  30667. + /* if unknown chip, assume array element #0, original RTL-8169 in this case */
  30668. + dprintf(("PCI device: unknown chip version, assuming RTL-8169\n"));
  30669. + dprintf(("PCI device: TxConfig = 0x%hX\n",
  30670. + (unsigned long) RTL_R32(TxConfig)));
  30671. + tpc->chipset = 0;
  30672. + return 1;
  30673. + match:
  30674. + return 0;
  30675. +
  30676. +}
  30677. +
  30678. +/**************************************************************************
  30679. +IRQ - Wait for a frame
  30680. +***************************************************************************/
  30681. +void r8169_irq ( struct nic *nic __unused, irq_action_t action ) {
  30682. + int intr_status = 0;
  30683. + int interested = RxUnderrun | RxOverflow | RxFIFOOver | RxErr | RxOK;
  30684. +
  30685. + switch ( action ) {
  30686. + case DISABLE:
  30687. + case ENABLE:
  30688. + intr_status = RTL_R16(IntrStatus);
  30689. + /* h/w no longer present (hotplug?) or major error,
  30690. + bail */
  30691. + if (intr_status == 0xFFFF)
  30692. + break;
  30693. +
  30694. + intr_status = intr_status & ~interested;
  30695. + if ( action == ENABLE )
  30696. + intr_status = intr_status | interested;
  30697. + RTL_W16(IntrMask, intr_status);
  30698. + break;
  30699. + case FORCE :
  30700. + RTL_W8(TxPoll, (RTL_R8(TxPoll) | 0x01));
  30701. + break;
  30702. + }
  30703. +}
  30704. +
  30705. +/**************************************************************************
  30706. +POLL - Wait for a frame
  30707. +***************************************************************************/
  30708. +static int r8169_poll(struct nic *nic, int retreive)
  30709. +{
  30710. + /* return true if there's an ethernet packet ready to read */
  30711. + /* nic->packet should contain data on return */
  30712. + /* nic->packetlen should contain length of data */
  30713. + int cur_rx;
  30714. + unsigned int intr_status = 0;
  30715. + cur_rx = tpc->cur_rx;
  30716. + if ((tpc->RxDescArray[cur_rx].status & OWNbit) == 0) {
  30717. + /* There is a packet ready */
  30718. + if(!retreive)
  30719. + return 1;
  30720. + intr_status = RTL_R16(IntrStatus);
  30721. + /* h/w no longer present (hotplug?) or major error,
  30722. + bail */
  30723. + if (intr_status == 0xFFFF)
  30724. + return 0;
  30725. + RTL_W16(IntrStatus, intr_status &
  30726. + ~(RxFIFOOver | RxOverflow | RxOK));
  30727. +
  30728. + if (!(tpc->RxDescArray[cur_rx].status & RxRES)) {
  30729. + nic->packetlen = (int) (tpc->RxDescArray[cur_rx].
  30730. + status & 0x00001FFF) - 4;
  30731. + memcpy(nic->packet, tpc->RxBufferRing[cur_rx],
  30732. + nic->packetlen);
  30733. + if (cur_rx == NUM_RX_DESC - 1)
  30734. + tpc->RxDescArray[cur_rx].status =
  30735. + (OWNbit | EORbit) + RX_BUF_SIZE;
  30736. + else
  30737. + tpc->RxDescArray[cur_rx].status =
  30738. + OWNbit + RX_BUF_SIZE;
  30739. + tpc->RxDescArray[cur_rx].buf_addr =
  30740. + virt_to_bus(tpc->RxBufferRing[cur_rx]);
  30741. + } else
  30742. + printf("Error Rx");
  30743. + /* FIXME: shouldn't I reset the status on an error */
  30744. + cur_rx = (cur_rx + 1) % NUM_RX_DESC;
  30745. + tpc->cur_rx = cur_rx;
  30746. + RTL_W16(IntrStatus, intr_status &
  30747. + (RxFIFOOver | RxOverflow | RxOK));
  30748. +
  30749. + return 1;
  30750. +
  30751. + }
  30752. + tpc->cur_rx = cur_rx;
  30753. + /* FIXME: There is no reason to do this as cur_rx did not change */
  30754. +
  30755. + return (0); /* initially as this is called to flush the input */
  30756. +
  30757. +}
  30758. +
  30759. +/**************************************************************************
  30760. +TRANSMIT - Transmit a frame
  30761. +***************************************************************************/
  30762. +static void r8169_transmit(struct nic *nic, const char *d, /* Destination */
  30763. + unsigned int t, /* Type */
  30764. + unsigned int s, /* size */
  30765. + const char *p)
  30766. +{ /* Packet */
  30767. + /* send the packet to destination */
  30768. +
  30769. + u16 nstype;
  30770. + u32 to;
  30771. + u8 *ptxb;
  30772. + int entry = tpc->cur_tx % NUM_TX_DESC;
  30773. +
  30774. + /* point to the current txb incase multiple tx_rings are used */
  30775. + ptxb = tpc->Tx_skbuff[entry * MAX_ETH_FRAME_SIZE];
  30776. + memcpy(ptxb, d, ETH_ALEN);
  30777. + memcpy(ptxb + ETH_ALEN, nic->node_addr, ETH_ALEN);
  30778. + nstype = htons((u16) t);
  30779. + memcpy(ptxb + 2 * ETH_ALEN, (u8 *) & nstype, 2);
  30780. + memcpy(ptxb + ETH_HLEN, p, s);
  30781. + s += ETH_HLEN;
  30782. + s &= 0x0FFF;
  30783. + while (s < ETH_ZLEN)
  30784. + ptxb[s++] = '\0';
  30785. +
  30786. + tpc->TxDescArray[entry].buf_addr = virt_to_bus(ptxb);
  30787. + if (entry != (NUM_TX_DESC - 1))
  30788. + tpc->TxDescArray[entry].status =
  30789. + (OWNbit | FSbit | LSbit) | ((s > ETH_ZLEN) ? s :
  30790. + ETH_ZLEN);
  30791. + else
  30792. + tpc->TxDescArray[entry].status =
  30793. + (OWNbit | EORbit | FSbit | LSbit) | ((s > ETH_ZLEN) ? s
  30794. + : ETH_ZLEN);
  30795. + RTL_W8(TxPoll, 0x40); /* set polling bit */
  30796. +
  30797. + tpc->cur_tx++;
  30798. + to = currticks() + TX_TIMEOUT;
  30799. + while ((tpc->TxDescArray[entry].status & OWNbit) && (currticks() < to)); /* wait */
  30800. +
  30801. + if (currticks() >= to) {
  30802. + printf("TX Time Out");
  30803. + }
  30804. +}
  30805. +
  30806. +static void rtl8169_set_rx_mode(struct nic *nic __unused)
  30807. +{
  30808. + u32 mc_filter[2]; /* Multicast hash filter */
  30809. + int rx_mode;
  30810. + u32 tmp = 0;
  30811. +
  30812. + /* IFF_ALLMULTI */
  30813. + /* Too many to filter perfectly -- accept all multicasts. */
  30814. + rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
  30815. + mc_filter[1] = mc_filter[0] = 0xffffffff;
  30816. +
  30817. + tmp =
  30818. + rtl8169_rx_config | rx_mode | (RTL_R32(RxConfig) &
  30819. + rtl_chip_info[tpc->chipset].
  30820. + RxConfigMask);
  30821. +
  30822. + RTL_W32(RxConfig, tmp);
  30823. + RTL_W32(MAR0 + 0, mc_filter[0]);
  30824. + RTL_W32(MAR0 + 4, mc_filter[1]);
  30825. +}
  30826. +static void rtl8169_hw_start(struct nic *nic)
  30827. +{
  30828. + u32 i;
  30829. +
  30830. + /* Soft reset the chip. */
  30831. + RTL_W8(ChipCmd, CmdReset);
  30832. +
  30833. + /* Check that the chip has finished the reset. */
  30834. + for (i = 1000; i > 0; i--) {
  30835. + if ((RTL_R8(ChipCmd) & CmdReset) == 0)
  30836. + break;
  30837. + else
  30838. + udelay(10);
  30839. + }
  30840. +
  30841. + RTL_W8(Cfg9346, Cfg9346_Unlock);
  30842. + RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
  30843. + RTL_W8(EarlyTxThres, EarlyTxThld);
  30844. +
  30845. + /* For gigabit rtl8169 */
  30846. + RTL_W16(RxMaxSize, RxPacketMaxSize);
  30847. +
  30848. + /* Set Rx Config register */
  30849. + i = rtl8169_rx_config | (RTL_R32(RxConfig) &
  30850. + rtl_chip_info[tpc->chipset].RxConfigMask);
  30851. + RTL_W32(RxConfig, i);
  30852. +
  30853. + /* Set DMA burst size and Interframe Gap Time */
  30854. + RTL_W32(TxConfig,
  30855. + (TX_DMA_BURST << TxDMAShift) | (InterFrameGap <<
  30856. + TxInterFrameGapShift));
  30857. +
  30858. +
  30859. + tpc->cur_rx = 0;
  30860. +
  30861. + RTL_W32(TxDescStartAddr, virt_to_le32desc(tpc->TxDescArray));
  30862. + RTL_W32(RxDescStartAddr, virt_to_le32desc(tpc->RxDescArray));
  30863. + RTL_W8(Cfg9346, Cfg9346_Lock);
  30864. + udelay(10);
  30865. +
  30866. + RTL_W32(RxMissed, 0);
  30867. +
  30868. + rtl8169_set_rx_mode(nic);
  30869. +
  30870. + /* no early-rx interrupts */
  30871. + RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000);
  30872. +}
  30873. +
  30874. +static void rtl8169_init_ring(struct nic *nic __unused)
  30875. +{
  30876. + int i;
  30877. +
  30878. + tpc->cur_rx = 0;
  30879. + tpc->cur_tx = 0;
  30880. + memset(tpc->TxDescArray, 0x0, NUM_TX_DESC * sizeof(struct TxDesc));
  30881. + memset(tpc->RxDescArray, 0x0, NUM_RX_DESC * sizeof(struct RxDesc));
  30882. +
  30883. + for (i = 0; i < NUM_TX_DESC; i++) {
  30884. + tpc->Tx_skbuff[i] = &txb[i];
  30885. + }
  30886. +
  30887. + for (i = 0; i < NUM_RX_DESC; i++) {
  30888. + if (i == (NUM_RX_DESC - 1))
  30889. + tpc->RxDescArray[i].status =
  30890. + (OWNbit | EORbit) + RX_BUF_SIZE;
  30891. + else
  30892. + tpc->RxDescArray[i].status = OWNbit + RX_BUF_SIZE;
  30893. +
  30894. + tpc->RxBufferRing[i] = &rxb[i * RX_BUF_SIZE];
  30895. + tpc->RxDescArray[i].buf_addr =
  30896. + virt_to_bus(tpc->RxBufferRing[i]);
  30897. + }
  30898. +}
  30899. +
  30900. +/**************************************************************************
  30901. +RESET - Finish setting up the ethernet interface
  30902. +***************************************************************************/
  30903. +static void r8169_reset(struct nic *nic)
  30904. +{
  30905. + int i;
  30906. + u8 diff;
  30907. + u32 TxPhyAddr, RxPhyAddr;
  30908. +
  30909. + tpc->TxDescArrays = tx_ring;
  30910. + if (tpc->TxDescArrays == 0)
  30911. + printf("Allot Error");
  30912. + /* Tx Desscriptor needs 256 bytes alignment; */
  30913. + TxPhyAddr = virt_to_bus(tpc->TxDescArrays);
  30914. + diff = 256 - (TxPhyAddr - ((TxPhyAddr >> 8) << 8));
  30915. + TxPhyAddr += diff;
  30916. + tpc->TxDescArray = (struct TxDesc *) (tpc->TxDescArrays + diff);
  30917. +
  30918. + tpc->RxDescArrays = rx_ring;
  30919. + /* Rx Desscriptor needs 256 bytes alignment; */
  30920. + RxPhyAddr = virt_to_bus(tpc->RxDescArrays);
  30921. + diff = 256 - (RxPhyAddr - ((RxPhyAddr >> 8) << 8));
  30922. + RxPhyAddr += diff;
  30923. + tpc->RxDescArray = (struct RxDesc *) (tpc->RxDescArrays + diff);
  30924. +
  30925. + if (tpc->TxDescArrays == NULL || tpc->RxDescArrays == NULL) {
  30926. + printf("Allocate RxDescArray or TxDescArray failed\n");
  30927. + return;
  30928. + }
  30929. +
  30930. + rtl8169_init_ring(nic);
  30931. + rtl8169_hw_start(nic);
  30932. + /* Construct a perfect filter frame with the mac address as first match
  30933. + * and broadcast for all others */
  30934. + for (i = 0; i < 192; i++)
  30935. + txb[i] = 0xFF;
  30936. +
  30937. + txb[0] = nic->node_addr[0];
  30938. + txb[1] = nic->node_addr[1];
  30939. + txb[2] = nic->node_addr[2];
  30940. + txb[3] = nic->node_addr[3];
  30941. + txb[4] = nic->node_addr[4];
  30942. + txb[5] = nic->node_addr[5];
  30943. +}
  30944. +
  30945. +/**************************************************************************
  30946. +DISABLE - Turn off ethernet interface
  30947. +***************************************************************************/
  30948. +static void r8169_disable(struct dev *dev __unused)
  30949. +{
  30950. + int i;
  30951. + /* Stop the chip's Tx and Rx DMA processes. */
  30952. + RTL_W8(ChipCmd, 0x00);
  30953. +
  30954. + /* Disable interrupts by clearing the interrupt mask. */
  30955. + RTL_W16(IntrMask, 0x0000);
  30956. +
  30957. + RTL_W32(RxMissed, 0);
  30958. +
  30959. + tpc->TxDescArrays = NULL;
  30960. + tpc->RxDescArrays = NULL;
  30961. + tpc->TxDescArray = NULL;
  30962. + tpc->RxDescArray = NULL;
  30963. + for (i = 0; i < NUM_RX_DESC; i++) {
  30964. + tpc->RxBufferRing[i] = NULL;
  30965. + }
  30966. +}
  30967. +
  30968. +/**************************************************************************
  30969. +PROBE - Look for an adapter, this routine's visible to the outside
  30970. +***************************************************************************/
  30971. +
  30972. +#define board_found 1
  30973. +#define valid_link 0
  30974. +static int r8169_probe(struct dev *dev, struct pci_device *pci)
  30975. +{
  30976. + struct nic *nic = (struct nic *) dev;
  30977. + static int board_idx = -1;
  30978. + static int printed_version = 0;
  30979. + int i, rc;
  30980. + int option = -1, Cap10_100 = 0, Cap1000 = 0;
  30981. +
  30982. + printf("r8169.c: Found %s, Vendor=%hX Device=%hX\n",
  30983. + pci->name, pci->vendor, pci->dev_id);
  30984. +
  30985. + board_idx++;
  30986. +
  30987. + printed_version = 1;
  30988. +
  30989. + /* point to private storage */
  30990. + tpc = &tpx;
  30991. +
  30992. + rc = rtl8169_init_board(pci); /* Return code is meaningless */
  30993. +
  30994. + /* Get MAC address. FIXME: read EEPROM */
  30995. + for (i = 0; i < MAC_ADDR_LEN; i++)
  30996. + nic->node_addr[i] = RTL_R8(MAC0 + i);
  30997. +
  30998. + dprintf(("%s: Identified chip type is '%s'.\n", pci->name,
  30999. + rtl_chip_info[tpc->chipset].name));
  31000. + /* Print out some hardware info */
  31001. + printf("%s: %! at ioaddr %hX, ", pci->name, nic->node_addr,
  31002. + ioaddr);
  31003. +
  31004. + /* if TBI is not endbled */
  31005. + if (!(RTL_R8(PHYstatus) & TBI_Enable)) {
  31006. + int val = mdio_read(PHY_AUTO_NEGO_REG);
  31007. +
  31008. + option = media;
  31009. + /* Force RTL8169 in 10/100/1000 Full/Half mode. */
  31010. + if (option > 0) {
  31011. + printf(" Force-mode Enabled.\n");
  31012. + Cap10_100 = 0, Cap1000 = 0;
  31013. + switch (option) {
  31014. + case _10_Half:
  31015. + Cap10_100 = PHY_Cap_10_Half;
  31016. + Cap1000 = PHY_Cap_Null;
  31017. + break;
  31018. + case _10_Full:
  31019. + Cap10_100 = PHY_Cap_10_Full;
  31020. + Cap1000 = PHY_Cap_Null;
  31021. + break;
  31022. + case _100_Half:
  31023. + Cap10_100 = PHY_Cap_100_Half;
  31024. + Cap1000 = PHY_Cap_Null;
  31025. + break;
  31026. + case _100_Full:
  31027. + Cap10_100 = PHY_Cap_100_Full;
  31028. + Cap1000 = PHY_Cap_Null;
  31029. + break;
  31030. + case _1000_Full:
  31031. + Cap10_100 = PHY_Cap_Null;
  31032. + Cap1000 = PHY_Cap_1000_Full;
  31033. + break;
  31034. + default:
  31035. + break;
  31036. + }
  31037. + /* leave PHY_AUTO_NEGO_REG bit4:0 unchanged */
  31038. + mdio_write(PHY_AUTO_NEGO_REG,
  31039. + Cap10_100 | (val & 0x1F));
  31040. + mdio_write(PHY_1000_CTRL_REG, Cap1000);
  31041. + } else {
  31042. + dprintf(("Auto-negotiation Enabled.\n",
  31043. + pci->name));
  31044. +
  31045. + /* enable 10/100 Full/Half Mode, leave PHY_AUTO_NEGO_REG bit4:0 unchanged */
  31046. + mdio_write(PHY_AUTO_NEGO_REG,
  31047. + PHY_Cap_10_Half | PHY_Cap_10_Full |
  31048. + PHY_Cap_100_Half | PHY_Cap_100_Full |
  31049. + (val & 0x1F));
  31050. +
  31051. + /* enable 1000 Full Mode */
  31052. + mdio_write(PHY_1000_CTRL_REG, PHY_Cap_1000_Full);
  31053. +
  31054. + }
  31055. +
  31056. + /* Enable auto-negotiation and restart auto-nigotiation */
  31057. + mdio_write(PHY_CTRL_REG,
  31058. + PHY_Enable_Auto_Nego | PHY_Restart_Auto_Nego);
  31059. + udelay(100);
  31060. +
  31061. + /* wait for auto-negotiation process */
  31062. + for (i = 10000; i > 0; i--) {
  31063. + /* Check if auto-negotiation complete */
  31064. + if (mdio_read(PHY_STAT_REG) & PHY_Auto_Neco_Comp) {
  31065. + udelay(100);
  31066. + option = RTL_R8(PHYstatus);
  31067. + if (option & _1000bpsF) {
  31068. + printf
  31069. + ("1000Mbps Full-duplex operation.\n");
  31070. + } else {
  31071. + printf
  31072. + ("%sMbps %s-duplex operation.\n",
  31073. + (option & _100bps) ? "100" :
  31074. + "10",
  31075. + (option & FullDup) ? "Full" :
  31076. + "Half");
  31077. + }
  31078. + break;
  31079. + } else {
  31080. + udelay(100);
  31081. + }
  31082. + } /* end for-loop to wait for auto-negotiation process */
  31083. +
  31084. + } else {
  31085. + udelay(100);
  31086. + printf
  31087. + ("%s: 1000Mbps Full-duplex operation, TBI Link %s!\n",
  31088. + pci->name,
  31089. + (RTL_R32(TBICSR) & TBILinkOK) ? "OK" : "Failed");
  31090. +
  31091. + }
  31092. +
  31093. + r8169_reset(nic);
  31094. + /* point to NIC specific routines */
  31095. + dev->disable = r8169_disable;
  31096. + nic->poll = r8169_poll;
  31097. + nic->transmit = r8169_transmit;
  31098. + nic->irqno = pci->irq;
  31099. + nic->irq = r8169_irq;
  31100. + nic->ioaddr = ioaddr;
  31101. + return 1;
  31102. +
  31103. +}
  31104. +
  31105. +static struct pci_id r8169_nics[] = {
  31106. + PCI_ROM(0x10ec, 0x8169, "r8169", "RealTek RTL8169 Gigabit Ethernet"),
  31107. +};
  31108. +
  31109. +struct pci_driver r8169_driver = {
  31110. + .type = NIC_DRIVER,
  31111. + .name = "r8169/PCI",
  31112. + .probe = r8169_probe,
  31113. + .ids = r8169_nics,
  31114. + .id_count = sizeof(r8169_nics) / sizeof(r8169_nics[0]),
  31115. + .class = 0,
  31116. +};
  31117. Index: b/netboot/rtl8139.c
  31118. ===================================================================
  31119. --- a/netboot/rtl8139.c
  31120. +++ b/netboot/rtl8139.c
  31121. @@ -17,6 +17,8 @@
  31122. /*********************************************************************/
  31123. /*
  31124. + 28 Dec 2002 ken_yap@users.sourceforge.net (Ken Yap)
  31125. + Put in virt_to_bus calls to allow Etherboot relocation.
  31126. 06 Apr 2001 ken_yap@users.sourceforge.net (Ken Yap)
  31127. Following email from Hyun-Joon Cha, added a disable routine, otherwise
  31128. @@ -63,7 +65,6 @@
  31129. #include "etherboot.h"
  31130. #include "nic.h"
  31131. #include "pci.h"
  31132. -#include "cards.h"
  31133. #include "timer.h"
  31134. #define RTL_TIMEOUT (1*TICKS_PER_SEC)
  31135. @@ -112,9 +113,19 @@
  31136. * definitions we will probably never need to know about. */
  31137. };
  31138. +enum RxEarlyStatusBits {
  31139. + ERGood=0x08, ERBad=0x04, EROVW=0x02, EROK=0x01
  31140. +};
  31141. +
  31142. enum ChipCmdBits {
  31143. CmdReset=0x10, CmdRxEnb=0x08, CmdTxEnb=0x04, RxBufEmpty=0x01, };
  31144. +enum IntrMaskBits {
  31145. + SERR=0x8000, TimeOut=0x4000, LenChg=0x2000,
  31146. + FOVW=0x40, PUN_LinkChg=0x20, RXOVW=0x10,
  31147. + TER=0x08, TOK=0x04, RER=0x02, ROK=0x01
  31148. +};
  31149. +
  31150. /* Interrupt register bits, using my own meaningful names. */
  31151. enum IntrStatusBits {
  31152. PCIErr=0x8000, PCSTimeout=0x4000, CableLenChange= 0x2000,
  31153. @@ -155,74 +166,68 @@
  31154. AcceptMulticast=0x04, AcceptMyPhys=0x02, AcceptAllPhys=0x01,
  31155. };
  31156. -static int ioaddr;
  31157. static unsigned int cur_rx,cur_tx;
  31158. /* The RTL8139 can only transmit from a contiguous, aligned memory block. */
  31159. static unsigned char tx_buffer[TX_BUF_SIZE] __attribute__((aligned(4)));
  31160. -
  31161. -/* I know that this is a MEGA HACK, but the tagged boot image specification
  31162. - * states that we can do whatever we want below 0x10000 - so we do! */
  31163. -/* But we still give the user the choice of using an internal buffer
  31164. - just in case - Ken */
  31165. -#ifdef USE_LOWMEM_BUFFER
  31166. -#define rx_ring ((unsigned char *)(0x10000 - (RX_BUF_LEN + 16)))
  31167. -#else
  31168. static unsigned char rx_ring[RX_BUF_LEN+16] __attribute__((aligned(4)));
  31169. -#endif
  31170. -struct nic *rtl8139_probe(struct nic *nic, unsigned short *probeaddrs,
  31171. - struct pci_device *pci);
  31172. -static int read_eeprom(int location);
  31173. +static int rtl8139_probe(struct dev *dev, struct pci_device *pci);
  31174. +static int read_eeprom(struct nic *nic, int location, int addr_len);
  31175. static void rtl_reset(struct nic *nic);
  31176. static void rtl_transmit(struct nic *nic, const char *destaddr,
  31177. unsigned int type, unsigned int len, const char *data);
  31178. -static int rtl_poll(struct nic *nic);
  31179. -static void rtl_disable(struct nic*);
  31180. +static int rtl_poll(struct nic *nic, int retrieve);
  31181. +static void rtl_disable(struct dev *);
  31182. +static void rtl_irq(struct nic *nic, irq_action_t action);
  31183. -struct nic *rtl8139_probe(struct nic *nic, unsigned short *probeaddrs,
  31184. - struct pci_device *pci)
  31185. +static int rtl8139_probe(struct dev *dev, struct pci_device *pci)
  31186. {
  31187. + struct nic *nic = (struct nic *)dev;
  31188. int i;
  31189. int speed10, fullduplex;
  31190. + int addr_len;
  31191. + unsigned short *ap = (unsigned short*)nic->node_addr;
  31192. /* There are enough "RTL8139" strings on the console already, so
  31193. * be brief and concentrate on the interesting pieces of info... */
  31194. printf(" - ");
  31195. /* Mask the bit that says "this is an io addr" */
  31196. - ioaddr = probeaddrs[0] & ~3;
  31197. + nic->ioaddr = pci->ioaddr & ~3;
  31198. +
  31199. + /* Copy IRQ from PCI information */
  31200. + nic->irqno = pci->irq;
  31201. adjust_pci_device(pci);
  31202. /* Bring the chip out of low-power mode. */
  31203. - outb(0x00, ioaddr + Config1);
  31204. -
  31205. - if (read_eeprom(0) != 0xffff) {
  31206. - unsigned short *ap = (unsigned short*)nic->node_addr;
  31207. - for (i = 0; i < 3; i++)
  31208. - *ap++ = read_eeprom(i + 7);
  31209. - } else {
  31210. - unsigned char *ap = (unsigned char*)nic->node_addr;
  31211. - for (i = 0; i < ETH_ALEN; i++)
  31212. - *ap++ = inb(ioaddr + MAC0 + i);
  31213. - }
  31214. + outb(0x00, nic->ioaddr + Config1);
  31215. - speed10 = inb(ioaddr + MediaStatus) & MSRSpeed10;
  31216. - fullduplex = inw(ioaddr + MII_BMCR) & BMCRDuplex;
  31217. - printf("ioaddr %#hX, addr %! %sMbps %s-duplex\n", ioaddr,
  31218. - nic->node_addr, speed10 ? "10" : "100",
  31219. - fullduplex ? "full" : "half");
  31220. + addr_len = read_eeprom(nic,0,8) == 0x8129 ? 8 : 6;
  31221. + for (i = 0; i < 3; i++)
  31222. + *ap++ = read_eeprom(nic,i + 7,addr_len);
  31223. +
  31224. + speed10 = inb(nic->ioaddr + MediaStatus) & MSRSpeed10;
  31225. + fullduplex = inw(nic->ioaddr + MII_BMCR) & BMCRDuplex;
  31226. + printf("ioaddr %#hX, irq %d, addr %! %sMbps %s-duplex\n", nic->ioaddr,
  31227. + nic->irqno, nic->node_addr, speed10 ? "10" : "100",
  31228. + fullduplex ? "full" : "half");
  31229. rtl_reset(nic);
  31230. - nic->reset = rtl_reset;
  31231. - nic->poll = rtl_poll;
  31232. + if (inb(nic->ioaddr + MediaStatus) & MSRLinkFail) {
  31233. + printf("Cable not connected or other link failure\n");
  31234. + return(0);
  31235. + }
  31236. +
  31237. + dev->disable = rtl_disable;
  31238. + nic->poll = rtl_poll;
  31239. nic->transmit = rtl_transmit;
  31240. - nic->disable = rtl_disable;
  31241. + nic->irq = rtl_irq;
  31242. - return nic;
  31243. + return 1;
  31244. }
  31245. /* Serial EEPROM section. */
  31246. @@ -244,22 +249,23 @@
  31247. #define eeprom_delay() inl(ee_addr)
  31248. /* The EEPROM commands include the alway-set leading bit. */
  31249. -#define EE_WRITE_CMD (5 << 6)
  31250. -#define EE_READ_CMD (6 << 6)
  31251. -#define EE_ERASE_CMD (7 << 6)
  31252. +#define EE_WRITE_CMD (5)
  31253. +#define EE_READ_CMD (6)
  31254. +#define EE_ERASE_CMD (7)
  31255. -static int read_eeprom(int location)
  31256. +static int read_eeprom(struct nic *nic, int location, int addr_len)
  31257. {
  31258. int i;
  31259. unsigned int retval = 0;
  31260. - long ee_addr = ioaddr + Cfg9346;
  31261. - int read_cmd = location | EE_READ_CMD;
  31262. + long ee_addr = nic->ioaddr + Cfg9346;
  31263. + int read_cmd = location | (EE_READ_CMD << addr_len);
  31264. outb(EE_ENB & ~EE_CS, ee_addr);
  31265. outb(EE_ENB, ee_addr);
  31266. + eeprom_delay();
  31267. /* Shift the read command bits out. */
  31268. - for (i = 10; i >= 0; i--) {
  31269. + for (i = 4 + addr_len; i >= 0; i--) {
  31270. int dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
  31271. outb(EE_ENB | dataval, ee_addr);
  31272. eeprom_delay();
  31273. @@ -279,31 +285,51 @@
  31274. /* Terminate the EEPROM access. */
  31275. outb(~EE_CS, ee_addr);
  31276. + eeprom_delay();
  31277. return retval;
  31278. }
  31279. +static const unsigned int rtl8139_rx_config =
  31280. + (RX_BUF_LEN_IDX << 11) |
  31281. + (RX_FIFO_THRESH << 13) |
  31282. + (RX_DMA_BURST << 8);
  31283. +
  31284. +static void set_rx_mode(struct nic *nic) {
  31285. + unsigned int mc_filter[2];
  31286. + int rx_mode;
  31287. + /* !IFF_PROMISC */
  31288. + rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
  31289. + mc_filter[1] = mc_filter[0] = 0xffffffff;
  31290. +
  31291. + outl(rtl8139_rx_config | rx_mode, nic->ioaddr + RxConfig);
  31292. +
  31293. + outl(mc_filter[0], nic->ioaddr + MAR0 + 0);
  31294. + outl(mc_filter[1], nic->ioaddr + MAR0 + 4);
  31295. +}
  31296. +
  31297. static void rtl_reset(struct nic* nic)
  31298. {
  31299. int i;
  31300. - outb(CmdReset, ioaddr + ChipCmd);
  31301. + outb(CmdReset, nic->ioaddr + ChipCmd);
  31302. cur_rx = 0;
  31303. cur_tx = 0;
  31304. /* Give the chip 10ms to finish the reset. */
  31305. load_timer2(10*TICKS_PER_MS);
  31306. - while ((inb(ioaddr + ChipCmd) & CmdReset) != 0 && timer2_running())
  31307. + while ((inb(nic->ioaddr + ChipCmd) & CmdReset) != 0 &&
  31308. + timer2_running())
  31309. /* wait */;
  31310. for (i = 0; i < ETH_ALEN; i++)
  31311. - outb(nic->node_addr[i], ioaddr + MAC0 + i);
  31312. + outb(nic->node_addr[i], nic->ioaddr + MAC0 + i);
  31313. /* Must enable Tx/Rx before setting transfer thresholds! */
  31314. - outb(CmdRxEnb | CmdTxEnb, ioaddr + ChipCmd);
  31315. + outb(CmdRxEnb | CmdTxEnb, nic->ioaddr + ChipCmd);
  31316. outl((RX_FIFO_THRESH<<13) | (RX_BUF_LEN_IDX<<11) | (RX_DMA_BURST<<8),
  31317. - ioaddr + RxConfig); /* accept no frames yet! */
  31318. - outl((TX_DMA_BURST<<8)|0x03000000, ioaddr + TxConfig);
  31319. + nic->ioaddr + RxConfig); /* accept no frames yet! */
  31320. + outl((TX_DMA_BURST<<8)|0x03000000, nic->ioaddr + TxConfig);
  31321. /* The Linux driver changes Config1 here to use a different LED pattern
  31322. * for half duplex or full/autodetect duplex (for full/autodetect, the
  31323. @@ -316,19 +342,26 @@
  31324. #ifdef DEBUG_RX
  31325. printf("rx ring address is %X\n",(unsigned long)rx_ring);
  31326. #endif
  31327. - outl((unsigned long)rx_ring, ioaddr + RxBuf);
  31328. + outl((unsigned long)virt_to_bus(rx_ring), nic->ioaddr + RxBuf);
  31329. +
  31330. +
  31331. - /* Start the chip's Tx and Rx process. */
  31332. - outl(0, ioaddr + RxMissed);
  31333. - /* set_rx_mode */
  31334. - outb(AcceptBroadcast|AcceptMyPhys, ioaddr + RxConfig);
  31335. /* If we add multicast support, the MAR0 register would have to be
  31336. * initialized to 0xffffffffffffffff (two 32 bit accesses). Etherboot
  31337. * only needs broadcast (for ARP/RARP/BOOTP/DHCP) and unicast. */
  31338. - outb(CmdRxEnb | CmdTxEnb, ioaddr + ChipCmd);
  31339. + outb(CmdRxEnb | CmdTxEnb, nic->ioaddr + ChipCmd);
  31340. +
  31341. + outl(rtl8139_rx_config, nic->ioaddr + RxConfig);
  31342. +
  31343. + /* Start the chip's Tx and Rx process. */
  31344. + outl(0, nic->ioaddr + RxMissed);
  31345. +
  31346. + /* set_rx_mode */
  31347. + set_rx_mode(nic);
  31348. +
  31349. /* Disable all known interrupts by setting the interrupt mask. */
  31350. - outw(0, ioaddr + IntrMask);
  31351. + outw(0, nic->ioaddr + IntrMask);
  31352. }
  31353. static void rtl_transmit(struct nic *nic, const char *destaddr,
  31354. @@ -337,10 +370,11 @@
  31355. unsigned int status, to, nstype;
  31356. unsigned long txstatus;
  31357. + /* nstype assignment moved up here to avoid gcc 3.0.3 compiler bug */
  31358. + nstype = htons(type);
  31359. memcpy(tx_buffer, destaddr, ETH_ALEN);
  31360. memcpy(tx_buffer + ETH_ALEN, nic->node_addr, ETH_ALEN);
  31361. - nstype = htons(type);
  31362. - memcpy(tx_buffer + 2 * ETH_ALEN, (char*)&nstype, 2);
  31363. + memcpy(tx_buffer + 2 * ETH_ALEN, &nstype, 2);
  31364. memcpy(tx_buffer + ETH_HLEN, data, len);
  31365. len += ETH_HLEN;
  31366. @@ -354,22 +388,22 @@
  31367. tx_buffer[len++] = '\0';
  31368. }
  31369. - outl((unsigned long)tx_buffer, ioaddr + TxAddr0 + cur_tx*4);
  31370. + outl((unsigned long)virt_to_bus(tx_buffer), nic->ioaddr + TxAddr0 + cur_tx*4);
  31371. outl(((TX_FIFO_THRESH<<11) & 0x003f0000) | len,
  31372. - ioaddr + TxStatus0 + cur_tx*4);
  31373. + nic->ioaddr + TxStatus0 + cur_tx*4);
  31374. to = currticks() + RTL_TIMEOUT;
  31375. do {
  31376. - status = inw(ioaddr + IntrStatus);
  31377. + status = inw(nic->ioaddr + IntrStatus);
  31378. /* Only acknlowledge interrupt sources we can properly handle
  31379. * here - the RxOverflow/RxFIFOOver MUST be handled in the
  31380. * rtl_poll() function. */
  31381. - outw(status & (TxOK | TxErr | PCIErr), ioaddr + IntrStatus);
  31382. + outw(status & (TxOK | TxErr | PCIErr), nic->ioaddr + IntrStatus);
  31383. if ((status & (TxOK | TxErr | PCIErr)) != 0) break;
  31384. } while (currticks() < to);
  31385. - txstatus = inl(ioaddr+ TxStatus0 + cur_tx*4);
  31386. + txstatus = inl(nic->ioaddr+ TxStatus0 + cur_tx*4);
  31387. if (status & TxOK) {
  31388. cur_tx = (cur_tx + 1) % NUM_TX_DESC;
  31389. @@ -386,19 +420,22 @@
  31390. }
  31391. }
  31392. -static int rtl_poll(struct nic *nic)
  31393. +static int rtl_poll(struct nic *nic, int retrieve)
  31394. {
  31395. unsigned int status;
  31396. unsigned int ring_offs;
  31397. unsigned int rx_size, rx_status;
  31398. - if (inb(ioaddr + ChipCmd) & RxBufEmpty) {
  31399. + if (inb(nic->ioaddr + ChipCmd) & RxBufEmpty) {
  31400. return 0;
  31401. }
  31402. - status = inw(ioaddr + IntrStatus);
  31403. + /* There is a packet ready */
  31404. + if ( ! retrieve ) return 1;
  31405. +
  31406. + status = inw(nic->ioaddr + IntrStatus);
  31407. /* See below for the rest of the interrupt acknowledges. */
  31408. - outw(status & ~(RxFIFOOver | RxOverflow | RxOK), ioaddr + IntrStatus);
  31409. + outw(status & ~(RxFIFOOver | RxOverflow | RxOK), nic->ioaddr + IntrStatus);
  31410. #ifdef DEBUG_RX
  31411. printf("rtl_poll: int %hX ", status);
  31412. @@ -438,21 +475,77 @@
  31413. nic->packet[12], nic->packet[13], rx_status);
  31414. #endif
  31415. cur_rx = (cur_rx + rx_size + 4 + 3) & ~3;
  31416. - outw(cur_rx - 16, ioaddr + RxBufPtr);
  31417. + outw(cur_rx - 16, nic->ioaddr + RxBufPtr);
  31418. /* See RTL8139 Programming Guide V0.1 for the official handling of
  31419. * Rx overflow situations. The document itself contains basically no
  31420. * usable information, except for a few exception handling rules. */
  31421. - outw(status & (RxFIFOOver | RxOverflow | RxOK), ioaddr + IntrStatus);
  31422. + outw(status & (RxFIFOOver | RxOverflow | RxOK), nic->ioaddr + IntrStatus);
  31423. return 1;
  31424. }
  31425. -static void rtl_disable(struct nic *nic)
  31426. +static void rtl_irq(struct nic *nic, irq_action_t action)
  31427. {
  31428. + unsigned int mask;
  31429. + /* Bit of a guess as to which interrupts we should allow */
  31430. + unsigned int interested = ROK | RER | RXOVW | FOVW | SERR;
  31431. +
  31432. + switch ( action ) {
  31433. + case DISABLE :
  31434. + case ENABLE :
  31435. + mask = inw(nic->ioaddr + IntrMask);
  31436. + mask = mask & ~interested;
  31437. + if ( action == ENABLE ) mask = mask | interested;
  31438. + outw(mask, nic->ioaddr + IntrMask);
  31439. + break;
  31440. + case FORCE :
  31441. + /* Apparently writing a 1 to this read-only bit of a
  31442. + * read-only and otherwise unrelated register will
  31443. + * force an interrupt. If you ever want to see how
  31444. + * not to write a datasheet, read the one for the
  31445. + * RTL8139...
  31446. + */
  31447. + outb(EROK, nic->ioaddr + RxEarlyStatus);
  31448. + break;
  31449. + }
  31450. +}
  31451. +
  31452. +static void rtl_disable(struct dev *dev)
  31453. +{
  31454. + struct nic *nic = (struct nic *)dev;
  31455. + /* merge reset and disable */
  31456. + rtl_reset(nic);
  31457. +
  31458. /* reset the chip */
  31459. - outb(CmdReset, ioaddr + ChipCmd);
  31460. + outb(CmdReset, nic->ioaddr + ChipCmd);
  31461. /* 10 ms timeout */
  31462. load_timer2(10*TICKS_PER_MS);
  31463. - while ((inb(ioaddr + ChipCmd) & CmdReset) != 0 && timer2_running())
  31464. + while ((inb(nic->ioaddr + ChipCmd) & CmdReset) != 0 && timer2_running())
  31465. /* wait */;
  31466. }
  31467. +
  31468. +static struct pci_id rtl8139_nics[] = {
  31469. +PCI_ROM(0x10ec, 0x8129, "rtl8129", "Realtek 8129"),
  31470. +PCI_ROM(0x10ec, 0x8139, "rtl8139", "Realtek 8139"),
  31471. +PCI_ROM(0x10ec, 0x8138, "rtl8139b", "Realtek 8139B"),
  31472. +PCI_ROM(0x1186, 0x1300, "dfe538", "DFE530TX+/DFE538TX"),
  31473. +PCI_ROM(0x1113, 0x1211, "smc1211-1", "SMC EZ10/100"),
  31474. +PCI_ROM(0x1112, 0x1211, "smc1211", "SMC EZ10/100"),
  31475. +PCI_ROM(0x1500, 0x1360, "delta8139", "Delta Electronics 8139"),
  31476. +PCI_ROM(0x4033, 0x1360, "addtron8139", "Addtron Technology 8139"),
  31477. +PCI_ROM(0x1186, 0x1340, "dfe690txd", "D-Link DFE690TXD"),
  31478. +PCI_ROM(0x13d1, 0xab06, "fe2000vx", "AboCom FE2000VX"),
  31479. +PCI_ROM(0x1259, 0xa117, "allied8139", "Allied Telesyn 8139"),
  31480. +PCI_ROM(0x14ea, 0xab06, "fnw3603tx", "Planex FNW-3603-TX"),
  31481. +PCI_ROM(0x14ea, 0xab07, "fnw3800tx", "Planex FNW-3800-TX"),
  31482. +PCI_ROM(0xffff, 0x8139, "clone-rtl8139", "Cloned 8139"),
  31483. +};
  31484. +
  31485. +struct pci_driver rtl8139_driver = {
  31486. + .type = NIC_DRIVER,
  31487. + .name = "RTL8139",
  31488. + .probe = rtl8139_probe,
  31489. + .ids = rtl8139_nics,
  31490. + .id_count = sizeof(rtl8139_nics)/sizeof(rtl8139_nics[0]),
  31491. + .class = 0,
  31492. +};
  31493. Index: b/netboot/segoff.h
  31494. ===================================================================
  31495. --- /dev/null
  31496. +++ b/netboot/segoff.h
  31497. @@ -0,0 +1,43 @@
  31498. +/*
  31499. + * Segment:offset types and macros
  31500. + *
  31501. + * Initially written by Michael Brown (mcb30).
  31502. + */
  31503. +
  31504. +#ifndef SEGOFF_H
  31505. +#define SEGOFF_H
  31506. +
  31507. +#include <stdint.h>
  31508. +#include <io.h>
  31509. +
  31510. +/* Segment:offset structure. Note that the order within the structure
  31511. + * is offset:segment.
  31512. + */
  31513. +typedef struct {
  31514. + uint16_t offset;
  31515. + uint16_t segment;
  31516. +} segoff_t;
  31517. +
  31518. +/* For PXE stuff */
  31519. +typedef segoff_t SEGOFF16_t;
  31520. +
  31521. +/* Macros for converting from virtual to segment:offset addresses,
  31522. + * when we don't actually care which of the many isomorphic results we
  31523. + * get.
  31524. + */
  31525. +#ifdef DEBUG_SEGMENT
  31526. +uint16_t SEGMENT ( const void * const ptr ) {
  31527. + uint32_t phys = virt_to_phys ( ptr );
  31528. + if ( phys > 0xfffff ) {
  31529. + printf ( "FATAL ERROR: segment address out of range\n" );
  31530. + }
  31531. + return phys >> 4;
  31532. +}
  31533. +#else
  31534. +#define SEGMENT(x) ( virt_to_phys ( x ) >> 4 )
  31535. +#endif
  31536. +#define OFFSET(x) ( virt_to_phys ( x ) & 0xf )
  31537. +#define SEGOFF(x) { OFFSET(x), SEGMENT(x) }
  31538. +#define VIRTUAL(x,y) ( phys_to_virt ( ( ( x ) << 4 ) + ( y ) ) )
  31539. +
  31540. +#endif /* SEGOFF_H */
  31541. Index: b/netboot/sis900.c
  31542. ===================================================================
  31543. --- a/netboot/sis900.c
  31544. +++ b/netboot/sis900.c
  31545. @@ -27,6 +27,11 @@
  31546. /* Revision History */
  31547. /*
  31548. + 07 Dec 2003 timlegge - Enabled Multicast Support
  31549. + 06 Dec 2003 timlegge - Fixed relocation issue in 5.2
  31550. + 04 Jan 2002 Chien-Yu Chen, Doug Ambrisko, Marty Connor Patch to Etherboot 5.0.5
  31551. + Added support for the SiS 630ET plus various bug fixes from linux kernel
  31552. + source 2.4.17.
  31553. 01 March 2001 mdc 1.0
  31554. Initial Release. Tested with PCI based sis900 card and ThinkNIC
  31555. computer.
  31556. @@ -35,13 +40,12 @@
  31557. Testet with SIS730S chipset + ICS1893
  31558. */
  31559. -
  31560. /* Includes */
  31561. #include "etherboot.h"
  31562. #include "nic.h"
  31563. #include "pci.h"
  31564. -#include "cards.h"
  31565. +#include "timer.h"
  31566. #include "sis900.h"
  31567. @@ -51,6 +55,7 @@
  31568. static unsigned short vendor, dev_id;
  31569. static unsigned long ioaddr;
  31570. +static u8 pci_revision;
  31571. static unsigned int cur_phy;
  31572. @@ -58,15 +63,10 @@
  31573. static BufferDesc txd;
  31574. static BufferDesc rxd[NUM_RX_DESC];
  31575. -
  31576. -#ifdef USE_LOWMEM_BUFFER
  31577. -#define txb ((char *)0x10000 - TX_BUF_SIZE)
  31578. -#define rxb ((char *)0x10000 - NUM_RX_DESC*RX_BUF_SIZE - TX_BUF_SIZE)
  31579. -#else
  31580. static unsigned char txb[TX_BUF_SIZE];
  31581. static unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE];
  31582. -#endif
  31583. +#if 0
  31584. static struct mac_chip_info {
  31585. const char *name;
  31586. u16 vendor_id, device_id, flags;
  31587. @@ -78,11 +78,13 @@
  31588. PCI_COMMAND_IO|PCI_COMMAND_MASTER, SIS900_TOTAL_SIZE},
  31589. {0,0,0,0,0} /* 0 terminated list. */
  31590. };
  31591. +#endif
  31592. static void sis900_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  31593. static void amd79c901_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  31594. static void ics1893_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  31595. static void rtl8201_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  31596. +static void vt6103_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  31597. static struct mii_chip_info {
  31598. const char * name;
  31599. @@ -96,6 +98,7 @@
  31600. {"AMD 79C901 HomePNA PHY", 0x0000, 0x35c8, amd79c901_read_mode},
  31601. {"ICS 1893 Integrated PHYceiver" , 0x0015, 0xf441,ics1893_read_mode},
  31602. {"RTL 8201 10/100Mbps Phyceiver" , 0x0000, 0x8201,rtl8201_read_mode},
  31603. + {"VIA 6103 10/100Mbps Phyceiver", 0x0101, 0x8f20,vt6103_read_mode},
  31604. {0,0,0,0}
  31605. };
  31606. @@ -106,24 +109,32 @@
  31607. u16 status;
  31608. } mii;
  31609. -
  31610. // PCI to ISA bridge for SIS640E access
  31611. -static struct pci_device pci_isa_bridge_list[] = {
  31612. +static struct pci_id pci_isa_bridge_list[] = {
  31613. { 0x1039, 0x0008,
  31614. - "SIS 85C503/5513 PCI to ISA bridge", 0, 0, 0, 0},
  31615. - {0, 0, NULL, 0, 0, 0, 0}
  31616. + "SIS 85C503/5513 PCI to ISA bridge"},
  31617. +};
  31618. +
  31619. +struct pci_driver sis_bridge_driver = {
  31620. + .type = BRIDGE_DRIVER,
  31621. + .name = "",
  31622. + .probe = 0,
  31623. + .ids = pci_isa_bridge_list,
  31624. + .id_count = sizeof(pci_isa_bridge_list)/sizeof(pci_isa_bridge_list[0]),
  31625. + .class = 0,
  31626. };
  31627. /* Function Prototypes */
  31628. -struct nic *sis900_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci);
  31629. +static int sis900_probe(struct dev *dev, struct pci_device *pci);
  31630. static u16 sis900_read_eeprom(int location);
  31631. static void sis900_mdio_reset(long mdio_addr);
  31632. static void sis900_mdio_idle(long mdio_addr);
  31633. static u16 sis900_mdio_read(int phy_id, int location);
  31634. +#if 0
  31635. static void sis900_mdio_write(int phy_id, int location, int val);
  31636. -
  31637. +#endif
  31638. static void sis900_init(struct nic *nic);
  31639. static void sis900_reset(struct nic *nic);
  31640. @@ -136,9 +147,11 @@
  31641. static void sis900_transmit(struct nic *nic, const char *d,
  31642. unsigned int t, unsigned int s, const char *p);
  31643. -static int sis900_poll(struct nic *nic);
  31644. +static int sis900_poll(struct nic *nic, int retrieve);
  31645. +
  31646. +static void sis900_disable(struct dev *dev);
  31647. -static void sis900_disable(struct nic *nic);
  31648. +static void sis900_irq(struct nic *nic, irq_action_t action);
  31649. /**
  31650. * sis900_get_mac_addr: - Get MAC address for stand alone SiS900 model
  31651. @@ -149,7 +162,7 @@
  31652. * MAC address is read from read_eeprom() into @net_dev->dev_addr.
  31653. */
  31654. -static int sis900_get_mac_addr(struct pci_device * pci_dev , struct nic *nic)
  31655. +static int sis900_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  31656. {
  31657. u16 signature;
  31658. int i;
  31659. @@ -168,6 +181,50 @@
  31660. }
  31661. /**
  31662. + * sis96x_get_mac_addr: - Get MAC address for SiS962 or SiS963 model
  31663. + * @pci_dev: the sis900 pci device
  31664. + * @net_dev: the net device to get address for
  31665. + *
  31666. + * SiS962 or SiS963 model, use EEPROM to store MAC address. And EEPROM
  31667. + * is shared by
  31668. + * LAN and 1394. When access EEPROM, send EEREQ signal to hardware first
  31669. + * and wait for EEGNT. If EEGNT is ON, EEPROM is permitted to be access
  31670. + * by LAN, otherwise is not. After MAC address is read from EEPROM, send
  31671. + * EEDONE signal to refuse EEPROM access by LAN.
  31672. + * The EEPROM map of SiS962 or SiS963 is different to SiS900.
  31673. + * The signature field in SiS962 or SiS963 spec is meaningless.
  31674. + * MAC address is read into @net_dev->dev_addr.
  31675. + */
  31676. +
  31677. +static int sis96x_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  31678. +{
  31679. +/* long ioaddr = net_dev->base_addr; */
  31680. + long ee_addr = ioaddr + mear;
  31681. + u32 waittime = 0;
  31682. + int i;
  31683. +
  31684. + printf("Alternate function\n");
  31685. +
  31686. + outl(EEREQ, ee_addr);
  31687. + while(waittime < 2000) {
  31688. + if(inl(ee_addr) & EEGNT) {
  31689. +
  31690. + /* get MAC address from EEPROM */
  31691. + for (i = 0; i < 3; i++)
  31692. + ((u16 *)(nic->node_addr))[i] = sis900_read_eeprom(i+EEPROMMACAddr);
  31693. +
  31694. + outl(EEDONE, ee_addr);
  31695. + return 1;
  31696. + } else {
  31697. + udelay(1);
  31698. + waittime ++;
  31699. + }
  31700. + }
  31701. + outl(EEDONE, ee_addr);
  31702. + return 0;
  31703. +}
  31704. +
  31705. +/**
  31706. * sis630e_get_mac_addr: - Get MAC address for SiS630E model
  31707. * @pci_dev: the sis900 pci device
  31708. * @net_dev: the net device to get address for
  31709. @@ -177,17 +234,21 @@
  31710. * MAC address is read into @net_dev->dev_addr.
  31711. */
  31712. -static int sis630e_get_mac_addr(struct pci_device * pci_dev, struct nic *nic)
  31713. +static int sis630e_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  31714. {
  31715. u8 reg;
  31716. int i;
  31717. - struct pci_device *p;
  31718. -
  31719. - // find PCI to ISA bridge
  31720. - eth_pci_init(pci_isa_bridge_list);
  31721. + struct pci_device p[1];
  31722. - /* the firts entry in this list should contain bus/devfn */
  31723. - p = pci_isa_bridge_list;
  31724. + /* find PCI to ISA bridge */
  31725. + memset(p, 0, sizeof(p));
  31726. + do {
  31727. + find_pci(BRIDGE_DRIVER, p);
  31728. + } while(p->driver && p->driver != &sis_bridge_driver);
  31729. +
  31730. + /* error on failure */
  31731. + if (!p->driver)
  31732. + return 0;
  31733. pcibios_read_config_byte(p->bus,p->devfn, 0x48, &reg);
  31734. pcibios_write_config_byte(p->bus,p->devfn, 0x48, reg | 0x40);
  31735. @@ -201,7 +262,43 @@
  31736. return 1;
  31737. }
  31738. -
  31739. +
  31740. +/**
  31741. + * sis630e_get_mac_addr: - Get MAC address for SiS630E model
  31742. + * @pci_dev: the sis900 pci device
  31743. + * @net_dev: the net device to get address for
  31744. + *
  31745. + * SiS630E model, use APC CMOS RAM to store MAC address.
  31746. + * APC CMOS RAM is accessed through ISA bridge.
  31747. + * MAC address is read into @net_dev->dev_addr.
  31748. + */
  31749. +
  31750. +static int sis635_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  31751. +{
  31752. + u32 rfcrSave;
  31753. + u32 i;
  31754. +
  31755. +
  31756. + rfcrSave = inl(rfcr + ioaddr);
  31757. +
  31758. + outl(rfcrSave | RELOAD, ioaddr + cr);
  31759. + outl(0, ioaddr + cr);
  31760. +
  31761. + /* disable packet filtering before setting filter */
  31762. + outl(rfcrSave & ~RFEN, rfcr + ioaddr);
  31763. +
  31764. + /* load MAC addr to filter data register */
  31765. + for (i = 0 ; i < 3 ; i++) {
  31766. + outl((i << RFADDR_shift), ioaddr + rfcr);
  31767. + *( ((u16 *)nic->node_addr) + i) = inw(ioaddr + rfdr);
  31768. + }
  31769. +
  31770. + /* enable packet filitering */
  31771. + outl(rfcrSave | RFEN, rfcr + ioaddr);
  31772. +
  31773. + return 1;
  31774. +}
  31775. +
  31776. /*
  31777. * Function: sis900_probe
  31778. *
  31779. @@ -216,19 +313,21 @@
  31780. * Returns: struct nic *: pointer to NIC data structure
  31781. */
  31782. -struct nic *sis900_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci)
  31783. +static int sis900_probe(struct dev *dev, struct pci_device *pci)
  31784. {
  31785. + struct nic *nic = (struct nic *)dev;
  31786. int i;
  31787. int found=0;
  31788. int phy_addr;
  31789. - u16 signature;
  31790. u8 revision;
  31791. int ret;
  31792. - if (io_addrs == 0 || *io_addrs == 0)
  31793. - return NULL;
  31794. + if (pci->ioaddr == 0)
  31795. + return 0;
  31796. - ioaddr = *io_addrs & ~3;
  31797. + nic->irqno = 0;
  31798. + nic->ioaddr = pci->ioaddr & ~3;
  31799. + ioaddr = pci->ioaddr & ~3;
  31800. vendor = pci->vendor;
  31801. dev_id = pci->dev_id;
  31802. @@ -240,19 +339,29 @@
  31803. /* get MAC address */
  31804. ret = 0;
  31805. pcibios_read_config_byte(pci->bus,pci->devfn, PCI_REVISION, &revision);
  31806. - if (revision == SIS630E_900_REV || revision == SIS630EA1_900_REV)
  31807. - ret = sis630e_get_mac_addr(pci, nic);
  31808. - else if (revision == SIS630S_900_REV)
  31809. +
  31810. + /* save for use later in sis900_reset() */
  31811. + pci_revision = revision;
  31812. +
  31813. + if (revision == SIS630E_900_REV)
  31814. ret = sis630e_get_mac_addr(pci, nic);
  31815. + else if ((revision > 0x81) && (revision <= 0x90))
  31816. + ret = sis635_get_mac_addr(pci, nic);
  31817. + else if (revision == SIS96x_900_REV)
  31818. + ret = sis96x_get_mac_addr(pci, nic);
  31819. else
  31820. ret = sis900_get_mac_addr(pci, nic);
  31821. if (ret == 0)
  31822. {
  31823. printf ("sis900_probe: Error MAC address not found\n");
  31824. - return NULL;
  31825. + return 0;
  31826. }
  31827. + /* 630ET : set the mii access mode as software-mode */
  31828. + if (revision == SIS630ET_900_REV)
  31829. + outl(ACCESSMODE | inl(ioaddr + cr), ioaddr + cr);
  31830. +
  31831. printf("\nsis900_probe: MAC addr %! at ioaddr %#hX\n",
  31832. nic->node_addr, ioaddr);
  31833. printf("sis900_probe: Vendor:%#hX Device:%#hX\n", vendor, dev_id);
  31834. @@ -264,7 +373,7 @@
  31835. for (phy_addr = 0; phy_addr < 32; phy_addr++) {
  31836. u16 mii_status;
  31837. u16 phy_id0, phy_id1;
  31838. -
  31839. +
  31840. mii_status = sis900_mdio_read(phy_addr, MII_STATUS);
  31841. if (mii_status == 0xffff || mii_status == 0x0000)
  31842. /* the mii is not accessable, try next one */
  31843. @@ -272,7 +381,7 @@
  31844. phy_id0 = sis900_mdio_read(phy_addr, MII_PHY_ID0);
  31845. phy_id1 = sis900_mdio_read(phy_addr, MII_PHY_ID1);
  31846. -
  31847. +
  31848. /* search our mii table for the current mii */
  31849. for (i = 0; mii_chip_table[i].phy_id1; i++) {
  31850. @@ -294,7 +403,7 @@
  31851. if (found == 0) {
  31852. printf("sis900_probe: No MII transceivers found!\n");
  31853. - return NULL;
  31854. + return 0;
  31855. }
  31856. /* Arbitrarily select the last PHY found as current PHY */
  31857. @@ -304,15 +413,14 @@
  31858. /* initialize device */
  31859. sis900_init(nic);
  31860. - nic->reset = sis900_init;
  31861. + dev->disable = sis900_disable;
  31862. nic->poll = sis900_poll;
  31863. nic->transmit = sis900_transmit;
  31864. - nic->disable = sis900_disable;
  31865. + nic->irq = sis900_irq;
  31866. - return nic;
  31867. + return 1;
  31868. }
  31869. -
  31870. /*
  31871. * EEPROM Routines: These functions read and write to EEPROM for
  31872. * retrieving the MAC address and other configuration information about
  31873. @@ -322,7 +430,6 @@
  31874. /* Delay between EEPROM clock transitions. */
  31875. #define eeprom_delay() inl(ee_addr)
  31876. -
  31877. /* Function: sis900_read_eeprom
  31878. *
  31879. * Description: reads and returns a given location from EEPROM
  31880. @@ -378,7 +485,6 @@
  31881. #define sis900_mdio_delay() inl(mdio_addr)
  31882. -
  31883. /*
  31884. Read and write the MII management registers using software-generated
  31885. serial MDIO protocol. Note that the command bits and data bits are
  31886. @@ -432,9 +538,11 @@
  31887. outl(MDC, mdio_addr);
  31888. sis900_mdio_delay();
  31889. }
  31890. + outl(0x00, mdio_addr);
  31891. return retval;
  31892. }
  31893. +#if 0
  31894. static void sis900_mdio_write(int phy_id, int location, int value)
  31895. {
  31896. long mdio_addr = ioaddr + mear;
  31897. @@ -471,10 +579,11 @@
  31898. outb(MDC, mdio_addr);
  31899. sis900_mdio_delay();
  31900. }
  31901. + outl(0x00, mdio_addr);
  31902. return;
  31903. }
  31904. +#endif
  31905. -
  31906. /* Function: sis900_init
  31907. *
  31908. * Description: resets the ethernet controller chip and various
  31909. @@ -500,10 +609,9 @@
  31910. sis900_check_mode(nic);
  31911. - outl(RxENA, ioaddr + cr);
  31912. + outl(RxENA| inl(ioaddr + cr), ioaddr + cr);
  31913. }
  31914. -
  31915. /*
  31916. * Function: sis900_reset
  31917. *
  31918. @@ -515,7 +623,7 @@
  31919. */
  31920. static void
  31921. -sis900_reset(struct nic *nic)
  31922. +sis900_reset(struct nic *nic __unused)
  31923. {
  31924. int i = 0;
  31925. u32 status = TxRCMP | RxRCMP;
  31926. @@ -524,16 +632,19 @@
  31927. outl(0, ioaddr + imr);
  31928. outl(0, ioaddr + rfcr);
  31929. - outl(RxRESET | TxRESET | RESET, ioaddr + cr);
  31930. -
  31931. + outl(RxRESET | TxRESET | RESET | inl(ioaddr + cr), ioaddr + cr);
  31932. +
  31933. /* Check that the chip has finished the reset. */
  31934. while (status && (i++ < 1000)) {
  31935. status ^= (inl(isr + ioaddr) & status);
  31936. }
  31937. - outl(PESEL, ioaddr + cfg);
  31938. +
  31939. + if( (pci_revision == SIS635A_900_REV) || (pci_revision == SIS900B_900_REV) )
  31940. + outl(PESEL | RND_CNT, ioaddr + cfg);
  31941. + else
  31942. + outl(PESEL, ioaddr + cfg);
  31943. }
  31944. -
  31945. /* Function: sis_init_rxfilter
  31946. *
  31947. * Description: sets receive filter address to our MAC address
  31948. @@ -552,7 +663,7 @@
  31949. rfcrSave = inl(rfcr + ioaddr);
  31950. /* disable packet filtering before setting filter */
  31951. - outl(rfcrSave & ~RFEN, rfcr);
  31952. + outl(rfcrSave & ~RFEN, rfcr + ioaddr);
  31953. /* load MAC addr to filter data register */
  31954. for (i = 0 ; i < 3 ; i++) {
  31955. @@ -571,7 +682,6 @@
  31956. outl(rfcrSave | RFEN, rfcr + ioaddr);
  31957. }
  31958. -
  31959. /*
  31960. * Function: sis_init_txd
  31961. *
  31962. @@ -583,20 +693,19 @@
  31963. */
  31964. static void
  31965. -sis900_init_txd(struct nic *nic)
  31966. +sis900_init_txd(struct nic *nic __unused)
  31967. {
  31968. txd.link = (u32) 0;
  31969. txd.cmdsts = (u32) 0;
  31970. - txd.bufptr = (u32) &txb[0];
  31971. + txd.bufptr = virt_to_bus(&txb[0]);
  31972. /* load Transmit Descriptor Register */
  31973. - outl((u32) &txd, ioaddr + txdp);
  31974. + outl(virt_to_bus(&txd), ioaddr + txdp);
  31975. if (sis900_debug > 0)
  31976. printf("sis900_init_txd: TX descriptor register loaded with: %X\n",
  31977. inl(ioaddr + txdp));
  31978. }
  31979. -
  31980. /* Function: sis_init_rxd
  31981. *
  31982. * Description: initializes the Rx descriptor ring
  31983. @@ -607,7 +716,7 @@
  31984. */
  31985. static void
  31986. -sis900_init_rxd(struct nic *nic)
  31987. +sis900_init_rxd(struct nic *nic __unused)
  31988. {
  31989. int i;
  31990. @@ -615,16 +724,16 @@
  31991. /* init RX descriptor */
  31992. for (i = 0; i < NUM_RX_DESC; i++) {
  31993. - rxd[i].link = (i+1 < NUM_RX_DESC) ? (u32) &rxd[i+1] : (u32) &rxd[0];
  31994. + rxd[i].link = virt_to_bus((i+1 < NUM_RX_DESC) ? &rxd[i+1] : &rxd[0]);
  31995. rxd[i].cmdsts = (u32) RX_BUF_SIZE;
  31996. - rxd[i].bufptr = (u32) &rxb[i*RX_BUF_SIZE];
  31997. + rxd[i].bufptr = virt_to_bus(&rxb[i*RX_BUF_SIZE]);
  31998. if (sis900_debug > 0)
  31999. printf("sis900_init_rxd: rxd[%d]=%X link=%X cmdsts=%X bufptr=%X\n",
  32000. i, &rxd[i], rxd[i].link, rxd[i].cmdsts, rxd[i].bufptr);
  32001. }
  32002. /* load Receive Descriptor Register */
  32003. - outl((u32) &rxd[0], ioaddr + rxdp);
  32004. + outl(virt_to_bus(&rxd[0]), ioaddr + rxdp);
  32005. if (sis900_debug > 0)
  32006. printf("sis900_init_rxd: RX descriptor register loaded with: %X\n",
  32007. @@ -632,7 +741,6 @@
  32008. }
  32009. -
  32010. /* Function: sis_init_rxd
  32011. *
  32012. * Description:
  32013. @@ -644,25 +752,36 @@
  32014. * Returns: void.
  32015. */
  32016. -static void sis900_set_rx_mode(struct nic *nic)
  32017. +static void sis900_set_rx_mode(struct nic *nic __unused)
  32018. {
  32019. - int i;
  32020. + int i, table_entries;
  32021. + u32 rx_mode;
  32022. + u16 mc_filter[16] = {0}; /* 256/128 bits multicast hash table */
  32023. +
  32024. + if((pci_revision == SIS635A_900_REV) || (pci_revision == SIS900B_900_REV))
  32025. + table_entries = 16;
  32026. + else
  32027. + table_entries = 8;
  32028. - /* Configure Multicast Hash Table in Receive Filter
  32029. - to reject all MCAST packets */
  32030. - for (i = 0; i < 8; i++) {
  32031. + /* accept all multicast packet */
  32032. + rx_mode = RFAAB | RFAAM;
  32033. + for (i = 0; i < table_entries; i++)
  32034. + mc_filter[i] = 0xffff;
  32035. +
  32036. + /* update Multicast Hash Table in Receive Filter */
  32037. + for (i = 0; i < table_entries; i++) {
  32038. /* why plus 0x04? That makes the correct value for hash table. */
  32039. outl((u32)(0x00000004+i) << RFADDR_shift, ioaddr + rfcr);
  32040. - outl((u32)(0x0), ioaddr + rfdr);
  32041. + outl(mc_filter[i], ioaddr + rfdr);
  32042. }
  32043. - /* Accept Broadcast packets, destination addresses that match
  32044. +
  32045. + /* Accept Broadcast and multicast packets, destination addresses that match
  32046. our MAC address */
  32047. - outl(RFEN | RFAAB, ioaddr + rfcr);
  32048. + outl(RFEN | rx_mode, ioaddr + rfcr);
  32049. return;
  32050. }
  32051. -
  32052. /* Function: sis900_check_mode
  32053. *
  32054. * Description: checks the state of transmit and receive
  32055. @@ -674,15 +793,21 @@
  32056. */
  32057. static void
  32058. -sis900_check_mode (struct nic *nic)
  32059. +sis900_check_mode(struct nic *nic)
  32060. {
  32061. int speed, duplex;
  32062. u32 tx_flags = 0, rx_flags = 0;
  32063. mii.chip_info->read_mode(nic, cur_phy, &speed, &duplex);
  32064. - tx_flags = TxATP | (TX_DMA_BURST << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
  32065. - rx_flags = RX_DMA_BURST << RxMXDMA_shift;
  32066. + if( inl(ioaddr + cfg) & EDB_MASTER_EN ) {
  32067. + tx_flags = TxATP | (DMA_BURST_64 << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
  32068. + rx_flags = DMA_BURST_64 << RxMXDMA_shift;
  32069. + }
  32070. + else {
  32071. + tx_flags = TxATP | (DMA_BURST_512 << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
  32072. + rx_flags = DMA_BURST_512 << RxMXDMA_shift;
  32073. + }
  32074. if (speed == HW_SPEED_HOME || speed == HW_SPEED_10_MBPS) {
  32075. rx_flags |= (RxDRNT_10 << RxDRNT_shift);
  32076. @@ -702,7 +827,6 @@
  32077. outl (rx_flags, ioaddr + rxcfg);
  32078. }
  32079. -
  32080. /* Function: sis900_read_mode
  32081. *
  32082. * Description: retrieves and displays speed and duplex
  32083. @@ -714,24 +838,33 @@
  32084. */
  32085. static void
  32086. -sis900_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex)
  32087. +sis900_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  32088. {
  32089. int i = 0;
  32090. u32 status;
  32091. + u16 phy_id0, phy_id1;
  32092. /* STSOUT register is Latched on Transition, read operation updates it */
  32093. while (i++ < 2)
  32094. status = sis900_mdio_read(phy_addr, MII_STSOUT);
  32095. - if (status & MII_STSOUT_SPD)
  32096. - *speed = HW_SPEED_100_MBPS;
  32097. - else
  32098. - *speed = HW_SPEED_10_MBPS;
  32099. -
  32100. - if (status & MII_STSOUT_DPLX)
  32101. - *duplex = FDX_CAPABLE_FULL_SELECTED;
  32102. - else
  32103. - *duplex = FDX_CAPABLE_HALF_SELECTED;
  32104. + *speed = HW_SPEED_10_MBPS;
  32105. + *duplex = FDX_CAPABLE_HALF_SELECTED;
  32106. +
  32107. + if (status & (MII_NWAY_TX | MII_NWAY_TX_FDX))
  32108. + *speed = HW_SPEED_100_MBPS;
  32109. + if (status & ( MII_NWAY_TX_FDX | MII_NWAY_T_FDX))
  32110. + *duplex = FDX_CAPABLE_FULL_SELECTED;
  32111. +
  32112. + /* Workaround for Realtek RTL8201 PHY issue */
  32113. + phy_id0 = sis900_mdio_read(phy_addr, MII_PHY_ID0);
  32114. + phy_id1 = sis900_mdio_read(phy_addr, MII_PHY_ID1);
  32115. + if((phy_id0 == 0x0000) && ((phy_id1 & 0xFFF0) == 0x8200)){
  32116. + if(sis900_mdio_read(phy_addr, MII_CONTROL) & MII_CNTL_FDX)
  32117. + *duplex = FDX_CAPABLE_FULL_SELECTED;
  32118. + if(sis900_mdio_read(phy_addr, 0x0019) & 0x01)
  32119. + *speed = HW_SPEED_100_MBPS;
  32120. + }
  32121. if (status & MII_STSOUT_LINK_FAIL)
  32122. printf("sis900_read_mode: Media Link Off\n");
  32123. @@ -743,7 +876,6 @@
  32124. "full" : "half");
  32125. }
  32126. -
  32127. /* Function: amd79c901_read_mode
  32128. *
  32129. * Description: retrieves and displays speed and duplex
  32130. @@ -755,7 +887,7 @@
  32131. */
  32132. static void
  32133. -amd79c901_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex)
  32134. +amd79c901_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  32135. {
  32136. int i;
  32137. u16 status;
  32138. @@ -796,7 +928,6 @@
  32139. }
  32140. }
  32141. -
  32142. /**
  32143. * ics1893_read_mode: - read media mode for ICS1893 PHY
  32144. * @net_dev: the net device to read mode for
  32145. @@ -808,7 +939,7 @@
  32146. * to determine the speed and duplex mode for sis900
  32147. */
  32148. -static void ics1893_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex)
  32149. +static void ics1893_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  32150. {
  32151. int i = 0;
  32152. u32 status;
  32153. @@ -848,7 +979,7 @@
  32154. * to determine the speed and duplex mode for sis900
  32155. */
  32156. -static void rtl8201_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex)
  32157. +static void rtl8201_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  32158. {
  32159. u32 status;
  32160. @@ -878,7 +1009,51 @@
  32161. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  32162. "full" : "half");
  32163. else
  32164. - printf("rtl9201_read_config_mode: Media Link Off\n");
  32165. + printf("rtl8201_read_config_mode: Media Link Off\n");
  32166. +}
  32167. +
  32168. +/**
  32169. + * vt6103_read_mode: - read media mode for vt6103 phy
  32170. + * @nic: the net device to read mode for
  32171. + * @phy_addr: mii phy address
  32172. + * @speed: the transmit speed to be determined
  32173. + * @duplex: the duplex mode to be determined
  32174. + *
  32175. + * read MII_STATUS register from rtl8201 phy
  32176. + * to determine the speed and duplex mode for sis900
  32177. + */
  32178. +
  32179. +static void vt6103_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  32180. +{
  32181. + u32 status;
  32182. +
  32183. + status = sis900_mdio_read(phy_addr, MII_STATUS);
  32184. +
  32185. + if (status & MII_STAT_CAN_TX_FDX) {
  32186. + *speed = HW_SPEED_100_MBPS;
  32187. + *duplex = FDX_CAPABLE_FULL_SELECTED;
  32188. + }
  32189. + else if (status & MII_STAT_CAN_TX) {
  32190. + *speed = HW_SPEED_100_MBPS;
  32191. + *duplex = FDX_CAPABLE_HALF_SELECTED;
  32192. + }
  32193. + else if (status & MII_STAT_CAN_T_FDX) {
  32194. + *speed = HW_SPEED_10_MBPS;
  32195. + *duplex = FDX_CAPABLE_FULL_SELECTED;
  32196. + }
  32197. + else if (status & MII_STAT_CAN_T) {
  32198. + *speed = HW_SPEED_10_MBPS;
  32199. + *duplex = FDX_CAPABLE_HALF_SELECTED;
  32200. + }
  32201. +
  32202. + if (status & MII_STAT_LINK)
  32203. + printf("vt6103_read_mode: Media Link On %s %s-duplex \n",
  32204. + *speed == HW_SPEED_100_MBPS ?
  32205. + "100mbps" : "10mbps",
  32206. + *duplex == FDX_CAPABLE_FULL_SELECTED ?
  32207. + "full" : "half");
  32208. + else
  32209. + printf("vt6103_read_config_mode: Media Link Off\n");
  32210. }
  32211. /* Function: sis900_transmit
  32212. @@ -900,14 +1075,14 @@
  32213. unsigned int s, /* size */
  32214. const char *p) /* Packet */
  32215. {
  32216. - u32 status, to, nstype;
  32217. + u32 to, nstype;
  32218. volatile u32 tx_status;
  32219. /* Stop the transmitter */
  32220. - outl(TxDIS, ioaddr + cr);
  32221. + outl(TxDIS | inl(ioaddr + cr), ioaddr + cr);
  32222. /* load Transmit Descriptor Register */
  32223. - outl((u32) &txd, ioaddr + txdp);
  32224. + outl(virt_to_bus(&txd), ioaddr + txdp);
  32225. if (sis900_debug > 1)
  32226. printf("sis900_transmit: TX descriptor register loaded with: %X\n",
  32227. inl(ioaddr + txdp));
  32228. @@ -929,18 +1104,18 @@
  32229. txb[s++] = '\0';
  32230. /* set the transmit buffer descriptor and enable Transmit State Machine */
  32231. - txd.bufptr = (u32) &txb[0];
  32232. + txd.bufptr = virt_to_bus(&txb[0]);
  32233. txd.cmdsts = (u32) OWN | s;
  32234. /* restart the transmitter */
  32235. - outl(TxENA, ioaddr + cr);
  32236. + outl(TxENA | inl(ioaddr + cr), ioaddr + cr);
  32237. if (sis900_debug > 1)
  32238. printf("sis900_transmit: Queued Tx packet size %d.\n", (int) s);
  32239. to = currticks() + TX_TIMEOUT;
  32240. - while (((tx_status=txd.cmdsts) & OWN) && (currticks() < to))
  32241. + while (((tx_status=txd.cmdsts & OWN) && (currticks() < to))
  32242. /* wait */ ;
  32243. if (currticks() >= to) {
  32244. @@ -955,7 +1130,6 @@
  32245. outl(0, ioaddr + imr);
  32246. }
  32247. -
  32248. /* Function: sis900_poll
  32249. *
  32250. * Description: checks for a received packet and returns it if found.
  32251. @@ -971,7 +1145,7 @@
  32252. */
  32253. static int
  32254. -sis900_poll(struct nic *nic)
  32255. +sis900_poll(struct nic *nic, int retrieve)
  32256. {
  32257. u32 rx_status = rxd[cur_rx].cmdsts;
  32258. int retstat = 0;
  32259. @@ -986,6 +1160,8 @@
  32260. printf("sis900_poll: got a packet: cur_rx:%d, status:%X\n",
  32261. cur_rx, rx_status);
  32262. + if ( ! retrieve ) return 1;
  32263. +
  32264. nic->packetlen = (rx_status & DSIZE) - CRC_SIZE;
  32265. if (rx_status & (ABORT|OVERRUN|TOOLONG|RUNT|RXISERR|CRCERR|FAERR)) {
  32266. @@ -1001,18 +1177,18 @@
  32267. /* return the descriptor and buffer to receive ring */
  32268. rxd[cur_rx].cmdsts = RX_BUF_SIZE;
  32269. - rxd[cur_rx].bufptr = (u32) &rxb[cur_rx*RX_BUF_SIZE];
  32270. + rxd[cur_rx].bufptr = virt_to_bus(&rxb[cur_rx*RX_BUF_SIZE]);
  32271. if (++cur_rx == NUM_RX_DESC)
  32272. cur_rx = 0;
  32273. /* re-enable the potentially idle receive state machine */
  32274. - outl(RxENA , ioaddr + cr);
  32275. + outl(RxENA | inl(ioaddr + cr), ioaddr + cr);
  32276. return retstat;
  32277. +
  32278. }
  32279. -
  32280. /* Function: sis900_disable
  32281. *
  32282. * Description: Turns off interrupts and stops Tx and Rx engines
  32283. @@ -1023,12 +1199,53 @@
  32284. */
  32285. static void
  32286. -sis900_disable(struct nic *nic)
  32287. +sis900_disable(struct dev *dev)
  32288. {
  32289. + struct nic *nic = (struct nic *)dev;
  32290. + /* merge reset and disable */
  32291. + sis900_init(nic);
  32292. +
  32293. /* Disable interrupts by clearing the interrupt mask. */
  32294. outl(0, ioaddr + imr);
  32295. outl(0, ioaddr + ier);
  32296. /* Stop the chip's Tx and Rx Status Machine */
  32297. - outl(RxDIS | TxDIS, ioaddr + cr);
  32298. + outl(RxDIS | TxDIS | inl(ioaddr + cr), ioaddr + cr);
  32299. +}
  32300. +
  32301. +/* Function: sis900_irq
  32302. + *
  32303. + * Description: Enable, Disable, or Force, interrupts
  32304. + *
  32305. + * Arguments: struct nic *nic: NIC data structure
  32306. + * irq_action_t action: Requested action
  32307. + *
  32308. + * Returns: void.
  32309. + */
  32310. +
  32311. +static void
  32312. +sis900_irq(struct nic *nic __unused, irq_action_t action __unused)
  32313. +{
  32314. + switch ( action ) {
  32315. + case DISABLE :
  32316. + break;
  32317. + case ENABLE :
  32318. + break;
  32319. + case FORCE :
  32320. + break;
  32321. + }
  32322. }
  32323. +
  32324. +static struct pci_id sis900_nics[] = {
  32325. +PCI_ROM(0x1039, 0x0900, "sis900", "SIS900"),
  32326. +PCI_ROM(0x1039, 0x7016, "sis7016", "SIS7016"),
  32327. +};
  32328. +
  32329. +struct pci_driver sis900_driver = {
  32330. + .type = NIC_DRIVER,
  32331. + .name = "SIS900",
  32332. + .probe = sis900_probe,
  32333. + .ids = sis900_nics,
  32334. + .id_count = sizeof(sis900_nics)/sizeof(sis900_nics[0]),
  32335. + .class = 0,
  32336. +};
  32337. Index: b/netboot/sis900.h
  32338. ===================================================================
  32339. --- a/netboot/sis900.h
  32340. +++ b/netboot/sis900.h
  32341. @@ -39,14 +39,16 @@
  32342. /* Symbolic names for bits in various registers */
  32343. enum sis900_command_register_bits {
  32344. - RESET = 0x00000100,
  32345. - SWI = 0x00000080,
  32346. - RxRESET = 0x00000020,
  32347. - TxRESET = 0x00000010,
  32348. - RxDIS = 0x00000008,
  32349. - RxENA = 0x00000004,
  32350. - TxDIS = 0x00000002,
  32351. - TxENA = 0x00000001
  32352. + RELOAD = 0x00000400,
  32353. + ACCESSMODE = 0x00000200,
  32354. + RESET = 0x00000100,
  32355. + SWI = 0x00000080,
  32356. + RxRESET = 0x00000020,
  32357. + TxRESET = 0x00000010,
  32358. + RxDIS = 0x00000008,
  32359. + RxENA = 0x00000004,
  32360. + TxDIS = 0x00000002,
  32361. + TxENA = 0x00000001
  32362. };
  32363. enum sis900_configuration_register_bits {
  32364. @@ -57,7 +59,10 @@
  32365. EXD = 0x00000010,
  32366. PESEL = 0x00000008,
  32367. LPM = 0x00000004,
  32368. - BEM = 0x00000001
  32369. + BEM = 0x00000001,
  32370. + RND_CNT = 0x00000400,
  32371. + FAIR_BACKOFF = 0x00000200,
  32372. + EDB_MASTER_EN = 0x00002000
  32373. };
  32374. enum sis900_eeprom_access_reigster_bits {
  32375. @@ -108,6 +113,10 @@
  32376. #define TX_DMA_BURST 0
  32377. #define RX_DMA_BURST 0
  32378. +enum sis900_tx_rx_dma{
  32379. + DMA_BURST_512 = 0, DMA_BURST_64 = 5
  32380. +};
  32381. +
  32382. /* transmit FIFO threshholds */
  32383. #define TX_FILL_THRESH 16 /* 1/4 FIFO size */
  32384. #define TxFILLT_shift 8
  32385. @@ -172,6 +181,11 @@
  32386. EEeraseAll = 0x0120,
  32387. EEwriteAll = 0x0110,
  32388. EEaddrMask = 0x013F,
  32389. + EEcmdShift = 16
  32390. +};
  32391. +/* For SiS962 or SiS963, request the eeprom software access */
  32392. +enum sis96x_eeprom_command {
  32393. + EEREQ = 0x00000400, EEDONE = 0x00000200, EEGNT = 0x00000100
  32394. };
  32395. /* Manamgement Data I/O (mdio) frame */
  32396. @@ -236,7 +250,8 @@
  32397. MII_CONFIG1 = 0x0010,
  32398. MII_CONFIG2 = 0x0011,
  32399. MII_STSOUT = 0x0012,
  32400. - MII_MASK = 0x0013
  32401. + MII_MASK = 0x0013,
  32402. + MII_RESV = 0x0014
  32403. };
  32404. /* mii registers specific to AMD 79C901 */
  32405. @@ -320,7 +335,9 @@
  32406. enum sis900_revision_id {
  32407. SIS630A_900_REV = 0x80, SIS630E_900_REV = 0x81,
  32408. - SIS630S_900_REV = 0x82, SIS630EA1_900_REV = 0x83
  32409. + SIS630S_900_REV = 0x82, SIS630EA1_900_REV = 0x83,
  32410. + SIS630ET_900_REV = 0x84, SIS635A_900_REV = 0x90,
  32411. + SIS96x_900_REV = 0X91, SIS900B_900_REV = 0x03
  32412. };
  32413. enum sis630_revision_id {
  32414. Index: b/netboot/sis900.txt
  32415. ===================================================================
  32416. --- a/netboot/sis900.txt
  32417. +++ /dev/null
  32418. @@ -1,91 +0,0 @@
  32419. -How I added the SIS900 card to Etherboot
  32420. -
  32421. -Author: Marty Connor (mdc@thinguin.org)
  32422. -
  32423. -Date: 25 Febrary 2001
  32424. -
  32425. -Description:
  32426. -
  32427. -This file is intended to help people who want to write an Etherboot
  32428. -driver or port another driver to Etherboot. It is a starting point.
  32429. -Perhaps someday I may write a more detailed description of writing an
  32430. -Etherboot driver. This text should help get people started, and
  32431. -studying sis900.[ch] should help show the basic structure and
  32432. -techniques involved in writing and Etherboot driver.
  32433. -
  32434. -***********************************************************************
  32435. -
  32436. -0. Back up all the files I need to modify:
  32437. -
  32438. -cd etherboot-4.7.20/src
  32439. -cp Makefile Makefile.orig
  32440. -cp config.c config.c.orig
  32441. -cp pci.h pci.h.orig
  32442. -cp NIC NIC.orig
  32443. -cp cards.h cards.h.orig
  32444. -
  32445. -1. Edit src/Makefile to add SIS900FLAGS to defines
  32446. -
  32447. -SIS900FLAGS= -DINCLUDE_SIS900
  32448. -
  32449. -2. edit src/pci.h to add PCI signatures for card
  32450. -
  32451. -#define PCI_VENDOR_ID_SIS 0x1039
  32452. -#define PCI_DEVICE_ID_SIS900 0x0900
  32453. -#define PCI_DEVICE_ID_SIS7016 0x7016
  32454. -
  32455. -3. Edit src/config.c to add the card to the card probe list
  32456. -
  32457. -#if defined(INCLUDE_NS8390) || defined(INCLUDE_EEPRO100) ||
  32458. - defined(INCLUDE_LANCE) || defined(INCLUDE_EPIC100) ||
  32459. - defined(INCLUDE_TULIP) || defined(INCLUDE_OTULIP) ||
  32460. - defined(INCLUDE_3C90X) || defined(INCLUDE_3C595) ||
  32461. - defined(INCLUDE_RTL8139) || defined(INCLUDE_VIA_RHINE) ||
  32462. - defined(INCLUDE_SIS900) || defined(INCLUDE_W89C840)
  32463. -
  32464. -... and ...
  32465. -
  32466. -#ifdef INCLUDE_SIS900
  32467. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS900,
  32468. - "SIS900", 0, 0, 0, 0},
  32469. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS7016,
  32470. - "SIS7016", 0, 0, 0, 0},
  32471. -#endif
  32472. -
  32473. -... and ...
  32474. -
  32475. -#ifdef INCLUDE_SIS900
  32476. - { "SIS900", sis900_probe, pci_ioaddrs },
  32477. -#endif
  32478. -
  32479. -4. Edit NIC to add sis900 and sis7016 to NIC list
  32480. -
  32481. -# SIS 900 and SIS 7016
  32482. -sis900 sis900 0x1039,0x0900
  32483. -sis7016 sis900 0x1039,0x7016
  32484. -
  32485. -5. Edit cards.h to add sis900 probe routine declaration
  32486. -
  32487. -#ifdef INCLUDE_SIS900
  32488. -extern struct nic *sis900_probe(struct nic *, unsigned short *
  32489. - PCI_ARG(struct pci_device *));
  32490. -#endif
  32491. -
  32492. -***********************************************************************
  32493. -
  32494. -At this point, you can begin creating your driver source file. See
  32495. -the "Writing and Etherboot Driver" section of the Etherboot
  32496. -documentation for some hints. See the skel.c file for a starting
  32497. -point. If there is a Linux driver for the card, you may be able to
  32498. -use that. Copy and learn from existing Etherboot drivers (this is GPL
  32499. -/ Open Source software!).
  32500. -
  32501. -Join the etherboot-developers and etherboot-users mailing lists
  32502. -(information is on etherboot.sourceforge.net) for information and
  32503. -assistance. We invite more developers to help improve Etherboot.
  32504. -
  32505. -Visit the http://etherboot.sourceforge.net, http://thinguin.org,
  32506. -http://rom-o-matic.net, and http://ltsp.org sites for information and
  32507. -assistance.
  32508. -
  32509. -Enjoy.
  32510. Index: b/netboot/smc9000.c
  32511. ===================================================================
  32512. --- a/netboot/smc9000.c
  32513. +++ /dev/null
  32514. @@ -1,522 +0,0 @@
  32515. - /*------------------------------------------------------------------------
  32516. - * smc9000.c
  32517. - * This is a Etherboot driver for SMC's 9000 series of Ethernet cards.
  32518. - *
  32519. - * Copyright (C) 1998 Daniel Engström <daniel.engstrom@riksnett.no>
  32520. - * Based on the Linux SMC9000 driver, smc9194.c by Eric Stahlman
  32521. - * Copyright (C) 1996 by Erik Stahlman <eric@vt.edu>
  32522. - *
  32523. - * This software may be used and distributed according to the terms
  32524. - * of the GNU Public License, incorporated herein by reference.
  32525. - *
  32526. - * "Features" of the SMC chip:
  32527. - * 4608 byte packet memory. ( for the 91C92/4. Others have more )
  32528. - * EEPROM for configuration
  32529. - * AUI/TP selection
  32530. - *
  32531. - * Authors
  32532. - * Erik Stahlman <erik@vt.edu>
  32533. - * Daniel Engström <daniel.engstrom@riksnett.no>
  32534. - *
  32535. - * History
  32536. - * 98-09-25 Daniel Engström Etherboot driver crated from Eric's
  32537. - * Linux driver.
  32538. - *
  32539. - *---------------------------------------------------------------------------*/
  32540. -#define LINUX_OUT_MACROS 1
  32541. -#define SMC9000_VERBOSE 1
  32542. -#define SMC9000_DEBUG 0
  32543. -
  32544. -#include "etherboot.h"
  32545. -#include "nic.h"
  32546. -#include "cards.h"
  32547. -#include "smc9000.h"
  32548. -
  32549. -# define _outb outb
  32550. -# define _outw outw
  32551. -
  32552. -static const char smc9000_version[] = "Version 0.99 98-09-30";
  32553. -static unsigned int smc9000_base=0;
  32554. -static const char *interfaces[ 2 ] = { "TP", "AUI" };
  32555. -static const char *chip_ids[ 15 ] = {
  32556. - NULL, NULL, NULL,
  32557. - /* 3 */ "SMC91C90/91C92",
  32558. - /* 4 */ "SMC91C94",
  32559. - /* 5 */ "SMC91C95",
  32560. - NULL,
  32561. - /* 7 */ "SMC91C100",
  32562. - /* 8 */ "SMC91C100FD",
  32563. - NULL, NULL, NULL,
  32564. - NULL, NULL, NULL
  32565. -};
  32566. -static const char smc91c96_id[] = "SMC91C96";
  32567. -
  32568. -/*
  32569. - * Function: smc_reset( int ioaddr )
  32570. - * Purpose:
  32571. - * This sets the SMC91xx chip to its normal state, hopefully from whatever
  32572. - * mess that any other DOS driver has put it in.
  32573. - *
  32574. - * Maybe I should reset more registers to defaults in here? SOFTRESET should
  32575. - * do that for me.
  32576. - *
  32577. - * Method:
  32578. - * 1. send a SOFT RESET
  32579. - * 2. wait for it to finish
  32580. - * 3. reset the memory management unit
  32581. - * 4. clear all interrupts
  32582. - *
  32583. -*/
  32584. -static void smc_reset(int ioaddr)
  32585. -{
  32586. - /* This resets the registers mostly to defaults, but doesn't
  32587. - * affect EEPROM. That seems unnecessary */
  32588. - SMC_SELECT_BANK(ioaddr, 0);
  32589. - _outw( RCR_SOFTRESET, ioaddr + RCR );
  32590. -
  32591. - /* this should pause enough for the chip to be happy */
  32592. - SMC_DELAY(ioaddr);
  32593. -
  32594. - /* Set the transmit and receive configuration registers to
  32595. - * default values */
  32596. - _outw(RCR_CLEAR, ioaddr + RCR);
  32597. - _outw(TCR_CLEAR, ioaddr + TCR);
  32598. -
  32599. - /* Reset the MMU */
  32600. - SMC_SELECT_BANK(ioaddr, 2);
  32601. - _outw( MC_RESET, ioaddr + MMU_CMD );
  32602. -
  32603. - /* Note: It doesn't seem that waiting for the MMU busy is needed here,
  32604. - * but this is a place where future chipsets _COULD_ break. Be wary
  32605. - * of issuing another MMU command right after this */
  32606. - _outb(0, ioaddr + INT_MASK);
  32607. -}
  32608. -
  32609. -
  32610. -/*----------------------------------------------------------------------
  32611. - * Function: smc_probe( int ioaddr )
  32612. - *
  32613. - * Purpose:
  32614. - * Tests to see if a given ioaddr points to an SMC9xxx chip.
  32615. - * Returns a 0 on success
  32616. - *
  32617. - * Algorithm:
  32618. - * (1) see if the high byte of BANK_SELECT is 0x33
  32619. - * (2) compare the ioaddr with the base register's address
  32620. - * (3) see if I recognize the chip ID in the appropriate register
  32621. - *
  32622. - * ---------------------------------------------------------------------
  32623. - */
  32624. -static int smc_probe( int ioaddr )
  32625. -{
  32626. - word bank;
  32627. - word revision_register;
  32628. - word base_address_register;
  32629. -
  32630. - /* First, see if the high byte is 0x33 */
  32631. - bank = inw(ioaddr + BANK_SELECT);
  32632. - if ((bank & 0xFF00) != 0x3300) {
  32633. - return -1;
  32634. - }
  32635. - /* The above MIGHT indicate a device, but I need to write to further
  32636. - * test this. */
  32637. - _outw(0x0, ioaddr + BANK_SELECT);
  32638. - bank = inw(ioaddr + BANK_SELECT);
  32639. - if ((bank & 0xFF00) != 0x3300) {
  32640. - return -1;
  32641. - }
  32642. -
  32643. - /* well, we've already written once, so hopefully another time won't
  32644. - * hurt. This time, I need to switch the bank register to bank 1,
  32645. - * so I can access the base address register */
  32646. - SMC_SELECT_BANK(ioaddr, 1);
  32647. - base_address_register = inw(ioaddr + BASE);
  32648. -
  32649. - if (ioaddr != (base_address_register >> 3 & 0x3E0)) {
  32650. -#ifdef SMC9000_VERBOSE
  32651. - printf("SMC9000: IOADDR %hX doesn't match configuration (%hX)."
  32652. - "Probably not a SMC chip\n",
  32653. - ioaddr, base_address_register >> 3 & 0x3E0);
  32654. -#endif
  32655. - /* well, the base address register didn't match. Must not have
  32656. - * been a SMC chip after all. */
  32657. - return -1;
  32658. - }
  32659. -
  32660. -
  32661. - /* check if the revision register is something that I recognize.
  32662. - * These might need to be added to later, as future revisions
  32663. - * could be added. */
  32664. - SMC_SELECT_BANK(ioaddr, 3);
  32665. - revision_register = inw(ioaddr + REVISION);
  32666. - if (!chip_ids[(revision_register >> 4) & 0xF]) {
  32667. - /* I don't recognize this chip, so... */
  32668. -#ifdef SMC9000_VERBOSE
  32669. - printf("SMC9000: IO %hX: Unrecognized revision register:"
  32670. - " %hX, Contact author.\n", ioaddr, revision_register);
  32671. -#endif
  32672. - return -1;
  32673. - }
  32674. -
  32675. - /* at this point I'll assume that the chip is an SMC9xxx.
  32676. - * It might be prudent to check a listing of MAC addresses
  32677. - * against the hardware address, or do some other tests. */
  32678. - return 0;
  32679. -}
  32680. -
  32681. -
  32682. -/**************************************************************************
  32683. - * ETH_RESET - Reset adapter
  32684. - ***************************************************************************/
  32685. -
  32686. -static void smc9000_reset(struct nic *nic)
  32687. -{
  32688. - smc_reset(smc9000_base);
  32689. -}
  32690. -
  32691. -/**************************************************************************
  32692. - * ETH_TRANSMIT - Transmit a frame
  32693. - ***************************************************************************/
  32694. -static void smc9000_transmit(
  32695. - struct nic *nic,
  32696. - const char *d, /* Destination */
  32697. - unsigned int t, /* Type */
  32698. - unsigned int s, /* size */
  32699. - const char *p) /* Packet */
  32700. -{
  32701. - word length; /* real, length incl. header */
  32702. - word numPages;
  32703. - unsigned long time_out;
  32704. - byte packet_no;
  32705. - word status;
  32706. - int i;
  32707. -
  32708. - /* We dont pad here since we can have the hardware doing it for us */
  32709. - length = (s + ETH_HLEN + 1)&~1;
  32710. -
  32711. - /* convert to MMU pages */
  32712. - numPages = length / 256;
  32713. -
  32714. - if (numPages > 7 ) {
  32715. -#ifdef SMC9000_VERBOSE
  32716. - printf("SMC9000: Far too big packet error. \n");
  32717. -#endif
  32718. - return;
  32719. - }
  32720. -
  32721. - /* dont try more than, say 30 times */
  32722. - for (i=0;i<30;i++) {
  32723. - /* now, try to allocate the memory */
  32724. - SMC_SELECT_BANK(smc9000_base, 2);
  32725. - _outw(MC_ALLOC | numPages, smc9000_base + MMU_CMD);
  32726. -
  32727. - status = 0;
  32728. - /* wait for the memory allocation to finnish */
  32729. - for (time_out = currticks() + 5*TICKS_PER_SEC; currticks() < time_out; ) {
  32730. - status = inb(smc9000_base + INTERRUPT);
  32731. - if ( status & IM_ALLOC_INT ) {
  32732. - /* acknowledge the interrupt */
  32733. - _outb(IM_ALLOC_INT, smc9000_base + INTERRUPT);
  32734. - break;
  32735. - }
  32736. - }
  32737. -
  32738. - if ((status & IM_ALLOC_INT) != 0 ) {
  32739. - /* We've got the memory */
  32740. - break;
  32741. - } else {
  32742. - printf("SMC9000: Memory allocation timed out, resetting MMU.\n");
  32743. - _outw(MC_RESET, smc9000_base + MMU_CMD);
  32744. - }
  32745. - }
  32746. -
  32747. - /* If I get here, I _know_ there is a packet slot waiting for me */
  32748. - packet_no = inb(smc9000_base + PNR_ARR + 1);
  32749. - if (packet_no & 0x80) {
  32750. - /* or isn't there? BAD CHIP! */
  32751. - printf("SMC9000: Memory allocation failed. \n");
  32752. - return;
  32753. - }
  32754. -
  32755. - /* we have a packet address, so tell the card to use it */
  32756. - _outb(packet_no, smc9000_base + PNR_ARR);
  32757. -
  32758. - /* point to the beginning of the packet */
  32759. - _outw(PTR_AUTOINC, smc9000_base + POINTER);
  32760. -
  32761. -#if SMC9000_DEBUG > 2
  32762. - printf("Trying to xmit packet of length %hX\n", length );
  32763. -#endif
  32764. -
  32765. - /* send the packet length ( +6 for status, length and ctl byte )
  32766. - * and the status word ( set to zeros ) */
  32767. - _outw(0, smc9000_base + DATA_1 );
  32768. -
  32769. - /* send the packet length ( +6 for status words, length, and ctl) */
  32770. - _outb((length+6) & 0xFF, smc9000_base + DATA_1);
  32771. - _outb((length+6) >> 8 , smc9000_base + DATA_1);
  32772. -
  32773. - /* Write the contents of the packet */
  32774. -
  32775. - /* The ethernet header first... */
  32776. - outsw(smc9000_base + DATA_1, d, ETH_ALEN >> 1);
  32777. - outsw(smc9000_base + DATA_1, nic->node_addr, ETH_ALEN >> 1);
  32778. - _outw(htons(t), smc9000_base + DATA_1);
  32779. -
  32780. - /* ... the data ... */
  32781. - outsw(smc9000_base + DATA_1 , p, s >> 1);
  32782. -
  32783. - /* ... and the last byte, if there is one. */
  32784. - if ((s & 1) == 0) {
  32785. - _outw(0, smc9000_base + DATA_1);
  32786. - } else {
  32787. - _outb(p[s-1], smc9000_base + DATA_1);
  32788. - _outb(0x20, smc9000_base + DATA_1);
  32789. - }
  32790. -
  32791. - /* and let the chipset deal with it */
  32792. - _outw(MC_ENQUEUE , smc9000_base + MMU_CMD);
  32793. -
  32794. - status = 0; time_out = currticks() + 5*TICKS_PER_SEC;
  32795. - do {
  32796. - status = inb(smc9000_base + INTERRUPT);
  32797. -
  32798. - if ((status & IM_TX_INT ) != 0) {
  32799. - word tx_status;
  32800. -
  32801. - /* ack interrupt */
  32802. - _outb(IM_TX_INT, smc9000_base + INTERRUPT);
  32803. -
  32804. - packet_no = inw(smc9000_base + FIFO_PORTS);
  32805. - packet_no &= 0x7F;
  32806. -
  32807. - /* select this as the packet to read from */
  32808. - _outb( packet_no, smc9000_base + PNR_ARR );
  32809. -
  32810. - /* read the first word from this packet */
  32811. - _outw( PTR_AUTOINC | PTR_READ, smc9000_base + POINTER );
  32812. -
  32813. - tx_status = inw( smc9000_base + DATA_1 );
  32814. -
  32815. - if (0 == (tx_status & TS_SUCCESS)) {
  32816. -#ifdef SMC9000_VERBOSE
  32817. - printf("SMC9000: TX FAIL STATUS: %hX \n", tx_status);
  32818. -#endif
  32819. - /* re-enable transmit */
  32820. - SMC_SELECT_BANK(smc9000_base, 0);
  32821. - _outw(inw(smc9000_base + TCR ) | TCR_ENABLE, smc9000_base + TCR );
  32822. - }
  32823. -
  32824. - /* kill the packet */
  32825. - SMC_SELECT_BANK(smc9000_base, 2);
  32826. - _outw(MC_FREEPKT, smc9000_base + MMU_CMD);
  32827. -
  32828. - return;
  32829. - }
  32830. - }while(currticks() < time_out);
  32831. -
  32832. - printf("SMC9000: Waring TX timed out, resetting board\n");
  32833. - smc_reset(smc9000_base);
  32834. - return;
  32835. -}
  32836. -
  32837. -/**************************************************************************
  32838. - * ETH_POLL - Wait for a frame
  32839. - ***************************************************************************/
  32840. -static int smc9000_poll(struct nic *nic)
  32841. -{
  32842. - if(!smc9000_base)
  32843. - return 0;
  32844. -
  32845. - SMC_SELECT_BANK(smc9000_base, 2);
  32846. - if (inw(smc9000_base + FIFO_PORTS) & FP_RXEMPTY)
  32847. - return 0;
  32848. -
  32849. - /* start reading from the start of the packet */
  32850. - _outw(PTR_READ | PTR_RCV | PTR_AUTOINC, smc9000_base + POINTER);
  32851. -
  32852. - /* First read the status and check that we're ok */
  32853. - if (!(inw(smc9000_base + DATA_1) & RS_ERRORS)) {
  32854. - /* Next: read the packet length and mask off the top bits */
  32855. - nic->packetlen = (inw(smc9000_base + DATA_1) & 0x07ff);
  32856. -
  32857. - /* the packet length includes the 3 extra words */
  32858. - nic->packetlen -= 6;
  32859. -#if SMC9000_DEBUG > 2
  32860. - printf(" Reading %d words (and %d byte(s))\n",
  32861. - (nic->packetlen >> 1), nic->packetlen & 1);
  32862. -#endif
  32863. - /* read the packet (and the last "extra" word) */
  32864. - insw(smc9000_base + DATA_1, nic->packet, (nic->packetlen+2) >> 1);
  32865. - /* is there an odd last byte ? */
  32866. - if (nic->packet[nic->packetlen+1] & 0x20)
  32867. - nic->packetlen++;
  32868. -
  32869. - /* error or good, tell the card to get rid of this packet */
  32870. - _outw(MC_RELEASE, smc9000_base + MMU_CMD);
  32871. - return 1;
  32872. - }
  32873. -
  32874. - printf("SMC9000: RX error\n");
  32875. - /* error or good, tell the card to get rid of this packet */
  32876. - _outw(MC_RELEASE, smc9000_base + MMU_CMD);
  32877. - return 0;
  32878. -}
  32879. -
  32880. -static void smc9000_disable(struct nic *nic)
  32881. -{
  32882. - if(!smc9000_base)
  32883. - return;
  32884. -
  32885. - /* no more interrupts for me */
  32886. - SMC_SELECT_BANK(smc9000_base, 2);
  32887. - _outb( 0, smc9000_base + INT_MASK);
  32888. -
  32889. - /* and tell the card to stay away from that nasty outside world */
  32890. - SMC_SELECT_BANK(smc9000_base, 0);
  32891. - _outb( RCR_CLEAR, smc9000_base + RCR );
  32892. - _outb( TCR_CLEAR, smc9000_base + TCR );
  32893. -}
  32894. -
  32895. -/**************************************************************************
  32896. - * ETH_PROBE - Look for an adapter
  32897. - ***************************************************************************/
  32898. -
  32899. -struct nic *smc9000_probe(struct nic *nic, unsigned short *probe_addrs)
  32900. -{
  32901. - unsigned short revision;
  32902. - int memory;
  32903. - int media;
  32904. - const char * version_string;
  32905. - const char * if_string;
  32906. - int i;
  32907. -
  32908. - /*
  32909. - * the SMC9000 can be at any of the following port addresses. To change,
  32910. - * for a slightly different card, you can add it to the array. Keep in
  32911. - * mind that the array must end in zero.
  32912. - */
  32913. - static unsigned short portlist[] = {
  32914. -#ifdef SMC9000_SCAN
  32915. - SMC9000_SCAN,
  32916. -#else
  32917. - 0x200, 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x2E0,
  32918. - 0x300, 0x320, 0x340, 0x360, 0x380, 0x3A0, 0x3C0, 0x3E0,
  32919. -#endif
  32920. - 0 };
  32921. -
  32922. - printf("\nSMC9000 %s\n", smc9000_version);
  32923. -#ifdef SMC9000_VERBOSE
  32924. - printf("Copyright (C) 1998 Daniel Engstr\x94m\n");
  32925. - printf("Copyright (C) 1996 Eric Stahlman\n");
  32926. -#endif
  32927. - /* if no addresses supplied, fall back on defaults */
  32928. - if (probe_addrs == 0 || probe_addrs[0] == 0)
  32929. - probe_addrs = portlist;
  32930. -
  32931. - /* check every ethernet address */
  32932. - for (i = 0; probe_addrs[i]; i++) {
  32933. - /* check this specific address */
  32934. - if (smc_probe(probe_addrs[i]) == 0)
  32935. - smc9000_base = probe_addrs[i];
  32936. - }
  32937. -
  32938. - /* couldn't find anything */
  32939. - if(0 == smc9000_base)
  32940. - goto out;
  32941. -
  32942. - /*
  32943. - * Get the MAC address ( bank 1, regs 4 - 9 )
  32944. - */
  32945. - SMC_SELECT_BANK(smc9000_base, 1);
  32946. - for ( i = 0; i < 6; i += 2 ) {
  32947. - word address;
  32948. -
  32949. - address = inw(smc9000_base + ADDR0 + i);
  32950. - nic->node_addr[i+1] = address >> 8;
  32951. - nic->node_addr[i] = address & 0xFF;
  32952. - }
  32953. -
  32954. -
  32955. - /* get the memory information */
  32956. - SMC_SELECT_BANK(smc9000_base, 0);
  32957. - memory = ( inw(smc9000_base + MCR) >> 9 ) & 0x7; /* multiplier */
  32958. - memory *= 256 * (inw(smc9000_base + MIR) & 0xFF);
  32959. -
  32960. - /*
  32961. - * Now, I want to find out more about the chip. This is sort of
  32962. - * redundant, but it's cleaner to have it in both, rather than having
  32963. - * one VERY long probe procedure.
  32964. - */
  32965. - SMC_SELECT_BANK(smc9000_base, 3);
  32966. - revision = inw(smc9000_base + REVISION);
  32967. - version_string = chip_ids[(revision >> 4) & 0xF];
  32968. -
  32969. - if (((revision & 0xF0) >> 4 == CHIP_9196) &&
  32970. - ((revision & 0x0F) >= REV_9196)) {
  32971. - /* This is a 91c96. 'c96 has the same chip id as 'c94 (4) but
  32972. - * a revision starting at 6 */
  32973. - version_string = smc91c96_id;
  32974. - }
  32975. -
  32976. - if ( !version_string ) {
  32977. - /* I shouldn't get here because this call was done before.... */
  32978. - goto out;
  32979. - }
  32980. -
  32981. - /* is it using AUI or 10BaseT ? */
  32982. - SMC_SELECT_BANK(smc9000_base, 1);
  32983. - if (inw(smc9000_base + CONFIG) & CFG_AUI_SELECT)
  32984. - media = 2;
  32985. - else
  32986. - media = 1;
  32987. -
  32988. - if_string = interfaces[media - 1];
  32989. -
  32990. - /* now, reset the chip, and put it into a known state */
  32991. - smc_reset(smc9000_base);
  32992. -
  32993. - printf("%s rev:%d I/O port:%hX Interface:%s RAM:%d bytes \n",
  32994. - version_string, revision & 0xF,
  32995. - smc9000_base, if_string, memory );
  32996. - /*
  32997. - * Print the Ethernet address
  32998. - */
  32999. - printf("Ethernet MAC address: %!\n", nic->node_addr);
  33000. -
  33001. - SMC_SELECT_BANK(smc9000_base, 0);
  33002. -
  33003. - /* see the header file for options in TCR/RCR NORMAL*/
  33004. - _outw(TCR_NORMAL, smc9000_base + TCR);
  33005. - _outw(RCR_NORMAL, smc9000_base + RCR);
  33006. -
  33007. - /* Select which interface to use */
  33008. - SMC_SELECT_BANK(smc9000_base, 1);
  33009. - if ( media == 1 ) {
  33010. - _outw( inw( smc9000_base + CONFIG ) & ~CFG_AUI_SELECT,
  33011. - smc9000_base + CONFIG );
  33012. - }
  33013. - else if ( media == 2 ) {
  33014. - _outw( inw( smc9000_base + CONFIG ) | CFG_AUI_SELECT,
  33015. - smc9000_base + CONFIG );
  33016. - }
  33017. -
  33018. - nic->reset = smc9000_reset;
  33019. - nic->poll = smc9000_poll;
  33020. - nic->transmit = smc9000_transmit;
  33021. - nic->disable = smc9000_disable;
  33022. -
  33023. -
  33024. - return nic;
  33025. -
  33026. -out:
  33027. -#ifdef SMC9000_VERBOSE
  33028. - printf("No SMC9000 adapters found\n");
  33029. -#endif
  33030. - smc9000_base = 0;
  33031. -
  33032. - return (0);
  33033. -}
  33034. -
  33035. -
  33036. -
  33037. Index: b/netboot/smc9000.h
  33038. ===================================================================
  33039. --- a/netboot/smc9000.h
  33040. +++ /dev/null
  33041. @@ -1,205 +0,0 @@
  33042. -/*------------------------------------------------------------------------
  33043. - * smc9000.h
  33044. - *
  33045. - * Copyright (C) 1998 by Daniel Engström
  33046. - * Copyright (C) 1996 by Erik Stahlman
  33047. - *
  33048. - * This software may be used and distributed according to the terms
  33049. - * of the GNU Public License, incorporated herein by reference.
  33050. - *
  33051. - * This file contains register information and access macros for
  33052. - * the SMC91xxx chipset.
  33053. - *
  33054. - * Information contained in this file was obtained from the SMC91C94
  33055. - * manual from SMC. To get a copy, if you really want one, you can find
  33056. - * information under www.smsc.com in the components division.
  33057. - * ( this thanks to advice from Donald Becker ).
  33058. - *
  33059. - * Authors
  33060. - * Daniel Engström <daniel.engstrom@riksnett.no>
  33061. - * Erik Stahlman <erik@vt.edu>
  33062. - *
  33063. - * History
  33064. - * 96-01-06 Erik Stahlman moved definitions here from main .c
  33065. - * file
  33066. - * 96-01-19 Erik Stahlman polished this up some, and added
  33067. - * better error handling
  33068. - * 98-09-25 Daniel Engström adjusted for Etherboot
  33069. - * 98-09-27 Daniel Engström moved some static strings back to the
  33070. - * main .c file
  33071. - * --------------------------------------------------------------------------*/
  33072. -#ifndef _SMC9000_H_
  33073. -# define _SMC9000_H_
  33074. -
  33075. -/* I want some simple types */
  33076. -typedef unsigned char byte;
  33077. -typedef unsigned short word;
  33078. -typedef unsigned long int dword;
  33079. -
  33080. -/*---------------------------------------------------------------
  33081. - *
  33082. - * A description of the SMC registers is probably in order here,
  33083. - * although for details, the SMC datasheet is invaluable.
  33084. - *
  33085. - * Basically, the chip has 4 banks of registers ( 0 to 3 ), which
  33086. - * are accessed by writing a number into the BANK_SELECT register
  33087. - * ( I also use a SMC_SELECT_BANK macro for this ).
  33088. - *
  33089. - * The banks are configured so that for most purposes, bank 2 is all
  33090. - * that is needed for simple run time tasks.
  33091. - * ----------------------------------------------------------------------*/
  33092. -
  33093. -/*
  33094. - * Bank Select Register:
  33095. - *
  33096. - * yyyy yyyy 0000 00xx
  33097. - * xx = bank number
  33098. - * yyyy yyyy = 0x33, for identification purposes.
  33099. - */
  33100. -#define BANK_SELECT 14
  33101. -
  33102. -/* BANK 0 */
  33103. -
  33104. -#define TCR 0 /* transmit control register */
  33105. -#define TCR_ENABLE 0x0001 /* if this is 1, we can transmit */
  33106. -#define TCR_FDUPLX 0x0800 /* receive packets sent out */
  33107. -#define TCR_STP_SQET 0x1000 /* stop transmitting if Signal quality error */
  33108. -#define TCR_MON_CNS 0x0400 /* monitors the carrier status */
  33109. -#define TCR_PAD_ENABLE 0x0080 /* pads short packets to 64 bytes */
  33110. -
  33111. -#define TCR_CLEAR 0 /* do NOTHING */
  33112. -/* the normal settings for the TCR register : */
  33113. -#define TCR_NORMAL (TCR_ENABLE | TCR_PAD_ENABLE)
  33114. -
  33115. -
  33116. -#define EPH_STATUS 2
  33117. -#define ES_LINK_OK 0x4000 /* is the link integrity ok ? */
  33118. -
  33119. -#define RCR 4
  33120. -#define RCR_SOFTRESET 0x8000 /* resets the chip */
  33121. -#define RCR_STRIP_CRC 0x200 /* strips CRC */
  33122. -#define RCR_ENABLE 0x100 /* IFF this is set, we can receive packets */
  33123. -#define RCR_ALMUL 0x4 /* receive all multicast packets */
  33124. -#define RCR_PROMISC 0x2 /* enable promiscuous mode */
  33125. -
  33126. -/* the normal settings for the RCR register : */
  33127. -#define RCR_NORMAL (RCR_STRIP_CRC | RCR_ENABLE)
  33128. -#define RCR_CLEAR 0x0 /* set it to a base state */
  33129. -
  33130. -#define COUNTER 6
  33131. -#define MIR 8
  33132. -#define MCR 10
  33133. -/* 12 is reserved */
  33134. -
  33135. -/* BANK 1 */
  33136. -#define CONFIG 0
  33137. -#define CFG_AUI_SELECT 0x100
  33138. -#define BASE 2
  33139. -#define ADDR0 4
  33140. -#define ADDR1 6
  33141. -#define ADDR2 8
  33142. -#define GENERAL 10
  33143. -#define CONTROL 12
  33144. -#define CTL_POWERDOWN 0x2000
  33145. -#define CTL_LE_ENABLE 0x80
  33146. -#define CTL_CR_ENABLE 0x40
  33147. -#define CTL_TE_ENABLE 0x0020
  33148. -#define CTL_AUTO_RELEASE 0x0800
  33149. -#define CTL_EPROM_ACCESS 0x0003 /* high if Eprom is being read */
  33150. -
  33151. -/* BANK 2 */
  33152. -#define MMU_CMD 0
  33153. -#define MC_BUSY 1 /* only readable bit in the register */
  33154. -#define MC_NOP 0
  33155. -#define MC_ALLOC 0x20 /* or with number of 256 byte packets */
  33156. -#define MC_RESET 0x40
  33157. -#define MC_REMOVE 0x60 /* remove the current rx packet */
  33158. -#define MC_RELEASE 0x80 /* remove and release the current rx packet */
  33159. -#define MC_FREEPKT 0xA0 /* Release packet in PNR register */
  33160. -#define MC_ENQUEUE 0xC0 /* Enqueue the packet for transmit */
  33161. -
  33162. -#define PNR_ARR 2
  33163. -#define FIFO_PORTS 4
  33164. -
  33165. -#define FP_RXEMPTY 0x8000
  33166. -#define FP_TXEMPTY 0x80
  33167. -
  33168. -#define POINTER 6
  33169. -#define PTR_READ 0x2000
  33170. -#define PTR_RCV 0x8000
  33171. -#define PTR_AUTOINC 0x4000
  33172. -#define PTR_AUTO_INC 0x0040
  33173. -
  33174. -#define DATA_1 8
  33175. -#define DATA_2 10
  33176. -#define INTERRUPT 12
  33177. -
  33178. -#define INT_MASK 13
  33179. -#define IM_RCV_INT 0x1
  33180. -#define IM_TX_INT 0x2
  33181. -#define IM_TX_EMPTY_INT 0x4
  33182. -#define IM_ALLOC_INT 0x8
  33183. -#define IM_RX_OVRN_INT 0x10
  33184. -#define IM_EPH_INT 0x20
  33185. -#define IM_ERCV_INT 0x40 /* not on SMC9192 */
  33186. -
  33187. -/* BANK 3 */
  33188. -#define MULTICAST1 0
  33189. -#define MULTICAST2 2
  33190. -#define MULTICAST3 4
  33191. -#define MULTICAST4 6
  33192. -#define MGMT 8
  33193. -#define REVISION 10 /* ( hi: chip id low: rev # ) */
  33194. -
  33195. -
  33196. -/* this is NOT on SMC9192 */
  33197. -#define ERCV 12
  33198. -
  33199. -/* Note that 9194 and 9196 have the smame chip id,
  33200. - * the 9196 will have revisions starting at 6 */
  33201. -#define CHIP_9190 3
  33202. -#define CHIP_9194 4
  33203. -#define CHIP_9195 5
  33204. -#define CHIP_9196 4
  33205. -#define CHIP_91100 7
  33206. -#define CHIP_91100FD 8
  33207. -
  33208. -#define REV_9196 6
  33209. -
  33210. -/*
  33211. - * Transmit status bits
  33212. - */
  33213. -#define TS_SUCCESS 0x0001
  33214. -#define TS_LOSTCAR 0x0400
  33215. -#define TS_LATCOL 0x0200
  33216. -#define TS_16COL 0x0010
  33217. -
  33218. -/*
  33219. - * Receive status bits
  33220. - */
  33221. -#define RS_ALGNERR 0x8000
  33222. -#define RS_BADCRC 0x2000
  33223. -#define RS_ODDFRAME 0x1000
  33224. -#define RS_TOOLONG 0x0800
  33225. -#define RS_TOOSHORT 0x0400
  33226. -#define RS_MULTICAST 0x0001
  33227. -#define RS_ERRORS (RS_ALGNERR | RS_BADCRC | RS_TOOLONG | RS_TOOSHORT)
  33228. -
  33229. -
  33230. -/*-------------------------------------------------------------------------
  33231. - * I define some macros to make it easier to do somewhat common
  33232. - * or slightly complicated, repeated tasks.
  33233. - --------------------------------------------------------------------------*/
  33234. -
  33235. -/* select a register bank, 0 to 3 */
  33236. -
  33237. -#define SMC_SELECT_BANK(x, y) { _outw( y, x + BANK_SELECT ); }
  33238. -
  33239. -/* define a small delay for the reset */
  33240. -#define SMC_DELAY(x) { inw( x + RCR );\
  33241. - inw( x + RCR );\
  33242. - inw( x + RCR ); }
  33243. -
  33244. -
  33245. -#endif /* _SMC_9000_H_ */
  33246. -
  33247. Index: b/netboot/stdint.h
  33248. ===================================================================
  33249. --- /dev/null
  33250. +++ b/netboot/stdint.h
  33251. @@ -0,0 +1,18 @@
  33252. +#ifndef STDINT_H
  33253. +#define STDINT_H
  33254. +/*
  33255. + * I'm architecture depended. Check me before port GRUB
  33256. + */
  33257. +typedef unsigned size_t;
  33258. +
  33259. +typedef unsigned char uint8_t;
  33260. +typedef unsigned short uint16_t;
  33261. +typedef unsigned long uint32_t;
  33262. +typedef unsigned long long uint64_t;
  33263. +
  33264. +typedef signed char int8_t;
  33265. +typedef signed short int16_t;
  33266. +typedef signed long int32_t;
  33267. +typedef signed long long int64_t;
  33268. +
  33269. +#endif /* STDINT_H */
  33270. Index: b/netboot/tftp.h
  33271. ===================================================================
  33272. --- /dev/null
  33273. +++ b/netboot/tftp.h
  33274. @@ -0,0 +1,82 @@
  33275. +#ifndef _TFTP_H
  33276. +#define _TFTP_H
  33277. +
  33278. +#include "if_ether.h"
  33279. +#include "ip.h"
  33280. +#include "udp.h"
  33281. +
  33282. +#ifndef MAX_TFTP_RETRIES
  33283. +#define MAX_TFTP_RETRIES 20
  33284. +#endif
  33285. +
  33286. +/* These settings have sense only if compiled with -DCONGESTED */
  33287. +/* total retransmission timeout in ticks */
  33288. +#define TFTP_TIMEOUT (30*TICKS_PER_SEC)
  33289. +/* packet retransmission timeout in ticks */
  33290. +#define TFTP_REXMT (3*TICKS_PER_SEC)
  33291. +
  33292. +#define TFTP_PORT 69
  33293. +#define TFTP_DEFAULTSIZE_PACKET 512
  33294. +#define TFTP_MAX_PACKET 1432 /* 512 */
  33295. +
  33296. +#define TFTP_RRQ 1
  33297. +#define TFTP_WRQ 2
  33298. +#define TFTP_DATA 3
  33299. +#define TFTP_ACK 4
  33300. +#define TFTP_ERROR 5
  33301. +#define TFTP_OACK 6
  33302. +
  33303. +#define TFTP_CODE_EOF 1
  33304. +#define TFTP_CODE_MORE 2
  33305. +#define TFTP_CODE_ERROR 3
  33306. +#define TFTP_CODE_BOOT 4
  33307. +#define TFTP_CODE_CFG 5
  33308. +
  33309. +struct tftp_t {
  33310. + struct iphdr ip;
  33311. + struct udphdr udp;
  33312. + uint16_t opcode;
  33313. + union {
  33314. + uint8_t rrq[TFTP_DEFAULTSIZE_PACKET];
  33315. + struct {
  33316. + uint16_t block;
  33317. + uint8_t download[TFTP_MAX_PACKET];
  33318. + } data;
  33319. + struct {
  33320. + uint16_t block;
  33321. + } ack;
  33322. + struct {
  33323. + uint16_t errcode;
  33324. + uint8_t errmsg[TFTP_DEFAULTSIZE_PACKET];
  33325. + } err;
  33326. + struct {
  33327. + uint8_t data[TFTP_DEFAULTSIZE_PACKET+2];
  33328. + } oack;
  33329. + } u;
  33330. +};
  33331. +
  33332. +/* define a smaller tftp packet solely for making requests to conserve stack
  33333. + 512 bytes should be enough */
  33334. +struct tftpreq_t {
  33335. + struct iphdr ip;
  33336. + struct udphdr udp;
  33337. + uint16_t opcode;
  33338. + union {
  33339. + uint8_t rrq[512];
  33340. + struct {
  33341. + uint16_t block;
  33342. + } ack;
  33343. + struct {
  33344. + uint16_t errcode;
  33345. + uint8_t errmsg[512-2];
  33346. + } err;
  33347. + } u;
  33348. +};
  33349. +
  33350. +#define TFTP_MIN_PACKET (sizeof(struct iphdr) + sizeof(struct udphdr) + 4)
  33351. +
  33352. +typedef int (*read_actor_t)(unsigned char *, unsigned int, unsigned int, int);
  33353. +
  33354. +int tftp_file_read(const char *name, read_actor_t);
  33355. +
  33356. +#endif /* _TFTP_H */
  33357. Index: b/netboot/tg3.c
  33358. ===================================================================
  33359. --- /dev/null
  33360. +++ b/netboot/tg3.c
  33361. @@ -0,0 +1,3322 @@
  33362. +/* $Id: grub-0.95-diskless-patch-2.patch,v 1.1.1.1 2005/06/14 08:18:50 wesolows Exp $
  33363. + * tg3.c: Broadcom Tigon3 ethernet driver.
  33364. + *
  33365. + * Copyright (C) 2001, 2002 David S. Miller (davem@redhat.com)
  33366. + * Copyright (C) 2001, 2002 Jeff Garzik (jgarzik@mandrakesoft.com)
  33367. + * Copyright (C) 2003 Eric Biederman (ebiederman@lnxi.com) [etherboot port]
  33368. + */
  33369. +
  33370. +/* 11-13-2003 timlegge Fix Issue with NetGear GA302T
  33371. + * 11-18-2003 ebiederm Generalize NetGear Fix to what the code was supposed to be.
  33372. + */
  33373. +
  33374. +#include "etherboot.h"
  33375. +#include "nic.h"
  33376. +#include "pci.h"
  33377. +#include "timer.h"
  33378. +/*#include "string.h"*/
  33379. +#include "tg3.h"
  33380. +
  33381. +#define SUPPORT_COPPER_PHY 1
  33382. +#define SUPPORT_FIBER_PHY 1
  33383. +#define SUPPORT_LINK_REPORT 1
  33384. +#define SUPPORT_PARTNO_STR 1
  33385. +#define SUPPORT_PHY_STR 1
  33386. +
  33387. +struct tg3 tg3;
  33388. +
  33389. +/* Dummy defines for error handling */
  33390. +#define EBUSY 1
  33391. +#define ENODEV 2
  33392. +#define EINVAL 3
  33393. +#define ENOMEM 4
  33394. +
  33395. +
  33396. +/* These numbers seem to be hard coded in the NIC firmware somehow.
  33397. + * You can't change the ring sizes, but you can change where you place
  33398. + * them in the NIC onboard memory.
  33399. + */
  33400. +#define TG3_RX_RING_SIZE 512
  33401. +#define TG3_DEF_RX_RING_PENDING 20 /* RX_RING_PENDING seems to be o.k. at 20 and 200 */
  33402. +#define TG3_RX_RCB_RING_SIZE 1024
  33403. +
  33404. +/* (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ? \
  33405. + 512 : 1024) */
  33406. + #define TG3_TX_RING_SIZE 512
  33407. +#define TG3_DEF_TX_RING_PENDING (TG3_TX_RING_SIZE - 1)
  33408. +
  33409. +#define TG3_RX_RING_BYTES (sizeof(struct tg3_rx_buffer_desc) * TG3_RX_RING_SIZE)
  33410. +#define TG3_RX_RCB_RING_BYTES (sizeof(struct tg3_rx_buffer_desc) * TG3_RX_RCB_RING_SIZE)
  33411. +
  33412. +#define TG3_TX_RING_BYTES (sizeof(struct tg3_tx_buffer_desc) * TG3_TX_RING_SIZE)
  33413. +#define NEXT_TX(N) (((N) + 1) & (TG3_TX_RING_SIZE - 1))
  33414. +#define PREV_TX(N) (((N) - 1) & (TG3_TX_RING_SIZE - 1))
  33415. +
  33416. +#define RX_PKT_BUF_SZ (1536 + 2 + 64)
  33417. +
  33418. +
  33419. +static struct bss {
  33420. + struct tg3_rx_buffer_desc rx_std[TG3_RX_RING_SIZE];
  33421. + struct tg3_rx_buffer_desc rx_rcb[TG3_RX_RCB_RING_SIZE];
  33422. + struct tg3_tx_buffer_desc tx_ring[TG3_TX_RING_SIZE];
  33423. + struct tg3_hw_status hw_status;
  33424. + struct tg3_hw_stats hw_stats;
  33425. + unsigned char rx_bufs[TG3_DEF_RX_RING_PENDING][RX_PKT_BUF_SZ];
  33426. +} tg3_bss;
  33427. +
  33428. +/**
  33429. + * pci_save_state - save the PCI configuration space of a device before suspending
  33430. + * @dev: - PCI device that we're dealing with
  33431. + * @buffer: - buffer to hold config space context
  33432. + *
  33433. + * @buffer must be large enough to hold the entire PCI 2.2 config space
  33434. + * (>= 64 bytes).
  33435. + */
  33436. +static int pci_save_state(struct pci_device *dev, uint32_t *buffer)
  33437. +{
  33438. + int i;
  33439. + for (i = 0; i < 16; i++)
  33440. + pci_read_config_dword(dev, i * 4,&buffer[i]);
  33441. + return 0;
  33442. +}
  33443. +
  33444. +/**
  33445. + * pci_restore_state - Restore the saved state of a PCI device
  33446. + * @dev: - PCI device that we're dealing with
  33447. + * @buffer: - saved PCI config space
  33448. + *
  33449. + */
  33450. +static int pci_restore_state(struct pci_device *dev, uint32_t *buffer)
  33451. +{
  33452. + int i;
  33453. +
  33454. + for (i = 0; i < 16; i++)
  33455. + pci_write_config_dword(dev,i * 4, buffer[i]);
  33456. + return 0;
  33457. +}
  33458. +
  33459. +static void tg3_write_indirect_reg32(uint32_t off, uint32_t val)
  33460. +{
  33461. + pci_write_config_dword(tg3.pdev, TG3PCI_REG_BASE_ADDR, off);
  33462. + pci_write_config_dword(tg3.pdev, TG3PCI_REG_DATA, val);
  33463. +}
  33464. +
  33465. +#define tw32(reg,val) tg3_write_indirect_reg32((reg),(val))
  33466. +#define tw32_mailbox(reg, val) writel(((val) & 0xffffffff), tg3.regs + (reg))
  33467. +#define tw16(reg,val) writew(((val) & 0xffff), tg3.regs + (reg))
  33468. +#define tw8(reg,val) writeb(((val) & 0xff), tg3.regs + (reg))
  33469. +#define tr32(reg) readl(tg3.regs + (reg))
  33470. +#define tr16(reg) readw(tg3.regs + (reg))
  33471. +#define tr8(reg) readb(tg3.regs + (reg))
  33472. +
  33473. +static void tw32_carefully(uint32_t reg, uint32_t val)
  33474. +{
  33475. + tw32(reg, val);
  33476. + tr32(reg);
  33477. + udelay(100);
  33478. +}
  33479. +
  33480. +static void tw32_mailbox2(uint32_t reg, uint32_t val)
  33481. +{
  33482. + tw32_mailbox(reg, val);
  33483. + tr32(reg);
  33484. +}
  33485. +
  33486. +static void tg3_write_mem(uint32_t off, uint32_t val)
  33487. +{
  33488. + pci_write_config_dword(tg3.pdev, TG3PCI_MEM_WIN_BASE_ADDR, off);
  33489. + pci_write_config_dword(tg3.pdev, TG3PCI_MEM_WIN_DATA, val);
  33490. +
  33491. + /* Always leave this as zero. */
  33492. + pci_write_config_dword(tg3.pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0);
  33493. +}
  33494. +
  33495. +static void tg3_read_mem(uint32_t off, uint32_t *val)
  33496. +{
  33497. + pci_write_config_dword(tg3.pdev, TG3PCI_MEM_WIN_BASE_ADDR, off);
  33498. + pci_read_config_dword(tg3.pdev, TG3PCI_MEM_WIN_DATA, val);
  33499. +
  33500. + /* Always leave this as zero. */
  33501. + pci_write_config_dword(tg3.pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0);
  33502. +}
  33503. +
  33504. +static void tg3_disable_ints(struct tg3 *tp)
  33505. +{
  33506. + tw32(TG3PCI_MISC_HOST_CTRL,
  33507. + (tp->misc_host_ctrl | MISC_HOST_CTRL_MASK_PCI_INT));
  33508. + tw32_mailbox2(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
  33509. +}
  33510. +
  33511. +static void tg3_switch_clocks(struct tg3 *tp)
  33512. +{
  33513. + uint32_t orig_clock_ctrl, clock_ctrl;
  33514. +
  33515. + clock_ctrl = tr32(TG3PCI_CLOCK_CTRL);
  33516. +
  33517. + orig_clock_ctrl = clock_ctrl;
  33518. + clock_ctrl &= (CLOCK_CTRL_FORCE_CLKRUN | CLOCK_CTRL_CLKRUN_OENABLE | 0x1f);
  33519. + tp->pci_clock_ctrl = clock_ctrl;
  33520. +
  33521. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) &&
  33522. + (orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE)!=0) {
  33523. + tw32_carefully(TG3PCI_CLOCK_CTRL,
  33524. + clock_ctrl | (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK));
  33525. + tw32_carefully(TG3PCI_CLOCK_CTRL,
  33526. + clock_ctrl | (CLOCK_CTRL_ALTCLK));
  33527. + }
  33528. + tw32_carefully(TG3PCI_CLOCK_CTRL, clock_ctrl);
  33529. +}
  33530. +
  33531. +#define PHY_BUSY_LOOPS 5000
  33532. +
  33533. +static int tg3_readphy(struct tg3 *tp, int reg, uint32_t *val)
  33534. +{
  33535. + uint32_t frame_val;
  33536. + int loops, ret;
  33537. +
  33538. + tw32_carefully(MAC_MI_MODE, tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL);
  33539. +
  33540. + *val = 0xffffffff;
  33541. +
  33542. + frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
  33543. + MI_COM_PHY_ADDR_MASK);
  33544. + frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
  33545. + MI_COM_REG_ADDR_MASK);
  33546. + frame_val |= (MI_COM_CMD_READ | MI_COM_START);
  33547. +
  33548. + tw32_carefully(MAC_MI_COM, frame_val);
  33549. +
  33550. + loops = PHY_BUSY_LOOPS;
  33551. + while (loops-- > 0) {
  33552. + udelay(10);
  33553. + frame_val = tr32(MAC_MI_COM);
  33554. +
  33555. + if ((frame_val & MI_COM_BUSY) == 0) {
  33556. + udelay(5);
  33557. + frame_val = tr32(MAC_MI_COM);
  33558. + break;
  33559. + }
  33560. + }
  33561. +
  33562. + ret = -EBUSY;
  33563. + if (loops > 0) {
  33564. + *val = frame_val & MI_COM_DATA_MASK;
  33565. + ret = 0;
  33566. + }
  33567. +
  33568. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  33569. +
  33570. + return ret;
  33571. +}
  33572. +
  33573. +static int tg3_writephy(struct tg3 *tp, int reg, uint32_t val)
  33574. +{
  33575. + uint32_t frame_val;
  33576. + int loops, ret;
  33577. +
  33578. + tw32_carefully(MAC_MI_MODE, tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL);
  33579. +
  33580. + frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
  33581. + MI_COM_PHY_ADDR_MASK);
  33582. + frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
  33583. + MI_COM_REG_ADDR_MASK);
  33584. + frame_val |= (val & MI_COM_DATA_MASK);
  33585. + frame_val |= (MI_COM_CMD_WRITE | MI_COM_START);
  33586. +
  33587. + tw32_carefully(MAC_MI_COM, frame_val);
  33588. +
  33589. + loops = PHY_BUSY_LOOPS;
  33590. + while (loops-- > 0) {
  33591. + udelay(10);
  33592. + frame_val = tr32(MAC_MI_COM);
  33593. + if ((frame_val & MI_COM_BUSY) == 0) {
  33594. + udelay(5);
  33595. + frame_val = tr32(MAC_MI_COM);
  33596. + break;
  33597. + }
  33598. + }
  33599. +
  33600. + ret = -EBUSY;
  33601. + if (loops > 0)
  33602. + ret = 0;
  33603. +
  33604. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  33605. +
  33606. + return ret;
  33607. +}
  33608. +
  33609. +static int tg3_writedsp(struct tg3 *tp, uint16_t addr, uint16_t val)
  33610. +{
  33611. + int err;
  33612. + err = tg3_writephy(tp, MII_TG3_DSP_ADDRESS, addr);
  33613. + err |= tg3_writephy(tp, MII_TG3_DSP_RW_PORT, val);
  33614. + return err;
  33615. +}
  33616. +
  33617. +
  33618. +static void tg3_phy_set_wirespeed(struct tg3 *tp)
  33619. +{
  33620. + uint32_t val;
  33621. +
  33622. + if (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED)
  33623. + return;
  33624. +
  33625. + tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x7007);
  33626. + tg3_readphy(tp, MII_TG3_AUX_CTRL, &val);
  33627. + tg3_writephy(tp, MII_TG3_AUX_CTRL, (val | (1 << 15) | (1 << 4)));
  33628. +}
  33629. +
  33630. +static int tg3_bmcr_reset(struct tg3 *tp)
  33631. +{
  33632. + uint32_t phy_control;
  33633. + int limit, err;
  33634. +
  33635. + /* OK, reset it, and poll the BMCR_RESET bit until it
  33636. + * clears or we time out.
  33637. + */
  33638. + phy_control = BMCR_RESET;
  33639. + err = tg3_writephy(tp, MII_BMCR, phy_control);
  33640. + if (err != 0)
  33641. + return -EBUSY;
  33642. +
  33643. + limit = 5000;
  33644. + while (limit--) {
  33645. + err = tg3_readphy(tp, MII_BMCR, &phy_control);
  33646. + if (err != 0)
  33647. + return -EBUSY;
  33648. +
  33649. + if ((phy_control & BMCR_RESET) == 0) {
  33650. + udelay(40);
  33651. + break;
  33652. + }
  33653. + udelay(10);
  33654. + }
  33655. + if (limit <= 0)
  33656. + return -EBUSY;
  33657. +
  33658. + return 0;
  33659. +}
  33660. +
  33661. +static int tg3_wait_macro_done(struct tg3 *tp)
  33662. +{
  33663. + int limit = 100;
  33664. +
  33665. + while (limit--) {
  33666. + uint32_t tmp32;
  33667. +
  33668. + tg3_readphy(tp, 0x16, &tmp32);
  33669. + if ((tmp32 & 0x1000) == 0)
  33670. + break;
  33671. + }
  33672. + if (limit <= 0)
  33673. + return -EBUSY;
  33674. +
  33675. + return 0;
  33676. +}
  33677. +
  33678. +static int tg3_phy_write_and_check_testpat(struct tg3 *tp, int *resetp)
  33679. +{
  33680. + static const uint32_t test_pat[4][6] = {
  33681. + { 0x00005555, 0x00000005, 0x00002aaa, 0x0000000a, 0x00003456, 0x00000003 },
  33682. + { 0x00002aaa, 0x0000000a, 0x00003333, 0x00000003, 0x0000789a, 0x00000005 },
  33683. + { 0x00005a5a, 0x00000005, 0x00002a6a, 0x0000000a, 0x00001bcd, 0x00000003 },
  33684. + { 0x00002a5a, 0x0000000a, 0x000033c3, 0x00000003, 0x00002ef1, 0x00000005 }
  33685. + };
  33686. + int chan;
  33687. +
  33688. + for (chan = 0; chan < 4; chan++) {
  33689. + int i;
  33690. +
  33691. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
  33692. + (chan * 0x2000) | 0x0200);
  33693. + tg3_writephy(tp, 0x16, 0x0002);
  33694. +
  33695. + for (i = 0; i < 6; i++)
  33696. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT,
  33697. + test_pat[chan][i]);
  33698. +
  33699. + tg3_writephy(tp, 0x16, 0x0202);
  33700. + if (tg3_wait_macro_done(tp)) {
  33701. + *resetp = 1;
  33702. + return -EBUSY;
  33703. + }
  33704. +
  33705. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
  33706. + (chan * 0x2000) | 0x0200);
  33707. + tg3_writephy(tp, 0x16, 0x0082);
  33708. + if (tg3_wait_macro_done(tp)) {
  33709. + *resetp = 1;
  33710. + return -EBUSY;
  33711. + }
  33712. +
  33713. + tg3_writephy(tp, 0x16, 0x0802);
  33714. + if (tg3_wait_macro_done(tp)) {
  33715. + *resetp = 1;
  33716. + return -EBUSY;
  33717. + }
  33718. +
  33719. + for (i = 0; i < 6; i += 2) {
  33720. + uint32_t low, high;
  33721. +
  33722. + tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &low);
  33723. + tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &high);
  33724. + if (tg3_wait_macro_done(tp)) {
  33725. + *resetp = 1;
  33726. + return -EBUSY;
  33727. + }
  33728. + low &= 0x7fff;
  33729. + high &= 0x000f;
  33730. + if (low != test_pat[chan][i] ||
  33731. + high != test_pat[chan][i+1]) {
  33732. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000b);
  33733. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4001);
  33734. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4005);
  33735. +
  33736. + return -EBUSY;
  33737. + }
  33738. + }
  33739. + }
  33740. +
  33741. + return 0;
  33742. +}
  33743. +
  33744. +static int tg3_phy_reset_chanpat(struct tg3 *tp)
  33745. +{
  33746. + int chan;
  33747. +
  33748. + for (chan = 0; chan < 4; chan++) {
  33749. + int i;
  33750. +
  33751. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
  33752. + (chan * 0x2000) | 0x0200);
  33753. + tg3_writephy(tp, 0x16, 0x0002);
  33754. + for (i = 0; i < 6; i++)
  33755. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x000);
  33756. + tg3_writephy(tp, 0x16, 0x0202);
  33757. + if (tg3_wait_macro_done(tp))
  33758. + return -EBUSY;
  33759. + }
  33760. +
  33761. + return 0;
  33762. +}
  33763. +
  33764. +static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
  33765. +{
  33766. + uint32_t reg32, phy9_orig;
  33767. + int retries, do_phy_reset, err;
  33768. +
  33769. + retries = 10;
  33770. + do_phy_reset = 1;
  33771. + do {
  33772. + if (do_phy_reset) {
  33773. + err = tg3_bmcr_reset(tp);
  33774. + if (err)
  33775. + return err;
  33776. + do_phy_reset = 0;
  33777. + }
  33778. +
  33779. + /* Disable transmitter and interrupt. */
  33780. + tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32);
  33781. + reg32 |= 0x3000;
  33782. + tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
  33783. +
  33784. + /* Set full-duplex, 1000 mbps. */
  33785. + tg3_writephy(tp, MII_BMCR,
  33786. + BMCR_FULLDPLX | TG3_BMCR_SPEED1000);
  33787. +
  33788. + /* Set to master mode. */
  33789. + tg3_readphy(tp, MII_TG3_CTRL, &phy9_orig);
  33790. + tg3_writephy(tp, MII_TG3_CTRL,
  33791. + (MII_TG3_CTRL_AS_MASTER |
  33792. + MII_TG3_CTRL_ENABLE_AS_MASTER));
  33793. +
  33794. + /* Enable SM_DSP_CLOCK and 6dB. */
  33795. + tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00);
  33796. +
  33797. + /* Block the PHY control access. */
  33798. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8005);
  33799. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x0800);
  33800. +
  33801. + err = tg3_phy_write_and_check_testpat(tp, &do_phy_reset);
  33802. + if (!err)
  33803. + break;
  33804. + } while (--retries);
  33805. +
  33806. + err = tg3_phy_reset_chanpat(tp);
  33807. + if (err)
  33808. + return err;
  33809. +
  33810. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8005);
  33811. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x0000);
  33812. +
  33813. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200);
  33814. + tg3_writephy(tp, 0x16, 0x0000);
  33815. +
  33816. + tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400);
  33817. +
  33818. + tg3_writephy(tp, MII_TG3_CTRL, phy9_orig);
  33819. +
  33820. + tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32);
  33821. + reg32 &= ~0x3000;
  33822. + tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
  33823. +
  33824. + return err;
  33825. +}
  33826. +
  33827. +/* This will reset the tigon3 PHY if there is no valid
  33828. + * link.
  33829. + */
  33830. +static int tg3_phy_reset(struct tg3 *tp)
  33831. +{
  33832. + uint32_t phy_status;
  33833. + int err;
  33834. +
  33835. + err = tg3_readphy(tp, MII_BMSR, &phy_status);
  33836. + err |= tg3_readphy(tp, MII_BMSR, &phy_status);
  33837. + if (err != 0)
  33838. + return -EBUSY;
  33839. +
  33840. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
  33841. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
  33842. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) {
  33843. + err = tg3_phy_reset_5703_4_5(tp);
  33844. + if (err)
  33845. + return err;
  33846. + goto out;
  33847. + }
  33848. + err = tg3_bmcr_reset(tp);
  33849. + if (err)
  33850. + return err;
  33851. + out:
  33852. + tg3_phy_set_wirespeed(tp);
  33853. + return 0;
  33854. +}
  33855. +
  33856. +static void tg3_set_power_state_0(struct tg3 *tp)
  33857. +{
  33858. + uint16_t power_control;
  33859. + int pm = tp->pm_cap;
  33860. +
  33861. + /* Make sure register accesses (indirect or otherwise)
  33862. + * will function correctly.
  33863. + */
  33864. + pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, tp->misc_host_ctrl);
  33865. +
  33866. + pci_read_config_word(tp->pdev, pm + PCI_PM_CTRL, &power_control);
  33867. +
  33868. + power_control |= PCI_PM_CTRL_PME_STATUS;
  33869. + power_control &= ~(PCI_PM_CTRL_STATE_MASK);
  33870. + power_control |= 0;
  33871. + pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control);
  33872. +
  33873. + tw32_carefully(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
  33874. +
  33875. + return;
  33876. +}
  33877. +
  33878. +
  33879. +#if SUPPORT_LINK_REPORT
  33880. +static void tg3_link_report(struct tg3 *tp)
  33881. +{
  33882. + if (!tp->carrier_ok) {
  33883. + printf("Link is down.\n");
  33884. + } else {
  33885. + printf("Link is up at %d Mbps, %s duplex. %s %s %s\n",
  33886. + (tp->link_config.active_speed == SPEED_1000 ?
  33887. + 1000 :
  33888. + (tp->link_config.active_speed == SPEED_100 ?
  33889. + 100 : 10)),
  33890. + (tp->link_config.active_duplex == DUPLEX_FULL ?
  33891. + "full" : "half"),
  33892. + (tp->tg3_flags & TG3_FLAG_TX_PAUSE) ? "TX" : "",
  33893. + (tp->tg3_flags & TG3_FLAG_RX_PAUSE) ? "RX" : "",
  33894. + (tp->tg3_flags & (TG3_FLAG_TX_PAUSE |TG3_FLAG_RX_PAUSE)) ? "flow control" : "");
  33895. + }
  33896. +}
  33897. +#else
  33898. +#define tg3_link_report(tp)
  33899. +#endif
  33900. +
  33901. +static void tg3_setup_flow_control(struct tg3 *tp, uint32_t local_adv, uint32_t remote_adv)
  33902. +{
  33903. + uint32_t new_tg3_flags = 0;
  33904. +
  33905. + if (local_adv & ADVERTISE_PAUSE_CAP) {
  33906. + if (local_adv & ADVERTISE_PAUSE_ASYM) {
  33907. + if (remote_adv & LPA_PAUSE_CAP)
  33908. + new_tg3_flags |=
  33909. + (TG3_FLAG_RX_PAUSE |
  33910. + TG3_FLAG_TX_PAUSE);
  33911. + else if (remote_adv & LPA_PAUSE_ASYM)
  33912. + new_tg3_flags |=
  33913. + (TG3_FLAG_RX_PAUSE);
  33914. + } else {
  33915. + if (remote_adv & LPA_PAUSE_CAP)
  33916. + new_tg3_flags |=
  33917. + (TG3_FLAG_RX_PAUSE |
  33918. + TG3_FLAG_TX_PAUSE);
  33919. + }
  33920. + } else if (local_adv & ADVERTISE_PAUSE_ASYM) {
  33921. + if ((remote_adv & LPA_PAUSE_CAP) &&
  33922. + (remote_adv & LPA_PAUSE_ASYM))
  33923. + new_tg3_flags |= TG3_FLAG_TX_PAUSE;
  33924. + }
  33925. +
  33926. + tp->tg3_flags &= ~(TG3_FLAG_RX_PAUSE | TG3_FLAG_TX_PAUSE);
  33927. + tp->tg3_flags |= new_tg3_flags;
  33928. +
  33929. + if (new_tg3_flags & TG3_FLAG_RX_PAUSE)
  33930. + tp->rx_mode |= RX_MODE_FLOW_CTRL_ENABLE;
  33931. + else
  33932. + tp->rx_mode &= ~RX_MODE_FLOW_CTRL_ENABLE;
  33933. +
  33934. + if (new_tg3_flags & TG3_FLAG_TX_PAUSE)
  33935. + tp->tx_mode |= TX_MODE_FLOW_CTRL_ENABLE;
  33936. + else
  33937. + tp->tx_mode &= ~TX_MODE_FLOW_CTRL_ENABLE;
  33938. +}
  33939. +
  33940. +#if SUPPORT_COPPER_PHY
  33941. +static void tg3_aux_stat_to_speed_duplex(
  33942. + struct tg3 *tp __unused, uint32_t val, uint8_t *speed, uint8_t *duplex)
  33943. +{
  33944. + static const uint8_t map[] = {
  33945. + [0] = (SPEED_INVALID << 2) | DUPLEX_INVALID,
  33946. + [MII_TG3_AUX_STAT_10HALF >> 8] = (SPEED_10 << 2) | DUPLEX_HALF,
  33947. + [MII_TG3_AUX_STAT_10FULL >> 8] = (SPEED_10 << 2) | DUPLEX_FULL,
  33948. + [MII_TG3_AUX_STAT_100HALF >> 8] = (SPEED_100 << 2) | DUPLEX_HALF,
  33949. + [MII_TG3_AUX_STAT_100_4 >> 8] = (SPEED_INVALID << 2) | DUPLEX_INVALID,
  33950. + [MII_TG3_AUX_STAT_100FULL >> 8] = (SPEED_100 << 2) | DUPLEX_FULL,
  33951. + [MII_TG3_AUX_STAT_1000HALF >> 8] = (SPEED_1000 << 2) | DUPLEX_HALF,
  33952. + [MII_TG3_AUX_STAT_1000FULL >> 8] = (SPEED_1000 << 2) | DUPLEX_FULL,
  33953. + };
  33954. + uint8_t result;
  33955. + result = map[(val & MII_TG3_AUX_STAT_SPDMASK) >> 8];
  33956. + *speed = result >> 2;
  33957. + *duplex = result & 3;
  33958. +}
  33959. +
  33960. +static int tg3_phy_copper_begin(struct tg3 *tp)
  33961. +{
  33962. + uint32_t new_adv;
  33963. +
  33964. + tp->link_config.advertising =
  33965. + (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
  33966. + ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
  33967. + ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full |
  33968. + ADVERTISED_Autoneg | ADVERTISED_MII);
  33969. +
  33970. + if (tp->tg3_flags & TG3_FLAG_10_100_ONLY) {
  33971. + tp->link_config.advertising &=
  33972. + ~(ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full);
  33973. + }
  33974. +
  33975. + new_adv = (ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
  33976. + if (tp->link_config.advertising & ADVERTISED_10baseT_Half) {
  33977. + new_adv |= ADVERTISE_10HALF;
  33978. + }
  33979. + if (tp->link_config.advertising & ADVERTISED_10baseT_Full) {
  33980. + new_adv |= ADVERTISE_10FULL;
  33981. + }
  33982. + if (tp->link_config.advertising & ADVERTISED_100baseT_Half) {
  33983. + new_adv |= ADVERTISE_100HALF;
  33984. + }
  33985. + if (tp->link_config.advertising & ADVERTISED_100baseT_Full) {
  33986. + new_adv |= ADVERTISE_100FULL;
  33987. + }
  33988. + tg3_writephy(tp, MII_ADVERTISE, new_adv);
  33989. +
  33990. + if (tp->link_config.advertising &
  33991. + (ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full)) {
  33992. + new_adv = 0;
  33993. + if (tp->link_config.advertising & ADVERTISED_1000baseT_Half) {
  33994. + new_adv |= MII_TG3_CTRL_ADV_1000_HALF;
  33995. + }
  33996. + if (tp->link_config.advertising & ADVERTISED_1000baseT_Full) {
  33997. + new_adv |= MII_TG3_CTRL_ADV_1000_FULL;
  33998. + }
  33999. + if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY) &&
  34000. + (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
  34001. + tp->pci_chip_rev_id == CHIPREV_ID_5701_B0)) {
  34002. + new_adv |= (MII_TG3_CTRL_AS_MASTER |
  34003. + MII_TG3_CTRL_ENABLE_AS_MASTER);
  34004. + }
  34005. + tg3_writephy(tp, MII_TG3_CTRL, new_adv);
  34006. + } else {
  34007. + tg3_writephy(tp, MII_TG3_CTRL, 0);
  34008. + }
  34009. +
  34010. + tg3_writephy(tp, MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART);
  34011. +
  34012. + return 0;
  34013. +}
  34014. +
  34015. +static int tg3_init_5401phy_dsp(struct tg3 *tp)
  34016. +{
  34017. + int err;
  34018. +
  34019. + /* Turn off tap power management. */
  34020. + err = tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c20);
  34021. +
  34022. + err |= tg3_writedsp(tp, 0x0012, 0x1804);
  34023. + err |= tg3_writedsp(tp, 0x0013, 0x1204);
  34024. + err |= tg3_writedsp(tp, 0x8006, 0x0132);
  34025. + err |= tg3_writedsp(tp, 0x8006, 0x0232);
  34026. + err |= tg3_writedsp(tp, 0x201f, 0x0a20);
  34027. +
  34028. + udelay(40);
  34029. +
  34030. + return err;
  34031. +}
  34032. +
  34033. +static int tg3_setup_copper_phy(struct tg3 *tp)
  34034. +{
  34035. + int current_link_up;
  34036. + uint32_t bmsr, dummy;
  34037. + int i, err;
  34038. +
  34039. + tw32_carefully(MAC_STATUS,
  34040. + (MAC_STATUS_SYNC_CHANGED | MAC_STATUS_CFG_CHANGED));
  34041. +
  34042. + tp->mi_mode = MAC_MI_MODE_BASE;
  34043. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  34044. +
  34045. + tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x02);
  34046. +
  34047. + /* Some third-party PHYs need to be reset on link going
  34048. + * down.
  34049. + */
  34050. + if ( ( (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
  34051. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
  34052. + (tp->pci_chip_rev_id == CHIPREV_ID_5705_A0)) &&
  34053. + (tp->carrier_ok)) {
  34054. + tg3_readphy(tp, MII_BMSR, &bmsr);
  34055. + tg3_readphy(tp, MII_BMSR, &bmsr);
  34056. + if (!(bmsr & BMSR_LSTATUS))
  34057. + tg3_phy_reset(tp);
  34058. + }
  34059. +
  34060. + if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) {
  34061. + tg3_readphy(tp, MII_BMSR, &bmsr);
  34062. + tg3_readphy(tp, MII_BMSR, &bmsr);
  34063. +
  34064. + if (!(tp->tg3_flags & TG3_FLAG_INIT_COMPLETE))
  34065. + bmsr = 0;
  34066. +
  34067. + if (!(bmsr & BMSR_LSTATUS)) {
  34068. + err = tg3_init_5401phy_dsp(tp);
  34069. + if (err)
  34070. + return err;
  34071. +
  34072. + tg3_readphy(tp, MII_BMSR, &bmsr);
  34073. + for (i = 0; i < 1000; i++) {
  34074. + udelay(10);
  34075. + tg3_readphy(tp, MII_BMSR, &bmsr);
  34076. + if (bmsr & BMSR_LSTATUS) {
  34077. + udelay(40);
  34078. + break;
  34079. + }
  34080. + }
  34081. +
  34082. + if ((tp->phy_id & PHY_ID_REV_MASK) == PHY_REV_BCM5401_B0 &&
  34083. + !(bmsr & BMSR_LSTATUS) &&
  34084. + tp->link_config.active_speed == SPEED_1000) {
  34085. + err = tg3_phy_reset(tp);
  34086. + if (!err)
  34087. + err = tg3_init_5401phy_dsp(tp);
  34088. + if (err)
  34089. + return err;
  34090. + }
  34091. + }
  34092. + } else if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
  34093. + tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) {
  34094. + /* 5701 {A0,B0} CRC bug workaround */
  34095. + tg3_writephy(tp, 0x15, 0x0a75);
  34096. + tg3_writephy(tp, 0x1c, 0x8c68);
  34097. + tg3_writephy(tp, 0x1c, 0x8d68);
  34098. + tg3_writephy(tp, 0x1c, 0x8c68);
  34099. + }
  34100. +
  34101. + /* Clear pending interrupts... */
  34102. + tg3_readphy(tp, MII_TG3_ISTAT, &dummy);
  34103. + tg3_readphy(tp, MII_TG3_ISTAT, &dummy);
  34104. +
  34105. + tg3_writephy(tp, MII_TG3_IMASK, ~0);
  34106. +
  34107. + if (tp->led_mode == led_mode_three_link)
  34108. + tg3_writephy(tp, MII_TG3_EXT_CTRL,
  34109. + MII_TG3_EXT_CTRL_LNK3_LED_MODE);
  34110. + else
  34111. + tg3_writephy(tp, MII_TG3_EXT_CTRL, 0);
  34112. +
  34113. + current_link_up = 0;
  34114. +
  34115. + tg3_readphy(tp, MII_BMSR, &bmsr);
  34116. + tg3_readphy(tp, MII_BMSR, &bmsr);
  34117. +
  34118. + if (bmsr & BMSR_LSTATUS) {
  34119. + uint32_t aux_stat, bmcr;
  34120. +
  34121. + tg3_readphy(tp, MII_TG3_AUX_STAT, &aux_stat);
  34122. + for (i = 0; i < 2000; i++) {
  34123. + udelay(10);
  34124. + tg3_readphy(tp, MII_TG3_AUX_STAT, &aux_stat);
  34125. + if (aux_stat)
  34126. + break;
  34127. + }
  34128. +
  34129. + tg3_aux_stat_to_speed_duplex(tp, aux_stat,
  34130. + &tp->link_config.active_speed,
  34131. + &tp->link_config.active_duplex);
  34132. + tg3_readphy(tp, MII_BMCR, &bmcr);
  34133. + tg3_readphy(tp, MII_BMCR, &bmcr);
  34134. + if (bmcr & BMCR_ANENABLE) {
  34135. + uint32_t gig_ctrl;
  34136. +
  34137. + current_link_up = 1;
  34138. +
  34139. + /* Force autoneg restart if we are exiting
  34140. + * low power mode.
  34141. + */
  34142. + tg3_readphy(tp, MII_TG3_CTRL, &gig_ctrl);
  34143. + if (!(gig_ctrl & (MII_TG3_CTRL_ADV_1000_HALF |
  34144. + MII_TG3_CTRL_ADV_1000_FULL))) {
  34145. + current_link_up = 0;
  34146. + }
  34147. + } else {
  34148. + current_link_up = 0;
  34149. + }
  34150. + }
  34151. +
  34152. + if (current_link_up == 1 &&
  34153. + (tp->link_config.active_duplex == DUPLEX_FULL)) {
  34154. + uint32_t local_adv, remote_adv;
  34155. +
  34156. + tg3_readphy(tp, MII_ADVERTISE, &local_adv);
  34157. + local_adv &= (ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
  34158. +
  34159. + tg3_readphy(tp, MII_LPA, &remote_adv);
  34160. + remote_adv &= (LPA_PAUSE_CAP | LPA_PAUSE_ASYM);
  34161. +
  34162. + /* If we are not advertising full pause capability,
  34163. + * something is wrong. Bring the link down and reconfigure.
  34164. + */
  34165. + if (local_adv != ADVERTISE_PAUSE_CAP) {
  34166. + current_link_up = 0;
  34167. + } else {
  34168. + tg3_setup_flow_control(tp, local_adv, remote_adv);
  34169. + }
  34170. + }
  34171. +
  34172. + if (current_link_up == 0) {
  34173. + uint32_t tmp;
  34174. +
  34175. + tg3_phy_copper_begin(tp);
  34176. +
  34177. + tg3_readphy(tp, MII_BMSR, &tmp);
  34178. + tg3_readphy(tp, MII_BMSR, &tmp);
  34179. + if (tmp & BMSR_LSTATUS)
  34180. + current_link_up = 1;
  34181. + }
  34182. +
  34183. + tp->mac_mode &= ~MAC_MODE_PORT_MODE_MASK;
  34184. + if (current_link_up == 1) {
  34185. + if (tp->link_config.active_speed == SPEED_100 ||
  34186. + tp->link_config.active_speed == SPEED_10)
  34187. + tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
  34188. + else
  34189. + tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
  34190. + } else
  34191. + tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
  34192. +
  34193. + tp->mac_mode &= ~MAC_MODE_HALF_DUPLEX;
  34194. + if (tp->link_config.active_duplex == DUPLEX_HALF)
  34195. + tp->mac_mode |= MAC_MODE_HALF_DUPLEX;
  34196. +
  34197. + tp->mac_mode &= ~MAC_MODE_LINK_POLARITY;
  34198. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) {
  34199. + if ((tp->led_mode == led_mode_link10) ||
  34200. + (current_link_up == 1 &&
  34201. + tp->link_config.active_speed == SPEED_10))
  34202. + tp->mac_mode |= MAC_MODE_LINK_POLARITY;
  34203. + } else {
  34204. + if (current_link_up == 1)
  34205. + tp->mac_mode |= MAC_MODE_LINK_POLARITY;
  34206. + tw32(MAC_LED_CTRL, LED_CTRL_PHY_MODE_1);
  34207. + }
  34208. +
  34209. + /* ??? Without this setting Netgear GA302T PHY does not
  34210. + * ??? send/receive packets...
  34211. + * With this other PHYs cannot bring up the link
  34212. + */
  34213. + if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5411 &&
  34214. + tp->pci_chip_rev_id == CHIPREV_ID_5700_ALTIMA) {
  34215. + tp->mi_mode |= MAC_MI_MODE_AUTO_POLL;
  34216. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  34217. + }
  34218. +
  34219. + tw32_carefully(MAC_MODE, tp->mac_mode);
  34220. +
  34221. + /* Link change polled. */
  34222. + tw32_carefully(MAC_EVENT, 0);
  34223. +
  34224. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 &&
  34225. + current_link_up == 1 &&
  34226. + tp->link_config.active_speed == SPEED_1000 &&
  34227. + ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) ||
  34228. + (tp->tg3_flags & TG3_FLAG_PCI_HIGH_SPEED))) {
  34229. + udelay(120);
  34230. + tw32_carefully(MAC_STATUS,
  34231. + (MAC_STATUS_SYNC_CHANGED | MAC_STATUS_CFG_CHANGED));
  34232. + tg3_write_mem(
  34233. + NIC_SRAM_FIRMWARE_MBOX,
  34234. + NIC_SRAM_FIRMWARE_MBOX_MAGIC2);
  34235. + }
  34236. +
  34237. + if (current_link_up != tp->carrier_ok) {
  34238. + tp->carrier_ok = current_link_up;
  34239. + tg3_link_report(tp);
  34240. + }
  34241. +
  34242. + return 0;
  34243. +}
  34244. +#else
  34245. +#define tg3_setup_copper_phy(TP) (-EINVAL)
  34246. +#endif /* SUPPORT_COPPER_PHY */
  34247. +
  34248. +#if SUPPORT_FIBER_PHY
  34249. +struct tg3_fiber_aneginfo {
  34250. + int state;
  34251. +#define ANEG_STATE_UNKNOWN 0
  34252. +#define ANEG_STATE_AN_ENABLE 1
  34253. +#define ANEG_STATE_RESTART_INIT 2
  34254. +#define ANEG_STATE_RESTART 3
  34255. +#define ANEG_STATE_DISABLE_LINK_OK 4
  34256. +#define ANEG_STATE_ABILITY_DETECT_INIT 5
  34257. +#define ANEG_STATE_ABILITY_DETECT 6
  34258. +#define ANEG_STATE_ACK_DETECT_INIT 7
  34259. +#define ANEG_STATE_ACK_DETECT 8
  34260. +#define ANEG_STATE_COMPLETE_ACK_INIT 9
  34261. +#define ANEG_STATE_COMPLETE_ACK 10
  34262. +#define ANEG_STATE_IDLE_DETECT_INIT 11
  34263. +#define ANEG_STATE_IDLE_DETECT 12
  34264. +#define ANEG_STATE_LINK_OK 13
  34265. +#define ANEG_STATE_NEXT_PAGE_WAIT_INIT 14
  34266. +#define ANEG_STATE_NEXT_PAGE_WAIT 15
  34267. +
  34268. + uint32_t flags;
  34269. +#define MR_AN_ENABLE 0x00000001
  34270. +#define MR_RESTART_AN 0x00000002
  34271. +#define MR_AN_COMPLETE 0x00000004
  34272. +#define MR_PAGE_RX 0x00000008
  34273. +#define MR_NP_LOADED 0x00000010
  34274. +#define MR_TOGGLE_TX 0x00000020
  34275. +#define MR_LP_ADV_FULL_DUPLEX 0x00000040
  34276. +#define MR_LP_ADV_HALF_DUPLEX 0x00000080
  34277. +#define MR_LP_ADV_SYM_PAUSE 0x00000100
  34278. +#define MR_LP_ADV_ASYM_PAUSE 0x00000200
  34279. +#define MR_LP_ADV_REMOTE_FAULT1 0x00000400
  34280. +#define MR_LP_ADV_REMOTE_FAULT2 0x00000800
  34281. +#define MR_LP_ADV_NEXT_PAGE 0x00001000
  34282. +#define MR_TOGGLE_RX 0x00002000
  34283. +#define MR_NP_RX 0x00004000
  34284. +
  34285. +#define MR_LINK_OK 0x80000000
  34286. +
  34287. + unsigned long link_time, cur_time;
  34288. +
  34289. + uint32_t ability_match_cfg;
  34290. + int ability_match_count;
  34291. +
  34292. + char ability_match, idle_match, ack_match;
  34293. +
  34294. + uint32_t txconfig, rxconfig;
  34295. +#define ANEG_CFG_NP 0x00000080
  34296. +#define ANEG_CFG_ACK 0x00000040
  34297. +#define ANEG_CFG_RF2 0x00000020
  34298. +#define ANEG_CFG_RF1 0x00000010
  34299. +#define ANEG_CFG_PS2 0x00000001
  34300. +#define ANEG_CFG_PS1 0x00008000
  34301. +#define ANEG_CFG_HD 0x00004000
  34302. +#define ANEG_CFG_FD 0x00002000
  34303. +#define ANEG_CFG_INVAL 0x00001f06
  34304. +
  34305. +};
  34306. +#define ANEG_OK 0
  34307. +#define ANEG_DONE 1
  34308. +#define ANEG_TIMER_ENAB 2
  34309. +#define ANEG_FAILED -1
  34310. +
  34311. +#define ANEG_STATE_SETTLE_TIME 10000
  34312. +
  34313. +static int tg3_fiber_aneg_smachine(struct tg3 *tp,
  34314. + struct tg3_fiber_aneginfo *ap)
  34315. +{
  34316. + unsigned long delta;
  34317. + uint32_t rx_cfg_reg;
  34318. + int ret;
  34319. +
  34320. + if (ap->state == ANEG_STATE_UNKNOWN) {
  34321. + ap->rxconfig = 0;
  34322. + ap->link_time = 0;
  34323. + ap->cur_time = 0;
  34324. + ap->ability_match_cfg = 0;
  34325. + ap->ability_match_count = 0;
  34326. + ap->ability_match = 0;
  34327. + ap->idle_match = 0;
  34328. + ap->ack_match = 0;
  34329. + }
  34330. + ap->cur_time++;
  34331. +
  34332. + if (tr32(MAC_STATUS) & MAC_STATUS_RCVD_CFG) {
  34333. + rx_cfg_reg = tr32(MAC_RX_AUTO_NEG);
  34334. +
  34335. + if (rx_cfg_reg != ap->ability_match_cfg) {
  34336. + ap->ability_match_cfg = rx_cfg_reg;
  34337. + ap->ability_match = 0;
  34338. + ap->ability_match_count = 0;
  34339. + } else {
  34340. + if (++ap->ability_match_count > 1) {
  34341. + ap->ability_match = 1;
  34342. + ap->ability_match_cfg = rx_cfg_reg;
  34343. + }
  34344. + }
  34345. + if (rx_cfg_reg & ANEG_CFG_ACK)
  34346. + ap->ack_match = 1;
  34347. + else
  34348. + ap->ack_match = 0;
  34349. +
  34350. + ap->idle_match = 0;
  34351. + } else {
  34352. + ap->idle_match = 1;
  34353. + ap->ability_match_cfg = 0;
  34354. + ap->ability_match_count = 0;
  34355. + ap->ability_match = 0;
  34356. + ap->ack_match = 0;
  34357. +
  34358. + rx_cfg_reg = 0;
  34359. + }
  34360. +
  34361. + ap->rxconfig = rx_cfg_reg;
  34362. + ret = ANEG_OK;
  34363. +
  34364. + switch(ap->state) {
  34365. + case ANEG_STATE_UNKNOWN:
  34366. + if (ap->flags & (MR_AN_ENABLE | MR_RESTART_AN))
  34367. + ap->state = ANEG_STATE_AN_ENABLE;
  34368. +
  34369. + /* fallthru */
  34370. + case ANEG_STATE_AN_ENABLE:
  34371. + ap->flags &= ~(MR_AN_COMPLETE | MR_PAGE_RX);
  34372. + if (ap->flags & MR_AN_ENABLE) {
  34373. + ap->link_time = 0;
  34374. + ap->cur_time = 0;
  34375. + ap->ability_match_cfg = 0;
  34376. + ap->ability_match_count = 0;
  34377. + ap->ability_match = 0;
  34378. + ap->idle_match = 0;
  34379. + ap->ack_match = 0;
  34380. +
  34381. + ap->state = ANEG_STATE_RESTART_INIT;
  34382. + } else {
  34383. + ap->state = ANEG_STATE_DISABLE_LINK_OK;
  34384. + }
  34385. + break;
  34386. +
  34387. + case ANEG_STATE_RESTART_INIT:
  34388. + ap->link_time = ap->cur_time;
  34389. + ap->flags &= ~(MR_NP_LOADED);
  34390. + ap->txconfig = 0;
  34391. + tw32(MAC_TX_AUTO_NEG, 0);
  34392. + tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
  34393. + tw32_carefully(MAC_MODE, tp->mac_mode);
  34394. +
  34395. + ret = ANEG_TIMER_ENAB;
  34396. + ap->state = ANEG_STATE_RESTART;
  34397. +
  34398. + /* fallthru */
  34399. + case ANEG_STATE_RESTART:
  34400. + delta = ap->cur_time - ap->link_time;
  34401. + if (delta > ANEG_STATE_SETTLE_TIME) {
  34402. + ap->state = ANEG_STATE_ABILITY_DETECT_INIT;
  34403. + } else {
  34404. + ret = ANEG_TIMER_ENAB;
  34405. + }
  34406. + break;
  34407. +
  34408. + case ANEG_STATE_DISABLE_LINK_OK:
  34409. + ret = ANEG_DONE;
  34410. + break;
  34411. +
  34412. + case ANEG_STATE_ABILITY_DETECT_INIT:
  34413. + ap->flags &= ~(MR_TOGGLE_TX);
  34414. + ap->txconfig = (ANEG_CFG_FD | ANEG_CFG_PS1);
  34415. + tw32(MAC_TX_AUTO_NEG, ap->txconfig);
  34416. + tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
  34417. + tw32_carefully(MAC_MODE, tp->mac_mode);
  34418. +
  34419. + ap->state = ANEG_STATE_ABILITY_DETECT;
  34420. + break;
  34421. +
  34422. + case ANEG_STATE_ABILITY_DETECT:
  34423. + if (ap->ability_match != 0 && ap->rxconfig != 0) {
  34424. + ap->state = ANEG_STATE_ACK_DETECT_INIT;
  34425. + }
  34426. + break;
  34427. +
  34428. + case ANEG_STATE_ACK_DETECT_INIT:
  34429. + ap->txconfig |= ANEG_CFG_ACK;
  34430. + tw32(MAC_TX_AUTO_NEG, ap->txconfig);
  34431. + tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
  34432. + tw32_carefully(MAC_MODE, tp->mac_mode);
  34433. +
  34434. + ap->state = ANEG_STATE_ACK_DETECT;
  34435. +
  34436. + /* fallthru */
  34437. + case ANEG_STATE_ACK_DETECT:
  34438. + if (ap->ack_match != 0) {
  34439. + if ((ap->rxconfig & ~ANEG_CFG_ACK) ==
  34440. + (ap->ability_match_cfg & ~ANEG_CFG_ACK)) {
  34441. + ap->state = ANEG_STATE_COMPLETE_ACK_INIT;
  34442. + } else {
  34443. + ap->state = ANEG_STATE_AN_ENABLE;
  34444. + }
  34445. + } else if (ap->ability_match != 0 &&
  34446. + ap->rxconfig == 0) {
  34447. + ap->state = ANEG_STATE_AN_ENABLE;
  34448. + }
  34449. + break;
  34450. +
  34451. + case ANEG_STATE_COMPLETE_ACK_INIT:
  34452. + if (ap->rxconfig & ANEG_CFG_INVAL) {
  34453. + ret = ANEG_FAILED;
  34454. + break;
  34455. + }
  34456. + ap->flags &= ~(MR_LP_ADV_FULL_DUPLEX |
  34457. + MR_LP_ADV_HALF_DUPLEX |
  34458. + MR_LP_ADV_SYM_PAUSE |
  34459. + MR_LP_ADV_ASYM_PAUSE |
  34460. + MR_LP_ADV_REMOTE_FAULT1 |
  34461. + MR_LP_ADV_REMOTE_FAULT2 |
  34462. + MR_LP_ADV_NEXT_PAGE |
  34463. + MR_TOGGLE_RX |
  34464. + MR_NP_RX);
  34465. + if (ap->rxconfig & ANEG_CFG_FD)
  34466. + ap->flags |= MR_LP_ADV_FULL_DUPLEX;
  34467. + if (ap->rxconfig & ANEG_CFG_HD)
  34468. + ap->flags |= MR_LP_ADV_HALF_DUPLEX;
  34469. + if (ap->rxconfig & ANEG_CFG_PS1)
  34470. + ap->flags |= MR_LP_ADV_SYM_PAUSE;
  34471. + if (ap->rxconfig & ANEG_CFG_PS2)
  34472. + ap->flags |= MR_LP_ADV_ASYM_PAUSE;
  34473. + if (ap->rxconfig & ANEG_CFG_RF1)
  34474. + ap->flags |= MR_LP_ADV_REMOTE_FAULT1;
  34475. + if (ap->rxconfig & ANEG_CFG_RF2)
  34476. + ap->flags |= MR_LP_ADV_REMOTE_FAULT2;
  34477. + if (ap->rxconfig & ANEG_CFG_NP)
  34478. + ap->flags |= MR_LP_ADV_NEXT_PAGE;
  34479. +
  34480. + ap->link_time = ap->cur_time;
  34481. +
  34482. + ap->flags ^= (MR_TOGGLE_TX);
  34483. + if (ap->rxconfig & 0x0008)
  34484. + ap->flags |= MR_TOGGLE_RX;
  34485. + if (ap->rxconfig & ANEG_CFG_NP)
  34486. + ap->flags |= MR_NP_RX;
  34487. + ap->flags |= MR_PAGE_RX;
  34488. +
  34489. + ap->state = ANEG_STATE_COMPLETE_ACK;
  34490. + ret = ANEG_TIMER_ENAB;
  34491. + break;
  34492. +
  34493. + case ANEG_STATE_COMPLETE_ACK:
  34494. + if (ap->ability_match != 0 &&
  34495. + ap->rxconfig == 0) {
  34496. + ap->state = ANEG_STATE_AN_ENABLE;
  34497. + break;
  34498. + }
  34499. + delta = ap->cur_time - ap->link_time;
  34500. + if (delta > ANEG_STATE_SETTLE_TIME) {
  34501. + if (!(ap->flags & (MR_LP_ADV_NEXT_PAGE))) {
  34502. + ap->state = ANEG_STATE_IDLE_DETECT_INIT;
  34503. + } else {
  34504. + if ((ap->txconfig & ANEG_CFG_NP) == 0 &&
  34505. + !(ap->flags & MR_NP_RX)) {
  34506. + ap->state = ANEG_STATE_IDLE_DETECT_INIT;
  34507. + } else {
  34508. + ret = ANEG_FAILED;
  34509. + }
  34510. + }
  34511. + }
  34512. + break;
  34513. +
  34514. + case ANEG_STATE_IDLE_DETECT_INIT:
  34515. + ap->link_time = ap->cur_time;
  34516. + tp->mac_mode &= ~MAC_MODE_SEND_CONFIGS;
  34517. + tw32_carefully(MAC_MODE, tp->mac_mode);
  34518. +
  34519. + ap->state = ANEG_STATE_IDLE_DETECT;
  34520. + ret = ANEG_TIMER_ENAB;
  34521. + break;
  34522. +
  34523. + case ANEG_STATE_IDLE_DETECT:
  34524. + if (ap->ability_match != 0 &&
  34525. + ap->rxconfig == 0) {
  34526. + ap->state = ANEG_STATE_AN_ENABLE;
  34527. + break;
  34528. + }
  34529. + delta = ap->cur_time - ap->link_time;
  34530. + if (delta > ANEG_STATE_SETTLE_TIME) {
  34531. + /* XXX another gem from the Broadcom driver :( */
  34532. + ap->state = ANEG_STATE_LINK_OK;
  34533. + }
  34534. + break;
  34535. +
  34536. + case ANEG_STATE_LINK_OK:
  34537. + ap->flags |= (MR_AN_COMPLETE | MR_LINK_OK);
  34538. + ret = ANEG_DONE;
  34539. + break;
  34540. +
  34541. + case ANEG_STATE_NEXT_PAGE_WAIT_INIT:
  34542. + /* ??? unimplemented */
  34543. + break;
  34544. +
  34545. + case ANEG_STATE_NEXT_PAGE_WAIT:
  34546. + /* ??? unimplemented */
  34547. + break;
  34548. +
  34549. + default:
  34550. + ret = ANEG_FAILED;
  34551. + break;
  34552. + };
  34553. +
  34554. + return ret;
  34555. +}
  34556. +
  34557. +static int tg3_setup_fiber_phy(struct tg3 *tp)
  34558. +{
  34559. + uint32_t orig_pause_cfg;
  34560. + uint16_t orig_active_speed;
  34561. + uint8_t orig_active_duplex;
  34562. + int current_link_up;
  34563. + int i;
  34564. +
  34565. + orig_pause_cfg =
  34566. + (tp->tg3_flags & (TG3_FLAG_RX_PAUSE |
  34567. + TG3_FLAG_TX_PAUSE));
  34568. + orig_active_speed = tp->link_config.active_speed;
  34569. + orig_active_duplex = tp->link_config.active_duplex;
  34570. +
  34571. + tp->mac_mode &= ~(MAC_MODE_PORT_MODE_MASK | MAC_MODE_HALF_DUPLEX);
  34572. + tp->mac_mode |= MAC_MODE_PORT_MODE_TBI;
  34573. + tw32_carefully(MAC_MODE, tp->mac_mode);
  34574. +
  34575. + /* Reset when initting first time or we have a link. */
  34576. + if (!(tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) ||
  34577. + (tr32(MAC_STATUS) & MAC_STATUS_PCS_SYNCED)) {
  34578. + /* Set PLL lock range. */
  34579. + tg3_writephy(tp, 0x16, 0x8007);
  34580. +
  34581. + /* SW reset */
  34582. + tg3_writephy(tp, MII_BMCR, BMCR_RESET);
  34583. +
  34584. + /* Wait for reset to complete. */
  34585. + mdelay(5);
  34586. +
  34587. + /* Config mode; select PMA/Ch 1 regs. */
  34588. + tg3_writephy(tp, 0x10, 0x8411);
  34589. +
  34590. + /* Enable auto-lock and comdet, select txclk for tx. */
  34591. + tg3_writephy(tp, 0x11, 0x0a10);
  34592. +
  34593. + tg3_writephy(tp, 0x18, 0x00a0);
  34594. + tg3_writephy(tp, 0x16, 0x41ff);
  34595. +
  34596. + /* Assert and deassert POR. */
  34597. + tg3_writephy(tp, 0x13, 0x0400);
  34598. + udelay(40);
  34599. + tg3_writephy(tp, 0x13, 0x0000);
  34600. +
  34601. + tg3_writephy(tp, 0x11, 0x0a50);
  34602. + udelay(40);
  34603. + tg3_writephy(tp, 0x11, 0x0a10);
  34604. +
  34605. + /* Wait for signal to stabilize */
  34606. + mdelay(150);
  34607. +
  34608. + /* Deselect the channel register so we can read the PHYID
  34609. + * later.
  34610. + */
  34611. + tg3_writephy(tp, 0x10, 0x8011);
  34612. + }
  34613. +
  34614. + /* Disable link change interrupt. */
  34615. + tw32_carefully(MAC_EVENT, 0);
  34616. +
  34617. + current_link_up = 0;
  34618. + if (tr32(MAC_STATUS) & MAC_STATUS_PCS_SYNCED) {
  34619. + if (!(tp->tg3_flags & TG3_FLAG_GOT_SERDES_FLOWCTL)) {
  34620. + struct tg3_fiber_aneginfo aninfo;
  34621. + int status = ANEG_FAILED;
  34622. + unsigned int tick;
  34623. + uint32_t tmp;
  34624. +
  34625. + memset(&aninfo, 0, sizeof(aninfo));
  34626. + aninfo.flags |= (MR_AN_ENABLE);
  34627. +
  34628. + tw32(MAC_TX_AUTO_NEG, 0);
  34629. +
  34630. + tmp = tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK;
  34631. + tw32_carefully(MAC_MODE, tmp | MAC_MODE_PORT_MODE_GMII);
  34632. +
  34633. + tw32_carefully(MAC_MODE, tp->mac_mode | MAC_MODE_SEND_CONFIGS);
  34634. +
  34635. + aninfo.state = ANEG_STATE_UNKNOWN;
  34636. + aninfo.cur_time = 0;
  34637. + tick = 0;
  34638. + while (++tick < 195000) {
  34639. + status = tg3_fiber_aneg_smachine(tp, &aninfo);
  34640. + if (status == ANEG_DONE ||
  34641. + status == ANEG_FAILED)
  34642. + break;
  34643. +
  34644. + udelay(1);
  34645. + }
  34646. +
  34647. + tp->mac_mode &= ~MAC_MODE_SEND_CONFIGS;
  34648. + tw32_carefully(MAC_MODE, tp->mac_mode);
  34649. +
  34650. + if (status == ANEG_DONE &&
  34651. + (aninfo.flags &
  34652. + (MR_AN_COMPLETE | MR_LINK_OK |
  34653. + MR_LP_ADV_FULL_DUPLEX))) {
  34654. + uint32_t local_adv, remote_adv;
  34655. +
  34656. + local_adv = ADVERTISE_PAUSE_CAP;
  34657. + remote_adv = 0;
  34658. + if (aninfo.flags & MR_LP_ADV_SYM_PAUSE)
  34659. + remote_adv |= LPA_PAUSE_CAP;
  34660. + if (aninfo.flags & MR_LP_ADV_ASYM_PAUSE)
  34661. + remote_adv |= LPA_PAUSE_ASYM;
  34662. +
  34663. + tg3_setup_flow_control(tp, local_adv, remote_adv);
  34664. +
  34665. + tp->tg3_flags |=
  34666. + TG3_FLAG_GOT_SERDES_FLOWCTL;
  34667. + current_link_up = 1;
  34668. + }
  34669. + for (i = 0; i < 60; i++) {
  34670. + udelay(20);
  34671. + tw32_carefully(MAC_STATUS,
  34672. + (MAC_STATUS_SYNC_CHANGED | MAC_STATUS_CFG_CHANGED));
  34673. + if ((tr32(MAC_STATUS) &
  34674. + (MAC_STATUS_SYNC_CHANGED |
  34675. + MAC_STATUS_CFG_CHANGED)) == 0)
  34676. + break;
  34677. + }
  34678. + if (current_link_up == 0 &&
  34679. + (tr32(MAC_STATUS) & MAC_STATUS_PCS_SYNCED)) {
  34680. + current_link_up = 1;
  34681. + }
  34682. + } else {
  34683. + /* Forcing 1000FD link up. */
  34684. + current_link_up = 1;
  34685. + }
  34686. + }
  34687. +
  34688. + tp->mac_mode &= ~MAC_MODE_LINK_POLARITY;
  34689. + tw32_carefully(MAC_MODE, tp->mac_mode);
  34690. +
  34691. + tp->hw_status->status =
  34692. + (SD_STATUS_UPDATED |
  34693. + (tp->hw_status->status & ~SD_STATUS_LINK_CHG));
  34694. +
  34695. + for (i = 0; i < 100; i++) {
  34696. + udelay(20);
  34697. + tw32_carefully(MAC_STATUS,
  34698. + (MAC_STATUS_SYNC_CHANGED | MAC_STATUS_CFG_CHANGED));
  34699. + if ((tr32(MAC_STATUS) &
  34700. + (MAC_STATUS_SYNC_CHANGED |
  34701. + MAC_STATUS_CFG_CHANGED)) == 0)
  34702. + break;
  34703. + }
  34704. +
  34705. + if ((tr32(MAC_STATUS) & MAC_STATUS_PCS_SYNCED) == 0)
  34706. + current_link_up = 0;
  34707. +
  34708. + if (current_link_up == 1) {
  34709. + tp->link_config.active_speed = SPEED_1000;
  34710. + tp->link_config.active_duplex = DUPLEX_FULL;
  34711. + } else {
  34712. + tp->link_config.active_speed = SPEED_INVALID;
  34713. + tp->link_config.active_duplex = DUPLEX_INVALID;
  34714. + }
  34715. +
  34716. + if (current_link_up != tp->carrier_ok) {
  34717. + tp->carrier_ok = current_link_up;
  34718. + tg3_link_report(tp);
  34719. + } else {
  34720. + uint32_t now_pause_cfg =
  34721. + tp->tg3_flags & (TG3_FLAG_RX_PAUSE |
  34722. + TG3_FLAG_TX_PAUSE);
  34723. + if (orig_pause_cfg != now_pause_cfg ||
  34724. + orig_active_speed != tp->link_config.active_speed ||
  34725. + orig_active_duplex != tp->link_config.active_duplex)
  34726. + tg3_link_report(tp);
  34727. + }
  34728. +
  34729. + if ((tr32(MAC_STATUS) & MAC_STATUS_PCS_SYNCED) == 0) {
  34730. + tw32_carefully(MAC_MODE, tp->mac_mode | MAC_MODE_LINK_POLARITY);
  34731. + if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) {
  34732. + tw32_carefully(MAC_MODE, tp->mac_mode);
  34733. + }
  34734. + }
  34735. +
  34736. + return 0;
  34737. +}
  34738. +#else
  34739. +#define tg3_setup_fiber_phy(TP) (-EINVAL)
  34740. +#endif /* SUPPORT_FIBER_PHY */
  34741. +
  34742. +static int tg3_setup_phy(struct tg3 *tp)
  34743. +{
  34744. + int err;
  34745. +
  34746. + if (tp->phy_id == PHY_ID_SERDES) {
  34747. + err = tg3_setup_fiber_phy(tp);
  34748. + } else {
  34749. + err = tg3_setup_copper_phy(tp);
  34750. + }
  34751. +
  34752. + if (tp->link_config.active_speed == SPEED_1000 &&
  34753. + tp->link_config.active_duplex == DUPLEX_HALF)
  34754. + tw32(MAC_TX_LENGTHS,
  34755. + ((2 << TX_LENGTHS_IPG_CRS_SHIFT) |
  34756. + (6 << TX_LENGTHS_IPG_SHIFT) |
  34757. + (0xff << TX_LENGTHS_SLOT_TIME_SHIFT)));
  34758. + else
  34759. + tw32(MAC_TX_LENGTHS,
  34760. + ((2 << TX_LENGTHS_IPG_CRS_SHIFT) |
  34761. + (6 << TX_LENGTHS_IPG_SHIFT) |
  34762. + (32 << TX_LENGTHS_SLOT_TIME_SHIFT)));
  34763. +
  34764. + return err;
  34765. +}
  34766. +
  34767. +
  34768. +#define MAX_WAIT_CNT 1000
  34769. +
  34770. +/* To stop a block, clear the enable bit and poll till it
  34771. + * clears.
  34772. + */
  34773. +static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, uint32_t enable_bit)
  34774. +{
  34775. + unsigned int i;
  34776. + uint32_t val;
  34777. +
  34778. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
  34779. + switch(ofs) {
  34780. + case RCVLSC_MODE:
  34781. + case DMAC_MODE:
  34782. + case MBFREE_MODE:
  34783. + case BUFMGR_MODE:
  34784. + case MEMARB_MODE:
  34785. + /* We can't enable/disable these bits of the
  34786. + * 5705, just say success.
  34787. + */
  34788. + return 0;
  34789. + default:
  34790. + break;
  34791. + }
  34792. + }
  34793. + val = tr32(ofs);
  34794. + val &= ~enable_bit;
  34795. + tw32(ofs, val);
  34796. + tr32(ofs);
  34797. +
  34798. + for (i = 0; i < MAX_WAIT_CNT; i++) {
  34799. + udelay(100);
  34800. + val = tr32(ofs);
  34801. + if ((val & enable_bit) == 0)
  34802. + break;
  34803. + }
  34804. +
  34805. + if (i == MAX_WAIT_CNT) {
  34806. + printf("tg3_stop_block timed out, ofs=%lx enable_bit=%x\n",
  34807. + ofs, enable_bit);
  34808. + return -ENODEV;
  34809. + }
  34810. +
  34811. + return 0;
  34812. +}
  34813. +
  34814. +static int tg3_abort_hw(struct tg3 *tp)
  34815. +{
  34816. + int i, err;
  34817. +
  34818. + tg3_disable_ints(tp);
  34819. +
  34820. + tp->rx_mode &= ~RX_MODE_ENABLE;
  34821. + tw32_carefully(MAC_RX_MODE, tp->rx_mode);
  34822. +
  34823. + err = tg3_stop_block(tp, RCVBDI_MODE, RCVBDI_MODE_ENABLE);
  34824. + err |= tg3_stop_block(tp, RCVLPC_MODE, RCVLPC_MODE_ENABLE);
  34825. + err |= tg3_stop_block(tp, RCVLSC_MODE, RCVLSC_MODE_ENABLE);
  34826. + err |= tg3_stop_block(tp, RCVDBDI_MODE, RCVDBDI_MODE_ENABLE);
  34827. + err |= tg3_stop_block(tp, RCVDCC_MODE, RCVDCC_MODE_ENABLE);
  34828. + err |= tg3_stop_block(tp, RCVCC_MODE, RCVCC_MODE_ENABLE);
  34829. +
  34830. + err |= tg3_stop_block(tp, SNDBDS_MODE, SNDBDS_MODE_ENABLE);
  34831. + err |= tg3_stop_block(tp, SNDBDI_MODE, SNDBDI_MODE_ENABLE);
  34832. + err |= tg3_stop_block(tp, SNDDATAI_MODE, SNDDATAI_MODE_ENABLE);
  34833. + err |= tg3_stop_block(tp, RDMAC_MODE, RDMAC_MODE_ENABLE);
  34834. + err |= tg3_stop_block(tp, SNDDATAC_MODE, SNDDATAC_MODE_ENABLE);
  34835. + err |= tg3_stop_block(tp, SNDBDC_MODE, SNDBDC_MODE_ENABLE);
  34836. + if (err)
  34837. + goto out;
  34838. +
  34839. + tp->mac_mode &= ~MAC_MODE_TDE_ENABLE;
  34840. + tw32_carefully(MAC_MODE, tp->mac_mode);
  34841. +
  34842. + tp->tx_mode &= ~TX_MODE_ENABLE;
  34843. + tw32_carefully(MAC_TX_MODE, tp->tx_mode);
  34844. +
  34845. + for (i = 0; i < MAX_WAIT_CNT; i++) {
  34846. + udelay(100);
  34847. + if (!(tr32(MAC_TX_MODE) & TX_MODE_ENABLE))
  34848. + break;
  34849. + }
  34850. + if (i >= MAX_WAIT_CNT) {
  34851. + printf("tg3_abort_hw timed out TX_MODE_ENABLE will not clear MAC_TX_MODE=%x\n",
  34852. + tr32(MAC_TX_MODE));
  34853. + return -ENODEV;
  34854. + }
  34855. +
  34856. + err = tg3_stop_block(tp, HOSTCC_MODE, HOSTCC_MODE_ENABLE);
  34857. + err |= tg3_stop_block(tp, WDMAC_MODE, WDMAC_MODE_ENABLE);
  34858. + err |= tg3_stop_block(tp, MBFREE_MODE, MBFREE_MODE_ENABLE);
  34859. +
  34860. + tw32(FTQ_RESET, 0xffffffff);
  34861. + tw32(FTQ_RESET, 0x00000000);
  34862. +
  34863. + err |= tg3_stop_block(tp, BUFMGR_MODE, BUFMGR_MODE_ENABLE);
  34864. + err |= tg3_stop_block(tp, MEMARB_MODE, MEMARB_MODE_ENABLE);
  34865. + if (err)
  34866. + goto out;
  34867. +
  34868. + memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE);
  34869. +
  34870. +out:
  34871. + return err;
  34872. +}
  34873. +
  34874. +static void tg3_chip_reset(struct tg3 *tp)
  34875. +{
  34876. + uint32_t val;
  34877. +
  34878. + if (!(tp->tg3_flags2 & TG3_FLG2_SUN_5704)) {
  34879. + /* Force NVRAM to settle.
  34880. + * This deals with a chip bug which can result in EEPROM
  34881. + * corruption.
  34882. + */
  34883. + if (tp->tg3_flags & TG3_FLAG_NVRAM) {
  34884. + int i;
  34885. +
  34886. + tw32(NVRAM_SWARB, SWARB_REQ_SET1);
  34887. + for (i = 0; i < 100000; i++) {
  34888. + if (tr32(NVRAM_SWARB) & SWARB_GNT1)
  34889. + break;
  34890. + udelay(10);
  34891. + }
  34892. + }
  34893. + }
  34894. + /* In Etherboot we don't need to worry about the 5701
  34895. + * REG_WRITE_BUG because we do all register writes indirectly.
  34896. + */
  34897. +
  34898. + /* do the reset */
  34899. + val = GRC_MISC_CFG_CORECLK_RESET;
  34900. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
  34901. + val |= GRC_MISC_CFG_KEEP_GPHY_POWER;
  34902. + tw32(GRC_MISC_CFG, val);
  34903. +
  34904. + /* Flush PCI posted writes. The normal MMIO registers
  34905. + * are inaccessible at this time so this is the only
  34906. + * way to make this reliably. I tried to use indirect
  34907. + * register read/write but this upset some 5701 variants.
  34908. + */
  34909. + pci_read_config_dword(tp->pdev, PCI_COMMAND, &val);
  34910. +
  34911. + udelay(120);
  34912. +
  34913. + /* Re-enable indirect register accesses. */
  34914. + pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
  34915. + tp->misc_host_ctrl);
  34916. +
  34917. + /* Set MAX PCI retry to zero. */
  34918. + val = (PCISTATE_ROM_ENABLE | PCISTATE_ROM_RETRY_ENABLE);
  34919. + if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0 &&
  34920. + (tp->tg3_flags & TG3_FLAG_PCIX_MODE))
  34921. + val |= PCISTATE_RETRY_SAME_DMA;
  34922. + pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, val);
  34923. +
  34924. + pci_restore_state(tp->pdev, tp->pci_cfg_state);
  34925. +
  34926. + /* Make sure PCI-X relaxed ordering bit is clear. */
  34927. + pci_read_config_dword(tp->pdev, TG3PCI_X_CAPS, &val);
  34928. + val &= ~PCIX_CAPS_RELAXED_ORDERING;
  34929. + pci_write_config_dword(tp->pdev, TG3PCI_X_CAPS, val);
  34930. +
  34931. + tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
  34932. +
  34933. + if (((tp->nic_sram_data_cfg & NIC_SRAM_DATA_CFG_MINI_PCI) != 0) &&
  34934. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) {
  34935. + tp->pci_clock_ctrl |=
  34936. + (CLOCK_CTRL_FORCE_CLKRUN | CLOCK_CTRL_CLKRUN_OENABLE);
  34937. + tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
  34938. + }
  34939. +
  34940. + tw32(TG3PCI_MISC_HOST_CTRL, tp->misc_host_ctrl);
  34941. +}
  34942. +
  34943. +static void tg3_stop_fw(struct tg3 *tp)
  34944. +{
  34945. + if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) {
  34946. + uint32_t val;
  34947. + int i;
  34948. +
  34949. + tg3_write_mem(NIC_SRAM_FW_CMD_MBOX, FWCMD_NICDRV_PAUSE_FW);
  34950. + val = tr32(GRC_RX_CPU_EVENT);
  34951. + val |= (1 << 14);
  34952. + tw32(GRC_RX_CPU_EVENT, val);
  34953. +
  34954. + /* Wait for RX cpu to ACK the event. */
  34955. + for (i = 0; i < 100; i++) {
  34956. + if (!(tr32(GRC_RX_CPU_EVENT) & (1 << 14)))
  34957. + break;
  34958. + udelay(1);
  34959. + }
  34960. + }
  34961. +}
  34962. +
  34963. +static int tg3_restart_fw(struct tg3 *tp, uint32_t state)
  34964. +{
  34965. + uint32_t val;
  34966. + int i;
  34967. +
  34968. + tg3_write_mem(NIC_SRAM_FIRMWARE_MBOX,
  34969. + NIC_SRAM_FIRMWARE_MBOX_MAGIC1);
  34970. + /* Wait for firmware initialization to complete. */
  34971. + for (i = 0; i < 100000; i++) {
  34972. + tg3_read_mem(NIC_SRAM_FIRMWARE_MBOX, &val);
  34973. + if (val == (uint32_t) ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
  34974. + break;
  34975. + udelay(10);
  34976. + }
  34977. + if (i >= 100000 &&
  34978. + !(tp->tg3_flags2 & TG3_FLG2_SUN_5704)) {
  34979. + printf("Firmware will not restart magic=%x\n",
  34980. + val);
  34981. + return -ENODEV;
  34982. + }
  34983. + if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
  34984. + state = DRV_STATE_SUSPEND;
  34985. + }
  34986. + tg3_write_mem(NIC_SRAM_FW_DRV_STATE_MBOX, state);
  34987. + return 0;
  34988. +}
  34989. +
  34990. +static int tg3_halt(struct tg3 *tp)
  34991. +{
  34992. + tg3_stop_fw(tp);
  34993. + tg3_abort_hw(tp);
  34994. + tg3_chip_reset(tp);
  34995. + return tg3_restart_fw(tp, DRV_STATE_UNLOAD);
  34996. +}
  34997. +
  34998. +static void __tg3_set_mac_addr(struct tg3 *tp)
  34999. +{
  35000. + uint32_t addr_high, addr_low;
  35001. + int i;
  35002. +
  35003. + addr_high = ((tp->nic->node_addr[0] << 8) |
  35004. + tp->nic->node_addr[1]);
  35005. + addr_low = ((tp->nic->node_addr[2] << 24) |
  35006. + (tp->nic->node_addr[3] << 16) |
  35007. + (tp->nic->node_addr[4] << 8) |
  35008. + (tp->nic->node_addr[5] << 0));
  35009. + for (i = 0; i < 4; i++) {
  35010. + tw32(MAC_ADDR_0_HIGH + (i * 8), addr_high);
  35011. + tw32(MAC_ADDR_0_LOW + (i * 8), addr_low);
  35012. + }
  35013. +
  35014. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700) &&
  35015. + (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) &&
  35016. + (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)) {
  35017. + for(i = 0; i < 12; i++) {
  35018. + tw32(MAC_EXTADDR_0_HIGH + (i * 8), addr_high);
  35019. + tw32(MAC_EXTADDR_0_LOW + (i * 8), addr_low);
  35020. + }
  35021. + }
  35022. + addr_high = (tp->nic->node_addr[0] +
  35023. + tp->nic->node_addr[1] +
  35024. + tp->nic->node_addr[2] +
  35025. + tp->nic->node_addr[3] +
  35026. + tp->nic->node_addr[4] +
  35027. + tp->nic->node_addr[5]) &
  35028. + TX_BACKOFF_SEED_MASK;
  35029. + tw32(MAC_TX_BACKOFF_SEED, addr_high);
  35030. +}
  35031. +
  35032. +static void tg3_set_bdinfo(struct tg3 *tp, uint32_t bdinfo_addr,
  35033. + dma_addr_t mapping, uint32_t maxlen_flags,
  35034. + uint32_t nic_addr)
  35035. +{
  35036. + tg3_write_mem((bdinfo_addr +
  35037. + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH),
  35038. + ((uint64_t) mapping >> 32));
  35039. + tg3_write_mem((bdinfo_addr +
  35040. + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW),
  35041. + ((uint64_t) mapping & 0xffffffff));
  35042. + tg3_write_mem((bdinfo_addr +
  35043. + TG3_BDINFO_MAXLEN_FLAGS),
  35044. + maxlen_flags);
  35045. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  35046. + tg3_write_mem((bdinfo_addr + TG3_BDINFO_NIC_ADDR), nic_addr);
  35047. + }
  35048. +}
  35049. +
  35050. +
  35051. +static void tg3_init_rings(struct tg3 *tp)
  35052. +{
  35053. + unsigned i;
  35054. +
  35055. + /* Zero out the tg3 variables */
  35056. + memset(&tg3_bss, 0, sizeof(tg3_bss));
  35057. + tp->rx_std = &tg3_bss.rx_std[0];
  35058. + tp->rx_rcb = &tg3_bss.rx_rcb[0];
  35059. + tp->tx_ring = &tg3_bss.tx_ring[0];
  35060. + tp->hw_status = &tg3_bss.hw_status;
  35061. + tp->hw_stats = &tg3_bss.hw_stats;
  35062. + tp->mac_mode = 0;
  35063. +
  35064. +
  35065. + /* Initialize tx/rx rings for packet processing.
  35066. + *
  35067. + * The chip has been shut down and the driver detached from
  35068. + * the networking, so no interrupts or new tx packets will
  35069. + * end up in the driver.
  35070. + */
  35071. +
  35072. + /* Initialize invariants of the rings, we only set this
  35073. + * stuff once. This works because the card does not
  35074. + * write into the rx buffer posting rings.
  35075. + */
  35076. + for (i = 0; i < TG3_RX_RING_SIZE; i++) {
  35077. + struct tg3_rx_buffer_desc *rxd;
  35078. +
  35079. + rxd = &tp->rx_std[i];
  35080. + rxd->idx_len = (RX_PKT_BUF_SZ - 2 - 64) << RXD_LEN_SHIFT;
  35081. + rxd->type_flags = (RXD_FLAG_END << RXD_FLAGS_SHIFT);
  35082. + rxd->opaque = (RXD_OPAQUE_RING_STD | (i << RXD_OPAQUE_INDEX_SHIFT));
  35083. +
  35084. + /* Note where the receive buffer for the ring is placed */
  35085. + rxd->addr_hi = 0;
  35086. + rxd->addr_lo = virt_to_bus(
  35087. + &tg3_bss.rx_bufs[i%TG3_DEF_RX_RING_PENDING][2]);
  35088. + }
  35089. +}
  35090. +
  35091. +#define TG3_WRITE_SETTINGS(TABLE) \
  35092. +do { \
  35093. + const uint32_t *_table, *_end; \
  35094. + _table = TABLE; \
  35095. + _end = _table + sizeof(TABLE)/sizeof(TABLE[0]); \
  35096. + for(; _table < _end; _table += 2) { \
  35097. + tw32(_table[0], _table[1]); \
  35098. + } \
  35099. +} while(0)
  35100. +
  35101. +
  35102. +/* initialize/reset the tg3 */
  35103. +static int tg3_setup_hw(struct tg3 *tp)
  35104. +{
  35105. + uint32_t val, rdmac_mode;
  35106. + int i, err, limit;
  35107. +
  35108. + /* Simply don't support setups with extremly buggy firmware in etherboot */
  35109. + if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0) {
  35110. + printf("Error 5701_A0 firmware bug detected\n");
  35111. + return -EINVAL;
  35112. + }
  35113. +
  35114. + tg3_disable_ints(tp);
  35115. +
  35116. + /* Originally this was all in tg3_init_hw */
  35117. +
  35118. + /* Force the chip into D0. */
  35119. + tg3_set_power_state_0(tp);
  35120. +
  35121. + tg3_switch_clocks(tp);
  35122. +
  35123. + tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0);
  35124. +
  35125. +
  35126. + /* Originally this was all in tg3_reset_hw */
  35127. +
  35128. + tg3_stop_fw(tp);
  35129. +
  35130. + /* No need to call tg3_abort_hw here, it is called before tg3_setup_hw. */
  35131. +
  35132. + tg3_chip_reset(tp);
  35133. +
  35134. + tw32(GRC_MODE, tp->grc_mode); /* Redundant? */
  35135. +
  35136. + err = tg3_restart_fw(tp, DRV_STATE_START);
  35137. + if (err)
  35138. + return err;
  35139. +
  35140. + if (tp->phy_id == PHY_ID_SERDES) {
  35141. + tp->mac_mode = MAC_MODE_PORT_MODE_TBI;
  35142. + }
  35143. + tw32_carefully(MAC_MODE, tp->mac_mode);
  35144. +
  35145. +
  35146. + /* This works around an issue with Athlon chipsets on
  35147. + * B3 tigon3 silicon. This bit has no effect on any
  35148. + * other revision.
  35149. + */
  35150. + tp->pci_clock_ctrl |= CLOCK_CTRL_DELAY_PCI_GRANT;
  35151. + tw32_carefully(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
  35152. +
  35153. + if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0 &&
  35154. + (tp->tg3_flags & TG3_FLAG_PCIX_MODE)) {
  35155. + val = tr32(TG3PCI_PCISTATE);
  35156. + val |= PCISTATE_RETRY_SAME_DMA;
  35157. + tw32(TG3PCI_PCISTATE, val);
  35158. + }
  35159. +
  35160. + /* Descriptor ring init may make accesses to the
  35161. + * NIC SRAM area to setup the TX descriptors, so we
  35162. + * can only do this after the hardware has been
  35163. + * successfully reset.
  35164. + */
  35165. + tg3_init_rings(tp);
  35166. +
  35167. + /* Clear statistics/status block in chip */
  35168. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  35169. + for (i = NIC_SRAM_STATS_BLK;
  35170. + i < NIC_SRAM_STATUS_BLK + TG3_HW_STATUS_SIZE;
  35171. + i += sizeof(uint32_t)) {
  35172. + tg3_write_mem(i, 0);
  35173. + udelay(40);
  35174. + }
  35175. + }
  35176. +
  35177. + /* This value is determined during the probe time DMA
  35178. + * engine test, tg3_setup_dma.
  35179. + */
  35180. + tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
  35181. +
  35182. + tp->grc_mode &= ~(GRC_MODE_HOST_SENDBDS |
  35183. + GRC_MODE_4X_NIC_SEND_RINGS |
  35184. + GRC_MODE_NO_TX_PHDR_CSUM |
  35185. + GRC_MODE_NO_RX_PHDR_CSUM);
  35186. + tp->grc_mode |= GRC_MODE_HOST_SENDBDS;
  35187. + tp->grc_mode |= GRC_MODE_NO_TX_PHDR_CSUM;
  35188. + tp->grc_mode |= GRC_MODE_NO_RX_PHDR_CSUM;
  35189. +
  35190. + tw32(GRC_MODE,
  35191. + tp->grc_mode |
  35192. + (GRC_MODE_IRQ_ON_MAC_ATTN | GRC_MODE_HOST_STACKUP));
  35193. +
  35194. + /* Setup the timer prescalar register. Clock is always 66Mhz. */
  35195. + tw32(GRC_MISC_CFG,
  35196. + (65 << GRC_MISC_CFG_PRESCALAR_SHIFT));
  35197. +
  35198. + /* Initialize MBUF/DESC pool. */
  35199. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  35200. + tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
  35201. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
  35202. + tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE64);
  35203. + else
  35204. + tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE96);
  35205. + tw32(BUFMGR_DMA_DESC_POOL_ADDR, NIC_SRAM_DMA_DESC_POOL_BASE);
  35206. + tw32(BUFMGR_DMA_DESC_POOL_SIZE, NIC_SRAM_DMA_DESC_POOL_SIZE);
  35207. + }
  35208. + if (!(tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE)) {
  35209. + tw32(BUFMGR_MB_RDMA_LOW_WATER,
  35210. + tp->bufmgr_config.mbuf_read_dma_low_water);
  35211. + tw32(BUFMGR_MB_MACRX_LOW_WATER,
  35212. + tp->bufmgr_config.mbuf_mac_rx_low_water);
  35213. + tw32(BUFMGR_MB_HIGH_WATER,
  35214. + tp->bufmgr_config.mbuf_high_water);
  35215. + } else {
  35216. + tw32(BUFMGR_MB_RDMA_LOW_WATER,
  35217. + tp->bufmgr_config.mbuf_read_dma_low_water_jumbo);
  35218. + tw32(BUFMGR_MB_MACRX_LOW_WATER,
  35219. + tp->bufmgr_config.mbuf_mac_rx_low_water_jumbo);
  35220. + tw32(BUFMGR_MB_HIGH_WATER,
  35221. + tp->bufmgr_config.mbuf_high_water_jumbo);
  35222. + }
  35223. + tw32(BUFMGR_DMA_LOW_WATER,
  35224. + tp->bufmgr_config.dma_low_water);
  35225. + tw32(BUFMGR_DMA_HIGH_WATER,
  35226. + tp->bufmgr_config.dma_high_water);
  35227. +
  35228. + tw32(BUFMGR_MODE, BUFMGR_MODE_ENABLE | BUFMGR_MODE_ATTN_ENABLE);
  35229. + for (i = 0; i < 2000; i++) {
  35230. + if (tr32(BUFMGR_MODE) & BUFMGR_MODE_ENABLE)
  35231. + break;
  35232. + udelay(10);
  35233. + }
  35234. + if (i >= 2000) {
  35235. + printf("tg3_setup_hw cannot enable BUFMGR\n");
  35236. + return -ENODEV;
  35237. + }
  35238. +
  35239. + tw32(FTQ_RESET, 0xffffffff);
  35240. + tw32(FTQ_RESET, 0x00000000);
  35241. + for (i = 0; i < 2000; i++) {
  35242. + if (tr32(FTQ_RESET) == 0x00000000)
  35243. + break;
  35244. + udelay(10);
  35245. + }
  35246. + if (i >= 2000) {
  35247. + printf("tg3_setup_hw cannot reset FTQ\n");
  35248. + return -ENODEV;
  35249. + }
  35250. +
  35251. + /* Initialize TG3_BDINFO's at:
  35252. + * RCVDBDI_STD_BD: standard eth size rx ring
  35253. + * RCVDBDI_JUMBO_BD: jumbo frame rx ring
  35254. + * RCVDBDI_MINI_BD: small frame rx ring (??? does not work)
  35255. + *
  35256. + * like so:
  35257. + * TG3_BDINFO_HOST_ADDR: high/low parts of DMA address of ring
  35258. + * TG3_BDINFO_MAXLEN_FLAGS: (rx max buffer size << 16) |
  35259. + * ring attribute flags
  35260. + * TG3_BDINFO_NIC_ADDR: location of descriptors in nic SRAM
  35261. + *
  35262. + * Standard receive ring @ NIC_SRAM_RX_BUFFER_DESC, 512 entries.
  35263. + * Jumbo receive ring @ NIC_SRAM_RX_JUMBO_BUFFER_DESC, 256 entries.
  35264. + *
  35265. + * ??? No space allocated for mini receive ring? :(
  35266. + *
  35267. + * The size of each ring is fixed in the firmware, but the location is
  35268. + * configurable.
  35269. + */
  35270. + {
  35271. + static const uint32_t table_all[] = {
  35272. + /* Setup replenish thresholds. */
  35273. + RCVBDI_STD_THRESH, TG3_DEF_RX_RING_PENDING / 8,
  35274. +
  35275. + /* Etherboot lives below 4GB */
  35276. + RCVDBDI_STD_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH, 0,
  35277. + RCVDBDI_STD_BD + TG3_BDINFO_NIC_ADDR, NIC_SRAM_RX_BUFFER_DESC,
  35278. + };
  35279. + static const uint32_t table_not_5705[] = {
  35280. + /* Buffer maximum length */
  35281. + RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS, RX_STD_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT,
  35282. +
  35283. + /* Disable the mini frame rx ring */
  35284. + RCVDBDI_MINI_BD + TG3_BDINFO_MAXLEN_FLAGS, BDINFO_FLAGS_DISABLED,
  35285. +
  35286. + /* Disable the jumbo frame rx ring */
  35287. + RCVBDI_JUMBO_THRESH, 0,
  35288. + RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS, BDINFO_FLAGS_DISABLED,
  35289. +
  35290. +
  35291. + };
  35292. + TG3_WRITE_SETTINGS(table_all);
  35293. + tw32(RCVDBDI_STD_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
  35294. + virt_to_bus(tp->rx_std));
  35295. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
  35296. + tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
  35297. + RX_STD_MAX_SIZE_5705 << BDINFO_FLAGS_MAXLEN_SHIFT);
  35298. + } else {
  35299. + TG3_WRITE_SETTINGS(table_not_5705);
  35300. + }
  35301. + }
  35302. +
  35303. +
  35304. + /* There is only one send ring on 5705, no need to explicitly
  35305. + * disable the others.
  35306. + */
  35307. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  35308. + /* Clear out send RCB ring in SRAM. */
  35309. + for (i = NIC_SRAM_SEND_RCB; i < NIC_SRAM_RCV_RET_RCB; i += TG3_BDINFO_SIZE)
  35310. + tg3_write_mem(i + TG3_BDINFO_MAXLEN_FLAGS, BDINFO_FLAGS_DISABLED);
  35311. + }
  35312. +
  35313. + tp->tx_prod = 0;
  35314. + tw32_mailbox(MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW, 0);
  35315. + tw32_mailbox2(MAILBOX_SNDNIC_PROD_IDX_0 + TG3_64BIT_REG_LOW, 0);
  35316. +
  35317. + tg3_set_bdinfo(tp,
  35318. + NIC_SRAM_SEND_RCB,
  35319. + virt_to_bus(tp->tx_ring),
  35320. + (TG3_TX_RING_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT),
  35321. + NIC_SRAM_TX_BUFFER_DESC);
  35322. +
  35323. + /* There is only one receive return ring on 5705, no need to explicitly
  35324. + * disable the others.
  35325. + */
  35326. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  35327. + for (i = NIC_SRAM_RCV_RET_RCB; i < NIC_SRAM_STATS_BLK; i += TG3_BDINFO_SIZE) {
  35328. + tg3_write_mem(i + TG3_BDINFO_MAXLEN_FLAGS,
  35329. + BDINFO_FLAGS_DISABLED);
  35330. + }
  35331. + }
  35332. +
  35333. + tp->rx_rcb_ptr = 0;
  35334. + tw32_mailbox2(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW, 0);
  35335. +
  35336. + tg3_set_bdinfo(tp,
  35337. + NIC_SRAM_RCV_RET_RCB,
  35338. + virt_to_bus(tp->rx_rcb),
  35339. + (TG3_RX_RCB_RING_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT),
  35340. + 0);
  35341. +
  35342. + tp->rx_std_ptr = TG3_DEF_RX_RING_PENDING;
  35343. + tw32_mailbox2(MAILBOX_RCV_STD_PROD_IDX + TG3_64BIT_REG_LOW,
  35344. + tp->rx_std_ptr);
  35345. +
  35346. + tw32_mailbox2(MAILBOX_RCV_JUMBO_PROD_IDX + TG3_64BIT_REG_LOW, 0);
  35347. +
  35348. + /* Initialize MAC address and backoff seed. */
  35349. + __tg3_set_mac_addr(tp);
  35350. +
  35351. + /* Calculate RDMAC_MODE setting early, we need it to determine
  35352. + * the RCVLPC_STATE_ENABLE mask.
  35353. + */
  35354. + rdmac_mode = (RDMAC_MODE_ENABLE | RDMAC_MODE_TGTABORT_ENAB |
  35355. + RDMAC_MODE_MSTABORT_ENAB | RDMAC_MODE_PARITYERR_ENAB |
  35356. + RDMAC_MODE_ADDROFLOW_ENAB | RDMAC_MODE_FIFOOFLOW_ENAB |
  35357. + RDMAC_MODE_FIFOURUN_ENAB | RDMAC_MODE_FIFOOREAD_ENAB |
  35358. + RDMAC_MODE_LNGREAD_ENAB);
  35359. + if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
  35360. + rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE;
  35361. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
  35362. + if (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) {
  35363. + if (!(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) &&
  35364. + !(tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
  35365. + rdmac_mode |= RDMAC_MODE_FIFO_LONG_BURST;
  35366. + }
  35367. + }
  35368. + }
  35369. +
  35370. + /* Setup host coalescing engine. */
  35371. + tw32(HOSTCC_MODE, 0);
  35372. + for (i = 0; i < 2000; i++) {
  35373. + if (!(tr32(HOSTCC_MODE) & HOSTCC_MODE_ENABLE))
  35374. + break;
  35375. + udelay(10);
  35376. + }
  35377. +
  35378. + tp->mac_mode = MAC_MODE_TXSTAT_ENABLE | MAC_MODE_RXSTAT_ENABLE |
  35379. + MAC_MODE_TDE_ENABLE | MAC_MODE_RDE_ENABLE | MAC_MODE_FHDE_ENABLE;
  35380. + tw32_carefully(MAC_MODE, tp->mac_mode | MAC_MODE_RXSTAT_CLEAR | MAC_MODE_TXSTAT_CLEAR);
  35381. +
  35382. + tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM;
  35383. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700)
  35384. + tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
  35385. + GRC_LCLCTRL_GPIO_OUTPUT1);
  35386. + tw32_carefully(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
  35387. +
  35388. + tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0);
  35389. + tr32(MAILBOX_INTERRUPT_0);
  35390. +
  35391. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  35392. + tw32_carefully(DMAC_MODE, DMAC_MODE_ENABLE);
  35393. + }
  35394. +
  35395. + val = ( WDMAC_MODE_ENABLE | WDMAC_MODE_TGTABORT_ENAB |
  35396. + WDMAC_MODE_MSTABORT_ENAB | WDMAC_MODE_PARITYERR_ENAB |
  35397. + WDMAC_MODE_ADDROFLOW_ENAB | WDMAC_MODE_FIFOOFLOW_ENAB |
  35398. + WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB |
  35399. + WDMAC_MODE_LNGREAD_ENAB);
  35400. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) &&
  35401. + ((tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) != 0) &&
  35402. + !(tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
  35403. + val |= WDMAC_MODE_RX_ACCEL;
  35404. + }
  35405. + tw32_carefully(WDMAC_MODE, val);
  35406. +
  35407. + if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) {
  35408. + val = tr32(TG3PCI_X_CAPS);
  35409. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) {
  35410. + val &= PCIX_CAPS_BURST_MASK;
  35411. + val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT);
  35412. + } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
  35413. + val &= ~(PCIX_CAPS_SPLIT_MASK | PCIX_CAPS_BURST_MASK);
  35414. + val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT);
  35415. + if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
  35416. + val |= (tp->split_mode_max_reqs <<
  35417. + PCIX_CAPS_SPLIT_SHIFT);
  35418. + }
  35419. + tw32(TG3PCI_X_CAPS, val);
  35420. + }
  35421. +
  35422. + tw32_carefully(RDMAC_MODE, rdmac_mode);
  35423. + {
  35424. + static const uint32_t table_all[] = {
  35425. + /* MTU + ethernet header + FCS + optional VLAN tag */
  35426. + MAC_RX_MTU_SIZE, ETH_MAX_MTU + ETH_HLEN + 8,
  35427. +
  35428. + /* The slot time is changed by tg3_setup_phy if we
  35429. + * run at gigabit with half duplex.
  35430. + */
  35431. + MAC_TX_LENGTHS,
  35432. + (2 << TX_LENGTHS_IPG_CRS_SHIFT) |
  35433. + (6 << TX_LENGTHS_IPG_SHIFT) |
  35434. + (32 << TX_LENGTHS_SLOT_TIME_SHIFT),
  35435. +
  35436. + /* Receive rules. */
  35437. + MAC_RCV_RULE_CFG, RCV_RULE_CFG_DEFAULT_CLASS,
  35438. + RCVLPC_CONFIG, 0x0181,
  35439. +
  35440. + /* Receive/send statistics. */
  35441. + RCVLPC_STATS_ENABLE, 0xffffff,
  35442. + RCVLPC_STATSCTRL, RCVLPC_STATSCTRL_ENABLE,
  35443. + SNDDATAI_STATSENAB, 0xffffff,
  35444. + SNDDATAI_STATSCTRL, (SNDDATAI_SCTRL_ENABLE |SNDDATAI_SCTRL_FASTUPD),
  35445. +
  35446. + /* Host coalescing engine */
  35447. + HOSTCC_RXCOL_TICKS, 0,
  35448. + HOSTCC_TXCOL_TICKS, LOW_TXCOL_TICKS,
  35449. + HOSTCC_RXMAX_FRAMES, 1,
  35450. + HOSTCC_TXMAX_FRAMES, LOW_RXMAX_FRAMES,
  35451. + HOSTCC_RXCOAL_MAXF_INT, 1,
  35452. + HOSTCC_TXCOAL_MAXF_INT, 0,
  35453. +
  35454. + /* Status/statistics block address. */
  35455. + /* Etherboot lives below 4GB, so HIGH == 0 */
  35456. + HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, 0,
  35457. +
  35458. + /* No need to enable 32byte coalesce mode. */
  35459. + HOSTCC_MODE, HOSTCC_MODE_ENABLE | 0,
  35460. +
  35461. + RCVCC_MODE, RCVCC_MODE_ENABLE | RCVCC_MODE_ATTN_ENABLE,
  35462. + RCVLPC_MODE, RCVLPC_MODE_ENABLE,
  35463. +
  35464. + RCVDCC_MODE, RCVDCC_MODE_ENABLE | RCVDCC_MODE_ATTN_ENABLE,
  35465. +
  35466. + SNDDATAC_MODE, SNDDATAC_MODE_ENABLE,
  35467. + SNDBDC_MODE, SNDBDC_MODE_ENABLE | SNDBDC_MODE_ATTN_ENABLE,
  35468. + RCVBDI_MODE, RCVBDI_MODE_ENABLE | RCVBDI_MODE_RCB_ATTN_ENAB,
  35469. + RCVDBDI_MODE, RCVDBDI_MODE_ENABLE | RCVDBDI_MODE_INV_RING_SZ,
  35470. + SNDDATAI_MODE, SNDDATAI_MODE_ENABLE,
  35471. + SNDBDI_MODE, SNDBDI_MODE_ENABLE | SNDBDI_MODE_ATTN_ENABLE,
  35472. + SNDBDS_MODE, SNDBDS_MODE_ENABLE | SNDBDS_MODE_ATTN_ENABLE,
  35473. +
  35474. + /* Accept all multicast frames. */
  35475. + MAC_HASH_REG_0, 0xffffffff,
  35476. + MAC_HASH_REG_1, 0xffffffff,
  35477. + MAC_HASH_REG_2, 0xffffffff,
  35478. + MAC_HASH_REG_3, 0xffffffff,
  35479. + };
  35480. + static const uint32_t table_not_5705[] = {
  35481. + /* Host coalescing engine */
  35482. + HOSTCC_RXCOAL_TICK_INT, 0,
  35483. + HOSTCC_TXCOAL_TICK_INT, 0,
  35484. +
  35485. + /* Status/statistics block address. */
  35486. + /* Etherboot lives below 4GB, so HIGH == 0 */
  35487. + HOSTCC_STAT_COAL_TICKS, DEFAULT_STAT_COAL_TICKS,
  35488. + HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, 0,
  35489. + HOSTCC_STATS_BLK_NIC_ADDR, NIC_SRAM_STATS_BLK,
  35490. + HOSTCC_STATUS_BLK_NIC_ADDR, NIC_SRAM_STATUS_BLK,
  35491. +
  35492. + RCVLSC_MODE, RCVLSC_MODE_ENABLE | RCVLSC_MODE_ATTN_ENABLE,
  35493. +
  35494. + MBFREE_MODE, MBFREE_MODE_ENABLE,
  35495. + };
  35496. + TG3_WRITE_SETTINGS(table_all);
  35497. + tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
  35498. + virt_to_bus(tp->hw_stats));
  35499. + tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
  35500. + virt_to_bus(tp->hw_status));
  35501. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  35502. + TG3_WRITE_SETTINGS(table_not_5705);
  35503. + }
  35504. + }
  35505. +
  35506. + tp->tx_mode = TX_MODE_ENABLE;
  35507. + tw32_carefully(MAC_TX_MODE, tp->tx_mode);
  35508. +
  35509. + tp->rx_mode = RX_MODE_ENABLE;
  35510. + tw32_carefully(MAC_RX_MODE, tp->rx_mode);
  35511. +
  35512. + tp->mi_mode = MAC_MI_MODE_BASE;
  35513. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  35514. +
  35515. + tw32(MAC_LED_CTRL, 0);
  35516. + tw32(MAC_MI_STAT, MAC_MI_STAT_LNKSTAT_ATTN_ENAB);
  35517. + if (tp->phy_id == PHY_ID_SERDES) {
  35518. + tw32_carefully(MAC_RX_MODE, RX_MODE_RESET);
  35519. + }
  35520. + tp->rx_mode |= RX_MODE_KEEP_VLAN_TAG; /* drop tagged vlan packets */
  35521. + tw32_carefully(MAC_RX_MODE, tp->rx_mode);
  35522. +
  35523. + if (tp->pci_chip_rev_id == CHIPREV_ID_5703_A1)
  35524. + tw32(MAC_SERDES_CFG, 0x616000);
  35525. +
  35526. + /* Prevent chip from dropping frames when flow control
  35527. + * is enabled.
  35528. + */
  35529. + tw32(MAC_LOW_WMARK_MAX_RX_FRAME, 2);
  35530. + tr32(MAC_LOW_WMARK_MAX_RX_FRAME);
  35531. +
  35532. + err = tg3_setup_phy(tp);
  35533. +
  35534. + /* Ignore CRC stats */
  35535. +
  35536. + /* Initialize receive rules. */
  35537. + tw32(MAC_RCV_RULE_0, 0xc2000000 & RCV_RULE_DISABLE_MASK);
  35538. + tw32(MAC_RCV_VALUE_0, 0xffffffff & RCV_RULE_DISABLE_MASK);
  35539. + tw32(MAC_RCV_RULE_1, 0x86000004 & RCV_RULE_DISABLE_MASK);
  35540. + tw32(MAC_RCV_VALUE_1, 0xffffffff & RCV_RULE_DISABLE_MASK);
  35541. +
  35542. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
  35543. + limit = 8;
  35544. + else
  35545. + limit = 16;
  35546. + if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF)
  35547. + limit -= 4;
  35548. + switch (limit) {
  35549. + case 16: tw32(MAC_RCV_RULE_15, 0); tw32(MAC_RCV_VALUE_15, 0);
  35550. + case 15: tw32(MAC_RCV_RULE_14, 0); tw32(MAC_RCV_VALUE_14, 0);
  35551. + case 14: tw32(MAC_RCV_RULE_13, 0); tw32(MAC_RCV_VALUE_13, 0);
  35552. + case 13: tw32(MAC_RCV_RULE_12, 0); tw32(MAC_RCV_VALUE_12, 0);
  35553. + case 12: tw32(MAC_RCV_RULE_11, 0); tw32(MAC_RCV_VALUE_11, 0);
  35554. + case 11: tw32(MAC_RCV_RULE_10, 0); tw32(MAC_RCV_VALUE_10, 0);
  35555. + case 10: tw32(MAC_RCV_RULE_9, 0); tw32(MAC_RCV_VALUE_9, 0);
  35556. + case 9: tw32(MAC_RCV_RULE_8, 0); tw32(MAC_RCV_VALUE_8, 0);
  35557. + case 8: tw32(MAC_RCV_RULE_7, 0); tw32(MAC_RCV_VALUE_7, 0);
  35558. + case 7: tw32(MAC_RCV_RULE_6, 0); tw32(MAC_RCV_VALUE_6, 0);
  35559. + case 6: tw32(MAC_RCV_RULE_5, 0); tw32(MAC_RCV_VALUE_5, 0);
  35560. + case 5: tw32(MAC_RCV_RULE_4, 0); tw32(MAC_RCV_VALUE_4, 0);
  35561. + case 4: /* tw32(MAC_RCV_RULE_3, 0); tw32(MAC_RCV_VALUE_3, 0); */
  35562. + case 3: /* tw32(MAC_RCV_RULE_2, 0); tw32(MAC_RCV_VALUE_2, 0); */
  35563. + case 2:
  35564. + case 1:
  35565. + default:
  35566. + break;
  35567. + };
  35568. +
  35569. + return err;
  35570. +}
  35571. +
  35572. +
  35573. +
  35574. +/* Chips other than 5700/5701 use the NVRAM for fetching info. */
  35575. +static void tg3_nvram_init(struct tg3 *tp)
  35576. +{
  35577. + tw32(GRC_EEPROM_ADDR,
  35578. + (EEPROM_ADDR_FSM_RESET |
  35579. + (EEPROM_DEFAULT_CLOCK_PERIOD <<
  35580. + EEPROM_ADDR_CLKPERD_SHIFT)));
  35581. +
  35582. + mdelay(1);
  35583. +
  35584. + /* Enable seeprom accesses. */
  35585. + tw32_carefully(GRC_LOCAL_CTRL,
  35586. + tr32(GRC_LOCAL_CTRL) | GRC_LCLCTRL_AUTO_SEEPROM);
  35587. +
  35588. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
  35589. + GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
  35590. + uint32_t nvcfg1 = tr32(NVRAM_CFG1);
  35591. +
  35592. + tp->tg3_flags |= TG3_FLAG_NVRAM;
  35593. + if (nvcfg1 & NVRAM_CFG1_FLASHIF_ENAB) {
  35594. + if (nvcfg1 & NVRAM_CFG1_BUFFERED_MODE)
  35595. + tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
  35596. + } else {
  35597. + nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS;
  35598. + tw32(NVRAM_CFG1, nvcfg1);
  35599. + }
  35600. +
  35601. + } else {
  35602. + tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
  35603. + }
  35604. +}
  35605. +
  35606. +
  35607. +static int tg3_nvram_read_using_eeprom(
  35608. + struct tg3 *tp __unused, uint32_t offset, uint32_t *val)
  35609. +{
  35610. + uint32_t tmp;
  35611. + int i;
  35612. +
  35613. + if (offset > EEPROM_ADDR_ADDR_MASK ||
  35614. + (offset % 4) != 0) {
  35615. + return -EINVAL;
  35616. + }
  35617. +
  35618. + tmp = tr32(GRC_EEPROM_ADDR) & ~(EEPROM_ADDR_ADDR_MASK |
  35619. + EEPROM_ADDR_DEVID_MASK |
  35620. + EEPROM_ADDR_READ);
  35621. + tw32(GRC_EEPROM_ADDR,
  35622. + tmp |
  35623. + (0 << EEPROM_ADDR_DEVID_SHIFT) |
  35624. + ((offset << EEPROM_ADDR_ADDR_SHIFT) &
  35625. + EEPROM_ADDR_ADDR_MASK) |
  35626. + EEPROM_ADDR_READ | EEPROM_ADDR_START);
  35627. +
  35628. + for (i = 0; i < 10000; i++) {
  35629. + tmp = tr32(GRC_EEPROM_ADDR);
  35630. +
  35631. + if (tmp & EEPROM_ADDR_COMPLETE)
  35632. + break;
  35633. + udelay(100);
  35634. + }
  35635. + if (!(tmp & EEPROM_ADDR_COMPLETE)) {
  35636. + return -EBUSY;
  35637. + }
  35638. +
  35639. + *val = tr32(GRC_EEPROM_DATA);
  35640. + return 0;
  35641. +}
  35642. +
  35643. +static int tg3_nvram_read(struct tg3 *tp, uint32_t offset, uint32_t *val)
  35644. +{
  35645. + int i, saw_done_clear;
  35646. +
  35647. + if (!(tp->tg3_flags & TG3_FLAG_NVRAM))
  35648. + return tg3_nvram_read_using_eeprom(tp, offset, val);
  35649. +
  35650. + if (tp->tg3_flags & TG3_FLAG_NVRAM_BUFFERED)
  35651. + offset = ((offset / NVRAM_BUFFERED_PAGE_SIZE) <<
  35652. + NVRAM_BUFFERED_PAGE_POS) +
  35653. + (offset % NVRAM_BUFFERED_PAGE_SIZE);
  35654. +
  35655. + if (offset > NVRAM_ADDR_MSK)
  35656. + return -EINVAL;
  35657. +
  35658. + tw32(NVRAM_SWARB, SWARB_REQ_SET1);
  35659. + for (i = 0; i < 1000; i++) {
  35660. + if (tr32(NVRAM_SWARB) & SWARB_GNT1)
  35661. + break;
  35662. + udelay(20);
  35663. + }
  35664. +
  35665. + tw32(NVRAM_ADDR, offset);
  35666. + tw32(NVRAM_CMD,
  35667. + NVRAM_CMD_RD | NVRAM_CMD_GO |
  35668. + NVRAM_CMD_FIRST | NVRAM_CMD_LAST | NVRAM_CMD_DONE);
  35669. +
  35670. + /* Wait for done bit to clear then set again. */
  35671. + saw_done_clear = 0;
  35672. + for (i = 0; i < 1000; i++) {
  35673. + udelay(10);
  35674. + if (!saw_done_clear &&
  35675. + !(tr32(NVRAM_CMD) & NVRAM_CMD_DONE))
  35676. + saw_done_clear = 1;
  35677. + else if (saw_done_clear &&
  35678. + (tr32(NVRAM_CMD) & NVRAM_CMD_DONE))
  35679. + break;
  35680. + }
  35681. + if (i >= 1000) {
  35682. + tw32(NVRAM_SWARB, SWARB_REQ_CLR1);
  35683. + return -EBUSY;
  35684. + }
  35685. +
  35686. + *val = bswap_32(tr32(NVRAM_RDDATA));
  35687. + tw32(NVRAM_SWARB, 0x20);
  35688. +
  35689. + return 0;
  35690. +}
  35691. +
  35692. +struct subsys_tbl_ent {
  35693. + uint16_t subsys_vendor, subsys_devid;
  35694. + uint32_t phy_id;
  35695. +};
  35696. +
  35697. +static struct subsys_tbl_ent subsys_id_to_phy_id[] = {
  35698. + /* Broadcom boards. */
  35699. + { 0x14e4, 0x1644, PHY_ID_BCM5401 }, /* BCM95700A6 */
  35700. + { 0x14e4, 0x0001, PHY_ID_BCM5701 }, /* BCM95701A5 */
  35701. + { 0x14e4, 0x0002, PHY_ID_BCM8002 }, /* BCM95700T6 */
  35702. + { 0x14e4, 0x0003, PHY_ID_SERDES }, /* BCM95700A9 */
  35703. + { 0x14e4, 0x0005, PHY_ID_BCM5701 }, /* BCM95701T1 */
  35704. + { 0x14e4, 0x0006, PHY_ID_BCM5701 }, /* BCM95701T8 */
  35705. + { 0x14e4, 0x0007, PHY_ID_SERDES }, /* BCM95701A7 */
  35706. + { 0x14e4, 0x0008, PHY_ID_BCM5701 }, /* BCM95701A10 */
  35707. + { 0x14e4, 0x8008, PHY_ID_BCM5701 }, /* BCM95701A12 */
  35708. + { 0x14e4, 0x0009, PHY_ID_BCM5701 }, /* BCM95703Ax1 */
  35709. + { 0x14e4, 0x8009, PHY_ID_BCM5701 }, /* BCM95703Ax2 */
  35710. +
  35711. + /* 3com boards. */
  35712. + { PCI_VENDOR_ID_3COM, 0x1000, PHY_ID_BCM5401 }, /* 3C996T */
  35713. + { PCI_VENDOR_ID_3COM, 0x1006, PHY_ID_BCM5701 }, /* 3C996BT */
  35714. + /* { PCI_VENDOR_ID_3COM, 0x1002, PHY_ID_XXX }, 3C996CT */
  35715. + /* { PCI_VENDOR_ID_3COM, 0x1003, PHY_ID_XXX }, 3C997T */
  35716. + { PCI_VENDOR_ID_3COM, 0x1004, PHY_ID_SERDES }, /* 3C996SX */
  35717. + /* { PCI_VENDOR_ID_3COM, 0x1005, PHY_ID_XXX }, 3C997SZ */
  35718. + { PCI_VENDOR_ID_3COM, 0x1007, PHY_ID_BCM5701 }, /* 3C1000T */
  35719. + { PCI_VENDOR_ID_3COM, 0x1008, PHY_ID_BCM5701 }, /* 3C940BR01 */
  35720. +
  35721. + /* DELL boards. */
  35722. + { PCI_VENDOR_ID_DELL, 0x00d1, PHY_ID_BCM5401 }, /* VIPER */
  35723. + { PCI_VENDOR_ID_DELL, 0x0106, PHY_ID_BCM5401 }, /* JAGUAR */
  35724. + { PCI_VENDOR_ID_DELL, 0x0109, PHY_ID_BCM5411 }, /* MERLOT */
  35725. + { PCI_VENDOR_ID_DELL, 0x010a, PHY_ID_BCM5411 }, /* SLIM_MERLOT */
  35726. +
  35727. + /* Compaq boards. */
  35728. + { PCI_VENDOR_ID_COMPAQ, 0x007c, PHY_ID_BCM5701 }, /* BANSHEE */
  35729. + { PCI_VENDOR_ID_COMPAQ, 0x009a, PHY_ID_BCM5701 }, /* BANSHEE_2 */
  35730. + { PCI_VENDOR_ID_COMPAQ, 0x007d, PHY_ID_SERDES }, /* CHANGELING */
  35731. + { PCI_VENDOR_ID_COMPAQ, 0x0085, PHY_ID_BCM5701 }, /* NC7780 */
  35732. + { PCI_VENDOR_ID_COMPAQ, 0x0099, PHY_ID_BCM5701 } /* NC7780_2 */
  35733. +};
  35734. +
  35735. +static int tg3_phy_probe(struct tg3 *tp)
  35736. +{
  35737. + uint32_t eeprom_phy_id, hw_phy_id_1, hw_phy_id_2;
  35738. + uint32_t hw_phy_id, hw_phy_id_masked;
  35739. + enum phy_led_mode eeprom_led_mode;
  35740. + uint32_t val;
  35741. + unsigned i;
  35742. + int eeprom_signature_found, err;
  35743. +
  35744. + tp->phy_id = PHY_ID_INVALID;
  35745. +
  35746. + for (i = 0; i < sizeof(subsys_id_to_phy_id)/sizeof(subsys_id_to_phy_id[0]); i++) {
  35747. + if ((subsys_id_to_phy_id[i].subsys_vendor == tp->subsystem_vendor) &&
  35748. + (subsys_id_to_phy_id[i].subsys_devid == tp->subsystem_device)) {
  35749. + tp->phy_id = subsys_id_to_phy_id[i].phy_id;
  35750. + break;
  35751. + }
  35752. + }
  35753. +
  35754. + eeprom_phy_id = PHY_ID_INVALID;
  35755. + eeprom_led_mode = led_mode_auto;
  35756. + eeprom_signature_found = 0;
  35757. + tg3_read_mem(NIC_SRAM_DATA_SIG, &val);
  35758. + if (val == NIC_SRAM_DATA_SIG_MAGIC) {
  35759. + uint32_t nic_cfg;
  35760. +
  35761. + tg3_read_mem(NIC_SRAM_DATA_CFG, &nic_cfg);
  35762. + tp->nic_sram_data_cfg = nic_cfg;
  35763. +
  35764. + eeprom_signature_found = 1;
  35765. +
  35766. + if ((nic_cfg & NIC_SRAM_DATA_CFG_PHY_TYPE_MASK) ==
  35767. + NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER) {
  35768. + eeprom_phy_id = PHY_ID_SERDES;
  35769. + } else {
  35770. + uint32_t nic_phy_id;
  35771. +
  35772. + tg3_read_mem(NIC_SRAM_DATA_PHY_ID, &nic_phy_id);
  35773. + if (nic_phy_id != 0) {
  35774. + uint32_t id1 = nic_phy_id & NIC_SRAM_DATA_PHY_ID1_MASK;
  35775. + uint32_t id2 = nic_phy_id & NIC_SRAM_DATA_PHY_ID2_MASK;
  35776. +
  35777. + eeprom_phy_id = (id1 >> 16) << 10;
  35778. + eeprom_phy_id |= (id2 & 0xfc00) << 16;
  35779. + eeprom_phy_id |= (id2 & 0x03ff) << 0;
  35780. + }
  35781. + }
  35782. +
  35783. + switch (nic_cfg & NIC_SRAM_DATA_CFG_LED_MODE_MASK) {
  35784. + case NIC_SRAM_DATA_CFG_LED_TRIPLE_SPD:
  35785. + eeprom_led_mode = led_mode_three_link;
  35786. + break;
  35787. +
  35788. + case NIC_SRAM_DATA_CFG_LED_LINK_SPD:
  35789. + eeprom_led_mode = led_mode_link10;
  35790. + break;
  35791. +
  35792. + default:
  35793. + eeprom_led_mode = led_mode_auto;
  35794. + break;
  35795. + };
  35796. + if (((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
  35797. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
  35798. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) &&
  35799. + (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP)) {
  35800. + tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
  35801. + }
  35802. +
  35803. + if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE)
  35804. + tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
  35805. + if (nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL)
  35806. + tp->tg3_flags |= TG3_FLAG_SERDES_WOL_CAP;
  35807. + }
  35808. +
  35809. + /* Now read the physical PHY_ID from the chip and verify
  35810. + * that it is sane. If it doesn't look good, we fall back
  35811. + * to either the hard-coded table based PHY_ID and failing
  35812. + * that the value found in the eeprom area.
  35813. + */
  35814. + err = tg3_readphy(tp, MII_PHYSID1, &hw_phy_id_1);
  35815. + err |= tg3_readphy(tp, MII_PHYSID2, &hw_phy_id_2);
  35816. +
  35817. + hw_phy_id = (hw_phy_id_1 & 0xffff) << 10;
  35818. + hw_phy_id |= (hw_phy_id_2 & 0xfc00) << 16;
  35819. + hw_phy_id |= (hw_phy_id_2 & 0x03ff) << 0;
  35820. +
  35821. + hw_phy_id_masked = hw_phy_id & PHY_ID_MASK;
  35822. +
  35823. + if (!err && KNOWN_PHY_ID(hw_phy_id_masked)) {
  35824. + tp->phy_id = hw_phy_id;
  35825. + } else {
  35826. + /* phy_id currently holds the value found in the
  35827. + * subsys_id_to_phy_id[] table or PHY_ID_INVALID
  35828. + * if a match was not found there.
  35829. + */
  35830. + if (tp->phy_id == PHY_ID_INVALID) {
  35831. + if (!eeprom_signature_found ||
  35832. + !KNOWN_PHY_ID(eeprom_phy_id & PHY_ID_MASK))
  35833. + return -ENODEV;
  35834. + tp->phy_id = eeprom_phy_id;
  35835. + }
  35836. + }
  35837. +
  35838. + err = tg3_phy_reset(tp);
  35839. + if (err)
  35840. + return err;
  35841. +
  35842. + if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
  35843. + tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) {
  35844. + uint32_t mii_tg3_ctrl;
  35845. +
  35846. + /* These chips, when reset, only advertise 10Mb
  35847. + * capabilities. Fix that.
  35848. + */
  35849. + err = tg3_writephy(tp, MII_ADVERTISE,
  35850. + (ADVERTISE_CSMA |
  35851. + ADVERTISE_PAUSE_CAP |
  35852. + ADVERTISE_10HALF |
  35853. + ADVERTISE_10FULL |
  35854. + ADVERTISE_100HALF |
  35855. + ADVERTISE_100FULL));
  35856. + mii_tg3_ctrl = (MII_TG3_CTRL_ADV_1000_HALF |
  35857. + MII_TG3_CTRL_ADV_1000_FULL |
  35858. + MII_TG3_CTRL_AS_MASTER |
  35859. + MII_TG3_CTRL_ENABLE_AS_MASTER);
  35860. + if (tp->tg3_flags & TG3_FLAG_10_100_ONLY)
  35861. + mii_tg3_ctrl = 0;
  35862. +
  35863. + err |= tg3_writephy(tp, MII_TG3_CTRL, mii_tg3_ctrl);
  35864. + err |= tg3_writephy(tp, MII_BMCR,
  35865. + (BMCR_ANRESTART | BMCR_ANENABLE));
  35866. + }
  35867. +
  35868. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) {
  35869. + tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00);
  35870. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x201f);
  35871. + tg3_writedsp(tp, MII_TG3_DSP_RW_PORT, 0x2aaa);
  35872. + }
  35873. +
  35874. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
  35875. + tg3_writephy(tp, 0x1c, 0x8d68);
  35876. + tg3_writephy(tp, 0x1c, 0x8d68);
  35877. + }
  35878. +
  35879. + /* Enable Ethernet@WireSpeed */
  35880. + tg3_phy_set_wirespeed(tp);
  35881. +
  35882. + if (!err && ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401)) {
  35883. + err = tg3_init_5401phy_dsp(tp);
  35884. + }
  35885. +
  35886. + /* Determine the PHY led mode.
  35887. + * Be careful if this gets set wrong it can result in an inability to
  35888. + * establish a link.
  35889. + */
  35890. + if (tp->phy_id == PHY_ID_SERDES) {
  35891. + tp->led_mode = led_mode_three_link;
  35892. + }
  35893. + else if (tp->subsystem_vendor == PCI_VENDOR_ID_DELL) {
  35894. + tp->led_mode = led_mode_link10;
  35895. + } else {
  35896. + tp->led_mode = led_mode_three_link;
  35897. + if (eeprom_signature_found &&
  35898. + eeprom_led_mode != led_mode_auto)
  35899. + tp->led_mode = eeprom_led_mode;
  35900. + }
  35901. +
  35902. + if (tp->phy_id == PHY_ID_SERDES)
  35903. + tp->link_config.advertising =
  35904. + (ADVERTISED_1000baseT_Half |
  35905. + ADVERTISED_1000baseT_Full |
  35906. + ADVERTISED_Autoneg |
  35907. + ADVERTISED_FIBRE);
  35908. + if (tp->tg3_flags & TG3_FLAG_10_100_ONLY)
  35909. + tp->link_config.advertising &=
  35910. + ~(ADVERTISED_1000baseT_Half |
  35911. + ADVERTISED_1000baseT_Full);
  35912. +
  35913. + return err;
  35914. +}
  35915. +
  35916. +#if SUPPORT_PARTNO_STR
  35917. +static void tg3_read_partno(struct tg3 *tp)
  35918. +{
  35919. + unsigned char vpd_data[256];
  35920. + int i;
  35921. +
  35922. + for (i = 0; i < 256; i += 4) {
  35923. + uint32_t tmp;
  35924. +
  35925. + if (tg3_nvram_read(tp, 0x100 + i, &tmp))
  35926. + goto out_not_found;
  35927. +
  35928. + vpd_data[i + 0] = ((tmp >> 0) & 0xff);
  35929. + vpd_data[i + 1] = ((tmp >> 8) & 0xff);
  35930. + vpd_data[i + 2] = ((tmp >> 16) & 0xff);
  35931. + vpd_data[i + 3] = ((tmp >> 24) & 0xff);
  35932. + }
  35933. +
  35934. + /* Now parse and find the part number. */
  35935. + for (i = 0; i < 256; ) {
  35936. + unsigned char val = vpd_data[i];
  35937. + int block_end;
  35938. +
  35939. + if (val == 0x82 || val == 0x91) {
  35940. + i = (i + 3 +
  35941. + (vpd_data[i + 1] +
  35942. + (vpd_data[i + 2] << 8)));
  35943. + continue;
  35944. + }
  35945. +
  35946. + if (val != 0x90)
  35947. + goto out_not_found;
  35948. +
  35949. + block_end = (i + 3 +
  35950. + (vpd_data[i + 1] +
  35951. + (vpd_data[i + 2] << 8)));
  35952. + i += 3;
  35953. + while (i < block_end) {
  35954. + if (vpd_data[i + 0] == 'P' &&
  35955. + vpd_data[i + 1] == 'N') {
  35956. + int partno_len = vpd_data[i + 2];
  35957. +
  35958. + if (partno_len > 24)
  35959. + goto out_not_found;
  35960. +
  35961. + memcpy(tp->board_part_number,
  35962. + &vpd_data[i + 3],
  35963. + partno_len);
  35964. +
  35965. + /* Success. */
  35966. + return;
  35967. + }
  35968. + }
  35969. +
  35970. + /* Part number not found. */
  35971. + goto out_not_found;
  35972. + }
  35973. +
  35974. +out_not_found:
  35975. + memcpy(tp->board_part_number, "none", sizeof("none"));
  35976. +}
  35977. +#else
  35978. +#define tg3_read_partno(TP) ((TP)->board_part_number[0] = '\0')
  35979. +#endif
  35980. +
  35981. +static int tg3_get_invariants(struct tg3 *tp)
  35982. +{
  35983. + uint32_t misc_ctrl_reg;
  35984. + uint32_t pci_state_reg, grc_misc_cfg;
  35985. + uint16_t pci_cmd;
  35986. + uint8_t pci_latency;
  35987. + int err;
  35988. +
  35989. + /* Read the subsystem vendor and device ids */
  35990. + pci_read_config_word(tp->pdev, PCI_SUBSYSTEM_VENDOR_ID, &tp->subsystem_vendor);
  35991. + pci_read_config_word(tp->pdev, PCI_SUBSYSTEM_ID, &tp->subsystem_device);
  35992. +
  35993. + /* The sun_5704 code needs infrastructure etherboot does have
  35994. + * ignore it for now.
  35995. + */
  35996. +
  35997. + /* If we have an AMD 762 or Intel ICH/ICH0 chipset, write
  35998. + * reordering to the mailbox registers done by the host
  35999. + * controller can cause major troubles. We read back from
  36000. + * every mailbox register write to force the writes to be
  36001. + * posted to the chip in order.
  36002. + *
  36003. + * TG3_FLAG_MBOX_WRITE_REORDER has been forced on.
  36004. + */
  36005. +
  36006. + /* Force memory write invalidate off. If we leave it on,
  36007. + * then on 5700_BX chips we have to enable a workaround.
  36008. + * The workaround is to set the TG3PCI_DMA_RW_CTRL boundry
  36009. + * to match the cacheline size. The Broadcom driver have this
  36010. + * workaround but turns MWI off all the times so never uses
  36011. + * it. This seems to suggest that the workaround is insufficient.
  36012. + */
  36013. + pci_read_config_word(tp->pdev, PCI_COMMAND, &pci_cmd);
  36014. + pci_cmd &= ~PCI_COMMAND_INVALIDATE;
  36015. + /* Also, force SERR#/PERR# in PCI command. */
  36016. + pci_cmd |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
  36017. + pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd);
  36018. +
  36019. + /* It is absolutely critical that TG3PCI_MISC_HOST_CTRL
  36020. + * has the register indirect write enable bit set before
  36021. + * we try to access any of the MMIO registers. It is also
  36022. + * critical that the PCI-X hw workaround situation is decided
  36023. + * before that as well.
  36024. + */
  36025. + pci_read_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, &misc_ctrl_reg);
  36026. +
  36027. + tp->pci_chip_rev_id = (misc_ctrl_reg >> MISC_HOST_CTRL_CHIPREV_SHIFT);
  36028. +
  36029. + /* Initialize misc host control in PCI block. */
  36030. + tp->misc_host_ctrl |= (misc_ctrl_reg &
  36031. + MISC_HOST_CTRL_CHIPREV);
  36032. + pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
  36033. + tp->misc_host_ctrl);
  36034. +
  36035. + pci_read_config_byte(tp->pdev, PCI_LATENCY_TIMER, &pci_latency);
  36036. + if (pci_latency < 64) {
  36037. + pci_write_config_byte(tp->pdev, PCI_LATENCY_TIMER, 64);
  36038. + }
  36039. +
  36040. + pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE, &pci_state_reg);
  36041. +
  36042. + /* If this is a 5700 BX chipset, and we are in PCI-X
  36043. + * mode, enable register write workaround.
  36044. + *
  36045. + * The workaround is to use indirect register accesses
  36046. + * for all chip writes not to mailbox registers.
  36047. + *
  36048. + * In etherboot to simplify things we just always use this work around.
  36049. + */
  36050. + if ((pci_state_reg & PCISTATE_CONV_PCI_MODE) == 0) {
  36051. + tp->tg3_flags |= TG3_FLAG_PCIX_MODE;
  36052. + }
  36053. + /* Back to back register writes can cause problems on the 5701,
  36054. + * the workaround is to read back all reg writes except those to
  36055. + * mailbox regs.
  36056. + * In etherboot we always use indirect register accesses so
  36057. + * we don't see this.
  36058. + */
  36059. +
  36060. + if ((pci_state_reg & PCISTATE_BUS_SPEED_HIGH) != 0)
  36061. + tp->tg3_flags |= TG3_FLAG_PCI_HIGH_SPEED;
  36062. + if ((pci_state_reg & PCISTATE_BUS_32BIT) != 0)
  36063. + tp->tg3_flags |= TG3_FLAG_PCI_32BIT;
  36064. +
  36065. + /* Chip-specific fixup from Broadcom driver */
  36066. + if ((tp->pci_chip_rev_id == CHIPREV_ID_5704_A0) &&
  36067. + (!(pci_state_reg & PCISTATE_RETRY_SAME_DMA))) {
  36068. + pci_state_reg |= PCISTATE_RETRY_SAME_DMA;
  36069. + pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg);
  36070. + }
  36071. +
  36072. + /* Force the chip into D0. */
  36073. + tg3_set_power_state_0(tp);
  36074. +
  36075. + /* Etherboot does not ask the tg3 to do checksums */
  36076. + /* Etherboot does not ask the tg3 to do jumbo frames */
  36077. + /* Ehterboot does not ask the tg3 to use WakeOnLan. */
  36078. +
  36079. + /* A few boards don't want Ethernet@WireSpeed phy feature */
  36080. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) ||
  36081. + ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) &&
  36082. + (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) &&
  36083. + (tp->pci_chip_rev_id != CHIPREV_ID_5705_A1))) {
  36084. + tp->tg3_flags2 |= TG3_FLG2_NO_ETH_WIRE_SPEED;
  36085. + }
  36086. +
  36087. + /* Avoid tagged irq status etherboot does not use irqs */
  36088. +
  36089. + /* Only 5701 and later support tagged irq status mode.
  36090. + * Also, 5788 chips cannot use tagged irq status.
  36091. + *
  36092. + * However, since etherboot does not use irqs avoid tagged irqs
  36093. + * status because the interrupt condition is more difficult to
  36094. + * fully clear in that mode.
  36095. + */
  36096. +
  36097. + /* Since some 5700_AX && 5700_BX have problems with 32BYTE
  36098. + * coalesce_mode, and the rest work fine anything set.
  36099. + * Don't enable HOST_CC_MODE_32BYTE in etherboot.
  36100. + */
  36101. +
  36102. + /* Initialize MAC MI mode, polling disabled. */
  36103. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  36104. +
  36105. + /* Initialize data/descriptor byte/word swapping. */
  36106. + tw32(GRC_MODE, tp->grc_mode);
  36107. +
  36108. + tg3_switch_clocks(tp);
  36109. +
  36110. + /* Clear this out for sanity. */
  36111. + tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0);
  36112. +
  36113. + /* Etherboot does not need to check if the PCIX_TARGET_HWBUG
  36114. + * is needed. It always uses it.
  36115. + */
  36116. +
  36117. + udelay(50);
  36118. + tg3_nvram_init(tp);
  36119. +
  36120. + /* The TX descriptors will reside in main memory.
  36121. + */
  36122. +
  36123. + /* See which board we are using.
  36124. + */
  36125. + grc_misc_cfg = tr32(GRC_MISC_CFG);
  36126. + grc_misc_cfg &= GRC_MISC_CFG_BOARD_ID_MASK;
  36127. +
  36128. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 &&
  36129. + grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5704CIOBE) {
  36130. + tp->tg3_flags |= TG3_FLAG_SPLIT_MODE;
  36131. + tp->split_mode_max_reqs = SPLIT_MODE_5704_MAX_REQ;
  36132. + }
  36133. +
  36134. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
  36135. + (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788 ||
  36136. + grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788M))
  36137. + tp->tg3_flags2 |= TG3_FLG2_IS_5788;
  36138. +
  36139. + /* these are limited to 10/100 only */
  36140. + if (((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) &&
  36141. + ((grc_misc_cfg == 0x8000) || (grc_misc_cfg == 0x4000))) ||
  36142. + ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) &&
  36143. + (tp->pdev->vendor == PCI_VENDOR_ID_BROADCOM) &&
  36144. + ((tp->pdev->dev_id == PCI_DEVICE_ID_TIGON3_5901) ||
  36145. + (tp->pdev->dev_id == PCI_DEVICE_ID_TIGON3_5901_2)))) {
  36146. + tp->tg3_flags |= TG3_FLAG_10_100_ONLY;
  36147. + }
  36148. +
  36149. + err = tg3_phy_probe(tp);
  36150. + if (err) {
  36151. + printf("phy probe failed, err %d\n", err);
  36152. + }
  36153. +
  36154. + tg3_read_partno(tp);
  36155. +
  36156. +
  36157. + /* 5700 BX chips need to have their TX producer index mailboxes
  36158. + * written twice to workaround a bug.
  36159. + * In etherboot we do this unconditionally to simplify things.
  36160. + */
  36161. +
  36162. + /* 5700 chips can get confused if TX buffers straddle the
  36163. + * 4GB address boundary in some cases.
  36164. + *
  36165. + * In etherboot we can ignore the problem as etherboot lives below 4GB.
  36166. + */
  36167. +
  36168. + /* In etherboot wake-on-lan is unconditionally disabled */
  36169. + return err;
  36170. +}
  36171. +
  36172. +static int tg3_get_device_address(struct tg3 *tp)
  36173. +{
  36174. + struct nic *nic = tp->nic;
  36175. + uint32_t hi, lo, mac_offset;
  36176. +
  36177. + if (PCI_FUNC(tp->pdev->devfn) == 0)
  36178. + mac_offset = 0x7c;
  36179. + else
  36180. + mac_offset = 0xcc;
  36181. +
  36182. + /* First try to get it from MAC address mailbox. */
  36183. + tg3_read_mem(NIC_SRAM_MAC_ADDR_HIGH_MBOX, &hi);
  36184. + if ((hi >> 16) == 0x484b) {
  36185. + nic->node_addr[0] = (hi >> 8) & 0xff;
  36186. + nic->node_addr[1] = (hi >> 0) & 0xff;
  36187. +
  36188. + tg3_read_mem(NIC_SRAM_MAC_ADDR_LOW_MBOX, &lo);
  36189. + nic->node_addr[2] = (lo >> 24) & 0xff;
  36190. + nic->node_addr[3] = (lo >> 16) & 0xff;
  36191. + nic->node_addr[4] = (lo >> 8) & 0xff;
  36192. + nic->node_addr[5] = (lo >> 0) & 0xff;
  36193. + }
  36194. + /* Next, try NVRAM. */
  36195. + else if (!tg3_nvram_read(tp, mac_offset + 0, &hi) &&
  36196. + !tg3_nvram_read(tp, mac_offset + 4, &lo)) {
  36197. + nic->node_addr[0] = ((hi >> 16) & 0xff);
  36198. + nic->node_addr[1] = ((hi >> 24) & 0xff);
  36199. + nic->node_addr[2] = ((lo >> 0) & 0xff);
  36200. + nic->node_addr[3] = ((lo >> 8) & 0xff);
  36201. + nic->node_addr[4] = ((lo >> 16) & 0xff);
  36202. + nic->node_addr[5] = ((lo >> 24) & 0xff);
  36203. + }
  36204. + /* Finally just fetch it out of the MAC control regs. */
  36205. + else {
  36206. + hi = tr32(MAC_ADDR_0_HIGH);
  36207. + lo = tr32(MAC_ADDR_0_LOW);
  36208. +
  36209. + nic->node_addr[5] = lo & 0xff;
  36210. + nic->node_addr[4] = (lo >> 8) & 0xff;
  36211. + nic->node_addr[3] = (lo >> 16) & 0xff;
  36212. + nic->node_addr[2] = (lo >> 24) & 0xff;
  36213. + nic->node_addr[1] = hi & 0xff;
  36214. + nic->node_addr[0] = (hi >> 8) & 0xff;
  36215. + }
  36216. +
  36217. + return 0;
  36218. +}
  36219. +
  36220. +
  36221. +static int tg3_setup_dma(struct tg3 *tp)
  36222. +{
  36223. + tw32(TG3PCI_CLOCK_CTRL, 0);
  36224. +
  36225. + if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) == 0) {
  36226. + tp->dma_rwctrl =
  36227. + (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) |
  36228. + (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT) |
  36229. + (0x7 << DMA_RWCTRL_WRITE_WATER_SHIFT) |
  36230. + (0x7 << DMA_RWCTRL_READ_WATER_SHIFT) |
  36231. + (0x0f << DMA_RWCTRL_MIN_DMA_SHIFT);
  36232. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
  36233. + tp->dma_rwctrl &= ~(DMA_RWCTRL_MIN_DMA << DMA_RWCTRL_MIN_DMA_SHIFT);
  36234. + }
  36235. + } else {
  36236. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
  36237. + tp->dma_rwctrl =
  36238. + (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) |
  36239. + (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT) |
  36240. + (0x3 << DMA_RWCTRL_WRITE_WATER_SHIFT) |
  36241. + (0x7 << DMA_RWCTRL_READ_WATER_SHIFT) |
  36242. + (0x00 << DMA_RWCTRL_MIN_DMA_SHIFT);
  36243. + else
  36244. + tp->dma_rwctrl =
  36245. + (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) |
  36246. + (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT) |
  36247. + (0x3 << DMA_RWCTRL_WRITE_WATER_SHIFT) |
  36248. + (0x3 << DMA_RWCTRL_READ_WATER_SHIFT) |
  36249. + (0x0f << DMA_RWCTRL_MIN_DMA_SHIFT);
  36250. +
  36251. + /* Wheee, some more chip bugs... */
  36252. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
  36253. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)) {
  36254. + uint32_t ccval = tr32(TG3PCI_CLOCK_CTRL) & 0x1f;
  36255. +
  36256. + if ((ccval == 0x6) || (ccval == 0x7)) {
  36257. + tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA;
  36258. + }
  36259. + }
  36260. + }
  36261. +
  36262. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
  36263. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)) {
  36264. + tp->dma_rwctrl &= ~(DMA_RWCTRL_MIN_DMA << DMA_RWCTRL_MIN_DMA_SHIFT);
  36265. + }
  36266. +
  36267. + tp->dma_rwctrl |= DMA_RWCTRL_ASSERT_ALL_BE;
  36268. +
  36269. + tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
  36270. +
  36271. + return 0;
  36272. +}
  36273. +
  36274. +static void tg3_init_link_config(struct tg3 *tp)
  36275. +{
  36276. + tp->link_config.advertising =
  36277. + (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
  36278. + ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
  36279. + ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full |
  36280. + ADVERTISED_Autoneg | ADVERTISED_MII);
  36281. + tp->carrier_ok = 0;
  36282. + tp->link_config.active_speed = SPEED_INVALID;
  36283. + tp->link_config.active_duplex = DUPLEX_INVALID;
  36284. +}
  36285. +
  36286. +
  36287. +#if SUPPORT_PHY_STR
  36288. +static const char * tg3_phy_string(struct tg3 *tp)
  36289. +{
  36290. + switch (tp->phy_id & PHY_ID_MASK) {
  36291. + case PHY_ID_BCM5400: return "5400";
  36292. + case PHY_ID_BCM5401: return "5401";
  36293. + case PHY_ID_BCM5411: return "5411";
  36294. + case PHY_ID_BCM5701: return "5701";
  36295. + case PHY_ID_BCM5703: return "5703";
  36296. + case PHY_ID_BCM5704: return "5704";
  36297. + case PHY_ID_BCM8002: return "8002";
  36298. + case PHY_ID_SERDES: return "serdes";
  36299. + default: return "unknown";
  36300. + };
  36301. +}
  36302. +#else
  36303. +#define tg3_phy_string(TP) "?"
  36304. +#endif
  36305. +
  36306. +
  36307. +static void tg3_poll_link(struct tg3 *tp)
  36308. +{
  36309. + uint32_t mac_stat;
  36310. +
  36311. + mac_stat = tr32(MAC_STATUS);
  36312. + if (tp->phy_id == PHY_ID_SERDES) {
  36313. + if (tp->carrier_ok?
  36314. + (mac_stat & MAC_STATUS_LNKSTATE_CHANGED):
  36315. + (mac_stat & MAC_STATUS_PCS_SYNCED)) {
  36316. + tw32_carefully(MAC_MODE, tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK);
  36317. + tw32_carefully(MAC_MODE, tp->mac_mode);
  36318. +
  36319. + tg3_setup_phy(tp);
  36320. + }
  36321. + }
  36322. + else {
  36323. + if (mac_stat & MAC_STATUS_LNKSTATE_CHANGED) {
  36324. + tg3_setup_phy(tp);
  36325. + }
  36326. + }
  36327. +}
  36328. +
  36329. +/**************************************************************************
  36330. +POLL - Wait for a frame
  36331. +***************************************************************************/
  36332. +static void tg3_ack_irqs(struct tg3 *tp)
  36333. +{
  36334. + if (tp->hw_status->status & SD_STATUS_UPDATED) {
  36335. + /*
  36336. + * writing any value to intr-mbox-0 clears PCI INTA# and
  36337. + * chip-internal interrupt pending events.
  36338. + * writing non-zero to intr-mbox-0 additional tells the
  36339. + * NIC to stop sending us irqs, engaging "in-intr-handler"
  36340. + * event coalescing.
  36341. + */
  36342. + tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
  36343. + 0x00000001);
  36344. + /*
  36345. + * Flush PCI write. This also guarantees that our
  36346. + * status block has been flushed to host memory.
  36347. + */
  36348. + tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
  36349. + tp->hw_status->status &= ~SD_STATUS_UPDATED;
  36350. + }
  36351. +}
  36352. +
  36353. +static int tg3_poll(struct nic *nic, int retrieve)
  36354. +{
  36355. + /* return true if there's an ethernet packet ready to read */
  36356. + /* nic->packet should contain data on return */
  36357. + /* nic->packetlen should contain length of data */
  36358. +
  36359. + struct tg3 *tp = &tg3;
  36360. + int result;
  36361. +
  36362. + result = 0;
  36363. +
  36364. + if ( (tp->hw_status->idx[0].rx_producer != tp->rx_rcb_ptr) && !retrieve )
  36365. + return 1;
  36366. +
  36367. + tg3_ack_irqs(tp);
  36368. +
  36369. + if (tp->hw_status->idx[0].rx_producer != tp->rx_rcb_ptr) {
  36370. + struct tg3_rx_buffer_desc *desc;
  36371. + unsigned int len;
  36372. + desc = &tp->rx_rcb[tp->rx_rcb_ptr];
  36373. + if ((desc->opaque & RXD_OPAQUE_RING_MASK) == RXD_OPAQUE_RING_STD) {
  36374. + len = ((desc->idx_len & RXD_LEN_MASK) >> RXD_LEN_SHIFT) - 4; /* omit crc */
  36375. +
  36376. + nic->packetlen = len;
  36377. + memcpy(nic->packet, bus_to_virt(desc->addr_lo), len);
  36378. + result = 1;
  36379. + }
  36380. + tp->rx_rcb_ptr = (tp->rx_rcb_ptr + 1) % TG3_RX_RCB_RING_SIZE;
  36381. +
  36382. + /* ACK the status ring */
  36383. + tw32_mailbox2(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW, tp->rx_rcb_ptr);
  36384. +
  36385. + /* Refill RX ring. */
  36386. + if (result) {
  36387. + tp->rx_std_ptr = (tp->rx_std_ptr + 1) % TG3_RX_RING_SIZE;
  36388. + tw32_mailbox2(MAILBOX_RCV_STD_PROD_IDX + TG3_64BIT_REG_LOW, tp->rx_std_ptr);
  36389. + }
  36390. + }
  36391. + tg3_poll_link(tp);
  36392. + return result;
  36393. +}
  36394. +
  36395. +/**************************************************************************
  36396. +TRANSMIT - Transmit a frame
  36397. +***************************************************************************/
  36398. +#if 0
  36399. +static void tg3_set_txd(struct tg3 *tp, int entry,
  36400. + dma_addr_t mapping, int len, uint32_t flags,
  36401. + uint32_t mss_and_is_end)
  36402. +{
  36403. + struct tg3_tx_buffer_desc *txd = &tp->tx_ring[entry];
  36404. + int is_end = (mss_and_is_end & 0x1);
  36405. + if (is_end) {
  36406. + flags |= TXD_FLAG_END;
  36407. + }
  36408. +
  36409. + txd->addr_hi = 0;
  36410. + txd->addr_lo = mapping & 0xffffffff;
  36411. + txd->len_flags = (len << TXD_LEN_SHIFT) | flags;
  36412. + txd->vlan_tag = 0 << TXD_VLAN_TAG_SHIFT;
  36413. +}
  36414. +#endif
  36415. +
  36416. +static void tg3_transmit(struct nic *nic, const char *dst_addr,
  36417. + unsigned int type, unsigned int size, const char *packet)
  36418. +{
  36419. + static struct eth_frame {
  36420. + uint8_t dst_addr[ETH_ALEN];
  36421. + uint8_t src_addr[ETH_ALEN];
  36422. + uint16_t type;
  36423. + uint8_t data [ETH_FRAME_LEN - ETH_HLEN];
  36424. + } frame[2];
  36425. + static int frame_idx;
  36426. +
  36427. + /* send the packet to destination */
  36428. + struct tg3_tx_buffer_desc *txd;
  36429. + struct tg3 *tp;
  36430. + uint32_t entry;
  36431. + int i;
  36432. +
  36433. + /* Wait until there is a free packet frame */
  36434. + tp = &tg3;
  36435. + i = 0;
  36436. + entry = tp->tx_prod;
  36437. + while((tp->hw_status->idx[0].tx_consumer != entry) &&
  36438. + (tp->hw_status->idx[0].tx_consumer != PREV_TX(entry))) {
  36439. + mdelay(10); /* give the nick a chance */
  36440. + poll_interruptions();
  36441. + if (++i > 500) { /* timeout 5s for transmit */
  36442. + printf("transmit timed out\n");
  36443. + tg3_halt(tp);
  36444. + tg3_setup_hw(tp);
  36445. + return;
  36446. + }
  36447. + }
  36448. + if (i != 0) {
  36449. + printf("#");
  36450. + }
  36451. +
  36452. + /* Copy the packet to the our local buffer */
  36453. + memcpy(&frame[frame_idx].dst_addr, dst_addr, ETH_ALEN);
  36454. + memcpy(&frame[frame_idx].src_addr, nic->node_addr, ETH_ALEN);
  36455. + frame[frame_idx].type = htons(type);
  36456. + memset(&frame[frame_idx].data, 0, sizeof(frame[frame_idx].data));
  36457. + memcpy(&frame[frame_idx].data, packet, size);
  36458. +
  36459. + /* Setup the ring buffer entry to transmit */
  36460. + txd = &tp->tx_ring[entry];
  36461. + txd->addr_hi = 0; /* Etherboot runs under 4GB */
  36462. + txd->addr_lo = virt_to_bus(&frame[frame_idx]);
  36463. + txd->len_flags = ((size + ETH_HLEN) << TXD_LEN_SHIFT) | TXD_FLAG_END;
  36464. + txd->vlan_tag = 0 << TXD_VLAN_TAG_SHIFT;
  36465. +
  36466. + /* Advance to the next entry */
  36467. + entry = NEXT_TX(entry);
  36468. + frame_idx ^= 1;
  36469. +
  36470. + /* Packets are ready, update Tx producer idx local and on card */
  36471. + tw32_mailbox((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry);
  36472. + tw32_mailbox2((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry);
  36473. + tp->tx_prod = entry;
  36474. +}
  36475. +
  36476. +/**************************************************************************
  36477. +DISABLE - Turn off ethernet interface
  36478. +***************************************************************************/
  36479. +static void tg3_disable(struct dev *dev __unused)
  36480. +{
  36481. + struct tg3 *tp = &tg3;
  36482. + /* put the card in its initial state */
  36483. + /* This function serves 3 purposes.
  36484. + * This disables DMA and interrupts so we don't receive
  36485. + * unexpected packets or interrupts from the card after
  36486. + * etherboot has finished.
  36487. + * This frees resources so etherboot may use
  36488. + * this driver on another interface
  36489. + * This allows etherboot to reinitialize the interface
  36490. + * if something is something goes wrong.
  36491. + */
  36492. + tg3_halt(tp);
  36493. + tp->tg3_flags &= ~(TG3_FLAG_INIT_COMPLETE|TG3_FLAG_GOT_SERDES_FLOWCTL);
  36494. + tp->carrier_ok = 0;
  36495. + iounmap((void *)tp->regs);
  36496. +}
  36497. +
  36498. +/**************************************************************************
  36499. +IRQ - Enable, Disable, or Force interrupts
  36500. +***************************************************************************/
  36501. +static void tg3_irq(struct nic *nic __unused, irq_action_t action __unused)
  36502. +{
  36503. + switch ( action ) {
  36504. + case DISABLE :
  36505. + break;
  36506. + case ENABLE :
  36507. + break;
  36508. + case FORCE :
  36509. + break;
  36510. + }
  36511. +}
  36512. +
  36513. +/**************************************************************************
  36514. +PROBE - Look for an adapter, this routine's visible to the outside
  36515. +You should omit the last argument struct pci_device * for a non-PCI NIC
  36516. +***************************************************************************/
  36517. +static int tg3_probe(struct dev *dev, struct pci_device *pdev)
  36518. +{
  36519. + struct nic *nic = (struct nic *)dev;
  36520. + struct tg3 *tp = &tg3;
  36521. + unsigned long tg3reg_base, tg3reg_len;
  36522. + int i, err, pm_cap;
  36523. +
  36524. + if (pdev == 0)
  36525. + return 0;
  36526. +
  36527. + memset(tp, 0, sizeof(*tp));
  36528. +
  36529. + adjust_pci_device(pdev);
  36530. +
  36531. + nic->irqno = 0;
  36532. + nic->ioaddr = pdev->ioaddr & ~3;
  36533. +
  36534. + /* Find power-management capability. */
  36535. + pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
  36536. + if (pm_cap == 0) {
  36537. + printf("Cannot find PowerManagement capability, aborting.\n");
  36538. + return 0;
  36539. + }
  36540. + tg3reg_base = pci_bar_start(pdev, PCI_BASE_ADDRESS_0);
  36541. + if (tg3reg_base == -1UL) {
  36542. + printf("Unuseable bar\n");
  36543. + return 0;
  36544. + }
  36545. + tg3reg_len = pci_bar_size(pdev, PCI_BASE_ADDRESS_0);
  36546. +
  36547. + tp->pdev = pdev;
  36548. + tp->nic = nic;
  36549. + tp->pm_cap = pm_cap;
  36550. + tp->rx_mode = 0;
  36551. + tp->tx_mode = 0;
  36552. + tp->mi_mode = MAC_MI_MODE_BASE;
  36553. + tp->tg3_flags = 0 & ~TG3_FLAG_INIT_COMPLETE;
  36554. +
  36555. + /* The word/byte swap controls here control register access byte
  36556. + * swapping. DMA data byte swapping is controlled in the GRC_MODE
  36557. + * setting below.
  36558. + */
  36559. + tp->misc_host_ctrl =
  36560. + MISC_HOST_CTRL_MASK_PCI_INT |
  36561. + MISC_HOST_CTRL_WORD_SWAP |
  36562. + MISC_HOST_CTRL_INDIR_ACCESS |
  36563. + MISC_HOST_CTRL_PCISTATE_RW;
  36564. +
  36565. + /* The NONFRM (non-frame) byte/word swap controls take effect
  36566. + * on descriptor entries, anything which isn't packet data.
  36567. + *
  36568. + * The StrongARM chips on the board (one for tx, one for rx)
  36569. + * are running in big-endian mode.
  36570. + */
  36571. + tp->grc_mode = (GRC_MODE_WSWAP_DATA | GRC_MODE_BSWAP_DATA |
  36572. + GRC_MODE_WSWAP_NONFRM_DATA);
  36573. +#if __BYTE_ORDER == __BIG_ENDIAN
  36574. + tp->grc_mode |= GRC_MODE_BSWAP_NONFRM_DATA;
  36575. +#endif
  36576. + tp->regs = (unsigned long) ioremap(tg3reg_base, tg3reg_len);
  36577. + if (tp->regs == 0UL) {
  36578. + printf("Cannot map device registers, aborting\n");
  36579. + return 0;
  36580. + }
  36581. +
  36582. + tg3_init_link_config(tp);
  36583. +
  36584. + err = tg3_get_invariants(tp);
  36585. + if (err) {
  36586. + printf("Problem fetching invariants of chip, aborting.\n");
  36587. + goto err_out_iounmap;
  36588. + }
  36589. +
  36590. + err = tg3_get_device_address(tp);
  36591. + if (err) {
  36592. + printf("Could not obtain valid ethernet address, aborting.\n");
  36593. + goto err_out_iounmap;
  36594. + }
  36595. + printf("Ethernet addr: %!\n", nic->node_addr);
  36596. +
  36597. + tg3_setup_dma(tp);
  36598. +
  36599. + /* Now that we have fully setup the chip, save away a snapshot
  36600. + * of the PCI config space. We need to restore this after
  36601. + * GRC_MISC_CFG core clock resets and some resume events.
  36602. + */
  36603. + pci_save_state(tp->pdev, tp->pci_cfg_state);
  36604. +
  36605. + printf("Tigon3 [partno(%s) rev %hx PHY(%s)] (PCI%s:%s:%s)\n",
  36606. + tp->board_part_number,
  36607. + tp->pci_chip_rev_id,
  36608. + tg3_phy_string(tp),
  36609. + ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) ? "X" : ""),
  36610. + ((tp->tg3_flags & TG3_FLAG_PCI_HIGH_SPEED) ?
  36611. + ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) ? "133MHz" : "66MHz") :
  36612. + ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) ? "100MHz" : "33MHz")),
  36613. + ((tp->tg3_flags & TG3_FLAG_PCI_32BIT) ? "32-bit" : "64-bit"));
  36614. +
  36615. +
  36616. + err = tg3_setup_hw(tp);
  36617. + if (err) {
  36618. + goto err_out_disable;
  36619. + }
  36620. + tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
  36621. +
  36622. + /* Wait for a reasonable time for the link to come up */
  36623. + tg3_poll_link(tp);
  36624. + for(i = 0; !tp->carrier_ok && (i < VALID_LINK_TIMEOUT*100); i++) {
  36625. + mdelay(1);
  36626. + tg3_poll_link(tp);
  36627. + }
  36628. + if (!tp->carrier_ok){
  36629. + printf("Valid link not established\n");
  36630. + goto err_out_disable;
  36631. + }
  36632. +
  36633. + dev->disable = tg3_disable;
  36634. + nic->poll = tg3_poll;
  36635. + nic->transmit = tg3_transmit;
  36636. + nic->irq = tg3_irq;
  36637. +
  36638. + return 1;
  36639. +
  36640. + err_out_iounmap:
  36641. + iounmap((void *)tp->regs);
  36642. + return 0;
  36643. + err_out_disable:
  36644. + tg3_disable(dev);
  36645. + return 0;
  36646. +}
  36647. +
  36648. +static struct pci_id tg3_nics[] = {
  36649. +PCI_ROM(0x14e4, 0x1644, "tg3-5700", "Broadcom Tigon 3 5700"),
  36650. +PCI_ROM(0x14e4, 0x1645, "tg3-5701", "Broadcom Tigon 3 5701"),
  36651. +PCI_ROM(0x14e4, 0x1646, "tg3-5702", "Broadcom Tigon 3 5702"),
  36652. +PCI_ROM(0x14e4, 0x1647, "tg3-5703", "Broadcom Tigon 3 5703"),
  36653. +PCI_ROM(0x14e4, 0x1648, "tg3-5704", "Broadcom Tigon 3 5704"),
  36654. +PCI_ROM(0x14e4, 0x164d, "tg3-5702FE", "Broadcom Tigon 3 5702FE"),
  36655. +PCI_ROM(0x14e4, 0x1653, "tg3-5705", "Broadcom Tigon 3 5705"),
  36656. +PCI_ROM(0x14e4, 0x1654, "tg3-5705_2", "Broadcom Tigon 3 5705_2"),
  36657. +PCI_ROM(0x14e4, 0x165d, "tg3-5705M", "Broadcom Tigon 3 5705M"),
  36658. +PCI_ROM(0x14e4, 0x165e, "tg3-5705M_2", "Broadcom Tigon 3 5705M_2"),
  36659. +PCI_ROM(0x14e4, 0x1696, "tg3-5782", "Broadcom Tigon 3 5782"),
  36660. +PCI_ROM(0x14e4, 0x169c, "tg3-5788", "Broadcom Tigon 3 5788"),
  36661. +PCI_ROM(0x14e4, 0x16a6, "tg3-5702X", "Broadcom Tigon 3 5702X"),
  36662. +PCI_ROM(0x14e4, 0x16a7, "tg3-5703X", "Broadcom Tigon 3 5703X"),
  36663. +PCI_ROM(0x14e4, 0x16a8, "tg3-5704S", "Broadcom Tigon 3 5704S"),
  36664. +PCI_ROM(0x14e4, 0x16c6, "tg3-5702A3", "Broadcom Tigon 3 5702A3"),
  36665. +PCI_ROM(0x14e4, 0x16c7, "tg3-5703A3", "Broadcom Tigon 3 5703A3"),
  36666. +PCI_ROM(0x14e4, 0x170d, "tg3-5901", "Broadcom Tigon 3 5901"),
  36667. +PCI_ROM(0x14e4, 0x170e, "tg3-5901_2", "Broadcom Tigon 3 5901_2"),
  36668. +PCI_ROM(0x1148, 0x4400, "tg3-9DXX", "Syskonnect 9DXX"),
  36669. +PCI_ROM(0x1148, 0x4500, "tg3-9MXX", "Syskonnect 9MXX"),
  36670. +PCI_ROM(0x173b, 0x03e8, "tg3-ac1000", "Altima AC1000"),
  36671. +PCI_ROM(0x173b, 0x03e9, "tg3-ac1001", "Altima AC1001"),
  36672. +PCI_ROM(0x173b, 0x03ea, "tg3-ac9100", "Altima AC9100"),
  36673. +PCI_ROM(0x173b, 0x03eb, "tg3-ac1003", "Altima AC1003"),
  36674. +};
  36675. +
  36676. +struct pci_driver tg3_driver = {
  36677. + .type = NIC_DRIVER,
  36678. + .name = "TG3",
  36679. + .probe = tg3_probe,
  36680. + .ids = tg3_nics,
  36681. + .id_count = sizeof(tg3_nics)/sizeof(tg3_nics[0]),
  36682. + .class = 0,
  36683. +};
  36684. Index: b/netboot/tg3.h
  36685. ===================================================================
  36686. --- /dev/null
  36687. +++ b/netboot/tg3.h
  36688. @@ -0,0 +1,2203 @@
  36689. +/* $Id: grub-0.95-diskless-patch-2.patch,v 1.1.1.1 2005/06/14 08:18:50 wesolows Exp $
  36690. + * tg3.h: Definitions for Broadcom Tigon3 ethernet driver.
  36691. + *
  36692. + * Copyright (C) 2001, 2002 David S. Miller (davem@redhat.com)
  36693. + * Copyright (C) 2001 Jeff Garzik (jgarzik@mandrakesoft.com)
  36694. + */
  36695. +
  36696. +#ifndef _T3_H
  36697. +#define _T3_H
  36698. +
  36699. +#include "stdint.h"
  36700. +
  36701. +typedef unsigned long dma_addr_t;
  36702. +
  36703. +/* From mii.h */
  36704. +
  36705. +/* Indicates what features are advertised by the interface. */
  36706. +#define ADVERTISED_10baseT_Half (1 << 0)
  36707. +#define ADVERTISED_10baseT_Full (1 << 1)
  36708. +#define ADVERTISED_100baseT_Half (1 << 2)
  36709. +#define ADVERTISED_100baseT_Full (1 << 3)
  36710. +#define ADVERTISED_1000baseT_Half (1 << 4)
  36711. +#define ADVERTISED_1000baseT_Full (1 << 5)
  36712. +#define ADVERTISED_Autoneg (1 << 6)
  36713. +#define ADVERTISED_TP (1 << 7)
  36714. +#define ADVERTISED_AUI (1 << 8)
  36715. +#define ADVERTISED_MII (1 << 9)
  36716. +#define ADVERTISED_FIBRE (1 << 10)
  36717. +#define ADVERTISED_BNC (1 << 11)
  36718. +
  36719. +/* The following are all involved in forcing a particular link
  36720. + * mode for the device for setting things. When getting the
  36721. + * devices settings, these indicate the current mode and whether
  36722. + * it was foced up into this mode or autonegotiated.
  36723. + */
  36724. +
  36725. +/* The forced speed, 10Mb, 100Mb, gigabit. */
  36726. +#define SPEED_10 0
  36727. +#define SPEED_100 1
  36728. +#define SPEED_1000 2
  36729. +#define SPEED_INVALID 3
  36730. +
  36731. +
  36732. +/* Duplex, half or full. */
  36733. +#define DUPLEX_HALF 0x00
  36734. +#define DUPLEX_FULL 0x01
  36735. +#define DUPLEX_INVALID 0x02
  36736. +
  36737. +/* Which connector port. */
  36738. +#define PORT_TP 0x00
  36739. +#define PORT_AUI 0x01
  36740. +#define PORT_MII 0x02
  36741. +#define PORT_FIBRE 0x03
  36742. +#define PORT_BNC 0x04
  36743. +
  36744. +/* Which tranceiver to use. */
  36745. +#define XCVR_INTERNAL 0x00
  36746. +#define XCVR_EXTERNAL 0x01
  36747. +#define XCVR_DUMMY1 0x02
  36748. +#define XCVR_DUMMY2 0x03
  36749. +#define XCVR_DUMMY3 0x04
  36750. +
  36751. +/* Enable or disable autonegotiation. If this is set to enable,
  36752. + * the forced link modes above are completely ignored.
  36753. + */
  36754. +#define AUTONEG_DISABLE 0x00
  36755. +#define AUTONEG_ENABLE 0x01
  36756. +
  36757. +/* Wake-On-Lan options. */
  36758. +#define WAKE_PHY (1 << 0)
  36759. +#define WAKE_UCAST (1 << 1)
  36760. +#define WAKE_MCAST (1 << 2)
  36761. +#define WAKE_BCAST (1 << 3)
  36762. +#define WAKE_ARP (1 << 4)
  36763. +#define WAKE_MAGIC (1 << 5)
  36764. +#define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */
  36765. +
  36766. +/* Generic MII registers. */
  36767. +
  36768. +#define MII_BMCR 0x00 /* Basic mode control register */
  36769. +#define MII_BMSR 0x01 /* Basic mode status register */
  36770. +#define MII_PHYSID1 0x02 /* PHYS ID 1 */
  36771. +#define MII_PHYSID2 0x03 /* PHYS ID 2 */
  36772. +#define MII_ADVERTISE 0x04 /* Advertisement control reg */
  36773. +#define MII_LPA 0x05 /* Link partner ability reg */
  36774. +#define MII_EXPANSION 0x06 /* Expansion register */
  36775. +#define MII_DCOUNTER 0x12 /* Disconnect counter */
  36776. +#define MII_FCSCOUNTER 0x13 /* False carrier counter */
  36777. +#define MII_NWAYTEST 0x14 /* N-way auto-neg test reg */
  36778. +#define MII_RERRCOUNTER 0x15 /* Receive error counter */
  36779. +#define MII_SREVISION 0x16 /* Silicon revision */
  36780. +#define MII_RESV1 0x17 /* Reserved... */
  36781. +#define MII_LBRERROR 0x18 /* Lpback, rx, bypass error */
  36782. +#define MII_PHYADDR 0x19 /* PHY address */
  36783. +#define MII_RESV2 0x1a /* Reserved... */
  36784. +#define MII_TPISTATUS 0x1b /* TPI status for 10mbps */
  36785. +#define MII_NCONFIG 0x1c /* Network interface config */
  36786. +
  36787. +/* Basic mode control register. */
  36788. +#define BMCR_RESV 0x007f /* Unused... */
  36789. +#define BMCR_CTST 0x0080 /* Collision test */
  36790. +#define BMCR_FULLDPLX 0x0100 /* Full duplex */
  36791. +#define BMCR_ANRESTART 0x0200 /* Auto negotiation restart */
  36792. +#define BMCR_ISOLATE 0x0400 /* Disconnect DP83840 from MII */
  36793. +#define BMCR_PDOWN 0x0800 /* Powerdown the DP83840 */
  36794. +#define BMCR_ANENABLE 0x1000 /* Enable auto negotiation */
  36795. +#define BMCR_SPEED100 0x2000 /* Select 100Mbps */
  36796. +#define BMCR_LOOPBACK 0x4000 /* TXD loopback bits */
  36797. +#define BMCR_RESET 0x8000 /* Reset the DP83840 */
  36798. +
  36799. +/* Basic mode status register. */
  36800. +#define BMSR_ERCAP 0x0001 /* Ext-reg capability */
  36801. +#define BMSR_JCD 0x0002 /* Jabber detected */
  36802. +#define BMSR_LSTATUS 0x0004 /* Link status */
  36803. +#define BMSR_ANEGCAPABLE 0x0008 /* Able to do auto-negotiation */
  36804. +#define BMSR_RFAULT 0x0010 /* Remote fault detected */
  36805. +#define BMSR_ANEGCOMPLETE 0x0020 /* Auto-negotiation complete */
  36806. +#define BMSR_RESV 0x07c0 /* Unused... */
  36807. +#define BMSR_10HALF 0x0800 /* Can do 10mbps, half-duplex */
  36808. +#define BMSR_10FULL 0x1000 /* Can do 10mbps, full-duplex */
  36809. +#define BMSR_100HALF 0x2000 /* Can do 100mbps, half-duplex */
  36810. +#define BMSR_100FULL 0x4000 /* Can do 100mbps, full-duplex */
  36811. +#define BMSR_100BASE4 0x8000 /* Can do 100mbps, 4k packets */
  36812. +
  36813. +/* Advertisement control register. */
  36814. +#define ADVERTISE_SLCT 0x001f /* Selector bits */
  36815. +#define ADVERTISE_CSMA 0x0001 /* Only selector supported */
  36816. +#define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */
  36817. +#define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */
  36818. +#define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */
  36819. +#define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */
  36820. +#define ADVERTISE_100BASE4 0x0200 /* Try for 100mbps 4k packets */
  36821. +#define ADVERTISE_RESV 0x1c00 /* Unused... */
  36822. +#define ADVERTISE_RFAULT 0x2000 /* Say we can detect faults */
  36823. +#define ADVERTISE_LPACK 0x4000 /* Ack link partners response */
  36824. +#define ADVERTISE_NPAGE 0x8000 /* Next page bit */
  36825. +
  36826. +#define ADVERTISE_FULL (ADVERTISE_100FULL | ADVERTISE_10FULL | \
  36827. + ADVERTISE_CSMA)
  36828. +#define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \
  36829. + ADVERTISE_100HALF | ADVERTISE_100FULL)
  36830. +
  36831. +/* Link partner ability register. */
  36832. +#define LPA_SLCT 0x001f /* Same as advertise selector */
  36833. +#define LPA_10HALF 0x0020 /* Can do 10mbps half-duplex */
  36834. +#define LPA_10FULL 0x0040 /* Can do 10mbps full-duplex */
  36835. +#define LPA_100HALF 0x0080 /* Can do 100mbps half-duplex */
  36836. +#define LPA_100FULL 0x0100 /* Can do 100mbps full-duplex */
  36837. +#define LPA_100BASE4 0x0200 /* Can do 100mbps 4k packets */
  36838. +#define LPA_RESV 0x1c00 /* Unused... */
  36839. +#define LPA_RFAULT 0x2000 /* Link partner faulted */
  36840. +#define LPA_LPACK 0x4000 /* Link partner acked us */
  36841. +#define LPA_NPAGE 0x8000 /* Next page bit */
  36842. +
  36843. +#define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
  36844. +#define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
  36845. +
  36846. +/* Expansion register for auto-negotiation. */
  36847. +#define EXPANSION_NWAY 0x0001 /* Can do N-way auto-nego */
  36848. +#define EXPANSION_LCWP 0x0002 /* Got new RX page code word */
  36849. +#define EXPANSION_ENABLENPAGE 0x0004 /* This enables npage words */
  36850. +#define EXPANSION_NPCAPABLE 0x0008 /* Link partner supports npage */
  36851. +#define EXPANSION_MFAULTS 0x0010 /* Multiple faults detected */
  36852. +#define EXPANSION_RESV 0xffe0 /* Unused... */
  36853. +
  36854. +/* N-way test register. */
  36855. +#define NWAYTEST_RESV1 0x00ff /* Unused... */
  36856. +#define NWAYTEST_LOOPBACK 0x0100 /* Enable loopback for N-way */
  36857. +#define NWAYTEST_RESV2 0xfe00 /* Unused... */
  36858. +
  36859. +
  36860. +/* From tg3.h */
  36861. +
  36862. +#define TG3_64BIT_REG_HIGH 0x00UL
  36863. +#define TG3_64BIT_REG_LOW 0x04UL
  36864. +
  36865. +/* Descriptor block info. */
  36866. +#define TG3_BDINFO_HOST_ADDR 0x0UL /* 64-bit */
  36867. +#define TG3_BDINFO_MAXLEN_FLAGS 0x8UL /* 32-bit */
  36868. +#define BDINFO_FLAGS_USE_EXT_RECV 0x00000001 /* ext rx_buffer_desc */
  36869. +#define BDINFO_FLAGS_DISABLED 0x00000002
  36870. +#define BDINFO_FLAGS_MAXLEN_MASK 0xffff0000
  36871. +#define BDINFO_FLAGS_MAXLEN_SHIFT 16
  36872. +#define TG3_BDINFO_NIC_ADDR 0xcUL /* 32-bit */
  36873. +#define TG3_BDINFO_SIZE 0x10UL
  36874. +
  36875. +#define RX_COPY_THRESHOLD 256
  36876. +
  36877. +#define RX_STD_MAX_SIZE 1536
  36878. +#define RX_STD_MAX_SIZE_5705 512
  36879. +#define RX_JUMBO_MAX_SIZE 0xdeadbeef /* XXX */
  36880. +
  36881. +/* First 256 bytes are a mirror of PCI config space. */
  36882. +#define TG3PCI_VENDOR 0x00000000
  36883. +#define TG3PCI_VENDOR_BROADCOM 0x14e4
  36884. +#define TG3PCI_DEVICE 0x00000002
  36885. +#define TG3PCI_DEVICE_TIGON3_1 0x1644 /* BCM5700 */
  36886. +#define TG3PCI_DEVICE_TIGON3_2 0x1645 /* BCM5701 */
  36887. +#define TG3PCI_DEVICE_TIGON3_3 0x1646 /* BCM5702 */
  36888. +#define TG3PCI_DEVICE_TIGON3_4 0x1647 /* BCM5703 */
  36889. +#define TG3PCI_COMMAND 0x00000004
  36890. +#define TG3PCI_STATUS 0x00000006
  36891. +#define TG3PCI_CCREVID 0x00000008
  36892. +#define TG3PCI_CACHELINESZ 0x0000000c
  36893. +#define TG3PCI_LATTIMER 0x0000000d
  36894. +#define TG3PCI_HEADERTYPE 0x0000000e
  36895. +#define TG3PCI_BIST 0x0000000f
  36896. +#define TG3PCI_BASE0_LOW 0x00000010
  36897. +#define TG3PCI_BASE0_HIGH 0x00000014
  36898. +/* 0x18 --> 0x2c unused */
  36899. +#define TG3PCI_SUBSYSVENID 0x0000002c
  36900. +#define TG3PCI_SUBSYSID 0x0000002e
  36901. +#define TG3PCI_ROMADDR 0x00000030
  36902. +#define TG3PCI_CAPLIST 0x00000034
  36903. +/* 0x35 --> 0x3c unused */
  36904. +#define TG3PCI_IRQ_LINE 0x0000003c
  36905. +#define TG3PCI_IRQ_PIN 0x0000003d
  36906. +#define TG3PCI_MIN_GNT 0x0000003e
  36907. +#define TG3PCI_MAX_LAT 0x0000003f
  36908. +#define TG3PCI_X_CAPS 0x00000040
  36909. +#define PCIX_CAPS_RELAXED_ORDERING 0x00020000
  36910. +#define PCIX_CAPS_SPLIT_MASK 0x00700000
  36911. +#define PCIX_CAPS_SPLIT_SHIFT 20
  36912. +#define PCIX_CAPS_BURST_MASK 0x000c0000
  36913. +#define PCIX_CAPS_BURST_SHIFT 18
  36914. +#define PCIX_CAPS_MAX_BURST_CPIOB 2
  36915. +#define TG3PCI_PM_CAP_PTR 0x00000041
  36916. +#define TG3PCI_X_COMMAND 0x00000042
  36917. +#define TG3PCI_X_STATUS 0x00000044
  36918. +#define TG3PCI_PM_CAP_ID 0x00000048
  36919. +#define TG3PCI_VPD_CAP_PTR 0x00000049
  36920. +#define TG3PCI_PM_CAPS 0x0000004a
  36921. +#define TG3PCI_PM_CTRL_STAT 0x0000004c
  36922. +#define TG3PCI_BR_SUPP_EXT 0x0000004e
  36923. +#define TG3PCI_PM_DATA 0x0000004f
  36924. +#define TG3PCI_VPD_CAP_ID 0x00000050
  36925. +#define TG3PCI_MSI_CAP_PTR 0x00000051
  36926. +#define TG3PCI_VPD_ADDR_FLAG 0x00000052
  36927. +#define VPD_ADDR_FLAG_WRITE 0x00008000
  36928. +#define TG3PCI_VPD_DATA 0x00000054
  36929. +#define TG3PCI_MSI_CAP_ID 0x00000058
  36930. +#define TG3PCI_NXT_CAP_PTR 0x00000059
  36931. +#define TG3PCI_MSI_CTRL 0x0000005a
  36932. +#define TG3PCI_MSI_ADDR_LOW 0x0000005c
  36933. +#define TG3PCI_MSI_ADDR_HIGH 0x00000060
  36934. +#define TG3PCI_MSI_DATA 0x00000064
  36935. +/* 0x66 --> 0x68 unused */
  36936. +#define TG3PCI_MISC_HOST_CTRL 0x00000068
  36937. +#define MISC_HOST_CTRL_CLEAR_INT 0x00000001
  36938. +#define MISC_HOST_CTRL_MASK_PCI_INT 0x00000002
  36939. +#define MISC_HOST_CTRL_BYTE_SWAP 0x00000004
  36940. +#define MISC_HOST_CTRL_WORD_SWAP 0x00000008
  36941. +#define MISC_HOST_CTRL_PCISTATE_RW 0x00000010
  36942. +#define MISC_HOST_CTRL_CLKREG_RW 0x00000020
  36943. +#define MISC_HOST_CTRL_REGWORD_SWAP 0x00000040
  36944. +#define MISC_HOST_CTRL_INDIR_ACCESS 0x00000080
  36945. +#define MISC_HOST_CTRL_IRQ_MASK_MODE 0x00000100
  36946. +#define MISC_HOST_CTRL_TAGGED_STATUS 0x00000200
  36947. +#define MISC_HOST_CTRL_CHIPREV 0xffff0000
  36948. +#define MISC_HOST_CTRL_CHIPREV_SHIFT 16
  36949. +#define GET_CHIP_REV_ID(MISC_HOST_CTRL) \
  36950. + (((MISC_HOST_CTRL) & MISC_HOST_CTRL_CHIPREV) >> \
  36951. + MISC_HOST_CTRL_CHIPREV_SHIFT)
  36952. +#define CHIPREV_ID_5700_A0 0x7000
  36953. +#define CHIPREV_ID_5700_A1 0x7001
  36954. +#define CHIPREV_ID_5700_B0 0x7100
  36955. +#define CHIPREV_ID_5700_B1 0x7101
  36956. +#define CHIPREV_ID_5700_B3 0x7102
  36957. +#define CHIPREV_ID_5700_ALTIMA 0x7104
  36958. +#define CHIPREV_ID_5700_C0 0x7200
  36959. +#define CHIPREV_ID_5701_A0 0x0000
  36960. +#define CHIPREV_ID_5701_B0 0x0100
  36961. +#define CHIPREV_ID_5701_B2 0x0102
  36962. +#define CHIPREV_ID_5701_B5 0x0105
  36963. +#define CHIPREV_ID_5703_A0 0x1000
  36964. +#define CHIPREV_ID_5703_A1 0x1001
  36965. +#define CHIPREV_ID_5703_A2 0x1002
  36966. +#define CHIPREV_ID_5703_A3 0x1003
  36967. +#define CHIPREV_ID_5704_A0 0x2000
  36968. +#define CHIPREV_ID_5704_A1 0x2001
  36969. +#define CHIPREV_ID_5704_A2 0x2002
  36970. +#define CHIPREV_ID_5705_A0 0x3000
  36971. +#define CHIPREV_ID_5705_A1 0x3001
  36972. +#define CHIPREV_ID_5705_A2 0x3002
  36973. +#define CHIPREV_ID_5705_A3 0x3003
  36974. +#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12)
  36975. +#define ASIC_REV_5700 0x07
  36976. +#define ASIC_REV_5701 0x00
  36977. +#define ASIC_REV_5703 0x01
  36978. +#define ASIC_REV_5704 0x02
  36979. +#define ASIC_REV_5705 0x03
  36980. +#define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8)
  36981. +#define CHIPREV_5700_AX 0x70
  36982. +#define CHIPREV_5700_BX 0x71
  36983. +#define CHIPREV_5700_CX 0x72
  36984. +#define CHIPREV_5701_AX 0x00
  36985. +#define GET_METAL_REV(CHIP_REV_ID) ((CHIP_REV_ID) & 0xff)
  36986. +#define METAL_REV_A0 0x00
  36987. +#define METAL_REV_A1 0x01
  36988. +#define METAL_REV_B0 0x00
  36989. +#define METAL_REV_B1 0x01
  36990. +#define METAL_REV_B2 0x02
  36991. +#define TG3PCI_DMA_RW_CTRL 0x0000006c
  36992. +#define DMA_RWCTRL_MIN_DMA 0x000000ff
  36993. +#define DMA_RWCTRL_MIN_DMA_SHIFT 0
  36994. +#define DMA_RWCTRL_READ_BNDRY_MASK 0x00000700
  36995. +#define DMA_RWCTRL_READ_BNDRY_DISAB 0x00000000
  36996. +#define DMA_RWCTRL_READ_BNDRY_16 0x00000100
  36997. +#define DMA_RWCTRL_READ_BNDRY_32 0x00000200
  36998. +#define DMA_RWCTRL_READ_BNDRY_64 0x00000300
  36999. +#define DMA_RWCTRL_READ_BNDRY_128 0x00000400
  37000. +#define DMA_RWCTRL_READ_BNDRY_256 0x00000500
  37001. +#define DMA_RWCTRL_READ_BNDRY_512 0x00000600
  37002. +#define DMA_RWCTRL_READ_BNDRY_1024 0x00000700
  37003. +#define DMA_RWCTRL_WRITE_BNDRY_MASK 0x00003800
  37004. +#define DMA_RWCTRL_WRITE_BNDRY_DISAB 0x00000000
  37005. +#define DMA_RWCTRL_WRITE_BNDRY_16 0x00000800
  37006. +#define DMA_RWCTRL_WRITE_BNDRY_32 0x00001000
  37007. +#define DMA_RWCTRL_WRITE_BNDRY_64 0x00001800
  37008. +#define DMA_RWCTRL_WRITE_BNDRY_128 0x00002000
  37009. +#define DMA_RWCTRL_WRITE_BNDRY_256 0x00002800
  37010. +#define DMA_RWCTRL_WRITE_BNDRY_512 0x00003000
  37011. +#define DMA_RWCTRL_WRITE_BNDRY_1024 0x00003800
  37012. +#define DMA_RWCTRL_ONE_DMA 0x00004000
  37013. +#define DMA_RWCTRL_READ_WATER 0x00070000
  37014. +#define DMA_RWCTRL_READ_WATER_SHIFT 16
  37015. +#define DMA_RWCTRL_WRITE_WATER 0x00380000
  37016. +#define DMA_RWCTRL_WRITE_WATER_SHIFT 19
  37017. +#define DMA_RWCTRL_USE_MEM_READ_MULT 0x00400000
  37018. +#define DMA_RWCTRL_ASSERT_ALL_BE 0x00800000
  37019. +#define DMA_RWCTRL_PCI_READ_CMD 0x0f000000
  37020. +#define DMA_RWCTRL_PCI_READ_CMD_SHIFT 24
  37021. +#define DMA_RWCTRL_PCI_WRITE_CMD 0xf0000000
  37022. +#define DMA_RWCTRL_PCI_WRITE_CMD_SHIFT 28
  37023. +#define TG3PCI_PCISTATE 0x00000070
  37024. +#define PCISTATE_FORCE_RESET 0x00000001
  37025. +#define PCISTATE_INT_NOT_ACTIVE 0x00000002
  37026. +#define PCISTATE_CONV_PCI_MODE 0x00000004
  37027. +#define PCISTATE_BUS_SPEED_HIGH 0x00000008
  37028. +#define PCISTATE_BUS_32BIT 0x00000010
  37029. +#define PCISTATE_ROM_ENABLE 0x00000020
  37030. +#define PCISTATE_ROM_RETRY_ENABLE 0x00000040
  37031. +#define PCISTATE_FLAT_VIEW 0x00000100
  37032. +#define PCISTATE_RETRY_SAME_DMA 0x00002000
  37033. +#define TG3PCI_CLOCK_CTRL 0x00000074
  37034. +#define CLOCK_CTRL_CORECLK_DISABLE 0x00000200
  37035. +#define CLOCK_CTRL_RXCLK_DISABLE 0x00000400
  37036. +#define CLOCK_CTRL_TXCLK_DISABLE 0x00000800
  37037. +#define CLOCK_CTRL_ALTCLK 0x00001000
  37038. +#define CLOCK_CTRL_PWRDOWN_PLL133 0x00008000
  37039. +#define CLOCK_CTRL_44MHZ_CORE 0x00040000
  37040. +#define CLOCK_CTRL_625_CORE 0x00100000
  37041. +#define CLOCK_CTRL_FORCE_CLKRUN 0x00200000
  37042. +#define CLOCK_CTRL_CLKRUN_OENABLE 0x00400000
  37043. +#define CLOCK_CTRL_DELAY_PCI_GRANT 0x80000000
  37044. +#define TG3PCI_REG_BASE_ADDR 0x00000078
  37045. +#define TG3PCI_MEM_WIN_BASE_ADDR 0x0000007c
  37046. +#define TG3PCI_REG_DATA 0x00000080
  37047. +#define TG3PCI_MEM_WIN_DATA 0x00000084
  37048. +#define TG3PCI_MODE_CTRL 0x00000088
  37049. +#define TG3PCI_MISC_CFG 0x0000008c
  37050. +#define TG3PCI_MISC_LOCAL_CTRL 0x00000090
  37051. +/* 0x94 --> 0x98 unused */
  37052. +#define TG3PCI_STD_RING_PROD_IDX 0x00000098 /* 64-bit */
  37053. +#define TG3PCI_RCV_RET_RING_CON_IDX 0x000000a0 /* 64-bit */
  37054. +#define TG3PCI_SND_PROD_IDX 0x000000a8 /* 64-bit */
  37055. +/* 0xb0 --> 0x100 unused */
  37056. +
  37057. +/* 0x100 --> 0x200 unused */
  37058. +
  37059. +/* Mailbox registers */
  37060. +#define MAILBOX_INTERRUPT_0 0x00000200 /* 64-bit */
  37061. +#define MAILBOX_INTERRUPT_1 0x00000208 /* 64-bit */
  37062. +#define MAILBOX_INTERRUPT_2 0x00000210 /* 64-bit */
  37063. +#define MAILBOX_INTERRUPT_3 0x00000218 /* 64-bit */
  37064. +#define MAILBOX_GENERAL_0 0x00000220 /* 64-bit */
  37065. +#define MAILBOX_GENERAL_1 0x00000228 /* 64-bit */
  37066. +#define MAILBOX_GENERAL_2 0x00000230 /* 64-bit */
  37067. +#define MAILBOX_GENERAL_3 0x00000238 /* 64-bit */
  37068. +#define MAILBOX_GENERAL_4 0x00000240 /* 64-bit */
  37069. +#define MAILBOX_GENERAL_5 0x00000248 /* 64-bit */
  37070. +#define MAILBOX_GENERAL_6 0x00000250 /* 64-bit */
  37071. +#define MAILBOX_GENERAL_7 0x00000258 /* 64-bit */
  37072. +#define MAILBOX_RELOAD_STAT 0x00000260 /* 64-bit */
  37073. +#define MAILBOX_RCV_STD_PROD_IDX 0x00000268 /* 64-bit */
  37074. +#define MAILBOX_RCV_JUMBO_PROD_IDX 0x00000270 /* 64-bit */
  37075. +#define MAILBOX_RCV_MINI_PROD_IDX 0x00000278 /* 64-bit */
  37076. +#define MAILBOX_RCVRET_CON_IDX_0 0x00000280 /* 64-bit */
  37077. +#define MAILBOX_RCVRET_CON_IDX_1 0x00000288 /* 64-bit */
  37078. +#define MAILBOX_RCVRET_CON_IDX_2 0x00000290 /* 64-bit */
  37079. +#define MAILBOX_RCVRET_CON_IDX_3 0x00000298 /* 64-bit */
  37080. +#define MAILBOX_RCVRET_CON_IDX_4 0x000002a0 /* 64-bit */
  37081. +#define MAILBOX_RCVRET_CON_IDX_5 0x000002a8 /* 64-bit */
  37082. +#define MAILBOX_RCVRET_CON_IDX_6 0x000002b0 /* 64-bit */
  37083. +#define MAILBOX_RCVRET_CON_IDX_7 0x000002b8 /* 64-bit */
  37084. +#define MAILBOX_RCVRET_CON_IDX_8 0x000002c0 /* 64-bit */
  37085. +#define MAILBOX_RCVRET_CON_IDX_9 0x000002c8 /* 64-bit */
  37086. +#define MAILBOX_RCVRET_CON_IDX_10 0x000002d0 /* 64-bit */
  37087. +#define MAILBOX_RCVRET_CON_IDX_11 0x000002d8 /* 64-bit */
  37088. +#define MAILBOX_RCVRET_CON_IDX_12 0x000002e0 /* 64-bit */
  37089. +#define MAILBOX_RCVRET_CON_IDX_13 0x000002e8 /* 64-bit */
  37090. +#define MAILBOX_RCVRET_CON_IDX_14 0x000002f0 /* 64-bit */
  37091. +#define MAILBOX_RCVRET_CON_IDX_15 0x000002f8 /* 64-bit */
  37092. +#define MAILBOX_SNDHOST_PROD_IDX_0 0x00000300 /* 64-bit */
  37093. +#define MAILBOX_SNDHOST_PROD_IDX_1 0x00000308 /* 64-bit */
  37094. +#define MAILBOX_SNDHOST_PROD_IDX_2 0x00000310 /* 64-bit */
  37095. +#define MAILBOX_SNDHOST_PROD_IDX_3 0x00000318 /* 64-bit */
  37096. +#define MAILBOX_SNDHOST_PROD_IDX_4 0x00000320 /* 64-bit */
  37097. +#define MAILBOX_SNDHOST_PROD_IDX_5 0x00000328 /* 64-bit */
  37098. +#define MAILBOX_SNDHOST_PROD_IDX_6 0x00000330 /* 64-bit */
  37099. +#define MAILBOX_SNDHOST_PROD_IDX_7 0x00000338 /* 64-bit */
  37100. +#define MAILBOX_SNDHOST_PROD_IDX_8 0x00000340 /* 64-bit */
  37101. +#define MAILBOX_SNDHOST_PROD_IDX_9 0x00000348 /* 64-bit */
  37102. +#define MAILBOX_SNDHOST_PROD_IDX_10 0x00000350 /* 64-bit */
  37103. +#define MAILBOX_SNDHOST_PROD_IDX_11 0x00000358 /* 64-bit */
  37104. +#define MAILBOX_SNDHOST_PROD_IDX_12 0x00000360 /* 64-bit */
  37105. +#define MAILBOX_SNDHOST_PROD_IDX_13 0x00000368 /* 64-bit */
  37106. +#define MAILBOX_SNDHOST_PROD_IDX_14 0x00000370 /* 64-bit */
  37107. +#define MAILBOX_SNDHOST_PROD_IDX_15 0x00000378 /* 64-bit */
  37108. +#define MAILBOX_SNDNIC_PROD_IDX_0 0x00000380 /* 64-bit */
  37109. +#define MAILBOX_SNDNIC_PROD_IDX_1 0x00000388 /* 64-bit */
  37110. +#define MAILBOX_SNDNIC_PROD_IDX_2 0x00000390 /* 64-bit */
  37111. +#define MAILBOX_SNDNIC_PROD_IDX_3 0x00000398 /* 64-bit */
  37112. +#define MAILBOX_SNDNIC_PROD_IDX_4 0x000003a0 /* 64-bit */
  37113. +#define MAILBOX_SNDNIC_PROD_IDX_5 0x000003a8 /* 64-bit */
  37114. +#define MAILBOX_SNDNIC_PROD_IDX_6 0x000003b0 /* 64-bit */
  37115. +#define MAILBOX_SNDNIC_PROD_IDX_7 0x000003b8 /* 64-bit */
  37116. +#define MAILBOX_SNDNIC_PROD_IDX_8 0x000003c0 /* 64-bit */
  37117. +#define MAILBOX_SNDNIC_PROD_IDX_9 0x000003c8 /* 64-bit */
  37118. +#define MAILBOX_SNDNIC_PROD_IDX_10 0x000003d0 /* 64-bit */
  37119. +#define MAILBOX_SNDNIC_PROD_IDX_11 0x000003d8 /* 64-bit */
  37120. +#define MAILBOX_SNDNIC_PROD_IDX_12 0x000003e0 /* 64-bit */
  37121. +#define MAILBOX_SNDNIC_PROD_IDX_13 0x000003e8 /* 64-bit */
  37122. +#define MAILBOX_SNDNIC_PROD_IDX_14 0x000003f0 /* 64-bit */
  37123. +#define MAILBOX_SNDNIC_PROD_IDX_15 0x000003f8 /* 64-bit */
  37124. +
  37125. +/* MAC control registers */
  37126. +#define MAC_MODE 0x00000400
  37127. +#define MAC_MODE_RESET 0x00000001
  37128. +#define MAC_MODE_HALF_DUPLEX 0x00000002
  37129. +#define MAC_MODE_PORT_MODE_MASK 0x0000000c
  37130. +#define MAC_MODE_PORT_MODE_TBI 0x0000000c
  37131. +#define MAC_MODE_PORT_MODE_GMII 0x00000008
  37132. +#define MAC_MODE_PORT_MODE_MII 0x00000004
  37133. +#define MAC_MODE_PORT_MODE_NONE 0x00000000
  37134. +#define MAC_MODE_PORT_INT_LPBACK 0x00000010
  37135. +#define MAC_MODE_TAGGED_MAC_CTRL 0x00000080
  37136. +#define MAC_MODE_TX_BURSTING 0x00000100
  37137. +#define MAC_MODE_MAX_DEFER 0x00000200
  37138. +#define MAC_MODE_LINK_POLARITY 0x00000400
  37139. +#define MAC_MODE_RXSTAT_ENABLE 0x00000800
  37140. +#define MAC_MODE_RXSTAT_CLEAR 0x00001000
  37141. +#define MAC_MODE_RXSTAT_FLUSH 0x00002000
  37142. +#define MAC_MODE_TXSTAT_ENABLE 0x00004000
  37143. +#define MAC_MODE_TXSTAT_CLEAR 0x00008000
  37144. +#define MAC_MODE_TXSTAT_FLUSH 0x00010000
  37145. +#define MAC_MODE_SEND_CONFIGS 0x00020000
  37146. +#define MAC_MODE_MAGIC_PKT_ENABLE 0x00040000
  37147. +#define MAC_MODE_ACPI_ENABLE 0x00080000
  37148. +#define MAC_MODE_MIP_ENABLE 0x00100000
  37149. +#define MAC_MODE_TDE_ENABLE 0x00200000
  37150. +#define MAC_MODE_RDE_ENABLE 0x00400000
  37151. +#define MAC_MODE_FHDE_ENABLE 0x00800000
  37152. +#define MAC_STATUS 0x00000404
  37153. +#define MAC_STATUS_PCS_SYNCED 0x00000001
  37154. +#define MAC_STATUS_SIGNAL_DET 0x00000002
  37155. +#define MAC_STATUS_RCVD_CFG 0x00000004
  37156. +#define MAC_STATUS_CFG_CHANGED 0x00000008
  37157. +#define MAC_STATUS_SYNC_CHANGED 0x00000010
  37158. +#define MAC_STATUS_PORT_DEC_ERR 0x00000400
  37159. +#define MAC_STATUS_LNKSTATE_CHANGED 0x00001000
  37160. +#define MAC_STATUS_MI_COMPLETION 0x00400000
  37161. +#define MAC_STATUS_MI_INTERRUPT 0x00800000
  37162. +#define MAC_STATUS_AP_ERROR 0x01000000
  37163. +#define MAC_STATUS_ODI_ERROR 0x02000000
  37164. +#define MAC_STATUS_RXSTAT_OVERRUN 0x04000000
  37165. +#define MAC_STATUS_TXSTAT_OVERRUN 0x08000000
  37166. +#define MAC_EVENT 0x00000408
  37167. +#define MAC_EVENT_PORT_DECODE_ERR 0x00000400
  37168. +#define MAC_EVENT_LNKSTATE_CHANGED 0x00001000
  37169. +#define MAC_EVENT_MI_COMPLETION 0x00400000
  37170. +#define MAC_EVENT_MI_INTERRUPT 0x00800000
  37171. +#define MAC_EVENT_AP_ERROR 0x01000000
  37172. +#define MAC_EVENT_ODI_ERROR 0x02000000
  37173. +#define MAC_EVENT_RXSTAT_OVERRUN 0x04000000
  37174. +#define MAC_EVENT_TXSTAT_OVERRUN 0x08000000
  37175. +#define MAC_LED_CTRL 0x0000040c
  37176. +#define LED_CTRL_LNKLED_OVERRIDE 0x00000001
  37177. +#define LED_CTRL_1000MBPS_ON 0x00000002
  37178. +#define LED_CTRL_100MBPS_ON 0x00000004
  37179. +#define LED_CTRL_10MBPS_ON 0x00000008
  37180. +#define LED_CTRL_TRAFFIC_OVERRIDE 0x00000010
  37181. +#define LED_CTRL_TRAFFIC_BLINK 0x00000020
  37182. +#define LED_CTRL_TRAFFIC_LED 0x00000040
  37183. +#define LED_CTRL_1000MBPS_STATUS 0x00000080
  37184. +#define LED_CTRL_100MBPS_STATUS 0x00000100
  37185. +#define LED_CTRL_10MBPS_STATUS 0x00000200
  37186. +#define LED_CTRL_TRAFFIC_STATUS 0x00000400
  37187. +#define LED_CTRL_MAC_MODE 0x00000000
  37188. +#define LED_CTRL_PHY_MODE_1 0x00000800
  37189. +#define LED_CTRL_PHY_MODE_2 0x00001000
  37190. +#define LED_CTRL_BLINK_RATE_MASK 0x7ff80000
  37191. +#define LED_CTRL_BLINK_RATE_SHIFT 19
  37192. +#define LED_CTRL_BLINK_PER_OVERRIDE 0x00080000
  37193. +#define LED_CTRL_BLINK_RATE_OVERRIDE 0x80000000
  37194. +#define MAC_ADDR_0_HIGH 0x00000410 /* upper 2 bytes */
  37195. +#define MAC_ADDR_0_LOW 0x00000414 /* lower 4 bytes */
  37196. +#define MAC_ADDR_1_HIGH 0x00000418 /* upper 2 bytes */
  37197. +#define MAC_ADDR_1_LOW 0x0000041c /* lower 4 bytes */
  37198. +#define MAC_ADDR_2_HIGH 0x00000420 /* upper 2 bytes */
  37199. +#define MAC_ADDR_2_LOW 0x00000424 /* lower 4 bytes */
  37200. +#define MAC_ADDR_3_HIGH 0x00000428 /* upper 2 bytes */
  37201. +#define MAC_ADDR_3_LOW 0x0000042c /* lower 4 bytes */
  37202. +#define MAC_ACPI_MBUF_PTR 0x00000430
  37203. +#define MAC_ACPI_LEN_OFFSET 0x00000434
  37204. +#define ACPI_LENOFF_LEN_MASK 0x0000ffff
  37205. +#define ACPI_LENOFF_LEN_SHIFT 0
  37206. +#define ACPI_LENOFF_OFF_MASK 0x0fff0000
  37207. +#define ACPI_LENOFF_OFF_SHIFT 16
  37208. +#define MAC_TX_BACKOFF_SEED 0x00000438
  37209. +#define TX_BACKOFF_SEED_MASK 0x000003ff
  37210. +#define MAC_RX_MTU_SIZE 0x0000043c
  37211. +#define RX_MTU_SIZE_MASK 0x0000ffff
  37212. +#define MAC_PCS_TEST 0x00000440
  37213. +#define PCS_TEST_PATTERN_MASK 0x000fffff
  37214. +#define PCS_TEST_PATTERN_SHIFT 0
  37215. +#define PCS_TEST_ENABLE 0x00100000
  37216. +#define MAC_TX_AUTO_NEG 0x00000444
  37217. +#define TX_AUTO_NEG_MASK 0x0000ffff
  37218. +#define TX_AUTO_NEG_SHIFT 0
  37219. +#define MAC_RX_AUTO_NEG 0x00000448
  37220. +#define RX_AUTO_NEG_MASK 0x0000ffff
  37221. +#define RX_AUTO_NEG_SHIFT 0
  37222. +#define MAC_MI_COM 0x0000044c
  37223. +#define MI_COM_CMD_MASK 0x0c000000
  37224. +#define MI_COM_CMD_WRITE 0x04000000
  37225. +#define MI_COM_CMD_READ 0x08000000
  37226. +#define MI_COM_READ_FAILED 0x10000000
  37227. +#define MI_COM_START 0x20000000
  37228. +#define MI_COM_BUSY 0x20000000
  37229. +#define MI_COM_PHY_ADDR_MASK 0x03e00000
  37230. +#define MI_COM_PHY_ADDR_SHIFT 21
  37231. +#define MI_COM_REG_ADDR_MASK 0x001f0000
  37232. +#define MI_COM_REG_ADDR_SHIFT 16
  37233. +#define MI_COM_DATA_MASK 0x0000ffff
  37234. +#define MAC_MI_STAT 0x00000450
  37235. +#define MAC_MI_STAT_LNKSTAT_ATTN_ENAB 0x00000001
  37236. +#define MAC_MI_MODE 0x00000454
  37237. +#define MAC_MI_MODE_CLK_10MHZ 0x00000001
  37238. +#define MAC_MI_MODE_SHORT_PREAMBLE 0x00000002
  37239. +#define MAC_MI_MODE_AUTO_POLL 0x00000010
  37240. +#define MAC_MI_MODE_CORE_CLK_62MHZ 0x00008000
  37241. +#define MAC_MI_MODE_BASE 0x000c0000 /* XXX magic values XXX */
  37242. +#define MAC_AUTO_POLL_STATUS 0x00000458
  37243. +#define MAC_AUTO_POLL_ERROR 0x00000001
  37244. +#define MAC_TX_MODE 0x0000045c
  37245. +#define TX_MODE_RESET 0x00000001
  37246. +#define TX_MODE_ENABLE 0x00000002
  37247. +#define TX_MODE_FLOW_CTRL_ENABLE 0x00000010
  37248. +#define TX_MODE_BIG_BCKOFF_ENABLE 0x00000020
  37249. +#define TX_MODE_LONG_PAUSE_ENABLE 0x00000040
  37250. +#define MAC_TX_STATUS 0x00000460
  37251. +#define TX_STATUS_XOFFED 0x00000001
  37252. +#define TX_STATUS_SENT_XOFF 0x00000002
  37253. +#define TX_STATUS_SENT_XON 0x00000004
  37254. +#define TX_STATUS_LINK_UP 0x00000008
  37255. +#define TX_STATUS_ODI_UNDERRUN 0x00000010
  37256. +#define TX_STATUS_ODI_OVERRUN 0x00000020
  37257. +#define MAC_TX_LENGTHS 0x00000464
  37258. +#define TX_LENGTHS_SLOT_TIME_MASK 0x000000ff
  37259. +#define TX_LENGTHS_SLOT_TIME_SHIFT 0
  37260. +#define TX_LENGTHS_IPG_MASK 0x00000f00
  37261. +#define TX_LENGTHS_IPG_SHIFT 8
  37262. +#define TX_LENGTHS_IPG_CRS_MASK 0x00003000
  37263. +#define TX_LENGTHS_IPG_CRS_SHIFT 12
  37264. +#define MAC_RX_MODE 0x00000468
  37265. +#define RX_MODE_RESET 0x00000001
  37266. +#define RX_MODE_ENABLE 0x00000002
  37267. +#define RX_MODE_FLOW_CTRL_ENABLE 0x00000004
  37268. +#define RX_MODE_KEEP_MAC_CTRL 0x00000008
  37269. +#define RX_MODE_KEEP_PAUSE 0x00000010
  37270. +#define RX_MODE_ACCEPT_OVERSIZED 0x00000020
  37271. +#define RX_MODE_ACCEPT_RUNTS 0x00000040
  37272. +#define RX_MODE_LEN_CHECK 0x00000080
  37273. +#define RX_MODE_PROMISC 0x00000100
  37274. +#define RX_MODE_NO_CRC_CHECK 0x00000200
  37275. +#define RX_MODE_KEEP_VLAN_TAG 0x00000400
  37276. +#define MAC_RX_STATUS 0x0000046c
  37277. +#define RX_STATUS_REMOTE_TX_XOFFED 0x00000001
  37278. +#define RX_STATUS_XOFF_RCVD 0x00000002
  37279. +#define RX_STATUS_XON_RCVD 0x00000004
  37280. +#define MAC_HASH_REG_0 0x00000470
  37281. +#define MAC_HASH_REG_1 0x00000474
  37282. +#define MAC_HASH_REG_2 0x00000478
  37283. +#define MAC_HASH_REG_3 0x0000047c
  37284. +#define MAC_RCV_RULE_0 0x00000480
  37285. +#define MAC_RCV_VALUE_0 0x00000484
  37286. +#define MAC_RCV_RULE_1 0x00000488
  37287. +#define MAC_RCV_VALUE_1 0x0000048c
  37288. +#define MAC_RCV_RULE_2 0x00000490
  37289. +#define MAC_RCV_VALUE_2 0x00000494
  37290. +#define MAC_RCV_RULE_3 0x00000498
  37291. +#define MAC_RCV_VALUE_3 0x0000049c
  37292. +#define MAC_RCV_RULE_4 0x000004a0
  37293. +#define MAC_RCV_VALUE_4 0x000004a4
  37294. +#define MAC_RCV_RULE_5 0x000004a8
  37295. +#define MAC_RCV_VALUE_5 0x000004ac
  37296. +#define MAC_RCV_RULE_6 0x000004b0
  37297. +#define MAC_RCV_VALUE_6 0x000004b4
  37298. +#define MAC_RCV_RULE_7 0x000004b8
  37299. +#define MAC_RCV_VALUE_7 0x000004bc
  37300. +#define MAC_RCV_RULE_8 0x000004c0
  37301. +#define MAC_RCV_VALUE_8 0x000004c4
  37302. +#define MAC_RCV_RULE_9 0x000004c8
  37303. +#define MAC_RCV_VALUE_9 0x000004cc
  37304. +#define MAC_RCV_RULE_10 0x000004d0
  37305. +#define MAC_RCV_VALUE_10 0x000004d4
  37306. +#define MAC_RCV_RULE_11 0x000004d8
  37307. +#define MAC_RCV_VALUE_11 0x000004dc
  37308. +#define MAC_RCV_RULE_12 0x000004e0
  37309. +#define MAC_RCV_VALUE_12 0x000004e4
  37310. +#define MAC_RCV_RULE_13 0x000004e8
  37311. +#define MAC_RCV_VALUE_13 0x000004ec
  37312. +#define MAC_RCV_RULE_14 0x000004f0
  37313. +#define MAC_RCV_VALUE_14 0x000004f4
  37314. +#define MAC_RCV_RULE_15 0x000004f8
  37315. +#define MAC_RCV_VALUE_15 0x000004fc
  37316. +#define RCV_RULE_DISABLE_MASK 0x7fffffff
  37317. +#define MAC_RCV_RULE_CFG 0x00000500
  37318. +#define RCV_RULE_CFG_DEFAULT_CLASS 0x00000008
  37319. +#define MAC_LOW_WMARK_MAX_RX_FRAME 0x00000504
  37320. +/* 0x508 --> 0x520 unused */
  37321. +#define MAC_HASHREGU_0 0x00000520
  37322. +#define MAC_HASHREGU_1 0x00000524
  37323. +#define MAC_HASHREGU_2 0x00000528
  37324. +#define MAC_HASHREGU_3 0x0000052c
  37325. +#define MAC_EXTADDR_0_HIGH 0x00000530
  37326. +#define MAC_EXTADDR_0_LOW 0x00000534
  37327. +#define MAC_EXTADDR_1_HIGH 0x00000538
  37328. +#define MAC_EXTADDR_1_LOW 0x0000053c
  37329. +#define MAC_EXTADDR_2_HIGH 0x00000540
  37330. +#define MAC_EXTADDR_2_LOW 0x00000544
  37331. +#define MAC_EXTADDR_3_HIGH 0x00000548
  37332. +#define MAC_EXTADDR_3_LOW 0x0000054c
  37333. +#define MAC_EXTADDR_4_HIGH 0x00000550
  37334. +#define MAC_EXTADDR_4_LOW 0x00000554
  37335. +#define MAC_EXTADDR_5_HIGH 0x00000558
  37336. +#define MAC_EXTADDR_5_LOW 0x0000055c
  37337. +#define MAC_EXTADDR_6_HIGH 0x00000560
  37338. +#define MAC_EXTADDR_6_LOW 0x00000564
  37339. +#define MAC_EXTADDR_7_HIGH 0x00000568
  37340. +#define MAC_EXTADDR_7_LOW 0x0000056c
  37341. +#define MAC_EXTADDR_8_HIGH 0x00000570
  37342. +#define MAC_EXTADDR_8_LOW 0x00000574
  37343. +#define MAC_EXTADDR_9_HIGH 0x00000578
  37344. +#define MAC_EXTADDR_9_LOW 0x0000057c
  37345. +#define MAC_EXTADDR_10_HIGH 0x00000580
  37346. +#define MAC_EXTADDR_10_LOW 0x00000584
  37347. +#define MAC_EXTADDR_11_HIGH 0x00000588
  37348. +#define MAC_EXTADDR_11_LOW 0x0000058c
  37349. +#define MAC_SERDES_CFG 0x00000590
  37350. +#define MAC_SERDES_STAT 0x00000594
  37351. +/* 0x598 --> 0x600 unused */
  37352. +#define MAC_TX_MAC_STATE_BASE 0x00000600 /* 16 bytes */
  37353. +#define MAC_RX_MAC_STATE_BASE 0x00000610 /* 20 bytes */
  37354. +/* 0x624 --> 0x800 unused */
  37355. +#define MAC_TX_STATS_OCTETS 0x00000800
  37356. +#define MAC_TX_STATS_RESV1 0x00000804
  37357. +#define MAC_TX_STATS_COLLISIONS 0x00000808
  37358. +#define MAC_TX_STATS_XON_SENT 0x0000080c
  37359. +#define MAC_TX_STATS_XOFF_SENT 0x00000810
  37360. +#define MAC_TX_STATS_RESV2 0x00000814
  37361. +#define MAC_TX_STATS_MAC_ERRORS 0x00000818
  37362. +#define MAC_TX_STATS_SINGLE_COLLISIONS 0x0000081c
  37363. +#define MAC_TX_STATS_MULT_COLLISIONS 0x00000820
  37364. +#define MAC_TX_STATS_DEFERRED 0x00000824
  37365. +#define MAC_TX_STATS_RESV3 0x00000828
  37366. +#define MAC_TX_STATS_EXCESSIVE_COL 0x0000082c
  37367. +#define MAC_TX_STATS_LATE_COL 0x00000830
  37368. +#define MAC_TX_STATS_RESV4_1 0x00000834
  37369. +#define MAC_TX_STATS_RESV4_2 0x00000838
  37370. +#define MAC_TX_STATS_RESV4_3 0x0000083c
  37371. +#define MAC_TX_STATS_RESV4_4 0x00000840
  37372. +#define MAC_TX_STATS_RESV4_5 0x00000844
  37373. +#define MAC_TX_STATS_RESV4_6 0x00000848
  37374. +#define MAC_TX_STATS_RESV4_7 0x0000084c
  37375. +#define MAC_TX_STATS_RESV4_8 0x00000850
  37376. +#define MAC_TX_STATS_RESV4_9 0x00000854
  37377. +#define MAC_TX_STATS_RESV4_10 0x00000858
  37378. +#define MAC_TX_STATS_RESV4_11 0x0000085c
  37379. +#define MAC_TX_STATS_RESV4_12 0x00000860
  37380. +#define MAC_TX_STATS_RESV4_13 0x00000864
  37381. +#define MAC_TX_STATS_RESV4_14 0x00000868
  37382. +#define MAC_TX_STATS_UCAST 0x0000086c
  37383. +#define MAC_TX_STATS_MCAST 0x00000870
  37384. +#define MAC_TX_STATS_BCAST 0x00000874
  37385. +#define MAC_TX_STATS_RESV5_1 0x00000878
  37386. +#define MAC_TX_STATS_RESV5_2 0x0000087c
  37387. +#define MAC_RX_STATS_OCTETS 0x00000880
  37388. +#define MAC_RX_STATS_RESV1 0x00000884
  37389. +#define MAC_RX_STATS_FRAGMENTS 0x00000888
  37390. +#define MAC_RX_STATS_UCAST 0x0000088c
  37391. +#define MAC_RX_STATS_MCAST 0x00000890
  37392. +#define MAC_RX_STATS_BCAST 0x00000894
  37393. +#define MAC_RX_STATS_FCS_ERRORS 0x00000898
  37394. +#define MAC_RX_STATS_ALIGN_ERRORS 0x0000089c
  37395. +#define MAC_RX_STATS_XON_PAUSE_RECVD 0x000008a0
  37396. +#define MAC_RX_STATS_XOFF_PAUSE_RECVD 0x000008a4
  37397. +#define MAC_RX_STATS_MAC_CTRL_RECVD 0x000008a8
  37398. +#define MAC_RX_STATS_XOFF_ENTERED 0x000008ac
  37399. +#define MAC_RX_STATS_FRAME_TOO_LONG 0x000008b0
  37400. +#define MAC_RX_STATS_JABBERS 0x000008b4
  37401. +#define MAC_RX_STATS_UNDERSIZE 0x000008b8
  37402. +/* 0x8bc --> 0xc00 unused */
  37403. +
  37404. +/* Send data initiator control registers */
  37405. +#define SNDDATAI_MODE 0x00000c00
  37406. +#define SNDDATAI_MODE_RESET 0x00000001
  37407. +#define SNDDATAI_MODE_ENABLE 0x00000002
  37408. +#define SNDDATAI_MODE_STAT_OFLOW_ENAB 0x00000004
  37409. +#define SNDDATAI_STATUS 0x00000c04
  37410. +#define SNDDATAI_STATUS_STAT_OFLOW 0x00000004
  37411. +#define SNDDATAI_STATSCTRL 0x00000c08
  37412. +#define SNDDATAI_SCTRL_ENABLE 0x00000001
  37413. +#define SNDDATAI_SCTRL_FASTUPD 0x00000002
  37414. +#define SNDDATAI_SCTRL_CLEAR 0x00000004
  37415. +#define SNDDATAI_SCTRL_FLUSH 0x00000008
  37416. +#define SNDDATAI_SCTRL_FORCE_ZERO 0x00000010
  37417. +#define SNDDATAI_STATSENAB 0x00000c0c
  37418. +#define SNDDATAI_STATSINCMASK 0x00000c10
  37419. +/* 0xc14 --> 0xc80 unused */
  37420. +#define SNDDATAI_COS_CNT_0 0x00000c80
  37421. +#define SNDDATAI_COS_CNT_1 0x00000c84
  37422. +#define SNDDATAI_COS_CNT_2 0x00000c88
  37423. +#define SNDDATAI_COS_CNT_3 0x00000c8c
  37424. +#define SNDDATAI_COS_CNT_4 0x00000c90
  37425. +#define SNDDATAI_COS_CNT_5 0x00000c94
  37426. +#define SNDDATAI_COS_CNT_6 0x00000c98
  37427. +#define SNDDATAI_COS_CNT_7 0x00000c9c
  37428. +#define SNDDATAI_COS_CNT_8 0x00000ca0
  37429. +#define SNDDATAI_COS_CNT_9 0x00000ca4
  37430. +#define SNDDATAI_COS_CNT_10 0x00000ca8
  37431. +#define SNDDATAI_COS_CNT_11 0x00000cac
  37432. +#define SNDDATAI_COS_CNT_12 0x00000cb0
  37433. +#define SNDDATAI_COS_CNT_13 0x00000cb4
  37434. +#define SNDDATAI_COS_CNT_14 0x00000cb8
  37435. +#define SNDDATAI_COS_CNT_15 0x00000cbc
  37436. +#define SNDDATAI_DMA_RDQ_FULL_CNT 0x00000cc0
  37437. +#define SNDDATAI_DMA_PRIO_RDQ_FULL_CNT 0x00000cc4
  37438. +#define SNDDATAI_SDCQ_FULL_CNT 0x00000cc8
  37439. +#define SNDDATAI_NICRNG_SSND_PIDX_CNT 0x00000ccc
  37440. +#define SNDDATAI_STATS_UPDATED_CNT 0x00000cd0
  37441. +#define SNDDATAI_INTERRUPTS_CNT 0x00000cd4
  37442. +#define SNDDATAI_AVOID_INTERRUPTS_CNT 0x00000cd8
  37443. +#define SNDDATAI_SND_THRESH_HIT_CNT 0x00000cdc
  37444. +/* 0xce0 --> 0x1000 unused */
  37445. +
  37446. +/* Send data completion control registers */
  37447. +#define SNDDATAC_MODE 0x00001000
  37448. +#define SNDDATAC_MODE_RESET 0x00000001
  37449. +#define SNDDATAC_MODE_ENABLE 0x00000002
  37450. +/* 0x1004 --> 0x1400 unused */
  37451. +
  37452. +/* Send BD ring selector */
  37453. +#define SNDBDS_MODE 0x00001400
  37454. +#define SNDBDS_MODE_RESET 0x00000001
  37455. +#define SNDBDS_MODE_ENABLE 0x00000002
  37456. +#define SNDBDS_MODE_ATTN_ENABLE 0x00000004
  37457. +#define SNDBDS_STATUS 0x00001404
  37458. +#define SNDBDS_STATUS_ERROR_ATTN 0x00000004
  37459. +#define SNDBDS_HWDIAG 0x00001408
  37460. +/* 0x140c --> 0x1440 */
  37461. +#define SNDBDS_SEL_CON_IDX_0 0x00001440
  37462. +#define SNDBDS_SEL_CON_IDX_1 0x00001444
  37463. +#define SNDBDS_SEL_CON_IDX_2 0x00001448
  37464. +#define SNDBDS_SEL_CON_IDX_3 0x0000144c
  37465. +#define SNDBDS_SEL_CON_IDX_4 0x00001450
  37466. +#define SNDBDS_SEL_CON_IDX_5 0x00001454
  37467. +#define SNDBDS_SEL_CON_IDX_6 0x00001458
  37468. +#define SNDBDS_SEL_CON_IDX_7 0x0000145c
  37469. +#define SNDBDS_SEL_CON_IDX_8 0x00001460
  37470. +#define SNDBDS_SEL_CON_IDX_9 0x00001464
  37471. +#define SNDBDS_SEL_CON_IDX_10 0x00001468
  37472. +#define SNDBDS_SEL_CON_IDX_11 0x0000146c
  37473. +#define SNDBDS_SEL_CON_IDX_12 0x00001470
  37474. +#define SNDBDS_SEL_CON_IDX_13 0x00001474
  37475. +#define SNDBDS_SEL_CON_IDX_14 0x00001478
  37476. +#define SNDBDS_SEL_CON_IDX_15 0x0000147c
  37477. +/* 0x1480 --> 0x1800 unused */
  37478. +
  37479. +/* Send BD initiator control registers */
  37480. +#define SNDBDI_MODE 0x00001800
  37481. +#define SNDBDI_MODE_RESET 0x00000001
  37482. +#define SNDBDI_MODE_ENABLE 0x00000002
  37483. +#define SNDBDI_MODE_ATTN_ENABLE 0x00000004
  37484. +#define SNDBDI_STATUS 0x00001804
  37485. +#define SNDBDI_STATUS_ERROR_ATTN 0x00000004
  37486. +#define SNDBDI_IN_PROD_IDX_0 0x00001808
  37487. +#define SNDBDI_IN_PROD_IDX_1 0x0000180c
  37488. +#define SNDBDI_IN_PROD_IDX_2 0x00001810
  37489. +#define SNDBDI_IN_PROD_IDX_3 0x00001814
  37490. +#define SNDBDI_IN_PROD_IDX_4 0x00001818
  37491. +#define SNDBDI_IN_PROD_IDX_5 0x0000181c
  37492. +#define SNDBDI_IN_PROD_IDX_6 0x00001820
  37493. +#define SNDBDI_IN_PROD_IDX_7 0x00001824
  37494. +#define SNDBDI_IN_PROD_IDX_8 0x00001828
  37495. +#define SNDBDI_IN_PROD_IDX_9 0x0000182c
  37496. +#define SNDBDI_IN_PROD_IDX_10 0x00001830
  37497. +#define SNDBDI_IN_PROD_IDX_11 0x00001834
  37498. +#define SNDBDI_IN_PROD_IDX_12 0x00001838
  37499. +#define SNDBDI_IN_PROD_IDX_13 0x0000183c
  37500. +#define SNDBDI_IN_PROD_IDX_14 0x00001840
  37501. +#define SNDBDI_IN_PROD_IDX_15 0x00001844
  37502. +/* 0x1848 --> 0x1c00 unused */
  37503. +
  37504. +/* Send BD completion control registers */
  37505. +#define SNDBDC_MODE 0x00001c00
  37506. +#define SNDBDC_MODE_RESET 0x00000001
  37507. +#define SNDBDC_MODE_ENABLE 0x00000002
  37508. +#define SNDBDC_MODE_ATTN_ENABLE 0x00000004
  37509. +/* 0x1c04 --> 0x2000 unused */
  37510. +
  37511. +/* Receive list placement control registers */
  37512. +#define RCVLPC_MODE 0x00002000
  37513. +#define RCVLPC_MODE_RESET 0x00000001
  37514. +#define RCVLPC_MODE_ENABLE 0x00000002
  37515. +#define RCVLPC_MODE_CLASS0_ATTN_ENAB 0x00000004
  37516. +#define RCVLPC_MODE_MAPOOR_AATTN_ENAB 0x00000008
  37517. +#define RCVLPC_MODE_STAT_OFLOW_ENAB 0x00000010
  37518. +#define RCVLPC_STATUS 0x00002004
  37519. +#define RCVLPC_STATUS_CLASS0 0x00000004
  37520. +#define RCVLPC_STATUS_MAPOOR 0x00000008
  37521. +#define RCVLPC_STATUS_STAT_OFLOW 0x00000010
  37522. +#define RCVLPC_LOCK 0x00002008
  37523. +#define RCVLPC_LOCK_REQ_MASK 0x0000ffff
  37524. +#define RCVLPC_LOCK_REQ_SHIFT 0
  37525. +#define RCVLPC_LOCK_GRANT_MASK 0xffff0000
  37526. +#define RCVLPC_LOCK_GRANT_SHIFT 16
  37527. +#define RCVLPC_NON_EMPTY_BITS 0x0000200c
  37528. +#define RCVLPC_NON_EMPTY_BITS_MASK 0x0000ffff
  37529. +#define RCVLPC_CONFIG 0x00002010
  37530. +#define RCVLPC_STATSCTRL 0x00002014
  37531. +#define RCVLPC_STATSCTRL_ENABLE 0x00000001
  37532. +#define RCVLPC_STATSCTRL_FASTUPD 0x00000002
  37533. +#define RCVLPC_STATS_ENABLE 0x00002018
  37534. +#define RCVLPC_STATSENAB_LNGBRST_RFIX 0x00400000
  37535. +#define RCVLPC_STATS_INCMASK 0x0000201c
  37536. +/* 0x2020 --> 0x2100 unused */
  37537. +#define RCVLPC_SELLST_BASE 0x00002100 /* 16 16-byte entries */
  37538. +#define SELLST_TAIL 0x00000004
  37539. +#define SELLST_CONT 0x00000008
  37540. +#define SELLST_UNUSED 0x0000000c
  37541. +#define RCVLPC_COS_CNTL_BASE 0x00002200 /* 16 4-byte entries */
  37542. +#define RCVLPC_DROP_FILTER_CNT 0x00002240
  37543. +#define RCVLPC_DMA_WQ_FULL_CNT 0x00002244
  37544. +#define RCVLPC_DMA_HIPRIO_WQ_FULL_CNT 0x00002248
  37545. +#define RCVLPC_NO_RCV_BD_CNT 0x0000224c
  37546. +#define RCVLPC_IN_DISCARDS_CNT 0x00002250
  37547. +#define RCVLPC_IN_ERRORS_CNT 0x00002254
  37548. +#define RCVLPC_RCV_THRESH_HIT_CNT 0x00002258
  37549. +/* 0x225c --> 0x2400 unused */
  37550. +
  37551. +/* Receive Data and Receive BD Initiator Control */
  37552. +#define RCVDBDI_MODE 0x00002400
  37553. +#define RCVDBDI_MODE_RESET 0x00000001
  37554. +#define RCVDBDI_MODE_ENABLE 0x00000002
  37555. +#define RCVDBDI_MODE_JUMBOBD_NEEDED 0x00000004
  37556. +#define RCVDBDI_MODE_FRM_TOO_BIG 0x00000008
  37557. +#define RCVDBDI_MODE_INV_RING_SZ 0x00000010
  37558. +#define RCVDBDI_STATUS 0x00002404
  37559. +#define RCVDBDI_STATUS_JUMBOBD_NEEDED 0x00000004
  37560. +#define RCVDBDI_STATUS_FRM_TOO_BIG 0x00000008
  37561. +#define RCVDBDI_STATUS_INV_RING_SZ 0x00000010
  37562. +#define RCVDBDI_SPLIT_FRAME_MINSZ 0x00002408
  37563. +/* 0x240c --> 0x2440 unused */
  37564. +#define RCVDBDI_JUMBO_BD 0x00002440 /* TG3_BDINFO_... */
  37565. +#define RCVDBDI_STD_BD 0x00002450 /* TG3_BDINFO_... */
  37566. +#define RCVDBDI_MINI_BD 0x00002460 /* TG3_BDINFO_... */
  37567. +#define RCVDBDI_JUMBO_CON_IDX 0x00002470
  37568. +#define RCVDBDI_STD_CON_IDX 0x00002474
  37569. +#define RCVDBDI_MINI_CON_IDX 0x00002478
  37570. +/* 0x247c --> 0x2480 unused */
  37571. +#define RCVDBDI_BD_PROD_IDX_0 0x00002480
  37572. +#define RCVDBDI_BD_PROD_IDX_1 0x00002484
  37573. +#define RCVDBDI_BD_PROD_IDX_2 0x00002488
  37574. +#define RCVDBDI_BD_PROD_IDX_3 0x0000248c
  37575. +#define RCVDBDI_BD_PROD_IDX_4 0x00002490
  37576. +#define RCVDBDI_BD_PROD_IDX_5 0x00002494
  37577. +#define RCVDBDI_BD_PROD_IDX_6 0x00002498
  37578. +#define RCVDBDI_BD_PROD_IDX_7 0x0000249c
  37579. +#define RCVDBDI_BD_PROD_IDX_8 0x000024a0
  37580. +#define RCVDBDI_BD_PROD_IDX_9 0x000024a4
  37581. +#define RCVDBDI_BD_PROD_IDX_10 0x000024a8
  37582. +#define RCVDBDI_BD_PROD_IDX_11 0x000024ac
  37583. +#define RCVDBDI_BD_PROD_IDX_12 0x000024b0
  37584. +#define RCVDBDI_BD_PROD_IDX_13 0x000024b4
  37585. +#define RCVDBDI_BD_PROD_IDX_14 0x000024b8
  37586. +#define RCVDBDI_BD_PROD_IDX_15 0x000024bc
  37587. +#define RCVDBDI_HWDIAG 0x000024c0
  37588. +/* 0x24c4 --> 0x2800 unused */
  37589. +
  37590. +/* Receive Data Completion Control */
  37591. +#define RCVDCC_MODE 0x00002800
  37592. +#define RCVDCC_MODE_RESET 0x00000001
  37593. +#define RCVDCC_MODE_ENABLE 0x00000002
  37594. +#define RCVDCC_MODE_ATTN_ENABLE 0x00000004
  37595. +/* 0x2804 --> 0x2c00 unused */
  37596. +
  37597. +/* Receive BD Initiator Control Registers */
  37598. +#define RCVBDI_MODE 0x00002c00
  37599. +#define RCVBDI_MODE_RESET 0x00000001
  37600. +#define RCVBDI_MODE_ENABLE 0x00000002
  37601. +#define RCVBDI_MODE_RCB_ATTN_ENAB 0x00000004
  37602. +#define RCVBDI_STATUS 0x00002c04
  37603. +#define RCVBDI_STATUS_RCB_ATTN 0x00000004
  37604. +#define RCVBDI_JUMBO_PROD_IDX 0x00002c08
  37605. +#define RCVBDI_STD_PROD_IDX 0x00002c0c
  37606. +#define RCVBDI_MINI_PROD_IDX 0x00002c10
  37607. +#define RCVBDI_MINI_THRESH 0x00002c14
  37608. +#define RCVBDI_STD_THRESH 0x00002c18
  37609. +#define RCVBDI_JUMBO_THRESH 0x00002c1c
  37610. +/* 0x2c20 --> 0x3000 unused */
  37611. +
  37612. +/* Receive BD Completion Control Registers */
  37613. +#define RCVCC_MODE 0x00003000
  37614. +#define RCVCC_MODE_RESET 0x00000001
  37615. +#define RCVCC_MODE_ENABLE 0x00000002
  37616. +#define RCVCC_MODE_ATTN_ENABLE 0x00000004
  37617. +#define RCVCC_STATUS 0x00003004
  37618. +#define RCVCC_STATUS_ERROR_ATTN 0x00000004
  37619. +#define RCVCC_JUMP_PROD_IDX 0x00003008
  37620. +#define RCVCC_STD_PROD_IDX 0x0000300c
  37621. +#define RCVCC_MINI_PROD_IDX 0x00003010
  37622. +/* 0x3014 --> 0x3400 unused */
  37623. +
  37624. +/* Receive list selector control registers */
  37625. +#define RCVLSC_MODE 0x00003400
  37626. +#define RCVLSC_MODE_RESET 0x00000001
  37627. +#define RCVLSC_MODE_ENABLE 0x00000002
  37628. +#define RCVLSC_MODE_ATTN_ENABLE 0x00000004
  37629. +#define RCVLSC_STATUS 0x00003404
  37630. +#define RCVLSC_STATUS_ERROR_ATTN 0x00000004
  37631. +/* 0x3408 --> 0x3800 unused */
  37632. +
  37633. +/* Mbuf cluster free registers */
  37634. +#define MBFREE_MODE 0x00003800
  37635. +#define MBFREE_MODE_RESET 0x00000001
  37636. +#define MBFREE_MODE_ENABLE 0x00000002
  37637. +#define MBFREE_STATUS 0x00003804
  37638. +/* 0x3808 --> 0x3c00 unused */
  37639. +
  37640. +/* Host coalescing control registers */
  37641. +#define HOSTCC_MODE 0x00003c00
  37642. +#define HOSTCC_MODE_RESET 0x00000001
  37643. +#define HOSTCC_MODE_ENABLE 0x00000002
  37644. +#define HOSTCC_MODE_ATTN 0x00000004
  37645. +#define HOSTCC_MODE_NOW 0x00000008
  37646. +#define HOSTCC_MODE_FULL_STATUS 0x00000000
  37647. +#define HOSTCC_MODE_64BYTE 0x00000080
  37648. +#define HOSTCC_MODE_32BYTE 0x00000100
  37649. +#define HOSTCC_MODE_CLRTICK_RXBD 0x00000200
  37650. +#define HOSTCC_MODE_CLRTICK_TXBD 0x00000400
  37651. +#define HOSTCC_MODE_NOINT_ON_NOW 0x00000800
  37652. +#define HOSTCC_MODE_NOINT_ON_FORCE 0x00001000
  37653. +#define HOSTCC_STATUS 0x00003c04
  37654. +#define HOSTCC_STATUS_ERROR_ATTN 0x00000004
  37655. +#define HOSTCC_RXCOL_TICKS 0x00003c08
  37656. +#define LOW_RXCOL_TICKS 0x00000032
  37657. +#define DEFAULT_RXCOL_TICKS 0x00000048
  37658. +#define HIGH_RXCOL_TICKS 0x00000096
  37659. +#define HOSTCC_TXCOL_TICKS 0x00003c0c
  37660. +#define LOW_TXCOL_TICKS 0x00000096
  37661. +#define DEFAULT_TXCOL_TICKS 0x0000012c
  37662. +#define HIGH_TXCOL_TICKS 0x00000145
  37663. +#define HOSTCC_RXMAX_FRAMES 0x00003c10
  37664. +#define LOW_RXMAX_FRAMES 0x00000005
  37665. +#define DEFAULT_RXMAX_FRAMES 0x00000008
  37666. +#define HIGH_RXMAX_FRAMES 0x00000012
  37667. +#define HOSTCC_TXMAX_FRAMES 0x00003c14
  37668. +#define LOW_TXMAX_FRAMES 0x00000035
  37669. +#define DEFAULT_TXMAX_FRAMES 0x0000004b
  37670. +#define HIGH_TXMAX_FRAMES 0x00000052
  37671. +#define HOSTCC_RXCOAL_TICK_INT 0x00003c18
  37672. +#define DEFAULT_RXCOAL_TICK_INT 0x00000019
  37673. +#define HOSTCC_TXCOAL_TICK_INT 0x00003c1c
  37674. +#define DEFAULT_TXCOAL_TICK_INT 0x00000019
  37675. +#define HOSTCC_RXCOAL_MAXF_INT 0x00003c20
  37676. +#define DEFAULT_RXCOAL_MAXF_INT 0x00000005
  37677. +#define HOSTCC_TXCOAL_MAXF_INT 0x00003c24
  37678. +#define DEFAULT_TXCOAL_MAXF_INT 0x00000005
  37679. +#define HOSTCC_STAT_COAL_TICKS 0x00003c28
  37680. +#define DEFAULT_STAT_COAL_TICKS 0x000f4240
  37681. +/* 0x3c2c --> 0x3c30 unused */
  37682. +#define HOSTCC_STATS_BLK_HOST_ADDR 0x00003c30 /* 64-bit */
  37683. +#define HOSTCC_STATUS_BLK_HOST_ADDR 0x00003c38 /* 64-bit */
  37684. +#define HOSTCC_STATS_BLK_NIC_ADDR 0x00003c40
  37685. +#define HOSTCC_STATUS_BLK_NIC_ADDR 0x00003c44
  37686. +#define HOSTCC_FLOW_ATTN 0x00003c48
  37687. +/* 0x3c4c --> 0x3c50 unused */
  37688. +#define HOSTCC_JUMBO_CON_IDX 0x00003c50
  37689. +#define HOSTCC_STD_CON_IDX 0x00003c54
  37690. +#define HOSTCC_MINI_CON_IDX 0x00003c58
  37691. +/* 0x3c5c --> 0x3c80 unused */
  37692. +#define HOSTCC_RET_PROD_IDX_0 0x00003c80
  37693. +#define HOSTCC_RET_PROD_IDX_1 0x00003c84
  37694. +#define HOSTCC_RET_PROD_IDX_2 0x00003c88
  37695. +#define HOSTCC_RET_PROD_IDX_3 0x00003c8c
  37696. +#define HOSTCC_RET_PROD_IDX_4 0x00003c90
  37697. +#define HOSTCC_RET_PROD_IDX_5 0x00003c94
  37698. +#define HOSTCC_RET_PROD_IDX_6 0x00003c98
  37699. +#define HOSTCC_RET_PROD_IDX_7 0x00003c9c
  37700. +#define HOSTCC_RET_PROD_IDX_8 0x00003ca0
  37701. +#define HOSTCC_RET_PROD_IDX_9 0x00003ca4
  37702. +#define HOSTCC_RET_PROD_IDX_10 0x00003ca8
  37703. +#define HOSTCC_RET_PROD_IDX_11 0x00003cac
  37704. +#define HOSTCC_RET_PROD_IDX_12 0x00003cb0
  37705. +#define HOSTCC_RET_PROD_IDX_13 0x00003cb4
  37706. +#define HOSTCC_RET_PROD_IDX_14 0x00003cb8
  37707. +#define HOSTCC_RET_PROD_IDX_15 0x00003cbc
  37708. +#define HOSTCC_SND_CON_IDX_0 0x00003cc0
  37709. +#define HOSTCC_SND_CON_IDX_1 0x00003cc4
  37710. +#define HOSTCC_SND_CON_IDX_2 0x00003cc8
  37711. +#define HOSTCC_SND_CON_IDX_3 0x00003ccc
  37712. +#define HOSTCC_SND_CON_IDX_4 0x00003cd0
  37713. +#define HOSTCC_SND_CON_IDX_5 0x00003cd4
  37714. +#define HOSTCC_SND_CON_IDX_6 0x00003cd8
  37715. +#define HOSTCC_SND_CON_IDX_7 0x00003cdc
  37716. +#define HOSTCC_SND_CON_IDX_8 0x00003ce0
  37717. +#define HOSTCC_SND_CON_IDX_9 0x00003ce4
  37718. +#define HOSTCC_SND_CON_IDX_10 0x00003ce8
  37719. +#define HOSTCC_SND_CON_IDX_11 0x00003cec
  37720. +#define HOSTCC_SND_CON_IDX_12 0x00003cf0
  37721. +#define HOSTCC_SND_CON_IDX_13 0x00003cf4
  37722. +#define HOSTCC_SND_CON_IDX_14 0x00003cf8
  37723. +#define HOSTCC_SND_CON_IDX_15 0x00003cfc
  37724. +/* 0x3d00 --> 0x4000 unused */
  37725. +
  37726. +/* Memory arbiter control registers */
  37727. +#define MEMARB_MODE 0x00004000
  37728. +#define MEMARB_MODE_RESET 0x00000001
  37729. +#define MEMARB_MODE_ENABLE 0x00000002
  37730. +#define MEMARB_STATUS 0x00004004
  37731. +#define MEMARB_TRAP_ADDR_LOW 0x00004008
  37732. +#define MEMARB_TRAP_ADDR_HIGH 0x0000400c
  37733. +/* 0x4010 --> 0x4400 unused */
  37734. +
  37735. +/* Buffer manager control registers */
  37736. +#define BUFMGR_MODE 0x00004400
  37737. +#define BUFMGR_MODE_RESET 0x00000001
  37738. +#define BUFMGR_MODE_ENABLE 0x00000002
  37739. +#define BUFMGR_MODE_ATTN_ENABLE 0x00000004
  37740. +#define BUFMGR_MODE_BM_TEST 0x00000008
  37741. +#define BUFMGR_MODE_MBLOW_ATTN_ENAB 0x00000010
  37742. +#define BUFMGR_STATUS 0x00004404
  37743. +#define BUFMGR_STATUS_ERROR 0x00000004
  37744. +#define BUFMGR_STATUS_MBLOW 0x00000010
  37745. +#define BUFMGR_MB_POOL_ADDR 0x00004408
  37746. +#define BUFMGR_MB_POOL_SIZE 0x0000440c
  37747. +#define BUFMGR_MB_RDMA_LOW_WATER 0x00004410
  37748. +#define DEFAULT_MB_RDMA_LOW_WATER 0x00000050
  37749. +#define DEFAULT_MB_RDMA_LOW_WATER_5705 0x00000000
  37750. +#define DEFAULT_MB_RDMA_LOW_WATER_JUMBO 0x00000130
  37751. +#define BUFMGR_MB_MACRX_LOW_WATER 0x00004414
  37752. +#define DEFAULT_MB_MACRX_LOW_WATER 0x00000020
  37753. +#define DEFAULT_MB_MACRX_LOW_WATER_5705 0x00000010
  37754. +#define DEFAULT_MB_MACRX_LOW_WATER_JUMBO 0x00000098
  37755. +#define BUFMGR_MB_HIGH_WATER 0x00004418
  37756. +#define DEFAULT_MB_HIGH_WATER 0x00000060
  37757. +#define DEFAULT_MB_HIGH_WATER_5705 0x00000060
  37758. +#define DEFAULT_MB_HIGH_WATER_JUMBO 0x0000017c
  37759. +#define BUFMGR_RX_MB_ALLOC_REQ 0x0000441c
  37760. +#define BUFMGR_MB_ALLOC_BIT 0x10000000
  37761. +#define BUFMGR_RX_MB_ALLOC_RESP 0x00004420
  37762. +#define BUFMGR_TX_MB_ALLOC_REQ 0x00004424
  37763. +#define BUFMGR_TX_MB_ALLOC_RESP 0x00004428
  37764. +#define BUFMGR_DMA_DESC_POOL_ADDR 0x0000442c
  37765. +#define BUFMGR_DMA_DESC_POOL_SIZE 0x00004430
  37766. +#define BUFMGR_DMA_LOW_WATER 0x00004434
  37767. +#define DEFAULT_DMA_LOW_WATER 0x00000005
  37768. +#define BUFMGR_DMA_HIGH_WATER 0x00004438
  37769. +#define DEFAULT_DMA_HIGH_WATER 0x0000000a
  37770. +#define BUFMGR_RX_DMA_ALLOC_REQ 0x0000443c
  37771. +#define BUFMGR_RX_DMA_ALLOC_RESP 0x00004440
  37772. +#define BUFMGR_TX_DMA_ALLOC_REQ 0x00004444
  37773. +#define BUFMGR_TX_DMA_ALLOC_RESP 0x00004448
  37774. +#define BUFMGR_HWDIAG_0 0x0000444c
  37775. +#define BUFMGR_HWDIAG_1 0x00004450
  37776. +#define BUFMGR_HWDIAG_2 0x00004454
  37777. +/* 0x4458 --> 0x4800 unused */
  37778. +
  37779. +/* Read DMA control registers */
  37780. +#define RDMAC_MODE 0x00004800
  37781. +#define RDMAC_MODE_RESET 0x00000001
  37782. +#define RDMAC_MODE_ENABLE 0x00000002
  37783. +#define RDMAC_MODE_TGTABORT_ENAB 0x00000004
  37784. +#define RDMAC_MODE_MSTABORT_ENAB 0x00000008
  37785. +#define RDMAC_MODE_PARITYERR_ENAB 0x00000010
  37786. +#define RDMAC_MODE_ADDROFLOW_ENAB 0x00000020
  37787. +#define RDMAC_MODE_FIFOOFLOW_ENAB 0x00000040
  37788. +#define RDMAC_MODE_FIFOURUN_ENAB 0x00000080
  37789. +#define RDMAC_MODE_FIFOOREAD_ENAB 0x00000100
  37790. +#define RDMAC_MODE_LNGREAD_ENAB 0x00000200
  37791. +#define RDMAC_MODE_SPLIT_ENABLE 0x00000800
  37792. +#define RDMAC_MODE_SPLIT_RESET 0x00001000
  37793. +#define RDMAC_MODE_FIFO_SIZE_128 0x00020000
  37794. +#define RDMAC_MODE_FIFO_LONG_BURST 0x00030000
  37795. +#define RDMAC_STATUS 0x00004804
  37796. +#define RDMAC_STATUS_TGTABORT 0x00000004
  37797. +#define RDMAC_STATUS_MSTABORT 0x00000008
  37798. +#define RDMAC_STATUS_PARITYERR 0x00000010
  37799. +#define RDMAC_STATUS_ADDROFLOW 0x00000020
  37800. +#define RDMAC_STATUS_FIFOOFLOW 0x00000040
  37801. +#define RDMAC_STATUS_FIFOURUN 0x00000080
  37802. +#define RDMAC_STATUS_FIFOOREAD 0x00000100
  37803. +#define RDMAC_STATUS_LNGREAD 0x00000200
  37804. +/* 0x4808 --> 0x4c00 unused */
  37805. +
  37806. +/* Write DMA control registers */
  37807. +#define WDMAC_MODE 0x00004c00
  37808. +#define WDMAC_MODE_RESET 0x00000001
  37809. +#define WDMAC_MODE_ENABLE 0x00000002
  37810. +#define WDMAC_MODE_TGTABORT_ENAB 0x00000004
  37811. +#define WDMAC_MODE_MSTABORT_ENAB 0x00000008
  37812. +#define WDMAC_MODE_PARITYERR_ENAB 0x00000010
  37813. +#define WDMAC_MODE_ADDROFLOW_ENAB 0x00000020
  37814. +#define WDMAC_MODE_FIFOOFLOW_ENAB 0x00000040
  37815. +#define WDMAC_MODE_FIFOURUN_ENAB 0x00000080
  37816. +#define WDMAC_MODE_FIFOOREAD_ENAB 0x00000100
  37817. +#define WDMAC_MODE_LNGREAD_ENAB 0x00000200
  37818. +#define WDMAC_MODE_RX_ACCEL 0x00000400
  37819. +#define WDMAC_STATUS 0x00004c04
  37820. +#define WDMAC_STATUS_TGTABORT 0x00000004
  37821. +#define WDMAC_STATUS_MSTABORT 0x00000008
  37822. +#define WDMAC_STATUS_PARITYERR 0x00000010
  37823. +#define WDMAC_STATUS_ADDROFLOW 0x00000020
  37824. +#define WDMAC_STATUS_FIFOOFLOW 0x00000040
  37825. +#define WDMAC_STATUS_FIFOURUN 0x00000080
  37826. +#define WDMAC_STATUS_FIFOOREAD 0x00000100
  37827. +#define WDMAC_STATUS_LNGREAD 0x00000200
  37828. +/* 0x4c08 --> 0x5000 unused */
  37829. +
  37830. +/* Per-cpu register offsets (arm9) */
  37831. +#define CPU_MODE 0x00000000
  37832. +#define CPU_MODE_RESET 0x00000001
  37833. +#define CPU_MODE_HALT 0x00000400
  37834. +#define CPU_STATE 0x00000004
  37835. +#define CPU_EVTMASK 0x00000008
  37836. +/* 0xc --> 0x1c reserved */
  37837. +#define CPU_PC 0x0000001c
  37838. +#define CPU_INSN 0x00000020
  37839. +#define CPU_SPAD_UFLOW 0x00000024
  37840. +#define CPU_WDOG_CLEAR 0x00000028
  37841. +#define CPU_WDOG_VECTOR 0x0000002c
  37842. +#define CPU_WDOG_PC 0x00000030
  37843. +#define CPU_HW_BP 0x00000034
  37844. +/* 0x38 --> 0x44 unused */
  37845. +#define CPU_WDOG_SAVED_STATE 0x00000044
  37846. +#define CPU_LAST_BRANCH_ADDR 0x00000048
  37847. +#define CPU_SPAD_UFLOW_SET 0x0000004c
  37848. +/* 0x50 --> 0x200 unused */
  37849. +#define CPU_R0 0x00000200
  37850. +#define CPU_R1 0x00000204
  37851. +#define CPU_R2 0x00000208
  37852. +#define CPU_R3 0x0000020c
  37853. +#define CPU_R4 0x00000210
  37854. +#define CPU_R5 0x00000214
  37855. +#define CPU_R6 0x00000218
  37856. +#define CPU_R7 0x0000021c
  37857. +#define CPU_R8 0x00000220
  37858. +#define CPU_R9 0x00000224
  37859. +#define CPU_R10 0x00000228
  37860. +#define CPU_R11 0x0000022c
  37861. +#define CPU_R12 0x00000230
  37862. +#define CPU_R13 0x00000234
  37863. +#define CPU_R14 0x00000238
  37864. +#define CPU_R15 0x0000023c
  37865. +#define CPU_R16 0x00000240
  37866. +#define CPU_R17 0x00000244
  37867. +#define CPU_R18 0x00000248
  37868. +#define CPU_R19 0x0000024c
  37869. +#define CPU_R20 0x00000250
  37870. +#define CPU_R21 0x00000254
  37871. +#define CPU_R22 0x00000258
  37872. +#define CPU_R23 0x0000025c
  37873. +#define CPU_R24 0x00000260
  37874. +#define CPU_R25 0x00000264
  37875. +#define CPU_R26 0x00000268
  37876. +#define CPU_R27 0x0000026c
  37877. +#define CPU_R28 0x00000270
  37878. +#define CPU_R29 0x00000274
  37879. +#define CPU_R30 0x00000278
  37880. +#define CPU_R31 0x0000027c
  37881. +/* 0x280 --> 0x400 unused */
  37882. +
  37883. +#define RX_CPU_BASE 0x00005000
  37884. +#define TX_CPU_BASE 0x00005400
  37885. +
  37886. +/* Mailboxes */
  37887. +#define GRCMBOX_INTERRUPT_0 0x00005800 /* 64-bit */
  37888. +#define GRCMBOX_INTERRUPT_1 0x00005808 /* 64-bit */
  37889. +#define GRCMBOX_INTERRUPT_2 0x00005810 /* 64-bit */
  37890. +#define GRCMBOX_INTERRUPT_3 0x00005818 /* 64-bit */
  37891. +#define GRCMBOX_GENERAL_0 0x00005820 /* 64-bit */
  37892. +#define GRCMBOX_GENERAL_1 0x00005828 /* 64-bit */
  37893. +#define GRCMBOX_GENERAL_2 0x00005830 /* 64-bit */
  37894. +#define GRCMBOX_GENERAL_3 0x00005838 /* 64-bit */
  37895. +#define GRCMBOX_GENERAL_4 0x00005840 /* 64-bit */
  37896. +#define GRCMBOX_GENERAL_5 0x00005848 /* 64-bit */
  37897. +#define GRCMBOX_GENERAL_6 0x00005850 /* 64-bit */
  37898. +#define GRCMBOX_GENERAL_7 0x00005858 /* 64-bit */
  37899. +#define GRCMBOX_RELOAD_STAT 0x00005860 /* 64-bit */
  37900. +#define GRCMBOX_RCVSTD_PROD_IDX 0x00005868 /* 64-bit */
  37901. +#define GRCMBOX_RCVJUMBO_PROD_IDX 0x00005870 /* 64-bit */
  37902. +#define GRCMBOX_RCVMINI_PROD_IDX 0x00005878 /* 64-bit */
  37903. +#define GRCMBOX_RCVRET_CON_IDX_0 0x00005880 /* 64-bit */
  37904. +#define GRCMBOX_RCVRET_CON_IDX_1 0x00005888 /* 64-bit */
  37905. +#define GRCMBOX_RCVRET_CON_IDX_2 0x00005890 /* 64-bit */
  37906. +#define GRCMBOX_RCVRET_CON_IDX_3 0x00005898 /* 64-bit */
  37907. +#define GRCMBOX_RCVRET_CON_IDX_4 0x000058a0 /* 64-bit */
  37908. +#define GRCMBOX_RCVRET_CON_IDX_5 0x000058a8 /* 64-bit */
  37909. +#define GRCMBOX_RCVRET_CON_IDX_6 0x000058b0 /* 64-bit */
  37910. +#define GRCMBOX_RCVRET_CON_IDX_7 0x000058b8 /* 64-bit */
  37911. +#define GRCMBOX_RCVRET_CON_IDX_8 0x000058c0 /* 64-bit */
  37912. +#define GRCMBOX_RCVRET_CON_IDX_9 0x000058c8 /* 64-bit */
  37913. +#define GRCMBOX_RCVRET_CON_IDX_10 0x000058d0 /* 64-bit */
  37914. +#define GRCMBOX_RCVRET_CON_IDX_11 0x000058d8 /* 64-bit */
  37915. +#define GRCMBOX_RCVRET_CON_IDX_12 0x000058e0 /* 64-bit */
  37916. +#define GRCMBOX_RCVRET_CON_IDX_13 0x000058e8 /* 64-bit */
  37917. +#define GRCMBOX_RCVRET_CON_IDX_14 0x000058f0 /* 64-bit */
  37918. +#define GRCMBOX_RCVRET_CON_IDX_15 0x000058f8 /* 64-bit */
  37919. +#define GRCMBOX_SNDHOST_PROD_IDX_0 0x00005900 /* 64-bit */
  37920. +#define GRCMBOX_SNDHOST_PROD_IDX_1 0x00005908 /* 64-bit */
  37921. +#define GRCMBOX_SNDHOST_PROD_IDX_2 0x00005910 /* 64-bit */
  37922. +#define GRCMBOX_SNDHOST_PROD_IDX_3 0x00005918 /* 64-bit */
  37923. +#define GRCMBOX_SNDHOST_PROD_IDX_4 0x00005920 /* 64-bit */
  37924. +#define GRCMBOX_SNDHOST_PROD_IDX_5 0x00005928 /* 64-bit */
  37925. +#define GRCMBOX_SNDHOST_PROD_IDX_6 0x00005930 /* 64-bit */
  37926. +#define GRCMBOX_SNDHOST_PROD_IDX_7 0x00005938 /* 64-bit */
  37927. +#define GRCMBOX_SNDHOST_PROD_IDX_8 0x00005940 /* 64-bit */
  37928. +#define GRCMBOX_SNDHOST_PROD_IDX_9 0x00005948 /* 64-bit */
  37929. +#define GRCMBOX_SNDHOST_PROD_IDX_10 0x00005950 /* 64-bit */
  37930. +#define GRCMBOX_SNDHOST_PROD_IDX_11 0x00005958 /* 64-bit */
  37931. +#define GRCMBOX_SNDHOST_PROD_IDX_12 0x00005960 /* 64-bit */
  37932. +#define GRCMBOX_SNDHOST_PROD_IDX_13 0x00005968 /* 64-bit */
  37933. +#define GRCMBOX_SNDHOST_PROD_IDX_14 0x00005970 /* 64-bit */
  37934. +#define GRCMBOX_SNDHOST_PROD_IDX_15 0x00005978 /* 64-bit */
  37935. +#define GRCMBOX_SNDNIC_PROD_IDX_0 0x00005980 /* 64-bit */
  37936. +#define GRCMBOX_SNDNIC_PROD_IDX_1 0x00005988 /* 64-bit */
  37937. +#define GRCMBOX_SNDNIC_PROD_IDX_2 0x00005990 /* 64-bit */
  37938. +#define GRCMBOX_SNDNIC_PROD_IDX_3 0x00005998 /* 64-bit */
  37939. +#define GRCMBOX_SNDNIC_PROD_IDX_4 0x000059a0 /* 64-bit */
  37940. +#define GRCMBOX_SNDNIC_PROD_IDX_5 0x000059a8 /* 64-bit */
  37941. +#define GRCMBOX_SNDNIC_PROD_IDX_6 0x000059b0 /* 64-bit */
  37942. +#define GRCMBOX_SNDNIC_PROD_IDX_7 0x000059b8 /* 64-bit */
  37943. +#define GRCMBOX_SNDNIC_PROD_IDX_8 0x000059c0 /* 64-bit */
  37944. +#define GRCMBOX_SNDNIC_PROD_IDX_9 0x000059c8 /* 64-bit */
  37945. +#define GRCMBOX_SNDNIC_PROD_IDX_10 0x000059d0 /* 64-bit */
  37946. +#define GRCMBOX_SNDNIC_PROD_IDX_11 0x000059d8 /* 64-bit */
  37947. +#define GRCMBOX_SNDNIC_PROD_IDX_12 0x000059e0 /* 64-bit */
  37948. +#define GRCMBOX_SNDNIC_PROD_IDX_13 0x000059e8 /* 64-bit */
  37949. +#define GRCMBOX_SNDNIC_PROD_IDX_14 0x000059f0 /* 64-bit */
  37950. +#define GRCMBOX_SNDNIC_PROD_IDX_15 0x000059f8 /* 64-bit */
  37951. +#define GRCMBOX_HIGH_PRIO_EV_VECTOR 0x00005a00
  37952. +#define GRCMBOX_HIGH_PRIO_EV_MASK 0x00005a04
  37953. +#define GRCMBOX_LOW_PRIO_EV_VEC 0x00005a08
  37954. +#define GRCMBOX_LOW_PRIO_EV_MASK 0x00005a0c
  37955. +/* 0x5a10 --> 0x5c00 */
  37956. +
  37957. +/* Flow Through queues */
  37958. +#define FTQ_RESET 0x00005c00
  37959. +/* 0x5c04 --> 0x5c10 unused */
  37960. +#define FTQ_DMA_NORM_READ_CTL 0x00005c10
  37961. +#define FTQ_DMA_NORM_READ_FULL_CNT 0x00005c14
  37962. +#define FTQ_DMA_NORM_READ_FIFO_ENQDEQ 0x00005c18
  37963. +#define FTQ_DMA_NORM_READ_WRITE_PEEK 0x00005c1c
  37964. +#define FTQ_DMA_HIGH_READ_CTL 0x00005c20
  37965. +#define FTQ_DMA_HIGH_READ_FULL_CNT 0x00005c24
  37966. +#define FTQ_DMA_HIGH_READ_FIFO_ENQDEQ 0x00005c28
  37967. +#define FTQ_DMA_HIGH_READ_WRITE_PEEK 0x00005c2c
  37968. +#define FTQ_DMA_COMP_DISC_CTL 0x00005c30
  37969. +#define FTQ_DMA_COMP_DISC_FULL_CNT 0x00005c34
  37970. +#define FTQ_DMA_COMP_DISC_FIFO_ENQDEQ 0x00005c38
  37971. +#define FTQ_DMA_COMP_DISC_WRITE_PEEK 0x00005c3c
  37972. +#define FTQ_SEND_BD_COMP_CTL 0x00005c40
  37973. +#define FTQ_SEND_BD_COMP_FULL_CNT 0x00005c44
  37974. +#define FTQ_SEND_BD_COMP_FIFO_ENQDEQ 0x00005c48
  37975. +#define FTQ_SEND_BD_COMP_WRITE_PEEK 0x00005c4c
  37976. +#define FTQ_SEND_DATA_INIT_CTL 0x00005c50
  37977. +#define FTQ_SEND_DATA_INIT_FULL_CNT 0x00005c54
  37978. +#define FTQ_SEND_DATA_INIT_FIFO_ENQDEQ 0x00005c58
  37979. +#define FTQ_SEND_DATA_INIT_WRITE_PEEK 0x00005c5c
  37980. +#define FTQ_DMA_NORM_WRITE_CTL 0x00005c60
  37981. +#define FTQ_DMA_NORM_WRITE_FULL_CNT 0x00005c64
  37982. +#define FTQ_DMA_NORM_WRITE_FIFO_ENQDEQ 0x00005c68
  37983. +#define FTQ_DMA_NORM_WRITE_WRITE_PEEK 0x00005c6c
  37984. +#define FTQ_DMA_HIGH_WRITE_CTL 0x00005c70
  37985. +#define FTQ_DMA_HIGH_WRITE_FULL_CNT 0x00005c74
  37986. +#define FTQ_DMA_HIGH_WRITE_FIFO_ENQDEQ 0x00005c78
  37987. +#define FTQ_DMA_HIGH_WRITE_WRITE_PEEK 0x00005c7c
  37988. +#define FTQ_SWTYPE1_CTL 0x00005c80
  37989. +#define FTQ_SWTYPE1_FULL_CNT 0x00005c84
  37990. +#define FTQ_SWTYPE1_FIFO_ENQDEQ 0x00005c88
  37991. +#define FTQ_SWTYPE1_WRITE_PEEK 0x00005c8c
  37992. +#define FTQ_SEND_DATA_COMP_CTL 0x00005c90
  37993. +#define FTQ_SEND_DATA_COMP_FULL_CNT 0x00005c94
  37994. +#define FTQ_SEND_DATA_COMP_FIFO_ENQDEQ 0x00005c98
  37995. +#define FTQ_SEND_DATA_COMP_WRITE_PEEK 0x00005c9c
  37996. +#define FTQ_HOST_COAL_CTL 0x00005ca0
  37997. +#define FTQ_HOST_COAL_FULL_CNT 0x00005ca4
  37998. +#define FTQ_HOST_COAL_FIFO_ENQDEQ 0x00005ca8
  37999. +#define FTQ_HOST_COAL_WRITE_PEEK 0x00005cac
  38000. +#define FTQ_MAC_TX_CTL 0x00005cb0
  38001. +#define FTQ_MAC_TX_FULL_CNT 0x00005cb4
  38002. +#define FTQ_MAC_TX_FIFO_ENQDEQ 0x00005cb8
  38003. +#define FTQ_MAC_TX_WRITE_PEEK 0x00005cbc
  38004. +#define FTQ_MB_FREE_CTL 0x00005cc0
  38005. +#define FTQ_MB_FREE_FULL_CNT 0x00005cc4
  38006. +#define FTQ_MB_FREE_FIFO_ENQDEQ 0x00005cc8
  38007. +#define FTQ_MB_FREE_WRITE_PEEK 0x00005ccc
  38008. +#define FTQ_RCVBD_COMP_CTL 0x00005cd0
  38009. +#define FTQ_RCVBD_COMP_FULL_CNT 0x00005cd4
  38010. +#define FTQ_RCVBD_COMP_FIFO_ENQDEQ 0x00005cd8
  38011. +#define FTQ_RCVBD_COMP_WRITE_PEEK 0x00005cdc
  38012. +#define FTQ_RCVLST_PLMT_CTL 0x00005ce0
  38013. +#define FTQ_RCVLST_PLMT_FULL_CNT 0x00005ce4
  38014. +#define FTQ_RCVLST_PLMT_FIFO_ENQDEQ 0x00005ce8
  38015. +#define FTQ_RCVLST_PLMT_WRITE_PEEK 0x00005cec
  38016. +#define FTQ_RCVDATA_INI_CTL 0x00005cf0
  38017. +#define FTQ_RCVDATA_INI_FULL_CNT 0x00005cf4
  38018. +#define FTQ_RCVDATA_INI_FIFO_ENQDEQ 0x00005cf8
  38019. +#define FTQ_RCVDATA_INI_WRITE_PEEK 0x00005cfc
  38020. +#define FTQ_RCVDATA_COMP_CTL 0x00005d00
  38021. +#define FTQ_RCVDATA_COMP_FULL_CNT 0x00005d04
  38022. +#define FTQ_RCVDATA_COMP_FIFO_ENQDEQ 0x00005d08
  38023. +#define FTQ_RCVDATA_COMP_WRITE_PEEK 0x00005d0c
  38024. +#define FTQ_SWTYPE2_CTL 0x00005d10
  38025. +#define FTQ_SWTYPE2_FULL_CNT 0x00005d14
  38026. +#define FTQ_SWTYPE2_FIFO_ENQDEQ 0x00005d18
  38027. +#define FTQ_SWTYPE2_WRITE_PEEK 0x00005d1c
  38028. +/* 0x5d20 --> 0x6000 unused */
  38029. +
  38030. +/* Message signaled interrupt registers */
  38031. +#define MSGINT_MODE 0x00006000
  38032. +#define MSGINT_MODE_RESET 0x00000001
  38033. +#define MSGINT_MODE_ENABLE 0x00000002
  38034. +#define MSGINT_STATUS 0x00006004
  38035. +#define MSGINT_FIFO 0x00006008
  38036. +/* 0x600c --> 0x6400 unused */
  38037. +
  38038. +/* DMA completion registers */
  38039. +#define DMAC_MODE 0x00006400
  38040. +#define DMAC_MODE_RESET 0x00000001
  38041. +#define DMAC_MODE_ENABLE 0x00000002
  38042. +/* 0x6404 --> 0x6800 unused */
  38043. +
  38044. +/* GRC registers */
  38045. +#define GRC_MODE 0x00006800
  38046. +#define GRC_MODE_UPD_ON_COAL 0x00000001
  38047. +#define GRC_MODE_BSWAP_NONFRM_DATA 0x00000002
  38048. +#define GRC_MODE_WSWAP_NONFRM_DATA 0x00000004
  38049. +#define GRC_MODE_BSWAP_DATA 0x00000010
  38050. +#define GRC_MODE_WSWAP_DATA 0x00000020
  38051. +#define GRC_MODE_SPLITHDR 0x00000100
  38052. +#define GRC_MODE_NOFRM_CRACKING 0x00000200
  38053. +#define GRC_MODE_INCL_CRC 0x00000400
  38054. +#define GRC_MODE_ALLOW_BAD_FRMS 0x00000800
  38055. +#define GRC_MODE_NOIRQ_ON_SENDS 0x00002000
  38056. +#define GRC_MODE_NOIRQ_ON_RCV 0x00004000
  38057. +#define GRC_MODE_FORCE_PCI32BIT 0x00008000
  38058. +#define GRC_MODE_HOST_STACKUP 0x00010000
  38059. +#define GRC_MODE_HOST_SENDBDS 0x00020000
  38060. +#define GRC_MODE_NO_TX_PHDR_CSUM 0x00100000
  38061. +#define GRC_MODE_NO_RX_PHDR_CSUM 0x00800000
  38062. +#define GRC_MODE_IRQ_ON_TX_CPU_ATTN 0x01000000
  38063. +#define GRC_MODE_IRQ_ON_RX_CPU_ATTN 0x02000000
  38064. +#define GRC_MODE_IRQ_ON_MAC_ATTN 0x04000000
  38065. +#define GRC_MODE_IRQ_ON_DMA_ATTN 0x08000000
  38066. +#define GRC_MODE_IRQ_ON_FLOW_ATTN 0x10000000
  38067. +#define GRC_MODE_4X_NIC_SEND_RINGS 0x20000000
  38068. +#define GRC_MODE_MCAST_FRM_ENABLE 0x40000000
  38069. +#define GRC_MISC_CFG 0x00006804
  38070. +#define GRC_MISC_CFG_CORECLK_RESET 0x00000001
  38071. +#define GRC_MISC_CFG_PRESCALAR_MASK 0x000000fe
  38072. +#define GRC_MISC_CFG_PRESCALAR_SHIFT 1
  38073. +#define GRC_MISC_CFG_BOARD_ID_MASK 0x0001e000
  38074. +#define GRC_MISC_CFG_BOARD_ID_5700 0x0001e000
  38075. +#define GRC_MISC_CFG_BOARD_ID_5701 0x00000000
  38076. +#define GRC_MISC_CFG_BOARD_ID_5702FE 0x00004000
  38077. +#define GRC_MISC_CFG_BOARD_ID_5703 0x00000000
  38078. +#define GRC_MISC_CFG_BOARD_ID_5703S 0x00002000
  38079. +#define GRC_MISC_CFG_BOARD_ID_5704 0x00000000
  38080. +#define GRC_MISC_CFG_BOARD_ID_5704CIOBE 0x00004000
  38081. +#define GRC_MISC_CFG_BOARD_ID_5704_A2 0x00008000
  38082. +#define GRC_MISC_CFG_BOARD_ID_5788 0x00010000
  38083. +#define GRC_MISC_CFG_BOARD_ID_5788M 0x00018000
  38084. +#define GRC_MISC_CFG_BOARD_ID_AC91002A1 0x00018000
  38085. +#define GRC_MISC_CFG_KEEP_GPHY_POWER 0x04000000
  38086. +#define GRC_LOCAL_CTRL 0x00006808
  38087. +#define GRC_LCLCTRL_INT_ACTIVE 0x00000001
  38088. +#define GRC_LCLCTRL_CLEARINT 0x00000002
  38089. +#define GRC_LCLCTRL_SETINT 0x00000004
  38090. +#define GRC_LCLCTRL_INT_ON_ATTN 0x00000008
  38091. +#define GRC_LCLCTRL_GPIO_INPUT0 0x00000100
  38092. +#define GRC_LCLCTRL_GPIO_INPUT1 0x00000200
  38093. +#define GRC_LCLCTRL_GPIO_INPUT2 0x00000400
  38094. +#define GRC_LCLCTRL_GPIO_OE0 0x00000800
  38095. +#define GRC_LCLCTRL_GPIO_OE1 0x00001000
  38096. +#define GRC_LCLCTRL_GPIO_OE2 0x00002000
  38097. +#define GRC_LCLCTRL_GPIO_OUTPUT0 0x00004000
  38098. +#define GRC_LCLCTRL_GPIO_OUTPUT1 0x00008000
  38099. +#define GRC_LCLCTRL_GPIO_OUTPUT2 0x00010000
  38100. +#define GRC_LCLCTRL_EXTMEM_ENABLE 0x00020000
  38101. +#define GRC_LCLCTRL_MEMSZ_MASK 0x001c0000
  38102. +#define GRC_LCLCTRL_MEMSZ_256K 0x00000000
  38103. +#define GRC_LCLCTRL_MEMSZ_512K 0x00040000
  38104. +#define GRC_LCLCTRL_MEMSZ_1M 0x00080000
  38105. +#define GRC_LCLCTRL_MEMSZ_2M 0x000c0000
  38106. +#define GRC_LCLCTRL_MEMSZ_4M 0x00100000
  38107. +#define GRC_LCLCTRL_MEMSZ_8M 0x00140000
  38108. +#define GRC_LCLCTRL_MEMSZ_16M 0x00180000
  38109. +#define GRC_LCLCTRL_BANK_SELECT 0x00200000
  38110. +#define GRC_LCLCTRL_SSRAM_TYPE 0x00400000
  38111. +#define GRC_LCLCTRL_AUTO_SEEPROM 0x01000000
  38112. +#define GRC_TIMER 0x0000680c
  38113. +#define GRC_RX_CPU_EVENT 0x00006810
  38114. +#define GRC_RX_TIMER_REF 0x00006814
  38115. +#define GRC_RX_CPU_SEM 0x00006818
  38116. +#define GRC_REMOTE_RX_CPU_ATTN 0x0000681c
  38117. +#define GRC_TX_CPU_EVENT 0x00006820
  38118. +#define GRC_TX_TIMER_REF 0x00006824
  38119. +#define GRC_TX_CPU_SEM 0x00006828
  38120. +#define GRC_REMOTE_TX_CPU_ATTN 0x0000682c
  38121. +#define GRC_MEM_POWER_UP 0x00006830 /* 64-bit */
  38122. +#define GRC_EEPROM_ADDR 0x00006838
  38123. +#define EEPROM_ADDR_WRITE 0x00000000
  38124. +#define EEPROM_ADDR_READ 0x80000000
  38125. +#define EEPROM_ADDR_COMPLETE 0x40000000
  38126. +#define EEPROM_ADDR_FSM_RESET 0x20000000
  38127. +#define EEPROM_ADDR_DEVID_MASK 0x1c000000
  38128. +#define EEPROM_ADDR_DEVID_SHIFT 26
  38129. +#define EEPROM_ADDR_START 0x02000000
  38130. +#define EEPROM_ADDR_CLKPERD_SHIFT 16
  38131. +#define EEPROM_ADDR_ADDR_MASK 0x0000ffff
  38132. +#define EEPROM_ADDR_ADDR_SHIFT 0
  38133. +#define EEPROM_DEFAULT_CLOCK_PERIOD 0x60
  38134. +#define EEPROM_CHIP_SIZE (64 * 1024)
  38135. +#define GRC_EEPROM_DATA 0x0000683c
  38136. +#define GRC_EEPROM_CTRL 0x00006840
  38137. +#define GRC_MDI_CTRL 0x00006844
  38138. +#define GRC_SEEPROM_DELAY 0x00006848
  38139. +/* 0x684c --> 0x6c00 unused */
  38140. +
  38141. +/* 0x6c00 --> 0x7000 unused */
  38142. +
  38143. +/* NVRAM Control registers */
  38144. +#define NVRAM_CMD 0x00007000
  38145. +#define NVRAM_CMD_RESET 0x00000001
  38146. +#define NVRAM_CMD_DONE 0x00000008
  38147. +#define NVRAM_CMD_GO 0x00000010
  38148. +#define NVRAM_CMD_WR 0x00000020
  38149. +#define NVRAM_CMD_RD 0x00000000
  38150. +#define NVRAM_CMD_ERASE 0x00000040
  38151. +#define NVRAM_CMD_FIRST 0x00000080
  38152. +#define NVRAM_CMD_LAST 0x00000100
  38153. +#define NVRAM_STAT 0x00007004
  38154. +#define NVRAM_WRDATA 0x00007008
  38155. +#define NVRAM_ADDR 0x0000700c
  38156. +#define NVRAM_ADDR_MSK 0x00ffffff
  38157. +#define NVRAM_RDDATA 0x00007010
  38158. +#define NVRAM_CFG1 0x00007014
  38159. +#define NVRAM_CFG1_FLASHIF_ENAB 0x00000001
  38160. +#define NVRAM_CFG1_BUFFERED_MODE 0x00000002
  38161. +#define NVRAM_CFG1_PASS_THRU 0x00000004
  38162. +#define NVRAM_CFG1_BIT_BANG 0x00000008
  38163. +#define NVRAM_CFG1_COMPAT_BYPASS 0x80000000
  38164. +#define NVRAM_CFG2 0x00007018
  38165. +#define NVRAM_CFG3 0x0000701c
  38166. +#define NVRAM_SWARB 0x00007020
  38167. +#define SWARB_REQ_SET0 0x00000001
  38168. +#define SWARB_REQ_SET1 0x00000002
  38169. +#define SWARB_REQ_SET2 0x00000004
  38170. +#define SWARB_REQ_SET3 0x00000008
  38171. +#define SWARB_REQ_CLR0 0x00000010
  38172. +#define SWARB_REQ_CLR1 0x00000020
  38173. +#define SWARB_REQ_CLR2 0x00000040
  38174. +#define SWARB_REQ_CLR3 0x00000080
  38175. +#define SWARB_GNT0 0x00000100
  38176. +#define SWARB_GNT1 0x00000200
  38177. +#define SWARB_GNT2 0x00000400
  38178. +#define SWARB_GNT3 0x00000800
  38179. +#define SWARB_REQ0 0x00001000
  38180. +#define SWARB_REQ1 0x00002000
  38181. +#define SWARB_REQ2 0x00004000
  38182. +#define SWARB_REQ3 0x00008000
  38183. +#define NVRAM_BUFFERED_PAGE_SIZE 264
  38184. +#define NVRAM_BUFFERED_PAGE_POS 9
  38185. +/* 0x7024 --> 0x7400 unused */
  38186. +
  38187. +/* 0x7400 --> 0x8000 unused */
  38188. +
  38189. +/* 32K Window into NIC internal memory */
  38190. +#define NIC_SRAM_WIN_BASE 0x00008000
  38191. +
  38192. +/* Offsets into first 32k of NIC internal memory. */
  38193. +#define NIC_SRAM_PAGE_ZERO 0x00000000
  38194. +#define NIC_SRAM_SEND_RCB 0x00000100 /* 16 * TG3_BDINFO_... */
  38195. +#define NIC_SRAM_RCV_RET_RCB 0x00000200 /* 16 * TG3_BDINFO_... */
  38196. +#define NIC_SRAM_STATS_BLK 0x00000300
  38197. +#define NIC_SRAM_STATUS_BLK 0x00000b00
  38198. +
  38199. +#define NIC_SRAM_FIRMWARE_MBOX 0x00000b50
  38200. +#define NIC_SRAM_FIRMWARE_MBOX_MAGIC1 0x4B657654
  38201. +#define NIC_SRAM_FIRMWARE_MBOX_MAGIC2 0x4861764b /* !dma on linkchg */
  38202. +
  38203. +#define NIC_SRAM_DATA_SIG 0x00000b54
  38204. +#define NIC_SRAM_DATA_SIG_MAGIC 0x4b657654 /* ascii for 'KevT' */
  38205. +
  38206. +#define NIC_SRAM_DATA_CFG 0x00000b58
  38207. +#define NIC_SRAM_DATA_CFG_LED_MODE_MASK 0x0000000c
  38208. +#define NIC_SRAM_DATA_CFG_LED_MODE_UNKNOWN 0x00000000
  38209. +#define NIC_SRAM_DATA_CFG_LED_TRIPLE_SPD 0x00000004
  38210. +#define NIC_SRAM_DATA_CFG_LED_OPEN_DRAIN 0x00000004
  38211. +#define NIC_SRAM_DATA_CFG_LED_LINK_SPD 0x00000008
  38212. +#define NIC_SRAM_DATA_CFG_LED_OUTPUT 0x00000008
  38213. +#define NIC_SRAM_DATA_CFG_PHY_TYPE_MASK 0x00000030
  38214. +#define NIC_SRAM_DATA_CFG_PHY_TYPE_UNKNOWN 0x00000000
  38215. +#define NIC_SRAM_DATA_CFG_PHY_TYPE_COPPER 0x00000010
  38216. +#define NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER 0x00000020
  38217. +#define NIC_SRAM_DATA_CFG_WOL_ENABLE 0x00000040
  38218. +#define NIC_SRAM_DATA_CFG_ASF_ENABLE 0x00000080
  38219. +#define NIC_SRAM_DATA_CFG_EEPROM_WP 0x00000100
  38220. +#define NIC_SRAM_DATA_CFG_MINI_PCI 0x00001000
  38221. +#define NIC_SRAM_DATA_CFG_FIBER_WOL 0x00004000
  38222. +
  38223. +#define NIC_SRAM_DATA_PHY_ID 0x00000b74
  38224. +#define NIC_SRAM_DATA_PHY_ID1_MASK 0xffff0000
  38225. +#define NIC_SRAM_DATA_PHY_ID2_MASK 0x0000ffff
  38226. +
  38227. +#define NIC_SRAM_FW_CMD_MBOX 0x00000b78
  38228. +#define FWCMD_NICDRV_ALIVE 0x00000001
  38229. +#define FWCMD_NICDRV_PAUSE_FW 0x00000002
  38230. +#define FWCMD_NICDRV_IPV4ADDR_CHG 0x00000003
  38231. +#define FWCMD_NICDRV_IPV6ADDR_CHG 0x00000004
  38232. +#define FWCMD_NICDRV_FIX_DMAR 0x00000005
  38233. +#define FWCMD_NICDRV_FIX_DMAW 0x00000006
  38234. +#define NIC_SRAM_FW_CMD_LEN_MBOX 0x00000b7c
  38235. +#define NIC_SRAM_FW_CMD_DATA_MBOX 0x00000b80
  38236. +#define NIC_SRAM_FW_ASF_STATUS_MBOX 0x00000c00
  38237. +#define NIC_SRAM_FW_DRV_STATE_MBOX 0x00000c04
  38238. +#define DRV_STATE_START 0x00000001
  38239. +#define DRV_STATE_UNLOAD 0x00000002
  38240. +#define DRV_STATE_WOL 0x00000003
  38241. +#define DRV_STATE_SUSPEND 0x00000004
  38242. +
  38243. +#define NIC_SRAM_FW_RESET_TYPE_MBOX 0x00000c08
  38244. +
  38245. +#define NIC_SRAM_MAC_ADDR_HIGH_MBOX 0x00000c14
  38246. +#define NIC_SRAM_MAC_ADDR_LOW_MBOX 0x00000c18
  38247. +
  38248. +#define NIC_SRAM_RX_MINI_BUFFER_DESC 0x00001000
  38249. +
  38250. +#define NIC_SRAM_DMA_DESC_POOL_BASE 0x00002000
  38251. +#define NIC_SRAM_DMA_DESC_POOL_SIZE 0x00002000
  38252. +#define NIC_SRAM_TX_BUFFER_DESC 0x00004000 /* 512 entries */
  38253. +#define NIC_SRAM_RX_BUFFER_DESC 0x00006000 /* 256 entries */
  38254. +#define NIC_SRAM_RX_JUMBO_BUFFER_DESC 0x00007000 /* 256 entries */
  38255. +#define NIC_SRAM_MBUF_POOL_BASE 0x00008000
  38256. +#define NIC_SRAM_MBUF_POOL_SIZE96 0x00018000
  38257. +#define NIC_SRAM_MBUF_POOL_SIZE64 0x00010000
  38258. +#define NIC_SRAM_MBUF_POOL_BASE5705 0x00010000
  38259. +#define NIC_SRAM_MBUF_POOL_SIZE5705 0x0000e000
  38260. +
  38261. +/* Currently this is fixed. */
  38262. +#define PHY_ADDR 0x01
  38263. +
  38264. +/* Tigon3 specific PHY MII registers. */
  38265. +#define TG3_BMCR_SPEED1000 0x0040
  38266. +
  38267. +#define MII_TG3_CTRL 0x09 /* 1000-baseT control register */
  38268. +#define MII_TG3_CTRL_ADV_1000_HALF 0x0100
  38269. +#define MII_TG3_CTRL_ADV_1000_FULL 0x0200
  38270. +#define MII_TG3_CTRL_AS_MASTER 0x0800
  38271. +#define MII_TG3_CTRL_ENABLE_AS_MASTER 0x1000
  38272. +
  38273. +#define MII_TG3_EXT_CTRL 0x10 /* Extended control register */
  38274. +#define MII_TG3_EXT_CTRL_LNK3_LED_MODE 0x0002
  38275. +#define MII_TG3_EXT_CTRL_TBI 0x8000
  38276. +
  38277. +#define MII_TG3_EXT_STAT 0x11 /* Extended status register */
  38278. +#define MII_TG3_EXT_STAT_LPASS 0x0100
  38279. +
  38280. +#define MII_TG3_DSP_RW_PORT 0x15 /* DSP coefficient read/write port */
  38281. +
  38282. +#define MII_TG3_DSP_ADDRESS 0x17 /* DSP address register */
  38283. +
  38284. +#define MII_TG3_AUX_CTRL 0x18 /* auxilliary control register */
  38285. +
  38286. +#define MII_TG3_AUX_STAT 0x19 /* auxilliary status register */
  38287. +#define MII_TG3_AUX_STAT_LPASS 0x0004
  38288. +#define MII_TG3_AUX_STAT_SPDMASK 0x0700
  38289. +#define MII_TG3_AUX_STAT_10HALF 0x0100
  38290. +#define MII_TG3_AUX_STAT_10FULL 0x0200
  38291. +#define MII_TG3_AUX_STAT_100HALF 0x0300
  38292. +#define MII_TG3_AUX_STAT_100_4 0x0400
  38293. +#define MII_TG3_AUX_STAT_100FULL 0x0500
  38294. +#define MII_TG3_AUX_STAT_1000HALF 0x0600
  38295. +#define MII_TG3_AUX_STAT_1000FULL 0x0700
  38296. +
  38297. +#define MII_TG3_ISTAT 0x1a /* IRQ status register */
  38298. +#define MII_TG3_IMASK 0x1b /* IRQ mask register */
  38299. +
  38300. +/* ISTAT/IMASK event bits */
  38301. +#define MII_TG3_INT_LINKCHG 0x0002
  38302. +#define MII_TG3_INT_SPEEDCHG 0x0004
  38303. +#define MII_TG3_INT_DUPLEXCHG 0x0008
  38304. +#define MII_TG3_INT_ANEG_PAGE_RX 0x0400
  38305. +
  38306. +/* XXX Add this to mii.h */
  38307. +#ifndef ADVERTISE_PAUSE
  38308. +#define ADVERTISE_PAUSE_CAP 0x0400
  38309. +#endif
  38310. +#ifndef ADVERTISE_PAUSE_ASYM
  38311. +#define ADVERTISE_PAUSE_ASYM 0x0800
  38312. +#endif
  38313. +#ifndef LPA_PAUSE
  38314. +#define LPA_PAUSE_CAP 0x0400
  38315. +#endif
  38316. +#ifndef LPA_PAUSE_ASYM
  38317. +#define LPA_PAUSE_ASYM 0x0800
  38318. +#endif
  38319. +
  38320. +/* There are two ways to manage the TX descriptors on the tigon3.
  38321. + * Either the descriptors are in host DMA'able memory, or they
  38322. + * exist only in the cards on-chip SRAM. All 16 send bds are under
  38323. + * the same mode, they may not be configured individually.
  38324. + *
  38325. + * The mode we use is controlled by TG3_FLAG_HOST_TXDS in tp->tg3_flags.
  38326. + *
  38327. + * To use host memory TX descriptors:
  38328. + * 1) Set GRC_MODE_HOST_SENDBDS in GRC_MODE register.
  38329. + * Make sure GRC_MODE_4X_NIC_SEND_RINGS is clear.
  38330. + * 2) Allocate DMA'able memory.
  38331. + * 3) In NIC_SRAM_SEND_RCB (of desired index) of on-chip SRAM:
  38332. + * a) Set TG3_BDINFO_HOST_ADDR to DMA address of memory
  38333. + * obtained in step 2
  38334. + * b) Set TG3_BDINFO_NIC_ADDR to NIC_SRAM_TX_BUFFER_DESC.
  38335. + * c) Set len field of TG3_BDINFO_MAXLEN_FLAGS to number
  38336. + * of TX descriptors. Leave flags field clear.
  38337. + * 4) Access TX descriptors via host memory. The chip
  38338. + * will refetch into local SRAM as needed when producer
  38339. + * index mailboxes are updated.
  38340. + *
  38341. + * To use on-chip TX descriptors:
  38342. + * 1) Set GRC_MODE_4X_NIC_SEND_RINGS in GRC_MODE register.
  38343. + * Make sure GRC_MODE_HOST_SENDBDS is clear.
  38344. + * 2) In NIC_SRAM_SEND_RCB (of desired index) of on-chip SRAM:
  38345. + * a) Set TG3_BDINFO_HOST_ADDR to zero.
  38346. + * b) Set TG3_BDINFO_NIC_ADDR to NIC_SRAM_TX_BUFFER_DESC
  38347. + * c) TG3_BDINFO_MAXLEN_FLAGS is don't care.
  38348. + * 3) Access TX descriptors directly in on-chip SRAM
  38349. + * using normal {read,write}l(). (and not using
  38350. + * pointer dereferencing of ioremap()'d memory like
  38351. + * the broken Broadcom driver does)
  38352. + *
  38353. + * Note that BDINFO_FLAGS_DISABLED should be set in the flags field of
  38354. + * TG3_BDINFO_MAXLEN_FLAGS of all unused SEND_RCB indices.
  38355. + */
  38356. +struct tg3_tx_buffer_desc {
  38357. + uint32_t addr_hi;
  38358. + uint32_t addr_lo;
  38359. +
  38360. + uint32_t len_flags;
  38361. +#define TXD_FLAG_TCPUDP_CSUM 0x0001
  38362. +#define TXD_FLAG_IP_CSUM 0x0002
  38363. +#define TXD_FLAG_END 0x0004
  38364. +#define TXD_FLAG_IP_FRAG 0x0008
  38365. +#define TXD_FLAG_IP_FRAG_END 0x0010
  38366. +#define TXD_FLAG_VLAN 0x0040
  38367. +#define TXD_FLAG_COAL_NOW 0x0080
  38368. +#define TXD_FLAG_CPU_PRE_DMA 0x0100
  38369. +#define TXD_FLAG_CPU_POST_DMA 0x0200
  38370. +#define TXD_FLAG_ADD_SRC_ADDR 0x1000
  38371. +#define TXD_FLAG_CHOOSE_SRC_ADDR 0x6000
  38372. +#define TXD_FLAG_NO_CRC 0x8000
  38373. +#define TXD_LEN_SHIFT 16
  38374. +
  38375. + uint32_t vlan_tag;
  38376. +#define TXD_VLAN_TAG_SHIFT 0
  38377. +#define TXD_MSS_SHIFT 16
  38378. +};
  38379. +
  38380. +#define TXD_ADDR 0x00UL /* 64-bit */
  38381. +#define TXD_LEN_FLAGS 0x08UL /* 32-bit (upper 16-bits are len) */
  38382. +#define TXD_VLAN_TAG 0x0cUL /* 32-bit (upper 16-bits are tag) */
  38383. +#define TXD_SIZE 0x10UL
  38384. +
  38385. +struct tg3_rx_buffer_desc {
  38386. + uint32_t addr_hi;
  38387. + uint32_t addr_lo;
  38388. +
  38389. + uint32_t idx_len;
  38390. +#define RXD_IDX_MASK 0xffff0000
  38391. +#define RXD_IDX_SHIFT 16
  38392. +#define RXD_LEN_MASK 0x0000ffff
  38393. +#define RXD_LEN_SHIFT 0
  38394. +
  38395. + uint32_t type_flags;
  38396. +#define RXD_TYPE_SHIFT 16
  38397. +#define RXD_FLAGS_SHIFT 0
  38398. +
  38399. +#define RXD_FLAG_END 0x0004
  38400. +#define RXD_FLAG_MINI 0x0800
  38401. +#define RXD_FLAG_JUMBO 0x0020
  38402. +#define RXD_FLAG_VLAN 0x0040
  38403. +#define RXD_FLAG_ERROR 0x0400
  38404. +#define RXD_FLAG_IP_CSUM 0x1000
  38405. +#define RXD_FLAG_TCPUDP_CSUM 0x2000
  38406. +#define RXD_FLAG_IS_TCP 0x4000
  38407. +
  38408. + uint32_t ip_tcp_csum;
  38409. +#define RXD_IPCSUM_MASK 0xffff0000
  38410. +#define RXD_IPCSUM_SHIFT 16
  38411. +#define RXD_TCPCSUM_MASK 0x0000ffff
  38412. +#define RXD_TCPCSUM_SHIFT 0
  38413. +
  38414. + uint32_t err_vlan;
  38415. +
  38416. +#define RXD_VLAN_MASK 0x0000ffff
  38417. +
  38418. +#define RXD_ERR_BAD_CRC 0x00010000
  38419. +#define RXD_ERR_COLLISION 0x00020000
  38420. +#define RXD_ERR_LINK_LOST 0x00040000
  38421. +#define RXD_ERR_PHY_DECODE 0x00080000
  38422. +#define RXD_ERR_ODD_NIBBLE_RCVD_MII 0x00100000
  38423. +#define RXD_ERR_MAC_ABRT 0x00200000
  38424. +#define RXD_ERR_TOO_SMALL 0x00400000
  38425. +#define RXD_ERR_NO_RESOURCES 0x00800000
  38426. +#define RXD_ERR_HUGE_FRAME 0x01000000
  38427. +#define RXD_ERR_MASK 0xffff0000
  38428. +
  38429. + uint32_t reserved;
  38430. + uint32_t opaque;
  38431. +#define RXD_OPAQUE_INDEX_MASK 0x0000ffff
  38432. +#define RXD_OPAQUE_INDEX_SHIFT 0
  38433. +#define RXD_OPAQUE_RING_STD 0x00010000
  38434. +#define RXD_OPAQUE_RING_JUMBO 0x00020000
  38435. +#define RXD_OPAQUE_RING_MINI 0x00040000
  38436. +#define RXD_OPAQUE_RING_MASK 0x00070000
  38437. +};
  38438. +
  38439. +struct tg3_ext_rx_buffer_desc {
  38440. + struct {
  38441. + uint32_t addr_hi;
  38442. + uint32_t addr_lo;
  38443. + } addrlist[3];
  38444. + uint32_t len2_len1;
  38445. + uint32_t resv_len3;
  38446. + struct tg3_rx_buffer_desc std;
  38447. +};
  38448. +
  38449. +/* We only use this when testing out the DMA engine
  38450. + * at probe time. This is the internal format of buffer
  38451. + * descriptors used by the chip at NIC_SRAM_DMA_DESCS.
  38452. + */
  38453. +struct tg3_internal_buffer_desc {
  38454. + uint32_t addr_hi;
  38455. + uint32_t addr_lo;
  38456. + uint32_t nic_mbuf;
  38457. + /* XXX FIX THIS */
  38458. +#if __BYTE_ORDER == __BIG_ENDIAN
  38459. + uint16_t cqid_sqid;
  38460. + uint16_t len;
  38461. +#else
  38462. + uint16_t len;
  38463. + uint16_t cqid_sqid;
  38464. +#endif
  38465. + uint32_t flags;
  38466. + uint32_t __cookie1;
  38467. + uint32_t __cookie2;
  38468. + uint32_t __cookie3;
  38469. +};
  38470. +
  38471. +#define TG3_HW_STATUS_SIZE 0x50
  38472. +struct tg3_hw_status {
  38473. + uint32_t status;
  38474. +#define SD_STATUS_UPDATED 0x00000001
  38475. +#define SD_STATUS_LINK_CHG 0x00000002
  38476. +#define SD_STATUS_ERROR 0x00000004
  38477. +
  38478. + uint32_t status_tag;
  38479. +
  38480. +#if __BYTE_ORDER == __BIG_ENDIAN
  38481. + uint16_t rx_consumer;
  38482. + uint16_t rx_jumbo_consumer;
  38483. +#else
  38484. + uint16_t rx_jumbo_consumer;
  38485. + uint16_t rx_consumer;
  38486. +#endif
  38487. +
  38488. +#if __BYTE_ORDER == __BIG_ENDIAN
  38489. + uint16_t reserved;
  38490. + uint16_t rx_mini_consumer;
  38491. +#else
  38492. + uint16_t rx_mini_consumer;
  38493. + uint16_t reserved;
  38494. +#endif
  38495. + struct {
  38496. +#if __BYTE_ORDER == __BIG_ENDIAN
  38497. + uint16_t tx_consumer;
  38498. + uint16_t rx_producer;
  38499. +#else
  38500. + uint16_t rx_producer;
  38501. + uint16_t tx_consumer;
  38502. +#endif
  38503. + } idx[16];
  38504. +};
  38505. +
  38506. +typedef struct {
  38507. + uint32_t high, low;
  38508. +} tg3_stat64_t;
  38509. +
  38510. +struct tg3_hw_stats {
  38511. + uint8_t __reserved0[0x400-0x300];
  38512. +
  38513. + /* Statistics maintained by Receive MAC. */
  38514. + tg3_stat64_t rx_octets;
  38515. + uint64_t __reserved1;
  38516. + tg3_stat64_t rx_fragments;
  38517. + tg3_stat64_t rx_ucast_packets;
  38518. + tg3_stat64_t rx_mcast_packets;
  38519. + tg3_stat64_t rx_bcast_packets;
  38520. + tg3_stat64_t rx_fcs_errors;
  38521. + tg3_stat64_t rx_align_errors;
  38522. + tg3_stat64_t rx_xon_pause_rcvd;
  38523. + tg3_stat64_t rx_xoff_pause_rcvd;
  38524. + tg3_stat64_t rx_mac_ctrl_rcvd;
  38525. + tg3_stat64_t rx_xoff_entered;
  38526. + tg3_stat64_t rx_frame_too_long_errors;
  38527. + tg3_stat64_t rx_jabbers;
  38528. + tg3_stat64_t rx_undersize_packets;
  38529. + tg3_stat64_t rx_in_length_errors;
  38530. + tg3_stat64_t rx_out_length_errors;
  38531. + tg3_stat64_t rx_64_or_less_octet_packets;
  38532. + tg3_stat64_t rx_65_to_127_octet_packets;
  38533. + tg3_stat64_t rx_128_to_255_octet_packets;
  38534. + tg3_stat64_t rx_256_to_511_octet_packets;
  38535. + tg3_stat64_t rx_512_to_1023_octet_packets;
  38536. + tg3_stat64_t rx_1024_to_1522_octet_packets;
  38537. + tg3_stat64_t rx_1523_to_2047_octet_packets;
  38538. + tg3_stat64_t rx_2048_to_4095_octet_packets;
  38539. + tg3_stat64_t rx_4096_to_8191_octet_packets;
  38540. + tg3_stat64_t rx_8192_to_9022_octet_packets;
  38541. +
  38542. + uint64_t __unused0[37];
  38543. +
  38544. + /* Statistics maintained by Transmit MAC. */
  38545. + tg3_stat64_t tx_octets;
  38546. + uint64_t __reserved2;
  38547. + tg3_stat64_t tx_collisions;
  38548. + tg3_stat64_t tx_xon_sent;
  38549. + tg3_stat64_t tx_xoff_sent;
  38550. + tg3_stat64_t tx_flow_control;
  38551. + tg3_stat64_t tx_mac_errors;
  38552. + tg3_stat64_t tx_single_collisions;
  38553. + tg3_stat64_t tx_mult_collisions;
  38554. + tg3_stat64_t tx_deferred;
  38555. + uint64_t __reserved3;
  38556. + tg3_stat64_t tx_excessive_collisions;
  38557. + tg3_stat64_t tx_late_collisions;
  38558. + tg3_stat64_t tx_collide_2times;
  38559. + tg3_stat64_t tx_collide_3times;
  38560. + tg3_stat64_t tx_collide_4times;
  38561. + tg3_stat64_t tx_collide_5times;
  38562. + tg3_stat64_t tx_collide_6times;
  38563. + tg3_stat64_t tx_collide_7times;
  38564. + tg3_stat64_t tx_collide_8times;
  38565. + tg3_stat64_t tx_collide_9times;
  38566. + tg3_stat64_t tx_collide_10times;
  38567. + tg3_stat64_t tx_collide_11times;
  38568. + tg3_stat64_t tx_collide_12times;
  38569. + tg3_stat64_t tx_collide_13times;
  38570. + tg3_stat64_t tx_collide_14times;
  38571. + tg3_stat64_t tx_collide_15times;
  38572. + tg3_stat64_t tx_ucast_packets;
  38573. + tg3_stat64_t tx_mcast_packets;
  38574. + tg3_stat64_t tx_bcast_packets;
  38575. + tg3_stat64_t tx_carrier_sense_errors;
  38576. + tg3_stat64_t tx_discards;
  38577. + tg3_stat64_t tx_errors;
  38578. +
  38579. + uint64_t __unused1[31];
  38580. +
  38581. + /* Statistics maintained by Receive List Placement. */
  38582. + tg3_stat64_t COS_rx_packets[16];
  38583. + tg3_stat64_t COS_rx_filter_dropped;
  38584. + tg3_stat64_t dma_writeq_full;
  38585. + tg3_stat64_t dma_write_prioq_full;
  38586. + tg3_stat64_t rxbds_empty;
  38587. + tg3_stat64_t rx_discards;
  38588. + tg3_stat64_t rx_errors;
  38589. + tg3_stat64_t rx_threshold_hit;
  38590. +
  38591. + uint64_t __unused2[9];
  38592. +
  38593. + /* Statistics maintained by Send Data Initiator. */
  38594. + tg3_stat64_t COS_out_packets[16];
  38595. + tg3_stat64_t dma_readq_full;
  38596. + tg3_stat64_t dma_read_prioq_full;
  38597. + tg3_stat64_t tx_comp_queue_full;
  38598. +
  38599. + /* Statistics maintained by Host Coalescing. */
  38600. + tg3_stat64_t ring_set_send_prod_index;
  38601. + tg3_stat64_t ring_status_update;
  38602. + tg3_stat64_t nic_irqs;
  38603. + tg3_stat64_t nic_avoided_irqs;
  38604. + tg3_stat64_t nic_tx_threshold_hit;
  38605. +
  38606. + uint8_t __reserved4[0xb00-0x9c0];
  38607. +};
  38608. +
  38609. +enum phy_led_mode {
  38610. + led_mode_auto,
  38611. + led_mode_three_link,
  38612. + led_mode_link10
  38613. +};
  38614. +
  38615. +#if 0
  38616. +/* 'mapping' is superfluous as the chip does not write into
  38617. + * the tx/rx post rings so we could just fetch it from there.
  38618. + * But the cache behavior is better how we are doing it now.
  38619. + */
  38620. +struct ring_info {
  38621. + struct sk_buff *skb;
  38622. + DECLARE_PCI_UNMAP_ADDR(mapping)
  38623. +};
  38624. +
  38625. +struct tx_ring_info {
  38626. + struct sk_buff *skb;
  38627. + DECLARE_PCI_UNMAP_ADDR(mapping)
  38628. + uint32_t prev_vlan_tag;
  38629. +};
  38630. +#endif
  38631. +
  38632. +struct tg3_config_info {
  38633. + uint32_t flags;
  38634. +};
  38635. +
  38636. +struct tg3_link_config {
  38637. + /* Describes what we're trying to get. */
  38638. + uint32_t advertising;
  38639. +#if 0
  38640. + uint16_t speed;
  38641. + uint8_t duplex;
  38642. + uint8_t autoneg;
  38643. +#define SPEED_INVALID 0xffff
  38644. +#define DUPLEX_INVALID 0xff
  38645. +#define AUTONEG_INVALID 0xff
  38646. +#endif
  38647. +
  38648. + /* Describes what we actually have. */
  38649. + uint8_t active_speed;
  38650. + uint8_t active_duplex;
  38651. +
  38652. + /* When we go in and out of low power mode we need
  38653. + * to swap with this state.
  38654. + */
  38655. +#if 0
  38656. + int phy_is_low_power;
  38657. + uint16_t orig_speed;
  38658. + uint8_t orig_duplex;
  38659. + uint8_t orig_autoneg;
  38660. +#endif
  38661. +};
  38662. +
  38663. +struct tg3_bufmgr_config {
  38664. + uint32_t mbuf_read_dma_low_water;
  38665. + uint32_t mbuf_mac_rx_low_water;
  38666. + uint32_t mbuf_high_water;
  38667. +
  38668. + uint32_t mbuf_read_dma_low_water_jumbo;
  38669. + uint32_t mbuf_mac_rx_low_water_jumbo;
  38670. + uint32_t mbuf_high_water_jumbo;
  38671. +
  38672. + uint32_t dma_low_water;
  38673. + uint32_t dma_high_water;
  38674. +};
  38675. +
  38676. +struct tg3 {
  38677. +#if 0
  38678. + /* SMP locking strategy:
  38679. + *
  38680. + * lock: Held during all operations except TX packet
  38681. + * processing.
  38682. + *
  38683. + * tx_lock: Held during tg3_start_xmit{,_4gbug} and tg3_tx
  38684. + *
  38685. + * If you want to shut up all asynchronous processing you must
  38686. + * acquire both locks, 'lock' taken before 'tx_lock'. IRQs must
  38687. + * be disabled to take 'lock' but only softirq disabling is
  38688. + * necessary for acquisition of 'tx_lock'.
  38689. + */
  38690. + spinlock_t lock;
  38691. + spinlock_t tx_lock;
  38692. +#endif
  38693. +
  38694. + uint32_t tx_prod;
  38695. +#if 0
  38696. + uint32_t tx_cons;
  38697. +#endif
  38698. + uint32_t rx_rcb_ptr;
  38699. + uint32_t rx_std_ptr;
  38700. +#if 0
  38701. + uint32_t rx_jumbo_ptr;
  38702. + spinlock_t indirect_lock;
  38703. +
  38704. + struct net_device_stats net_stats;
  38705. + struct net_device_stats net_stats_prev;
  38706. +#endif
  38707. + unsigned long phy_crc_errors;
  38708. +
  38709. +#if 0
  38710. + uint32_t rx_offset;
  38711. +#endif
  38712. + uint32_t tg3_flags;
  38713. +#if 0
  38714. +#define TG3_FLAG_HOST_TXDS 0x00000001
  38715. +#endif
  38716. +#define TG3_FLAG_TXD_MBOX_HWBUG 0x00000002
  38717. +#define TG3_FLAG_RX_CHECKSUMS 0x00000004
  38718. +#define TG3_FLAG_USE_LINKCHG_REG 0x00000008
  38719. +#define TG3_FLAG_USE_MI_INTERRUPT 0x00000010
  38720. +#define TG3_FLAG_ENABLE_ASF 0x00000020
  38721. +#define TG3_FLAG_5701_REG_WRITE_BUG 0x00000040
  38722. +#define TG3_FLAG_POLL_SERDES 0x00000080
  38723. +#define TG3_FLAG_MBOX_WRITE_REORDER 0x00000100
  38724. +#define TG3_FLAG_PCIX_TARGET_HWBUG 0x00000200
  38725. +#define TG3_FLAG_WOL_SPEED_100MB 0x00000400
  38726. +#define TG3_FLAG_WOL_ENABLE 0x00000800
  38727. +#define TG3_FLAG_EEPROM_WRITE_PROT 0x00001000
  38728. +#define TG3_FLAG_NVRAM 0x00002000
  38729. +#define TG3_FLAG_NVRAM_BUFFERED 0x00004000
  38730. +#define TG3_FLAG_RX_PAUSE 0x00008000
  38731. +#define TG3_FLAG_TX_PAUSE 0x00010000
  38732. +#define TG3_FLAG_PCIX_MODE 0x00020000
  38733. +#define TG3_FLAG_PCI_HIGH_SPEED 0x00040000
  38734. +#define TG3_FLAG_PCI_32BIT 0x00080000
  38735. +#define TG3_FLAG_NO_TX_PSEUDO_CSUM 0x00100000
  38736. +#define TG3_FLAG_NO_RX_PSEUDO_CSUM 0x00200000
  38737. +#define TG3_FLAG_SERDES_WOL_CAP 0x00400000
  38738. +#define TG3_FLAG_JUMBO_ENABLE 0x00800000
  38739. +#define TG3_FLAG_10_100_ONLY 0x01000000
  38740. +#define TG3_FLAG_PAUSE_AUTONEG 0x02000000
  38741. +#define TG3_FLAG_PAUSE_RX 0x04000000
  38742. +#define TG3_FLAG_PAUSE_TX 0x08000000
  38743. +#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000
  38744. +#define TG3_FLAG_GOT_SERDES_FLOWCTL 0x20000000
  38745. +#define TG3_FLAG_SPLIT_MODE 0x40000000
  38746. +#define TG3_FLAG_INIT_COMPLETE 0x80000000
  38747. +
  38748. + uint32_t tg3_flags2;
  38749. +#define TG3_FLG2_RESTART_TIMER 0x00000001
  38750. +#define TG3_FLG2_SUN_5704 0x00000002
  38751. +#define TG3_FLG2_NO_ETH_WIRE_SPEED 0x00000004
  38752. +#define TG3_FLG2_IS_5788 0x00000008
  38753. +#define TG3_FLG2_MAX_RXPEND_64 0x00000010
  38754. +#define TG3_FLG2_TSO_CAPABLE 0x00000020
  38755. +
  38756. +
  38757. +
  38758. + uint32_t split_mode_max_reqs;
  38759. +#define SPLIT_MODE_5704_MAX_REQ 3
  38760. +
  38761. +#if 0
  38762. + struct timer_list timer;
  38763. + uint16_t timer_counter;
  38764. + uint16_t timer_multiplier;
  38765. + uint32_t timer_offset;
  38766. + uint16_t asf_counter;
  38767. + uint16_t asf_multiplier;
  38768. +#endif
  38769. +
  38770. + struct tg3_link_config link_config;
  38771. + struct tg3_bufmgr_config bufmgr_config;
  38772. +
  38773. +#if 0
  38774. + uint32_t rx_pending;
  38775. + uint32_t rx_jumbo_pending;
  38776. + uint32_t tx_pending;
  38777. +#endif
  38778. +
  38779. + /* cache h/w values, often passed straight to h/w */
  38780. + uint32_t rx_mode;
  38781. + uint32_t tx_mode;
  38782. + uint32_t mac_mode;
  38783. + uint32_t mi_mode;
  38784. + uint32_t misc_host_ctrl;
  38785. + uint32_t grc_mode;
  38786. + uint32_t grc_local_ctrl;
  38787. + uint32_t dma_rwctrl;
  38788. +#if 0
  38789. + uint32_t coalesce_mode;
  38790. +#endif
  38791. +
  38792. + /* PCI block */
  38793. + uint16_t pci_chip_rev_id;
  38794. +#if 0
  38795. + uint8_t pci_cacheline_sz;
  38796. + uint8_t pci_lat_timer;
  38797. + uint8_t pci_hdr_type;
  38798. + uint8_t pci_bist;
  38799. +#endif
  38800. + uint32_t pci_cfg_state[64 / sizeof(uint32_t)];
  38801. +
  38802. + int pm_cap;
  38803. +
  38804. + /* PHY info */
  38805. + uint32_t phy_id;
  38806. +#define PHY_ID_MASK 0xfffffff0
  38807. +#define PHY_ID_BCM5400 0x60008040
  38808. +#define PHY_ID_BCM5401 0x60008050
  38809. +#define PHY_ID_BCM5411 0x60008070
  38810. +#define PHY_ID_BCM5701 0x60008110
  38811. +#define PHY_ID_BCM5703 0x60008160
  38812. +#define PHY_ID_BCM5704 0x60008190
  38813. +#define PHY_ID_BCM5705 0x600081a0
  38814. +#define PHY_ID_BCM8002 0x60010140
  38815. +#define PHY_ID_SERDES 0xfeedbee0
  38816. +#define PHY_ID_INVALID 0xffffffff
  38817. +#define PHY_ID_REV_MASK 0x0000000f
  38818. +#define PHY_REV_BCM5401_B0 0x1
  38819. +#define PHY_REV_BCM5401_B2 0x3
  38820. +#define PHY_REV_BCM5401_C0 0x6
  38821. +#define PHY_REV_BCM5411_X0 0x1 /* Found on Netgear GA302T */
  38822. +
  38823. + enum phy_led_mode led_mode;
  38824. +
  38825. + char board_part_number[24];
  38826. + uint32_t nic_sram_data_cfg;
  38827. + uint32_t pci_clock_ctrl;
  38828. +#if 0
  38829. + struct pci_device *pdev_peer;
  38830. +#endif
  38831. +
  38832. + /* This macro assumes the passed PHY ID is already masked
  38833. + * with PHY_ID_MASK.
  38834. + */
  38835. +#define KNOWN_PHY_ID(X) \
  38836. + ((X) == PHY_ID_BCM5400 || (X) == PHY_ID_BCM5401 || \
  38837. + (X) == PHY_ID_BCM5411 || (X) == PHY_ID_BCM5701 || \
  38838. + (X) == PHY_ID_BCM5703 || (X) == PHY_ID_BCM5704 || \
  38839. + (X) == PHY_ID_BCM5705 || \
  38840. + (X) == PHY_ID_BCM8002 || (X) == PHY_ID_SERDES)
  38841. +
  38842. + unsigned long regs;
  38843. + struct pci_device *pdev;
  38844. + struct nic *nic;
  38845. +#if 0
  38846. + struct net_device *dev;
  38847. +#endif
  38848. +#if TG3_VLAN_TAG_USED
  38849. + struct vlan_group *vlgrp;
  38850. +#endif
  38851. +
  38852. + struct tg3_rx_buffer_desc *rx_std;
  38853. +#if 0
  38854. + struct ring_info *rx_std_buffers;
  38855. + dma_addr_t rx_std_mapping;
  38856. + struct tg3_rx_buffer_desc *rx_jumbo;
  38857. + struct ring_info *rx_jumbo_buffers;
  38858. + dma_addr_t rx_jumbo_mapping;
  38859. +#endif
  38860. +
  38861. + struct tg3_rx_buffer_desc *rx_rcb;
  38862. +#if 0
  38863. + dma_addr_t rx_rcb_mapping;
  38864. +#endif
  38865. +
  38866. + /* TX descs are only used if TG3_FLAG_HOST_TXDS is set. */
  38867. + struct tg3_tx_buffer_desc *tx_ring;
  38868. +#if 0
  38869. + struct tx_ring_info *tx_buffers;
  38870. + dma_addr_t tx_desc_mapping;
  38871. +#endif
  38872. +
  38873. + struct tg3_hw_status *hw_status;
  38874. +#if 0
  38875. + dma_addr_t status_mapping;
  38876. +#endif
  38877. +#if 0
  38878. + uint32_t msg_enable;
  38879. +#endif
  38880. +
  38881. + struct tg3_hw_stats *hw_stats;
  38882. +#if 0
  38883. + dma_addr_t stats_mapping;
  38884. +#endif
  38885. +
  38886. + int carrier_ok;
  38887. + uint16_t subsystem_vendor;
  38888. + uint16_t subsystem_device;
  38889. +};
  38890. +
  38891. +#endif /* !(_T3_H) */
  38892. Index: b/netboot/tiara.c
  38893. ===================================================================
  38894. --- a/netboot/tiara.c
  38895. +++ /dev/null
  38896. @@ -1,255 +0,0 @@
  38897. -/**************************************************************************
  38898. -Etherboot - BOOTP/TFTP Bootstrap Program
  38899. -
  38900. -TIARA (Fujitsu Etherstar) NIC driver for Etherboot
  38901. -Copyright (c) Ken Yap 1998
  38902. -
  38903. -Information gleaned from:
  38904. -
  38905. -TIARA.ASM Packet driver by Brian Fisher, Queens U, Kingston, Ontario
  38906. -Fujitsu MB86960 spec sheet (different chip but same family)
  38907. -***************************************************************************/
  38908. -
  38909. -/*
  38910. - * This program is free software; you can redistribute it and/or
  38911. - * modify it under the terms of the GNU General Public License as
  38912. - * published by the Free Software Foundation; either version 2, or (at
  38913. - * your option) any later version.
  38914. - */
  38915. -
  38916. -/* to get some global routines like printf */
  38917. -#include "etherboot.h"
  38918. -/* to get the interface to the body of the program */
  38919. -#include "nic.h"
  38920. -#include "cards.h"
  38921. -
  38922. -/*
  38923. - EtherStar I/O Register offsets
  38924. -*/
  38925. -
  38926. -/* Offsets of registers */
  38927. -#define DLCR_XMIT_STAT 0x00
  38928. -#define DLCR_XMIT_MASK 0x01
  38929. -#define DLCR_RECV_STAT 0x02
  38930. -#define DLCR_RECV_MASK 0x03
  38931. -#define DLCR_XMIT_MODE 0x04
  38932. -#define DLCR_RECV_MODE 0x05
  38933. -#define DLCR_ENABLE 0x06
  38934. -#define DLCR_TDR_LOW 0x07
  38935. -#define DLCR_NODE_ID 0x08
  38936. -#define DLCR_TDR_HIGH 0x0F
  38937. -#define BMPR_MEM_PORT 0x10
  38938. -#define BMPR_PKT_LEN 0x12
  38939. -#define BMPR_DMA_ENABLE 0x14
  38940. -#define PROM_ID 0x18
  38941. -
  38942. -#define TMST 0x80
  38943. -#define TMT_OK 0x80
  38944. -#define TMT_16COLL 0x02
  38945. -#define BUF_EMPTY 0x40
  38946. -
  38947. -#define CARD_DISABLE 0x80 /* written to DLCR_ENABLE to disable card */
  38948. -#define CARD_ENABLE 0 /* written to DLCR_ENABLE to enable card */
  38949. -
  38950. -#define CLEAR_STATUS 0x0F /* used to clear status info */
  38951. -/*
  38952. - 00001111B
  38953. - !!!!!!!!--------
  38954. - !!!!!!!+--------CLEAR BUS WRITE ERROR
  38955. - !!!!!!+---------CLEAR 16 COLLISION
  38956. - !!!!!+----------CLEAR COLLISION
  38957. - !!!!+-----------CLEAR UNDERFLOW
  38958. - !!!+------------NC
  38959. - !!+-------------NC
  38960. - !+--------------NC
  38961. - +---------------NC
  38962. -*/
  38963. -
  38964. -#define NO_TX_IRQS 0 /* written to clear transmit IRQs */
  38965. -
  38966. -#define CLR_RCV_STATUS 0xCF /* clears receive status */
  38967. -
  38968. -#define EN_RCV_IRQS 0x80 /* enable receive interrupts */
  38969. -/*
  38970. - 10000000B
  38971. - !!!!!!!!--------
  38972. - !!!!!!!+--------ENABLE OVERFLOW
  38973. - !!!!!!+---------ENABLE CRC
  38974. - !!!!!+----------ENABLE ALIGN
  38975. - !!!!+-----------ENABLE SHORT PKT
  38976. - !!!+------------DISABLE REMOTE RESET
  38977. - !!+-------------RESERVED
  38978. - !+--------------RESERVED
  38979. - +---------------ENABLE PKT READY
  38980. -*/
  38981. -
  38982. -#define XMIT_MODE 0x02
  38983. -/*
  38984. - 00000010B
  38985. - !!!!!!!!---------ENABLE CARRIER DETECT
  38986. - !!!!!!!+---------DISABLE LOOPBACK
  38987. -*/
  38988. -
  38989. -#define RECV_MODE 0x02
  38990. -/*
  38991. - 00000010B
  38992. - !!!!!!!!---------ACCEPT ALL PACKETS
  38993. - !!!!!!!+---------ACCEPT PHYSICAL, MULTICAST, AND
  38994. - !!!!!!+----------BROADCAST PACKETS
  38995. - !!!!!+-----------DISABLE REMOTE RESET
  38996. - !!!!+------------DISABLE SHORT PACKETS
  38997. - !!!+-------------USE 6 BYTE ADDRESS
  38998. - !!+--------------NC
  38999. - !+---------------NC
  39000. - +----------------DISABLE CRC TEST MODE
  39001. -*/
  39002. -
  39003. -/* NIC specific static variables go here */
  39004. -
  39005. -static unsigned short ioaddr;
  39006. -
  39007. -/**************************************************************************
  39008. -RESET - Reset adapter
  39009. -***************************************************************************/
  39010. -static void tiara_reset(struct nic *nic)
  39011. -{
  39012. - int i;
  39013. -
  39014. - outb(CARD_DISABLE, ioaddr + DLCR_ENABLE);
  39015. - outb(CLEAR_STATUS, ioaddr + DLCR_XMIT_STAT);
  39016. - outb(NO_TX_IRQS, ioaddr + DLCR_XMIT_MASK);
  39017. - outb(CLR_RCV_STATUS, ioaddr + DLCR_RECV_STAT);
  39018. - outb(XMIT_MODE, ioaddr + DLCR_XMIT_MODE);
  39019. - outb(RECV_MODE, ioaddr + DLCR_RECV_MODE);
  39020. - /* Vacuum recv buffer */
  39021. - while ((inb(ioaddr + DLCR_RECV_MODE) & BUF_EMPTY) == 0)
  39022. - inb(ioaddr + BMPR_MEM_PORT);
  39023. - /* Set node address */
  39024. - for (i = 0; i < ETH_ALEN; ++i)
  39025. - outb(nic->node_addr[i], ioaddr + DLCR_NODE_ID + i);
  39026. - outb(CLR_RCV_STATUS, ioaddr + DLCR_RECV_STAT);
  39027. - outb(CARD_ENABLE, ioaddr + DLCR_ENABLE);
  39028. -}
  39029. -
  39030. -/**************************************************************************
  39031. -POLL - Wait for a frame
  39032. -***************************************************************************/
  39033. -static int tiara_poll(struct nic *nic)
  39034. -{
  39035. - unsigned int len;
  39036. -
  39037. - if (inb(ioaddr + DLCR_RECV_MODE) & BUF_EMPTY)
  39038. - return (0);
  39039. - /* Ack packet */
  39040. - outw(CLR_RCV_STATUS, ioaddr + DLCR_RECV_STAT);
  39041. - len = inw(ioaddr + BMPR_MEM_PORT); /* throw away status */
  39042. - len = inw(ioaddr + BMPR_MEM_PORT);
  39043. - /* Drop overlength packets */
  39044. - if (len > ETH_FRAME_LEN)
  39045. - return (0); /* should we drain the buffer? */
  39046. - insw(ioaddr + BMPR_MEM_PORT, nic->packet, len / 2);
  39047. - /* If it's our own, drop it */
  39048. - if (memcmp(nic->packet + ETH_ALEN, nic->node_addr, ETH_ALEN) == 0)
  39049. - return (0);
  39050. - nic->packetlen = len;
  39051. - return (1);
  39052. -}
  39053. -
  39054. -/**************************************************************************
  39055. -TRANSMIT - Transmit a frame
  39056. -***************************************************************************/
  39057. -static void tiara_transmit(
  39058. -struct nic *nic,
  39059. -const char *d, /* Destination */
  39060. -unsigned int t, /* Type */
  39061. -unsigned int s, /* size */
  39062. -const char *p) /* Packet */
  39063. -{
  39064. - unsigned int len;
  39065. - unsigned long time;
  39066. -
  39067. - len = s + ETH_HLEN;
  39068. - if (len < ETH_ZLEN)
  39069. - len = ETH_ZLEN;
  39070. - t = htons(t);
  39071. - outsw(ioaddr + BMPR_MEM_PORT, d, ETH_ALEN / 2);
  39072. - outsw(ioaddr + BMPR_MEM_PORT, nic->node_addr, ETH_ALEN / 2);
  39073. - outw(t, ioaddr + BMPR_MEM_PORT);
  39074. - outsw(ioaddr + BMPR_MEM_PORT, p, s / 2);
  39075. - if (s & 1) /* last byte */
  39076. - outb(p[s-1], ioaddr + BMPR_MEM_PORT);
  39077. - while (s++ < ETH_ZLEN - ETH_HLEN) /* pad */
  39078. - outb(0, ioaddr + BMPR_MEM_PORT);
  39079. - outw(len | (TMST << 8), ioaddr + BMPR_PKT_LEN);
  39080. - /* wait for transmit complete */
  39081. - time = currticks() + TICKS_PER_SEC; /* wait one second */
  39082. - while (currticks() < time && (inb(ioaddr) & (TMT_OK|TMT_16COLL)) == 0)
  39083. - ;
  39084. - if ((inb(ioaddr) & (TMT_OK|TMT_16COLL)) == 0)
  39085. - printf("Tiara timed out on transmit\n");
  39086. - /* Do we need to ack the transmit? */
  39087. -}
  39088. -
  39089. -/**************************************************************************
  39090. -DISABLE - Turn off ethernet interface
  39091. -***************************************************************************/
  39092. -static void tiara_disable(struct nic *nic)
  39093. -{
  39094. - /* Apparently only a power down can do this properly */
  39095. - outb(CARD_DISABLE, ioaddr + DLCR_ENABLE);
  39096. -}
  39097. -
  39098. -static int tiara_probe1(struct nic *nic)
  39099. -{
  39100. - /* Hope all the Tiara cards have this vendor prefix */
  39101. - static char vendor_prefix[] = { 0x08, 0x00, 0x1A };
  39102. - static char all_ones[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
  39103. - int i;
  39104. -
  39105. - for (i = 0; i < ETH_ALEN; ++i)
  39106. - nic->node_addr[i] = inb(ioaddr + PROM_ID + i);
  39107. - if (memcmp(nic->node_addr, vendor_prefix, sizeof(vendor_prefix)) != 0)
  39108. - return (0);
  39109. - if (memcmp(nic->node_addr, all_ones, sizeof(all_ones)) == 0)
  39110. - return (0);
  39111. - printf("\nTiara ioaddr %#hX, addr %!\n", ioaddr, nic->node_addr);
  39112. - return (1);
  39113. -}
  39114. -
  39115. -/**************************************************************************
  39116. -PROBE - Look for an adapter, this routine's visible to the outside
  39117. -***************************************************************************/
  39118. -struct nic *tiara_probe(struct nic *nic, unsigned short *probe_addrs)
  39119. -{
  39120. - /* missing entries are addresses usually already used */
  39121. - static unsigned short io_addrs[] = {
  39122. - 0x100, 0x120, 0x140, 0x160,
  39123. - 0x180, 0x1A0, 0x1C0, 0x1E0,
  39124. - 0x200, 0x220, 0x240, /*Par*/
  39125. - 0x280, 0x2A0, 0x2C0, /*Ser*/
  39126. - 0x300, 0x320, 0x340, /*Par*/
  39127. - 0x380, /*Vid,Par*/ 0x3C0, /*Ser*/
  39128. - 0x0
  39129. - };
  39130. - unsigned short *p;
  39131. -
  39132. - /* if probe_addrs is 0, then routine can use a hardwired default */
  39133. - if (probe_addrs == 0)
  39134. - probe_addrs = io_addrs;
  39135. - for (p = probe_addrs; (ioaddr = *p) != 0; ++p)
  39136. - if (tiara_probe1(nic))
  39137. - break;
  39138. - /* if board found */
  39139. - if (ioaddr != 0)
  39140. - {
  39141. - tiara_reset(nic);
  39142. - /* point to NIC specific routines */
  39143. - nic->reset = tiara_reset;
  39144. - nic->poll = tiara_poll;
  39145. - nic->transmit = tiara_transmit;
  39146. - nic->disable = tiara_disable;
  39147. - return nic;
  39148. - }
  39149. - else
  39150. - return (0);
  39151. -}
  39152. Index: b/netboot/timer.c
  39153. ===================================================================
  39154. --- a/netboot/timer.c
  39155. +++ b/netboot/timer.c
  39156. @@ -6,122 +6,24 @@
  39157. * published by the Free Software Foundation; either version 2, or (at
  39158. * your option) any later version.
  39159. */
  39160. -
  39161. -#include "etherboot.h"
  39162. +#include "grub.h"
  39163. #include "timer.h"
  39164. -void load_timer2(unsigned int ticks)
  39165. -{
  39166. - /* Set up the timer gate, turn off the speaker */
  39167. - outb((inb(PPC_PORTB) & ~PPCB_SPKR) | PPCB_T2GATE, PPC_PORTB);
  39168. - outb(TIMER2_SEL|WORD_ACCESS|MODE0|BINARY_COUNT, TIMER_MODE_PORT);
  39169. - outb(ticks & 0xFF, TIMER2_PORT);
  39170. - outb(ticks >> 8, TIMER2_PORT);
  39171. -}
  39172. -
  39173. -#if defined(CONFIG_TSC_CURRTICKS)
  39174. -#define rdtsc(low,high) \
  39175. - __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
  39176. -
  39177. -#define rdtscll(val) \
  39178. - __asm__ __volatile__ ("rdtsc" : "=A" (val))
  39179. -
  39180. -
  39181. -#define HZ TICKS_PER_SEC
  39182. -#define CLOCK_TICK_RATE 1193180U /* Underlying HZ */
  39183. -/* LATCH is used in the interval timer and ftape setup. */
  39184. -#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
  39185. +/* Machine Independant timer helper functions */
  39186. -
  39187. -/* ------ Calibrate the TSC -------
  39188. - * Return 2^32 * (1 / (TSC clocks per usec)) for do_fast_gettimeoffset().
  39189. - * Too much 64-bit arithmetic here to do this cleanly in C, and for
  39190. - * accuracy's sake we want to keep the overhead on the CTC speaker (channel 2)
  39191. - * output busy loop as low as possible. We avoid reading the CTC registers
  39192. - * directly because of the awkward 8-bit access mechanism of the 82C54
  39193. - * device.
  39194. - */
  39195. -
  39196. -#define CALIBRATE_LATCH (5 * LATCH)
  39197. -
  39198. -static unsigned long long calibrate_tsc(void)
  39199. +void mdelay(unsigned int msecs)
  39200. {
  39201. - /* Set the Gate high, disable speaker */
  39202. - outb((inb(0x61) & ~0x02) | 0x01, 0x61);
  39203. -
  39204. - /*
  39205. - * Now let's take care of CTC channel 2
  39206. - *
  39207. - * Set the Gate high, program CTC channel 2 for mode 0,
  39208. - * (interrupt on terminal count mode), binary count,
  39209. - * load 5 * LATCH count, (LSB and MSB) to begin countdown.
  39210. - */
  39211. - outb(0xb0, 0x43); /* binary, mode 0, LSB/MSB, Ch 2 */
  39212. - outb(CALIBRATE_LATCH & 0xff, 0x42); /* LSB of count */
  39213. - outb(CALIBRATE_LATCH >> 8, 0x42); /* MSB of count */
  39214. -
  39215. - {
  39216. - unsigned long startlow, starthigh;
  39217. - unsigned long endlow, endhigh;
  39218. - unsigned long count;
  39219. -
  39220. - rdtsc(startlow,starthigh);
  39221. - count = 0;
  39222. - do {
  39223. - count++;
  39224. - } while ((inb(0x61) & 0x20) == 0);
  39225. - rdtsc(endlow,endhigh);
  39226. -
  39227. - /* Error: ECTCNEVERSET */
  39228. - if (count <= 1)
  39229. - goto bad_ctc;
  39230. -
  39231. - /* 64-bit subtract - gcc just messes up with long longs */
  39232. - __asm__("subl %2,%0\n\t"
  39233. - "sbbl %3,%1"
  39234. - :"=a" (endlow), "=d" (endhigh)
  39235. - :"g" (startlow), "g" (starthigh),
  39236. - "0" (endlow), "1" (endhigh));
  39237. -
  39238. - /* Error: ECPUTOOFAST */
  39239. - if (endhigh)
  39240. - goto bad_ctc;
  39241. -
  39242. - endlow /= 5;
  39243. - return endlow;
  39244. + unsigned int i;
  39245. + for(i = 0; i < msecs; i++) {
  39246. + udelay(1000);
  39247. + poll_interruptions();
  39248. }
  39249. -
  39250. - /*
  39251. - * The CTC wasn't reliable: we got a hit on the very first read,
  39252. - * or the CPU was so fast/slow that the quotient wouldn't fit in
  39253. - * 32 bits..
  39254. - */
  39255. -bad_ctc:
  39256. - printf("bad_ctc\n");
  39257. - return 0;
  39258. }
  39259. -
  39260. -unsigned long currticks(void)
  39261. +void waiton_timer2(unsigned int ticks)
  39262. {
  39263. - static unsigned long clocks_per_tick;
  39264. - unsigned long clocks_high, clocks_low;
  39265. - unsigned long currticks;
  39266. - if (!clocks_per_tick) {
  39267. - clocks_per_tick = calibrate_tsc();
  39268. - printf("clocks_per_tick = %d\n", clocks_per_tick);
  39269. + load_timer2(ticks);
  39270. + while(timer2_running()) {
  39271. + poll_interruptions();
  39272. }
  39273. -
  39274. - /* Read the Time Stamp Counter */
  39275. - rdtsc(clocks_low, clocks_high);
  39276. -
  39277. - /* currticks = clocks / clocks_per_tick; */
  39278. - __asm__("divl %1"
  39279. - :"=a" (currticks)
  39280. - :"r" (clocks_per_tick), "0" (clocks_low), "d" (clocks_high));
  39281. -
  39282. -
  39283. - return currticks;
  39284. }
  39285. -
  39286. -#endif /* RTC_CURRTICKS */
  39287. Index: b/netboot/timer.h
  39288. ===================================================================
  39289. --- a/netboot/timer.h
  39290. +++ b/netboot/timer.h
  39291. @@ -36,7 +36,8 @@
  39292. #define BCD_COUNT 0x01
  39293. /* Timers tick over at this rate */
  39294. -#define TICKS_PER_MS 1193
  39295. +#define CLOCK_TICK_RATE 1193180U
  39296. +#define TICKS_PER_MS (CLOCK_TICK_RATE/1000)
  39297. /* Parallel Peripheral Controller Port B */
  39298. #define PPC_PORTB 0x61
  39299. @@ -49,16 +50,19 @@
  39300. /* Ticks must be between 0 and 65535 (0 == 65536)
  39301. because it is a 16 bit counter */
  39302. extern void load_timer2(unsigned int ticks);
  39303. -extern inline int timer2_running(void)
  39304. -{
  39305. - return ((inb(PPC_PORTB) & PPCB_T2OUT) == 0);
  39306. -}
  39307. -
  39308. -extern inline void waiton_timer2(unsigned int ticks)
  39309. -{
  39310. - load_timer2(ticks);
  39311. - while ((inb(PPC_PORTB) & PPCB_T2OUT) == 0)
  39312. - ;
  39313. -}
  39314. +extern inline int timer2_running(void);
  39315. +extern void waiton_timer2(unsigned int ticks);
  39316. +extern void __load_timer2(unsigned int ticks);
  39317. +
  39318. +extern void setup_timers(void);
  39319. +extern void ndelay(unsigned int nsecs);
  39320. +extern void udelay(unsigned int usecs);
  39321. +extern void mdelay(unsigned int msecs);
  39322. +//extern unsigned long currticks(void);
  39323. +
  39324. +struct timeval {
  39325. + long tv_sec;
  39326. + long tv_usec;
  39327. +};
  39328. #endif /* TIMER_H */
  39329. Index: b/netboot/tlan.c
  39330. ===================================================================
  39331. --- a/netboot/tlan.c
  39332. +++ b/netboot/tlan.c
  39333. @@ -1,3746 +1,1814 @@
  39334. +#define EB51
  39335. +
  39336. +#ifdef EB50
  39337. +#define __unused __attribute__((unused))
  39338. +#endif
  39339. +
  39340. /**************************************************************************
  39341. -Etherboot - BOOTP/TFTP Bootstrap Program
  39342. -TLAN driver for Etherboot
  39343. +*
  39344. +* tlan.c -- Etherboot device driver for the Texas Instruments ThunderLAN
  39345. +* Written 2003-2003 by Timothy Legge <tlegge@rogers.com>
  39346. +*
  39347. +* This program is free software; you can redistribute it and/or modify
  39348. +* it under the terms of the GNU General Public License as published by
  39349. +* the Free Software Foundation; either version 2 of the License, or
  39350. +* (at your option) any later version.
  39351. +*
  39352. +* This program is distributed in the hope that it will be useful,
  39353. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  39354. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39355. +* GNU General Public License for more details.
  39356. +*
  39357. +* You should have received a copy of the GNU General Public License
  39358. +* along with this program; if not, write to the Free Software
  39359. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  39360. +*
  39361. +* Portions of this code based on:
  39362. +* lan.c: Linux ThunderLan Driver:
  39363. +*
  39364. +* by James Banks
  39365. +*
  39366. +* (C) 1997-1998 Caldera, Inc.
  39367. +* (C) 1998 James Banks
  39368. +* (C) 1999-2001 Torben Mathiasen
  39369. +* (C) 2002 Samuel Chessman
  39370. +*
  39371. +* REVISION HISTORY:
  39372. +* ================
  39373. +* v1.0 07-08-2003 timlegge Initial not quite working version
  39374. +* v1.1 07-27-2003 timlegge Sync 5.0 and 5.1 versions
  39375. +* v1.2 08-19-2003 timlegge Implement Multicast Support
  39376. +* v1.3 08-23-2003 timlegge Fix the transmit Function
  39377. +* v1.4 01-17-2004 timlegge Initial driver output cleanup
  39378. +*
  39379. +* Indent Options: indent -kr -i8
  39380. ***************************************************************************/
  39381. -/*
  39382. - * This program is free software; you can redistribute it and/or
  39383. - * modify it under the terms of the GNU General Public License as
  39384. - * published by the Free Software Foundation; either version 2, or (at
  39385. - * your option) any later version.
  39386. - */
  39387. -
  39388. /* to get some global routines like printf */
  39389. #include "etherboot.h"
  39390. /* to get the interface to the body of the program */
  39391. #include "nic.h"
  39392. /* to get the PCI support functions, if this is a PCI NIC */
  39393. #include "pci.h"
  39394. -/* to get our own prototype */
  39395. -#include "cards.h"
  39396. -
  39397. - /*****************************************************************
  39398. - * TLan Definitions
  39399. - *
  39400. - ****************************************************************/
  39401. +#include "timer.h"
  39402. +#include "tlan.h"
  39403. -#define TLAN_MIN_FRAME_SIZE 64
  39404. -#define TLAN_MAX_FRAME_SIZE 1600
  39405. +#define drv_version "v1.4"
  39406. +#define drv_date "01-17-2004"
  39407. -#define TLAN_NUM_RX_LISTS 32
  39408. -#define TLAN_NUM_TX_LISTS 64
  39409. +/* NIC specific static variables go here */
  39410. +#define HZ 100
  39411. +#define TX_TIME_OUT (6*HZ)
  39412. -#define TLAN_IGNORE 0
  39413. -#define TLAN_RECORD 1
  39414. +#ifdef EB50
  39415. +#define cpu_to_le32(val) (val)
  39416. +#define le32_to_cpu(val) (val)
  39417. +#define virt_to_bus(x) ((unsigned long) x)
  39418. +#define bus_to_virt(x) ((unsigned long) x)
  39419. +#endif
  39420. -#define TLAN_DBG(lvl, format, args...) if (debug&lvl) printf("TLAN: " format, ##args );
  39421. -#define TLAN_DEBUG_GNRL 0x0001
  39422. -#define TLAN_DEBUG_TX 0x0002
  39423. -#define TLAN_DEBUG_RX 0x0004
  39424. -#define TLAN_DEBUG_LIST 0x0008
  39425. -#define TLAN_DEBUG_PROBE 0x0010
  39426. +/* Condensed operations for readability. */
  39427. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  39428. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  39429. -#define MAX_TLAN_BOARDS 8 /* Max number of boards installed at a time */
  39430. - /*****************************************************************
  39431. - * Device Identification Definitions
  39432. - *
  39433. - ****************************************************************/
  39434. -
  39435. -#define PCI_DEVICE_ID_NETELLIGENT_10_T2 0xB012
  39436. -#define PCI_DEVICE_ID_NETELLIGENT_10_100_WS_5100 0xB030
  39437. -#ifndef PCI_DEVICE_ID_OLICOM_OC2183
  39438. -#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
  39439. -#endif
  39440. -#ifndef PCI_DEVICE_ID_OLICOM_OC2325
  39441. -#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
  39442. -#endif
  39443. -#ifndef PCI_DEVICE_ID_OLICOM_OC2326
  39444. -#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
  39445. -#endif
  39446. -#define TLAN_ADAPTER_NONE 0x00000000
  39447. -#define TLAN_ADAPTER_UNMANAGED_PHY 0x00000001
  39448. -#define TLAN_ADAPTER_BIT_RATE_PHY 0x00000002
  39449. -#define TLAN_ADAPTER_USE_INTERN_10 0x00000004
  39450. -#define TLAN_ADAPTER_ACTIVITY_LED 0x00000008
  39451. -#define TLAN_SPEED_DEFAULT 0
  39452. -#define TLAN_SPEED_10 10
  39453. -#define TLAN_SPEED_100 100
  39454. -#define TLAN_DUPLEX_DEFAULT 0
  39455. -#define TLAN_DUPLEX_HALF 1
  39456. -#define TLAN_DUPLEX_FULL 2
  39457. -#define TLAN_BUFFERS_PER_LIST 10
  39458. -#define TLAN_LAST_BUFFER 0x80000000
  39459. -#define TLAN_CSTAT_UNUSED 0x8000
  39460. -#define TLAN_CSTAT_FRM_CMP 0x4000
  39461. -#define TLAN_CSTAT_READY 0x3000
  39462. -#define TLAN_CSTAT_EOC 0x0800
  39463. -#define TLAN_CSTAT_RX_ERROR 0x0400
  39464. -#define TLAN_CSTAT_PASS_CRC 0x0200
  39465. -#define TLAN_CSTAT_DP_PR 0x0100
  39466. -
  39467. - /*****************************************************************
  39468. - * PHY definitions
  39469. - *
  39470. - ****************************************************************/
  39471. -
  39472. -#define TLAN_PHY_MAX_ADDR 0x1F
  39473. -#define TLAN_PHY_NONE 0x20
  39474. -
  39475. - /*****************************************************************
  39476. - * TLan Driver Timer Definitions
  39477. - *
  39478. - ****************************************************************/
  39479. -
  39480. -#define TLAN_TIMER_LINK_BEAT 1
  39481. -#define TLAN_TIMER_ACTIVITY 2
  39482. -#define TLAN_TIMER_PHY_PDOWN 3
  39483. -#define TLAN_TIMER_PHY_PUP 4
  39484. -#define TLAN_TIMER_PHY_RESET 5
  39485. -#define TLAN_TIMER_PHY_START_LINK 6
  39486. -#define TLAN_TIMER_PHY_FINISH_AN 7
  39487. -#define TLAN_TIMER_FINISH_RESET 8
  39488. -#define TLAN_TIMER_ACT_DELAY (HZ/10)
  39489. -
  39490. - /*****************************************************************
  39491. - * TLan Driver Eeprom Definitions
  39492. - *
  39493. - ****************************************************************/
  39494. -
  39495. -#define TLAN_EEPROM_ACK 0
  39496. -#define TLAN_EEPROM_STOP 1
  39497. -
  39498. - /*****************************************************************
  39499. - * Host Register Offsets and Contents
  39500. - *
  39501. - ****************************************************************/
  39502. -
  39503. -#define TLAN_HOST_CMD 0x00
  39504. -#define TLAN_HC_GO 0x80000000
  39505. -#define TLAN_HC_STOP 0x40000000
  39506. -#define TLAN_HC_ACK 0x20000000
  39507. -#define TLAN_HC_CS_MASK 0x1FE00000
  39508. -#define TLAN_HC_EOC 0x00100000
  39509. -#define TLAN_HC_RT 0x00080000
  39510. -#define TLAN_HC_NES 0x00040000
  39511. -#define TLAN_HC_AD_RST 0x00008000
  39512. -#define TLAN_HC_LD_TMR 0x00004000
  39513. -#define TLAN_HC_LD_THR 0x00002000
  39514. -#define TLAN_HC_REQ_INT 0x00001000
  39515. -#define TLAN_HC_INT_OFF 0x00000800
  39516. -#define TLAN_HC_INT_ON 0x00000400
  39517. -#define TLAN_HC_AC_MASK 0x000000FF
  39518. -#define TLAN_CH_PARM 0x04
  39519. -#define TLAN_DIO_ADR 0x08
  39520. -#define TLAN_DA_ADR_INC 0x8000
  39521. -#define TLAN_DA_RAM_ADR 0x4000
  39522. -#define TLAN_HOST_INT 0x0A
  39523. -#define TLAN_HI_IV_MASK 0x1FE0
  39524. -#define TLAN_HI_IT_MASK 0x001C
  39525. -#define TLAN_DIO_DATA 0x0C
  39526. -
  39527. -/* ThunderLAN Internal Register DIO Offsets */
  39528. -
  39529. -#define TLAN_NET_CMD 0x00
  39530. -#define TLAN_NET_CMD_NRESET 0x80
  39531. -#define TLAN_NET_CMD_NWRAP 0x40
  39532. -#define TLAN_NET_CMD_CSF 0x20
  39533. -#define TLAN_NET_CMD_CAF 0x10
  39534. -#define TLAN_NET_CMD_NOBRX 0x08
  39535. -#define TLAN_NET_CMD_DUPLEX 0x04
  39536. -#define TLAN_NET_CMD_TRFRAM 0x02
  39537. -#define TLAN_NET_CMD_TXPACE 0x01
  39538. -#define TLAN_NET_SIO 0x01
  39539. -#define TLAN_NET_SIO_MINTEN 0x80
  39540. -#define TLAN_NET_SIO_ECLOK 0x40
  39541. -#define TLAN_NET_SIO_ETXEN 0x20
  39542. -#define TLAN_NET_SIO_EDATA 0x10
  39543. -#define TLAN_NET_SIO_NMRST 0x08
  39544. -#define TLAN_NET_SIO_MCLK 0x04
  39545. -#define TLAN_NET_SIO_MTXEN 0x02
  39546. -#define TLAN_NET_SIO_MDATA 0x01
  39547. -#define TLAN_NET_STS 0x02
  39548. -#define TLAN_NET_STS_MIRQ 0x80
  39549. -#define TLAN_NET_STS_HBEAT 0x40
  39550. -#define TLAN_NET_STS_TXSTOP 0x20
  39551. -#define TLAN_NET_STS_RXSTOP 0x10
  39552. -#define TLAN_NET_STS_RSRVD 0x0F
  39553. -#define TLAN_NET_MASK 0x03
  39554. -#define TLAN_NET_MASK_MASK7 0x80
  39555. -#define TLAN_NET_MASK_MASK6 0x40
  39556. -#define TLAN_NET_MASK_MASK5 0x20
  39557. -#define TLAN_NET_MASK_MASK4 0x10
  39558. -#define TLAN_NET_MASK_RSRVD 0x0F
  39559. -#define TLAN_NET_CONFIG 0x04
  39560. -#define TLAN_NET_CFG_RCLK 0x8000
  39561. -#define TLAN_NET_CFG_TCLK 0x4000
  39562. -#define TLAN_NET_CFG_BIT 0x2000
  39563. -#define TLAN_NET_CFG_RXCRC 0x1000
  39564. -#define TLAN_NET_CFG_PEF 0x0800
  39565. -#define TLAN_NET_CFG_1FRAG 0x0400
  39566. -#define TLAN_NET_CFG_1CHAN 0x0200
  39567. -#define TLAN_NET_CFG_MTEST 0x0100
  39568. -#define TLAN_NET_CFG_PHY_EN 0x0080
  39569. -#define TLAN_NET_CFG_MSMASK 0x007F
  39570. -#define TLAN_MAN_TEST 0x06
  39571. -#define TLAN_DEF_VENDOR_ID 0x08
  39572. -#define TLAN_DEF_DEVICE_ID 0x0A
  39573. -#define TLAN_DEF_REVISION 0x0C
  39574. -#define TLAN_DEF_SUBCLASS 0x0D
  39575. -#define TLAN_DEF_MIN_LAT 0x0E
  39576. -#define TLAN_DEF_MAX_LAT 0x0F
  39577. -#define TLAN_AREG_0 0x10
  39578. -#define TLAN_AREG_1 0x16
  39579. -#define TLAN_AREG_2 0x1C
  39580. -#define TLAN_AREG_3 0x22
  39581. -#define TLAN_HASH_1 0x28
  39582. -#define TLAN_HASH_2 0x2C
  39583. -#define TLAN_GOOD_TX_FRMS 0x30
  39584. -#define TLAN_TX_UNDERUNS 0x33
  39585. -#define TLAN_GOOD_RX_FRMS 0x34
  39586. -#define TLAN_RX_OVERRUNS 0x37
  39587. -#define TLAN_DEFERRED_TX 0x38
  39588. -#define TLAN_CRC_ERRORS 0x3A
  39589. -#define TLAN_CODE_ERRORS 0x3B
  39590. -#define TLAN_MULTICOL_FRMS 0x3C
  39591. -#define TLAN_SINGLECOL_FRMS 0x3E
  39592. -#define TLAN_EXCESSCOL_FRMS 0x40
  39593. -#define TLAN_LATE_COLS 0x41
  39594. -#define TLAN_CARRIER_LOSS 0x42
  39595. -#define TLAN_ACOMMIT 0x43
  39596. -#define TLAN_LED_REG 0x44
  39597. -#define TLAN_LED_ACT 0x10
  39598. -#define TLAN_LED_LINK 0x01
  39599. -#define TLAN_BSIZE_REG 0x45
  39600. -#define TLAN_MAX_RX 0x46
  39601. -#define TLAN_INT_DIS 0x48
  39602. -#define TLAN_ID_TX_EOC 0x04
  39603. -#define TLAN_ID_RX_EOF 0x02
  39604. -#define TLAN_ID_RX_EOC 0x01
  39605. -
  39606. -/* ThunderLAN Interrupt Codes */
  39607. -
  39608. -#define TLAN_INT_NUMBER_OF_INTS 8
  39609. -
  39610. -#define TLAN_INT_NONE 0x0000
  39611. -#define TLAN_INT_TX_EOF 0x0001
  39612. -#define TLAN_INT_STAT_OVERFLOW 0x0002
  39613. -#define TLAN_INT_RX_EOF 0x0003
  39614. -#define TLAN_INT_DUMMY 0x0004
  39615. -#define TLAN_INT_TX_EOC 0x0005
  39616. -#define TLAN_INT_STATUS_CHECK 0x0006
  39617. -#define TLAN_INT_RX_EOC 0x0007
  39618. -#define TLAN_TLPHY_ID 0x10
  39619. -#define TLAN_TLPHY_CTL 0x11
  39620. -#define TLAN_TC_IGLINK 0x8000
  39621. -#define TLAN_TC_SWAPOL 0x4000
  39622. -#define TLAN_TC_AUISEL 0x2000
  39623. -#define TLAN_TC_SQEEN 0x1000
  39624. -#define TLAN_TC_MTEST 0x0800
  39625. -#define TLAN_TC_RESERVED 0x07F8
  39626. -#define TLAN_TC_NFEW 0x0004
  39627. -#define TLAN_TC_INTEN 0x0002
  39628. -#define TLAN_TC_TINT 0x0001
  39629. -#define TLAN_TLPHY_STS 0x12
  39630. -#define TLAN_TS_MINT 0x8000
  39631. -#define TLAN_TS_PHOK 0x4000
  39632. -#define TLAN_TS_POLOK 0x2000
  39633. -#define TLAN_TS_TPENERGY 0x1000
  39634. -#define TLAN_TS_RESERVED 0x0FFF
  39635. -#define TLAN_TLPHY_PAR 0x19
  39636. -#define TLAN_PHY_CIM_STAT 0x0020
  39637. -#define TLAN_PHY_SPEED_100 0x0040
  39638. -#define TLAN_PHY_DUPLEX_FULL 0x0080
  39639. -#define TLAN_PHY_AN_EN_STAT 0x0400
  39640. -
  39641. -
  39642. -/* ThunderLAN MII Registers */
  39643. -
  39644. -/* Generic MII/PHY Registers */
  39645. -
  39646. -#define MII_GEN_CTL 0x00
  39647. -#define MII_GC_RESET 0x8000
  39648. -#define MII_GC_LOOPBK 0x4000
  39649. -#define MII_GC_SPEEDSEL 0x2000
  39650. -#define MII_GC_AUTOENB 0x1000
  39651. -#define MII_GC_PDOWN 0x0800
  39652. -#define MII_GC_ISOLATE 0x0400
  39653. -#define MII_GC_AUTORSRT 0x0200
  39654. -#define MII_GC_DUPLEX 0x0100
  39655. -#define MII_GC_COLTEST 0x0080
  39656. -#define MII_GC_RESERVED 0x007F
  39657. -#define MII_GEN_STS 0x01
  39658. -#define MII_GS_100BT4 0x8000
  39659. -#define MII_GS_100BTXFD 0x4000
  39660. -#define MII_GS_100BTXHD 0x2000
  39661. -#define MII_GS_10BTFD 0x1000
  39662. -#define MII_GS_10BTHD 0x0800
  39663. -#define MII_GS_RESERVED 0x07C0
  39664. -#define MII_GS_AUTOCMPLT 0x0020
  39665. -#define MII_GS_RFLT 0x0010
  39666. -#define MII_GS_AUTONEG 0x0008
  39667. -#define MII_GS_LINK 0x0004
  39668. -#define MII_GS_JABBER 0x0002
  39669. -#define MII_GS_EXTCAP 0x0001
  39670. -#define MII_GEN_ID_HI 0x02
  39671. -#define MII_GEN_ID_LO 0x03
  39672. -#define MII_GIL_OUI 0xFC00
  39673. -#define MII_GIL_MODEL 0x03F0
  39674. -#define MII_GIL_REVISION 0x000F
  39675. -#define MII_AN_ADV 0x04
  39676. -#define MII_AN_LPA 0x05
  39677. -#define MII_AN_EXP 0x06
  39678. -
  39679. -/* ThunderLAN Specific MII/PHY Registers */
  39680. -
  39681. -#define TLAN_TC_IGLINK 0x8000
  39682. -#define TLAN_TC_SWAPOL 0x4000
  39683. -#define TLAN_TC_AUISEL 0x2000
  39684. -#define TLAN_TC_SQEEN 0x1000
  39685. -#define TLAN_TC_MTEST 0x0800
  39686. -#define TLAN_TC_RESERVED 0x07F8
  39687. -#define TLAN_TC_NFEW 0x0004
  39688. -#define TLAN_TC_INTEN 0x0002
  39689. -#define TLAN_TC_TINT 0x0001
  39690. -#define TLAN_TS_MINT 0x8000
  39691. -#define TLAN_TS_PHOK 0x4000
  39692. -#define TLAN_TS_POLOK 0x2000
  39693. -#define TLAN_TS_TPENERGY 0x1000
  39694. -#define TLAN_TS_RESERVED 0x0FFF
  39695. -#define TLAN_PHY_CIM_STAT 0x0020
  39696. -#define TLAN_PHY_SPEED_100 0x0040
  39697. -#define TLAN_PHY_DUPLEX_FULL 0x0080
  39698. -#define TLAN_PHY_AN_EN_STAT 0x0400
  39699. -
  39700. -/* National Sem. & Level1 PHY id's */
  39701. -#define NAT_SEM_ID1 0x2000
  39702. -#define NAT_SEM_ID2 0x5C01
  39703. -#define LEVEL1_ID1 0x7810
  39704. -#define LEVEL1_ID2 0x0000
  39705. -
  39706. -#define TLan_ClearBit( bit, port ) outb_p(inb_p(port) & ~bit, port)
  39707. -#define TLan_GetBit( bit, port ) ((int) (inb_p(port) & bit))
  39708. -#define TLan_SetBit( bit, port ) outb_p(inb_p(port) | bit, port)
  39709. -
  39710. -typedef unsigned int u32;
  39711. -typedef unsigned short u16;
  39712. -typedef unsigned char u8;
  39713. +static void TLan_ResetLists(struct nic *nic __unused);
  39714. +static void TLan_ResetAdapter(struct nic *nic __unused);
  39715. +static void TLan_FinishReset(struct nic *nic __unused);
  39716. -/* Routines to access internal registers. */
  39717. +static void TLan_EeSendStart(u16);
  39718. +static int TLan_EeSendByte(u16, u8, int);
  39719. +static void TLan_EeReceiveByte(u16, u8 *, int);
  39720. +static int TLan_EeReadByte(u16 io_base, u8, u8 *);
  39721. -inline u8 TLan_DioRead8(u16 base_addr, u16 internal_addr)
  39722. -{
  39723. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  39724. - return (inb((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x3)));
  39725. -
  39726. -} /* TLan_DioRead8 */
  39727. +static void TLan_PhyDetect(struct nic *nic);
  39728. +static void TLan_PhyPowerDown(struct nic *nic);
  39729. +static void TLan_PhyPowerUp(struct nic *nic);
  39730. -inline u16 TLan_DioRead16(u16 base_addr, u16 internal_addr)
  39731. -{
  39732. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  39733. - return (inw((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x2)));
  39734. -} /* TLan_DioRead16 */
  39735. +static void TLan_SetMac(struct nic *nic __unused, int areg, char *mac);
  39736. -inline u32 TLan_DioRead32(u16 base_addr, u16 internal_addr)
  39737. -{
  39738. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  39739. - return (inl(base_addr + TLAN_DIO_DATA));
  39740. +static void TLan_PhyReset(struct nic *nic);
  39741. +static void TLan_PhyStartLink(struct nic *nic);
  39742. +static void TLan_PhyFinishAutoNeg(struct nic *nic);
  39743. -} /* TLan_DioRead32 */
  39744. +#ifdef MONITOR
  39745. +static void TLan_PhyMonitor(struct nic *nic);
  39746. +#endif
  39747. -inline void TLan_DioWrite8(u16 base_addr, u16 internal_addr, u8 data)
  39748. -{
  39749. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  39750. - outb(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x3));
  39751. -}
  39752. +static void refill_rx(struct nic *nic __unused);
  39753. -inline void TLan_DioWrite16(u16 base_addr, u16 internal_addr, u16 data)
  39754. -{
  39755. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  39756. - outw(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
  39757. +static int TLan_MiiReadReg(struct nic *nic __unused, u16, u16, u16 *);
  39758. +static void TLan_MiiSendData(u16, u32, unsigned);
  39759. +static void TLan_MiiSync(u16);
  39760. +static void TLan_MiiWriteReg(struct nic *nic __unused, u16, u16, u16);
  39761. -}
  39762. -inline void TLan_DioWrite32(u16 base_addr, u16 internal_addr, u32 data)
  39763. -{
  39764. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  39765. - outl(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
  39766. +const char *media[] = {
  39767. + "10BaseT-HD ", "10BaseT-FD ", "100baseTx-HD ",
  39768. + "100baseTx-FD", "100baseT4", 0
  39769. +};
  39770. -}
  39771. +/* This much match tlan_pci_tbl[]! */
  39772. +enum tlan_nics {
  39773. + NETEL10 = 0, NETEL100 = 1, NETFLEX3I = 2, THUNDER = 3, NETFLEX3B =
  39774. + 4, NETEL100PI = 5,
  39775. + NETEL100D = 6, NETEL100I = 7, OC2183 = 8, OC2325 = 9, OC2326 =
  39776. + 10, NETELLIGENT_10_100_WS_5100 = 11,
  39777. + NETELLIGENT_10_T2 = 12
  39778. +};
  39779. -/* NIC specific static variables go here */
  39780. +struct pci_id_info {
  39781. + const char *name;
  39782. + int nic_id;
  39783. + struct match_info {
  39784. + u32 pci, pci_mask, subsystem, subsystem_mask;
  39785. + u32 revision, revision_mask; /* Only 8 bits. */
  39786. + } id;
  39787. + u32 flags;
  39788. + u16 addrOfs; /* Address Offset */
  39789. +};
  39790. -/*****************************************************************************
  39791. -******************************************************************************
  39792. +static struct pci_id_info tlan_pci_tbl[] = {
  39793. + {"Compaq Netelligent 10 T PCI UTP", NETEL10,
  39794. + {0xae340e11, 0xffffffff, 0, 0, 0, 0},
  39795. + TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  39796. + {"Compaq Netelligent 10/100 TX PCI UTP", NETEL100,
  39797. + {0xae320e11, 0xffffffff, 0, 0, 0, 0},
  39798. + TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  39799. + {"Compaq Integrated NetFlex-3/P", NETFLEX3I,
  39800. + {0xae350e11, 0xffffffff, 0, 0, 0, 0},
  39801. + TLAN_ADAPTER_NONE, 0x83},
  39802. + {"Compaq NetFlex-3/P", THUNDER,
  39803. + {0xf1300e11, 0xffffffff, 0, 0, 0, 0},
  39804. + TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83},
  39805. + {"Compaq NetFlex-3/P", NETFLEX3B,
  39806. + {0xf1500e11, 0xffffffff, 0, 0, 0, 0},
  39807. + TLAN_ADAPTER_NONE, 0x83},
  39808. + {"Compaq Netelligent Integrated 10/100 TX UTP", NETEL100PI,
  39809. + {0xae430e11, 0xffffffff, 0, 0, 0, 0},
  39810. + TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  39811. + {"Compaq Netelligent Dual 10/100 TX PCI UTP", NETEL100D,
  39812. + {0xae400e11, 0xffffffff, 0, 0, 0, 0},
  39813. + TLAN_ADAPTER_NONE, 0x83},
  39814. + {"Compaq Netelligent 10/100 TX Embedded UTP", NETEL100I,
  39815. + {0xb0110e11, 0xffffffff, 0, 0, 0, 0},
  39816. + TLAN_ADAPTER_NONE, 0x83},
  39817. + {"Olicom OC-2183/2185", OC2183,
  39818. + {0x0013108d, 0xffffffff, 0, 0, 0, 0},
  39819. + TLAN_ADAPTER_USE_INTERN_10, 0x83},
  39820. + {"Olicom OC-2325", OC2325,
  39821. + {0x0012108d, 0xffffffff, 0, 0, 0, 0},
  39822. + TLAN_ADAPTER_UNMANAGED_PHY, 0xF8},
  39823. + {"Olicom OC-2326", OC2326,
  39824. + {0x0014108d, 0xffffffff, 0, 0, 0, 0},
  39825. + TLAN_ADAPTER_USE_INTERN_10, 0xF8},
  39826. + {"Compaq Netelligent 10/100 TX UTP", NETELLIGENT_10_100_WS_5100,
  39827. + {0xb0300e11, 0xffffffff, 0, 0, 0, 0},
  39828. + TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  39829. + {"Compaq Netelligent 10 T/2 PCI UTP/Coax", NETELLIGENT_10_T2,
  39830. + {0xb0120e11, 0xffffffff, 0, 0, 0, 0},
  39831. + TLAN_ADAPTER_NONE, 0x83},
  39832. + {"Compaq NetFlex-3/E", 0, /* EISA card */
  39833. + {0, 0, 0, 0, 0, 0},
  39834. + TLAN_ADAPTER_ACTIVITY_LED | TLAN_ADAPTER_UNMANAGED_PHY |
  39835. + TLAN_ADAPTER_BIT_RATE_PHY, 0x83},
  39836. + {"Compaq NetFlex-3/E", 0, /* EISA card */
  39837. + {0, 0, 0, 0, 0, 0},
  39838. + TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  39839. + {0, 0,
  39840. + {0, 0, 0, 0, 0, 0},
  39841. + 0, 0},
  39842. +};
  39843. - ThunderLAN Driver Eeprom routines
  39844. - The Compaq Netelligent 10 and 10/100 cards use a Microchip 24C02A
  39845. - EEPROM. These functions are based on information in Microchip's
  39846. - data sheet. I don't know how well this functions will work with
  39847. - other EEPROMs.
  39848. +struct TLanList {
  39849. + u32 forward;
  39850. + u16 cStat;
  39851. + u16 frameSize;
  39852. + struct {
  39853. + u32 count;
  39854. + u32 address;
  39855. + } buffer[TLAN_BUFFERS_PER_LIST];
  39856. +};
  39857. -******************************************************************************
  39858. -*****************************************************************************/
  39859. - /***************************************************************
  39860. - * TLan_EeSendStart
  39861. - *
  39862. - * Returns:
  39863. - * Nothing
  39864. - * Parms:
  39865. - * io_base The IO port base address for the
  39866. - * TLAN device with the EEPROM to
  39867. - * use.
  39868. - *
  39869. - * This function sends a start cycle to an EEPROM attached
  39870. - * to a TLAN chip.
  39871. - *
  39872. - **************************************************************/
  39873. -static void TLan_EeSendStart( u16 io_base )
  39874. -{
  39875. - u16 sio;
  39876. +struct TLanList tx_ring[TLAN_NUM_TX_LISTS];
  39877. +static unsigned char txb[TLAN_MAX_FRAME_SIZE * TLAN_NUM_TX_LISTS];
  39878. - outw( TLAN_NET_SIO, io_base + TLAN_DIO_ADR );
  39879. - sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  39880. +struct TLanList rx_ring[TLAN_NUM_RX_LISTS];
  39881. +static unsigned char rxb[TLAN_MAX_FRAME_SIZE * TLAN_NUM_RX_LISTS];
  39882. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  39883. - TLan_SetBit( TLAN_NET_SIO_EDATA, sio );
  39884. - TLan_SetBit( TLAN_NET_SIO_ETXEN, sio );
  39885. - TLan_ClearBit( TLAN_NET_SIO_EDATA, sio );
  39886. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  39887. +typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE];
  39888. -} /* TLan_EeSendStart */
  39889. - /***************************************************************
  39890. - * TLan_EeSendByte
  39891. - *
  39892. - * Returns:
  39893. - * If the correct ack was received, 0, otherwise 1
  39894. - * Parms: io_base The IO port base address for the
  39895. - * TLAN device with the EEPROM to
  39896. - * use.
  39897. - * data The 8 bits of information to
  39898. - * send to the EEPROM.
  39899. - * stop If TLAN_EEPROM_STOP is passed, a
  39900. - * stop cycle is sent after the
  39901. - * byte is sent after the ack is
  39902. - * read.
  39903. - *
  39904. - * This function sends a byte on the serial EEPROM line,
  39905. - * driving the clock to send each bit. The function then
  39906. - * reverses transmission direction and reads an acknowledge
  39907. - * bit.
  39908. - *
  39909. - **************************************************************/
  39910. +int chip_idx;
  39911. -static int TLan_EeSendByte( u16 io_base, u8 data, int stop )
  39912. -{
  39913. - int err;
  39914. - u8 place;
  39915. - u16 sio;
  39916. - outw( TLAN_NET_SIO, io_base + TLAN_DIO_ADR );
  39917. - sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  39918. +/*****************************************************************
  39919. +* TLAN Private Information Structure
  39920. +*
  39921. +****************************************************************/
  39922. +struct tlan_private {
  39923. + unsigned short vendor_id; /* PCI Vendor code */
  39924. + unsigned short dev_id; /* PCI Device code */
  39925. + const char *nic_name;
  39926. + u8 *padBuffer;
  39927. + u8 *rxBuffer;
  39928. + struct TLanList *rx_head_desc;
  39929. + u32 rxHead;
  39930. + u32 rxTail;
  39931. + u32 rxEocCount;
  39932. + unsigned int cur_rx, dirty_rx; /* Producer/consumer ring indicies */
  39933. + unsigned int cur_tx, dirty_tx;
  39934. + unsigned rx_buf_sz; /* Based on mtu + Slack */
  39935. + struct TLanList *txList;
  39936. + struct TLanList *rxList;
  39937. + u8 *txBuffer;
  39938. + u32 txHead;
  39939. + u32 txInProgress;
  39940. + u32 txTail;
  39941. + int eoc;
  39942. + u32 txBusyCount;
  39943. + u32 phyOnline;
  39944. + u32 timerSetAt;
  39945. + u32 timerType;
  39946. + u32 adapterRev;
  39947. + u32 aui;
  39948. + u32 debug;
  39949. + u32 duplex;
  39950. + u32 phy[2];
  39951. + u32 phyNum;
  39952. + u32 speed;
  39953. + u8 tlanRev;
  39954. + u8 tlanFullDuplex;
  39955. + char devName[8];
  39956. + u8 link;
  39957. + u8 is_eisa;
  39958. + u8 neg_be_verbose;
  39959. +} TLanPrivateInfo;
  39960. - /* Assume clock is low, tx is enabled; */
  39961. - for ( place = 0x80; place != 0; place >>= 1 ) {
  39962. - if ( place & data )
  39963. - TLan_SetBit( TLAN_NET_SIO_EDATA, sio );
  39964. - else
  39965. - TLan_ClearBit( TLAN_NET_SIO_EDATA, sio );
  39966. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  39967. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  39968. - }
  39969. - TLan_ClearBit( TLAN_NET_SIO_ETXEN, sio );
  39970. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  39971. - err = TLan_GetBit( TLAN_NET_SIO_EDATA, sio );
  39972. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  39973. - TLan_SetBit( TLAN_NET_SIO_ETXEN, sio );
  39974. +static struct tlan_private *priv;
  39975. - if ( ( ! err ) && stop ) {
  39976. - TLan_ClearBit( TLAN_NET_SIO_EDATA, sio ); /* STOP, raise data while clock is high */
  39977. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  39978. - TLan_SetBit( TLAN_NET_SIO_EDATA, sio );
  39979. - }
  39980. +u32 BASE;
  39981. - return ( err );
  39982. -} /* TLan_EeSendByte */
  39983. - /***************************************************************
  39984. - * TLan_EeReceiveByte
  39985. - *
  39986. - * Returns:
  39987. - * Nothing
  39988. - * Parms:
  39989. - * io_base The IO port base address for the
  39990. - * TLAN device with the EEPROM to
  39991. - * use.
  39992. - * data An address to a char to hold the
  39993. - * data sent from the EEPROM.
  39994. - * stop If TLAN_EEPROM_STOP is passed, a
  39995. - * stop cycle is sent after the
  39996. - * byte is received, and no ack is
  39997. - * sent.
  39998. - *
  39999. - * This function receives 8 bits of data from the EEPROM
  40000. - * over the serial link. It then sends and ack bit, or no
  40001. - * ack and a stop bit. This function is used to retrieve
  40002. - * data after the address of a byte in the EEPROM has been
  40003. - * sent.
  40004. - *
  40005. - **************************************************************/
  40006. +/***************************************************************
  40007. +* TLan_ResetLists
  40008. +*
  40009. +* Returns:
  40010. +* Nothing
  40011. +* Parms:
  40012. +* dev The device structure with the list
  40013. +* stuctures to be reset.
  40014. +*
  40015. +* This routine sets the variables associated with managing
  40016. +* the TLAN lists to their initial values.
  40017. +*
  40018. +**************************************************************/
  40019. -static void TLan_EeReceiveByte( u16 io_base, u8 *data, int stop )
  40020. +void TLan_ResetLists(struct nic *nic __unused)
  40021. {
  40022. - u8 place;
  40023. - u16 sio;
  40024. - outw( TLAN_NET_SIO, io_base + TLAN_DIO_ADR );
  40025. - sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  40026. - *data = 0;
  40027. + int i;
  40028. + struct TLanList *list;
  40029. + priv->txHead = 0;
  40030. + priv->txTail = 0;
  40031. - /* Assume clock is low, tx is enabled; */
  40032. - TLan_ClearBit( TLAN_NET_SIO_ETXEN, sio );
  40033. - for ( place = 0x80; place; place >>= 1 ) {
  40034. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  40035. - if ( TLan_GetBit( TLAN_NET_SIO_EDATA, sio ) )
  40036. - *data |= place;
  40037. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  40038. + for (i = 0; i < TLAN_NUM_TX_LISTS; i++) {
  40039. + list = &tx_ring[i];
  40040. + list->cStat = TLAN_CSTAT_UNUSED;
  40041. +/* list->buffer[0].address = 0; */
  40042. + list->buffer[0].address = virt_to_bus(txb +
  40043. + (i * TLAN_MAX_FRAME_SIZE));
  40044. + list->buffer[2].count = 0;
  40045. + list->buffer[2].address = 0;
  40046. + list->buffer[9].address = 0;
  40047. +/* list->forward = 0; */
  40048. }
  40049. - TLan_SetBit( TLAN_NET_SIO_ETXEN, sio );
  40050. - if ( ! stop ) {
  40051. - TLan_ClearBit( TLAN_NET_SIO_EDATA, sio ); /* Ack = 0 */
  40052. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  40053. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  40054. - } else {
  40055. - TLan_SetBit( TLAN_NET_SIO_EDATA, sio ); /* No ack = 1 (?) */
  40056. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  40057. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  40058. - TLan_ClearBit( TLAN_NET_SIO_EDATA, sio ); /* STOP, raise data while clock is high */
  40059. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  40060. - TLan_SetBit( TLAN_NET_SIO_EDATA, sio );
  40061. - }
  40062. + priv->cur_rx = 0;
  40063. + priv->rx_buf_sz = (TLAN_MAX_FRAME_SIZE);
  40064. + priv->rx_head_desc = &rx_ring[0];
  40065. +
  40066. + /* Initialize all the Rx descriptors */
  40067. + for (i = 0; i < TLAN_NUM_RX_LISTS; i++) {
  40068. + rx_ring[i].forward = virt_to_le32desc(&rx_ring[i + 1]);
  40069. + rx_ring[i].cStat = TLAN_CSTAT_READY;
  40070. + rx_ring[i].frameSize = TLAN_MAX_FRAME_SIZE;
  40071. + rx_ring[i].buffer[0].count =
  40072. + TLAN_MAX_FRAME_SIZE | TLAN_LAST_BUFFER;
  40073. + rx_ring[i].buffer[0].address =
  40074. + virt_to_le32desc(&rxb[i * TLAN_MAX_FRAME_SIZE]);
  40075. + rx_ring[i].buffer[1].count = 0;
  40076. + rx_ring[i].buffer[1].address = 0;
  40077. + }
  40078. +
  40079. + /* Mark the last entry as wrapping the ring */
  40080. + rx_ring[i - 1].forward = virt_to_le32desc(&rx_ring[0]);
  40081. + priv->dirty_rx = (unsigned int) (i - TLAN_NUM_RX_LISTS);
  40082. -} /* TLan_EeReceiveByte */
  40083. +} /* TLan_ResetLists */
  40084. - /***************************************************************
  40085. - * TLan_EeReadByte
  40086. - *
  40087. - * Returns:
  40088. - * No error = 0, else, the stage at which the error
  40089. - * occurred.
  40090. - * Parms:
  40091. - * io_base The IO port base address for the
  40092. - * TLAN device with the EEPROM to
  40093. - * use.
  40094. - * ee_addr The address of the byte in the
  40095. - * EEPROM whose contents are to be
  40096. - * retrieved.
  40097. - * data An address to a char to hold the
  40098. - * data obtained from the EEPROM.
  40099. - *
  40100. - * This function reads a byte of information from an byte
  40101. - * cell in the EEPROM.
  40102. - *
  40103. - **************************************************************/
  40104. +/***************************************************************
  40105. +* TLan_Reset
  40106. +*
  40107. +* Returns:
  40108. +* 0
  40109. +* Parms:
  40110. +* dev Pointer to device structure of adapter
  40111. +* to be reset.
  40112. +*
  40113. +* This function resets the adapter and it's physical
  40114. +* device. See Chap. 3, pp. 9-10 of the "ThunderLAN
  40115. +* Programmer's Guide" for details. The routine tries to
  40116. +* implement what is detailed there, though adjustments
  40117. +* have been made.
  40118. +*
  40119. +**************************************************************/
  40120. -static int TLan_EeReadByte( u16 io_base, u8 ee_addr, u8 *data )
  40121. +void TLan_ResetAdapter(struct nic *nic __unused)
  40122. {
  40123. - int err;
  40124. - unsigned long flags = 0;
  40125. - int ret=0;
  40126. + int i;
  40127. + u32 addr;
  40128. + u32 data;
  40129. + u8 data8;
  40130. - TLan_EeSendStart( io_base );
  40131. - err = TLan_EeSendByte( io_base, 0xA0, TLAN_EEPROM_ACK );
  40132. - if (err)
  40133. - {
  40134. - ret=1;
  40135. - goto fail;
  40136. - }
  40137. - err = TLan_EeSendByte( io_base, ee_addr, TLAN_EEPROM_ACK );
  40138. - if (err)
  40139. - {
  40140. - ret=2;
  40141. - goto fail;
  40142. - }
  40143. - TLan_EeSendStart( io_base );
  40144. - err = TLan_EeSendByte( io_base, 0xA1, TLAN_EEPROM_ACK );
  40145. - if (err)
  40146. - {
  40147. - ret=3;
  40148. - goto fail;
  40149. - }
  40150. - TLan_EeReceiveByte( io_base, data, TLAN_EEPROM_STOP );
  40151. -fail:
  40152. + priv->tlanFullDuplex = FALSE;
  40153. + priv->phyOnline = 0;
  40154. +/* 1. Assert reset bit. */
  40155. - return ret;
  40156. + data = inl(BASE + TLAN_HOST_CMD);
  40157. + data |= TLAN_HC_AD_RST;
  40158. + outl(data, BASE + TLAN_HOST_CMD);
  40159. -} /* TLan_EeReadByte */
  40160. + udelay(1000);
  40161. -#if 0
  40162. -/* Not yet converted from Linux driver */
  40163. -/*****************************************************************************
  40164. -******************************************************************************
  40165. +/* 2. Turn off interrupts. ( Probably isn't necessary ) */
  40166. - ThunderLAN Driver PHY Layer Routines
  40167. + data = inl(BASE + TLAN_HOST_CMD);
  40168. + data |= TLAN_HC_INT_OFF;
  40169. + outl(data, BASE + TLAN_HOST_CMD);
  40170. +/* 3. Clear AREGs and HASHs. */
  40171. -******************************************************************************
  40172. -*****************************************************************************/
  40173. + for (i = TLAN_AREG_0; i <= TLAN_HASH_2; i += 4) {
  40174. + TLan_DioWrite32(BASE, (u16) i, 0);
  40175. + }
  40176. - /*********************************************************************
  40177. - * TLan_PhyPrint
  40178. - *
  40179. - * Returns:
  40180. - * Nothing
  40181. - * Parms:
  40182. - * dev A pointer to the device structure of the
  40183. - * TLAN device having the PHYs to be detailed.
  40184. - *
  40185. - * This function prints the registers a PHY (aka tranceiver).
  40186. - *
  40187. - ********************************************************************/
  40188. +/* 4. Setup NetConfig register. */
  40189. -void TLan_PhyPrint( struct net_device *dev )
  40190. -{
  40191. - TLanPrivateInfo *priv = dev->priv;
  40192. - u16 i, data0, data1, data2, data3, phy;
  40193. + data =
  40194. + TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN;
  40195. + TLan_DioWrite16(BASE, TLAN_NET_CONFIG, (u16) data);
  40196. - phy = priv->phy[priv->phyNum];
  40197. +/* 5. Load Ld_Tmr and Ld_Thr in HOST_CMD. */
  40198. - if ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) {
  40199. - printk( "TLAN: Device %s, Unmanaged PHY.\n", dev->name );
  40200. - } else if ( phy <= TLAN_PHY_MAX_ADDR ) {
  40201. - printk( "TLAN: Device %s, PHY 0x%02x.\n", dev->name, phy );
  40202. - printk( "TLAN: Off. +0 +1 +2 +3 \n" );
  40203. - for ( i = 0; i < 0x20; i+= 4 ) {
  40204. - printk( "TLAN: 0x%02x", i );
  40205. - TLan_MiiReadReg( dev, phy, i, &data0 );
  40206. - printk( " 0x%04hx", data0 );
  40207. - TLan_MiiReadReg( dev, phy, i + 1, &data1 );
  40208. - printk( " 0x%04hx", data1 );
  40209. - TLan_MiiReadReg( dev, phy, i + 2, &data2 );
  40210. - printk( " 0x%04hx", data2 );
  40211. - TLan_MiiReadReg( dev, phy, i + 3, &data3 );
  40212. - printk( " 0x%04hx\n", data3 );
  40213. - }
  40214. - } else {
  40215. - printk( "TLAN: Device %s, Invalid PHY.\n", dev->name );
  40216. - }
  40217. + outl(TLAN_HC_LD_TMR | 0x3f, BASE + TLAN_HOST_CMD);
  40218. + outl(TLAN_HC_LD_THR | 0x0, BASE + TLAN_HOST_CMD);
  40219. -} /* TLan_PhyPrint */
  40220. +/* 6. Unreset the MII by setting NMRST (in NetSio) to 1. */
  40221. - /*********************************************************************
  40222. - * TLan_PhyDetect
  40223. - *
  40224. - * Returns:
  40225. - * Nothing
  40226. - * Parms:
  40227. - * dev A pointer to the device structure of the adapter
  40228. - * for which the PHY needs determined.
  40229. - *
  40230. - * So far I've found that adapters which have external PHYs
  40231. - * may also use the internal PHY for part of the functionality.
  40232. - * (eg, AUI/Thinnet). This function finds out if this TLAN
  40233. - * chip has an internal PHY, and then finds the first external
  40234. - * PHY (starting from address 0) if it exists).
  40235. - *
  40236. - ********************************************************************/
  40237. + outw(TLAN_NET_SIO, BASE + TLAN_DIO_ADR);
  40238. + addr = BASE + TLAN_DIO_DATA + TLAN_NET_SIO;
  40239. + TLan_SetBit(TLAN_NET_SIO_NMRST, addr);
  40240. -void TLan_PhyDetect( struct net_device *dev )
  40241. -{
  40242. - TLanPrivateInfo *priv = dev->priv;
  40243. - u16 control;
  40244. - u16 hi;
  40245. - u16 lo;
  40246. - u32 phy;
  40247. +/* 7. Setup the remaining registers. */
  40248. - if ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) {
  40249. - priv->phyNum = 0xFFFF;
  40250. - return;
  40251. + if (priv->tlanRev >= 0x30) {
  40252. + data8 = TLAN_ID_TX_EOC | TLAN_ID_RX_EOC;
  40253. + TLan_DioWrite8(BASE, TLAN_INT_DIS, data8);
  40254. }
  40255. + TLan_PhyDetect(nic);
  40256. + data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN;
  40257. - TLan_MiiReadReg( dev, TLAN_PHY_MAX_ADDR, MII_GEN_ID_HI, &hi );
  40258. -
  40259. - if ( hi != 0xFFFF ) {
  40260. - priv->phy[0] = TLAN_PHY_MAX_ADDR;
  40261. - } else {
  40262. - priv->phy[0] = TLAN_PHY_NONE;
  40263. + if (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_BIT_RATE_PHY) {
  40264. + data |= TLAN_NET_CFG_BIT;
  40265. + if (priv->aui == 1) {
  40266. + TLan_DioWrite8(BASE, TLAN_ACOMMIT, 0x0a);
  40267. + } else if (priv->duplex == TLAN_DUPLEX_FULL) {
  40268. + TLan_DioWrite8(BASE, TLAN_ACOMMIT, 0x00);
  40269. + priv->tlanFullDuplex = TRUE;
  40270. + } else {
  40271. + TLan_DioWrite8(BASE, TLAN_ACOMMIT, 0x08);
  40272. + }
  40273. }
  40274. - priv->phy[1] = TLAN_PHY_NONE;
  40275. - for ( phy = 0; phy <= TLAN_PHY_MAX_ADDR; phy++ ) {
  40276. - TLan_MiiReadReg( dev, phy, MII_GEN_CTL, &control );
  40277. - TLan_MiiReadReg( dev, phy, MII_GEN_ID_HI, &hi );
  40278. - TLan_MiiReadReg( dev, phy, MII_GEN_ID_LO, &lo );
  40279. - if ( ( control != 0xFFFF ) || ( hi != 0xFFFF ) || ( lo != 0xFFFF ) ) {
  40280. - TLAN_DBG( TLAN_DEBUG_GNRL, "PHY found at %02x %04x %04x %04x\n", phy, control, hi, lo );
  40281. - if ( ( priv->phy[1] == TLAN_PHY_NONE ) && ( phy != TLAN_PHY_MAX_ADDR ) ) {
  40282. - priv->phy[1] = phy;
  40283. - }
  40284. - }
  40285. + if (priv->phyNum == 0) {
  40286. + data |= TLAN_NET_CFG_PHY_EN;
  40287. }
  40288. + TLan_DioWrite16(BASE, TLAN_NET_CONFIG, (u16) data);
  40289. - if ( priv->phy[1] != TLAN_PHY_NONE ) {
  40290. - priv->phyNum = 1;
  40291. - } else if ( priv->phy[0] != TLAN_PHY_NONE ) {
  40292. - priv->phyNum = 0;
  40293. + if (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY) {
  40294. + TLan_FinishReset(nic);
  40295. } else {
  40296. - printk( "TLAN: Cannot initialize device, no PHY was found!\n" );
  40297. + TLan_PhyPowerDown(nic);
  40298. }
  40299. -} /* TLan_PhyDetect */
  40300. +} /* TLan_ResetAdapter */
  40301. -void TLan_PhyPowerDown( struct net_device *dev )
  40302. +void TLan_FinishReset(struct nic *nic)
  40303. {
  40304. - TLanPrivateInfo *priv = dev->priv;
  40305. - u16 value;
  40306. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Powering down PHY(s).\n", dev->name );
  40307. - value = MII_GC_PDOWN | MII_GC_LOOPBK | MII_GC_ISOLATE;
  40308. - TLan_MiiSync( dev->base_addr );
  40309. - TLan_MiiWriteReg( dev, priv->phy[priv->phyNum], MII_GEN_CTL, value );
  40310. - if ( ( priv->phyNum == 0 ) && ( priv->phy[1] != TLAN_PHY_NONE ) && ( ! ( priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10 ) ) ) {
  40311. - TLan_MiiSync( dev->base_addr );
  40312. - TLan_MiiWriteReg( dev, priv->phy[1], MII_GEN_CTL, value );
  40313. + u8 data;
  40314. + u32 phy;
  40315. + u8 sio;
  40316. + u16 status;
  40317. + u16 partner;
  40318. + u16 tlphy_ctl;
  40319. + u16 tlphy_par;
  40320. + u16 tlphy_id1, tlphy_id2;
  40321. + int i;
  40322. +
  40323. + phy = priv->phy[priv->phyNum];
  40324. +
  40325. + data = TLAN_NET_CMD_NRESET | TLAN_NET_CMD_NWRAP;
  40326. + if (priv->tlanFullDuplex) {
  40327. + data |= TLAN_NET_CMD_DUPLEX;
  40328. }
  40329. + TLan_DioWrite8(BASE, TLAN_NET_CMD, data);
  40330. + data = TLAN_NET_MASK_MASK4 | TLAN_NET_MASK_MASK5;
  40331. + if (priv->phyNum == 0) {
  40332. + data |= TLAN_NET_MASK_MASK7;
  40333. + }
  40334. + TLan_DioWrite8(BASE, TLAN_NET_MASK, data);
  40335. + TLan_DioWrite16(BASE, TLAN_MAX_RX, ((1536) + 7) & ~7);
  40336. + TLan_MiiReadReg(nic, phy, MII_GEN_ID_HI, &tlphy_id1);
  40337. + TLan_MiiReadReg(nic, phy, MII_GEN_ID_LO, &tlphy_id2);
  40338. - /* Wait for 50 ms and powerup
  40339. - * This is abitrary. It is intended to make sure the
  40340. - * tranceiver settles.
  40341. - */
  40342. - TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_PUP );
  40343. + if ((tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY)
  40344. + || (priv->aui)) {
  40345. + status = MII_GS_LINK;
  40346. + printf("TLAN: %s: Link forced.\n", priv->nic_name);
  40347. + } else {
  40348. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  40349. + udelay(1000);
  40350. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  40351. + if ((status & MII_GS_LINK) && /* We only support link info on Nat.Sem. PHY's */
  40352. + (tlphy_id1 == NAT_SEM_ID1)
  40353. + && (tlphy_id2 == NAT_SEM_ID2)) {
  40354. + TLan_MiiReadReg(nic, phy, MII_AN_LPA, &partner);
  40355. + TLan_MiiReadReg(nic, phy, TLAN_TLPHY_PAR,
  40356. + &tlphy_par);
  40357. -} /* TLan_PhyPowerDown */
  40358. + printf("TLAN: %s: Link active with ",
  40359. + priv->nic_name);
  40360. + if (!(tlphy_par & TLAN_PHY_AN_EN_STAT)) {
  40361. + printf("forced 10%sMbps %s-Duplex\n",
  40362. + tlphy_par & TLAN_PHY_SPEED_100 ? ""
  40363. + : "0",
  40364. + tlphy_par & TLAN_PHY_DUPLEX_FULL ?
  40365. + "Full" : "Half");
  40366. + } else {
  40367. + printf
  40368. + ("AutoNegotiation enabled, at 10%sMbps %s-Duplex\n",
  40369. + tlphy_par & TLAN_PHY_SPEED_100 ? "" :
  40370. + "0",
  40371. + tlphy_par & TLAN_PHY_DUPLEX_FULL ?
  40372. + "Full" : "Half");
  40373. + printf("TLAN: Partner capability: ");
  40374. + for (i = 5; i <= 10; i++)
  40375. + if (partner & (1 << i))
  40376. + printf("%s", media[i - 5]);
  40377. + printf("\n");
  40378. + }
  40379. -void TLan_PhyPowerUp( struct net_device *dev )
  40380. -{
  40381. - TLanPrivateInfo *priv = dev->priv;
  40382. - u16 value;
  40383. + TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
  40384. +#ifdef MONITOR
  40385. + /* We have link beat..for now anyway */
  40386. + priv->link = 1;
  40387. + /*Enabling link beat monitoring */
  40388. + /* TLan_SetTimer( nic, (10*HZ), TLAN_TIMER_LINK_BEAT ); */
  40389. + mdelay(10000);
  40390. + TLan_PhyMonitor(nic);
  40391. +#endif
  40392. + } else if (status & MII_GS_LINK) {
  40393. + printf("TLAN: %s: Link active\n", priv->nic_name);
  40394. + TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
  40395. + }
  40396. + }
  40397. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Powering up PHY.\n", dev->name );
  40398. - TLan_MiiSync( dev->base_addr );
  40399. - value = MII_GC_LOOPBK;
  40400. - TLan_MiiWriteReg( dev, priv->phy[priv->phyNum], MII_GEN_CTL, value );
  40401. - TLan_MiiSync(dev->base_addr);
  40402. - /* Wait for 500 ms and reset the
  40403. - * tranceiver. The TLAN docs say both 50 ms and
  40404. - * 500 ms, so do the longer, just in case.
  40405. - */
  40406. - TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_RESET );
  40407. + if (priv->phyNum == 0) {
  40408. + TLan_MiiReadReg(nic, phy, TLAN_TLPHY_CTL, &tlphy_ctl);
  40409. + tlphy_ctl |= TLAN_TC_INTEN;
  40410. + TLan_MiiWriteReg(nic, phy, TLAN_TLPHY_CTL, tlphy_ctl);
  40411. + sio = TLan_DioRead8(BASE, TLAN_NET_SIO);
  40412. + sio |= TLAN_NET_SIO_MINTEN;
  40413. + TLan_DioWrite8(BASE, TLAN_NET_SIO, sio);
  40414. + }
  40415. -} /* TLan_PhyPowerUp */
  40416. + if (status & MII_GS_LINK) {
  40417. + TLan_SetMac(nic, 0, nic->node_addr);
  40418. + priv->phyOnline = 1;
  40419. + outb((TLAN_HC_INT_ON >> 8), BASE + TLAN_HOST_CMD + 1);
  40420. +/* if ( debug >= 1 && debug != TLAN_DEBUG_PROBE ) {
  40421. + outb( ( TLAN_HC_REQ_INT >> 8 ), BASE + TLAN_HOST_CMD + 1 );
  40422. + }
  40423. -void TLan_PhyReset( struct net_device *dev )
  40424. -{
  40425. - TLanPrivateInfo *priv = dev->priv;
  40426. - u16 phy;
  40427. - u16 value;
  40428. + */
  40429. + outl(virt_to_bus(&rx_ring), BASE + TLAN_CH_PARM);
  40430. + outl(TLAN_HC_GO | TLAN_HC_RT, BASE + TLAN_HOST_CMD);
  40431. + } else {
  40432. + printf
  40433. + ("TLAN: %s: Link inactive, will retry in 10 secs...\n",
  40434. + priv->nic_name);
  40435. + /* TLan_SetTimer( nic, (10*HZ), TLAN_TIMER_FINISH_RESET ); */
  40436. + mdelay(10000);
  40437. + TLan_FinishReset(nic);
  40438. + return;
  40439. - phy = priv->phy[priv->phyNum];
  40440. + }
  40441. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Reseting PHY.\n", dev->name );
  40442. - TLan_MiiSync( dev->base_addr );
  40443. - value = MII_GC_LOOPBK | MII_GC_RESET;
  40444. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, value );
  40445. - TLan_MiiReadReg( dev, phy, MII_GEN_CTL, &value );
  40446. - while ( value & MII_GC_RESET ) {
  40447. - TLan_MiiReadReg( dev, phy, MII_GEN_CTL, &value );
  40448. - }
  40449. -
  40450. - /* Wait for 500 ms and initialize.
  40451. - * I don't remember why I wait this long.
  40452. - * I've changed this to 50ms, as it seems long enough.
  40453. - */
  40454. - TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_START_LINK );
  40455. -
  40456. -} /* TLan_PhyReset */
  40457. -
  40458. -void TLan_PhyStartLink( struct net_device *dev )
  40459. -{
  40460. - TLanPrivateInfo *priv = dev->priv;
  40461. - u16 ability;
  40462. - u16 control;
  40463. - u16 data;
  40464. - u16 phy;
  40465. - u16 status;
  40466. - u16 tctl;
  40467. -
  40468. - phy = priv->phy[priv->phyNum];
  40469. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Trying to activate link.\n", dev->name );
  40470. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status );
  40471. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &ability );
  40472. -
  40473. - if ( ( status & MII_GS_AUTONEG ) &&
  40474. - ( ! priv->aui ) ) {
  40475. - ability = status >> 11;
  40476. - if ( priv->speed == TLAN_SPEED_10 &&
  40477. - priv->duplex == TLAN_DUPLEX_HALF) {
  40478. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x0000);
  40479. - } else if ( priv->speed == TLAN_SPEED_10 &&
  40480. - priv->duplex == TLAN_DUPLEX_FULL) {
  40481. - priv->tlanFullDuplex = TRUE;
  40482. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x0100);
  40483. - } else if ( priv->speed == TLAN_SPEED_100 &&
  40484. - priv->duplex == TLAN_DUPLEX_HALF) {
  40485. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x2000);
  40486. - } else if ( priv->speed == TLAN_SPEED_100 &&
  40487. - priv->duplex == TLAN_DUPLEX_FULL) {
  40488. - priv->tlanFullDuplex = TRUE;
  40489. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x2100);
  40490. - } else {
  40491. -
  40492. - /* Set Auto-Neg advertisement */
  40493. - TLan_MiiWriteReg( dev, phy, MII_AN_ADV, (ability << 5) | 1);
  40494. - /* Enablee Auto-Neg */
  40495. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x1000 );
  40496. - /* Restart Auto-Neg */
  40497. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x1200 );
  40498. - /* Wait for 4 sec for autonegotiation
  40499. - * to complete. The max spec time is less than this
  40500. - * but the card need additional time to start AN.
  40501. - * .5 sec should be plenty extra.
  40502. - */
  40503. - printk( "TLAN: %s: Starting autonegotiation.\n", dev->name );
  40504. - TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_PHY_FINISH_AN );
  40505. - return;
  40506. - }
  40507. -
  40508. - }
  40509. -
  40510. - if ( ( priv->aui ) && ( priv->phyNum != 0 ) ) {
  40511. - priv->phyNum = 0;
  40512. - data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN;
  40513. - TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, data );
  40514. - TLan_SetTimer( dev, (40*HZ/1000), TLAN_TIMER_PHY_PDOWN );
  40515. - return;
  40516. - } else if ( priv->phyNum == 0 ) {
  40517. - TLan_MiiReadReg( dev, phy, TLAN_TLPHY_CTL, &tctl );
  40518. - if ( priv->aui ) {
  40519. - tctl |= TLAN_TC_AUISEL;
  40520. - } else {
  40521. - tctl &= ~TLAN_TC_AUISEL;
  40522. - control = 0;
  40523. - if ( priv->duplex == TLAN_DUPLEX_FULL ) {
  40524. - control |= MII_GC_DUPLEX;
  40525. - priv->tlanFullDuplex = TRUE;
  40526. - }
  40527. - if ( priv->speed == TLAN_SPEED_100 ) {
  40528. - control |= MII_GC_SPEEDSEL;
  40529. - }
  40530. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, control );
  40531. - }
  40532. - TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tctl );
  40533. - }
  40534. -
  40535. - /* Wait for 2 sec to give the tranceiver time
  40536. - * to establish link.
  40537. - */
  40538. - TLan_SetTimer( dev, (4*HZ), TLAN_TIMER_FINISH_RESET );
  40539. -
  40540. -} /* TLan_PhyStartLink */
  40541. -
  40542. -void TLan_PhyFinishAutoNeg( struct net_device *dev )
  40543. -{
  40544. - TLanPrivateInfo *priv = dev->priv;
  40545. - u16 an_adv;
  40546. - u16 an_lpa;
  40547. - u16 data;
  40548. - u16 mode;
  40549. - u16 phy;
  40550. - u16 status;
  40551. -
  40552. - phy = priv->phy[priv->phyNum];
  40553. -
  40554. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status );
  40555. - udelay( 1000 );
  40556. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status );
  40557. -
  40558. - if ( ! ( status & MII_GS_AUTOCMPLT ) ) {
  40559. - /* Wait for 8 sec to give the process
  40560. - * more time. Perhaps we should fail after a while.
  40561. - */
  40562. - if (!priv->neg_be_verbose++) {
  40563. - printk(KERN_INFO "TLAN: Giving autonegotiation more time.\n");
  40564. - printk(KERN_INFO "TLAN: Please check that your adapter has\n");
  40565. - printk(KERN_INFO "TLAN: been properly connected to a HUB or Switch.\n");
  40566. - printk(KERN_INFO "TLAN: Trying to establish link in the background...\n");
  40567. - }
  40568. - TLan_SetTimer( dev, (8*HZ), TLAN_TIMER_PHY_FINISH_AN );
  40569. - return;
  40570. - }
  40571. -
  40572. - printk( "TLAN: %s: Autonegotiation complete.\n", dev->name );
  40573. - TLan_MiiReadReg( dev, phy, MII_AN_ADV, &an_adv );
  40574. - TLan_MiiReadReg( dev, phy, MII_AN_LPA, &an_lpa );
  40575. - mode = an_adv & an_lpa & 0x03E0;
  40576. - if ( mode & 0x0100 ) {
  40577. - priv->tlanFullDuplex = TRUE;
  40578. - } else if ( ! ( mode & 0x0080 ) && ( mode & 0x0040 ) ) {
  40579. - priv->tlanFullDuplex = TRUE;
  40580. - }
  40581. -
  40582. - if ( ( ! ( mode & 0x0180 ) ) && ( priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10 ) && ( priv->phyNum != 0 ) ) {
  40583. - priv->phyNum = 0;
  40584. - data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN;
  40585. - TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, data );
  40586. - TLan_SetTimer( dev, (400*HZ/1000), TLAN_TIMER_PHY_PDOWN );
  40587. - return;
  40588. - }
  40589. -
  40590. - if ( priv->phyNum == 0 ) {
  40591. - if ( ( priv->duplex == TLAN_DUPLEX_FULL ) || ( an_adv & an_lpa & 0x0040 ) ) {
  40592. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, MII_GC_AUTOENB | MII_GC_DUPLEX );
  40593. - printk( "TLAN: Starting internal PHY with FULL-DUPLEX\n" );
  40594. - } else {
  40595. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, MII_GC_AUTOENB );
  40596. - printk( "TLAN: Starting internal PHY with HALF-DUPLEX\n" );
  40597. - }
  40598. - }
  40599. -
  40600. - /* Wait for 100 ms. No reason in partiticular.
  40601. - */
  40602. - TLan_SetTimer( dev, (HZ/10), TLAN_TIMER_FINISH_RESET );
  40603. -
  40604. -} /* TLan_PhyFinishAutoNeg */
  40605. -
  40606. -#ifdef MONITOR
  40607. -
  40608. - /*********************************************************************
  40609. - *
  40610. - * TLan_phyMonitor
  40611. - *
  40612. - * Returns:
  40613. - * None
  40614. - *
  40615. - * Params:
  40616. - * dev The device structure of this device.
  40617. - *
  40618. - *
  40619. - * This function monitors PHY condition by reading the status
  40620. - * register via the MII bus. This can be used to give info
  40621. - * about link changes (up/down), and possible switch to alternate
  40622. - * media.
  40623. - *
  40624. - * ******************************************************************/
  40625. -
  40626. -void TLan_PhyMonitor( struct net_device *dev )
  40627. -{
  40628. - TLanPrivateInfo *priv = dev->priv;
  40629. - u16 phy;
  40630. - u16 phy_status;
  40631. -
  40632. - phy = priv->phy[priv->phyNum];
  40633. -
  40634. - /* Get PHY status register */
  40635. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &phy_status );
  40636. -
  40637. - /* Check if link has been lost */
  40638. - if (!(phy_status & MII_GS_LINK)) {
  40639. - if (priv->link) {
  40640. - priv->link = 0;
  40641. - printk(KERN_DEBUG "TLAN: %s has lost link\n", dev->name);
  40642. - dev->flags &= ~IFF_RUNNING;
  40643. - TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT );
  40644. - return;
  40645. - }
  40646. - }
  40647. -
  40648. - /* Link restablished? */
  40649. - if ((phy_status & MII_GS_LINK) && !priv->link) {
  40650. - priv->link = 1;
  40651. - printk(KERN_DEBUG "TLAN: %s has reestablished link\n", dev->name);
  40652. - dev->flags |= IFF_RUNNING;
  40653. - }
  40654. -
  40655. - /* Setup a new monitor */
  40656. - TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT );
  40657. -}
  40658. -
  40659. -#endif /* MONITOR */
  40660. -
  40661. -/*****************************************************************************
  40662. -******************************************************************************
  40663. -
  40664. - ThunderLAN Driver MII Routines
  40665. -
  40666. - These routines are based on the information in Chap. 2 of the
  40667. - "ThunderLAN Programmer's Guide", pp. 15-24.
  40668. -
  40669. -******************************************************************************
  40670. -*****************************************************************************/
  40671. -
  40672. - /***************************************************************
  40673. - * TLan_MiiReadReg
  40674. - *
  40675. - * Returns:
  40676. - * 0 if ack received ok
  40677. - * 1 otherwise.
  40678. - *
  40679. - * Parms:
  40680. - * dev The device structure containing
  40681. - * The io address and interrupt count
  40682. - * for this device.
  40683. - * phy The address of the PHY to be queried.
  40684. - * reg The register whose contents are to be
  40685. - * retreived.
  40686. - * val A pointer to a variable to store the
  40687. - * retrieved value.
  40688. - *
  40689. - * This function uses the TLAN's MII bus to retreive the contents
  40690. - * of a given register on a PHY. It sends the appropriate info
  40691. - * and then reads the 16-bit register value from the MII bus via
  40692. - * the TLAN SIO register.
  40693. - *
  40694. - **************************************************************/
  40695. -
  40696. -int TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val )
  40697. -{
  40698. - u8 nack;
  40699. - u16 sio, tmp;
  40700. - u32 i;
  40701. - int err;
  40702. - int minten;
  40703. - TLanPrivateInfo *priv = dev->priv;
  40704. - unsigned long flags = 0;
  40705. -
  40706. - err = FALSE;
  40707. - outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR);
  40708. - sio = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO;
  40709. -
  40710. - if (!in_irq())
  40711. - spin_lock_irqsave(&priv->lock, flags);
  40712. -
  40713. - TLan_MiiSync(dev->base_addr);
  40714. -
  40715. - minten = TLan_GetBit( TLAN_NET_SIO_MINTEN, sio );
  40716. - if ( minten )
  40717. - TLan_ClearBit(TLAN_NET_SIO_MINTEN, sio);
  40718. -
  40719. - TLan_MiiSendData( dev->base_addr, 0x1, 2 ); /* Start ( 01b ) */
  40720. - TLan_MiiSendData( dev->base_addr, 0x2, 2 ); /* Read ( 10b ) */
  40721. - TLan_MiiSendData( dev->base_addr, phy, 5 ); /* Device # */
  40722. - TLan_MiiSendData( dev->base_addr, reg, 5 ); /* Register # */
  40723. -
  40724. - TLan_ClearBit(TLAN_NET_SIO_MTXEN, sio); /* Change direction */
  40725. -
  40726. - TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Clock Idle bit */
  40727. - TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  40728. - TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Wait 300ns */
  40729. -
  40730. - nack = TLan_GetBit(TLAN_NET_SIO_MDATA, sio); /* Check for ACK */
  40731. - TLan_SetBit(TLAN_NET_SIO_MCLK, sio); /* Finish ACK */
  40732. - if (nack) { /* No ACK, so fake it */
  40733. - for (i = 0; i < 16; i++) {
  40734. - TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  40735. - TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  40736. - }
  40737. - tmp = 0xffff;
  40738. - err = TRUE;
  40739. - } else { /* ACK, so read data */
  40740. - for (tmp = 0, i = 0x8000; i; i >>= 1) {
  40741. - TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  40742. - if (TLan_GetBit(TLAN_NET_SIO_MDATA, sio))
  40743. - tmp |= i;
  40744. - TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  40745. - }
  40746. - }
  40747. -
  40748. - TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Idle cycle */
  40749. - TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  40750. -
  40751. - if ( minten )
  40752. - TLan_SetBit(TLAN_NET_SIO_MINTEN, sio);
  40753. -
  40754. - *val = tmp;
  40755. -
  40756. - if (!in_irq())
  40757. - spin_unlock_irqrestore(&priv->lock, flags);
  40758. -
  40759. - return err;
  40760. -
  40761. -} /* TLan_MiiReadReg */
  40762. -
  40763. - /***************************************************************
  40764. - * TLan_MiiSendData
  40765. - *
  40766. - * Returns:
  40767. - * Nothing
  40768. - * Parms:
  40769. - * base_port The base IO port of the adapter in
  40770. - * question.
  40771. - * dev The address of the PHY to be queried.
  40772. - * data The value to be placed on the MII bus.
  40773. - * num_bits The number of bits in data that are to
  40774. - * be placed on the MII bus.
  40775. - *
  40776. - * This function sends on sequence of bits on the MII
  40777. - * configuration bus.
  40778. - *
  40779. - **************************************************************/
  40780. -
  40781. -void TLan_MiiSendData( u16 base_port, u32 data, unsigned num_bits )
  40782. -{
  40783. - u16 sio;
  40784. - u32 i;
  40785. -
  40786. - if ( num_bits == 0 )
  40787. - return;
  40788. -
  40789. - outw( TLAN_NET_SIO, base_port + TLAN_DIO_ADR );
  40790. - sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  40791. - TLan_SetBit( TLAN_NET_SIO_MTXEN, sio );
  40792. -
  40793. - for ( i = ( 0x1 << ( num_bits - 1 ) ); i; i >>= 1 ) {
  40794. - TLan_ClearBit( TLAN_NET_SIO_MCLK, sio );
  40795. - (void) TLan_GetBit( TLAN_NET_SIO_MCLK, sio );
  40796. - if ( data & i )
  40797. - TLan_SetBit( TLAN_NET_SIO_MDATA, sio );
  40798. - else
  40799. - TLan_ClearBit( TLAN_NET_SIO_MDATA, sio );
  40800. - TLan_SetBit( TLAN_NET_SIO_MCLK, sio );
  40801. - (void) TLan_GetBit( TLAN_NET_SIO_MCLK, sio );
  40802. - }
  40803. -
  40804. -} /* TLan_MiiSendData */
  40805. -
  40806. - /***************************************************************
  40807. - * TLan_MiiSync
  40808. - *
  40809. - * Returns:
  40810. - * Nothing
  40811. - * Parms:
  40812. - * base_port The base IO port of the adapter in
  40813. - * question.
  40814. - *
  40815. - * This functions syncs all PHYs in terms of the MII configuration
  40816. - * bus.
  40817. - *
  40818. - **************************************************************/
  40819. -
  40820. -void TLan_MiiSync( u16 base_port )
  40821. -{
  40822. - int i;
  40823. - u16 sio;
  40824. -
  40825. - outw( TLAN_NET_SIO, base_port + TLAN_DIO_ADR );
  40826. - sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  40827. -
  40828. - TLan_ClearBit( TLAN_NET_SIO_MTXEN, sio );
  40829. - for ( i = 0; i < 32; i++ ) {
  40830. - TLan_ClearBit( TLAN_NET_SIO_MCLK, sio );
  40831. - TLan_SetBit( TLAN_NET_SIO_MCLK, sio );
  40832. - }
  40833. -
  40834. -} /* TLan_MiiSync */
  40835. -
  40836. - /***************************************************************
  40837. - * TLan_MiiWriteReg
  40838. - *
  40839. - * Returns:
  40840. - * Nothing
  40841. - * Parms:
  40842. - * dev The device structure for the device
  40843. - * to write to.
  40844. - * phy The address of the PHY to be written to.
  40845. - * reg The register whose contents are to be
  40846. - * written.
  40847. - * val The value to be written to the register.
  40848. - *
  40849. - * This function uses the TLAN's MII bus to write the contents of a
  40850. - * given register on a PHY. It sends the appropriate info and then
  40851. - * writes the 16-bit register value from the MII configuration bus
  40852. - * via the TLAN SIO register.
  40853. - *
  40854. - **************************************************************/
  40855. -
  40856. -void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val )
  40857. -{
  40858. - u16 sio;
  40859. - int minten;
  40860. - unsigned long flags = 0;
  40861. - TLanPrivateInfo *priv = dev->priv;
  40862. -
  40863. - outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR);
  40864. - sio = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO;
  40865. -
  40866. - if (!in_irq())
  40867. - spin_lock_irqsave(&priv->lock, flags);
  40868. -
  40869. - TLan_MiiSync( dev->base_addr );
  40870. -
  40871. - minten = TLan_GetBit( TLAN_NET_SIO_MINTEN, sio );
  40872. - if ( minten )
  40873. - TLan_ClearBit( TLAN_NET_SIO_MINTEN, sio );
  40874. -
  40875. - TLan_MiiSendData( dev->base_addr, 0x1, 2 ); /* Start ( 01b ) */
  40876. - TLan_MiiSendData( dev->base_addr, 0x1, 2 ); /* Write ( 01b ) */
  40877. - TLan_MiiSendData( dev->base_addr, phy, 5 ); /* Device # */
  40878. - TLan_MiiSendData( dev->base_addr, reg, 5 ); /* Register # */
  40879. -
  40880. - TLan_MiiSendData( dev->base_addr, 0x2, 2 ); /* Send ACK */
  40881. - TLan_MiiSendData( dev->base_addr, val, 16 ); /* Send Data */
  40882. -
  40883. - TLan_ClearBit( TLAN_NET_SIO_MCLK, sio ); /* Idle cycle */
  40884. - TLan_SetBit( TLAN_NET_SIO_MCLK, sio );
  40885. -
  40886. - if ( minten )
  40887. - TLan_SetBit( TLAN_NET_SIO_MINTEN, sio );
  40888. -
  40889. - if (!in_irq())
  40890. - spin_unlock_irqrestore(&priv->lock, flags);
  40891. -
  40892. -} /* TLan_MiiWriteReg */
  40893. -#endif
  40894. -
  40895. -/**************************************************************************
  40896. -RESET - Reset adapter
  40897. -***************************************************************************/
  40898. -static void skel_reset(struct nic *nic)
  40899. -{
  40900. - /* put the card in its initial state */
  40901. -}
  40902. -
  40903. -/**************************************************************************
  40904. -POLL - Wait for a frame
  40905. -***************************************************************************/
  40906. -static int skel_poll(struct nic *nic)
  40907. -{
  40908. - /* return true if there's an ethernet packet ready to read */
  40909. - /* nic->packet should contain data on return */
  40910. - /* nic->packetlen should contain length of data */
  40911. - return (0); /* initially as this is called to flush the input */
  40912. -}
  40913. -
  40914. -/**************************************************************************
  40915. -TRANSMIT - Transmit a frame
  40916. -***************************************************************************/
  40917. -static void skel_transmit(
  40918. - struct nic *nic,
  40919. - const char *d, /* Destination */
  40920. - unsigned int t, /* Type */
  40921. - unsigned int s, /* size */
  40922. - const char *p) /* Packet */
  40923. -{
  40924. - /* send the packet to destination */
  40925. -}
  40926. -
  40927. -/**************************************************************************
  40928. -DISABLE - Turn off ethernet interface
  40929. -***************************************************************************/
  40930. -static void skel_disable(struct nic *nic)
  40931. -{
  40932. -}
  40933. -
  40934. -/**************************************************************************
  40935. -PROBE - Look for an adapter, this routine's visible to the outside
  40936. -You should omit the last argument struct pci_device * for a non-PCI NIC
  40937. -***************************************************************************/
  40938. -struct nic *tlan_probe(struct nic *nic, unsigned short *probe_addrs,
  40939. - struct pci_device *p)
  40940. -{
  40941. - /* if probe_addrs is 0, then routine can use a hardwired default */
  40942. - /* if board found */
  40943. - {
  40944. - /* point to NIC specific routines */
  40945. - nic->reset = skel_reset;
  40946. - nic->poll = skel_poll;
  40947. - nic->transmit = skel_transmit;
  40948. - nic->disable = skel_disable;
  40949. - return nic;
  40950. - }
  40951. - /* else */
  40952. - return 0;
  40953. -}
  40954. -
  40955. -#if 0
  40956. -#ifndef TLAN_H
  40957. -#define TLAN_H
  40958. -/********************************************************************
  40959. - *
  40960. - * Linux ThunderLAN Driver
  40961. - *
  40962. - * tlan.h
  40963. - * by James Banks
  40964. - *
  40965. - * (C) 1997-1998 Caldera, Inc.
  40966. - * (C) 1999-2001 Torben Mathiasen
  40967. - *
  40968. - * This software may be used and distributed according to the terms
  40969. - * of the GNU General Public License, incorporated herein by reference.
  40970. - *
  40971. - ** This file is best viewed/edited with tabstop=4, colums>=132
  40972. - *
  40973. - *
  40974. - * Dec 10, 1999 Torben Mathiasen <torben.mathiasen@compaq.com>
  40975. - * New Maintainer
  40976. - *
  40977. - ********************************************************************/
  40978. -
  40979. -#include <asm/io.h>
  40980. -#include <asm/types.h>
  40981. -#include <linux/netdevice.h>
  40982. -
  40983. -#define FALSE 0
  40984. -#define TRUE 1
  40985. -
  40986. -#define TX_TIMEOUT (10*HZ) /* We need time for auto-neg */
  40987. -
  40988. -typedef struct tlan_adapter_entry {
  40989. - u16 vendorId;
  40990. - u16 deviceId;
  40991. - char *deviceLabel;
  40992. - u32 flags;
  40993. - u16 addrOfs;
  40994. -} TLanAdapterEntry;
  40995. -
  40996. - /*****************************************************************
  40997. - * EISA Definitions
  40998. - *
  40999. - ****************************************************************/
  41000. -
  41001. -#define EISA_ID 0xc80 /* EISA ID Registers */
  41002. -#define EISA_ID0 0xc80 /* EISA ID Register 0 */
  41003. -#define EISA_ID1 0xc81 /* EISA ID Register 1 */
  41004. -#define EISA_ID2 0xc82 /* EISA ID Register 2 */
  41005. -#define EISA_ID3 0xc83 /* EISA ID Register 3 */
  41006. -#define EISA_CR 0xc84 /* EISA Control Register */
  41007. -#define EISA_REG0 0xc88 /* EISA Configuration Register 0 */
  41008. -#define EISA_REG1 0xc89 /* EISA Configuration Register 1 */
  41009. -#define EISA_REG2 0xc8a /* EISA Configuration Register 2 */
  41010. -#define EISA_REG3 0xc8f /* EISA Configuration Register 3 */
  41011. -#define EISA_APROM 0xc90 /* Ethernet Address PROM */
  41012. -
  41013. - /*****************************************************************
  41014. - * Rx/Tx List Definitions
  41015. - *
  41016. - ****************************************************************/
  41017. -
  41018. -typedef struct tlan_buffer_ref_tag {
  41019. - u32 count;
  41020. - u32 address;
  41021. -} TLanBufferRef;
  41022. -
  41023. -typedef struct tlan_list_tag {
  41024. - u32 forward;
  41025. - u16 cStat;
  41026. - u16 frameSize;
  41027. - TLanBufferRef buffer[TLAN_BUFFERS_PER_LIST];
  41028. -} TLanList;
  41029. -
  41030. -typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE];
  41031. -
  41032. - /*****************************************************************
  41033. - * TLAN Private Information Structure
  41034. - *
  41035. - ****************************************************************/
  41036. -
  41037. -typedef struct tlan_private_tag {
  41038. - struct net_device *nextDevice;
  41039. - void *dmaStorage;
  41040. - u8 *padBuffer;
  41041. - TLanList *rxList;
  41042. - u8 *rxBuffer;
  41043. - u32 rxHead;
  41044. - u32 rxTail;
  41045. - u32 rxEocCount;
  41046. - TLanList *txList;
  41047. - u8 *txBuffer;
  41048. - u32 txHead;
  41049. - u32 txInProgress;
  41050. - u32 txTail;
  41051. - u32 txBusyCount;
  41052. - u32 phyOnline;
  41053. - u32 timerSetAt;
  41054. - u32 timerType;
  41055. - struct timer_list timer;
  41056. - struct net_device_stats stats;
  41057. - struct board *adapter;
  41058. - u32 adapterRev;
  41059. - u32 aui;
  41060. - u32 debug;
  41061. - u32 duplex;
  41062. - u32 phy[2];
  41063. - u32 phyNum;
  41064. - u32 speed;
  41065. - u8 tlanRev;
  41066. - u8 tlanFullDuplex;
  41067. - char devName[8];
  41068. - spinlock_t lock;
  41069. - u8 link;
  41070. - u8 is_eisa;
  41071. - struct tq_struct tlan_tqueue;
  41072. - u8 neg_be_verbose;
  41073. -} TLanPrivateInfo;
  41074. -
  41075. -#define TLAN_HC_GO 0x80000000
  41076. -#define TLAN_HC_STOP 0x40000000
  41077. -#define TLAN_HC_ACK 0x20000000
  41078. -#define TLAN_HC_CS_MASK 0x1FE00000
  41079. -#define TLAN_HC_EOC 0x00100000
  41080. -#define TLAN_HC_RT 0x00080000
  41081. -#define TLAN_HC_NES 0x00040000
  41082. -#define TLAN_HC_AD_RST 0x00008000
  41083. -#define TLAN_HC_LD_TMR 0x00004000
  41084. -#define TLAN_HC_LD_THR 0x00002000
  41085. -#define TLAN_HC_REQ_INT 0x00001000
  41086. -#define TLAN_HC_INT_OFF 0x00000800
  41087. -#define TLAN_HC_INT_ON 0x00000400
  41088. -#define TLAN_HC_AC_MASK 0x000000FF
  41089. -#define TLAN_DA_ADR_INC 0x8000
  41090. -#define TLAN_DA_RAM_ADR 0x4000
  41091. -#define TLAN_HI_IV_MASK 0x1FE0
  41092. -#define TLAN_HI_IT_MASK 0x001C
  41093. -
  41094. -#define TLAN_NET_CMD_NRESET 0x80
  41095. -#define TLAN_NET_CMD_NWRAP 0x40
  41096. -#define TLAN_NET_CMD_CSF 0x20
  41097. -#define TLAN_NET_CMD_CAF 0x10
  41098. -#define TLAN_NET_CMD_NOBRX 0x08
  41099. -#define TLAN_NET_CMD_DUPLEX 0x04
  41100. -#define TLAN_NET_CMD_TRFRAM 0x02
  41101. -#define TLAN_NET_CMD_TXPACE 0x01
  41102. -#define TLAN_NET_SIO_MINTEN 0x80
  41103. -#define TLAN_NET_SIO_ECLOK 0x40
  41104. -#define TLAN_NET_SIO_ETXEN 0x20
  41105. -#define TLAN_NET_SIO_EDATA 0x10
  41106. -#define TLAN_NET_SIO_NMRST 0x08
  41107. -#define TLAN_NET_SIO_MCLK 0x04
  41108. -#define TLAN_NET_SIO_MTXEN 0x02
  41109. -#define TLAN_NET_SIO_MDATA 0x01
  41110. -#define TLAN_NET_STS_MIRQ 0x80
  41111. -#define TLAN_NET_STS_HBEAT 0x40
  41112. -#define TLAN_NET_STS_TXSTOP 0x20
  41113. -#define TLAN_NET_STS_RXSTOP 0x10
  41114. -#define TLAN_NET_STS_RSRVD 0x0F
  41115. -#define TLAN_NET_MASK_MASK7 0x80
  41116. -#define TLAN_NET_MASK_MASK6 0x40
  41117. -#define TLAN_NET_MASK_MASK5 0x20
  41118. -#define TLAN_NET_MASK_MASK4 0x10
  41119. -#define TLAN_NET_MASK_RSRVD 0x0F
  41120. -#define TLAN_NET_CFG_RCLK 0x8000
  41121. -#define TLAN_NET_CFG_TCLK 0x4000
  41122. -#define TLAN_NET_CFG_BIT 0x2000
  41123. -#define TLAN_NET_CFG_RXCRC 0x1000
  41124. -#define TLAN_NET_CFG_PEF 0x0800
  41125. -#define TLAN_NET_CFG_1FRAG 0x0400
  41126. -#define TLAN_NET_CFG_1CHAN 0x0200
  41127. -#define TLAN_NET_CFG_MTEST 0x0100
  41128. -#define TLAN_NET_CFG_PHY_EN 0x0080
  41129. -#define TLAN_NET_CFG_MSMASK 0x007F
  41130. -#define TLAN_LED_ACT 0x10
  41131. -#define TLAN_LED_LINK 0x01
  41132. -#define TLAN_ID_TX_EOC 0x04
  41133. -#define TLAN_ID_RX_EOF 0x02
  41134. -#define TLAN_ID_RX_EOC 0x01
  41135. -
  41136. -#define CIRC_INC( a, b ) if ( ++a >= b ) a = 0
  41137. -
  41138. -#ifdef I_LIKE_A_FAST_HASH_FUNCTION
  41139. -/* given 6 bytes, view them as 8 6-bit numbers and return the XOR of those */
  41140. -/* the code below is about seven times as fast as the original code */
  41141. -inline u32 TLan_HashFunc( u8 *a )
  41142. -{
  41143. - u8 hash;
  41144. -
  41145. - hash = (a[0]^a[3]); /* & 077 */
  41146. - hash ^= ((a[0]^a[3])>>6); /* & 003 */
  41147. - hash ^= ((a[1]^a[4])<<2); /* & 074 */
  41148. - hash ^= ((a[1]^a[4])>>4); /* & 017 */
  41149. - hash ^= ((a[2]^a[5])<<4); /* & 060 */
  41150. - hash ^= ((a[2]^a[5])>>2); /* & 077 */
  41151. -
  41152. - return (hash & 077);
  41153. -}
  41154. -
  41155. -#else /* original code */
  41156. -
  41157. -inline u32 xor( u32 a, u32 b )
  41158. -{
  41159. - return ( ( a && ! b ) || ( ! a && b ) );
  41160. -}
  41161. -#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 ) ) ) ) ) ) )
  41162. -#define DA( a, bit ) ( ( (u8) a[bit/8] ) & ( (u8) ( 1 << bit%8 ) ) )
  41163. -
  41164. -inline u32 TLan_HashFunc( u8 *a )
  41165. -{
  41166. - u32 hash;
  41167. -
  41168. - 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) );
  41169. - 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;
  41170. - 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;
  41171. - 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;
  41172. - 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;
  41173. - 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;
  41174. -
  41175. - return hash;
  41176. -
  41177. -}
  41178. -
  41179. -#endif /* I_LIKE_A_FAST_HASH_FUNCTION */
  41180. -#endif
  41181. -/*******************************************************************************
  41182. - *
  41183. - * Linux ThunderLAN Driver
  41184. - *
  41185. - * tlan.c
  41186. - * by James Banks
  41187. - *
  41188. - * (C) 1997-1998 Caldera, Inc.
  41189. - * (C) 1998 James Banks
  41190. - * (C) 1999-2001 Torben Mathiasen
  41191. - *
  41192. - * This software may be used and distributed according to the terms
  41193. - * of the GNU General Public License, incorporated herein by reference.
  41194. - *
  41195. - ** This file is best viewed/edited with columns>=132.
  41196. - *
  41197. - ** Useful (if not required) reading:
  41198. - *
  41199. - * Texas Instruments, ThunderLAN Programmer's Guide,
  41200. - * TI Literature Number SPWU013A
  41201. - * available in PDF format from www.ti.com
  41202. - * Level One, LXT901 and LXT970 Data Sheets
  41203. - * available in PDF format from www.level1.com
  41204. - * National Semiconductor, DP83840A Data Sheet
  41205. - * available in PDF format from www.national.com
  41206. - * Microchip Technology, 24C01A/02A/04A Data Sheet
  41207. - * available in PDF format from www.microchip.com
  41208. - *
  41209. - * Change History
  41210. - *
  41211. - * Tigran Aivazian <tigran@sco.com>: TLan_PciProbe() now uses
  41212. - * new PCI BIOS interface.
  41213. - * Alan Cox <alan@redhat.com>: Fixed the out of memory
  41214. - * handling.
  41215. - *
  41216. - * Torben Mathiasen <torben.mathiasen@compaq.com> New Maintainer!
  41217. - *
  41218. - * v1.1 Dec 20, 1999 - Removed linux version checking
  41219. - * Patch from Tigran Aivazian.
  41220. - * - v1.1 includes Alan's SMP updates.
  41221. - * - We still have problems on SMP though,
  41222. - * but I'm looking into that.
  41223. - *
  41224. - * v1.2 Jan 02, 2000 - Hopefully fixed the SMP deadlock.
  41225. - * - Removed dependency of HZ being 100.
  41226. - * - We now allow higher priority timers to
  41227. - * overwrite timers like TLAN_TIMER_ACTIVITY
  41228. - * Patch from John Cagle <john.cagle@compaq.com>.
  41229. - * - Fixed a few compiler warnings.
  41230. - *
  41231. - * v1.3 Feb 04, 2000 - Fixed the remaining HZ issues.
  41232. - * - Removed call to pci_present().
  41233. - * - Removed SA_INTERRUPT flag from irq handler.
  41234. - * - Added __init and __initdata to reduce resisdent
  41235. - * code size.
  41236. - * - Driver now uses module_init/module_exit.
  41237. - * - Rewrote init_module and tlan_probe to
  41238. - * share a lot more code. We now use tlan_probe
  41239. - * with builtin and module driver.
  41240. - * - Driver ported to new net API.
  41241. - * - tlan.txt has been reworked to reflect current
  41242. - * driver (almost)
  41243. - * - Other minor stuff
  41244. - *
  41245. - * v1.4 Feb 10, 2000 - Updated with more changes required after Dave's
  41246. - * network cleanup in 2.3.43pre7 (Tigran & myself)
  41247. - * - Minor stuff.
  41248. - *
  41249. - * v1.5 March 22, 2000 - Fixed another timer bug that would hang the driver
  41250. - * if no cable/link were present.
  41251. - * - Cosmetic changes.
  41252. - * - TODO: Port completely to new PCI/DMA API
  41253. - * Auto-Neg fallback.
  41254. - *
  41255. - * v1.6 April 04, 2000 - Fixed driver support for kernel-parameters. Haven't
  41256. - * tested it though, as the kernel support is currently
  41257. - * broken (2.3.99p4p3).
  41258. - * - Updated tlan.txt accordingly.
  41259. - * - Adjusted minimum/maximum frame length.
  41260. - * - There is now a TLAN website up at
  41261. - * http://tlan.kernel.dk
  41262. - *
  41263. - * v1.7 April 07, 2000 - Started to implement custom ioctls. Driver now
  41264. - * reports PHY information when used with Donald
  41265. - * Beckers userspace MII diagnostics utility.
  41266. - *
  41267. - * v1.8 April 23, 2000 - Fixed support for forced speed/duplex settings.
  41268. - * - Added link information to Auto-Neg and forced
  41269. - * modes. When NIC operates with auto-neg the driver
  41270. - * will report Link speed & duplex modes as well as
  41271. - * link partner abilities. When forced link is used,
  41272. - * the driver will report status of the established
  41273. - * link.
  41274. - * Please read tlan.txt for additional information.
  41275. - * - Removed call to check_region(), and used
  41276. - * return value of request_region() instead.
  41277. - *
  41278. - * v1.8a May 28, 2000 - Minor updates.
  41279. - *
  41280. - * v1.9 July 25, 2000 - Fixed a few remaining Full-Duplex issues.
  41281. - * - Updated with timer fixes from Andrew Morton.
  41282. - * - Fixed module race in TLan_Open.
  41283. - * - Added routine to monitor PHY status.
  41284. - * - Added activity led support for Proliant devices.
  41285. - *
  41286. - * v1.10 Aug 30, 2000 - Added support for EISA based tlan controllers
  41287. - * like the Compaq NetFlex3/E.
  41288. - * - Rewrote tlan_probe to better handle multiple
  41289. - * bus probes. Probing and device setup is now
  41290. - * done through TLan_Probe and TLan_init_one. Actual
  41291. - * hardware probe is done with kernel API and
  41292. - * TLan_EisaProbe.
  41293. - * - Adjusted debug information for probing.
  41294. - * - Fixed bug that would cause general debug information
  41295. - * to be printed after driver removal.
  41296. - * - Added transmit timeout handling.
  41297. - * - Fixed OOM return values in tlan_probe.
  41298. - * - Fixed possible mem leak in tlan_exit
  41299. - * (now tlan_remove_one).
  41300. - * - Fixed timer bug in TLan_phyMonitor.
  41301. - * - This driver version is alpha quality, please
  41302. - * send me any bug issues you may encounter.
  41303. - *
  41304. - * v1.11 Aug 31, 2000 - Do not try to register irq 0 if no irq line was
  41305. - * set for EISA cards.
  41306. - * - Added support for NetFlex3/E with nibble-rate
  41307. - * 10Base-T PHY. This is untestet as I haven't got
  41308. - * one of these cards.
  41309. - * - Fixed timer being added twice.
  41310. - * - Disabled PhyMonitoring by default as this is
  41311. - * work in progress. Define MONITOR to enable it.
  41312. - * - Now we don't display link info with PHYs that
  41313. - * doesn't support it (level1).
  41314. - * - Incresed tx_timeout beacuse of auto-neg.
  41315. - * - Adjusted timers for forced speeds.
  41316. - *
  41317. - * v1.12 Oct 12, 2000 - Minor fixes (memleak, init, etc.)
  41318. - *
  41319. - * v1.13 Nov 28, 2000 - Stop flooding console with auto-neg issues
  41320. - * when link can't be established.
  41321. - * - Added the bbuf option as a kernel parameter.
  41322. - * - Fixed ioaddr probe bug.
  41323. - * - Fixed stupid deadlock with MII interrupts.
  41324. - * - Added support for speed/duplex selection with
  41325. - * multiple nics.
  41326. - * - Added partly fix for TX Channel lockup with
  41327. - * TLAN v1.0 silicon. This needs to be investigated
  41328. - * further.
  41329. - *
  41330. - * v1.14 Dec 16, 2000 - Added support for servicing multiple frames per.
  41331. - * interrupt. Thanks goes to
  41332. - * Adam Keys <adam@ti.com>
  41333. - * Denis Beaudoin <dbeaudoin@ti.com>
  41334. - * for providing the patch.
  41335. - * - Fixed auto-neg output when using multiple
  41336. - * adapters.
  41337. - * - Converted to use new taskq interface.
  41338. - *
  41339. - * v1.14a Jan 6, 2001 - Minor adjustments (spinlocks, etc.)
  41340. - *
  41341. - *******************************************************************************/
  41342. -
  41343. -
  41344. -#include <linux/module.h>
  41345. -
  41346. -#include "tlan.h"
  41347. -
  41348. -#include <linux/init.h>
  41349. -#include <linux/ioport.h>
  41350. -#include <linux/pci.h>
  41351. -#include <linux/etherdevice.h>
  41352. -#include <linux/delay.h>
  41353. -#include <linux/spinlock.h>
  41354. -#include <linux/mii.h>
  41355. -
  41356. -typedef u32 (TLanIntVectorFunc)( struct net_device *, u16 );
  41357. -
  41358. -/* For removing EISA devices */
  41359. -static struct net_device *TLan_Eisa_Devices;
  41360. -
  41361. -static int TLanDevicesInstalled;
  41362. -
  41363. -/* Set speed, duplex and aui settings */
  41364. -static int aui[MAX_TLAN_BOARDS];
  41365. -static int duplex[MAX_TLAN_BOARDS];
  41366. -static int speed[MAX_TLAN_BOARDS];
  41367. -static int boards_found;
  41368. -
  41369. -MODULE_AUTHOR("Maintainer: Torben Mathiasen <torben.mathiasen@compaq.com>");
  41370. -MODULE_DESCRIPTION("Driver for TI ThunderLAN based ethernet PCI adapters");
  41371. -MODULE_LICENSE("GPL");
  41372. -
  41373. -MODULE_PARM(aui, "1-" __MODULE_STRING(MAX_TLAN_BOARDS) "i");
  41374. -MODULE_PARM(duplex, "1-" __MODULE_STRING(MAX_TLAN_BOARDS) "i");
  41375. -MODULE_PARM(speed, "1-" __MODULE_STRING(MAX_TLAN_BOARDS) "i");
  41376. -MODULE_PARM(debug, "i");
  41377. -MODULE_PARM(bbuf, "i");
  41378. -MODULE_PARM_DESC(aui, "ThunderLAN use AUI port(s) (0-1)");
  41379. -MODULE_PARM_DESC(duplex, "ThunderLAN duplex setting(s) (0-default, 1-half, 2-full)");
  41380. -MODULE_PARM_DESC(speed, "ThunderLAN port speen setting(s) (0,10,100)");
  41381. -MODULE_PARM_DESC(debug, "ThunderLAN debug mask");
  41382. -MODULE_PARM_DESC(bbuf, "ThunderLAN use big buffer (0-1)");
  41383. -EXPORT_NO_SYMBOLS;
  41384. -
  41385. -/* Define this to enable Link beat monitoring */
  41386. -#undef MONITOR
  41387. -
  41388. -/* Turn on debugging. See linux/Documentation/networking/tlan.txt for details */
  41389. -static int debug;
  41390. -
  41391. -static int bbuf;
  41392. -static u8 *TLanPadBuffer;
  41393. -static char TLanSignature[] = "TLAN";
  41394. -static const char tlan_banner[] = "ThunderLAN driver v1.14a\n";
  41395. -static int tlan_have_pci;
  41396. -static int tlan_have_eisa;
  41397. -
  41398. -const char *media[] = {
  41399. - "10BaseT-HD ", "10BaseT-FD ","100baseTx-HD ",
  41400. - "100baseTx-FD", "100baseT4", 0
  41401. -};
  41402. -
  41403. -int media_map[] = { 0x0020, 0x0040, 0x0080, 0x0100, 0x0200,};
  41404. -
  41405. -static struct board {
  41406. - const char *deviceLabel;
  41407. - u32 flags;
  41408. - u16 addrOfs;
  41409. -} board_info[] __devinitdata = {
  41410. - { "Compaq Netelligent 10 T PCI UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
  41411. - { "Compaq Netelligent 10/100 TX PCI UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
  41412. - { "Compaq Integrated NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 },
  41413. - { "Compaq NetFlex-3/P", TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83 },
  41414. - { "Compaq NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 },
  41415. - { "Compaq Netelligent Integrated 10/100 TX UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
  41416. - { "Compaq Netelligent Dual 10/100 TX PCI UTP", TLAN_ADAPTER_NONE, 0x83 },
  41417. - { "Compaq Netelligent 10/100 TX Embedded UTP", TLAN_ADAPTER_NONE, 0x83 },
  41418. - { "Olicom OC-2183/2185", TLAN_ADAPTER_USE_INTERN_10, 0x83 },
  41419. - { "Olicom OC-2325", TLAN_ADAPTER_UNMANAGED_PHY, 0xF8 },
  41420. - { "Olicom OC-2326", TLAN_ADAPTER_USE_INTERN_10, 0xF8 },
  41421. - { "Compaq Netelligent 10/100 TX UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
  41422. - { "Compaq Netelligent 10 T/2 PCI UTP/Coax", TLAN_ADAPTER_NONE, 0x83 },
  41423. - { "Compaq NetFlex-3/E", TLAN_ADAPTER_ACTIVITY_LED | /* EISA card */
  41424. - TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83 },
  41425. - { "Compaq NetFlex-3/E", TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, /* EISA card */
  41426. -};
  41427. -
  41428. -static struct pci_device_id tlan_pci_tbl[] __devinitdata = {
  41429. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL10,
  41430. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  41431. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100,
  41432. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
  41433. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETFLEX3I,
  41434. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 },
  41435. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_THUNDER,
  41436. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 },
  41437. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETFLEX3B,
  41438. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 },
  41439. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100PI,
  41440. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 },
  41441. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100D,
  41442. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 },
  41443. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100I,
  41444. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 },
  41445. - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2183,
  41446. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 },
  41447. - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2325,
  41448. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 },
  41449. - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2326,
  41450. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 },
  41451. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_NETELLIGENT_10_100_WS_5100,
  41452. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 },
  41453. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_NETELLIGENT_10_T2,
  41454. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 },
  41455. - { 0,}
  41456. -};
  41457. -MODULE_DEVICE_TABLE(pci, tlan_pci_tbl);
  41458. -
  41459. -static void TLan_EisaProbe( void );
  41460. -static void TLan_Eisa_Cleanup( void );
  41461. -static int TLan_Init( struct net_device * );
  41462. -static int TLan_Open( struct net_device *dev );
  41463. -static int TLan_StartTx( struct sk_buff *, struct net_device *);
  41464. -static void TLan_HandleInterrupt( int, void *, struct pt_regs *);
  41465. -static int TLan_Close( struct net_device *);
  41466. -static struct net_device_stats *TLan_GetStats( struct net_device *);
  41467. -static void TLan_SetMulticastList( struct net_device *);
  41468. -static int TLan_ioctl( struct net_device *dev, struct ifreq *rq, int cmd);
  41469. -static int TLan_probe1( struct pci_dev *pdev, long ioaddr, int irq, int rev, const struct pci_device_id *ent);
  41470. -static void TLan_tx_timeout( struct net_device *dev);
  41471. -static int tlan_init_one( struct pci_dev *pdev, const struct pci_device_id *ent);
  41472. -
  41473. -static u32 TLan_HandleInvalid( struct net_device *, u16 );
  41474. -static u32 TLan_HandleTxEOF( struct net_device *, u16 );
  41475. -static u32 TLan_HandleStatOverflow( struct net_device *, u16 );
  41476. -static u32 TLan_HandleRxEOF( struct net_device *, u16 );
  41477. -static u32 TLan_HandleDummy( struct net_device *, u16 );
  41478. -static u32 TLan_HandleTxEOC( struct net_device *, u16 );
  41479. -static u32 TLan_HandleStatusCheck( struct net_device *, u16 );
  41480. -static u32 TLan_HandleRxEOC( struct net_device *, u16 );
  41481. -
  41482. -static void TLan_Timer( unsigned long );
  41483. -
  41484. -static void TLan_ResetLists( struct net_device * );
  41485. -static void TLan_FreeLists( struct net_device * );
  41486. -static void TLan_PrintDio( u16 );
  41487. -static void TLan_PrintList( TLanList *, char *, int );
  41488. -static void TLan_ReadAndClearStats( struct net_device *, int );
  41489. -static void TLan_ResetAdapter( struct net_device * );
  41490. -static void TLan_FinishReset( struct net_device * );
  41491. -static void TLan_SetMac( struct net_device *, int areg, char *mac );
  41492. -
  41493. -static void TLan_PhyPrint( struct net_device * );
  41494. -static void TLan_PhyDetect( struct net_device * );
  41495. -static void TLan_PhyPowerDown( struct net_device * );
  41496. -static void TLan_PhyPowerUp( struct net_device * );
  41497. -static void TLan_PhyReset( struct net_device * );
  41498. -static void TLan_PhyStartLink( struct net_device * );
  41499. -static void TLan_PhyFinishAutoNeg( struct net_device * );
  41500. -#ifdef MONITOR
  41501. -static void TLan_PhyMonitor( struct net_device * );
  41502. -#endif
  41503. -
  41504. -/*
  41505. -static int TLan_PhyNop( struct net_device * );
  41506. -static int TLan_PhyInternalCheck( struct net_device * );
  41507. -static int TLan_PhyInternalService( struct net_device * );
  41508. -static int TLan_PhyDp83840aCheck( struct net_device * );
  41509. -*/
  41510. -
  41511. -static int TLan_MiiReadReg( struct net_device *, u16, u16, u16 * );
  41512. -static void TLan_MiiSendData( u16, u32, unsigned );
  41513. -static void TLan_MiiSync( u16 );
  41514. -static void TLan_MiiWriteReg( struct net_device *, u16, u16, u16 );
  41515. -
  41516. -static void TLan_EeSendStart( u16 );
  41517. -static int TLan_EeSendByte( u16, u8, int );
  41518. -static void TLan_EeReceiveByte( u16, u8 *, int );
  41519. -static int TLan_EeReadByte( struct net_device *, u8, u8 * );
  41520. -
  41521. -static TLanIntVectorFunc *TLanIntVector[TLAN_INT_NUMBER_OF_INTS] = {
  41522. - TLan_HandleInvalid,
  41523. - TLan_HandleTxEOF,
  41524. - TLan_HandleStatOverflow,
  41525. - TLan_HandleRxEOF,
  41526. - TLan_HandleDummy,
  41527. - TLan_HandleTxEOC,
  41528. - TLan_HandleStatusCheck,
  41529. - TLan_HandleRxEOC
  41530. -};
  41531. -
  41532. -static inline void
  41533. -TLan_SetTimer( struct net_device *dev, u32 ticks, u32 type )
  41534. -{
  41535. - TLanPrivateInfo *priv = dev->priv;
  41536. - unsigned long flags = 0;
  41537. -
  41538. - if (!in_irq())
  41539. - spin_lock_irqsave(&priv->lock, flags);
  41540. - if ( priv->timer.function != NULL &&
  41541. - priv->timerType != TLAN_TIMER_ACTIVITY ) {
  41542. - if (!in_irq())
  41543. - spin_unlock_irqrestore(&priv->lock, flags);
  41544. - return;
  41545. - }
  41546. - priv->timer.function = &TLan_Timer;
  41547. - if (!in_irq())
  41548. - spin_unlock_irqrestore(&priv->lock, flags);
  41549. -
  41550. - priv->timer.data = (unsigned long) dev;
  41551. - priv->timerSetAt = jiffies;
  41552. - priv->timerType = type;
  41553. - mod_timer(&priv->timer, jiffies + ticks);
  41554. -
  41555. -} /* TLan_SetTimer */
  41556. -
  41557. -/*****************************************************************************
  41558. -******************************************************************************
  41559. -
  41560. - ThunderLAN Driver Primary Functions
  41561. -
  41562. - These functions are more or less common to all Linux network drivers.
  41563. -
  41564. -******************************************************************************
  41565. -*****************************************************************************/
  41566. -
  41567. - /***************************************************************
  41568. - * tlan_remove_one
  41569. - *
  41570. - * Returns:
  41571. - * Nothing
  41572. - * Parms:
  41573. - * None
  41574. - *
  41575. - * Goes through the TLanDevices list and frees the device
  41576. - * structs and memory associated with each device (lists
  41577. - * and buffers). It also ureserves the IO port regions
  41578. - * associated with this device.
  41579. - *
  41580. - **************************************************************/
  41581. -
  41582. -static void __devexit tlan_remove_one( struct pci_dev *pdev)
  41583. -{
  41584. - struct net_device *dev = pci_get_drvdata( pdev );
  41585. - TLanPrivateInfo *priv = dev->priv;
  41586. -
  41587. - unregister_netdev( dev );
  41588. -
  41589. - if ( priv->dmaStorage ) {
  41590. - kfree( priv->dmaStorage );
  41591. - }
  41592. -
  41593. - release_region( dev->base_addr, 0x10 );
  41594. -
  41595. - kfree( dev );
  41596. -
  41597. - pci_set_drvdata( pdev, NULL );
  41598. -}
  41599. -
  41600. -static struct pci_driver tlan_driver = {
  41601. - name: "tlan",
  41602. - id_table: tlan_pci_tbl,
  41603. - probe: tlan_init_one,
  41604. - remove: tlan_remove_one,
  41605. -};
  41606. -
  41607. -static int __init tlan_probe(void)
  41608. -{
  41609. - static int pad_allocated;
  41610. -
  41611. - printk(KERN_INFO "%s", tlan_banner);
  41612. -
  41613. - TLanPadBuffer = (u8 *) kmalloc(TLAN_MIN_FRAME_SIZE,
  41614. - GFP_KERNEL);
  41615. -
  41616. - if (TLanPadBuffer == NULL) {
  41617. - printk(KERN_ERR "TLAN: Could not allocate memory for pad buffer.\n");
  41618. - return -ENOMEM;
  41619. - }
  41620. -
  41621. - memset(TLanPadBuffer, 0, TLAN_MIN_FRAME_SIZE);
  41622. - pad_allocated = 1;
  41623. -
  41624. - TLAN_DBG(TLAN_DEBUG_PROBE, "Starting PCI Probe....\n");
  41625. -
  41626. - /* Use new style PCI probing. Now the kernel will
  41627. - do most of this for us */
  41628. - pci_register_driver(&tlan_driver);
  41629. -
  41630. - TLAN_DBG(TLAN_DEBUG_PROBE, "Starting EISA Probe....\n");
  41631. - TLan_EisaProbe();
  41632. -
  41633. - printk(KERN_INFO "TLAN: %d device%s installed, PCI: %d EISA: %d\n",
  41634. - TLanDevicesInstalled, TLanDevicesInstalled == 1 ? "" : "s",
  41635. - tlan_have_pci, tlan_have_eisa);
  41636. -
  41637. - if (TLanDevicesInstalled == 0) {
  41638. - pci_unregister_driver(&tlan_driver);
  41639. - kfree(TLanPadBuffer);
  41640. - return -ENODEV;
  41641. - }
  41642. - return 0;
  41643. -}
  41644. -
  41645. -
  41646. -static int __devinit tlan_init_one( struct pci_dev *pdev,
  41647. - const struct pci_device_id *ent)
  41648. -{
  41649. - return TLan_probe1( pdev, -1, -1, 0, ent);
  41650. -}
  41651. -
  41652. -/*
  41653. - ***************************************************************
  41654. - * tlan_probe1
  41655. - *
  41656. - * Returns:
  41657. - * 0 on success, error code on error
  41658. - * Parms:
  41659. - * none
  41660. - *
  41661. - * The name is lower case to fit in with all the rest of
  41662. - * the netcard_probe names. This function looks for
  41663. - * another TLan based adapter, setting it up with the
  41664. - * allocated device struct if one is found.
  41665. - * tlan_probe has been ported to the new net API and
  41666. - * now allocates its own device structure. This function
  41667. - * is also used by modules.
  41668. - *
  41669. - **************************************************************/
  41670. -
  41671. -static int __devinit TLan_probe1(struct pci_dev *pdev,
  41672. - long ioaddr, int irq, int rev, const struct pci_device_id *ent )
  41673. -{
  41674. -
  41675. - struct net_device *dev;
  41676. - TLanPrivateInfo *priv;
  41677. - u8 pci_rev;
  41678. - u16 device_id;
  41679. - int reg;
  41680. -
  41681. - if (pdev && pci_enable_device(pdev))
  41682. - return -EIO;
  41683. -
  41684. - dev = init_etherdev(NULL, sizeof(TLanPrivateInfo));
  41685. - if (dev == NULL) {
  41686. - printk(KERN_ERR "TLAN: Could not allocate memory for device.\n");
  41687. - return -ENOMEM;
  41688. - }
  41689. - SET_MODULE_OWNER(dev);
  41690. -
  41691. - priv = dev->priv;
  41692. -
  41693. - /* Is this a PCI device? */
  41694. - if (pdev) {
  41695. - u32 pci_io_base = 0;
  41696. -
  41697. - priv->adapter = &board_info[ent->driver_data];
  41698. -
  41699. - pci_read_config_byte ( pdev, PCI_REVISION_ID, &pci_rev);
  41700. -
  41701. - for ( reg= 0; reg <= 5; reg ++ ) {
  41702. - if (pci_resource_flags(pdev, reg) & IORESOURCE_IO) {
  41703. - pci_io_base = pci_resource_start(pdev, reg);
  41704. - TLAN_DBG( TLAN_DEBUG_GNRL, "IO mapping is available at %x.\n",
  41705. - pci_io_base);
  41706. - break;
  41707. - }
  41708. - }
  41709. - if (!pci_io_base) {
  41710. - printk(KERN_ERR "TLAN: No IO mappings available\n");
  41711. - unregister_netdev(dev);
  41712. - kfree(dev);
  41713. - return -ENODEV;
  41714. - }
  41715. -
  41716. - dev->base_addr = pci_io_base;
  41717. - dev->irq = pdev->irq;
  41718. - priv->adapterRev = pci_rev;
  41719. - pci_set_master(pdev);
  41720. - pci_set_drvdata(pdev, dev);
  41721. -
  41722. - } else { /* EISA card */
  41723. - /* This is a hack. We need to know which board structure
  41724. - * is suited for this adapter */
  41725. - device_id = inw(ioaddr + EISA_ID2);
  41726. - priv->is_eisa = 1;
  41727. - if (device_id == 0x20F1) {
  41728. - priv->adapter = &board_info[13]; /* NetFlex-3/E */
  41729. - priv->adapterRev = 23; /* TLAN 2.3 */
  41730. - } else {
  41731. - priv->adapter = &board_info[14];
  41732. - priv->adapterRev = 10; /* TLAN 1.0 */
  41733. - }
  41734. - dev->base_addr = ioaddr;
  41735. - dev->irq = irq;
  41736. - }
  41737. -
  41738. - /* Kernel parameters */
  41739. - if (dev->mem_start) {
  41740. - priv->aui = dev->mem_start & 0x01;
  41741. - priv->duplex = ((dev->mem_start & 0x06) == 0x06) ? 0 : (dev->mem_start & 0x06) >> 1;
  41742. - priv->speed = ((dev->mem_start & 0x18) == 0x18) ? 0 : (dev->mem_start & 0x18) >> 3;
  41743. -
  41744. - if (priv->speed == 0x1) {
  41745. - priv->speed = TLAN_SPEED_10;
  41746. - } else if (priv->speed == 0x2) {
  41747. - priv->speed = TLAN_SPEED_100;
  41748. - }
  41749. - debug = priv->debug = dev->mem_end;
  41750. - } else {
  41751. - priv->aui = aui[boards_found];
  41752. - priv->speed = speed[boards_found];
  41753. - priv->duplex = duplex[boards_found];
  41754. - priv->debug = debug;
  41755. - }
  41756. -
  41757. - /* This will be used when we get an adapter error from
  41758. - * within our irq handler */
  41759. - INIT_LIST_HEAD(&priv->tlan_tqueue.list);
  41760. - priv->tlan_tqueue.sync = 0;
  41761. - priv->tlan_tqueue.routine = (void *)(void*)TLan_tx_timeout;
  41762. - priv->tlan_tqueue.data = dev;
  41763. -
  41764. - spin_lock_init(&priv->lock);
  41765. -
  41766. - if (TLan_Init(dev)) {
  41767. - printk(KERN_ERR "TLAN: Could not register device.\n");
  41768. - unregister_netdev(dev);
  41769. - kfree(dev);
  41770. - return -EAGAIN;
  41771. - } else {
  41772. -
  41773. - TLanDevicesInstalled++;
  41774. - boards_found++;
  41775. -
  41776. - /* pdev is NULL if this is an EISA device */
  41777. - if (pdev)
  41778. - tlan_have_pci++;
  41779. - else {
  41780. - priv->nextDevice = TLan_Eisa_Devices;
  41781. - TLan_Eisa_Devices = dev;
  41782. - tlan_have_eisa++;
  41783. - }
  41784. -
  41785. - printk(KERN_INFO "TLAN: %s irq=%2d, io=%04x, %s, Rev. %d\n",
  41786. - dev->name,
  41787. - (int) dev->irq,
  41788. - (int) dev->base_addr,
  41789. - priv->adapter->deviceLabel,
  41790. - priv->adapterRev);
  41791. - return 0;
  41792. - }
  41793. -
  41794. -}
  41795. +} /* TLan_FinishReset */
  41796. -static void TLan_Eisa_Cleanup(void)
  41797. -{
  41798. - struct net_device *dev;
  41799. - TLanPrivateInfo *priv;
  41800. -
  41801. - while( tlan_have_eisa ) {
  41802. - dev = TLan_Eisa_Devices;
  41803. - priv = dev->priv;
  41804. - if (priv->dmaStorage) {
  41805. - kfree(priv->dmaStorage);
  41806. - }
  41807. - release_region( dev->base_addr, 0x10);
  41808. - unregister_netdev( dev );
  41809. - TLan_Eisa_Devices = priv->nextDevice;
  41810. - kfree( dev );
  41811. - tlan_have_eisa--;
  41812. - }
  41813. -}
  41814. -
  41815. -
  41816. -static void __exit tlan_exit(void)
  41817. -{
  41818. - pci_unregister_driver(&tlan_driver);
  41819. -
  41820. - if (tlan_have_eisa)
  41821. - TLan_Eisa_Cleanup();
  41822. -
  41823. - kfree( TLanPadBuffer );
  41824. -
  41825. -}
  41826. -
  41827. -/* Module loading/unloading */
  41828. -module_init(tlan_probe);
  41829. -module_exit(tlan_exit);
  41830. -
  41831. - /**************************************************************
  41832. - * TLan_EisaProbe
  41833. - *
  41834. - * Returns: 0 on success, 1 otherwise
  41835. - *
  41836. - * Parms: None
  41837. - *
  41838. - *
  41839. - * This functions probes for EISA devices and calls
  41840. - * TLan_probe1 when one is found.
  41841. - *
  41842. - *************************************************************/
  41843. -
  41844. -static void __init TLan_EisaProbe (void)
  41845. +/**************************************************************************
  41846. +POLL - Wait for a frame
  41847. +***************************************************************************/
  41848. +static int tlan_poll(struct nic *nic, int retrieve)
  41849. {
  41850. - long ioaddr;
  41851. - int rc = -ENODEV;
  41852. - int irq;
  41853. - u16 device_id;
  41854. -
  41855. - if (!EISA_bus) {
  41856. - TLAN_DBG(TLAN_DEBUG_PROBE, "No EISA bus present\n");
  41857. - return;
  41858. - }
  41859. -
  41860. - /* Loop through all slots of the EISA bus */
  41861. - for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) {
  41862. -
  41863. - TLAN_DBG(TLAN_DEBUG_PROBE,"EISA_ID 0x%4x: 0x%4x\n", (int) ioaddr + 0xC80, inw(ioaddr + EISA_ID));
  41864. - TLAN_DBG(TLAN_DEBUG_PROBE,"EISA_ID 0x%4x: 0x%4x\n", (int) ioaddr + 0xC82, inw(ioaddr + EISA_ID2));
  41865. + /* return true if there's an ethernet packet ready to read */
  41866. + /* nic->packet should contain data on return */
  41867. + /* nic->packetlen should contain length of data */
  41868. + u32 framesize;
  41869. + u32 host_cmd = 0;
  41870. + u32 ack = 1;
  41871. + int eoc = 0;
  41872. + int entry = priv->cur_rx % TLAN_NUM_RX_LISTS;
  41873. + u16 tmpCStat = le32_to_cpu(rx_ring[entry].cStat);
  41874. + u16 host_int = inw(BASE + TLAN_HOST_INT);
  41875. - TLAN_DBG(TLAN_DEBUG_PROBE, "Probing for EISA adapter at IO: 0x%4x : ",
  41876. - (int) ioaddr);
  41877. - if (request_region(ioaddr, 0x10, TLanSignature) == NULL)
  41878. - goto out;
  41879. -
  41880. - if (inw(ioaddr + EISA_ID) != 0x110E) {
  41881. - release_region(ioaddr, 0x10);
  41882. - goto out;
  41883. - }
  41884. -
  41885. - device_id = inw(ioaddr + EISA_ID2);
  41886. - if (device_id != 0x20F1 && device_id != 0x40F1) {
  41887. - release_region (ioaddr, 0x10);
  41888. - goto out;
  41889. - }
  41890. -
  41891. - if (inb(ioaddr + EISA_CR) != 0x1) { /* Check if adapter is enabled */
  41892. - release_region (ioaddr, 0x10);
  41893. - goto out2;
  41894. - }
  41895. -
  41896. - if (debug == 0x10)
  41897. - printk("Found one\n");
  41898. + if ((tmpCStat & TLAN_CSTAT_FRM_CMP) && !retrieve)
  41899. + return 1;
  41900. - /* Get irq from board */
  41901. - switch (inb(ioaddr + 0xCC0)) {
  41902. - case(0x10):
  41903. - irq=5;
  41904. - break;
  41905. - case(0x20):
  41906. - irq=9;
  41907. - break;
  41908. - case(0x40):
  41909. - irq=10;
  41910. - break;
  41911. - case(0x80):
  41912. - irq=11;
  41913. - break;
  41914. - default:
  41915. - goto out;
  41916. - }
  41917. -
  41918. -
  41919. - /* Setup the newly found eisa adapter */
  41920. - rc = TLan_probe1( NULL, ioaddr, irq,
  41921. - 12, NULL);
  41922. - continue;
  41923. -
  41924. - out:
  41925. - if (debug == 0x10)
  41926. - printk("None found\n");
  41927. - continue;
  41928. -
  41929. - out2: if (debug == 0x10)
  41930. - printk("Card found but it is not enabled, skipping\n");
  41931. - continue;
  41932. -
  41933. - }
  41934. + outw(host_int, BASE + TLAN_HOST_INT);
  41935. -} /* TLan_EisaProbe */
  41936. + if (!(tmpCStat & TLAN_CSTAT_FRM_CMP))
  41937. + return 0;
  41938. -
  41939. + /* printf("PI-1: 0x%hX\n", host_int); */
  41940. + if (tmpCStat & TLAN_CSTAT_EOC)
  41941. + eoc = 1;
  41942. - /***************************************************************
  41943. - * TLan_Init
  41944. - *
  41945. - * Returns:
  41946. - * 0 on success, error code otherwise.
  41947. - * Parms:
  41948. - * dev The structure of the device to be
  41949. - * init'ed.
  41950. - *
  41951. - * This function completes the initialization of the
  41952. - * device structure and driver. It reserves the IO
  41953. - * addresses, allocates memory for the lists and bounce
  41954. - * buffers, retrieves the MAC address from the eeprom
  41955. - * and assignes the device's methods.
  41956. - *
  41957. - **************************************************************/
  41958. + framesize = rx_ring[entry].frameSize;
  41959. -static int TLan_Init( struct net_device *dev )
  41960. -{
  41961. - int dma_size;
  41962. - int err;
  41963. - int i;
  41964. - TLanPrivateInfo *priv;
  41965. + nic->packetlen = framesize;
  41966. - priv = dev->priv;
  41967. -
  41968. - if (!priv->is_eisa) /* EISA devices have already requested IO */
  41969. - if (!request_region( dev->base_addr, 0x10, TLanSignature )) {
  41970. - printk(KERN_ERR "TLAN: %s: IO port region 0x%lx size 0x%x in use.\n",
  41971. - dev->name,
  41972. - dev->base_addr,
  41973. - 0x10 );
  41974. - return -EIO;
  41975. +#ifdef EBDEBUG
  41976. + printf(".%d.", framesize);
  41977. +#endif
  41978. +
  41979. + memcpy(nic->packet, rxb +
  41980. + (priv->cur_rx * TLAN_MAX_FRAME_SIZE), nic->packetlen);
  41981. +
  41982. + rx_ring[entry].cStat = 0;
  41983. +#ifdef EBDEBUG
  41984. + //hex_dump(nic->packet, nic->packetlen);
  41985. + printf("%d", entry);
  41986. +#endif
  41987. + entry = (entry + 1) % TLAN_NUM_RX_LISTS;
  41988. + priv->cur_rx = entry;
  41989. + if (eoc) {
  41990. + if ((rx_ring[entry].cStat & TLAN_CSTAT_READY) ==
  41991. + TLAN_CSTAT_READY) {
  41992. + ack |= TLAN_HC_GO | TLAN_HC_RT;
  41993. + host_cmd = TLAN_HC_ACK | ack | 0x001C0000;
  41994. + outl(host_cmd, BASE + TLAN_HOST_CMD);
  41995. }
  41996. -
  41997. - if ( bbuf ) {
  41998. - dma_size = ( TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS )
  41999. - * ( sizeof(TLanList) + TLAN_MAX_FRAME_SIZE );
  42000. } else {
  42001. - dma_size = ( TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS )
  42002. - * ( sizeof(TLanList) );
  42003. - }
  42004. - priv->dmaStorage = kmalloc(dma_size, GFP_KERNEL | GFP_DMA);
  42005. - if ( priv->dmaStorage == NULL ) {
  42006. - printk(KERN_ERR "TLAN: Could not allocate lists and buffers for %s.\n",
  42007. - dev->name );
  42008. - release_region( dev->base_addr, 0x10 );
  42009. - return -ENOMEM;
  42010. - }
  42011. - memset( priv->dmaStorage, 0, dma_size );
  42012. - priv->rxList = (TLanList *)
  42013. - ( ( ( (u32) priv->dmaStorage ) + 7 ) & 0xFFFFFFF8 );
  42014. - priv->txList = priv->rxList + TLAN_NUM_RX_LISTS;
  42015. - if ( bbuf ) {
  42016. - priv->rxBuffer = (u8 *) ( priv->txList + TLAN_NUM_TX_LISTS );
  42017. - priv->txBuffer = priv->rxBuffer
  42018. - + ( TLAN_NUM_RX_LISTS * TLAN_MAX_FRAME_SIZE );
  42019. - }
  42020. -
  42021. - err = 0;
  42022. - for ( i = 0; i < 6 ; i++ )
  42023. - err |= TLan_EeReadByte( dev,
  42024. - (u8) priv->adapter->addrOfs + i,
  42025. - (u8 *) &dev->dev_addr[i] );
  42026. - if ( err ) {
  42027. - printk(KERN_ERR "TLAN: %s: Error reading MAC from eeprom: %d\n",
  42028. - dev->name,
  42029. - err );
  42030. - }
  42031. - dev->addr_len = 6;
  42032. -
  42033. - /* Device methods */
  42034. - dev->open = &TLan_Open;
  42035. - dev->hard_start_xmit = &TLan_StartTx;
  42036. - dev->stop = &TLan_Close;
  42037. - dev->get_stats = &TLan_GetStats;
  42038. - dev->set_multicast_list = &TLan_SetMulticastList;
  42039. - dev->do_ioctl = &TLan_ioctl;
  42040. - dev->tx_timeout = &TLan_tx_timeout;
  42041. - dev->watchdog_timeo = TX_TIMEOUT;
  42042. -
  42043. - return 0;
  42044. -
  42045. -} /* TLan_Init */
  42046. -
  42047. - /***************************************************************
  42048. - * TLan_Open
  42049. - *
  42050. - * Returns:
  42051. - * 0 on success, error code otherwise.
  42052. - * Parms:
  42053. - * dev Structure of device to be opened.
  42054. - *
  42055. - * This routine puts the driver and TLAN adapter in a
  42056. - * state where it is ready to send and receive packets.
  42057. - * It allocates the IRQ, resets and brings the adapter
  42058. - * out of reset, and allows interrupts. It also delays
  42059. - * the startup for autonegotiation or sends a Rx GO
  42060. - * command to the adapter, as appropriate.
  42061. - *
  42062. - **************************************************************/
  42063. -
  42064. -static int TLan_Open( struct net_device *dev )
  42065. -{
  42066. - TLanPrivateInfo *priv = dev->priv;
  42067. - int err;
  42068. -
  42069. - priv->tlanRev = TLan_DioRead8( dev->base_addr, TLAN_DEF_REVISION );
  42070. - err = request_irq( dev->irq, TLan_HandleInterrupt, SA_SHIRQ, TLanSignature, dev );
  42071. -
  42072. - if ( err ) {
  42073. - printk(KERN_ERR "TLAN: Cannot open %s because IRQ %d is already in use.\n", dev->name, dev->irq );
  42074. - return err;
  42075. + host_cmd = TLAN_HC_ACK | ack | (0x000C0000);
  42076. + outl(host_cmd, BASE + TLAN_HOST_CMD);
  42077. +#ifdef EBDEBUG
  42078. + printf("AC: 0x%hX\n", inw(BASE + TLAN_CH_PARM));
  42079. + host_int = inw(BASE + TLAN_HOST_INT);
  42080. + printf("PI-2: 0x%hX\n", host_int);
  42081. +#endif
  42082. }
  42083. -
  42084. - init_timer(&priv->timer);
  42085. - netif_start_queue(dev);
  42086. -
  42087. - /* NOTE: It might not be necessary to read the stats before a
  42088. - reset if you don't care what the values are.
  42089. - */
  42090. - TLan_ResetLists( dev );
  42091. - TLan_ReadAndClearStats( dev, TLAN_IGNORE );
  42092. - TLan_ResetAdapter( dev );
  42093. -
  42094. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Opened. TLAN Chip Rev: %x\n", dev->name, priv->tlanRev );
  42095. -
  42096. - return 0;
  42097. -
  42098. -} /* TLan_Open */
  42099. -
  42100. - /**************************************************************
  42101. - * TLan_ioctl
  42102. - *
  42103. - * Returns:
  42104. - * 0 on success, error code otherwise
  42105. - * Params:
  42106. - * dev structure of device to receive ioctl.
  42107. - *
  42108. - * rq ifreq structure to hold userspace data.
  42109. - *
  42110. - * cmd ioctl command.
  42111. - *
  42112. - *
  42113. - *************************************************************/
  42114. + refill_rx(nic);
  42115. + return (1); /* initially as this is called to flush the input */
  42116. +}
  42117. -static int TLan_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  42118. +static void refill_rx(struct nic *nic __unused)
  42119. {
  42120. - TLanPrivateInfo *priv = dev->priv;
  42121. - struct mii_ioctl_data *data = (struct mii_ioctl_data *)&rq->ifr_data;
  42122. - u32 phy = priv->phy[priv->phyNum];
  42123. -
  42124. - if (!priv->phyOnline)
  42125. - return -EAGAIN;
  42126. -
  42127. - switch(cmd) {
  42128. - case SIOCGMIIPHY: /* Get address of MII PHY in use. */
  42129. - case SIOCDEVPRIVATE: /* for binary compat, remove in 2.5 */
  42130. - data->phy_id = phy;
  42131. -
  42132. - case SIOCGMIIREG: /* Read MII PHY register. */
  42133. - case SIOCDEVPRIVATE+1: /* for binary compat, remove in 2.5 */
  42134. - TLan_MiiReadReg(dev, data->phy_id & 0x1f, data->reg_num & 0x1f, &data->val_out);
  42135. - return 0;
  42136. -
  42137. + int entry = 0;
  42138. - case SIOCSMIIREG: /* Write MII PHY register. */
  42139. - case SIOCDEVPRIVATE+2: /* for binary compat, remove in 2.5 */
  42140. - if (!capable(CAP_NET_ADMIN))
  42141. - return -EPERM;
  42142. - TLan_MiiWriteReg(dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
  42143. - return 0;
  42144. - default:
  42145. - return -EOPNOTSUPP;
  42146. + for (;
  42147. + (priv->cur_rx - priv->dirty_rx +
  42148. + TLAN_NUM_RX_LISTS) % TLAN_NUM_RX_LISTS > 0;
  42149. + priv->dirty_rx = (priv->dirty_rx + 1) % TLAN_NUM_RX_LISTS) {
  42150. + entry = priv->dirty_rx % TLAN_NUM_TX_LISTS;
  42151. + rx_ring[entry].frameSize = TLAN_MAX_FRAME_SIZE;
  42152. + rx_ring[entry].cStat = TLAN_CSTAT_READY;
  42153. }
  42154. -} /* tlan_ioctl */
  42155. -
  42156. - /***************************************************************
  42157. - * TLan_tx_timeout
  42158. - *
  42159. - * Returns: nothing
  42160. - *
  42161. - * Params:
  42162. - * dev structure of device which timed out
  42163. - * during transmit.
  42164. - *
  42165. - **************************************************************/
  42166. -
  42167. -static void TLan_tx_timeout(struct net_device *dev)
  42168. -{
  42169. -
  42170. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Transmit timed out.\n", dev->name);
  42171. -
  42172. - /* Ok so we timed out, lets see what we can do about it...*/
  42173. - TLan_FreeLists( dev );
  42174. - TLan_ResetLists( dev );
  42175. - TLan_ReadAndClearStats( dev, TLAN_IGNORE );
  42176. - TLan_ResetAdapter( dev );
  42177. - dev->trans_start = jiffies;
  42178. - netif_wake_queue( dev );
  42179. }
  42180. -
  42181. - /***************************************************************
  42182. - * TLan_StartTx
  42183. - *
  42184. - * Returns:
  42185. - * 0 on success, non-zero on failure.
  42186. - * Parms:
  42187. - * skb A pointer to the sk_buff containing the
  42188. - * frame to be sent.
  42189. - * dev The device to send the data on.
  42190. - *
  42191. - * This function adds a frame to the Tx list to be sent
  42192. - * ASAP. First it verifies that the adapter is ready and
  42193. - * there is room in the queue. Then it sets up the next
  42194. - * available list, copies the frame to the corresponding
  42195. - * buffer. If the adapter Tx channel is idle, it gives
  42196. - * the adapter a Tx Go command on the list, otherwise it
  42197. - * sets the forward address of the previous list to point
  42198. - * to this one. Then it frees the sk_buff.
  42199. - *
  42200. - **************************************************************/
  42201. +/* #define EBDEBUG */
  42202. +/**************************************************************************
  42203. +TRANSMIT - Transmit a frame
  42204. +***************************************************************************/
  42205. +static void tlan_transmit(struct nic *nic, const char *d, /* Destination */
  42206. + unsigned int t, /* Type */
  42207. + unsigned int s, /* size */
  42208. + const char *p)
  42209. +{ /* Packet */
  42210. + u16 nstype;
  42211. + u32 to;
  42212. + struct TLanList *tail_list;
  42213. + struct TLanList *head_list;
  42214. + u8 *tail_buffer;
  42215. + u32 ack = 0;
  42216. + u32 host_cmd;
  42217. + int eoc = 0;
  42218. + u16 tmpCStat;
  42219. +#ifdef EBDEBUG
  42220. + u16 host_int = inw(BASE + TLAN_HOST_INT);
  42221. +#endif
  42222. + int entry = 0;
  42223. -static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev )
  42224. -{
  42225. - TLanPrivateInfo *priv = dev->priv;
  42226. - TLanList *tail_list;
  42227. - u8 *tail_buffer;
  42228. - int pad;
  42229. - unsigned long flags;
  42230. -
  42231. - if ( ! priv->phyOnline ) {
  42232. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s PHY is not ready\n", dev->name );
  42233. - dev_kfree_skb_any(skb);
  42234. - return 0;
  42235. +#ifdef EBDEBUG
  42236. + printf("INT0-0x%hX\n", host_int);
  42237. +#endif
  42238. +
  42239. + if (!priv->phyOnline) {
  42240. + printf("TRANSMIT: %s PHY is not ready\n", priv->nic_name);
  42241. + return;
  42242. }
  42243. tail_list = priv->txList + priv->txTail;
  42244. -
  42245. - if ( tail_list->cStat != TLAN_CSTAT_UNUSED ) {
  42246. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s is busy (Head=%d Tail=%d)\n", dev->name, priv->txHead, priv->txTail );
  42247. - netif_stop_queue(dev);
  42248. +
  42249. + if (tail_list->cStat != TLAN_CSTAT_UNUSED) {
  42250. + printf("TRANSMIT: %s is busy (Head=%d Tail=%d)\n",
  42251. + priv->nic_name, priv->txList, priv->txTail);
  42252. + tx_ring[entry].cStat = TLAN_CSTAT_UNUSED;
  42253. priv->txBusyCount++;
  42254. - return 1;
  42255. + return;
  42256. }
  42257. tail_list->forward = 0;
  42258. - if ( bbuf ) {
  42259. - tail_buffer = priv->txBuffer + ( priv->txTail * TLAN_MAX_FRAME_SIZE );
  42260. - memcpy( tail_buffer, skb->data, skb->len );
  42261. - } else {
  42262. - tail_list->buffer[0].address = virt_to_bus( skb->data );
  42263. - tail_list->buffer[9].address = (u32) skb;
  42264. - }
  42265. + tail_buffer = txb + (priv->txTail * TLAN_MAX_FRAME_SIZE);
  42266. - pad = TLAN_MIN_FRAME_SIZE - skb->len;
  42267. -
  42268. - if ( pad > 0 ) {
  42269. - tail_list->frameSize = (u16) skb->len + pad;
  42270. - tail_list->buffer[0].count = (u32) skb->len;
  42271. - tail_list->buffer[1].count = TLAN_LAST_BUFFER | (u32) pad;
  42272. - tail_list->buffer[1].address = virt_to_bus( TLanPadBuffer );
  42273. - } else {
  42274. - tail_list->frameSize = (u16) skb->len;
  42275. - tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) skb->len;
  42276. - tail_list->buffer[1].count = 0;
  42277. - tail_list->buffer[1].address = 0;
  42278. - }
  42279. + /* send the packet to destination */
  42280. + memcpy(tail_buffer, d, ETH_ALEN);
  42281. + memcpy(tail_buffer + ETH_ALEN, nic->node_addr, ETH_ALEN);
  42282. + nstype = htons((u16) t);
  42283. + memcpy(tail_buffer + 2 * ETH_ALEN, (u8 *) & nstype, 2);
  42284. + memcpy(tail_buffer + ETH_HLEN, p, s);
  42285. +
  42286. + s += ETH_HLEN;
  42287. + s &= 0x0FFF;
  42288. + while (s < ETH_ZLEN)
  42289. + tail_buffer[s++] = '\0';
  42290. +
  42291. + /*=====================================================*/
  42292. + /* Receive
  42293. + * 0000 0000 0001 1100
  42294. + * 0000 0000 0000 1100
  42295. + * 0000 0000 0000 0011 = 0x0003
  42296. + *
  42297. + * 0000 0000 0000 0000 0000 0000 0000 0011
  42298. + * 0000 0000 0000 1100 0000 0000 0000 0000 = 0x000C0000
  42299. + *
  42300. + * Transmit
  42301. + * 0000 0000 0001 1100
  42302. + * 0000 0000 0000 0100
  42303. + * 0000 0000 0000 0001 = 0x0001
  42304. + *
  42305. + * 0000 0000 0000 0000 0000 0000 0000 0001
  42306. + * 0000 0000 0000 0100 0000 0000 0000 0000 = 0x00040000
  42307. + * */
  42308. +
  42309. + /* Setup the transmit descriptor */
  42310. + tail_list->frameSize = (u16) s;
  42311. + tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) s;
  42312. + tail_list->buffer[1].count = 0;
  42313. + tail_list->buffer[1].address = 0;
  42314. - spin_lock_irqsave(&priv->lock, flags);
  42315. tail_list->cStat = TLAN_CSTAT_READY;
  42316. - if ( ! priv->txInProgress ) {
  42317. +
  42318. +#ifdef EBDEBUG
  42319. + host_int = inw(BASE + TLAN_HOST_INT);
  42320. + printf("INT1-0x%hX\n", host_int);
  42321. +#endif
  42322. +
  42323. + if (!priv->txInProgress) {
  42324. priv->txInProgress = 1;
  42325. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Starting TX on buffer %d\n", priv->txTail );
  42326. - outl( virt_to_bus( tail_list ), dev->base_addr + TLAN_CH_PARM );
  42327. - outl( TLAN_HC_GO, dev->base_addr + TLAN_HOST_CMD );
  42328. + outl(virt_to_le32desc(tail_list), BASE + TLAN_CH_PARM);
  42329. + outl(TLAN_HC_GO, BASE + TLAN_HOST_CMD);
  42330. } else {
  42331. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Adding buffer %d to TX channel\n", priv->txTail );
  42332. - if ( priv->txTail == 0 ) {
  42333. - ( priv->txList + ( TLAN_NUM_TX_LISTS - 1 ) )->forward = virt_to_bus( tail_list );
  42334. + if (priv->txTail == 0) {
  42335. +#ifdef EBDEBUG
  42336. + printf("Out buffer\n");
  42337. +#endif
  42338. + (priv->txList + (TLAN_NUM_TX_LISTS - 1))->forward =
  42339. + virt_to_le32desc(tail_list);
  42340. } else {
  42341. - ( priv->txList + ( priv->txTail - 1 ) )->forward = virt_to_bus( tail_list );
  42342. +#ifdef EBDEBUG
  42343. + printf("Fix this \n");
  42344. +#endif
  42345. + (priv->txList + (priv->txTail - 1))->forward =
  42346. + virt_to_le32desc(tail_list);
  42347. }
  42348. }
  42349. - spin_unlock_irqrestore(&priv->lock, flags);
  42350. -
  42351. - CIRC_INC( priv->txTail, TLAN_NUM_TX_LISTS );
  42352. -
  42353. - if ( bbuf )
  42354. - dev_kfree_skb_any(skb);
  42355. -
  42356. - dev->trans_start = jiffies;
  42357. - return 0;
  42358. -
  42359. -} /* TLan_StartTx */
  42360. -
  42361. - /***************************************************************
  42362. - * TLan_HandleInterrupt
  42363. - *
  42364. - * Returns:
  42365. - * Nothing
  42366. - * Parms:
  42367. - * irq The line on which the interrupt
  42368. - * occurred.
  42369. - * dev_id A pointer to the device assigned to
  42370. - * this irq line.
  42371. - * regs ???
  42372. - *
  42373. - * This function handles an interrupt generated by its
  42374. - * assigned TLAN adapter. The function deactivates
  42375. - * interrupts on its adapter, records the type of
  42376. - * interrupt, executes the appropriate subhandler, and
  42377. - * acknowdges the interrupt to the adapter (thus
  42378. - * re-enabling adapter interrupts.
  42379. - *
  42380. - **************************************************************/
  42381. -
  42382. -static void TLan_HandleInterrupt(int irq, void *dev_id, struct pt_regs *regs)
  42383. -{
  42384. - u32 ack;
  42385. - struct net_device *dev;
  42386. - u32 host_cmd;
  42387. - u16 host_int;
  42388. - int type;
  42389. - TLanPrivateInfo *priv;
  42390. -
  42391. - dev = dev_id;
  42392. - priv = dev->priv;
  42393. -
  42394. - spin_lock(&priv->lock);
  42395. -
  42396. - host_int = inw( dev->base_addr + TLAN_HOST_INT );
  42397. - outw( host_int, dev->base_addr + TLAN_HOST_INT );
  42398. +
  42399. + CIRC_INC(priv->txTail, TLAN_NUM_TX_LISTS);
  42400. - type = ( host_int & TLAN_HI_IT_MASK ) >> 2;
  42401. +#ifdef EBDEBUG
  42402. + host_int = inw(BASE + TLAN_HOST_INT);
  42403. + printf("INT2-0x%hX\n", host_int);
  42404. +#endif
  42405. - ack = TLanIntVector[type]( dev, host_int );
  42406. + to = currticks() + TX_TIME_OUT;
  42407. + while ((tail_list->cStat == TLAN_CSTAT_READY) && currticks() < to);
  42408. - if ( ack ) {
  42409. - host_cmd = TLAN_HC_ACK | ack | ( type << 18 );
  42410. - outl( host_cmd, dev->base_addr + TLAN_HOST_CMD );
  42411. + head_list = priv->txList + priv->txHead;
  42412. + while (((tmpCStat = head_list->cStat) & TLAN_CSTAT_FRM_CMP)
  42413. + && (ack < 255)) {
  42414. + ack++;
  42415. + if(tmpCStat & TLAN_CSTAT_EOC)
  42416. + eoc =1;
  42417. + head_list->cStat = TLAN_CSTAT_UNUSED;
  42418. + CIRC_INC(priv->txHead, TLAN_NUM_TX_LISTS);
  42419. + head_list = priv->txList + priv->txHead;
  42420. +
  42421. }
  42422. + if(!ack)
  42423. + printf("Incomplete TX Frame\n");
  42424. - spin_unlock(&priv->lock);
  42425. -
  42426. -} /* TLan_HandleInterrupts */
  42427. -
  42428. - /***************************************************************
  42429. - * TLan_Close
  42430. - *
  42431. - * Returns:
  42432. - * An error code.
  42433. - * Parms:
  42434. - * dev The device structure of the device to
  42435. - * close.
  42436. - *
  42437. - * This function shuts down the adapter. It records any
  42438. - * stats, puts the adapter into reset state, deactivates
  42439. - * its time as needed, and frees the irq it is using.
  42440. - *
  42441. - **************************************************************/
  42442. -
  42443. -static int TLan_Close(struct net_device *dev)
  42444. -{
  42445. - TLanPrivateInfo *priv = dev->priv;
  42446. -
  42447. - netif_stop_queue(dev);
  42448. - priv->neg_be_verbose = 0;
  42449. -
  42450. - TLan_ReadAndClearStats( dev, TLAN_RECORD );
  42451. - outl( TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD );
  42452. - if ( priv->timer.function != NULL ) {
  42453. - del_timer_sync( &priv->timer );
  42454. - priv->timer.function = NULL;
  42455. + if(eoc) {
  42456. + head_list = priv->txList + priv->txHead;
  42457. + if ((head_list->cStat & TLAN_CSTAT_READY) == TLAN_CSTAT_READY) {
  42458. + outl(virt_to_le32desc(head_list), BASE + TLAN_CH_PARM);
  42459. + ack |= TLAN_HC_GO;
  42460. + } else {
  42461. + priv->txInProgress = 0;
  42462. + }
  42463. }
  42464. -
  42465. - free_irq( dev->irq, dev );
  42466. - TLan_FreeLists( dev );
  42467. - TLAN_DBG( TLAN_DEBUG_GNRL, "Device %s closed.\n", dev->name );
  42468. -
  42469. - return 0;
  42470. -
  42471. -} /* TLan_Close */
  42472. -
  42473. - /***************************************************************
  42474. - * TLan_GetStats
  42475. - *
  42476. - * Returns:
  42477. - * A pointer to the device's statistics structure.
  42478. - * Parms:
  42479. - * dev The device structure to return the
  42480. - * stats for.
  42481. - *
  42482. - * This function updates the devices statistics by reading
  42483. - * the TLAN chip's onboard registers. Then it returns the
  42484. - * address of the statistics structure.
  42485. - *
  42486. - **************************************************************/
  42487. -
  42488. -static struct net_device_stats *TLan_GetStats( struct net_device *dev )
  42489. -{
  42490. - TLanPrivateInfo *priv = dev->priv;
  42491. - int i;
  42492. -
  42493. - /* Should only read stats if open ? */
  42494. - TLan_ReadAndClearStats( dev, TLAN_RECORD );
  42495. -
  42496. - TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE: %s EOC count = %d\n", dev->name, priv->rxEocCount );
  42497. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s Busy count = %d\n", dev->name, priv->txBusyCount );
  42498. - if ( debug & TLAN_DEBUG_GNRL ) {
  42499. - TLan_PrintDio( dev->base_addr );
  42500. - TLan_PhyPrint( dev );
  42501. - }
  42502. - if ( debug & TLAN_DEBUG_LIST ) {
  42503. - for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ )
  42504. - TLan_PrintList( priv->rxList + i, "RX", i );
  42505. - for ( i = 0; i < TLAN_NUM_TX_LISTS; i++ )
  42506. - TLan_PrintList( priv->txList + i, "TX", i );
  42507. + if(ack) {
  42508. + host_cmd = TLAN_HC_ACK | ack;
  42509. + outl(host_cmd, BASE + TLAN_HOST_CMD);
  42510. }
  42511. - return ( &( (TLanPrivateInfo *) dev->priv )->stats );
  42512. -
  42513. -} /* TLan_GetStats */
  42514. -
  42515. - /***************************************************************
  42516. - * TLan_SetMulticastList
  42517. - *
  42518. - * Returns:
  42519. - * Nothing
  42520. - * Parms:
  42521. - * dev The device structure to set the
  42522. - * multicast list for.
  42523. - *
  42524. - * This function sets the TLAN adaptor to various receive
  42525. - * modes. If the IFF_PROMISC flag is set, promiscuous
  42526. - * mode is acitviated. Otherwise, promiscuous mode is
  42527. - * turned off. If the IFF_ALLMULTI flag is set, then
  42528. - * the hash table is set to receive all group addresses.
  42529. - * Otherwise, the first three multicast addresses are
  42530. - * stored in AREG_1-3, and the rest are selected via the
  42531. - * hash table, as necessary.
  42532. - *
  42533. - **************************************************************/
  42534. -
  42535. -static void TLan_SetMulticastList( struct net_device *dev )
  42536. -{
  42537. - struct dev_mc_list *dmi = dev->mc_list;
  42538. - u32 hash1 = 0;
  42539. - u32 hash2 = 0;
  42540. - int i;
  42541. - u32 offset;
  42542. - u8 tmp;
  42543. -
  42544. - if ( dev->flags & IFF_PROMISC ) {
  42545. - tmp = TLan_DioRead8( dev->base_addr, TLAN_NET_CMD );
  42546. - TLan_DioWrite8( dev->base_addr, TLAN_NET_CMD, tmp | TLAN_NET_CMD_CAF );
  42547. - } else {
  42548. - tmp = TLan_DioRead8( dev->base_addr, TLAN_NET_CMD );
  42549. - TLan_DioWrite8( dev->base_addr, TLAN_NET_CMD, tmp & ~TLAN_NET_CMD_CAF );
  42550. - if ( dev->flags & IFF_ALLMULTI ) {
  42551. - for ( i = 0; i < 3; i++ )
  42552. - TLan_SetMac( dev, i + 1, NULL );
  42553. - TLan_DioWrite32( dev->base_addr, TLAN_HASH_1, 0xFFFFFFFF );
  42554. - TLan_DioWrite32( dev->base_addr, TLAN_HASH_2, 0xFFFFFFFF );
  42555. + if(priv->tlanRev < 0x30 ) {
  42556. + ack = 1;
  42557. + head_list = priv->txList + priv->txHead;
  42558. + if ((head_list->cStat & TLAN_CSTAT_READY) == TLAN_CSTAT_READY) {
  42559. + outl(virt_to_le32desc(head_list), BASE + TLAN_CH_PARM);
  42560. + ack |= TLAN_HC_GO;
  42561. } else {
  42562. - for ( i = 0; i < dev->mc_count; i++ ) {
  42563. - if ( i < 3 ) {
  42564. - TLan_SetMac( dev, i + 1, (char *) &dmi->dmi_addr );
  42565. - } else {
  42566. - offset = TLan_HashFunc( (u8 *) &dmi->dmi_addr );
  42567. - if ( offset < 32 )
  42568. - hash1 |= ( 1 << offset );
  42569. - else
  42570. - hash2 |= ( 1 << ( offset - 32 ) );
  42571. - }
  42572. - dmi = dmi->next;
  42573. - }
  42574. - for ( ; i < 3; i++ )
  42575. - TLan_SetMac( dev, i + 1, NULL );
  42576. - TLan_DioWrite32( dev->base_addr, TLAN_HASH_1, hash1 );
  42577. - TLan_DioWrite32( dev->base_addr, TLAN_HASH_2, hash2 );
  42578. + priv->txInProgress = 0;
  42579. }
  42580. + host_cmd = TLAN_HC_ACK | ack | 0x00140000;
  42581. + outl(host_cmd, BASE + TLAN_HOST_CMD);
  42582. +
  42583. }
  42584. +
  42585. + if (currticks() >= to) {
  42586. + printf("TX Time Out");
  42587. + }
  42588. +}
  42589. -} /* TLan_SetMulticastList */
  42590. -
  42591. -/*****************************************************************************
  42592. -******************************************************************************
  42593. -
  42594. - ThunderLAN Driver Interrupt Vectors and Table
  42595. -
  42596. - Please see Chap. 4, "Interrupt Handling" of the "ThunderLAN
  42597. - Programmer's Guide" for more informations on handling interrupts
  42598. - generated by TLAN based adapters.
  42599. -
  42600. -******************************************************************************
  42601. -*****************************************************************************/
  42602. -
  42603. - /***************************************************************
  42604. - * TLan_HandleInvalid
  42605. - *
  42606. - * Returns:
  42607. - * 0
  42608. - * Parms:
  42609. - * dev Device assigned the IRQ that was
  42610. - * raised.
  42611. - * host_int The contents of the HOST_INT
  42612. - * port.
  42613. - *
  42614. - * This function handles invalid interrupts. This should
  42615. - * never happen unless some other adapter is trying to use
  42616. - * the IRQ line assigned to the device.
  42617. - *
  42618. - **************************************************************/
  42619. -
  42620. -u32 TLan_HandleInvalid( struct net_device *dev, u16 host_int )
  42621. +/**************************************************************************
  42622. +DISABLE - Turn off ethernet interface
  42623. +***************************************************************************/
  42624. +#ifdef EB51
  42625. +static void tlan_disable(struct dev *dev __unused)
  42626. +#else
  42627. +static void tlan_disable(struct nic *nic __unused)
  42628. +#endif
  42629. {
  42630. - /* printk( "TLAN: Invalid interrupt on %s.\n", dev->name ); */
  42631. - return 0;
  42632. -
  42633. -} /* TLan_HandleInvalid */
  42634. -
  42635. - /***************************************************************
  42636. - * TLan_HandleTxEOF
  42637. - *
  42638. - * Returns:
  42639. - * 1
  42640. - * Parms:
  42641. - * dev Device assigned the IRQ that was
  42642. - * raised.
  42643. - * host_int The contents of the HOST_INT
  42644. - * port.
  42645. - *
  42646. - * This function handles Tx EOF interrupts which are raised
  42647. - * by the adapter when it has completed sending the
  42648. - * contents of a buffer. If detemines which list/buffer
  42649. - * was completed and resets it. If the buffer was the last
  42650. - * in the channel (EOC), then the function checks to see if
  42651. - * another buffer is ready to send, and if so, sends a Tx
  42652. - * Go command. Finally, the driver activates/continues the
  42653. - * activity LED.
  42654. + /* put the card in its initial state */
  42655. + /* This function serves 3 purposes.
  42656. + * This disables DMA and interrupts so we don't receive
  42657. + * unexpected packets or interrupts from the card after
  42658. + * etherboot has finished.
  42659. + * This frees resources so etherboot may use
  42660. + * this driver on another interface
  42661. + * This allows etherboot to reinitialize the interface
  42662. + * if something is something goes wrong.
  42663. *
  42664. - **************************************************************/
  42665. + */
  42666. + outl(TLAN_HC_AD_RST, BASE + TLAN_HOST_CMD);
  42667. +}
  42668. -u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int )
  42669. +/**************************************************************************
  42670. +IRQ - Enable, Disable, or Force interrupts
  42671. +***************************************************************************/
  42672. +static void tlan_irq(struct nic *nic __unused, irq_action_t action __unused)
  42673. {
  42674. - TLanPrivateInfo *priv = dev->priv;
  42675. - int eoc = 0;
  42676. - TLanList *head_list;
  42677. - u32 ack = 0;
  42678. - u16 tmpCStat;
  42679. -
  42680. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Handling TX EOF (Head=%d Tail=%d)\n", priv->txHead, priv->txTail );
  42681. - head_list = priv->txList + priv->txHead;
  42682. + switch ( action ) {
  42683. + case DISABLE :
  42684. + break;
  42685. + case ENABLE :
  42686. + break;
  42687. + case FORCE :
  42688. + break;
  42689. + }
  42690. +}
  42691. - while (((tmpCStat = head_list->cStat ) & TLAN_CSTAT_FRM_CMP) && (ack < 255)) {
  42692. - ack++;
  42693. - if ( ! bbuf ) {
  42694. - dev_kfree_skb_any( (struct sk_buff *) head_list->buffer[9].address );
  42695. - head_list->buffer[9].address = 0;
  42696. - }
  42697. -
  42698. - if ( tmpCStat & TLAN_CSTAT_EOC )
  42699. - eoc = 1;
  42700. -
  42701. - priv->stats.tx_bytes += head_list->frameSize;
  42702. +static void TLan_SetMulticastList(struct nic *nic) {
  42703. + int i;
  42704. + u8 tmp;
  42705. - head_list->cStat = TLAN_CSTAT_UNUSED;
  42706. - netif_start_queue(dev);
  42707. - CIRC_INC( priv->txHead, TLAN_NUM_TX_LISTS );
  42708. - head_list = priv->txList + priv->txHead;
  42709. - }
  42710. + /* !IFF_PROMISC */
  42711. + tmp = TLan_DioRead8(BASE, TLAN_NET_CMD);
  42712. + TLan_DioWrite8(BASE, TLAN_NET_CMD, tmp & ~TLAN_NET_CMD_CAF);
  42713. +
  42714. + /* IFF_ALLMULTI */
  42715. + for(i = 0; i< 3; i++)
  42716. + TLan_SetMac(nic, i + 1, NULL);
  42717. + TLan_DioWrite32(BASE, TLAN_HASH_1, 0xFFFFFFFF);
  42718. + TLan_DioWrite32(BASE, TLAN_HASH_2, 0xFFFFFFFF);
  42719. - if (!ack)
  42720. - printk(KERN_INFO "TLAN: Received interrupt for uncompleted TX frame.\n");
  42721. -
  42722. - if ( eoc ) {
  42723. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Handling TX EOC (Head=%d Tail=%d)\n", priv->txHead, priv->txTail );
  42724. - head_list = priv->txList + priv->txHead;
  42725. - if ( ( head_list->cStat & TLAN_CSTAT_READY ) == TLAN_CSTAT_READY ) {
  42726. - outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
  42727. - ack |= TLAN_HC_GO;
  42728. - } else {
  42729. - priv->txInProgress = 0;
  42730. - }
  42731. - }
  42732. - if ( priv->adapter->flags & TLAN_ADAPTER_ACTIVITY_LED ) {
  42733. - TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK | TLAN_LED_ACT );
  42734. - if ( priv->timer.function == NULL ) {
  42735. - priv->timer.function = &TLan_Timer;
  42736. - priv->timer.data = (unsigned long) dev;
  42737. - priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY;
  42738. - priv->timerSetAt = jiffies;
  42739. - priv->timerType = TLAN_TIMER_ACTIVITY;
  42740. - add_timer(&priv->timer);
  42741. - } else if ( priv->timerType == TLAN_TIMER_ACTIVITY ) {
  42742. - priv->timerSetAt = jiffies;
  42743. +}
  42744. +/**************************************************************************
  42745. +PROBE - Look for an adapter, this routine's visible to the outside
  42746. +***************************************************************************/
  42747. +
  42748. +#define board_found 1
  42749. +#define valid_link 0
  42750. +#ifdef EB51
  42751. +static int tlan_probe(struct dev *dev, struct pci_device *pci)
  42752. +{
  42753. + struct nic *nic = (struct nic *) dev;
  42754. +#else
  42755. +struct nic *tlan_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci)
  42756. +{
  42757. +#endif
  42758. + u16 data = 0;
  42759. + int err;
  42760. + int i;
  42761. +
  42762. + if (pci->ioaddr == 0)
  42763. + return 0;
  42764. +
  42765. + nic->irqno = 0;
  42766. + nic->ioaddr = pci->ioaddr & ~3;
  42767. +
  42768. + BASE = pci->ioaddr;
  42769. + printf("\n");
  42770. + printf("tlan.c: %s, %s\n", drv_version, drv_date);
  42771. + printf("%s: Probing for Vendor 0x%hX, Device 0x%hX",
  42772. + pci->name, pci->vendor, pci->dev_id);
  42773. +
  42774. +
  42775. + /* I really must find out what this does */
  42776. + adjust_pci_device(pci);
  42777. +
  42778. + /* Point to private storage */
  42779. + priv = &TLanPrivateInfo;
  42780. + /* Figure out which chip we're dealing with */
  42781. + i = 0;
  42782. + chip_idx = -1;
  42783. +
  42784. + while (tlan_pci_tbl[i].name) {
  42785. + if ((((u32) pci->dev_id << 16) | pci->vendor) ==
  42786. + (tlan_pci_tbl[i].id.pci & 0xffffffff)) {
  42787. + chip_idx = i;
  42788. + break;
  42789. }
  42790. + i++;
  42791. }
  42792. - return ack;
  42793. + priv->vendor_id = pci->vendor;
  42794. + priv->dev_id = pci->dev_id;
  42795. + priv->nic_name = pci->name;
  42796. + priv->eoc = 0;
  42797. -} /* TLan_HandleTxEOF */
  42798. + err = 0;
  42799. + for (i = 0; i < 6; i++)
  42800. + err |= TLan_EeReadByte(BASE,
  42801. + (u8) tlan_pci_tbl[chip_idx].
  42802. + addrOfs + i,
  42803. + (u8 *) & nic->node_addr[i]);
  42804. + if (err) {
  42805. + printf("TLAN: %s: Error reading MAC from eeprom: %d\n",
  42806. + pci->name, err);
  42807. + } else
  42808. + printf("\nAddress: %!\n", nic->node_addr);
  42809. - /***************************************************************
  42810. - * TLan_HandleStatOverflow
  42811. - *
  42812. - * Returns:
  42813. - * 1
  42814. - * Parms:
  42815. - * dev Device assigned the IRQ that was
  42816. - * raised.
  42817. - * host_int The contents of the HOST_INT
  42818. - * port.
  42819. - *
  42820. - * This function handles the Statistics Overflow interrupt
  42821. - * which means that one or more of the TLAN statistics
  42822. - * registers has reached 1/2 capacity and needs to be read.
  42823. - *
  42824. - **************************************************************/
  42825. + priv->tlanRev = TLan_DioRead8(BASE, TLAN_DEF_REVISION);
  42826. + printf("\nRevision = 0x%hX\n", priv->tlanRev);
  42827. -u32 TLan_HandleStatOverflow( struct net_device *dev, u16 host_int )
  42828. -{
  42829. - TLan_ReadAndClearStats( dev, TLAN_RECORD );
  42830. + TLan_ResetLists(nic);
  42831. + TLan_ResetAdapter(nic);
  42832. +/*
  42833. + data = inl(BASE + TLAN_HOST_CMD);
  42834. + data |= TLAN_HC_EOC;
  42835. + outw(data, BASE + TLAN_HOST_CMD);
  42836. +*/
  42837. +
  42838. + data = inl(BASE + TLAN_HOST_CMD);
  42839. + data |= TLAN_HC_INT_OFF;
  42840. + outw(data, BASE + TLAN_HOST_CMD);
  42841. + TLan_SetMulticastList(nic);
  42842. + udelay(100);
  42843. + priv->txList = tx_ring;
  42844. + priv->rxList = rx_ring;
  42845. +/* if (board_found && valid_link)
  42846. + {*/
  42847. + /* point to NIC specific routines */
  42848. +#ifdef EB51
  42849. + dev->disable = tlan_disable;
  42850. + nic->poll = tlan_poll;
  42851. + nic->transmit = tlan_transmit;
  42852. + nic->irq = tlan_irq;
  42853. return 1;
  42854. +#else
  42855. + nic->disable = tlan_disable;
  42856. + nic->poll = tlan_poll;
  42857. + nic->transmit = tlan_transmit;
  42858. + nic->irq = tlan_irq;
  42859. + return nic;
  42860. +#endif
  42861. +}
  42862. +
  42863. +
  42864. +/*****************************************************************************
  42865. +******************************************************************************
  42866. +
  42867. + ThunderLAN Driver Eeprom routines
  42868. +
  42869. + The Compaq Netelligent 10 and 10/100 cards use a Microchip 24C02A
  42870. + EEPROM. These functions are based on information in Microchip's
  42871. + data sheet. I don't know how well this functions will work with
  42872. + other EEPROMs.
  42873. +
  42874. +******************************************************************************
  42875. +*****************************************************************************/
  42876. -} /* TLan_HandleStatOverflow */
  42877. /***************************************************************
  42878. - * TLan_HandleRxEOF
  42879. + * TLan_EeSendStart
  42880. *
  42881. * Returns:
  42882. - * 1
  42883. + * Nothing
  42884. * Parms:
  42885. - * dev Device assigned the IRQ that was
  42886. - * raised.
  42887. - * host_int The contents of the HOST_INT
  42888. - * port.
  42889. - *
  42890. - * This function handles the Rx EOF interrupt which
  42891. - * indicates a frame has been received by the adapter from
  42892. - * the net and the frame has been transferred to memory.
  42893. - * The function determines the bounce buffer the frame has
  42894. - * been loaded into, creates a new sk_buff big enough to
  42895. - * hold the frame, and sends it to protocol stack. It
  42896. - * then resets the used buffer and appends it to the end
  42897. - * of the list. If the frame was the last in the Rx
  42898. - * channel (EOC), the function restarts the receive channel
  42899. - * by sending an Rx Go command to the adapter. Then it
  42900. - * activates/continues the activity LED.
  42901. + * io_base The IO port base address for the
  42902. + * TLAN device with the EEPROM to
  42903. + * use.
  42904. + *
  42905. + * This function sends a start cycle to an EEPROM attached
  42906. + * to a TLAN chip.
  42907. *
  42908. **************************************************************/
  42909. -u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int )
  42910. +void TLan_EeSendStart(u16 io_base)
  42911. {
  42912. - TLanPrivateInfo *priv = dev->priv;
  42913. - u32 ack = 0;
  42914. - int eoc = 0;
  42915. - u8 *head_buffer;
  42916. - TLanList *head_list;
  42917. - struct sk_buff *skb;
  42918. - TLanList *tail_list;
  42919. - void *t;
  42920. - u32 frameSize;
  42921. - u16 tmpCStat;
  42922. -
  42923. - TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE: Handling RX EOF (Head=%d Tail=%d)\n", priv->rxHead, priv->rxTail );
  42924. - head_list = priv->rxList + priv->rxHead;
  42925. -
  42926. - while (((tmpCStat = head_list->cStat) & TLAN_CSTAT_FRM_CMP) && (ack < 255)) {
  42927. - frameSize = head_list->frameSize;
  42928. - ack++;
  42929. - if (tmpCStat & TLAN_CSTAT_EOC)
  42930. - eoc = 1;
  42931. -
  42932. - if (bbuf) {
  42933. - skb = dev_alloc_skb(frameSize + 7);
  42934. - if (skb == NULL)
  42935. - printk(KERN_INFO "TLAN: Couldn't allocate memory for received data.\n");
  42936. - else {
  42937. - head_buffer = priv->rxBuffer + (priv->rxHead * TLAN_MAX_FRAME_SIZE);
  42938. - skb->dev = dev;
  42939. - skb_reserve(skb, 2);
  42940. - t = (void *) skb_put(skb, frameSize);
  42941. -
  42942. - priv->stats.rx_bytes += head_list->frameSize;
  42943. -
  42944. - memcpy( t, head_buffer, frameSize );
  42945. - skb->protocol = eth_type_trans( skb, dev );
  42946. - netif_rx( skb );
  42947. - }
  42948. - } else {
  42949. - struct sk_buff *new_skb;
  42950. -
  42951. - /*
  42952. - * I changed the algorithm here. What we now do
  42953. - * is allocate the new frame. If this fails we
  42954. - * simply recycle the frame.
  42955. - */
  42956. -
  42957. - new_skb = dev_alloc_skb( TLAN_MAX_FRAME_SIZE + 7 );
  42958. -
  42959. - if ( new_skb != NULL ) {
  42960. - /* If this ever happened it would be a problem */
  42961. - /* not any more - ac */
  42962. - skb = (struct sk_buff *) head_list->buffer[9].address;
  42963. - skb_trim( skb, frameSize );
  42964. -
  42965. - priv->stats.rx_bytes += frameSize;
  42966. + u16 sio;
  42967. - skb->protocol = eth_type_trans( skb, dev );
  42968. - netif_rx( skb );
  42969. -
  42970. - new_skb->dev = dev;
  42971. - skb_reserve( new_skb, 2 );
  42972. - t = (void *) skb_put( new_skb, TLAN_MAX_FRAME_SIZE );
  42973. - head_list->buffer[0].address = virt_to_bus( t );
  42974. - head_list->buffer[8].address = (u32) t;
  42975. - head_list->buffer[9].address = (u32) new_skb;
  42976. - } else
  42977. - printk(KERN_WARNING "TLAN: Couldn't allocate memory for received data.\n" );
  42978. - }
  42979. + outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  42980. + sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  42981. - head_list->forward = 0;
  42982. - head_list->cStat = 0;
  42983. - tail_list = priv->rxList + priv->rxTail;
  42984. - tail_list->forward = virt_to_bus( head_list );
  42985. -
  42986. - CIRC_INC( priv->rxHead, TLAN_NUM_RX_LISTS );
  42987. - CIRC_INC( priv->rxTail, TLAN_NUM_RX_LISTS );
  42988. - head_list = priv->rxList + priv->rxHead;
  42989. - }
  42990. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  42991. + TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  42992. + TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  42993. + TLan_ClearBit(TLAN_NET_SIO_EDATA, sio);
  42994. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  42995. - if (!ack)
  42996. - printk(KERN_INFO "TLAN: Received interrupt for uncompleted RX frame.\n");
  42997. -
  42998. +} /* TLan_EeSendStart */
  42999. - if ( eoc ) {
  43000. - TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE: Handling RX EOC (Head=%d Tail=%d)\n", priv->rxHead, priv->rxTail );
  43001. - head_list = priv->rxList + priv->rxHead;
  43002. - outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
  43003. - ack |= TLAN_HC_GO | TLAN_HC_RT;
  43004. - priv->rxEocCount++;
  43005. - }
  43006. -
  43007. - if ( priv->adapter->flags & TLAN_ADAPTER_ACTIVITY_LED ) {
  43008. - TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK | TLAN_LED_ACT );
  43009. - if ( priv->timer.function == NULL ) {
  43010. - priv->timer.function = &TLan_Timer;
  43011. - priv->timer.data = (unsigned long) dev;
  43012. - priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY;
  43013. - priv->timerSetAt = jiffies;
  43014. - priv->timerType = TLAN_TIMER_ACTIVITY;
  43015. - add_timer(&priv->timer);
  43016. - } else if ( priv->timerType == TLAN_TIMER_ACTIVITY ) {
  43017. - priv->timerSetAt = jiffies;
  43018. - }
  43019. - }
  43020. - dev->last_rx = jiffies;
  43021. -
  43022. - return ack;
  43023. -} /* TLan_HandleRxEOF */
  43024. /***************************************************************
  43025. - * TLan_HandleDummy
  43026. + * TLan_EeSendByte
  43027. *
  43028. * Returns:
  43029. - * 1
  43030. - * Parms:
  43031. - * dev Device assigned the IRQ that was
  43032. - * raised.
  43033. - * host_int The contents of the HOST_INT
  43034. - * port.
  43035. - *
  43036. - * This function handles the Dummy interrupt, which is
  43037. - * raised whenever a test interrupt is generated by setting
  43038. - * the Req_Int bit of HOST_CMD to 1.
  43039. + * If the correct ack was received, 0, otherwise 1
  43040. + * Parms: io_base The IO port base address for the
  43041. + * TLAN device with the EEPROM to
  43042. + * use.
  43043. + * data The 8 bits of information to
  43044. + * send to the EEPROM.
  43045. + * stop If TLAN_EEPROM_STOP is passed, a
  43046. + * stop cycle is sent after the
  43047. + * byte is sent after the ack is
  43048. + * read.
  43049. + *
  43050. + * This function sends a byte on the serial EEPROM line,
  43051. + * driving the clock to send each bit. The function then
  43052. + * reverses transmission direction and reads an acknowledge
  43053. + * bit.
  43054. *
  43055. **************************************************************/
  43056. -u32 TLan_HandleDummy( struct net_device *dev, u16 host_int )
  43057. +int TLan_EeSendByte(u16 io_base, u8 data, int stop)
  43058. {
  43059. - printk( "TLAN: Test interrupt on %s.\n", dev->name );
  43060. - return 1;
  43061. + int err;
  43062. + u8 place;
  43063. + u16 sio;
  43064. -} /* TLan_HandleDummy */
  43065. + outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  43066. + sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  43067. - /***************************************************************
  43068. - * TLan_HandleTxEOC
  43069. - *
  43070. - * Returns:
  43071. - * 1
  43072. - * Parms:
  43073. - * dev Device assigned the IRQ that was
  43074. - * raised.
  43075. - * host_int The contents of the HOST_INT
  43076. - * port.
  43077. - *
  43078. - * This driver is structured to determine EOC occurances by
  43079. - * reading the CSTAT member of the list structure. Tx EOC
  43080. - * interrupts are disabled via the DIO INTDIS register.
  43081. - * However, TLAN chips before revision 3.0 didn't have this
  43082. - * functionality, so process EOC events if this is the
  43083. - * case.
  43084. - *
  43085. - **************************************************************/
  43086. + /* Assume clock is low, tx is enabled; */
  43087. + for (place = 0x80; place != 0; place >>= 1) {
  43088. + if (place & data)
  43089. + TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  43090. + else
  43091. + TLan_ClearBit(TLAN_NET_SIO_EDATA, sio);
  43092. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  43093. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  43094. + }
  43095. + TLan_ClearBit(TLAN_NET_SIO_ETXEN, sio);
  43096. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  43097. + err = TLan_GetBit(TLAN_NET_SIO_EDATA, sio);
  43098. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  43099. + TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  43100. -u32 TLan_HandleTxEOC( struct net_device *dev, u16 host_int )
  43101. -{
  43102. - TLanPrivateInfo *priv = dev->priv;
  43103. - TLanList *head_list;
  43104. - u32 ack = 1;
  43105. -
  43106. - host_int = 0;
  43107. - if ( priv->tlanRev < 0x30 ) {
  43108. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Handling TX EOC (Head=%d Tail=%d) -- IRQ\n", priv->txHead, priv->txTail );
  43109. - head_list = priv->txList + priv->txHead;
  43110. - if ( ( head_list->cStat & TLAN_CSTAT_READY ) == TLAN_CSTAT_READY ) {
  43111. - netif_stop_queue(dev);
  43112. - outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
  43113. - ack |= TLAN_HC_GO;
  43114. - } else {
  43115. - priv->txInProgress = 0;
  43116. - }
  43117. + if ((!err) && stop) {
  43118. + TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* STOP, raise data while clock is high */
  43119. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  43120. + TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  43121. }
  43122. - return ack;
  43123. + return (err);
  43124. +
  43125. +} /* TLan_EeSendByte */
  43126. +
  43127. +
  43128. -} /* TLan_HandleTxEOC */
  43129. /***************************************************************
  43130. - * TLan_HandleStatusCheck
  43131. + * TLan_EeReceiveByte
  43132. *
  43133. * Returns:
  43134. - * 0 if Adapter check, 1 if Network Status check.
  43135. + * Nothing
  43136. * Parms:
  43137. - * dev Device assigned the IRQ that was
  43138. - * raised.
  43139. - * host_int The contents of the HOST_INT
  43140. - * port.
  43141. - *
  43142. - * This function handles Adapter Check/Network Status
  43143. - * interrupts generated by the adapter. It checks the
  43144. - * vector in the HOST_INT register to determine if it is
  43145. - * an Adapter Check interrupt. If so, it resets the
  43146. - * adapter. Otherwise it clears the status registers
  43147. - * and services the PHY.
  43148. + * io_base The IO port base address for the
  43149. + * TLAN device with the EEPROM to
  43150. + * use.
  43151. + * data An address to a char to hold the
  43152. + * data sent from the EEPROM.
  43153. + * stop If TLAN_EEPROM_STOP is passed, a
  43154. + * stop cycle is sent after the
  43155. + * byte is received, and no ack is
  43156. + * sent.
  43157. + *
  43158. + * This function receives 8 bits of data from the EEPROM
  43159. + * over the serial link. It then sends and ack bit, or no
  43160. + * ack and a stop bit. This function is used to retrieve
  43161. + * data after the address of a byte in the EEPROM has been
  43162. + * sent.
  43163. *
  43164. **************************************************************/
  43165. -u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int )
  43166. -{
  43167. - TLanPrivateInfo *priv = dev->priv;
  43168. - u32 ack;
  43169. - u32 error;
  43170. - u8 net_sts;
  43171. - u32 phy;
  43172. - u16 tlphy_ctl;
  43173. - u16 tlphy_sts;
  43174. -
  43175. - ack = 1;
  43176. - if ( host_int & TLAN_HI_IV_MASK ) {
  43177. - netif_stop_queue( dev );
  43178. - error = inl( dev->base_addr + TLAN_CH_PARM );
  43179. - printk( "TLAN: %s: Adaptor Error = 0x%x\n", dev->name, error );
  43180. - TLan_ReadAndClearStats( dev, TLAN_RECORD );
  43181. - outl( TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD );
  43182. -
  43183. - queue_task(&priv->tlan_tqueue, &tq_immediate);
  43184. - mark_bh(IMMEDIATE_BH);
  43185. -
  43186. - netif_wake_queue(dev);
  43187. - ack = 0;
  43188. - } else {
  43189. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Status Check\n", dev->name );
  43190. - phy = priv->phy[priv->phyNum];
  43191. +void TLan_EeReceiveByte(u16 io_base, u8 * data, int stop)
  43192. +{
  43193. + u8 place;
  43194. + u16 sio;
  43195. - net_sts = TLan_DioRead8( dev->base_addr, TLAN_NET_STS );
  43196. - if ( net_sts ) {
  43197. - TLan_DioWrite8( dev->base_addr, TLAN_NET_STS, net_sts );
  43198. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Net_Sts = %x\n", dev->name, (unsigned) net_sts );
  43199. - }
  43200. - if ( ( net_sts & TLAN_NET_STS_MIRQ ) && ( priv->phyNum == 0 ) ) {
  43201. - TLan_MiiReadReg( dev, phy, TLAN_TLPHY_STS, &tlphy_sts );
  43202. - TLan_MiiReadReg( dev, phy, TLAN_TLPHY_CTL, &tlphy_ctl );
  43203. - if ( ! ( tlphy_sts & TLAN_TS_POLOK ) && ! ( tlphy_ctl & TLAN_TC_SWAPOL ) ) {
  43204. - tlphy_ctl |= TLAN_TC_SWAPOL;
  43205. - TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tlphy_ctl);
  43206. - } else if ( ( tlphy_sts & TLAN_TS_POLOK ) && ( tlphy_ctl & TLAN_TC_SWAPOL ) ) {
  43207. - tlphy_ctl &= ~TLAN_TC_SWAPOL;
  43208. - TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tlphy_ctl);
  43209. - }
  43210. + outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  43211. + sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  43212. + *data = 0;
  43213. - if (debug) {
  43214. - TLan_PhyPrint( dev );
  43215. - }
  43216. - }
  43217. + /* Assume clock is low, tx is enabled; */
  43218. + TLan_ClearBit(TLAN_NET_SIO_ETXEN, sio);
  43219. + for (place = 0x80; place; place >>= 1) {
  43220. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  43221. + if (TLan_GetBit(TLAN_NET_SIO_EDATA, sio))
  43222. + *data |= place;
  43223. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  43224. + }
  43225. +
  43226. + TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  43227. + if (!stop) {
  43228. + TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* Ack = 0 */
  43229. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  43230. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  43231. + } else {
  43232. + TLan_SetBit(TLAN_NET_SIO_EDATA, sio); /* No ack = 1 (?) */
  43233. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  43234. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  43235. + TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* STOP, raise data while clock is high */
  43236. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  43237. + TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  43238. }
  43239. - return ack;
  43240. +} /* TLan_EeReceiveByte */
  43241. +
  43242. -} /* TLan_HandleStatusCheck */
  43243. /***************************************************************
  43244. - * TLan_HandleRxEOC
  43245. + * TLan_EeReadByte
  43246. *
  43247. * Returns:
  43248. - * 1
  43249. + * No error = 0, else, the stage at which the error
  43250. + * occurred.
  43251. * Parms:
  43252. - * dev Device assigned the IRQ that was
  43253. - * raised.
  43254. - * host_int The contents of the HOST_INT
  43255. - * port.
  43256. - *
  43257. - * This driver is structured to determine EOC occurances by
  43258. - * reading the CSTAT member of the list structure. Rx EOC
  43259. - * interrupts are disabled via the DIO INTDIS register.
  43260. - * However, TLAN chips before revision 3.0 didn't have this
  43261. - * CSTAT member or a INTDIS register, so if this chip is
  43262. - * pre-3.0, process EOC interrupts normally.
  43263. + * io_base The IO port base address for the
  43264. + * TLAN device with the EEPROM to
  43265. + * use.
  43266. + * ee_addr The address of the byte in the
  43267. + * EEPROM whose contents are to be
  43268. + * retrieved.
  43269. + * data An address to a char to hold the
  43270. + * data obtained from the EEPROM.
  43271. + *
  43272. + * This function reads a byte of information from an byte
  43273. + * cell in the EEPROM.
  43274. *
  43275. **************************************************************/
  43276. -u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int )
  43277. +int TLan_EeReadByte(u16 io_base, u8 ee_addr, u8 * data)
  43278. {
  43279. - TLanPrivateInfo *priv = dev->priv;
  43280. - TLanList *head_list;
  43281. - u32 ack = 1;
  43282. + int err;
  43283. + int ret = 0;
  43284. - if ( priv->tlanRev < 0x30 ) {
  43285. - TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE: Handling RX EOC (Head=%d Tail=%d) -- IRQ\n", priv->rxHead, priv->rxTail );
  43286. - head_list = priv->rxList + priv->rxHead;
  43287. - outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
  43288. - ack |= TLAN_HC_GO | TLAN_HC_RT;
  43289. - priv->rxEocCount++;
  43290. +
  43291. + TLan_EeSendStart(io_base);
  43292. + err = TLan_EeSendByte(io_base, 0xA0, TLAN_EEPROM_ACK);
  43293. + if (err) {
  43294. + ret = 1;
  43295. + goto fail;
  43296. + }
  43297. + err = TLan_EeSendByte(io_base, ee_addr, TLAN_EEPROM_ACK);
  43298. + if (err) {
  43299. + ret = 2;
  43300. + goto fail;
  43301. + }
  43302. + TLan_EeSendStart(io_base);
  43303. + err = TLan_EeSendByte(io_base, 0xA1, TLAN_EEPROM_ACK);
  43304. + if (err) {
  43305. + ret = 3;
  43306. + goto fail;
  43307. }
  43308. + TLan_EeReceiveByte(io_base, data, TLAN_EEPROM_STOP);
  43309. + fail:
  43310. - return ack;
  43311. + return ret;
  43312. +
  43313. +} /* TLan_EeReadByte */
  43314. -} /* TLan_HandleRxEOC */
  43315. /*****************************************************************************
  43316. ******************************************************************************
  43317. - ThunderLAN Driver Timer Function
  43318. + ThunderLAN Driver MII Routines
  43319. +
  43320. + These routines are based on the information in Chap. 2 of the
  43321. + "ThunderLAN Programmer's Guide", pp. 15-24.
  43322. ******************************************************************************
  43323. *****************************************************************************/
  43324. +
  43325. /***************************************************************
  43326. - * TLan_Timer
  43327. + * TLan_MiiReadReg
  43328. *
  43329. * Returns:
  43330. - * Nothing
  43331. + * 0 if ack received ok
  43332. + * 1 otherwise.
  43333. + *
  43334. * Parms:
  43335. - * data A value given to add timer when
  43336. - * add_timer was called.
  43337. + * dev The device structure containing
  43338. + * The io address and interrupt count
  43339. + * for this device.
  43340. + * phy The address of the PHY to be queried.
  43341. + * reg The register whose contents are to be
  43342. + * retreived.
  43343. + * val A pointer to a variable to store the
  43344. + * retrieved value.
  43345. *
  43346. - * This function handles timed functionality for the
  43347. - * TLAN driver. The two current timer uses are for
  43348. - * delaying for autonegotionation and driving the ACT LED.
  43349. - * - Autonegotiation requires being allowed about
  43350. - * 2 1/2 seconds before attempting to transmit a
  43351. - * packet. It would be a very bad thing to hang
  43352. - * the kernel this long, so the driver doesn't
  43353. - * allow transmission 'til after this time, for
  43354. - * certain PHYs. It would be much nicer if all
  43355. - * PHYs were interrupt-capable like the internal
  43356. - * PHY.
  43357. - * - The ACT LED, which shows adapter activity, is
  43358. - * driven by the driver, and so must be left on
  43359. - * for a short period to power up the LED so it
  43360. - * can be seen. This delay can be changed by
  43361. - * changing the TLAN_TIMER_ACT_DELAY in tlan.h,
  43362. - * if desired. 100 ms produces a slightly
  43363. - * sluggish response.
  43364. + * This function uses the TLAN's MII bus to retreive the contents
  43365. + * of a given register on a PHY. It sends the appropriate info
  43366. + * and then reads the 16-bit register value from the MII bus via
  43367. + * the TLAN SIO register.
  43368. *
  43369. **************************************************************/
  43370. -void TLan_Timer( unsigned long data )
  43371. +int TLan_MiiReadReg(struct nic *nic __unused, u16 phy, u16 reg, u16 * val)
  43372. {
  43373. - struct net_device *dev = (struct net_device *) data;
  43374. - TLanPrivateInfo *priv = dev->priv;
  43375. - u32 elapsed;
  43376. - unsigned long flags = 0;
  43377. -
  43378. - priv->timer.function = NULL;
  43379. -
  43380. - switch ( priv->timerType ) {
  43381. -#ifdef MONITOR
  43382. - case TLAN_TIMER_LINK_BEAT:
  43383. - TLan_PhyMonitor( dev );
  43384. - break;
  43385. -#endif
  43386. - case TLAN_TIMER_PHY_PDOWN:
  43387. - TLan_PhyPowerDown( dev );
  43388. - break;
  43389. - case TLAN_TIMER_PHY_PUP:
  43390. - TLan_PhyPowerUp( dev );
  43391. - break;
  43392. - case TLAN_TIMER_PHY_RESET:
  43393. - TLan_PhyReset( dev );
  43394. - break;
  43395. - case TLAN_TIMER_PHY_START_LINK:
  43396. - TLan_PhyStartLink( dev );
  43397. - break;
  43398. - case TLAN_TIMER_PHY_FINISH_AN:
  43399. - TLan_PhyFinishAutoNeg( dev );
  43400. - break;
  43401. - case TLAN_TIMER_FINISH_RESET:
  43402. - TLan_FinishReset( dev );
  43403. - break;
  43404. - case TLAN_TIMER_ACTIVITY:
  43405. - spin_lock_irqsave(&priv->lock, flags);
  43406. - if ( priv->timer.function == NULL ) {
  43407. - elapsed = jiffies - priv->timerSetAt;
  43408. - if ( elapsed >= TLAN_TIMER_ACT_DELAY ) {
  43409. - TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK );
  43410. - } else {
  43411. - priv->timer.function = &TLan_Timer;
  43412. - priv->timer.expires = priv->timerSetAt + TLAN_TIMER_ACT_DELAY;
  43413. - spin_unlock_irqrestore(&priv->lock, flags);
  43414. - add_timer( &priv->timer );
  43415. - break;
  43416. - }
  43417. - }
  43418. - spin_unlock_irqrestore(&priv->lock, flags);
  43419. - break;
  43420. - default:
  43421. - break;
  43422. + u8 nack;
  43423. + u16 sio, tmp;
  43424. + u32 i;
  43425. + int err;
  43426. + int minten;
  43427. +
  43428. + err = FALSE;
  43429. + outw(TLAN_NET_SIO, BASE + TLAN_DIO_ADR);
  43430. + sio = BASE + TLAN_DIO_DATA + TLAN_NET_SIO;
  43431. +
  43432. + TLan_MiiSync(BASE);
  43433. +
  43434. + minten = TLan_GetBit(TLAN_NET_SIO_MINTEN, sio);
  43435. + if (minten)
  43436. + TLan_ClearBit(TLAN_NET_SIO_MINTEN, sio);
  43437. +
  43438. + TLan_MiiSendData(BASE, 0x1, 2); /* Start ( 01b ) */
  43439. + TLan_MiiSendData(BASE, 0x2, 2); /* Read ( 10b ) */
  43440. + TLan_MiiSendData(BASE, phy, 5); /* Device # */
  43441. + TLan_MiiSendData(BASE, reg, 5); /* Register # */
  43442. +
  43443. +
  43444. + TLan_ClearBit(TLAN_NET_SIO_MTXEN, sio); /* Change direction */
  43445. +
  43446. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Clock Idle bit */
  43447. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  43448. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Wait 300ns */
  43449. +
  43450. + nack = TLan_GetBit(TLAN_NET_SIO_MDATA, sio); /* Check for ACK */
  43451. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio); /* Finish ACK */
  43452. + if (nack) { /* No ACK, so fake it */
  43453. + for (i = 0; i < 16; i++) {
  43454. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  43455. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  43456. + }
  43457. + tmp = 0xffff;
  43458. + err = TRUE;
  43459. + } else { /* ACK, so read data */
  43460. + for (tmp = 0, i = 0x8000; i; i >>= 1) {
  43461. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  43462. + if (TLan_GetBit(TLAN_NET_SIO_MDATA, sio))
  43463. + tmp |= i;
  43464. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  43465. + }
  43466. }
  43467. -} /* TLan_Timer */
  43468. -/*****************************************************************************
  43469. -******************************************************************************
  43470. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Idle cycle */
  43471. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  43472. - ThunderLAN Driver Adapter Related Routines
  43473. + if (minten)
  43474. + TLan_SetBit(TLAN_NET_SIO_MINTEN, sio);
  43475. -******************************************************************************
  43476. -*****************************************************************************/
  43477. + *val = tmp;
  43478. +
  43479. + return err;
  43480. +
  43481. +} /* TLan_MiiReadReg */
  43482. /***************************************************************
  43483. - * TLan_ResetLists
  43484. - *
  43485. + * TLan_MiiSendData
  43486. + *
  43487. * Returns:
  43488. * Nothing
  43489. * Parms:
  43490. - * dev The device structure with the list
  43491. - * stuctures to be reset.
  43492. + * base_port The base IO port of the adapter in
  43493. + * question.
  43494. + * dev The address of the PHY to be queried.
  43495. + * data The value to be placed on the MII bus.
  43496. + * num_bits The number of bits in data that are to
  43497. + * be placed on the MII bus.
  43498. *
  43499. - * This routine sets the variables associated with managing
  43500. - * the TLAN lists to their initial values.
  43501. + * This function sends on sequence of bits on the MII
  43502. + * configuration bus.
  43503. *
  43504. **************************************************************/
  43505. -void TLan_ResetLists( struct net_device *dev )
  43506. +void TLan_MiiSendData(u16 base_port, u32 data, unsigned num_bits)
  43507. {
  43508. - TLanPrivateInfo *priv = dev->priv;
  43509. - int i;
  43510. - TLanList *list;
  43511. - struct sk_buff *skb;
  43512. - void *t = NULL;
  43513. + u16 sio;
  43514. + u32 i;
  43515. - priv->txHead = 0;
  43516. - priv->txTail = 0;
  43517. - for ( i = 0; i < TLAN_NUM_TX_LISTS; i++ ) {
  43518. - list = priv->txList + i;
  43519. - list->cStat = TLAN_CSTAT_UNUSED;
  43520. - if ( bbuf ) {
  43521. - list->buffer[0].address = virt_to_bus( priv->txBuffer + ( i * TLAN_MAX_FRAME_SIZE ) );
  43522. - } else {
  43523. - list->buffer[0].address = 0;
  43524. - }
  43525. - list->buffer[2].count = 0;
  43526. - list->buffer[2].address = 0;
  43527. - list->buffer[9].address = 0;
  43528. - }
  43529. + if (num_bits == 0)
  43530. + return;
  43531. +
  43532. + outw(TLAN_NET_SIO, base_port + TLAN_DIO_ADR);
  43533. + sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  43534. + TLan_SetBit(TLAN_NET_SIO_MTXEN, sio);
  43535. - priv->rxHead = 0;
  43536. - priv->rxTail = TLAN_NUM_RX_LISTS - 1;
  43537. - for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ ) {
  43538. - list = priv->rxList + i;
  43539. - list->cStat = TLAN_CSTAT_READY;
  43540. - list->frameSize = TLAN_MAX_FRAME_SIZE;
  43541. - list->buffer[0].count = TLAN_MAX_FRAME_SIZE | TLAN_LAST_BUFFER;
  43542. - if ( bbuf ) {
  43543. - list->buffer[0].address = virt_to_bus( priv->rxBuffer + ( i * TLAN_MAX_FRAME_SIZE ) );
  43544. - } else {
  43545. - skb = dev_alloc_skb( TLAN_MAX_FRAME_SIZE + 7 );
  43546. - if ( skb == NULL ) {
  43547. - printk( "TLAN: Couldn't allocate memory for received data.\n" );
  43548. - /* If this ever happened it would be a problem */
  43549. - } else {
  43550. - skb->dev = dev;
  43551. - skb_reserve( skb, 2 );
  43552. - t = (void *) skb_put( skb, TLAN_MAX_FRAME_SIZE );
  43553. - }
  43554. - list->buffer[0].address = virt_to_bus( t );
  43555. - list->buffer[8].address = (u32) t;
  43556. - list->buffer[9].address = (u32) skb;
  43557. - }
  43558. - list->buffer[1].count = 0;
  43559. - list->buffer[1].address = 0;
  43560. - if ( i < TLAN_NUM_RX_LISTS - 1 )
  43561. - list->forward = virt_to_bus( list + 1 );
  43562. + for (i = (0x1 << (num_bits - 1)); i; i >>= 1) {
  43563. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  43564. + (void) TLan_GetBit(TLAN_NET_SIO_MCLK, sio);
  43565. + if (data & i)
  43566. + TLan_SetBit(TLAN_NET_SIO_MDATA, sio);
  43567. else
  43568. - list->forward = 0;
  43569. + TLan_ClearBit(TLAN_NET_SIO_MDATA, sio);
  43570. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  43571. + (void) TLan_GetBit(TLAN_NET_SIO_MCLK, sio);
  43572. }
  43573. -} /* TLan_ResetLists */
  43574. +} /* TLan_MiiSendData */
  43575. -void TLan_FreeLists( struct net_device *dev )
  43576. -{
  43577. - TLanPrivateInfo *priv = dev->priv;
  43578. - int i;
  43579. - TLanList *list;
  43580. - struct sk_buff *skb;
  43581. -
  43582. - if ( ! bbuf ) {
  43583. - for ( i = 0; i < TLAN_NUM_TX_LISTS; i++ ) {
  43584. - list = priv->txList + i;
  43585. - skb = (struct sk_buff *) list->buffer[9].address;
  43586. - if ( skb ) {
  43587. - dev_kfree_skb_any( skb );
  43588. - list->buffer[9].address = 0;
  43589. - }
  43590. - }
  43591. - for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ ) {
  43592. - list = priv->rxList + i;
  43593. - skb = (struct sk_buff *) list->buffer[9].address;
  43594. - if ( skb ) {
  43595. - dev_kfree_skb_any( skb );
  43596. - list->buffer[9].address = 0;
  43597. - }
  43598. - }
  43599. - }
  43600. -} /* TLan_FreeLists */
  43601. /***************************************************************
  43602. - * TLan_PrintDio
  43603. - *
  43604. + * TLan_MiiSync
  43605. + *
  43606. * Returns:
  43607. * Nothing
  43608. * Parms:
  43609. - * io_base Base IO port of the device of
  43610. - * which to print DIO registers.
  43611. + * base_port The base IO port of the adapter in
  43612. + * question.
  43613. *
  43614. - * This function prints out all the internal (DIO)
  43615. - * registers of a TLAN chip.
  43616. + * This functions syncs all PHYs in terms of the MII configuration
  43617. + * bus.
  43618. *
  43619. **************************************************************/
  43620. -void TLan_PrintDio( u16 io_base )
  43621. +void TLan_MiiSync(u16 base_port)
  43622. {
  43623. - u32 data0, data1;
  43624. - int i;
  43625. + int i;
  43626. + u16 sio;
  43627. - printk( "TLAN: Contents of internal registers for io base 0x%04hx.\n", io_base );
  43628. - printk( "TLAN: Off. +0 +4\n" );
  43629. - for ( i = 0; i < 0x4C; i+= 8 ) {
  43630. - data0 = TLan_DioRead32( io_base, i );
  43631. - data1 = TLan_DioRead32( io_base, i + 0x4 );
  43632. - printk( "TLAN: 0x%02x 0x%08x 0x%08x\n", i, data0, data1 );
  43633. + outw(TLAN_NET_SIO, base_port + TLAN_DIO_ADR);
  43634. + sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  43635. +
  43636. + TLan_ClearBit(TLAN_NET_SIO_MTXEN, sio);
  43637. + for (i = 0; i < 32; i++) {
  43638. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  43639. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  43640. }
  43641. -} /* TLan_PrintDio */
  43642. +} /* TLan_MiiSync */
  43643. +
  43644. +
  43645. +
  43646. /***************************************************************
  43647. - * TLan_PrintList
  43648. - *
  43649. + * TLan_MiiWriteReg
  43650. + *
  43651. * Returns:
  43652. * Nothing
  43653. * Parms:
  43654. - * list A pointer to the TLanList structure to
  43655. - * be printed.
  43656. - * type A string to designate type of list,
  43657. - * "Rx" or "Tx".
  43658. - * num The index of the list.
  43659. + * dev The device structure for the device
  43660. + * to write to.
  43661. + * phy The address of the PHY to be written to.
  43662. + * reg The register whose contents are to be
  43663. + * written.
  43664. + * val The value to be written to the register.
  43665. *
  43666. - * This function prints out the contents of the list
  43667. - * pointed to by the list parameter.
  43668. + * This function uses the TLAN's MII bus to write the contents of a
  43669. + * given register on a PHY. It sends the appropriate info and then
  43670. + * writes the 16-bit register value from the MII configuration bus
  43671. + * via the TLAN SIO register.
  43672. *
  43673. **************************************************************/
  43674. -void TLan_PrintList( TLanList *list, char *type, int num)
  43675. +void TLan_MiiWriteReg(struct nic *nic __unused, u16 phy, u16 reg, u16 val)
  43676. {
  43677. - int i;
  43678. + u16 sio;
  43679. + int minten;
  43680. +
  43681. + outw(TLAN_NET_SIO, BASE + TLAN_DIO_ADR);
  43682. + sio = BASE + TLAN_DIO_DATA + TLAN_NET_SIO;
  43683. +
  43684. + TLan_MiiSync(BASE);
  43685. +
  43686. + minten = TLan_GetBit(TLAN_NET_SIO_MINTEN, sio);
  43687. + if (minten)
  43688. + TLan_ClearBit(TLAN_NET_SIO_MINTEN, sio);
  43689. +
  43690. + TLan_MiiSendData(BASE, 0x1, 2); /* Start ( 01b ) */
  43691. + TLan_MiiSendData(BASE, 0x1, 2); /* Write ( 01b ) */
  43692. + TLan_MiiSendData(BASE, phy, 5); /* Device # */
  43693. + TLan_MiiSendData(BASE, reg, 5); /* Register # */
  43694. +
  43695. + TLan_MiiSendData(BASE, 0x2, 2); /* Send ACK */
  43696. + TLan_MiiSendData(BASE, val, 16); /* Send Data */
  43697. +
  43698. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Idle cycle */
  43699. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  43700. +
  43701. + if (minten)
  43702. + TLan_SetBit(TLAN_NET_SIO_MINTEN, sio);
  43703. - printk( "TLAN: %s List %d at 0x%08x\n", type, num, (u32) list );
  43704. - printk( "TLAN: Forward = 0x%08x\n", list->forward );
  43705. - printk( "TLAN: CSTAT = 0x%04hx\n", list->cStat );
  43706. - printk( "TLAN: Frame Size = 0x%04hx\n", list->frameSize );
  43707. - /* for ( i = 0; i < 10; i++ ) { */
  43708. - for ( i = 0; i < 2; i++ ) {
  43709. - printk( "TLAN: Buffer[%d].count, addr = 0x%08x, 0x%08x\n", i, list->buffer[i].count, list->buffer[i].address );
  43710. - }
  43711. -} /* TLan_PrintList */
  43712. +} /* TLan_MiiWriteReg */
  43713. /***************************************************************
  43714. - * TLan_ReadAndClearStats
  43715. + * TLan_SetMac
  43716. *
  43717. * Returns:
  43718. * Nothing
  43719. * Parms:
  43720. * dev Pointer to device structure of adapter
  43721. - * to which to read stats.
  43722. - * record Flag indicating whether to add
  43723. + * on which to change the AREG.
  43724. + * areg The AREG to set the address in (0 - 3).
  43725. + * mac A pointer to an array of chars. Each
  43726. + * element stores one byte of the address.
  43727. + * IE, it isn't in ascii.
  43728. *
  43729. - * This functions reads all the internal status registers
  43730. - * of the TLAN chip, which clears them as a side effect.
  43731. - * It then either adds the values to the device's status
  43732. - * struct, or discards them, depending on whether record
  43733. - * is TLAN_RECORD (!=0) or TLAN_IGNORE (==0).
  43734. + * This function transfers a MAC address to one of the
  43735. + * TLAN AREGs (address registers). The TLAN chip locks
  43736. + * the register on writing to offset 0 and unlocks the
  43737. + * register after writing to offset 5. If NULL is passed
  43738. + * in mac, then the AREG is filled with 0's.
  43739. *
  43740. **************************************************************/
  43741. -void TLan_ReadAndClearStats( struct net_device *dev, int record )
  43742. +void TLan_SetMac(struct nic *nic __unused, int areg, char *mac)
  43743. {
  43744. - TLanPrivateInfo *priv = dev->priv;
  43745. - u32 tx_good, tx_under;
  43746. - u32 rx_good, rx_over;
  43747. - u32 def_tx, crc, code;
  43748. - u32 multi_col, single_col;
  43749. - u32 excess_col, late_col, loss;
  43750. -
  43751. - outw( TLAN_GOOD_TX_FRMS, dev->base_addr + TLAN_DIO_ADR );
  43752. - tx_good = inb( dev->base_addr + TLAN_DIO_DATA );
  43753. - tx_good += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
  43754. - tx_good += inb( dev->base_addr + TLAN_DIO_DATA + 2 ) << 16;
  43755. - tx_under = inb( dev->base_addr + TLAN_DIO_DATA + 3 );
  43756. -
  43757. - outw( TLAN_GOOD_RX_FRMS, dev->base_addr + TLAN_DIO_ADR );
  43758. - rx_good = inb( dev->base_addr + TLAN_DIO_DATA );
  43759. - rx_good += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
  43760. - rx_good += inb( dev->base_addr + TLAN_DIO_DATA + 2 ) << 16;
  43761. - rx_over = inb( dev->base_addr + TLAN_DIO_DATA + 3 );
  43762. -
  43763. - outw( TLAN_DEFERRED_TX, dev->base_addr + TLAN_DIO_ADR );
  43764. - def_tx = inb( dev->base_addr + TLAN_DIO_DATA );
  43765. - def_tx += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
  43766. - crc = inb( dev->base_addr + TLAN_DIO_DATA + 2 );
  43767. - code = inb( dev->base_addr + TLAN_DIO_DATA + 3 );
  43768. -
  43769. - outw( TLAN_MULTICOL_FRMS, dev->base_addr + TLAN_DIO_ADR );
  43770. - multi_col = inb( dev->base_addr + TLAN_DIO_DATA );
  43771. - multi_col += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
  43772. - single_col = inb( dev->base_addr + TLAN_DIO_DATA + 2 );
  43773. - single_col += inb( dev->base_addr + TLAN_DIO_DATA + 3 ) << 8;
  43774. -
  43775. - outw( TLAN_EXCESSCOL_FRMS, dev->base_addr + TLAN_DIO_ADR );
  43776. - excess_col = inb( dev->base_addr + TLAN_DIO_DATA );
  43777. - late_col = inb( dev->base_addr + TLAN_DIO_DATA + 1 );
  43778. - loss = inb( dev->base_addr + TLAN_DIO_DATA + 2 );
  43779. -
  43780. - if ( record ) {
  43781. - priv->stats.rx_packets += rx_good;
  43782. - priv->stats.rx_errors += rx_over + crc + code;
  43783. - priv->stats.tx_packets += tx_good;
  43784. - priv->stats.tx_errors += tx_under + loss;
  43785. - priv->stats.collisions += multi_col + single_col + excess_col + late_col;
  43786. -
  43787. - priv->stats.rx_over_errors += rx_over;
  43788. - priv->stats.rx_crc_errors += crc;
  43789. - priv->stats.rx_frame_errors += code;
  43790. + int i;
  43791. - priv->stats.tx_aborted_errors += tx_under;
  43792. - priv->stats.tx_carrier_errors += loss;
  43793. + areg *= 6;
  43794. +
  43795. + if (mac != NULL) {
  43796. + for (i = 0; i < 6; i++)
  43797. + TLan_DioWrite8(BASE, TLAN_AREG_0 + areg + i,
  43798. + mac[i]);
  43799. + } else {
  43800. + for (i = 0; i < 6; i++)
  43801. + TLan_DioWrite8(BASE, TLAN_AREG_0 + areg + i, 0);
  43802. }
  43803. -
  43804. -} /* TLan_ReadAndClearStats */
  43805. - /***************************************************************
  43806. - * TLan_Reset
  43807. +} /* TLan_SetMac */
  43808. +
  43809. + /*********************************************************************
  43810. + * TLan_PhyDetect
  43811. *
  43812. * Returns:
  43813. - * 0
  43814. + * Nothing
  43815. * Parms:
  43816. - * dev Pointer to device structure of adapter
  43817. - * to be reset.
  43818. + * dev A pointer to the device structure of the adapter
  43819. + * for which the PHY needs determined.
  43820. *
  43821. - * This function resets the adapter and it's physical
  43822. - * device. See Chap. 3, pp. 9-10 of the "ThunderLAN
  43823. - * Programmer's Guide" for details. The routine tries to
  43824. - * implement what is detailed there, though adjustments
  43825. - * have been made.
  43826. + * So far I've found that adapters which have external PHYs
  43827. + * may also use the internal PHY for part of the functionality.
  43828. + * (eg, AUI/Thinnet). This function finds out if this TLAN
  43829. + * chip has an internal PHY, and then finds the first external
  43830. + * PHY (starting from address 0) if it exists).
  43831. *
  43832. - **************************************************************/
  43833. + ********************************************************************/
  43834. -void
  43835. -TLan_ResetAdapter( struct net_device *dev )
  43836. +void TLan_PhyDetect(struct nic *nic)
  43837. {
  43838. - TLanPrivateInfo *priv = dev->priv;
  43839. - int i;
  43840. - u32 addr;
  43841. - u32 data;
  43842. - u8 data8;
  43843. + u16 control;
  43844. + u16 hi;
  43845. + u16 lo;
  43846. + u32 phy;
  43847. - priv->tlanFullDuplex = FALSE;
  43848. - priv->phyOnline=0;
  43849. -/* 1. Assert reset bit. */
  43850. + if (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY) {
  43851. + priv->phyNum = 0xFFFF;
  43852. + return;
  43853. + }
  43854. - data = inl(dev->base_addr + TLAN_HOST_CMD);
  43855. - data |= TLAN_HC_AD_RST;
  43856. - outl(data, dev->base_addr + TLAN_HOST_CMD);
  43857. -
  43858. - udelay(1000);
  43859. + TLan_MiiReadReg(nic, TLAN_PHY_MAX_ADDR, MII_GEN_ID_HI, &hi);
  43860. -/* 2. Turn off interrupts. ( Probably isn't necessary ) */
  43861. + if (hi != 0xFFFF) {
  43862. + priv->phy[0] = TLAN_PHY_MAX_ADDR;
  43863. + } else {
  43864. + priv->phy[0] = TLAN_PHY_NONE;
  43865. + }
  43866. - data = inl(dev->base_addr + TLAN_HOST_CMD);
  43867. - data |= TLAN_HC_INT_OFF;
  43868. - outl(data, dev->base_addr + TLAN_HOST_CMD);
  43869. + priv->phy[1] = TLAN_PHY_NONE;
  43870. + for (phy = 0; phy <= TLAN_PHY_MAX_ADDR; phy++) {
  43871. + TLan_MiiReadReg(nic, phy, MII_GEN_CTL, &control);
  43872. + TLan_MiiReadReg(nic, phy, MII_GEN_ID_HI, &hi);
  43873. + TLan_MiiReadReg(nic, phy, MII_GEN_ID_LO, &lo);
  43874. + if ((control != 0xFFFF) || (hi != 0xFFFF)
  43875. + || (lo != 0xFFFF)) {
  43876. + printf("PHY found at %hX %hX %hX %hX\n", phy,
  43877. + control, hi, lo);
  43878. + if ((priv->phy[1] == TLAN_PHY_NONE)
  43879. + && (phy != TLAN_PHY_MAX_ADDR)) {
  43880. + priv->phy[1] = phy;
  43881. + }
  43882. + }
  43883. + }
  43884. -/* 3. Clear AREGs and HASHs. */
  43885. + if (priv->phy[1] != TLAN_PHY_NONE) {
  43886. + priv->phyNum = 1;
  43887. + } else if (priv->phy[0] != TLAN_PHY_NONE) {
  43888. + priv->phyNum = 0;
  43889. + } else {
  43890. + printf
  43891. + ("TLAN: Cannot initialize device, no PHY was found!\n");
  43892. + }
  43893. +
  43894. +} /* TLan_PhyDetect */
  43895. - for ( i = TLAN_AREG_0; i <= TLAN_HASH_2; i += 4 ) {
  43896. - TLan_DioWrite32( dev->base_addr, (u16) i, 0 );
  43897. +void TLan_PhyPowerDown(struct nic *nic)
  43898. +{
  43899. +
  43900. + u16 value;
  43901. + printf("%s: Powering down PHY(s).\n", priv->nic_name);
  43902. + value = MII_GC_PDOWN | MII_GC_LOOPBK | MII_GC_ISOLATE;
  43903. + TLan_MiiSync(BASE);
  43904. + TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
  43905. + if ((priv->phyNum == 0) && (priv->phy[1] != TLAN_PHY_NONE)
  43906. + &&
  43907. + (!(tlan_pci_tbl[chip_idx].
  43908. + flags & TLAN_ADAPTER_USE_INTERN_10))) {
  43909. + TLan_MiiSync(BASE);
  43910. + TLan_MiiWriteReg(nic, priv->phy[1], MII_GEN_CTL, value);
  43911. }
  43912. -/* 4. Setup NetConfig register. */
  43913. + /* Wait for 50 ms and powerup
  43914. + * This is abitrary. It is intended to make sure the
  43915. + * tranceiver settles.
  43916. + */
  43917. + /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_PUP ); */
  43918. + mdelay(50);
  43919. + TLan_PhyPowerUp(nic);
  43920. - data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN;
  43921. - TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, (u16) data );
  43922. +} /* TLan_PhyPowerDown */
  43923. -/* 5. Load Ld_Tmr and Ld_Thr in HOST_CMD. */
  43924. - outl( TLAN_HC_LD_TMR | 0x3f, dev->base_addr + TLAN_HOST_CMD );
  43925. - outl( TLAN_HC_LD_THR | 0x9, dev->base_addr + TLAN_HOST_CMD );
  43926. +void TLan_PhyPowerUp(struct nic *nic)
  43927. +{
  43928. + u16 value;
  43929. -/* 6. Unreset the MII by setting NMRST (in NetSio) to 1. */
  43930. + printf("%s: Powering up PHY.\n", priv->nic_name);
  43931. + TLan_MiiSync(BASE);
  43932. + value = MII_GC_LOOPBK;
  43933. + TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
  43934. + TLan_MiiSync(BASE);
  43935. + /* Wait for 500 ms and reset the
  43936. + * tranceiver. The TLAN docs say both 50 ms and
  43937. + * 500 ms, so do the longer, just in case.
  43938. + */
  43939. + mdelay(500);
  43940. + TLan_PhyReset(nic);
  43941. + /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_RESET ); */
  43942. - outw( TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR );
  43943. - addr = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO;
  43944. - TLan_SetBit( TLAN_NET_SIO_NMRST, addr );
  43945. +} /* TLan_PhyPowerUp */
  43946. -/* 7. Setup the remaining registers. */
  43947. +void TLan_PhyReset(struct nic *nic)
  43948. +{
  43949. + u16 phy;
  43950. + u16 value;
  43951. - if ( priv->tlanRev >= 0x30 ) {
  43952. - data8 = TLAN_ID_TX_EOC | TLAN_ID_RX_EOC;
  43953. - TLan_DioWrite8( dev->base_addr, TLAN_INT_DIS, data8 );
  43954. + phy = priv->phy[priv->phyNum];
  43955. +
  43956. + printf("%s: Reseting PHY.\n", priv->nic_name);
  43957. + TLan_MiiSync(BASE);
  43958. + value = MII_GC_LOOPBK | MII_GC_RESET;
  43959. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, value);
  43960. + TLan_MiiReadReg(nic, phy, MII_GEN_CTL, &value);
  43961. + while (value & MII_GC_RESET) {
  43962. + TLan_MiiReadReg(nic, phy, MII_GEN_CTL, &value);
  43963. }
  43964. - TLan_PhyDetect( dev );
  43965. - data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN;
  43966. -
  43967. - if ( priv->adapter->flags & TLAN_ADAPTER_BIT_RATE_PHY ) {
  43968. - data |= TLAN_NET_CFG_BIT;
  43969. - if ( priv->aui == 1 ) {
  43970. - TLan_DioWrite8( dev->base_addr, TLAN_ACOMMIT, 0x0a );
  43971. - } else if ( priv->duplex == TLAN_DUPLEX_FULL ) {
  43972. - TLan_DioWrite8( dev->base_addr, TLAN_ACOMMIT, 0x00 );
  43973. +
  43974. + /* Wait for 500 ms and initialize.
  43975. + * I don't remember why I wait this long.
  43976. + * I've changed this to 50ms, as it seems long enough.
  43977. + */
  43978. + /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_START_LINK ); */
  43979. + mdelay(50);
  43980. + TLan_PhyStartLink(nic);
  43981. +
  43982. +} /* TLan_PhyReset */
  43983. +
  43984. +
  43985. +void TLan_PhyStartLink(struct nic *nic)
  43986. +{
  43987. +
  43988. + u16 ability;
  43989. + u16 control;
  43990. + u16 data;
  43991. + u16 phy;
  43992. + u16 status;
  43993. + u16 tctl;
  43994. +
  43995. + phy = priv->phy[priv->phyNum];
  43996. + printf("%s: Trying to activate link.\n", priv->nic_name);
  43997. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  43998. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &ability);
  43999. +
  44000. + if ((status & MII_GS_AUTONEG) && (!priv->aui)) {
  44001. + ability = status >> 11;
  44002. + if (priv->speed == TLAN_SPEED_10 &&
  44003. + priv->duplex == TLAN_DUPLEX_HALF) {
  44004. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x0000);
  44005. + } else if (priv->speed == TLAN_SPEED_10 &&
  44006. + priv->duplex == TLAN_DUPLEX_FULL) {
  44007. + priv->tlanFullDuplex = TRUE;
  44008. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x0100);
  44009. + } else if (priv->speed == TLAN_SPEED_100 &&
  44010. + priv->duplex == TLAN_DUPLEX_HALF) {
  44011. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x2000);
  44012. + } else if (priv->speed == TLAN_SPEED_100 &&
  44013. + priv->duplex == TLAN_DUPLEX_FULL) {
  44014. priv->tlanFullDuplex = TRUE;
  44015. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x2100);
  44016. } else {
  44017. - TLan_DioWrite8( dev->base_addr, TLAN_ACOMMIT, 0x08 );
  44018. +
  44019. + /* Set Auto-Neg advertisement */
  44020. + TLan_MiiWriteReg(nic, phy, MII_AN_ADV,
  44021. + (ability << 5) | 1);
  44022. + /* Enablee Auto-Neg */
  44023. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x1000);
  44024. + /* Restart Auto-Neg */
  44025. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x1200);
  44026. + /* Wait for 4 sec for autonegotiation
  44027. + * to complete. The max spec time is less than this
  44028. + * but the card need additional time to start AN.
  44029. + * .5 sec should be plenty extra.
  44030. + */
  44031. + printf("TLAN: %s: Starting autonegotiation.\n",
  44032. + priv->nic_name);
  44033. + mdelay(4000);
  44034. + TLan_PhyFinishAutoNeg(nic);
  44035. + /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_PHY_FINISH_AN ); */
  44036. + return;
  44037. }
  44038. - }
  44039. - if ( priv->phyNum == 0 ) {
  44040. - data |= TLAN_NET_CFG_PHY_EN;
  44041. }
  44042. - TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, (u16) data );
  44043. - if ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) {
  44044. - TLan_FinishReset( dev );
  44045. - } else {
  44046. - TLan_PhyPowerDown( dev );
  44047. + if ((priv->aui) && (priv->phyNum != 0)) {
  44048. + priv->phyNum = 0;
  44049. + data =
  44050. + TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN |
  44051. + TLAN_NET_CFG_PHY_EN;
  44052. + TLan_DioWrite16(BASE, TLAN_NET_CONFIG, data);
  44053. + mdelay(50);
  44054. + /* TLan_SetTimer( dev, (40*HZ/1000), TLAN_TIMER_PHY_PDOWN ); */
  44055. + TLan_PhyPowerDown(nic);
  44056. + return;
  44057. + } else if (priv->phyNum == 0) {
  44058. + control = 0;
  44059. + TLan_MiiReadReg(nic, phy, TLAN_TLPHY_CTL, &tctl);
  44060. + if (priv->aui) {
  44061. + tctl |= TLAN_TC_AUISEL;
  44062. + } else {
  44063. + tctl &= ~TLAN_TC_AUISEL;
  44064. + if (priv->duplex == TLAN_DUPLEX_FULL) {
  44065. + control |= MII_GC_DUPLEX;
  44066. + priv->tlanFullDuplex = TRUE;
  44067. + }
  44068. + if (priv->speed == TLAN_SPEED_100) {
  44069. + control |= MII_GC_SPEEDSEL;
  44070. + }
  44071. + }
  44072. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, control);
  44073. + TLan_MiiWriteReg(nic, phy, TLAN_TLPHY_CTL, tctl);
  44074. }
  44075. -} /* TLan_ResetAdapter */
  44076. + /* Wait for 2 sec to give the tranceiver time
  44077. + * to establish link.
  44078. + */
  44079. + /* TLan_SetTimer( dev, (4*HZ), TLAN_TIMER_FINISH_RESET ); */
  44080. + mdelay(2000);
  44081. + TLan_FinishReset(nic);
  44082. +
  44083. +} /* TLan_PhyStartLink */
  44084. -void
  44085. -TLan_FinishReset( struct net_device *dev )
  44086. +void TLan_PhyFinishAutoNeg(struct nic *nic)
  44087. {
  44088. - TLanPrivateInfo *priv = dev->priv;
  44089. - u8 data;
  44090. - u32 phy;
  44091. - u8 sio;
  44092. - u16 status;
  44093. - u16 partner;
  44094. - u16 tlphy_ctl;
  44095. - u16 tlphy_par;
  44096. - u16 tlphy_id1, tlphy_id2;
  44097. - int i;
  44098. +
  44099. + u16 an_adv;
  44100. + u16 an_lpa;
  44101. + u16 data;
  44102. + u16 mode;
  44103. + u16 phy;
  44104. + u16 status;
  44105. phy = priv->phy[priv->phyNum];
  44106. - data = TLAN_NET_CMD_NRESET | TLAN_NET_CMD_NWRAP;
  44107. - if ( priv->tlanFullDuplex ) {
  44108. - data |= TLAN_NET_CMD_DUPLEX;
  44109. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  44110. + udelay(1000);
  44111. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  44112. +
  44113. + if (!(status & MII_GS_AUTOCMPLT)) {
  44114. + /* Wait for 8 sec to give the process
  44115. + * more time. Perhaps we should fail after a while.
  44116. + */
  44117. + if (!priv->neg_be_verbose++) {
  44118. + printf
  44119. + ("TLAN: Giving autonegotiation more time.\n");
  44120. + printf
  44121. + ("TLAN: Please check that your adapter has\n");
  44122. + printf
  44123. + ("TLAN: been properly connected to a HUB or Switch.\n");
  44124. + printf
  44125. + ("TLAN: Trying to establish link in the background...\n");
  44126. + }
  44127. + mdelay(8000);
  44128. + TLan_PhyFinishAutoNeg(nic);
  44129. + /* TLan_SetTimer( dev, (8*HZ), TLAN_TIMER_PHY_FINISH_AN ); */
  44130. + return;
  44131. }
  44132. - TLan_DioWrite8( dev->base_addr, TLAN_NET_CMD, data );
  44133. - data = TLAN_NET_MASK_MASK4 | TLAN_NET_MASK_MASK5;
  44134. - if ( priv->phyNum == 0 ) {
  44135. - data |= TLAN_NET_MASK_MASK7;
  44136. - }
  44137. - TLan_DioWrite8( dev->base_addr, TLAN_NET_MASK, data );
  44138. - TLan_DioWrite16( dev->base_addr, TLAN_MAX_RX, ((1536)+7)&~7 );
  44139. - TLan_MiiReadReg( dev, phy, MII_GEN_ID_HI, &tlphy_id1 );
  44140. - TLan_MiiReadReg( dev, phy, MII_GEN_ID_LO, &tlphy_id2 );
  44141. -
  44142. - if ( ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) || ( priv->aui ) ) {
  44143. - status = MII_GS_LINK;
  44144. - printk( "TLAN: %s: Link forced.\n", dev->name );
  44145. - } else {
  44146. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status );
  44147. - udelay( 1000 );
  44148. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status );
  44149. - if ( (status & MII_GS_LINK) && /* We only support link info on Nat.Sem. PHY's */
  44150. - (tlphy_id1 == NAT_SEM_ID1) &&
  44151. - (tlphy_id2 == NAT_SEM_ID2) ) {
  44152. - TLan_MiiReadReg( dev, phy, MII_AN_LPA, &partner );
  44153. - TLan_MiiReadReg( dev, phy, TLAN_TLPHY_PAR, &tlphy_par );
  44154. -
  44155. - printk( "TLAN: %s: Link active with ", dev->name );
  44156. - if (!(tlphy_par & TLAN_PHY_AN_EN_STAT)) {
  44157. - printk( "forced 10%sMbps %s-Duplex\n",
  44158. - tlphy_par & TLAN_PHY_SPEED_100 ? "" : "0",
  44159. - tlphy_par & TLAN_PHY_DUPLEX_FULL ? "Full" : "Half");
  44160. - } else {
  44161. - printk( "AutoNegotiation enabled, at 10%sMbps %s-Duplex\n",
  44162. - tlphy_par & TLAN_PHY_SPEED_100 ? "" : "0",
  44163. - tlphy_par & TLAN_PHY_DUPLEX_FULL ? "Full" : "Half");
  44164. - printk("TLAN: Partner capability: ");
  44165. - for (i = 5; i <= 10; i++)
  44166. - if (partner & (1<<i))
  44167. - printk("%s", media[i-5]);
  44168. - printk("\n");
  44169. - }
  44170. - TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK );
  44171. -#ifdef MONITOR
  44172. - /* We have link beat..for now anyway */
  44173. - priv->link = 1;
  44174. - /*Enabling link beat monitoring */
  44175. - TLan_SetTimer( dev, (10*HZ), TLAN_TIMER_LINK_BEAT );
  44176. -#endif
  44177. - } else if (status & MII_GS_LINK) {
  44178. - printk( "TLAN: %s: Link active\n", dev->name );
  44179. - TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK );
  44180. - }
  44181. + printf("TLAN: %s: Autonegotiation complete.\n", priv->nic_name);
  44182. + TLan_MiiReadReg(nic, phy, MII_AN_ADV, &an_adv);
  44183. + TLan_MiiReadReg(nic, phy, MII_AN_LPA, &an_lpa);
  44184. + mode = an_adv & an_lpa & 0x03E0;
  44185. + if (mode & 0x0100) {
  44186. + printf("Full Duplex\n");
  44187. + priv->tlanFullDuplex = TRUE;
  44188. + } else if (!(mode & 0x0080) && (mode & 0x0040)) {
  44189. + priv->tlanFullDuplex = TRUE;
  44190. + printf("Full Duplex\n");
  44191. }
  44192. - if ( priv->phyNum == 0 ) {
  44193. - TLan_MiiReadReg( dev, phy, TLAN_TLPHY_CTL, &tlphy_ctl );
  44194. - tlphy_ctl |= TLAN_TC_INTEN;
  44195. - TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tlphy_ctl );
  44196. - sio = TLan_DioRead8( dev->base_addr, TLAN_NET_SIO );
  44197. - sio |= TLAN_NET_SIO_MINTEN;
  44198. - TLan_DioWrite8( dev->base_addr, TLAN_NET_SIO, sio );
  44199. + if ((!(mode & 0x0180))
  44200. + && (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_USE_INTERN_10)
  44201. + && (priv->phyNum != 0)) {
  44202. + priv->phyNum = 0;
  44203. + data =
  44204. + TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN |
  44205. + TLAN_NET_CFG_PHY_EN;
  44206. + TLan_DioWrite16(BASE, TLAN_NET_CONFIG, data);
  44207. + /* TLan_SetTimer( nic, (400*HZ/1000), TLAN_TIMER_PHY_PDOWN ); */
  44208. + mdelay(400);
  44209. + TLan_PhyPowerDown(nic);
  44210. + return;
  44211. }
  44212. - if ( status & MII_GS_LINK ) {
  44213. - TLan_SetMac( dev, 0, dev->dev_addr );
  44214. - priv->phyOnline = 1;
  44215. - outb( ( TLAN_HC_INT_ON >> 8 ), dev->base_addr + TLAN_HOST_CMD + 1 );
  44216. - if ( debug >= 1 && debug != TLAN_DEBUG_PROBE ) {
  44217. - outb( ( TLAN_HC_REQ_INT >> 8 ), dev->base_addr + TLAN_HOST_CMD + 1 );
  44218. + if (priv->phyNum == 0) {
  44219. + if ((priv->duplex == TLAN_DUPLEX_FULL)
  44220. + || (an_adv & an_lpa & 0x0040)) {
  44221. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
  44222. + MII_GC_AUTOENB | MII_GC_DUPLEX);
  44223. + printf
  44224. + ("TLAN: Starting internal PHY with FULL-DUPLEX\n");
  44225. + } else {
  44226. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
  44227. + MII_GC_AUTOENB);
  44228. + printf
  44229. + ("TLAN: Starting internal PHY with HALF-DUPLEX\n");
  44230. }
  44231. - outl( virt_to_bus( priv->rxList ), dev->base_addr + TLAN_CH_PARM );
  44232. - outl( TLAN_HC_GO | TLAN_HC_RT, dev->base_addr + TLAN_HOST_CMD );
  44233. - } else {
  44234. - printk( "TLAN: %s: Link inactive, will retry in 10 secs...\n", dev->name );
  44235. - TLan_SetTimer( dev, (10*HZ), TLAN_TIMER_FINISH_RESET );
  44236. - return;
  44237. }
  44238. -} /* TLan_FinishReset */
  44239. + /* Wait for 100 ms. No reason in partiticular.
  44240. + */
  44241. + /* TLan_SetTimer( dev, (HZ/10), TLAN_TIMER_FINISH_RESET ); */
  44242. + mdelay(100);
  44243. + TLan_FinishReset(nic);
  44244. - /***************************************************************
  44245. - * TLan_SetMac
  44246. - *
  44247. - * Returns:
  44248. - * Nothing
  44249. - * Parms:
  44250. - * dev Pointer to device structure of adapter
  44251. - * on which to change the AREG.
  44252. - * areg The AREG to set the address in (0 - 3).
  44253. - * mac A pointer to an array of chars. Each
  44254. - * element stores one byte of the address.
  44255. - * IE, it isn't in ascii.
  44256. - *
  44257. - * This function transfers a MAC address to one of the
  44258. - * TLAN AREGs (address registers). The TLAN chip locks
  44259. - * the register on writing to offset 0 and unlocks the
  44260. - * register after writing to offset 5. If NULL is passed
  44261. - * in mac, then the AREG is filled with 0's.
  44262. - *
  44263. - **************************************************************/
  44264. +} /* TLan_PhyFinishAutoNeg */
  44265. +
  44266. +#ifdef MONITOR
  44267. +
  44268. + /*********************************************************************
  44269. + *
  44270. + * TLan_phyMonitor
  44271. + *
  44272. + * Returns:
  44273. + * None
  44274. + *
  44275. + * Params:
  44276. + * dev The device structure of this device.
  44277. + *
  44278. + *
  44279. + * This function monitors PHY condition by reading the status
  44280. + * register via the MII bus. This can be used to give info
  44281. + * about link changes (up/down), and possible switch to alternate
  44282. + * media.
  44283. + *
  44284. + * ******************************************************************/
  44285. -void TLan_SetMac( struct net_device *dev, int areg, char *mac )
  44286. +void TLan_PhyMonitor(struct net_device *dev)
  44287. {
  44288. - int i;
  44289. -
  44290. - areg *= 6;
  44291. + TLanPrivateInfo *priv = dev->priv;
  44292. + u16 phy;
  44293. + u16 phy_status;
  44294. - if ( mac != NULL ) {
  44295. - for ( i = 0; i < 6; i++ )
  44296. - TLan_DioWrite8( dev->base_addr, TLAN_AREG_0 + areg + i, mac[i] );
  44297. - } else {
  44298. - for ( i = 0; i < 6; i++ )
  44299. - TLan_DioWrite8( dev->base_addr, TLAN_AREG_0 + areg + i, 0 );
  44300. + phy = priv->phy[priv->phyNum];
  44301. +
  44302. + /* Get PHY status register */
  44303. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &phy_status);
  44304. +
  44305. + /* Check if link has been lost */
  44306. + if (!(phy_status & MII_GS_LINK)) {
  44307. + if (priv->link) {
  44308. + priv->link = 0;
  44309. + printf("TLAN: %s has lost link\n", priv->nic_name);
  44310. + priv->flags &= ~IFF_RUNNING;
  44311. + mdelay(2000);
  44312. + TLan_PhyMonitor(nic);
  44313. + /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT ); */
  44314. + return;
  44315. + }
  44316. }
  44317. -} /* TLan_SetMac */
  44318. + /* Link restablished? */
  44319. + if ((phy_status & MII_GS_LINK) && !priv->link) {
  44320. + priv->link = 1;
  44321. + printf("TLAN: %s has reestablished link\n",
  44322. + priv->nic_name);
  44323. + priv->flags |= IFF_RUNNING;
  44324. + }
  44325. +
  44326. + /* Setup a new monitor */
  44327. + /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT ); */
  44328. + mdelay(2000);
  44329. + TLan_PhyMonitor(nic);
  44330. +}
  44331. +#endif /* MONITOR */
  44332. +
  44333. +#ifdef EB51
  44334. +static struct pci_id tlan_nics[] = {
  44335. + PCI_ROM(0x0e11, 0xae34, "netel10", "Compaq Netelligent 10 T PCI UTP"),
  44336. + PCI_ROM(0x0e11, 0xae32, "netel100","Compaq Netelligent 10/100 TX PCI UTP"),
  44337. + PCI_ROM(0x0e11, 0xae35, "netflex3i", "Compaq Integrated NetFlex-3/P"),
  44338. + PCI_ROM(0x0e11, 0xf130, "thunder", "Compaq NetFlex-3/P"),
  44339. + PCI_ROM(0x0e11, 0xf150, "netflex3b", "Compaq NetFlex-3/P"),
  44340. + PCI_ROM(0x0e11, 0xae43, "netel100pi", "Compaq Netelligent Integrated 10/100 TX UTP"),
  44341. + PCI_ROM(0x0e11, 0xae40, "netel100d", "Compaq Netelligent Dual 10/100 TX PCI UTP"),
  44342. + PCI_ROM(0x0e11, 0xb011, "netel100i", "Compaq Netelligent 10/100 TX Embedded UTP"),
  44343. + PCI_ROM(0x108d, 0x0013, "oc2183", "Olicom OC-2183/2185"),
  44344. + PCI_ROM(0x108d, 0x0012, "oc2325", "Olicom OC-2325"),
  44345. + PCI_ROM(0x108d, 0x0014, "oc2326", "Olicom OC-2326"),
  44346. + PCI_ROM(0x0e11, 0xb030, "netelligent_10_100_ws_5100", "Compaq Netelligent 10/100 TX UTP"),
  44347. + PCI_ROM(0x0e11, 0xb012, "netelligent_10_t2", "Compaq Netelligent 10 T/2 PCI UTP/Coax"),
  44348. +};
  44349. +
  44350. +struct pci_driver tlan_driver = {
  44351. + .type = NIC_DRIVER,
  44352. + .name = "TLAN/PCI",
  44353. + .probe = tlan_probe,
  44354. + .ids = tlan_nics,
  44355. + .id_count = sizeof(tlan_nics) / sizeof(tlan_nics[0]),
  44356. + .class = 0,
  44357. +};
  44358. #endif
  44359. Index: b/netboot/tlan.h
  44360. ===================================================================
  44361. --- /dev/null
  44362. +++ b/netboot/tlan.h
  44363. @@ -0,0 +1,536 @@
  44364. +/**************************************************************************
  44365. +*
  44366. +* tlan.c -- Etherboot device driver for the Texas Instruments ThunderLAN
  44367. +* Written 2003-2003 by Timothy Legge <tlegge@rogers.com>
  44368. +*
  44369. +* This program is free software; you can redistribute it and/or modify
  44370. +* it under the terms of the GNU General Public License as published by
  44371. +* the Free Software Foundation; either version 2 of the License, or
  44372. +* (at your option) any later version.
  44373. +*
  44374. +* This program is distributed in the hope that it will be useful,
  44375. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  44376. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  44377. +* GNU General Public License for more details.
  44378. +*
  44379. +* You should have received a copy of the GNU General Public License
  44380. +* along with this program; if not, write to the Free Software
  44381. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  44382. +*
  44383. +* Portions of this code (almost all) based on:
  44384. +* tlan.c: Linux ThunderLan Driver:
  44385. +*
  44386. +* by James Banks
  44387. +*
  44388. +* (C) 1997-1998 Caldera, Inc.
  44389. +* (C) 1998 James Banks
  44390. +* (C) 1999-2001 Torben Mathiasen
  44391. +* (C) 2002 Samuel Chessman
  44392. +*
  44393. +* REVISION HISTORY:
  44394. +* ================
  44395. +* v1.0 07-08-2003 timlegge Initial not quite working version
  44396. +*
  44397. +* Indent Style: indent -kr -i8
  44398. +***************************************************************************/
  44399. +
  44400. +/*
  44401. +#include <asm/io.h>
  44402. +#include <asm/types.h>
  44403. +#include <linux/netdevice.h>
  44404. +*/
  44405. +
  44406. +typedef unsigned char u8;
  44407. +typedef signed char s8;
  44408. +typedef unsigned short u16;
  44409. +typedef signed short s16;
  44410. +typedef unsigned int u32;
  44411. +typedef signed int s32;
  44412. + /*****************************************************************
  44413. + * TLan Definitions
  44414. + *
  44415. + ****************************************************************/
  44416. +
  44417. +#define FALSE 0
  44418. +#define TRUE 1
  44419. +
  44420. +#define TLAN_MIN_FRAME_SIZE 64
  44421. +#define TLAN_MAX_FRAME_SIZE 1600
  44422. +
  44423. +#define TLAN_NUM_RX_LISTS 4
  44424. +#define TLAN_NUM_TX_LISTS 2
  44425. +
  44426. +#define TLAN_IGNORE 0
  44427. +#define TLAN_RECORD 1
  44428. +/*
  44429. +#define TLAN_DBG(lvl, format, args...) if (debug&lvl) printf("TLAN: " format, ##args );
  44430. +*/
  44431. +#define TLAN_DEBUG_GNRL 0x0001
  44432. +#define TLAN_DEBUG_TX 0x0002
  44433. +#define TLAN_DEBUG_RX 0x0004
  44434. +#define TLAN_DEBUG_LIST 0x0008
  44435. +#define TLAN_DEBUG_PROBE 0x0010
  44436. +
  44437. +#define TX_TIMEOUT (10*HZ) /* We need time for auto-neg */
  44438. +#define MAX_TLAN_BOARDS 8 /* Max number of boards installed at a time */
  44439. +
  44440. +
  44441. + /*****************************************************************
  44442. + * Device Identification Definitions
  44443. + *
  44444. + ****************************************************************/
  44445. +
  44446. +#define PCI_DEVICE_ID_NETELLIGENT_10_T2 0xB012
  44447. +#define PCI_DEVICE_ID_NETELLIGENT_10_100_WS_5100 0xB030
  44448. +#ifndef PCI_DEVICE_ID_OLICOM_OC2183
  44449. +#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
  44450. +#endif
  44451. +#ifndef PCI_DEVICE_ID_OLICOM_OC2325
  44452. +#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
  44453. +#endif
  44454. +#ifndef PCI_DEVICE_ID_OLICOM_OC2326
  44455. +#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
  44456. +#endif
  44457. +
  44458. +typedef struct tlan_adapter_entry {
  44459. + u16 vendorId;
  44460. + u16 deviceId;
  44461. + char *deviceLabel;
  44462. + u32 flags;
  44463. + u16 addrOfs;
  44464. +} TLanAdapterEntry;
  44465. +
  44466. +#define TLAN_ADAPTER_NONE 0x00000000
  44467. +#define TLAN_ADAPTER_UNMANAGED_PHY 0x00000001
  44468. +#define TLAN_ADAPTER_BIT_RATE_PHY 0x00000002
  44469. +#define TLAN_ADAPTER_USE_INTERN_10 0x00000004
  44470. +#define TLAN_ADAPTER_ACTIVITY_LED 0x00000008
  44471. +
  44472. +#define TLAN_SPEED_DEFAULT 0
  44473. +#define TLAN_SPEED_10 10
  44474. +#define TLAN_SPEED_100 100
  44475. +
  44476. +#define TLAN_DUPLEX_DEFAULT 0
  44477. +#define TLAN_DUPLEX_HALF 1
  44478. +#define TLAN_DUPLEX_FULL 2
  44479. +
  44480. +
  44481. +
  44482. + /*****************************************************************
  44483. + * EISA Definitions
  44484. + *
  44485. + ****************************************************************/
  44486. +
  44487. +#define EISA_ID 0xc80 /* EISA ID Registers */
  44488. +#define EISA_ID0 0xc80 /* EISA ID Register 0 */
  44489. +#define EISA_ID1 0xc81 /* EISA ID Register 1 */
  44490. +#define EISA_ID2 0xc82 /* EISA ID Register 2 */
  44491. +#define EISA_ID3 0xc83 /* EISA ID Register 3 */
  44492. +#define EISA_CR 0xc84 /* EISA Control Register */
  44493. +#define EISA_REG0 0xc88 /* EISA Configuration Register 0 */
  44494. +#define EISA_REG1 0xc89 /* EISA Configuration Register 1 */
  44495. +#define EISA_REG2 0xc8a /* EISA Configuration Register 2 */
  44496. +#define EISA_REG3 0xc8f /* EISA Configuration Register 3 */
  44497. +#define EISA_APROM 0xc90 /* Ethernet Address PROM */
  44498. +
  44499. +
  44500. +
  44501. + /*****************************************************************
  44502. + * Rx/Tx List Definitions
  44503. + *
  44504. + ****************************************************************/
  44505. +
  44506. +#define TLAN_BUFFERS_PER_LIST 10
  44507. +#define TLAN_LAST_BUFFER 0x80000000
  44508. +#define TLAN_CSTAT_UNUSED 0x8000
  44509. +#define TLAN_CSTAT_FRM_CMP 0x4000
  44510. +#define TLAN_CSTAT_READY 0x3000
  44511. +#define TLAN_CSTAT_EOC 0x0800
  44512. +#define TLAN_CSTAT_RX_ERROR 0x0400
  44513. +#define TLAN_CSTAT_PASS_CRC 0x0200
  44514. +#define TLAN_CSTAT_DP_PR 0x0100
  44515. +
  44516. +
  44517. +
  44518. +
  44519. +
  44520. +
  44521. + /*****************************************************************
  44522. + * PHY definitions
  44523. + *
  44524. + ****************************************************************/
  44525. +
  44526. +#define TLAN_PHY_MAX_ADDR 0x1F
  44527. +#define TLAN_PHY_NONE 0x20
  44528. +
  44529. +
  44530. +
  44531. + /*****************************************************************
  44532. + * TLan Driver Timer Definitions
  44533. + *
  44534. + ****************************************************************/
  44535. +
  44536. +#define TLAN_TIMER_LINK_BEAT 1
  44537. +#define TLAN_TIMER_ACTIVITY 2
  44538. +#define TLAN_TIMER_PHY_PDOWN 3
  44539. +#define TLAN_TIMER_PHY_PUP 4
  44540. +#define TLAN_TIMER_PHY_RESET 5
  44541. +#define TLAN_TIMER_PHY_START_LINK 6
  44542. +#define TLAN_TIMER_PHY_FINISH_AN 7
  44543. +#define TLAN_TIMER_FINISH_RESET 8
  44544. +
  44545. +#define TLAN_TIMER_ACT_DELAY (HZ/10)
  44546. +
  44547. +
  44548. +
  44549. +
  44550. + /*****************************************************************
  44551. + * TLan Driver Eeprom Definitions
  44552. + *
  44553. + ****************************************************************/
  44554. +
  44555. +#define TLAN_EEPROM_ACK 0
  44556. +#define TLAN_EEPROM_STOP 1
  44557. +
  44558. +
  44559. +
  44560. +
  44561. + /*****************************************************************
  44562. + * Host Register Offsets and Contents
  44563. + *
  44564. + ****************************************************************/
  44565. +
  44566. +#define TLAN_HOST_CMD 0x00
  44567. +#define TLAN_HC_GO 0x80000000
  44568. +#define TLAN_HC_STOP 0x40000000
  44569. +#define TLAN_HC_ACK 0x20000000
  44570. +#define TLAN_HC_CS_MASK 0x1FE00000
  44571. +#define TLAN_HC_EOC 0x00100000
  44572. +#define TLAN_HC_RT 0x00080000
  44573. +#define TLAN_HC_NES 0x00040000
  44574. +#define TLAN_HC_AD_RST 0x00008000
  44575. +#define TLAN_HC_LD_TMR 0x00004000
  44576. +#define TLAN_HC_LD_THR 0x00002000
  44577. +#define TLAN_HC_REQ_INT 0x00001000
  44578. +#define TLAN_HC_INT_OFF 0x00000800
  44579. +#define TLAN_HC_INT_ON 0x00000400
  44580. +#define TLAN_HC_AC_MASK 0x000000FF
  44581. +#define TLAN_CH_PARM 0x04
  44582. +#define TLAN_DIO_ADR 0x08
  44583. +#define TLAN_DA_ADR_INC 0x8000
  44584. +#define TLAN_DA_RAM_ADR 0x4000
  44585. +#define TLAN_HOST_INT 0x0A
  44586. +#define TLAN_HI_IV_MASK 0x1FE0
  44587. +#define TLAN_HI_IT_MASK 0x001C
  44588. +#define TLAN_DIO_DATA 0x0C
  44589. +
  44590. +
  44591. +/* ThunderLAN Internal Register DIO Offsets */
  44592. +
  44593. +#define TLAN_NET_CMD 0x00
  44594. +#define TLAN_NET_CMD_NRESET 0x80
  44595. +#define TLAN_NET_CMD_NWRAP 0x40
  44596. +#define TLAN_NET_CMD_CSF 0x20
  44597. +#define TLAN_NET_CMD_CAF 0x10
  44598. +#define TLAN_NET_CMD_NOBRX 0x08
  44599. +#define TLAN_NET_CMD_DUPLEX 0x04
  44600. +#define TLAN_NET_CMD_TRFRAM 0x02
  44601. +#define TLAN_NET_CMD_TXPACE 0x01
  44602. +#define TLAN_NET_SIO 0x01
  44603. +#define TLAN_NET_SIO_MINTEN 0x80
  44604. +#define TLAN_NET_SIO_ECLOK 0x40
  44605. +#define TLAN_NET_SIO_ETXEN 0x20
  44606. +#define TLAN_NET_SIO_EDATA 0x10
  44607. +#define TLAN_NET_SIO_NMRST 0x08
  44608. +#define TLAN_NET_SIO_MCLK 0x04
  44609. +#define TLAN_NET_SIO_MTXEN 0x02
  44610. +#define TLAN_NET_SIO_MDATA 0x01
  44611. +#define TLAN_NET_STS 0x02
  44612. +#define TLAN_NET_STS_MIRQ 0x80
  44613. +#define TLAN_NET_STS_HBEAT 0x40
  44614. +#define TLAN_NET_STS_TXSTOP 0x20
  44615. +#define TLAN_NET_STS_RXSTOP 0x10
  44616. +#define TLAN_NET_STS_RSRVD 0x0F
  44617. +#define TLAN_NET_MASK 0x03
  44618. +#define TLAN_NET_MASK_MASK7 0x80
  44619. +#define TLAN_NET_MASK_MASK6 0x40
  44620. +#define TLAN_NET_MASK_MASK5 0x20
  44621. +#define TLAN_NET_MASK_MASK4 0x10
  44622. +#define TLAN_NET_MASK_RSRVD 0x0F
  44623. +#define TLAN_NET_CONFIG 0x04
  44624. +#define TLAN_NET_CFG_RCLK 0x8000
  44625. +#define TLAN_NET_CFG_TCLK 0x4000
  44626. +#define TLAN_NET_CFG_BIT 0x2000
  44627. +#define TLAN_NET_CFG_RXCRC 0x1000
  44628. +#define TLAN_NET_CFG_PEF 0x0800
  44629. +#define TLAN_NET_CFG_1FRAG 0x0400
  44630. +#define TLAN_NET_CFG_1CHAN 0x0200
  44631. +#define TLAN_NET_CFG_MTEST 0x0100
  44632. +#define TLAN_NET_CFG_PHY_EN 0x0080
  44633. +#define TLAN_NET_CFG_MSMASK 0x007F
  44634. +#define TLAN_MAN_TEST 0x06
  44635. +#define TLAN_DEF_VENDOR_ID 0x08
  44636. +#define TLAN_DEF_DEVICE_ID 0x0A
  44637. +#define TLAN_DEF_REVISION 0x0C
  44638. +#define TLAN_DEF_SUBCLASS 0x0D
  44639. +#define TLAN_DEF_MIN_LAT 0x0E
  44640. +#define TLAN_DEF_MAX_LAT 0x0F
  44641. +#define TLAN_AREG_0 0x10
  44642. +#define TLAN_AREG_1 0x16
  44643. +#define TLAN_AREG_2 0x1C
  44644. +#define TLAN_AREG_3 0x22
  44645. +#define TLAN_HASH_1 0x28
  44646. +#define TLAN_HASH_2 0x2C
  44647. +#define TLAN_GOOD_TX_FRMS 0x30
  44648. +#define TLAN_TX_UNDERUNS 0x33
  44649. +#define TLAN_GOOD_RX_FRMS 0x34
  44650. +#define TLAN_RX_OVERRUNS 0x37
  44651. +#define TLAN_DEFERRED_TX 0x38
  44652. +#define TLAN_CRC_ERRORS 0x3A
  44653. +#define TLAN_CODE_ERRORS 0x3B
  44654. +#define TLAN_MULTICOL_FRMS 0x3C
  44655. +#define TLAN_SINGLECOL_FRMS 0x3E
  44656. +#define TLAN_EXCESSCOL_FRMS 0x40
  44657. +#define TLAN_LATE_COLS 0x41
  44658. +#define TLAN_CARRIER_LOSS 0x42
  44659. +#define TLAN_ACOMMIT 0x43
  44660. +#define TLAN_LED_REG 0x44
  44661. +#define TLAN_LED_ACT 0x10
  44662. +#define TLAN_LED_LINK 0x01
  44663. +#define TLAN_BSIZE_REG 0x45
  44664. +#define TLAN_MAX_RX 0x46
  44665. +#define TLAN_INT_DIS 0x48
  44666. +#define TLAN_ID_TX_EOC 0x04
  44667. +#define TLAN_ID_RX_EOF 0x02
  44668. +#define TLAN_ID_RX_EOC 0x01
  44669. +
  44670. +
  44671. +
  44672. +/* ThunderLAN Interrupt Codes */
  44673. +
  44674. +#define TLAN_INT_NUMBER_OF_INTS 8
  44675. +
  44676. +#define TLAN_INT_NONE 0x0000
  44677. +#define TLAN_INT_TX_EOF 0x0001
  44678. +#define TLAN_INT_STAT_OVERFLOW 0x0002
  44679. +#define TLAN_INT_RX_EOF 0x0003
  44680. +#define TLAN_INT_DUMMY 0x0004
  44681. +#define TLAN_INT_TX_EOC 0x0005
  44682. +#define TLAN_INT_STATUS_CHECK 0x0006
  44683. +#define TLAN_INT_RX_EOC 0x0007
  44684. +
  44685. +
  44686. +
  44687. +/* ThunderLAN MII Registers */
  44688. +
  44689. +/* Generic MII/PHY Registers */
  44690. +
  44691. +#define MII_GEN_CTL 0x00
  44692. +#define MII_GC_RESET 0x8000
  44693. +#define MII_GC_LOOPBK 0x4000
  44694. +#define MII_GC_SPEEDSEL 0x2000
  44695. +#define MII_GC_AUTOENB 0x1000
  44696. +#define MII_GC_PDOWN 0x0800
  44697. +#define MII_GC_ISOLATE 0x0400
  44698. +#define MII_GC_AUTORSRT 0x0200
  44699. +#define MII_GC_DUPLEX 0x0100
  44700. +#define MII_GC_COLTEST 0x0080
  44701. +#define MII_GC_RESERVED 0x007F
  44702. +#define MII_GEN_STS 0x01
  44703. +#define MII_GS_100BT4 0x8000
  44704. +#define MII_GS_100BTXFD 0x4000
  44705. +#define MII_GS_100BTXHD 0x2000
  44706. +#define MII_GS_10BTFD 0x1000
  44707. +#define MII_GS_10BTHD 0x0800
  44708. +#define MII_GS_RESERVED 0x07C0
  44709. +#define MII_GS_AUTOCMPLT 0x0020
  44710. +#define MII_GS_RFLT 0x0010
  44711. +#define MII_GS_AUTONEG 0x0008
  44712. +#define MII_GS_LINK 0x0004
  44713. +#define MII_GS_JABBER 0x0002
  44714. +#define MII_GS_EXTCAP 0x0001
  44715. +#define MII_GEN_ID_HI 0x02
  44716. +#define MII_GEN_ID_LO 0x03
  44717. +#define MII_GIL_OUI 0xFC00
  44718. +#define MII_GIL_MODEL 0x03F0
  44719. +#define MII_GIL_REVISION 0x000F
  44720. +#define MII_AN_ADV 0x04
  44721. +#define MII_AN_LPA 0x05
  44722. +#define MII_AN_EXP 0x06
  44723. +
  44724. +/* ThunderLAN Specific MII/PHY Registers */
  44725. +
  44726. +#define TLAN_TLPHY_ID 0x10
  44727. +#define TLAN_TLPHY_CTL 0x11
  44728. +#define TLAN_TC_IGLINK 0x8000
  44729. +#define TLAN_TC_SWAPOL 0x4000
  44730. +#define TLAN_TC_AUISEL 0x2000
  44731. +#define TLAN_TC_SQEEN 0x1000
  44732. +#define TLAN_TC_MTEST 0x0800
  44733. +#define TLAN_TC_RESERVED 0x07F8
  44734. +#define TLAN_TC_NFEW 0x0004
  44735. +#define TLAN_TC_INTEN 0x0002
  44736. +#define TLAN_TC_TINT 0x0001
  44737. +#define TLAN_TLPHY_STS 0x12
  44738. +#define TLAN_TS_MINT 0x8000
  44739. +#define TLAN_TS_PHOK 0x4000
  44740. +#define TLAN_TS_POLOK 0x2000
  44741. +#define TLAN_TS_TPENERGY 0x1000
  44742. +#define TLAN_TS_RESERVED 0x0FFF
  44743. +#define TLAN_TLPHY_PAR 0x19
  44744. +#define TLAN_PHY_CIM_STAT 0x0020
  44745. +#define TLAN_PHY_SPEED_100 0x0040
  44746. +#define TLAN_PHY_DUPLEX_FULL 0x0080
  44747. +#define TLAN_PHY_AN_EN_STAT 0x0400
  44748. +
  44749. +/* National Sem. & Level1 PHY id's */
  44750. +#define NAT_SEM_ID1 0x2000
  44751. +#define NAT_SEM_ID2 0x5C01
  44752. +#define LEVEL1_ID1 0x7810
  44753. +#define LEVEL1_ID2 0x0000
  44754. +
  44755. +#define CIRC_INC( a, b ) if ( ++a >= b ) a = 0
  44756. +
  44757. +/* Routines to access internal registers. */
  44758. +
  44759. +inline u8 TLan_DioRead8(u16 base_addr, u16 internal_addr)
  44760. +{
  44761. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  44762. + return (inb((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x3)));
  44763. +
  44764. +} /* TLan_DioRead8 */
  44765. +
  44766. +
  44767. +
  44768. +
  44769. +inline u16 TLan_DioRead16(u16 base_addr, u16 internal_addr)
  44770. +{
  44771. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  44772. + return (inw((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x2)));
  44773. +
  44774. +} /* TLan_DioRead16 */
  44775. +
  44776. +
  44777. +
  44778. +
  44779. +inline u32 TLan_DioRead32(u16 base_addr, u16 internal_addr)
  44780. +{
  44781. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  44782. + return (inl(base_addr + TLAN_DIO_DATA));
  44783. +
  44784. +} /* TLan_DioRead32 */
  44785. +
  44786. +
  44787. +
  44788. +
  44789. +inline void TLan_DioWrite8(u16 base_addr, u16 internal_addr, u8 data)
  44790. +{
  44791. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  44792. + outb(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x3));
  44793. +
  44794. +}
  44795. +
  44796. +
  44797. +
  44798. +
  44799. +inline void TLan_DioWrite16(u16 base_addr, u16 internal_addr, u16 data)
  44800. +{
  44801. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  44802. + outw(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
  44803. +
  44804. +}
  44805. +
  44806. +
  44807. +
  44808. +
  44809. +inline void TLan_DioWrite32(u16 base_addr, u16 internal_addr, u32 data)
  44810. +{
  44811. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  44812. + outl(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
  44813. +
  44814. +}
  44815. +
  44816. +
  44817. +
  44818. +#if 0
  44819. +inline void TLan_ClearBit(u8 bit, u16 port)
  44820. +{
  44821. + outb_p(inb_p(port) & ~bit, port);
  44822. +}
  44823. +
  44824. +
  44825. +
  44826. +
  44827. +inline int TLan_GetBit(u8 bit, u16 port)
  44828. +{
  44829. + return ((int) (inb_p(port) & bit));
  44830. +}
  44831. +
  44832. +
  44833. +
  44834. +
  44835. +inline void TLan_SetBit(u8 bit, u16 port)
  44836. +{
  44837. + outb_p(inb_p(port) | bit, port);
  44838. +}
  44839. +#endif
  44840. +
  44841. +#define TLan_ClearBit( bit, port ) outb_p(inb_p(port) & ~bit, port)
  44842. +#define TLan_GetBit( bit, port ) ((int) (inb_p(port) & bit))
  44843. +#define TLan_SetBit( bit, port ) outb_p(inb_p(port) | bit, port)
  44844. +
  44845. +#ifdef I_LIKE_A_FAST_HASH_FUNCTION
  44846. +/* given 6 bytes, view them as 8 6-bit numbers and return the XOR of those */
  44847. +/* the code below is about seven times as fast as the original code */
  44848. +inline u32 TLan_HashFunc(u8 * a)
  44849. +{
  44850. + u8 hash;
  44851. +
  44852. + hash = (a[0] ^ a[3]); /* & 077 */
  44853. + hash ^= ((a[0] ^ a[3]) >> 6); /* & 003 */
  44854. + hash ^= ((a[1] ^ a[4]) << 2); /* & 074 */
  44855. + hash ^= ((a[1] ^ a[4]) >> 4); /* & 017 */
  44856. + hash ^= ((a[2] ^ a[5]) << 4); /* & 060 */
  44857. + hash ^= ((a[2] ^ a[5]) >> 2); /* & 077 */
  44858. +
  44859. + return (hash & 077);
  44860. +}
  44861. +
  44862. +#else /* original code */
  44863. +
  44864. +inline u32 xor(u32 a, u32 b)
  44865. +{
  44866. + return ((a && !b) || (!a && b));
  44867. +}
  44868. +
  44869. +#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 ) ) ) ) ) ) )
  44870. +#define DA( a, bit ) ( ( (u8) a[bit/8] ) & ( (u8) ( 1 << bit%8 ) ) )
  44871. +
  44872. +inline u32 TLan_HashFunc(u8 * a)
  44873. +{
  44874. + u32 hash;
  44875. +
  44876. + hash =
  44877. + XOR8(DA(a, 0), DA(a, 6), DA(a, 12), DA(a, 18), DA(a, 24),
  44878. + DA(a, 30), DA(a, 36), DA(a, 42));
  44879. + hash |=
  44880. + XOR8(DA(a, 1), DA(a, 7), DA(a, 13), DA(a, 19), DA(a, 25),
  44881. + DA(a, 31), DA(a, 37), DA(a, 43)) << 1;
  44882. + hash |=
  44883. + XOR8(DA(a, 2), DA(a, 8), DA(a, 14), DA(a, 20), DA(a, 26),
  44884. + DA(a, 32), DA(a, 38), DA(a, 44)) << 2;
  44885. + hash |=
  44886. + XOR8(DA(a, 3), DA(a, 9), DA(a, 15), DA(a, 21), DA(a, 27),
  44887. + DA(a, 33), DA(a, 39), DA(a, 45)) << 3;
  44888. + hash |=
  44889. + XOR8(DA(a, 4), DA(a, 10), DA(a, 16), DA(a, 22), DA(a, 28),
  44890. + DA(a, 34), DA(a, 40), DA(a, 46)) << 4;
  44891. + hash |=
  44892. + XOR8(DA(a, 5), DA(a, 11), DA(a, 17), DA(a, 23), DA(a, 29),
  44893. + DA(a, 35), DA(a, 41), DA(a, 47)) << 5;
  44894. +
  44895. + return hash;
  44896. +
  44897. +}
  44898. +
  44899. +#endif /* I_LIKE_A_FAST_HASH_FUNCTION */
  44900. Index: b/netboot/tulip.c
  44901. ===================================================================
  44902. --- a/netboot/tulip.c
  44903. +++ b/netboot/tulip.c
  44904. @@ -48,6 +48,7 @@
  44905. /*********************************************************************/
  44906. /*
  44907. + 07 Sep 2003 timlegge Multicast Support Added
  44908. 11 Apr 2001 mdc [patch to etherboot 4.7.24]
  44909. Major rewrite to include Linux tulip driver media detection
  44910. code. This driver should support a lot more cards now.
  44911. @@ -98,7 +99,6 @@
  44912. and thinguin mailing lists.
  44913. */
  44914. -
  44915. /*********************************************************************/
  44916. /* Declarations */
  44917. /*********************************************************************/
  44918. @@ -106,31 +106,29 @@
  44919. #include "etherboot.h"
  44920. #include "nic.h"
  44921. #include "pci.h"
  44922. -#include "cards.h"
  44923. /* User settable parameters */
  44924. -#undef TULIP_DEBUG
  44925. -#undef TULIP_DEBUG_WHERE
  44926. +#undef TULIP_DEBUG
  44927. +#undef TULIP_DEBUG_WHERE
  44928. +#ifdef TULIP_DEBUG
  44929. static int tulip_debug = 2; /* 1 normal messages, 0 quiet .. 7 verbose. */
  44930. +#endif
  44931. #define TX_TIME_OUT 2*TICKS_PER_SEC
  44932. -typedef unsigned char u8;
  44933. -typedef signed char s8;
  44934. -typedef unsigned short u16;
  44935. -typedef signed short s16;
  44936. -typedef unsigned int u32;
  44937. -typedef signed int s32;
  44938. +typedef uint8_t u8;
  44939. +typedef int8_t s8;
  44940. +typedef uint16_t u16;
  44941. +typedef int16_t s16;
  44942. +typedef uint32_t u32;
  44943. +typedef int32_t s32;
  44944. /* helpful macros if on a big_endian machine for changing byte order.
  44945. not strictly needed on Intel */
  44946. -#define le16_to_cpu(val) (val)
  44947. -#define cpu_to_le32(val) (val)
  44948. #define get_unaligned(ptr) (*(ptr))
  44949. #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
  44950. #define get_u16(ptr) (*(u16 *)(ptr))
  44951. -#define virt_to_bus(x) ((unsigned long)x)
  44952. #define virt_to_le32desc(addr) virt_to_bus(addr)
  44953. #define TULIP_IOTYPE PCI_USES_MASTER | PCI_USES_IO | PCI_ADDR0
  44954. @@ -212,6 +210,8 @@
  44955. TULIP_IOTYPE, 256, PNIC2 },
  44956. { "ADMtek AN981 Comet", { 0x09811317, 0xffffffff, 0, 0, 0, 0 },
  44957. TULIP_IOTYPE, 256, COMET },
  44958. + { "ADMTek AN983 Comet", { 0x12161113, 0xffffffff, 0, 0, 0, 0 },
  44959. + TULIP_IOTYPE, 256, COMET },
  44960. { "ADMtek Centaur-P", { 0x09851317, 0xffffffff, 0, 0, 0, 0 },
  44961. TULIP_IOTYPE, 256, COMET },
  44962. { "ADMtek Centaur-C", { 0x19851317, 0xffffffff, 0, 0, 0, 0 },
  44963. @@ -280,9 +280,13 @@
  44964. static u16 t21041_csr14[] = { 0xFFFF, 0xF7FD, 0xF7FD, 0x7F3F, 0x7F3D, };
  44965. static u16 t21041_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
  44966. +/* not used
  44967. static u16 t21142_csr13[] = { 0x0001, 0x0009, 0x0009, 0x0000, 0x0001, };
  44968. +*/
  44969. static u16 t21142_csr14[] = { 0xFFFF, 0x0705, 0x0705, 0x0000, 0x7F3D, };
  44970. +/* not used
  44971. static u16 t21142_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
  44972. +*/
  44973. /* Offsets to the Command and Status Registers, "CSRs". All accesses
  44974. must be longword instructions and quadword aligned. */
  44975. @@ -300,6 +304,14 @@
  44976. TxFIFOUnderflow=0x20, TxJabber=0x08, TxNoBuf=0x04, TxDied=0x02, TxIntr=0x01,
  44977. };
  44978. +/* The configuration bits in CSR6. */
  44979. +enum csr6_mode_bits {
  44980. + TxOn=0x2000, RxOn=0x0002, FullDuplex=0x0200,
  44981. + AcceptBroadcast=0x0100, AcceptAllMulticast=0x0080,
  44982. + AcceptAllPhys=0x0040, AcceptRunt=0x0008,
  44983. +};
  44984. +
  44985. +
  44986. enum desc_status_bits {
  44987. DescOwnded=0x80000000, RxDescFatalErr=0x8000, RxWholePkt=0x0300,
  44988. };
  44989. @@ -384,21 +396,11 @@
  44990. #define TX_RING_SIZE 2
  44991. static struct tulip_tx_desc tx_ring[TX_RING_SIZE] __attribute__ ((aligned(4)));
  44992. -
  44993. -#ifdef USE_LOWMEM_BUFFER
  44994. -#define txb ((char *)0x10000 - BUFLEN)
  44995. -#else
  44996. static unsigned char txb[BUFLEN] __attribute__ ((aligned(4)));
  44997. -#endif
  44998. #define RX_RING_SIZE 4
  44999. static struct tulip_rx_desc rx_ring[RX_RING_SIZE] __attribute__ ((aligned(4)));
  45000. -
  45001. -#ifdef USE_LOWMEM_BUFFER
  45002. -#define rxb ((char *)0x10000 - RX_RING_SIZE * BUFLEN - BUFLEN)
  45003. -#else
  45004. static unsigned char rxb[RX_RING_SIZE * BUFLEN] __attribute__ ((aligned(4)));
  45005. -#endif
  45006. static struct tulip_private {
  45007. int cur_rx;
  45008. @@ -471,7 +473,6 @@
  45009. static const char * block_name[] = {"21140 non-MII", "21140 MII PHY",
  45010. "21142 Serial PHY", "21142 MII PHY", "21143 SYM PHY", "21143 reset method"};
  45011. -
  45012. /*********************************************************************/
  45013. /* Function Prototypes */
  45014. /*********************************************************************/
  45015. @@ -479,14 +480,13 @@
  45016. static void mdio_write(struct nic *nic, int phy_id, int location, int value);
  45017. static int read_eeprom(unsigned long ioaddr, int location, int addr_len);
  45018. static void parse_eeprom(struct nic *nic);
  45019. -struct nic *tulip_probe(struct nic *nic, unsigned short *io_addrs,
  45020. - struct pci_device *pci);
  45021. +static int tulip_probe(struct dev *dev, struct pci_device *pci);
  45022. static void tulip_init_ring(struct nic *nic);
  45023. static void tulip_reset(struct nic *nic);
  45024. static void tulip_transmit(struct nic *nic, const char *d, unsigned int t,
  45025. unsigned int s, const char *p);
  45026. -static int tulip_poll(struct nic *nic);
  45027. -static void tulip_disable(struct nic *nic);
  45028. +static int tulip_poll(struct nic *nic, int retrieve);
  45029. +static void tulip_disable(struct dev *dev);
  45030. static void nway_start(struct nic *nic);
  45031. static void pnic_do_nway(struct nic *nic);
  45032. static void select_media(struct nic *nic, int startup);
  45033. @@ -504,7 +504,6 @@
  45034. static void tulip_more(void);
  45035. #endif
  45036. -
  45037. /*********************************************************************/
  45038. /* Utility Routines */
  45039. /*********************************************************************/
  45040. @@ -535,7 +534,6 @@
  45041. /* wait */ ;
  45042. }
  45043. -
  45044. /*********************************************************************/
  45045. /* Media Descriptor Code */
  45046. /*********************************************************************/
  45047. @@ -565,7 +563,7 @@
  45048. MDIO protocol. See the MII specifications or DP83840A data sheet
  45049. for details. */
  45050. -int mdio_read(struct nic *nic, int phy_id, int location)
  45051. +int mdio_read(struct nic *nic __unused, int phy_id, int location)
  45052. {
  45053. int i;
  45054. int read_cmd = (0xf6 << 10) | (phy_id << 5) | location;
  45055. @@ -626,7 +624,7 @@
  45056. return (retval>>1) & 0xffff;
  45057. }
  45058. -void mdio_write(struct nic *nic, int phy_id, int location, int value)
  45059. +void mdio_write(struct nic *nic __unused, int phy_id, int location, int value)
  45060. {
  45061. int i;
  45062. int cmd = (0x5002 << 16) | (phy_id << 23) | (location<<18) | value;
  45063. @@ -682,7 +680,6 @@
  45064. }
  45065. }
  45066. -
  45067. /*********************************************************************/
  45068. /* EEPROM Reading Code */
  45069. /*********************************************************************/
  45070. @@ -727,7 +724,6 @@
  45071. return retval;
  45072. }
  45073. -
  45074. /*********************************************************************/
  45075. /* EEPROM Parsing Code */
  45076. /*********************************************************************/
  45077. @@ -895,11 +891,10 @@
  45078. }
  45079. }
  45080. -
  45081. /*********************************************************************/
  45082. /* tulip_init_ring - setup the tx and rx descriptors */
  45083. /*********************************************************************/
  45084. -static void tulip_init_ring(struct nic *nic)
  45085. +static void tulip_init_ring(struct nic *nic __unused)
  45086. {
  45087. int i;
  45088. @@ -935,7 +930,22 @@
  45089. /* Mark the last entry as wrapping the ring, though this should never happen */
  45090. tx_ring[1].length = cpu_to_le32(DESC_RING_WRAP | BUFLEN);
  45091. }
  45092. -
  45093. +
  45094. +static void set_rx_mode(struct nic *nic __unused) {
  45095. + int csr6 = inl(ioaddr + CSR6) & ~0x00D5;
  45096. +
  45097. + tp->csr6 &= ~0x00D5;
  45098. +
  45099. + /* !IFF_PROMISC */
  45100. + tp->csr6 |= AcceptAllMulticast;
  45101. + csr6 |= AcceptAllMulticast;
  45102. +
  45103. + outl(csr6, ioaddr + CSR6);
  45104. +
  45105. +
  45106. +
  45107. +}
  45108. +
  45109. /*********************************************************************/
  45110. /* eth_reset - Reset adapter */
  45111. /*********************************************************************/
  45112. @@ -943,7 +953,6 @@
  45113. {
  45114. int i;
  45115. unsigned long to;
  45116. - u32 addr_low, addr_high;
  45117. #ifdef TULIP_DEBUG_WHERE
  45118. whereami("tulip_reset\n");
  45119. @@ -956,7 +965,7 @@
  45120. if (tp->mii_cnt || (tp->mtable && tp->mtable->has_mii)) {
  45121. outl(0x814C0000, ioaddr + CSR6);
  45122. }
  45123. -
  45124. +
  45125. /* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
  45126. outl(0x00000001, ioaddr + CSR0);
  45127. tulip_wait(1);
  45128. @@ -1022,8 +1031,8 @@
  45129. }
  45130. /* Point to rx and tx descriptors */
  45131. - outl((unsigned long)&rx_ring[0], ioaddr + CSR3);
  45132. - outl((unsigned long)&tx_ring[0], ioaddr + CSR4);
  45133. + outl(virt_to_le32desc(&rx_ring[0]), ioaddr + CSR3);
  45134. + outl(virt_to_le32desc(&tx_ring[0]), ioaddr + CSR4);
  45135. init_media(nic);
  45136. @@ -1049,11 +1058,12 @@
  45137. if (tp->chip_id == LC82C168)
  45138. tulip_check_duplex(nic);
  45139. + set_rx_mode(nic);
  45140. +
  45141. /* enable transmit and receive */
  45142. outl(tp->csr6 | 0x00002002, ioaddr + CSR6);
  45143. }
  45144. -
  45145. /*********************************************************************/
  45146. /* eth_transmit - Transmit a frame */
  45147. /*********************************************************************/
  45148. @@ -1095,7 +1105,7 @@
  45149. tx_ring[0].status = cpu_to_le32(0x80000000);
  45150. /* Point to transmit descriptor */
  45151. - outl((u32)&tx_ring[0], ioaddr + CSR4);
  45152. + outl(virt_to_le32desc(&tx_ring[0]), ioaddr + CSR4);
  45153. /* Enable Tx */
  45154. outl(csr6 | 0x00002000, ioaddr + CSR6);
  45155. @@ -1113,11 +1123,11 @@
  45156. /* Disable Tx */
  45157. outl(csr6 & ~0x00002000, ioaddr + CSR6);
  45158. }
  45159. -
  45160. +
  45161. /*********************************************************************/
  45162. /* eth_poll - Wait for a frame */
  45163. /*********************************************************************/
  45164. -static int tulip_poll(struct nic *nic)
  45165. +static int tulip_poll(struct nic *nic, int retrieve)
  45166. {
  45167. #ifdef TULIP_DEBUG_WHERE
  45168. @@ -1128,6 +1138,8 @@
  45169. if (rx_ring[tp->cur_rx].status & 0x80000000)
  45170. return 0;
  45171. + if ( ! retrieve ) return 1;
  45172. +
  45173. #ifdef TULIP_DEBUG_WHERE
  45174. whereami("tulip_poll got one\n");
  45175. #endif
  45176. @@ -1151,17 +1163,20 @@
  45177. return 1;
  45178. }
  45179. -
  45180. +
  45181. /*********************************************************************/
  45182. /* eth_disable - Disable the interface */
  45183. /*********************************************************************/
  45184. -static void tulip_disable(struct nic *nic)
  45185. +static void tulip_disable(struct dev *dev)
  45186. {
  45187. -
  45188. + struct nic *nic = (struct nic *)dev;
  45189. #ifdef TULIP_DEBUG_WHERE
  45190. whereami("tulip_disable\n");
  45191. #endif
  45192. + /* merge reset and disable */
  45193. + tulip_reset(nic);
  45194. +
  45195. /* disable interrupts */
  45196. outl(0x00000000, ioaddr + CSR7);
  45197. @@ -1171,24 +1186,41 @@
  45198. /* Clear the missed-packet counter. */
  45199. (volatile unsigned long)inl(ioaddr + CSR8);
  45200. }
  45201. -
  45202. +
  45203. +/*********************************************************************/
  45204. +/*IRQ - Enable, Disable, or Force interrupts */
  45205. +/*********************************************************************/
  45206. +static void tulip_irq(struct nic *nic __unused, irq_action_t action __unused)
  45207. +{
  45208. + switch ( action ) {
  45209. + case DISABLE :
  45210. + break;
  45211. + case ENABLE :
  45212. + break;
  45213. + case FORCE :
  45214. + break;
  45215. + }
  45216. +}
  45217. +
  45218. /*********************************************************************/
  45219. /* eth_probe - Look for an adapter */
  45220. /*********************************************************************/
  45221. -struct nic *tulip_probe(struct nic *nic, unsigned short *io_addrs,
  45222. - struct pci_device *pci)
  45223. +static int tulip_probe(struct dev *dev, struct pci_device *pci)
  45224. {
  45225. - u32 i, l1, l2;
  45226. + struct nic *nic = (struct nic *)dev;
  45227. + u32 i;
  45228. u8 chip_rev;
  45229. u8 ee_data[EEPROM_SIZE];
  45230. unsigned short sum;
  45231. int chip_idx;
  45232. static unsigned char last_phys_addr[ETH_ALEN] = {0x00, 'L', 'i', 'n', 'u', 'x'};
  45233. - if (io_addrs == 0 || *io_addrs == 0)
  45234. + if (pci->ioaddr == 0)
  45235. return 0;
  45236. - ioaddr = *io_addrs;
  45237. + ioaddr = pci->ioaddr;
  45238. + nic->ioaddr = pci->ioaddr & ~3;
  45239. + nic->irqno = 0;
  45240. /* point to private storage */
  45241. tp = &tpx;
  45242. @@ -1378,15 +1410,15 @@
  45243. /* reset the device and make ready for tx and rx of packets */
  45244. tulip_reset(nic);
  45245. - nic->reset = tulip_reset;
  45246. + dev->disable = tulip_disable;
  45247. nic->poll = tulip_poll;
  45248. nic->transmit = tulip_transmit;
  45249. - nic->disable = tulip_disable;
  45250. + nic->irq = tulip_irq;
  45251. /* give the board a chance to reset before returning */
  45252. tulip_wait(4*TICKS_PER_SEC);
  45253. - return nic;
  45254. + return 1;
  45255. }
  45256. static void start_link(struct nic *nic)
  45257. @@ -1508,7 +1540,7 @@
  45258. }
  45259. }
  45260. -static void nway_start(struct nic *nic)
  45261. +static void nway_start(struct nic *nic __unused)
  45262. {
  45263. int csr14 = ((tp->sym_advertise & 0x0780) << 9) |
  45264. ((tp->sym_advertise&0x0020)<<1) | 0xffbf;
  45265. @@ -1662,7 +1694,7 @@
  45266. }
  45267. }
  45268. -static void pnic_do_nway(struct nic *nic)
  45269. +static void pnic_do_nway(struct nic *nic __unused)
  45270. {
  45271. u32 phy_reg = inl(ioaddr + 0xB8);
  45272. u32 new_csr6 = tp->csr6 & ~0x40C40200;
  45273. @@ -1886,8 +1918,8 @@
  45274. }
  45275. } else if (tp->chip_id == DC21040) { /* 21040 */
  45276. /* Turn on the xcvr interface. */
  45277. - int csr12 = inl(ioaddr + CSR12);
  45278. #ifdef TULIP_DEBUG
  45279. + int csr12 = inl(ioaddr + CSR12);
  45280. if (tulip_debug > 1)
  45281. printf("%s: 21040 media type is %s, CSR12 is %hhX.\n",
  45282. tp->nic_name, medianame[tp->if_port], csr12);
  45283. @@ -1987,3 +2019,51 @@
  45284. return 0;
  45285. }
  45286. +
  45287. +static struct pci_id tulip_nics[] = {
  45288. +PCI_ROM(0x1011, 0x0002, "dc21040", "Digital Tulip"),
  45289. +PCI_ROM(0x1011, 0x0009, "ds21140", "Digital Tulip Fast"),
  45290. +PCI_ROM(0x1011, 0x0014, "dc21041", "Digital Tulip+"),
  45291. +PCI_ROM(0x1011, 0x0019, "ds21142", "Digital Tulip 21142"),
  45292. +PCI_ROM(0x10b7, 0x9300, "3csoho100b-tx","3ComSOHO100B-TX"),
  45293. +PCI_ROM(0x10b9, 0x5261, "ali1563", "ALi 1563 integrated ethernet"),
  45294. +PCI_ROM(0x10d9, 0x0512, "mx98713", "Macronix MX987x3"),
  45295. +PCI_ROM(0x10d9, 0x0531, "mx98715", "Macronix MX987x5"),
  45296. +PCI_ROM(0x1113, 0x1217, "mxic-98715", "Macronix MX987x5"),
  45297. +PCI_ROM(0x11ad, 0xc115, "lc82c115", "LinkSys LNE100TX"),
  45298. +PCI_ROM(0x11ad, 0x0002, "82c168", "Netgear FA310TX"),
  45299. +PCI_ROM(0x1282, 0x9100, "dm9100", "Davicom 9100"),
  45300. +PCI_ROM(0x1282, 0x9102, "dm9102", "Davicom 9102"),
  45301. +PCI_ROM(0x1282, 0x9009, "dm9009", "Davicom 9009"),
  45302. +PCI_ROM(0x1282, 0x9132, "dm9132", "Davicom 9132"),
  45303. +PCI_ROM(0x1317, 0x0985, "centaur-p", "ADMtek Centaur-P"),
  45304. +PCI_ROM(0x1317, 0x0981, "an981", "ADMtek AN981 Comet"), /* ADMTek Centaur-P (stmicro) */
  45305. +PCI_ROM(0x1113, 0x1216, "an983", "ADMTek AN983 Comet"),
  45306. +PCI_ROM(0x1317, 0x9511, "an983b", "ADMTek Comet 983b"),
  45307. +PCI_ROM(0x1317, 0x1985, "centaur-c", "ADMTek Centaur-C"),
  45308. +PCI_ROM(0x8086, 0x0039, "intel21145", "Intel Tulip"),
  45309. +PCI_ROM(0x125b, 0x1400, "ax88140", "ASIX AX88140"),
  45310. +PCI_ROM(0x11f6, 0x9881, "rl100tx", "Compex RL100-TX"),
  45311. +PCI_ROM(0x115d, 0x0003, "xircomtulip", "Xircom Tulip"),
  45312. +PCI_ROM(0x104a, 0x0981, "tulip-0981", "Tulip 0x104a 0x0981"),
  45313. +PCI_ROM(0x104a, 0x2774, "tulip-2774", "Tulip 0x104a 0x2774"),
  45314. +PCI_ROM(0x1113, 0x9511, "tulip-9511", "Tulip 0x1113 0x9511"),
  45315. +PCI_ROM(0x1186, 0x1561, "tulip-1561", "Tulip 0x1186 0x1561"),
  45316. +PCI_ROM(0x1259, 0xa120, "tulip-a120", "Tulip 0x1259 0xa120"),
  45317. +PCI_ROM(0x13d1, 0xab02, "tulip-ab02", "Tulip 0x13d1 0xab02"),
  45318. +PCI_ROM(0x13d1, 0xab03, "tulip-ab03", "Tulip 0x13d1 0xab03"),
  45319. +PCI_ROM(0x13d1, 0xab08, "tulip-ab08", "Tulip 0x13d1 0xab08"),
  45320. +PCI_ROM(0x14f1, 0x1803, "lanfinity", "Conexant LANfinity"),
  45321. +PCI_ROM(0x1626, 0x8410, "tulip-8410", "Tulip 0x1626 0x8410"),
  45322. +PCI_ROM(0x1737, 0xab08, "tulip-1737-ab08","Tulip 0x1737 0xab08"),
  45323. +PCI_ROM(0x1737, 0xab09, "tulip-ab09", "Tulip 0x1737 0xab09"),
  45324. +};
  45325. +
  45326. +struct pci_driver tulip_driver = {
  45327. + .type = NIC_DRIVER,
  45328. + .name = "Tulip",
  45329. + .probe = tulip_probe,
  45330. + .ids = tulip_nics,
  45331. + .id_count = sizeof(tulip_nics)/sizeof(tulip_nics[0]),
  45332. + .class = 0,
  45333. +};
  45334. Index: b/netboot/tulip.txt
  45335. ===================================================================
  45336. --- a/netboot/tulip.txt
  45337. +++ /dev/null
  45338. @@ -1,53 +0,0 @@
  45339. -This software may be used and distributed according to the terms of
  45340. -the GNU Public License, incorporated herein by reference.
  45341. -
  45342. -This is a tulip and clone driver for Etherboot. See the revision
  45343. -history in the tulip.c file for information on changes. This version
  45344. -of the driver incorporates changes from Bob Edwards and Paul Mackerras
  45345. -who cantributed changes to support the TRENDnet TE100-PCIA NIC which
  45346. -uses a genuine Intel 21143-PD chipset. There are also various code
  45347. -cleanups to make time-based activities more reliable.
  45348. -
  45349. -Of course you have to have all the usual Etherboot environment
  45350. -(bootp/dhcp/NFS) set up, and you need a Linux kernel with v0.91g
  45351. -(7.16.99) or later of the tulip.c driver compiled in to support some
  45352. -MX98715 based cards. That file is available at:
  45353. -
  45354. - http://cesdis.gsfc.nasa.gov/linux/drivers/test/tulip.c
  45355. -
  45356. -NOTES
  45357. -
  45358. -I've tested this driver with a SOHOware Fast 10/100 Model SDA110A,
  45359. -a Linksys LNE100TX v2.0, and a Netgear FA310TX card, and it worked at
  45360. -both 10 and 100 mbits. Other cards based on the tulip family may work as
  45361. -well.
  45362. -
  45363. -These cards are about 20$US, are supported by Linux and now Etherboot,
  45364. -and being PCI, they auto-configure IRQ and IOADDR and auto-negotiate
  45365. -10/100 half/full duplex. It seems like a pretty good value compared to
  45366. -some of the pricier cards, and can lower the cost of building/adapting
  45367. -thin client workstations substantially while giving a considerable
  45368. -performance increase.
  45369. -
  45370. -On some PCI tulip clone chipsets (MX987x5, LC82C115, LC82C168) this driver
  45371. -lets the card choose the fastest speed it can negotiate with the peer
  45372. -device. On other cards, it chooses 10mbit half-duplex.
  45373. -
  45374. -I burned an AM27C256 (32KByte) EPROM with mx987x5.lzrom and it worked.
  45375. -According to the data sheet the MX98715A supports up to 64K (27C512)
  45376. -EPROMs,
  45377. -
  45378. -I've liberally commented the code and header files in the hope that it
  45379. -will help the next person who hacks the code or needs to support some
  45380. -tulip clone card, or wishes to add functionality.
  45381. -
  45382. -Anyway, please test this if you can on your tulip based card, and let
  45383. -me (mdc@thinguin.org) and the netboot list (netboot@baghira.han.de)
  45384. -know how things go. I also would appreciate code review by people who
  45385. -program. I'm a strong believer in "another set of eyes".
  45386. -
  45387. -Regards,
  45388. -
  45389. -Marty Connor
  45390. -mdc@thinguin.org
  45391. -http://www.thinguin.org/
  45392. Index: b/netboot/types.h
  45393. ===================================================================
  45394. --- /dev/null
  45395. +++ b/netboot/types.h
  45396. @@ -0,0 +1,44 @@
  45397. +#ifndef _TYPES_H
  45398. +#define _TYPES_H
  45399. +
  45400. +/* I'm architecture independed :-) */
  45401. +
  45402. +/*
  45403. + * It's architecture depended headers for common integer types
  45404. + */
  45405. +#include "stdint.h"
  45406. +
  45407. +/*
  45408. + * Here are some RPC types define from linux /usr/include/rpc/types.h
  45409. + */
  45410. +typedef int bool_t;
  45411. +typedef int enum_t;
  45412. +typedef uint32_t rpcprog_t;
  45413. +typedef uint32_t rpcvers_t;
  45414. +typedef uint32_t rpcproc_t;
  45415. +typedef uint32_t rpcprot_t;
  45416. +typedef uint32_t rpcport_t;
  45417. +
  45418. +/* For bool_t */
  45419. +/* typedef enum { */
  45420. +/* FALSE = 0, */
  45421. +/* TRUE = 1 */
  45422. +/* } boolean_t; */
  45423. +
  45424. +
  45425. +
  45426. +/* Some BSD or RPC style types */
  45427. +typedef unsigned char u_char;
  45428. +typedef unsigned short u_short;
  45429. +typedef unsigned int u_int;
  45430. +typedef unsigned long u_long;
  45431. +typedef long long quad_t;
  45432. +typedef unsigned long long u_quad_t;
  45433. +typedef struct {
  45434. + int __val[2];
  45435. +}fsid_t; /* Type of file system IDs, from bits/types.h */
  45436. +
  45437. +typedef int daddr_t; /* The type of a disk address, from bits/types.h */
  45438. +typedef char * caddr_t;
  45439. +
  45440. +#endif /* _TYPES_H */
  45441. Index: b/netboot/udp.h
  45442. ===================================================================
  45443. --- /dev/null
  45444. +++ b/netboot/udp.h
  45445. @@ -0,0 +1,30 @@
  45446. +#ifndef _UDP_H
  45447. +#define _UDP_H
  45448. +
  45449. +/* We need 'uint16_t' and 'uint8_t' */
  45450. +#include "types.h"
  45451. +/* We need 'in_addr' */
  45452. +#include "in.h"
  45453. +
  45454. +struct udp_pseudo_hdr {
  45455. + in_addr src;
  45456. + in_addr dest;
  45457. + uint8_t unused;
  45458. + uint8_t protocol;
  45459. + uint16_t len;
  45460. +};
  45461. +struct udphdr {
  45462. + uint16_t src;
  45463. + uint16_t dest;
  45464. + uint16_t len;
  45465. + uint16_t chksum;
  45466. +};
  45467. +
  45468. +extern void build_udp_hdr(unsigned long __destip, unsigned int __srcsock,
  45469. + unsigned int __destsock, int __ttl, int __len,
  45470. + const void * __buf);
  45471. +
  45472. +extern int udp_transmit(unsigned long __destip, unsigned int __srcsock,
  45473. + unsigned int __destsock, int __len, const void * __buf);
  45474. +
  45475. +#endif /* _UDP_H */
  45476. Index: b/netboot/via-rhine.c
  45477. ===================================================================
  45478. --- a/netboot/via-rhine.c
  45479. +++ b/netboot/via-rhine.c
  45480. @@ -18,7 +18,7 @@
  45481. */
  45482. -static const char *version = "rhine.c v1.0.0 2000-01-07\n";
  45483. +static const char *version = "rhine.c v1.0.1 2003-02-06\n";
  45484. /* A few user-configurable values. */
  45485. @@ -46,7 +46,6 @@
  45486. #include "etherboot.h"
  45487. #include "nic.h"
  45488. #include "pci.h"
  45489. -#include "cards.h"
  45490. /* define all ioaddr */
  45491. @@ -103,6 +102,11 @@
  45492. #define byCFGD ioaddr + 0x7b
  45493. #define wTallyCntMPA ioaddr + 0x7c
  45494. #define wTallyCntCRC ioaddr + 0x7d
  45495. +#define bySTICKHW ioaddr + 0x83
  45496. +#define byWOLcrClr ioaddr + 0xA4
  45497. +#define byWOLcgClr ioaddr + 0xA7
  45498. +#define byPwrcsrClr ioaddr + 0xAC
  45499. +
  45500. /*--------------------- Exioaddr Definitions -------------------------*/
  45501. /*
  45502. @@ -617,9 +621,6 @@
  45503. */
  45504. -#define PCI_VENDOR_ID_FET 0x1106
  45505. -#define PCI_DEVICE_ID_FET_3043 0x3043
  45506. -
  45507. /* The rest of these values should never change. */
  45508. #define NUM_TX_DESC 2 /* Number of Tx descriptor registers. */
  45509. @@ -652,23 +653,19 @@
  45510. }
  45511. rhine;
  45512. -static struct nic *rhine_probe1 (struct nic *dev, int ioaddr,
  45513. +static void rhine_probe1 (struct nic *nic, int ioaddr,
  45514. int chip_id, int options);
  45515. static int QueryAuto (int);
  45516. static int ReadMII (int byMIIIndex, int);
  45517. static void WriteMII (char, char, char, int);
  45518. static void MIIDelay (void);
  45519. static void rhine_init_ring (struct nic *dev);
  45520. -static void rhine_disable (struct nic *nic);
  45521. +static void rhine_disable (struct dev *dev);
  45522. static void rhine_reset (struct nic *nic);
  45523. -static int rhine_poll (struct nic *nic);
  45524. +static int rhine_poll (struct nic *nic, int retreive);
  45525. static void rhine_transmit (struct nic *nic, const char *d, unsigned int t,
  45526. unsigned int s, const char *p);
  45527. -/* Linux support functions */
  45528. -#define virt_to_bus(x) ((unsigned long)x)
  45529. -#define bus_to_virt(x) ((void *)x)
  45530. -
  45531. /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
  45532. static void
  45533. rhine_init_ring (struct nic *nic)
  45534. @@ -854,26 +851,99 @@
  45535. }
  45536. }
  45537. -struct nic *
  45538. -rhine_probe (struct nic *nic, unsigned short *probeaddrs,
  45539. - struct pci_device *pci)
  45540. +/* Offsets to the device registers. */
  45541. +enum register_offsets {
  45542. + StationAddr=0x00, RxConfig=0x06, TxConfig=0x07, ChipCmd=0x08,
  45543. + IntrStatus=0x0C, IntrEnable=0x0E,
  45544. + MulticastFilter0=0x10, MulticastFilter1=0x14,
  45545. + RxRingPtr=0x18, TxRingPtr=0x1C, GFIFOTest=0x54,
  45546. + MIIPhyAddr=0x6C, MIIStatus=0x6D, PCIBusConfig=0x6E,
  45547. + MIICmd=0x70, MIIRegAddr=0x71, MIIData=0x72, MACRegEEcsr=0x74,
  45548. + ConfigA=0x78, ConfigB=0x79, ConfigC=0x7A, ConfigD=0x7B,
  45549. + RxMissed=0x7C, RxCRCErrs=0x7E, MiscCmd=0x81,
  45550. + StickyHW=0x83, IntrStatus2=0x84, WOLcrClr=0xA4, WOLcgClr=0xA7,
  45551. + PwrcsrClr=0xAC,
  45552. +};
  45553. +
  45554. +/* Bits in the interrupt status/mask registers. */
  45555. +enum intr_status_bits {
  45556. + IntrRxDone=0x0001, IntrRxErr=0x0004, IntrRxEmpty=0x0020,
  45557. + IntrTxDone=0x0002, IntrTxError=0x0008, IntrTxUnderrun=0x0210,
  45558. + IntrPCIErr=0x0040,
  45559. + IntrStatsMax=0x0080, IntrRxEarly=0x0100,
  45560. + IntrRxOverflow=0x0400, IntrRxDropped=0x0800, IntrRxNoBuf=0x1000,
  45561. + IntrTxAborted=0x2000, IntrLinkChange=0x4000,
  45562. + IntrRxWakeUp=0x8000,
  45563. + IntrNormalSummary=0x0003, IntrAbnormalSummary=0xC260,
  45564. + IntrTxDescRace=0x080000, /* mapped from IntrStatus2 */
  45565. + IntrTxErrSummary=0x082218,
  45566. +};
  45567. +#define DEFAULT_INTR (IntrRxDone | IntrRxErr | IntrRxEmpty| IntrRxOverflow | \
  45568. + IntrRxDropped | IntrRxNoBuf)
  45569. +
  45570. +/***************************************************************************
  45571. + IRQ - PXE IRQ Handler
  45572. +***************************************************************************/
  45573. +void rhine_irq ( struct nic *nic, irq_action_t action ) {
  45574. + struct rhine_private *tp = (struct rhine_private *) nic->priv_data;
  45575. + /* Enable interrupts by setting the interrupt mask. */
  45576. + unsigned int intr_status;
  45577. +
  45578. + switch ( action ) {
  45579. + case DISABLE :
  45580. + case ENABLE :
  45581. + intr_status = inw(nic->ioaddr + IntrStatus);
  45582. + /* On Rhine-II, Bit 3 indicates Tx descriptor write-back race. */
  45583. + if (tp->chip_id == 0x3065)
  45584. + intr_status |= inb(nic->ioaddr + IntrStatus2) << 16;
  45585. + intr_status = (intr_status & ~DEFAULT_INTR);
  45586. + if ( action == ENABLE )
  45587. + intr_status = intr_status | DEFAULT_INTR;
  45588. + outw(intr_status, nic->ioaddr + IntrEnable);
  45589. + break;
  45590. + case FORCE :
  45591. + outw(0x0010, nic->ioaddr + 0x84);
  45592. + break;
  45593. + }
  45594. +}
  45595. +
  45596. +static int
  45597. +rhine_probe (struct dev *dev, struct pci_device *pci)
  45598. {
  45599. + struct nic *nic = (struct nic *)dev;
  45600. + struct rhine_private *tp = &rhine;
  45601. if (!pci->ioaddr)
  45602. - return NULL;
  45603. - nic = rhine_probe1 (nic, pci->ioaddr, 0, -1);
  45604. + return 0;
  45605. + rhine_probe1 (nic, pci->ioaddr, pci->dev_id, -1);
  45606. - if (nic)
  45607. - adjust_pci_device(pci);
  45608. - nic->poll = rhine_poll;
  45609. - nic->transmit = rhine_transmit;
  45610. - nic->reset = rhine_reset;
  45611. - nic->disable = rhine_disable;
  45612. + adjust_pci_device(pci);
  45613. rhine_reset (nic);
  45614. - return nic;
  45615. + dev->disable = rhine_disable;
  45616. + nic->poll = rhine_poll;
  45617. + nic->transmit = rhine_transmit;
  45618. + nic->irqno = pci->irq;
  45619. + nic->irq = rhine_irq;
  45620. + nic->ioaddr = tp->ioaddr;
  45621. +
  45622. +
  45623. + return 1;
  45624. +}
  45625. +
  45626. +static void set_rx_mode(struct nic *nic __unused) {
  45627. + struct rhine_private *tp = (struct rhine_private *) nic->priv_data;
  45628. + unsigned char rx_mode;
  45629. + int ioaddr = tp->ioaddr;
  45630. +
  45631. + /* ! IFF_PROMISC */
  45632. + outl(0xffffffff, byMAR0);
  45633. + outl(0xffffffff, byMAR4);
  45634. + rx_mode = 0x0C;
  45635. +
  45636. + outb(0x60 /* thresh */ | rx_mode, byRCR );
  45637. }
  45638. -static struct nic *
  45639. +static void
  45640. rhine_probe1 (struct nic *nic, int ioaddr, int chip_id, int options)
  45641. {
  45642. struct rhine_private *tp;
  45643. @@ -885,6 +955,29 @@
  45644. if (rhine_debug > 0 && did_version++ == 0)
  45645. printf (version);
  45646. +
  45647. + /* D-Link provided reset code (with comment additions) */
  45648. + if((chip_id != 0x3043) && (chip_id != 0x6100)) {
  45649. + unsigned char byOrgValue;
  45650. +
  45651. + if(rhine_debug > 0)
  45652. + printf("Enabling Sticky Bit Workaround for Chip_id: 0x%hX\n"
  45653. + , chip_id);
  45654. + /* clear sticky bit before reset & read ethernet address */
  45655. + byOrgValue = inb(bySTICKHW);
  45656. + byOrgValue = byOrgValue & 0xFC;
  45657. + outb(byOrgValue, bySTICKHW);
  45658. +
  45659. + /* (bits written are cleared?) */
  45660. + /* disable force PME-enable */
  45661. + outb(0x80, byWOLcgClr);
  45662. + /* disable power-event config bit */
  45663. + outb(0xFF, byWOLcrClr);
  45664. + /* clear power status (undocumented in vt6102 docs?) */
  45665. + outb(0xFF, byPwrcsrClr);
  45666. +
  45667. + }
  45668. +
  45669. /* Perhaps this should be read from the EEPROM? */
  45670. for (i = 0; i < ETH_ALEN; i++)
  45671. nic->node_addr[i] = inb (byPAR0 + i);
  45672. @@ -920,6 +1013,7 @@
  45673. }
  45674. #endif
  45675. +
  45676. /* query MII to know LineSpeed,duplex mode */
  45677. byMIIvalue = inb (ioaddr + 0x6d);
  45678. LineSpeed = byMIIvalue & MIISR_SPEED;
  45679. @@ -971,15 +1065,19 @@
  45680. if (tp->default_port)
  45681. tp->medialock = 1;
  45682. }
  45683. - return nic;
  45684. + return;
  45685. }
  45686. -static void
  45687. -rhine_disable (struct nic *nic)
  45688. +static void
  45689. +rhine_disable (struct dev *dev)
  45690. {
  45691. + struct nic *nic = (struct nic *)dev;
  45692. struct rhine_private *tp = (struct rhine_private *) nic->priv_data;
  45693. int ioaddr = tp->ioaddr;
  45694. + /* merge reset and disable */
  45695. + rhine_reset(nic);
  45696. +
  45697. printf ("rhine disable\n");
  45698. /* Switch to loopback mode to avoid hardware races. */
  45699. writeb(0x60 | 0x01, byTCR);
  45700. @@ -1002,17 +1100,10 @@
  45701. int rx_bufs_tmp, rx_bufs_tmp1;
  45702. int tx_bufs_tmp, tx_bufs_tmp1;
  45703. -#ifdef USE_LOWMEM_BUFFER
  45704. -#define buf1 (0x10000 - (RX_RING_SIZE * PKT_BUF_SZ + 32))
  45705. -#define buf2 (buf1 - (RX_RING_SIZE * PKT_BUF_SZ + 32))
  45706. -#define desc1 (buf2 - (TX_RING_SIZE * sizeof (struct rhine_tx_desc) + 32))
  45707. -#define desc2 (desc1 - (TX_RING_SIZE * sizeof (struct rhine_tx_desc) + 32))
  45708. -#else
  45709. static char buf1[RX_RING_SIZE * PKT_BUF_SZ + 32];
  45710. static char buf2[RX_RING_SIZE * PKT_BUF_SZ + 32];
  45711. static char desc1[TX_RING_SIZE * sizeof (struct rhine_tx_desc) + 32];
  45712. static char desc2[TX_RING_SIZE * sizeof (struct rhine_tx_desc) + 32];
  45713. -#endif
  45714. /* printf ("rhine_reset\n"); */
  45715. /* Soft reset the chip. */
  45716. @@ -1069,6 +1160,9 @@
  45717. outl (virt_to_bus (tp->rx_ring), dwCurrentRxDescAddr);
  45718. outl (virt_to_bus (tp->tx_ring), dwCurrentTxDescAddr);
  45719. + /* Setup Multicast */
  45720. + set_rx_mode(nic);
  45721. +
  45722. /* close IMR */
  45723. outw (0x0000, byIMR0);
  45724. @@ -1093,15 +1187,34 @@
  45725. /*set IMR to work */
  45726. outw (IMRShadow, byIMR0);
  45727. }
  45728. +/* Beware of PCI posted writes */
  45729. +#define IOSYNC do { readb(nic->ioaddr + StationAddr); } while (0)
  45730. static int
  45731. -rhine_poll (struct nic *nic)
  45732. +rhine_poll (struct nic *nic, int retreive)
  45733. {
  45734. struct rhine_private *tp = (struct rhine_private *) nic->priv_data;
  45735. int rxstatus, good = 0;;
  45736. if (tp->rx_ring[tp->cur_rx].rx_status.bits.own_bit == 0)
  45737. {
  45738. + unsigned int intr_status;
  45739. + /* There is a packet ready */
  45740. + if(!retreive)
  45741. + return 1;
  45742. +
  45743. + intr_status = inw(nic->ioaddr + IntrStatus);
  45744. + /* On Rhine-II, Bit 3 indicates Tx descriptor write-back race. */
  45745. +#if 0
  45746. + if (tp->chip_id == 0x3065)
  45747. + intr_status |= inb(nic->ioaddr + IntrStatus2) << 16;
  45748. +#endif
  45749. + /* Acknowledge all of the current interrupt sources ASAP. */
  45750. + if (intr_status & IntrTxDescRace)
  45751. + outb(0x08, nic->ioaddr + IntrStatus2);
  45752. + outw(intr_status & 0xffff, nic->ioaddr + IntrStatus);
  45753. + IOSYNC;
  45754. +
  45755. rxstatus = tp->rx_ring[tp->cur_rx].rx_status.lw;
  45756. if ((rxstatus & 0x0300) != 0x0300)
  45757. {
  45758. @@ -1124,6 +1237,11 @@
  45759. tp->cur_rx++;
  45760. tp->cur_rx = tp->cur_rx % RX_RING_SIZE;
  45761. }
  45762. + /* Acknowledge all of the current interrupt sources ASAP. */
  45763. + outw(DEFAULT_INTR & ~IntrRxDone, nic->ioaddr + IntrStatus);
  45764. +
  45765. + IOSYNC;
  45766. +
  45767. return good;
  45768. }
  45769. @@ -1152,7 +1270,7 @@
  45770. while (s < ETH_ZLEN)
  45771. *((char *) tp->tx_buffs[entry] + ETH_HLEN + (s++)) = 0;
  45772. - tp->tx_ring[entry].tx_ctrl.bits.tx_buf_size = ETH_HLEN + s;
  45773. + tp->tx_ring[entry].tx_ctrl.bits.tx_buf_size = s;
  45774. tp->tx_ring[entry].tx_status.bits.own_bit = 1;
  45775. @@ -1170,6 +1288,9 @@
  45776. /*printf("td4=[%X]",inl(dwCurrentTDSE3)); */
  45777. outb (CR1bak, byCR1);
  45778. + /* Wait until transmit is finished */
  45779. + while (tp->tx_ring[entry].tx_status.bits.own_bit != 0)
  45780. + ;
  45781. tp->cur_tx++;
  45782. /*outw(IMRShadow,byIMR0); */
  45783. @@ -1177,4 +1298,21 @@
  45784. /*tp->tx_skbuff[entry] = 0; */
  45785. }
  45786. +static struct pci_id rhine_nics[] = {
  45787. +PCI_ROM(0x1106, 0x3065, "dlink-530tx", "VIA 6102"),
  45788. +PCI_ROM(0x1106, 0x3106, "via-rhine-6105", "VIA 6105"),
  45789. +PCI_ROM(0x1106, 0x3043, "dlink-530tx-old", "VIA 3043"), /* Rhine-I 86c100a */
  45790. +PCI_ROM(0x1106, 0x3053, "via6105m", "VIA 6105M"),
  45791. +PCI_ROM(0x1106, 0x6100, "via-rhine-old", "VIA 86C100A"), /* Rhine-II */
  45792. +};
  45793. +
  45794. +struct pci_driver rhine_driver = {
  45795. + .type = NIC_DRIVER,
  45796. + .name = "VIA 86C100",
  45797. + .probe = rhine_probe,
  45798. + .ids = rhine_nics,
  45799. + .id_count = sizeof(rhine_nics)/sizeof(rhine_nics[0]),
  45800. + .class = 0,
  45801. +};
  45802. +
  45803. /* EOF via-rhine.c */
  45804. Index: b/netboot/w89c840.c
  45805. ===================================================================
  45806. --- a/netboot/w89c840.c
  45807. +++ b/netboot/w89c840.c
  45808. @@ -43,6 +43,9 @@
  45809. * using timer2 routines. Proposed
  45810. * by Ken Yap to eliminate CPU speed
  45811. * dependency.
  45812. + * Dec 12 2003 V0.94 timlegge Fixed issues in 5.2, removed
  45813. + * interrupt usage, enabled
  45814. + * multicast support
  45815. *
  45816. * This is the etherboot driver for cards based on Winbond W89c840F chip.
  45817. *
  45818. @@ -77,10 +80,9 @@
  45819. #include "etherboot.h"
  45820. #include "nic.h"
  45821. #include "pci.h"
  45822. -#include "cards.h"
  45823. #include "timer.h"
  45824. -static const char *w89c840_version = "diver Version 0.92 - August 27, 2000";
  45825. +static const char *w89c840_version = "driver Version 0.94 - December 12, 2003";
  45826. typedef unsigned char u8;
  45827. typedef signed char s8;
  45828. @@ -90,9 +92,6 @@
  45829. typedef signed int s32;
  45830. /* Linux support functions */
  45831. -#define virt_to_bus(x) ((unsigned long)x)
  45832. -#define bus_to_virt(x) ((void *)x)
  45833. -
  45834. #define virt_to_le32desc(addr) virt_to_bus(addr)
  45835. #define le32desc_to_virt(addr) bus_to_virt(addr)
  45836. @@ -109,7 +108,6 @@
  45837. bonding and packet priority.
  45838. There are no ill effects from too-large receive rings. */
  45839. #define TX_RING_SIZE 2
  45840. -
  45841. #define RX_RING_SIZE 2
  45842. /* The presumed FIFO size for working around the Tx-FIFO-overflow bug.
  45843. @@ -260,32 +258,20 @@
  45844. static int ioaddr;
  45845. static unsigned short eeprom [0x40];
  45846. -
  45847. -#ifdef USE_LOWMEM_BUFFER
  45848. -#define rx_packet ((char *)0x10000 - PKT_BUF_SZ * RX_RING_SIZE)
  45849. -#define tx_packet ((char *)0x10000 - PKT_BUF_SZ * RX_RING_SIZE - PKT_BUF_SZ * TX_RING_SIZE)
  45850. -#else
  45851. static char rx_packet[PKT_BUF_SZ * RX_RING_SIZE];
  45852. static char tx_packet[PKT_BUF_SZ * TX_RING_SIZE];
  45853. -#endif
  45854. static int eeprom_read(long ioaddr, int location);
  45855. static int mdio_read(int base_address, int phy_id, int location);
  45856. +#if 0
  45857. static void mdio_write(int base_address, int phy_id, int location, int value);
  45858. +#endif
  45859. static void check_duplex(void);
  45860. static void set_rx_mode(void);
  45861. static void init_ring(void);
  45862. -/*
  45863. -static void wait_long_time(void)
  45864. -{
  45865. - printf("Paused - please read output above this line\n");
  45866. - sleep(3);
  45867. -}
  45868. -*/
  45869. -
  45870. -#if defined W89C840_DEBUG
  45871. +#if defined(W89C840_DEBUG)
  45872. static void decode_interrupt(u32 intr_status)
  45873. {
  45874. printf("Interrupt status: ");
  45875. @@ -349,15 +335,17 @@
  45876. check_duplex();
  45877. set_rx_mode();
  45878. - /* Clear and Enable interrupts by setting the interrupt mask. */
  45879. + /* Do not enable the interrupts Etherboot doesn't need them */
  45880. +/*
  45881. writel(0x1A0F5, ioaddr + IntrStatus);
  45882. writel(0x1A0F5, ioaddr + IntrEnable);
  45883. -
  45884. +*/
  45885. #if defined(W89C840_DEBUG)
  45886. printf("winbond-840 : Done reset.\n");
  45887. #endif
  45888. }
  45889. +#if 0
  45890. static void handle_intr(u32 intr_stat)
  45891. {
  45892. if ((intr_stat & (NormalIntr|AbnormalIntr)) == 0) {
  45893. @@ -372,7 +360,7 @@
  45894. /* There was an abnormal interrupt */
  45895. printf("\n-=- Abnormal interrupt.\n");
  45896. -#if defined (W89C840_DEBUG)
  45897. +#if defined(W89C840_DEBUG)
  45898. decode_interrupt(intr_stat);
  45899. #endif
  45900. @@ -383,19 +371,21 @@
  45901. }
  45902. }
  45903. }
  45904. +#endif
  45905. /**************************************************************************
  45906. w89c840_poll - Wait for a frame
  45907. ***************************************************************************/
  45908. -static int w89c840_poll(struct nic *nic)
  45909. +static int w89c840_poll(struct nic *nic, int retrieve)
  45910. {
  45911. /* return true if there's an ethernet packet ready to read */
  45912. /* nic->packet should contain data on return */
  45913. /* nic->packetlen should contain length of data */
  45914. int packet_received = 0;
  45915. +#if defined(W89C840_DEBUG)
  45916. u32 intr_status = readl(ioaddr + IntrStatus);
  45917. - /* handle_intr(intr_status); */ /* -- handled later */
  45918. +#endif
  45919. do {
  45920. /* Code from netdev_rx(dev) */
  45921. @@ -411,6 +401,11 @@
  45922. break;
  45923. }
  45924. + if ( !retrieve ) {
  45925. + packet_received = 1;
  45926. + break;
  45927. + }
  45928. +
  45929. if ((status & 0x38008300) != 0x0300) {
  45930. if ((status & 0x38000300) != 0x0300) {
  45931. /* Ingore earlier buffers. */
  45932. @@ -478,11 +473,7 @@
  45933. entry = (++w840private.cur_rx) % RX_RING_SIZE;
  45934. w840private.rx_head_desc = &w840private.rx_ring[entry];
  45935. } while (0);
  45936. -
  45937. - if (intr_status & (AbnormalIntr | TxFIFOUnderflow | IntrPCIErr |TimerInt | IntrTxStopped)) {
  45938. - handle_intr(intr_status);
  45939. - }
  45940. -
  45941. +
  45942. return packet_received;
  45943. }
  45944. @@ -521,13 +512,13 @@
  45945. w840private.tx_ring[entry].buffer1 = virt_to_le32desc(tx_packet);
  45946. - w840private.tx_ring[entry].length = (DescWholePkt | s);
  45947. + w840private.tx_ring[entry].length = (DescWholePkt | (u32) s);
  45948. if (entry >= TX_RING_SIZE-1) /* Wrap ring */
  45949. w840private.tx_ring[entry].length |= (DescIntr | DescEndRing);
  45950. w840private.tx_ring[entry].status = (DescOwn);
  45951. w840private.cur_tx++;
  45952. - w840private.tx_q_bytes += s;
  45953. + w840private.tx_q_bytes = (u16) s;
  45954. writel(0, ioaddr + TxStartDemand);
  45955. /* Work around horrible bug in the chip by marking the queue as full
  45956. @@ -550,33 +541,29 @@
  45957. load_timer2(TX_TIMEOUT);
  45958. {
  45959. +#if defined W89C840_DEBUG
  45960. u32 intr_stat = 0;
  45961. -
  45962. +#endif
  45963. while (1) {
  45964. - intr_stat = readl(ioaddr + IntrStatus);
  45965. #if defined(W89C840_DEBUG)
  45966. - decode_interrupt(intr_stat);
  45967. + decode_interrupt(intr_stat);
  45968. #endif
  45969. - if (intr_stat & (NormalIntr | IntrTxDone)) {
  45970. -
  45971. while ( (transmit_status & DescOwn) && timer2_running()) {
  45972. transmit_status = w840private.tx_ring[entry].status;
  45973. }
  45974. - writel(intr_stat & 0x0001ffff, ioaddr + IntrStatus);
  45975. break;
  45976. - }
  45977. }
  45978. }
  45979. if ((transmit_status & DescOwn) == 0) {
  45980. #if defined(W89C840_DEBUG)
  45981. - printf("winbond-840 : transmission complete after %d wait loop iterations, status %X\n",
  45982. - TX_LOOP_COUNT - transmit_loop_counter, w840private.tx_ring[entry].status);
  45983. + printf("winbond-840 : transmission complete after wait loop iterations, status %X\n",
  45984. + w840private.tx_ring[entry].status);
  45985. #endif
  45986. return;
  45987. @@ -592,8 +579,12 @@
  45988. /**************************************************************************
  45989. w89c840_disable - Turn off ethernet interface
  45990. ***************************************************************************/
  45991. -static void w89c840_disable(struct nic *nic)
  45992. +static void w89c840_disable(struct dev *dev)
  45993. {
  45994. + struct nic *nic = (struct nic *)dev;
  45995. + /* merge reset and disable */
  45996. + w89c840_reset(nic);
  45997. +
  45998. /* Don't know what to do to disable the board. Is this needed at all? */
  45999. /* Yes, a live NIC can corrupt the loaded memory later [Ken] */
  46000. /* Stop the chip's Tx and Rx processes. */
  46001. @@ -601,20 +592,37 @@
  46002. }
  46003. /**************************************************************************
  46004. +w89c840_irq - Enable, Disable, or Force interrupts
  46005. +***************************************************************************/
  46006. +static void w89c840_irq(struct nic *nic __unused, irq_action_t action __unused)
  46007. +{
  46008. + switch ( action ) {
  46009. + case DISABLE :
  46010. + break;
  46011. + case ENABLE :
  46012. + break;
  46013. + case FORCE :
  46014. + break;
  46015. + }
  46016. +}
  46017. +
  46018. +/**************************************************************************
  46019. w89c840_probe - Look for an adapter, this routine's visible to the outside
  46020. ***************************************************************************/
  46021. -struct nic *w89c840_probe(struct nic *nic, unsigned short *probe_addrs, struct pci_device *p)
  46022. +static int w89c840_probe(struct dev *dev, struct pci_device *p)
  46023. {
  46024. + struct nic *nic = (struct nic *)dev;
  46025. u16 sum = 0;
  46026. - int i, j, to;
  46027. + int i, j;
  46028. unsigned short value;
  46029. - int options;
  46030. - int promisc;
  46031. - if (probe_addrs == 0 || probe_addrs[0] == 0)
  46032. + if (p->ioaddr == 0)
  46033. return 0;
  46034. - ioaddr = probe_addrs[0]; /* Mask the bit that says "this is an io addr" */
  46035. + ioaddr = p->ioaddr;
  46036. + nic->ioaddr = p->ioaddr & ~3;
  46037. + nic->irqno = 0;
  46038. +
  46039. #if defined(W89C840_DEBUG)
  46040. printf("winbond-840: PCI bus %hhX device function %hhX: I/O address: %hX\n", p->bus, p->devfn, ioaddr);
  46041. @@ -622,8 +630,6 @@
  46042. ioaddr = ioaddr & ~3; /* Mask the bit that says "this is an io addr" */
  46043. - /* if probe_addrs is 0, then routine can use a hardwired default */
  46044. -
  46045. /* From Matt Hortman <mbhortman@acpthinclient.com> */
  46046. if (p->vendor == PCI_VENDOR_ID_WINBOND2
  46047. && p->dev_id == PCI_DEVICE_ID_WINBOND2_89C840) {
  46048. @@ -689,14 +695,14 @@
  46049. }
  46050. /* point to NIC specific routines */
  46051. - nic->reset = w89c840_reset;
  46052. - nic->poll = w89c840_poll;
  46053. + dev->disable = w89c840_disable;
  46054. + nic->poll = w89c840_poll;
  46055. nic->transmit = w89c840_transmit;
  46056. - nic->disable = w89c840_disable;
  46057. + nic->irq = w89c840_irq;
  46058. w89c840_reset(nic);
  46059. - return nic;
  46060. + return 1;
  46061. }
  46062. /* Read the EEPROM and MII Management Data I/O (MDIO) interfaces. These are
  46063. @@ -814,6 +820,7 @@
  46064. return (retval>>1) & 0xffff;
  46065. }
  46066. +#if 0
  46067. static void mdio_write(int base_address, int phy_id, int location, int value)
  46068. {
  46069. long mdio_addr = base_address + MIICtrl;
  46070. @@ -844,6 +851,7 @@
  46071. }
  46072. return;
  46073. }
  46074. +#endif
  46075. static void check_duplex(void)
  46076. {
  46077. @@ -877,12 +885,10 @@
  46078. memset(mc_filter, 0xff, sizeof(mc_filter));
  46079. /*
  46080. - * Actually, should work OK with multicast enabled. -- iko
  46081. - */
  46082. -/*
  46083. - * rx_mode = AcceptBroadcast | AcceptMyPhys | AcceptMulticast;
  46084. + * works OK with multicast enabled.
  46085. */
  46086. - rx_mode = AcceptBroadcast | AcceptMyPhys;
  46087. +
  46088. + rx_mode = AcceptBroadcast | AcceptMyPhys | AcceptMulticast;
  46089. writel(mc_filter[0], ioaddr + MulticastFilter0);
  46090. writel(mc_filter[1], ioaddr + MulticastFilter1);
  46091. @@ -932,3 +938,18 @@
  46092. }
  46093. return;
  46094. }
  46095. +
  46096. +
  46097. +static struct pci_id w89c840_nics[] = {
  46098. +PCI_ROM(0x1050, 0x0840, "winbond840", "Winbond W89C840F"),
  46099. +PCI_ROM(0x11f6, 0x2011, "compexrl100atx", "Compex RL100ATX"),
  46100. +};
  46101. +
  46102. +struct pci_driver w89c840_driver = {
  46103. + .type = NIC_DRIVER,
  46104. + .name = "W89C840F",
  46105. + .probe = w89c840_probe,
  46106. + .ids = w89c840_nics,
  46107. + .id_count = sizeof(w89c840_nics)/sizeof(w89c840_nics[0]),
  46108. + .class = 0,
  46109. +};
  46110. Index: b/stage2/disk_io.c
  46111. ===================================================================
  46112. --- a/stage2/disk_io.c
  46113. +++ b/stage2/disk_io.c
  46114. @@ -25,6 +25,7 @@
  46115. #ifdef SUPPORT_NETBOOT
  46116. # define GRUB 1
  46117. # include <etherboot.h>
  46118. +# include <grub.h>
  46119. #endif
  46120. #ifdef GRUB_UTIL