linux-2.6.23-nios2nommu.patch 729 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567
  1. diff --git a/arch/nios2nommu/ChangeLog b/arch/nios2nommu/ChangeLog
  2. new file mode 100644
  3. index 0000000..039c010
  4. --- /dev/null
  5. +++ b/arch/nios2nommu/ChangeLog
  6. @@ -0,0 +1,4 @@
  7. +2004-06-15 Ken Hill <khill@microtronix.com>
  8. +
  9. + * Kconfig: Add Microtronix uKit support.
  10. +
  11. diff --git a/arch/nios2nommu/Kconfig b/arch/nios2nommu/Kconfig
  12. new file mode 100644
  13. index 0000000..525c77b
  14. --- /dev/null
  15. +++ b/arch/nios2nommu/Kconfig
  16. @@ -0,0 +1,403 @@
  17. +#
  18. +# For a description of the syntax of this configuration file,
  19. +# see the Configure script.
  20. +#
  21. +mainmenu 'uClinux/Nios2 (w/o MMU) Kernel Configuration'
  22. +
  23. +config MMU
  24. + bool
  25. + default n
  26. +
  27. +config FPU
  28. + bool
  29. + default n
  30. +
  31. +config ZONE_DMA
  32. + bool
  33. + default y
  34. +
  35. +config UID16
  36. + bool
  37. + default y
  38. +
  39. +config RWSEM_GENERIC_SPINLOCK
  40. + bool
  41. + default y
  42. +
  43. +config RWSEM_XCHGADD_ALGORITHM
  44. + bool
  45. + default n
  46. +
  47. +config GENERIC_FIND_NEXT_BIT
  48. + bool
  49. + default y
  50. +
  51. +config GENERIC_HWEIGHT
  52. + bool
  53. + default y
  54. +
  55. +config GENERIC_CALIBRATE_DELAY
  56. + bool
  57. + default y
  58. +
  59. +source "init/Kconfig"
  60. +
  61. +menu "Processor type and features"
  62. +
  63. +comment 'Platform dependant setup'
  64. +
  65. +choice
  66. + prompt "CPU"
  67. + default NIOS2
  68. +
  69. +config NIOS2
  70. + bool "NIOS2"
  71. + help
  72. + Altera Nios2 softcore processor.
  73. +
  74. +endchoice
  75. +
  76. +choice
  77. + prompt "Platform"
  78. + default ALTERA_STRATIX
  79. +
  80. +config MICROTRONIX_UKIT
  81. + bool "Microtronix uKit board support"
  82. + depends on NIOS2
  83. + help
  84. + Support for the Microtronix uKit development board. Includes support
  85. + for Sodimm SDRAM/FLASH, soft ethernet MAC & PHY.
  86. +
  87. +config MICROTRONIX_STRATIX
  88. + bool "Microtronix Stratix board support"
  89. + depends on NIOS2
  90. + help
  91. + Support for the Microtronix Stratix board. Includes support
  92. + for Sodimm SDRAM/FLASH, soft ethernet MAC & PHY, USB, LVDS
  93. + & analog/digital converters.
  94. +
  95. +config MICROTRONIX_CYCLONE
  96. + bool "Microtronix Cyclone board support"
  97. + depends on NIOS2
  98. + help
  99. + Support for the Microtronix Cyclone board. Includes support
  100. + for SDRAM, FLASH, soft ethernet MAC & PHY, USB,
  101. + & analog/digital converters.
  102. +
  103. +config MICROTRONIX_PSK
  104. + bool "Microtronix PSK (Product Starter Kit) support"
  105. + depends on NIOS2
  106. + help
  107. + Support for the Microtronix PSK (Product Starter Kit), which
  108. + features firefly module (EP1C4 or EP1C12). Includes support
  109. + for SDRAM, FLASH, and a variety of product expansion kits such
  110. + as USB, Ethernet etc.
  111. +
  112. +config ALTERA_STRATIX
  113. + bool "Altera Stratix Development board support"
  114. + depends on NIOS2
  115. + help
  116. + Support for the Altera Stratix Development board. Includes
  117. + support for 10/100 ethernet, FLASH, SDRAM, compact flash.
  118. +
  119. +config ALTERA_STRATIX_PRO
  120. + bool "Altera Stratix Pro Development board support"
  121. + depends on NIOS2
  122. + help
  123. + Support for the Altera Stratix 1s40 Development board. Includes
  124. + support for 10/100 ethernet, FLASH, SDRAM, compact flash.
  125. +
  126. +config ALTERA_STRATIX_II
  127. + bool "Altera Stratix II Development board support"
  128. + depends on NIOS2
  129. + help
  130. + Support for the Altera Stratix II Development board. Includes
  131. + support for 10/100 ethernet, FLASH, SDRAM, compact flash.
  132. +
  133. +config ALTERA_CYCLONE
  134. + bool "Altera Cyclone Development board support"
  135. + depends on NIOS2
  136. + help
  137. + Support for the Altera Cyclone Development board. Includes
  138. + support for 10/100 ethernet, FLASH, SDRAM, compact flash.
  139. +
  140. +config ALTERA_CYCLONE_1C12_EVAL
  141. + bool "Altera Cyclone 1C12 Evaluation board support"
  142. + depends on NIOS2
  143. + help
  144. + Support for the Altera Cyclone 1C12 Evaluation board (with the
  145. + embedded processor module).
  146. +
  147. +config ALTERA_DE2
  148. + bool "Altera DE2 Development board support"
  149. + depends on NIOS2
  150. + help
  151. + Support for the Altera Cyclone Development board. Includes
  152. + support for 10/100 ethernet, FLASH, SDRAM, VGA, I2C.
  153. +
  154. +endchoice
  155. +
  156. +choice
  157. + prompt "Nios II Hardware Multiply Support"
  158. + default NIOS2_HW_MULX
  159. + help
  160. + This option enables various assembler instructions based on your
  161. + selection. The choice depends on what target hardware you'll be
  162. + running your applications on. The default is
  163. + "Enable mulx instruction".
  164. +
  165. + Here is an explanation of each option:
  166. + None = -mno-hw-mul -mno-hw-mulx
  167. + (no mul or mulx instructions used)
  168. + Enable mul instruction = -mhw-mul -mno-hw-mulx
  169. + (use mul instructions)
  170. + Enable mul and mulx instructions = -mhw-mul -mhw-mulx
  171. + (use mul and mulx instructions)
  172. +
  173. + If you don't know what to choose, select "Enable mulx instruction".
  174. +
  175. +config NIOS2_HW_MUL_OFF
  176. + bool "None"
  177. +
  178. +config NIOS2_HW_MUL
  179. + bool "Enable mul instruction"
  180. +
  181. +config NIOS2_HW_MULX
  182. + bool "Enable mul and mulx instructions"
  183. +
  184. +endchoice
  185. +
  186. +comment 'Platform drivers Options'
  187. +
  188. +config AVALON_DMA
  189. + bool "Support of DMA controller with Avalon interface"
  190. + default y
  191. + help
  192. + This enables support of Altera's DMA controller with Avalon
  193. + interface, so that drivers of DMA-able device can use this
  194. + interface.
  195. +
  196. +config PIO_DEVICES
  197. + bool "Enable leds, seven segment display"
  198. + default y
  199. + depends on (ALTERA_STRATIX || ALTERA_STRATIX_PRO || ALTERA_CYCLONE)
  200. + help
  201. + This enables example code to support leds, and seven segment
  202. + display as PIO devices. Once enabled, the kernel will show a
  203. + counter (increas once a second) on these devices.
  204. +
  205. +source "arch/nios2nommu/drivers/Kconfig"
  206. +
  207. +comment 'Miscellaneous Options'
  208. +
  209. +config EXCALIBUR
  210. + bool
  211. + default y
  212. + depends on (NIOS2)
  213. +
  214. +config BREAK_ON_START
  215. + bool "Include breakpoint trap on kernel startup"
  216. + help
  217. + Configures the kernel to trap to the GDB client on startup
  218. + before the kernel starts initialization. This allows you to
  219. + debug the kernel startup.
  220. +
  221. +config LARGE_ALLOCS
  222. + bool "Allow allocating large blocks (> 1MB) of memory"
  223. + help
  224. + Allow the slab memory allocator to keep chains for very large
  225. + memory sizes - upto 32MB. You may need this if your system has
  226. + a lot of RAM, and you need to able to allocate very large
  227. + contiguous chunks. If unsure, say N.
  228. +
  229. +choice
  230. + prompt "Kernel executes from"
  231. + ---help---
  232. + Choose the memory type that the kernel will be running in.
  233. +
  234. +config RAMKERNEL
  235. + bool "RAM"
  236. + help
  237. + The kernel will be resident in RAM when running.
  238. +
  239. +#config ROMKERNEL
  240. +# bool "ROM"
  241. +# help
  242. +# The kernel will be resident in FLASH/ROM when running.
  243. +
  244. +#config HIMEMKERNEL
  245. +# bool "HIMEM"
  246. +# help
  247. +# The kernel will be resident in high memory when running.
  248. +
  249. +endchoice
  250. +
  251. +config PREEMPT
  252. + bool "Preemptible Kernel"
  253. + help
  254. + This option reduces the latency of the kernel when reacting to
  255. + real-time or interactive events by allowing a low priority process to
  256. + be preempted even if it is in kernel mode executing a system call.
  257. + This allows applications to run more reliably even when the system is
  258. + under load.
  259. +
  260. + Say Y here if you are building a kernel for a desktop, embedded
  261. + or real-time system. Say N if you are unsure.
  262. +
  263. +config PREEMPT_TIMES
  264. + bool "Collect preemption latency times"
  265. + depends on PREEMPT
  266. + help
  267. + Allow collection for preemption latency times.
  268. +
  269. +config CMDLINE
  270. + string "Default kernel command string"
  271. + default "CONSOLE=/dev/ttyS0 root=/dev/rom0 ro"
  272. + help
  273. + On some architectures, there is currently no way
  274. + for the boot loader to pass arguments to the kernel. For these
  275. + architectures, you should supply some command-line options at build
  276. + time by entering them here. As a minimum, you should specify the
  277. + memory size and the root device (e.g., mem=64M root=/dev/nfs).
  278. +
  279. +config PASS_CMDLINE
  280. + bool "Passed kernel command line from u-boot"
  281. + default n
  282. + help
  283. + Use bootargs env variable from u-boot for kernel command line.
  284. + will override "Default kernel command string".
  285. + Say N if you are unsure.
  286. +
  287. +source "mm/Kconfig"
  288. +
  289. +config BOOT_LINK_OFFSET
  290. + hex "Link address offset for booting"
  291. + default "0x00800000"
  292. + help
  293. + This option allows you to set the link address offset of the zImage.
  294. + This can be useful if you are on a board which has a small amount of
  295. + memory.
  296. +
  297. +endmenu
  298. +
  299. +menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
  300. +
  301. +config PCI
  302. + bool "PCI support"
  303. + help
  304. + Support for PCI bus.
  305. +
  306. +source "drivers/pci/Kconfig"
  307. +
  308. +config HOTPLUG
  309. + bool "Support for hot-pluggable device"
  310. + ---help---
  311. + Say Y here if you want to plug devices into your computer while
  312. + the system is running, and be able to use them quickly. In many
  313. + cases, the devices can likewise be unplugged at any time too.
  314. +
  315. + One well known example of this is PCMCIA- or PC-cards, credit-card
  316. + size devices such as network cards, modems or hard drives which are
  317. + plugged into slots found on all modern laptop computers. Another
  318. + example, used on modern desktops as well as laptops, is USB.
  319. +
  320. + Enable HOTPLUG and KMOD, and build a modular kernel. Get agent
  321. + software (at <http://linux-hotplug.sourceforge.net/>) and install it.
  322. + Then your kernel will automatically call out to a user mode "policy
  323. + agent" (/sbin/hotplug) to load modules and set up software needed
  324. + to use devices as you hotplug them.
  325. +
  326. +source "drivers/pcmcia/Kconfig"
  327. +
  328. +source "drivers/pci/hotplug/Kconfig"
  329. +
  330. +endmenu
  331. +
  332. +menu "Executable file formats"
  333. +
  334. +config KCORE_AOUT
  335. + bool
  336. + default y
  337. +
  338. +config KCORE_ELF
  339. + bool
  340. + default y
  341. +
  342. +source "fs/Kconfig.binfmt"
  343. +
  344. +endmenu
  345. +
  346. +menu "Power management options"
  347. +
  348. +config PM
  349. + bool "Power Management support"
  350. + help
  351. + Support processor power management modes
  352. +
  353. +endmenu
  354. +
  355. +
  356. +source "net/Kconfig"
  357. +
  358. +source "drivers/Kconfig"
  359. +
  360. +source "fs/Kconfig"
  361. +
  362. +source "arch/nios2nommu/Kconfig.debug"
  363. +
  364. +menu "Kernel hacking"
  365. +
  366. +config FULLDEBUG
  367. + bool "Full Symbolic/Source Debugging support"
  368. + help
  369. + Enable debuging symbols on kernel build.
  370. +
  371. +config FRAME_POINTER
  372. + bool "Compile the kernel with frame pointers"
  373. + help
  374. + If you say Y here the resulting kernel image will be slightly larger
  375. + and slower, but it will give very useful debugging information.
  376. + If you don't debug the kernel, you can say N, but we may not be able
  377. + to solve problems without frame pointers.
  378. +
  379. +config MAGIC_SYSRQ
  380. + bool "Magic SysRq key"
  381. + help
  382. + Enables console device to interpret special characters as
  383. + commands to dump state information.
  384. +
  385. +config HIGHPROFILE
  386. + bool "Use fast second timer for profiling"
  387. + depends on COLDFIRE
  388. + help
  389. + Use a fast secondary clock to produce profiling information.
  390. +
  391. +config NO_KERNEL_MSG
  392. + bool "Suppress Kernel BUG Messages"
  393. + help
  394. + Do not output any debug BUG messages within the kernel.
  395. +
  396. +config LOG_BUF_SHIFT
  397. + int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" if DEBUG_KERNEL
  398. + range 12 21
  399. + default 17 if ARCH_S390
  400. + default 16 if X86_NUMAQ || IA64
  401. + default 15 if SMP
  402. + default 14
  403. + help
  404. + Select kernel log buffer size as a power of 2.
  405. + Defaults and Examples:
  406. + 17 => 128 KB for S/390
  407. + 16 => 64 KB for x86 NUMAQ or IA-64
  408. + 15 => 32 KB for SMP
  409. + 14 => 16 KB for uniprocessor
  410. + 13 => 8 KB
  411. + 12 => 4 KB
  412. +
  413. +endmenu
  414. +
  415. +source "security/Kconfig"
  416. +
  417. +source "crypto/Kconfig"
  418. +
  419. +source "lib/Kconfig"
  420. diff --git a/arch/nios2nommu/Kconfig.debug b/arch/nios2nommu/Kconfig.debug
  421. new file mode 100644
  422. index 0000000..b188c4a
  423. --- /dev/null
  424. +++ b/arch/nios2nommu/Kconfig.debug
  425. @@ -0,0 +1,35 @@
  426. +menu "Kernel hacking"
  427. +
  428. +source "lib/Kconfig.debug"
  429. +
  430. +config FULLDEBUG
  431. + bool "Full Symbolic/Source Debugging support"
  432. + help
  433. + Enable debuging symbols on kernel build.
  434. +
  435. +config FRAME_POINTER
  436. + bool "Compile the kernel with frame pointers"
  437. + help
  438. + If you say Y here the resulting kernel image will be slightly larger
  439. + and slower, but it will give very useful debugging information.
  440. + If you don't debug the kernel, you can say N, but we may not be able
  441. + to solve problems without frame pointers.
  442. +
  443. +config MAGIC_SYSRQ
  444. + bool "Magic SysRq key"
  445. + help
  446. + Enables console device to interpret special characters as
  447. + commands to dump state information.
  448. +
  449. +config HIGHPROFILE
  450. + bool "Use fast second timer for profiling"
  451. + depends on COLDFIRE
  452. + help
  453. + Use a fast secondary clock to produce profiling information.
  454. +
  455. +config NO_KERNEL_MSG
  456. + bool "Suppress Kernel BUG Messages"
  457. + help
  458. + Do not output any debug BUG messages within the kernel.
  459. +
  460. +endmenu
  461. diff --git a/arch/nios2nommu/Makefile b/arch/nios2nommu/Makefile
  462. new file mode 100644
  463. index 0000000..ca139b6
  464. --- /dev/null
  465. +++ b/arch/nios2nommu/Makefile
  466. @@ -0,0 +1,181 @@
  467. +# arch/niosnommu/Makefile
  468. +#
  469. +# Makefile for the architecture dependent flags and dependencies on the
  470. +# nios.
  471. +#
  472. +# Copyright (C) 2001 Vic Phillips (vic@microtronix.com)
  473. +#
  474. +# based on sparcnommu/Makefile:
  475. +#
  476. +# Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
  477. +#
  478. +KERNELLOAD = ${shell echo `grep "nasys_program_mem " include/asm/nios.h | sed 's/^.*\*)//' | sed 's/)//'`}
  479. +
  480. +HARDWARE_MK = arch/$(ARCH)/hardware.mk
  481. +
  482. +platform-$(CONFIG_NIOS) := NIOS2
  483. +PLATFORM := $(platform-y)
  484. +
  485. +board-$(CONFIG_ALTERA_STRATIX) := altera_stratix
  486. +board-$(CONFIG_ALTERA_STRATIX_PRO) := altera_stratix_pro
  487. +board-$(CONFIG_ALTERA_STRATIX_II) := altera_stratix_ii
  488. +board-$(CONFIG_ALTERA_CYCLONE) := altera_cyclone
  489. +board-$(CONFIG_ALTERA_CYCLONE_1C12_EVAL) := altera_cyclone_1c12_eval
  490. +board-$(CONFIG_MICROTRONIX_STRATIX) := microtronix_stratix
  491. +board-$(CONFIG_MICROTRONIX_CYCLONE) := microtronix_cyclone
  492. +board-$(CONFIG_MICROTRONIX_UKIT) := microtronix_ukit
  493. +board-$(CONFIG_MICROTRONIX_PSK) := microtronix_psk
  494. +BOARD := $(board-y)
  495. +
  496. +model-$(CONFIG_RAMKERNEL) := ram
  497. +model-$(CONFIG_ROMKERNEL) := rom
  498. +model-$(CONFIG_HIMEMKERNEL) := himem
  499. +MODEL := $(model-y)
  500. +
  501. +export PLATFORM BOARD MODEL
  502. +
  503. +CFLAGS += -DNO_MM -pipe -D__linux__ -D__ELF__
  504. +#CFLAGS += -DNO_MM -save-temps -D__linux__ -D__ELF__
  505. +
  506. +# Uncomment this if you are doing gdb source level
  507. +# debugging of the kernel to get the proper debugging information.
  508. +#
  509. +#CFLAGS += -DDEBUG
  510. +
  511. +# Turn on/off various hardware multiply options
  512. +cpu-cflags-$(CONFIG_NIOS2_HW_MUL_OFF) += -mno-hw-mul -mno-hw-mulx
  513. +cpu-cflags-$(CONFIG_NIOS2_HW_MUL) += -mhw-mul -mno-hw-mulx
  514. +cpu-cflags-$(CONFIG_NIOS2_HW_MULX) += -mhw-mul -mhw-mulx
  515. +CFLAGS += $(cpu-cflags-y)
  516. +
  517. +# mulx flags currently cause older version of nios2-elf-gcc to fail
  518. +# The following line ensures that all mulx flags are removed before
  519. +# it is passed to the compiler.
  520. +mulx_help_text:= $(shell $(CC) --target-help | grep mulx)
  521. +ifeq "$(mulx_help_text)" ""
  522. +CFLAGS := $(filter-out -mhw-mulx -mno-hw-mulx, $(CFLAGS))
  523. +endif
  524. +
  525. +# Temporary workaround for nios2-elf-gcc bug
  526. +# First noticed in v3.4.1 (Altera Nios II 1.1 b131)
  527. +# To be removed at a later date when bug is resolved.
  528. +CFLAGS += -fno-optimize-sibling-calls
  529. +
  530. +# This undefines the "__init" type used in defining initialization
  531. +# procedures. When defined, the procedures are put into an 'init' data
  532. +# section that GDB doesn't recognize as source.
  533. +#
  534. +CFLAGS += -DNO_TEXT_SECTIONS
  535. +CFLAGS += -fno-builtin
  536. +CFLAGS += -O2 -g -G 0
  537. +CFLAGS += -DUTS_SYSNAME=\"uClinux\"
  538. +
  539. +CFLAGS_GCC_INC := $(shell $(CC) -print-file-name=include)
  540. +CFLAGS += -I$(CFLAGS_GCC_INC)
  541. +
  542. +AFLAGS += -DNO_MM -g
  543. +#AFLAGS += -DNO_MM -g -save-temps
  544. +
  545. +# vic - add this to get name of nios gcc library
  546. +LIBGCC_CFLAGS = $(if $(CONFIG_NIOS2_HW_MUL_OFF),-mno-hw-mul)
  547. +LIBGCC := `$(CC) --print-libgcc-file-name $(LIBGCC_CFLAGS)`
  548. +
  549. +# add this to avoid multiple '_stack' and '_vecbase' definition errors
  550. +#
  551. +ifdef niosgnu
  552. +# Include the path to the lib directory where the ldscripts are found to fix
  553. +# a problem with the cygwin/bash environment.
  554. +
  555. +#cygwhack: kenw - this following section could be a possible problem
  556. +# due to the O= option on the command line.
  557. +LDSCRIPTS:=$(shell nios2-elf-gcc -print-file-name=ldscripts)
  558. +LDFLAGS += -mnios2elf -L $(LDSCRIPTS)/..
  559. +else
  560. +LDFLAGS += -mnios2elf
  561. +LDLIBS := -L `$(CC) -print-file-name=m32` -l gcc
  562. +endif
  563. +
  564. +head-y := arch/nios2nommu/kernel/head.o arch/nios2nommu/kernel/init_task.o
  565. +
  566. +CLEAN_FILES := include/asm-$(ARCH)/asm-offsets.h \
  567. + $(HARDWARE_MK) \
  568. + arch/$(ARCH)/kernel/asm-offsets.s \
  569. + linux.srec \
  570. + linux.flash \
  571. + linux.bin \
  572. + linux.bin.srec
  573. +
  574. +core-y += arch/nios2nommu/kernel/ \
  575. + arch/nios2nommu/mm/ \
  576. + arch/nios2nommu/drivers/
  577. +
  578. +libs-y += arch/nios2nommu/lib/
  579. +
  580. +libs-y += $(LIBGCC)
  581. +####;dgt2;tmp;
  582. +
  583. +# force user to configure hardware before building kernel
  584. +
  585. +pardoned_targets = clean mrproper sgmldocs psdocs pdfdocs \
  586. + htmldocs mandocs headers_install
  587. +
  588. +-include $(HARDWARE_MK)
  589. +build_targets = $(filter-out $(pardoned_targets), $(MAKECMDGOALS))
  590. +ifneq '$(strip $(build_targets))' ''
  591. + ifndef SYSPTF
  592. + ifneq '$(firstword $(MAKECMDGOALS))' 'hwselect'
  593. + $(error Run "make hwselect SYSPTF=<system.ptf>" first)
  594. + endif
  595. + endif
  596. +endif
  597. +
  598. +quiet_cmd_gen_mk = ' RUNNING $@'
  599. +define cmd_gen_mk
  600. + mkdir -p $(dir $(objtree)/$(HARDWARE_MK)); \
  601. + perl -I$(TOPDIR)/arch/$(ARCH)/scripts \
  602. + $(srctree)/arch/$(ARCH)/scripts/hwselect.pl $(SYSPTF) \
  603. + $(objtree)/$(HARDWARE_MK)
  604. +endef
  605. +
  606. +.PHONY: hwselect
  607. +hwselect:
  608. + @echo $($(quiet)cmd_gen_mk);
  609. + @$(cmd_gen_mk)
  610. +
  611. +prepare: include/nios2_system.h
  612. +
  613. +archclean:
  614. + $(call descend arch/$(ARCH)/boot, subdirclean)
  615. +
  616. +define filechk_nios2_system.h
  617. + # call perl script that will build nios2_system.h file
  618. + perl -I$(TOPDIR)/arch/$(ARCH)/scripts \
  619. + $(TOPDIR)/arch/$(ARCH)/scripts/gen_nios2_system.h.pl $(CPU) $(EXEMEM) $(UPLMEM)
  620. +endef
  621. +
  622. +include/nios2_system.h: $(SYSPTF) FORCE
  623. + $(call filechk,nios2_system.h)
  624. +
  625. +quiet_cmd_touch = ' TOUCH $@'
  626. + cmd_touch = touch $(TOPDIR)/$@
  627. +
  628. +arch/$(ARCH)/kernel/vmlinux.lds.S: FORCE
  629. + @echo $($(quiet)cmd_touch);
  630. + @$(cmd_touch)
  631. +
  632. +linuxsrec: linux
  633. + $(OBJCOPY) -O srec $(LINUX) linux.srec
  634. +
  635. +boot := arch/nios2nommu/boot
  636. +
  637. +zImage: vmlinux
  638. + $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  639. +
  640. +compressed: zImage
  641. +
  642. +CLEAN_FILES += include/nios2_system.h
  643. +
  644. +archmrproper:
  645. +
  646. +archdep:
  647. +
  648. diff --git a/arch/nios2nommu/boot/Makefile b/arch/nios2nommu/boot/Makefile
  649. new file mode 100644
  650. index 0000000..fd25b72
  651. --- /dev/null
  652. +++ b/arch/nios2nommu/boot/Makefile
  653. @@ -0,0 +1,17 @@
  654. +#
  655. +# arch/nios2nommu/boot/Makefile
  656. +#
  657. +# This file is subject to the terms and conditions of the GNU General Public
  658. +# License. See the file "COPYING" in the main directory of this archive
  659. +# for more details.
  660. +
  661. +targets := zImage
  662. +subdir- := compressed
  663. +
  664. +$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
  665. + $(call if_changed,objcopy)
  666. + @echo 'Kernel: $@ is ready'
  667. +
  668. +$(obj)/compressed/vmlinux: FORCE
  669. + $(Q)$(MAKE) $(build)=$(obj)/compressed $@
  670. +
  671. diff --git a/arch/nios2nommu/boot/compressed/Makefile b/arch/nios2nommu/boot/compressed/Makefile
  672. new file mode 100644
  673. index 0000000..2002471
  674. --- /dev/null
  675. +++ b/arch/nios2nommu/boot/compressed/Makefile
  676. @@ -0,0 +1,36 @@
  677. +#
  678. +# linux/arch/sh/boot/compressed/Makefile
  679. +#
  680. +# create a compressed vmlinux image from the original vmlinux
  681. +#
  682. +
  683. +targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o \
  684. + piggy.o vmlinux.lds
  685. +EXTRA_AFLAGS :=
  686. +
  687. +OBJECTS = $(obj)/head.o $(obj)/misc.o
  688. +
  689. +#
  690. +# IMAGE_OFFSET is the load offset of the compression loader
  691. +#
  692. +#IMAGE_OFFSET := $(shell printf "0x%08x" $$[$(CONFIG_MEMORY_START)+0x2000])
  693. +#IMAGE_OFFSET := $(shell printf "0x%08x" $$[$(CONFIG_MEMORY_START)+0x00400000])
  694. +
  695. +LDFLAGS_vmlinux := -T
  696. +
  697. +$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(obj)/piggy.o FORCE
  698. + $(call if_changed,ld)
  699. + @:
  700. +
  701. +$(obj)/vmlinux.bin: vmlinux FORCE
  702. + $(call if_changed,objcopy)
  703. +
  704. +$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
  705. + $(call if_changed,gzip)
  706. +
  707. +LDFLAGS_piggy.o := -r --format binary --oformat elf32-littlenios2 -T
  708. +
  709. +OBJCOPYFLAGS += -O binary
  710. +
  711. +$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
  712. + $(call if_changed,ld)
  713. diff --git a/arch/nios2nommu/boot/compressed/head.S b/arch/nios2nommu/boot/compressed/head.S
  714. new file mode 100644
  715. index 0000000..accadd0
  716. --- /dev/null
  717. +++ b/arch/nios2nommu/boot/compressed/head.S
  718. @@ -0,0 +1,100 @@
  719. +/*
  720. + * linux/arch/nios2nommu/boot/compressed/head.S
  721. + *
  722. + */
  723. +
  724. + .text
  725. + .set noat
  726. +#include <asm/asm-offsets.h>
  727. +#include <asm/asm-macros.h>
  728. +
  729. + /*
  730. + * This code can be loaded anywhere, as long as output will not
  731. + * overlap it.
  732. + *
  733. + */
  734. +
  735. + .global _start
  736. +_start:
  737. + // disable interrupt
  738. + wrctl status, r0
  739. + // flush the instruction cache
  740. + movia r1,NIOS2_ICACHE_SIZE
  741. + movi r2,NIOS2_ICACHE_LINE_SIZE
  742. +text_init:
  743. + initi r1
  744. + sub r1, r1, r2
  745. + bgt r1, zero, text_init
  746. + // then flush the pipeline
  747. + flushp
  748. + // flush the data cache
  749. + movia r1,NIOS2_DCACHE_SIZE
  750. + movi r2,NIOS2_DCACHE_LINE_SIZE
  751. +data_init:
  752. + initd (r1)
  753. + sub r1, r1, r2
  754. + bgt r1, zero, data_init
  755. + //------------------------------------------------------
  756. + // Zero out the .bss segment (uninitialized common data)
  757. + //
  758. + movia r2,__bss_start // presume nothing is between
  759. + movia r1,_end // the .bss and _end.
  760. +1:
  761. + stb r0,0(r2)
  762. + addi r2,r2,1
  763. + bne r1,r2,1b
  764. + // set up the stack pointer, some where higher than _end. The stack space must be greater than 32K for decompress.
  765. + movia sp, 0x10000
  766. + add sp,sp,r1
  767. + // save args passed from u-boot
  768. + addi sp,sp,-16
  769. + stw r4,0(sp)
  770. + stw r5,4(sp)
  771. + stw r6,8(sp)
  772. + stw r7,12(sp)
  773. +/*
  774. + * decompress the kernel
  775. + */
  776. + call decompress_kernel
  777. +
  778. +flush_cache:
  779. + // flush all cache after loading
  780. + // flush the data cache
  781. + movia r1,NIOS2_DCACHE_SIZE
  782. + movi r2,NIOS2_DCACHE_LINE_SIZE
  783. +data_flush:
  784. + flushd (r1)
  785. + sub r1, r1, r2
  786. + bgt r1, zero, data_flush
  787. + // flush the instruction cache
  788. + movia r1,NIOS2_ICACHE_SIZE
  789. + movi r2,NIOS2_ICACHE_LINE_SIZE
  790. +text_flush:
  791. + flushi r1
  792. + sub r1, r1, r2
  793. + bgt r1, zero, text_flush
  794. + // then flush the pipeline
  795. + flushp
  796. + // pass saved args to kernel
  797. + ldw r4,0(sp)
  798. + ldw r5,4(sp)
  799. + ldw r6,8(sp)
  800. + ldw r7,12(sp)
  801. + movia r1,LINUX_SDRAM_START
  802. + jmp r1
  803. +
  804. + .balign 512
  805. +fake_headers_as_bzImage:
  806. + .short 0
  807. + .ascii "HdrS"
  808. + .short 0x0202
  809. + .short 0
  810. + .short 0
  811. + .byte 0x00, 0x10
  812. + .short 0
  813. + .byte 0
  814. + .byte 1
  815. + .byte 0x00, 0x80
  816. + .long 0
  817. + .long 0
  818. +
  819. diff --git a/arch/nios2nommu/boot/compressed/install.sh b/arch/nios2nommu/boot/compressed/install.sh
  820. new file mode 100644
  821. index 0000000..6d72e9e
  822. --- /dev/null
  823. +++ b/arch/nios2nommu/boot/compressed/install.sh
  824. @@ -0,0 +1,57 @@
  825. +#!/bin/sh
  826. +#
  827. +# arch/sh/boot/install.sh
  828. +#
  829. +# This file is subject to the terms and conditions of the GNU General Public
  830. +# License. See the file "COPYING" in the main directory of this archive
  831. +# for more details.
  832. +#
  833. +# Copyright (C) 1995 by Linus Torvalds
  834. +#
  835. +# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
  836. +# Adapted from code in arch/i386/boot/install.sh by Russell King
  837. +# Adapted from code in arch/arm/boot/install.sh by Stuart Menefy
  838. +# Adapted from code in arch/sh/boot/install.sh by Takeo Takahashi
  839. +#
  840. +# "make install" script for sh architecture
  841. +#
  842. +# Arguments:
  843. +# $1 - kernel version
  844. +# $2 - kernel image file
  845. +# $3 - kernel map file
  846. +# $4 - default install path (blank if root directory)
  847. +#
  848. +
  849. +# User may have a custom install script
  850. +
  851. +if [ -x /sbin/installkernel ]; then
  852. + exec /sbin/installkernel "$@"
  853. +fi
  854. +
  855. +if [ "$2" = "zImage" ]; then
  856. +# Compressed install
  857. + echo "Installing compressed kernel"
  858. + if [ -f $4/vmlinuz-$1 ]; then
  859. + mv $4/vmlinuz-$1 $4/vmlinuz.old
  860. + fi
  861. +
  862. + if [ -f $4/System.map-$1 ]; then
  863. + mv $4/System.map-$1 $4/System.old
  864. + fi
  865. +
  866. + cat $2 > $4/vmlinuz-$1
  867. + cp $3 $4/System.map-$1
  868. +else
  869. +# Normal install
  870. + echo "Installing normal kernel"
  871. + if [ -f $4/vmlinux-$1 ]; then
  872. + mv $4/vmlinux-$1 $4/vmlinux.old
  873. + fi
  874. +
  875. + if [ -f $4/System.map ]; then
  876. + mv $4/System.map $4/System.old
  877. + fi
  878. +
  879. + cat $2 > $4/vmlinux-$1
  880. + cp $3 $4/System.map
  881. +fi
  882. diff --git a/arch/nios2nommu/boot/compressed/misc.c b/arch/nios2nommu/boot/compressed/misc.c
  883. new file mode 100644
  884. index 0000000..c513e6e
  885. --- /dev/null
  886. +++ b/arch/nios2nommu/boot/compressed/misc.c
  887. @@ -0,0 +1,208 @@
  888. +/*
  889. + * arch/nios2nommu/boot/compressed/misc.c
  890. + *
  891. + * This is a collection of several routines from gzip-1.0.3
  892. + * adapted for Linux.
  893. + *
  894. + * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
  895. + *
  896. + * Adapted for SH by Stuart Menefy, Aug 1999
  897. + *
  898. + * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000
  899. + */
  900. +
  901. +#include <linux/string.h>
  902. +
  903. +/*
  904. + * gzip declarations
  905. + */
  906. +
  907. +#define OF(args) args
  908. +#define STATIC static
  909. +
  910. +#undef memset
  911. +#undef memcpy
  912. +#define memzero(s, n) memset ((s), 0, (n))
  913. +
  914. +typedef unsigned char uch;
  915. +typedef unsigned short ush;
  916. +typedef unsigned long ulg;
  917. +
  918. +#define WSIZE 0x8000 /* Window size must be at least 32k, */
  919. + /* and a power of two */
  920. +
  921. +static uch *inbuf; /* input buffer */
  922. +static uch window[WSIZE]; /* Sliding window buffer */
  923. +
  924. +static unsigned insize = 0; /* valid bytes in inbuf */
  925. +static unsigned inptr = 0; /* index of next byte to be processed in inbuf */
  926. +static unsigned outcnt = 0; /* bytes in output buffer */
  927. +
  928. +/* gzip flag byte */
  929. +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
  930. +#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
  931. +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
  932. +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
  933. +#define COMMENT 0x10 /* bit 4 set: file comment present */
  934. +#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
  935. +#define RESERVED 0xC0 /* bit 6,7: reserved */
  936. +
  937. +#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
  938. +
  939. +/* Diagnostic functions */
  940. +#ifdef DEBUG
  941. +# define Assert(cond,msg) {if(!(cond)) error(msg);}
  942. +# define Trace(x) fprintf x
  943. +# define Tracev(x) {if (verbose) fprintf x ;}
  944. +# define Tracevv(x) {if (verbose>1) fprintf x ;}
  945. +# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
  946. +# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
  947. +#else
  948. +# define Assert(cond,msg)
  949. +# define Trace(x)
  950. +# define Tracev(x)
  951. +# define Tracevv(x)
  952. +# define Tracec(c,x)
  953. +# define Tracecv(c,x)
  954. +#endif
  955. +
  956. +static int fill_inbuf(void);
  957. +static void flush_window(void);
  958. +static void error(char *m);
  959. +static void gzip_mark(void **);
  960. +static void gzip_release(void **);
  961. +
  962. +extern char input_data[];
  963. +extern int input_len;
  964. +
  965. +static long bytes_out = 0;
  966. +static uch *output_data;
  967. +static unsigned long output_ptr = 0;
  968. +
  969. +#include "nios2_sio.c"
  970. +
  971. +static void *malloc(int size);
  972. +static void free(void *where);
  973. +static void error(char *m);
  974. +static void gzip_mark(void **);
  975. +static void gzip_release(void **);
  976. +
  977. +int puts(const char *);
  978. +
  979. +extern int _end;
  980. +static unsigned long free_mem_ptr;
  981. +static unsigned long free_mem_end_ptr;
  982. +
  983. +#define HEAP_SIZE 0x10000
  984. +
  985. +#include "../../../../lib/inflate.c"
  986. +
  987. +static void *malloc(int size)
  988. +{
  989. + void *p;
  990. +
  991. + if (size <0) error("Malloc error");
  992. + if (free_mem_ptr == 0) error("Memory error");
  993. +
  994. + free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
  995. +
  996. + p = (void *)free_mem_ptr;
  997. + free_mem_ptr += size;
  998. +
  999. + if (free_mem_ptr >= free_mem_end_ptr)
  1000. + error("Out of memory");
  1001. +
  1002. + return p;
  1003. +}
  1004. +
  1005. +static void free(void *where)
  1006. +{ /* Don't care */
  1007. +}
  1008. +
  1009. +static void gzip_mark(void **ptr)
  1010. +{
  1011. + *ptr = (void *) free_mem_ptr;
  1012. +}
  1013. +
  1014. +static void gzip_release(void **ptr)
  1015. +{
  1016. + free_mem_ptr = (long) *ptr;
  1017. +}
  1018. +
  1019. +void* memset(void* s, int c, size_t n)
  1020. +{
  1021. + int i;
  1022. + char *ss = (char*)s;
  1023. +
  1024. + for (i=0;i<n;i++) ss[i] = c;
  1025. + return s;
  1026. +}
  1027. +
  1028. +void* memcpy(void* __dest, __const void* __src,
  1029. + size_t __n)
  1030. +{
  1031. + int i;
  1032. + char *d = (char *)__dest, *s = (char *)__src;
  1033. +
  1034. + for (i=0;i<__n;i++) d[i] = s[i];
  1035. + return __dest;
  1036. +}
  1037. +
  1038. +/* ===========================================================================
  1039. + * Fill the input buffer. This is called only when the buffer is empty
  1040. + * and at least one byte is really needed.
  1041. + */
  1042. +static int fill_inbuf(void)
  1043. +{
  1044. + if (insize != 0) {
  1045. + error("ran out of input data");
  1046. + }
  1047. +
  1048. + inbuf = input_data;
  1049. + insize = input_len;
  1050. + inptr = 1;
  1051. + return inbuf[0];
  1052. +}
  1053. +
  1054. +/* ===========================================================================
  1055. + * Write the output window window[0..outcnt-1] and update crc and bytes_out.
  1056. + * (Used for the decompressed data only.)
  1057. + */
  1058. +static void flush_window(void)
  1059. +{
  1060. + ulg c = crc; /* temporary variable */
  1061. + unsigned n;
  1062. + uch *in, *out, ch;
  1063. + in = window;
  1064. + out = &output_data[output_ptr];
  1065. + for (n = 0; n < outcnt; n++) {
  1066. + ch = *out++ = *in++;
  1067. + c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
  1068. + }
  1069. + crc = c;
  1070. + bytes_out += (ulg)outcnt;
  1071. + output_ptr += (ulg)outcnt;
  1072. + outcnt = 0;
  1073. +}
  1074. +
  1075. +static void error(char *x)
  1076. +{
  1077. + puts("\nERROR\n");
  1078. + puts(x);
  1079. + puts("\n\n -- System halted");
  1080. +
  1081. + while(1); /* Halt */
  1082. +}
  1083. +
  1084. +void decompress_kernel(void)
  1085. +{
  1086. + output_data = (void *)nasys_program_mem;
  1087. + output_ptr = 0;
  1088. + free_mem_ptr = (unsigned long)&_end;
  1089. + free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
  1090. +
  1091. + makecrc();
  1092. + puts("Uncompressing Linux... ");
  1093. + gunzip();
  1094. + puts("Ok, booting the kernel.\n");
  1095. +}
  1096. diff --git a/arch/nios2nommu/boot/compressed/nios2_sio.c b/arch/nios2nommu/boot/compressed/nios2_sio.c
  1097. new file mode 100644
  1098. index 0000000..8630c8f
  1099. --- /dev/null
  1100. +++ b/arch/nios2nommu/boot/compressed/nios2_sio.c
  1101. @@ -0,0 +1,57 @@
  1102. +
  1103. +static int putchar(int ch);
  1104. +
  1105. +static int puts(const char *s)
  1106. + {
  1107. + while(*s)
  1108. + putchar(*s++);
  1109. + return 0;
  1110. + }
  1111. +
  1112. +#include <asm/nios.h>
  1113. +#include <asm/io.h>
  1114. +
  1115. +#if defined(CONFIG_SERIAL_AJUART_CONSOLE)
  1116. +
  1117. +#define IORD_ALTERA_AVALON_JTAG_UART_DATA(base) inl(base)
  1118. +#define IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, data) outl(data, base)
  1119. +#define IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base) inl(base+4)
  1120. +#define IOWR_ALTERA_AVALON_JTAG_UART_CONTROL(base, data) outl(data, base+4)
  1121. +#define ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK (0xFFFF0000u)
  1122. +#define ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_OFST (16)
  1123. +
  1124. +static void jtag_putc(int ch)
  1125. +{
  1126. + unsigned base = na_jtag_uart;
  1127. + while ((IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base) & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) == 0);
  1128. + IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, ch);
  1129. +}
  1130. +
  1131. +static int putchar(int ch)
  1132. +{
  1133. + jtag_putc( ch );
  1134. + return ch;
  1135. +}
  1136. +
  1137. +#elif defined(CONFIG_NIOS_SERIAL_CONSOLE)
  1138. +
  1139. +static void nr_txchar(int ch)
  1140. +{
  1141. + while ((na_uart0->np_uartstatus & np_uartstatus_trdy_mask) == 0);
  1142. + na_uart0->np_uarttxdata = ch;
  1143. +}
  1144. +
  1145. +static int putchar(int ch)
  1146. +{
  1147. + nr_txchar( ch ); if (ch=='\n') nr_txchar( '\r' );
  1148. + return ch;
  1149. +}
  1150. +
  1151. +#else
  1152. +
  1153. +static int putchar(int ch)
  1154. +{
  1155. + return ch;
  1156. +}
  1157. +
  1158. +#endif
  1159. diff --git a/arch/nios2nommu/boot/compressed/vmlinux.lds.S b/arch/nios2nommu/boot/compressed/vmlinux.lds.S
  1160. new file mode 100644
  1161. index 0000000..08bb3e2
  1162. --- /dev/null
  1163. +++ b/arch/nios2nommu/boot/compressed/vmlinux.lds.S
  1164. @@ -0,0 +1,34 @@
  1165. +#include <asm-generic/vmlinux.lds.h>
  1166. +#include <asm/nios.h>
  1167. +
  1168. +OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
  1169. +
  1170. +OUTPUT_ARCH(nios)
  1171. +ENTRY(_start) /* Defined in head.S */
  1172. +
  1173. +SECTIONS
  1174. +{
  1175. + . =nasys_program_mem + CONFIG_BOOT_LINK_OFFSET;
  1176. +
  1177. + _text = .;
  1178. + .text : { *(.text) } = 0
  1179. + .rodata : { *(.rodata) *(.rodata.*) }
  1180. + _etext = .;
  1181. +
  1182. + . = ALIGN(32 / 8);
  1183. + .data : { *(.data) }
  1184. + . = ALIGN(32 / 8);
  1185. + _got = .;
  1186. + .got : { *(.got) _egot = .; *(.got.*) }
  1187. + _edata = .;
  1188. +
  1189. + . = ALIGN(32 / 8);
  1190. + __bss_start = .;
  1191. + .bss : { *(.bss) *(.sbss) }
  1192. + . = ALIGN(32 / 8);
  1193. + _ebss = .;
  1194. + end = . ;
  1195. + _end = . ;
  1196. +
  1197. + got_len = (_egot - _got);
  1198. +}
  1199. diff --git a/arch/nios2nommu/defconfig b/arch/nios2nommu/defconfig
  1200. new file mode 100644
  1201. index 0000000..40629cb
  1202. --- /dev/null
  1203. +++ b/arch/nios2nommu/defconfig
  1204. @@ -0,0 +1,690 @@
  1205. +#
  1206. +# Automatically generated make config: don't edit
  1207. +# Linux kernel version: 2.6.19-uc1
  1208. +#
  1209. +# CONFIG_MMU is not set
  1210. +# CONFIG_FPU is not set
  1211. +CONFIG_UID16=y
  1212. +CONFIG_RWSEM_GENERIC_SPINLOCK=y
  1213. +# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
  1214. +CONFIG_GENERIC_FIND_NEXT_BIT=y
  1215. +CONFIG_GENERIC_HWEIGHT=y
  1216. +CONFIG_GENERIC_CALIBRATE_DELAY=y
  1217. +
  1218. +#
  1219. +# Code maturity level options
  1220. +#
  1221. +CONFIG_EXPERIMENTAL=y
  1222. +CONFIG_BROKEN_ON_SMP=y
  1223. +CONFIG_LOCK_KERNEL=y
  1224. +CONFIG_INIT_ENV_ARG_LIMIT=32
  1225. +
  1226. +#
  1227. +# General setup
  1228. +#
  1229. +CONFIG_LOCALVERSION=""
  1230. +CONFIG_LOCALVERSION_AUTO=y
  1231. +# CONFIG_SYSVIPC is not set
  1232. +# CONFIG_POSIX_MQUEUE is not set
  1233. +# CONFIG_BSD_PROCESS_ACCT is not set
  1234. +# CONFIG_TASKSTATS is not set
  1235. +# CONFIG_UTS_NS is not set
  1236. +# CONFIG_AUDIT is not set
  1237. +# CONFIG_IKCONFIG is not set
  1238. +# CONFIG_RELAY is not set
  1239. +CONFIG_INITRAMFS_SOURCE="../romfs ../vendors/Altera/nios2nommu/romfs_list"
  1240. +CONFIG_INITRAMFS_ROOT_UID=500
  1241. +CONFIG_INITRAMFS_ROOT_GID=500
  1242. +CONFIG_CC_OPTIMIZE_FOR_SIZE=y
  1243. +CONFIG_EMBEDDED=y
  1244. +# CONFIG_SYSCTL_SYSCALL is not set
  1245. +# CONFIG_KALLSYMS is not set
  1246. +# CONFIG_HOTPLUG is not set
  1247. +CONFIG_PRINTK=y
  1248. +CONFIG_BUG=y
  1249. +# CONFIG_ELF_CORE is not set
  1250. +CONFIG_BASE_FULL=y
  1251. +CONFIG_FUTEX=y
  1252. +# CONFIG_EPOLL is not set
  1253. +CONFIG_SLAB=y
  1254. +# CONFIG_VM_EVENT_COUNTERS is not set
  1255. +CONFIG_RT_MUTEXES=y
  1256. +CONFIG_TINY_SHMEM=y
  1257. +CONFIG_BASE_SMALL=0
  1258. +# CONFIG_SLOB is not set
  1259. +
  1260. +#
  1261. +# Loadable module support
  1262. +#
  1263. +# CONFIG_MODULES is not set
  1264. +
  1265. +#
  1266. +# Block layer
  1267. +#
  1268. +CONFIG_BLOCK=y
  1269. +# CONFIG_BLK_DEV_IO_TRACE is not set
  1270. +
  1271. +#
  1272. +# IO Schedulers
  1273. +#
  1274. +CONFIG_IOSCHED_NOOP=y
  1275. +# CONFIG_IOSCHED_AS is not set
  1276. +CONFIG_IOSCHED_DEADLINE=y
  1277. +# CONFIG_IOSCHED_CFQ is not set
  1278. +# CONFIG_DEFAULT_AS is not set
  1279. +CONFIG_DEFAULT_DEADLINE=y
  1280. +# CONFIG_DEFAULT_CFQ is not set
  1281. +# CONFIG_DEFAULT_NOOP is not set
  1282. +CONFIG_DEFAULT_IOSCHED="deadline"
  1283. +
  1284. +#
  1285. +# Processor type and features
  1286. +#
  1287. +
  1288. +#
  1289. +# Platform dependant setup
  1290. +#
  1291. +CONFIG_NIOS2=y
  1292. +# CONFIG_MICROTRONIX_UKIT is not set
  1293. +# CONFIG_MICROTRONIX_STRATIX is not set
  1294. +# CONFIG_MICROTRONIX_CYCLONE is not set
  1295. +# CONFIG_MICROTRONIX_PSK is not set
  1296. +CONFIG_ALTERA_STRATIX=y
  1297. +# CONFIG_ALTERA_STRATIX_PRO is not set
  1298. +# CONFIG_ALTERA_STRATIX_II is not set
  1299. +# CONFIG_ALTERA_CYCLONE is not set
  1300. +# CONFIG_ALTERA_CYCLONE_1C12_EVAL is not set
  1301. +# CONFIG_ALTERA_DE2 is not set
  1302. +# CONFIG_NIOS2_HW_MUL_OFF is not set
  1303. +CONFIG_NIOS2_HW_MUL=y
  1304. +# CONFIG_NIOS2_HW_MULX is not set
  1305. +
  1306. +#
  1307. +# Platform drivers Options
  1308. +#
  1309. +# CONFIG_AVALON_DMA is not set
  1310. +# CONFIG_PIO_DEVICES is not set
  1311. +# CONFIG_PCI is not set
  1312. +# CONFIG_FB_ALTERA is not set
  1313. +# CONFIG_SERIO_ALTPS2 is not set
  1314. +# CONFIG_I2C_GPIO is not set
  1315. +
  1316. +#
  1317. +# Miscellaneous Options
  1318. +#
  1319. +CONFIG_EXCALIBUR=y
  1320. +# CONFIG_BREAK_ON_START is not set
  1321. +CONFIG_LARGE_ALLOCS=y
  1322. +CONFIG_RAMKERNEL=y
  1323. +CONFIG_PREEMPT=y
  1324. +# CONFIG_PREEMPT_TIMES is not set
  1325. +CONFIG_CMDLINE=""
  1326. +# CONFIG_PASS_CMDLINE is not set
  1327. +CONFIG_SELECT_MEMORY_MODEL=y
  1328. +CONFIG_FLATMEM_MANUAL=y
  1329. +# CONFIG_DISCONTIGMEM_MANUAL is not set
  1330. +# CONFIG_SPARSEMEM_MANUAL is not set
  1331. +CONFIG_FLATMEM=y
  1332. +CONFIG_FLAT_NODE_MEM_MAP=y
  1333. +# CONFIG_SPARSEMEM_STATIC is not set
  1334. +CONFIG_SPLIT_PTLOCK_CPUS=4
  1335. +# CONFIG_RESOURCES_64BIT is not set
  1336. +CONFIG_BOOT_LINK_OFFSET=0x00500000
  1337. +
  1338. +#
  1339. +# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
  1340. +#
  1341. +
  1342. +#
  1343. +# PCCARD (PCMCIA/CardBus) support
  1344. +#
  1345. +
  1346. +#
  1347. +# PCI Hotplug Support
  1348. +#
  1349. +
  1350. +#
  1351. +# Executable file formats
  1352. +#
  1353. +CONFIG_KCORE_AOUT=y
  1354. +CONFIG_KCORE_ELF=y
  1355. +CONFIG_BINFMT_FLAT=y
  1356. +CONFIG_BINFMT_ZFLAT=y
  1357. +# CONFIG_BINFMT_SHARED_FLAT is not set
  1358. +# CONFIG_BINFMT_MISC is not set
  1359. +
  1360. +#
  1361. +# Power management options
  1362. +#
  1363. +# CONFIG_PM is not set
  1364. +
  1365. +#
  1366. +# Networking
  1367. +#
  1368. +CONFIG_NET=y
  1369. +
  1370. +#
  1371. +# Networking options
  1372. +#
  1373. +# CONFIG_NETDEBUG is not set
  1374. +CONFIG_PACKET=y
  1375. +# CONFIG_PACKET_MMAP is not set
  1376. +CONFIG_UNIX=y
  1377. +# CONFIG_NET_KEY is not set
  1378. +CONFIG_INET=y
  1379. +# CONFIG_IP_MULTICAST is not set
  1380. +# CONFIG_IP_ADVANCED_ROUTER is not set
  1381. +CONFIG_IP_FIB_HASH=y
  1382. +# CONFIG_IP_PNP is not set
  1383. +# CONFIG_NET_IPIP is not set
  1384. +# CONFIG_NET_IPGRE is not set
  1385. +# CONFIG_ARPD is not set
  1386. +# CONFIG_SYN_COOKIES is not set
  1387. +# CONFIG_INET_AH is not set
  1388. +# CONFIG_INET_ESP is not set
  1389. +# CONFIG_INET_IPCOMP is not set
  1390. +# CONFIG_INET_XFRM_TUNNEL is not set
  1391. +# CONFIG_INET_TUNNEL is not set
  1392. +# CONFIG_IPSEC_NAT_TRAVERSAL is not set
  1393. +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
  1394. +# CONFIG_INET_XFRM_MODE_TUNNEL is not set
  1395. +# CONFIG_INET_XFRM_MODE_BEET is not set
  1396. +# CONFIG_INET_DIAG is not set
  1397. +# CONFIG_TCP_CONG_ADVANCED is not set
  1398. +CONFIG_TCP_CONG_CUBIC=y
  1399. +CONFIG_DEFAULT_TCP_CONG="cubic"
  1400. +# CONFIG_IPV6 is not set
  1401. +# CONFIG_INET6_XFRM_TUNNEL is not set
  1402. +# CONFIG_INET6_TUNNEL is not set
  1403. +# CONFIG_NETWORK_SECMARK is not set
  1404. +# CONFIG_NETFILTER is not set
  1405. +
  1406. +#
  1407. +# DCCP Configuration (EXPERIMENTAL)
  1408. +#
  1409. +# CONFIG_IP_DCCP is not set
  1410. +
  1411. +#
  1412. +# SCTP Configuration (EXPERIMENTAL)
  1413. +#
  1414. +# CONFIG_IP_SCTP is not set
  1415. +
  1416. +#
  1417. +# TIPC Configuration (EXPERIMENTAL)
  1418. +#
  1419. +# CONFIG_TIPC is not set
  1420. +# CONFIG_ATM is not set
  1421. +# CONFIG_BRIDGE is not set
  1422. +# CONFIG_VLAN_8021Q is not set
  1423. +# CONFIG_DECNET is not set
  1424. +# CONFIG_LLC2 is not set
  1425. +# CONFIG_IPX is not set
  1426. +# CONFIG_ATALK is not set
  1427. +# CONFIG_X25 is not set
  1428. +# CONFIG_LAPB is not set
  1429. +# CONFIG_ECONET is not set
  1430. +# CONFIG_WAN_ROUTER is not set
  1431. +
  1432. +#
  1433. +# QoS and/or fair queueing
  1434. +#
  1435. +# CONFIG_NET_SCHED is not set
  1436. +
  1437. +#
  1438. +# Network testing
  1439. +#
  1440. +# CONFIG_NET_PKTGEN is not set
  1441. +# CONFIG_HAMRADIO is not set
  1442. +# CONFIG_IRDA is not set
  1443. +# CONFIG_BT is not set
  1444. +# CONFIG_KLIPS is not set
  1445. +# CONFIG_IEEE80211 is not set
  1446. +
  1447. +#
  1448. +# Device Drivers
  1449. +#
  1450. +
  1451. +#
  1452. +# Generic Driver Options
  1453. +#
  1454. +CONFIG_STANDALONE=y
  1455. +CONFIG_PREVENT_FIRMWARE_BUILD=y
  1456. +# CONFIG_SYS_HYPERVISOR is not set
  1457. +
  1458. +#
  1459. +# Connector - unified userspace <-> kernelspace linker
  1460. +#
  1461. +# CONFIG_CONNECTOR is not set
  1462. +
  1463. +#
  1464. +# Memory Technology Devices (MTD)
  1465. +#
  1466. +# CONFIG_MTD is not set
  1467. +
  1468. +#
  1469. +# Parallel port support
  1470. +#
  1471. +# CONFIG_PARPORT is not set
  1472. +
  1473. +#
  1474. +# Plug and Play support
  1475. +#
  1476. +
  1477. +#
  1478. +# Block devices
  1479. +#
  1480. +# CONFIG_BLK_DEV_COW_COMMON is not set
  1481. +# CONFIG_BLK_DEV_LOOP is not set
  1482. +# CONFIG_BLK_DEV_NBD is not set
  1483. +# CONFIG_BLK_DEV_RAM is not set
  1484. +# CONFIG_BLK_DEV_INITRD is not set
  1485. +# CONFIG_CDROM_PKTCDVD is not set
  1486. +# CONFIG_ATA_OVER_ETH is not set
  1487. +
  1488. +#
  1489. +# Misc devices
  1490. +#
  1491. +# CONFIG_TIFM_CORE is not set
  1492. +
  1493. +#
  1494. +# ATA/ATAPI/MFM/RLL support
  1495. +#
  1496. +# CONFIG_IDE is not set
  1497. +
  1498. +#
  1499. +# SCSI device support
  1500. +#
  1501. +# CONFIG_RAID_ATTRS is not set
  1502. +# CONFIG_SCSI is not set
  1503. +# CONFIG_SCSI_NETLINK is not set
  1504. +
  1505. +#
  1506. +# Serial ATA (prod) and Parallel ATA (experimental) drivers
  1507. +#
  1508. +# CONFIG_ATA is not set
  1509. +
  1510. +#
  1511. +# Multi-device support (RAID and LVM)
  1512. +#
  1513. +# CONFIG_MD is not set
  1514. +
  1515. +#
  1516. +# Fusion MPT device support
  1517. +#
  1518. +# CONFIG_FUSION is not set
  1519. +
  1520. +#
  1521. +# IEEE 1394 (FireWire) support
  1522. +#
  1523. +
  1524. +#
  1525. +# I2O device support
  1526. +#
  1527. +
  1528. +#
  1529. +# Network device support
  1530. +#
  1531. +CONFIG_NETDEVICES=y
  1532. +# CONFIG_DUMMY is not set
  1533. +# CONFIG_BONDING is not set
  1534. +# CONFIG_EQUALIZER is not set
  1535. +# CONFIG_TUN is not set
  1536. +
  1537. +#
  1538. +# PHY device support
  1539. +#
  1540. +# CONFIG_PHYLIB is not set
  1541. +
  1542. +#
  1543. +# Ethernet (10 or 100Mbit)
  1544. +#
  1545. +CONFIG_NET_ETHERNET=y
  1546. +CONFIG_MII=y
  1547. +# CONFIG_NET_VENDOR_SMC is not set
  1548. +# CONFIG_OPEN_ETH is not set
  1549. +# CONFIG_MTIP1000_ETH is not set
  1550. +# CONFIG_NE2000 is not set
  1551. +# CONFIG_NET_PCI is not set
  1552. +
  1553. +#
  1554. +# Ethernet (1000 Mbit)
  1555. +#
  1556. +
  1557. +#
  1558. +# Ethernet (10000 Mbit)
  1559. +#
  1560. +
  1561. +#
  1562. +# Token Ring devices
  1563. +#
  1564. +
  1565. +#
  1566. +# Wireless LAN (non-hamradio)
  1567. +#
  1568. +# CONFIG_NET_RADIO is not set
  1569. +
  1570. +#
  1571. +# Wan interfaces
  1572. +#
  1573. +# CONFIG_WAN is not set
  1574. +# CONFIG_PPP is not set
  1575. +# CONFIG_SLIP is not set
  1576. +# CONFIG_SHAPER is not set
  1577. +# CONFIG_NETCONSOLE is not set
  1578. +# CONFIG_NETPOLL is not set
  1579. +# CONFIG_NET_POLL_CONTROLLER is not set
  1580. +
  1581. +#
  1582. +# ISDN subsystem
  1583. +#
  1584. +# CONFIG_ISDN is not set
  1585. +
  1586. +#
  1587. +# Telephony Support
  1588. +#
  1589. +# CONFIG_PHONE is not set
  1590. +
  1591. +#
  1592. +# Input device support
  1593. +#
  1594. +# CONFIG_INPUT is not set
  1595. +
  1596. +#
  1597. +# Hardware I/O ports
  1598. +#
  1599. +# CONFIG_SERIO is not set
  1600. +# CONFIG_GAMEPORT is not set
  1601. +
  1602. +#
  1603. +# Character devices
  1604. +#
  1605. +# CONFIG_VT is not set
  1606. +# CONFIG_SERIAL_NONSTANDARD is not set
  1607. +# CONFIG_NIOS_LCD_16207 is not set
  1608. +# CONFIG_NIOS_BUTTON is not set
  1609. +# CONFIG_LEDMAN is not set
  1610. +# CONFIG_SNAPDOG is not set
  1611. +# CONFIG_FAST_TIMER is not set
  1612. +# CONFIG_RESETSWITCH is not set
  1613. +
  1614. +#
  1615. +# Serial drivers
  1616. +#
  1617. +# CONFIG_SERIAL_8250 is not set
  1618. +
  1619. +#
  1620. +# Non-8250 serial port support
  1621. +#
  1622. +CONFIG_SERIAL_CORE=y
  1623. +CONFIG_SERIAL_CORE_CONSOLE=y
  1624. +# CONFIG_NIOS_SERIAL is not set
  1625. +CONFIG_SERIAL_AJUART=y
  1626. +CONFIG_SERIAL_AJUART_CONSOLE=y
  1627. +# CONFIG_UNIX98_PTYS is not set
  1628. +CONFIG_LEGACY_PTYS=y
  1629. +CONFIG_LEGACY_PTY_COUNT=10
  1630. +
  1631. +#
  1632. +# IPMI
  1633. +#
  1634. +# CONFIG_IPMI_HANDLER is not set
  1635. +
  1636. +#
  1637. +# Watchdog Cards
  1638. +#
  1639. +# CONFIG_WATCHDOG is not set
  1640. +# CONFIG_HW_RANDOM is not set
  1641. +# CONFIG_RTC is not set
  1642. +# CONFIG_GEN_RTC is not set
  1643. +# CONFIG_DTLK is not set
  1644. +# CONFIG_R3964 is not set
  1645. +
  1646. +#
  1647. +# Ftape, the floppy tape device driver
  1648. +#
  1649. +# CONFIG_RAW_DRIVER is not set
  1650. +
  1651. +#
  1652. +# TPM devices
  1653. +#
  1654. +# CONFIG_TCG_TPM is not set
  1655. +# CONFIG_M41T11M6 is not set
  1656. +
  1657. +#
  1658. +# I2C support
  1659. +#
  1660. +# CONFIG_I2C is not set
  1661. +
  1662. +#
  1663. +# SPI support
  1664. +#
  1665. +# CONFIG_SPI is not set
  1666. +# CONFIG_SPI_MASTER is not set
  1667. +
  1668. +#
  1669. +# Dallas's 1-wire bus
  1670. +#
  1671. +# CONFIG_W1 is not set
  1672. +
  1673. +#
  1674. +# Hardware Monitoring support
  1675. +#
  1676. +CONFIG_HWMON=y
  1677. +# CONFIG_HWMON_VID is not set
  1678. +# CONFIG_SENSORS_ABITUGURU is not set
  1679. +# CONFIG_SENSORS_F71805F is not set
  1680. +# CONFIG_SENSORS_VT1211 is not set
  1681. +# CONFIG_HWMON_DEBUG_CHIP is not set
  1682. +
  1683. +#
  1684. +# Multimedia devices
  1685. +#
  1686. +# CONFIG_VIDEO_DEV is not set
  1687. +
  1688. +#
  1689. +# Digital Video Broadcasting Devices
  1690. +#
  1691. +# CONFIG_DVB is not set
  1692. +
  1693. +#
  1694. +# Graphics support
  1695. +#
  1696. +# CONFIG_FIRMWARE_EDID is not set
  1697. +# CONFIG_FB is not set
  1698. +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
  1699. +
  1700. +#
  1701. +# Sound
  1702. +#
  1703. +# CONFIG_SOUND is not set
  1704. +
  1705. +#
  1706. +# USB support
  1707. +#
  1708. +# CONFIG_USB_ARCH_HAS_HCD is not set
  1709. +# CONFIG_USB_ARCH_HAS_OHCI is not set
  1710. +# CONFIG_USB_ARCH_HAS_EHCI is not set
  1711. +
  1712. +#
  1713. +# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
  1714. +#
  1715. +
  1716. +#
  1717. +# USB Gadget Support
  1718. +#
  1719. +# CONFIG_USB_GADGET is not set
  1720. +
  1721. +#
  1722. +# MMC/SD Card support
  1723. +#
  1724. +# CONFIG_MMC is not set
  1725. +
  1726. +#
  1727. +# LED devices
  1728. +#
  1729. +# CONFIG_NEW_LEDS is not set
  1730. +
  1731. +#
  1732. +# LED drivers
  1733. +#
  1734. +
  1735. +#
  1736. +# LED Triggers
  1737. +#
  1738. +
  1739. +#
  1740. +# InfiniBand support
  1741. +#
  1742. +
  1743. +#
  1744. +# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
  1745. +#
  1746. +
  1747. +#
  1748. +# Real Time Clock
  1749. +#
  1750. +# CONFIG_RTC_CLASS is not set
  1751. +
  1752. +#
  1753. +# DMA Engine support
  1754. +#
  1755. +# CONFIG_DMA_ENGINE is not set
  1756. +
  1757. +#
  1758. +# DMA Clients
  1759. +#
  1760. +
  1761. +#
  1762. +# DMA Devices
  1763. +#
  1764. +
  1765. +#
  1766. +# File systems
  1767. +#
  1768. +# CONFIG_EXT2_FS is not set
  1769. +# CONFIG_EXT3_FS is not set
  1770. +# CONFIG_EXT4DEV_FS is not set
  1771. +# CONFIG_REISERFS_FS is not set
  1772. +# CONFIG_JFS_FS is not set
  1773. +# CONFIG_FS_POSIX_ACL is not set
  1774. +# CONFIG_XFS_FS is not set
  1775. +# CONFIG_GFS2_FS is not set
  1776. +# CONFIG_OCFS2_FS is not set
  1777. +# CONFIG_MINIX_FS is not set
  1778. +# CONFIG_ROMFS_FS is not set
  1779. +# CONFIG_INOTIFY is not set
  1780. +# CONFIG_QUOTA is not set
  1781. +# CONFIG_DNOTIFY is not set
  1782. +# CONFIG_AUTOFS_FS is not set
  1783. +# CONFIG_AUTOFS4_FS is not set
  1784. +# CONFIG_FUSE_FS is not set
  1785. +# CONFIG_DIRECTIO is not set
  1786. +
  1787. +#
  1788. +# CD-ROM/DVD Filesystems
  1789. +#
  1790. +# CONFIG_ISO9660_FS is not set
  1791. +# CONFIG_UDF_FS is not set
  1792. +
  1793. +#
  1794. +# DOS/FAT/NT Filesystems
  1795. +#
  1796. +# CONFIG_MSDOS_FS is not set
  1797. +# CONFIG_VFAT_FS is not set
  1798. +# CONFIG_NTFS_FS is not set
  1799. +
  1800. +#
  1801. +# Pseudo filesystems
  1802. +#
  1803. +CONFIG_PROC_FS=y
  1804. +# CONFIG_PROC_SYSCTL is not set
  1805. +CONFIG_SYSFS=y
  1806. +# CONFIG_TMPFS is not set
  1807. +# CONFIG_HUGETLB_PAGE is not set
  1808. +CONFIG_RAMFS=y
  1809. +# CONFIG_CONFIGFS_FS is not set
  1810. +
  1811. +#
  1812. +# Miscellaneous filesystems
  1813. +#
  1814. +# CONFIG_ADFS_FS is not set
  1815. +# CONFIG_AFFS_FS is not set
  1816. +# CONFIG_HFS_FS is not set
  1817. +# CONFIG_HFSPLUS_FS is not set
  1818. +# CONFIG_BEFS_FS is not set
  1819. +# CONFIG_BFS_FS is not set
  1820. +# CONFIG_EFS_FS is not set
  1821. +# CONFIG_CRAMFS is not set
  1822. +# CONFIG_SQUASHFS is not set
  1823. +# CONFIG_VXFS_FS is not set
  1824. +# CONFIG_HPFS_FS is not set
  1825. +# CONFIG_QNX4FS_FS is not set
  1826. +# CONFIG_SYSV_FS is not set
  1827. +# CONFIG_UFS_FS is not set
  1828. +
  1829. +#
  1830. +# Network File Systems
  1831. +#
  1832. +CONFIG_NFS_FS=y
  1833. +CONFIG_NFS_V3=y
  1834. +# CONFIG_NFS_V3_ACL is not set
  1835. +# CONFIG_NFS_V4 is not set
  1836. +# CONFIG_NFSD is not set
  1837. +CONFIG_LOCKD=y
  1838. +CONFIG_LOCKD_V4=y
  1839. +CONFIG_NFS_COMMON=y
  1840. +CONFIG_SUNRPC=y
  1841. +# CONFIG_RPCSEC_GSS_KRB5 is not set
  1842. +# CONFIG_RPCSEC_GSS_SPKM3 is not set
  1843. +# CONFIG_SMB_FS is not set
  1844. +# CONFIG_CIFS is not set
  1845. +# CONFIG_NCP_FS is not set
  1846. +# CONFIG_CODA_FS is not set
  1847. +# CONFIG_AFS_FS is not set
  1848. +# CONFIG_9P_FS is not set
  1849. +
  1850. +#
  1851. +# Partition Types
  1852. +#
  1853. +# CONFIG_PARTITION_ADVANCED is not set
  1854. +CONFIG_MSDOS_PARTITION=y
  1855. +
  1856. +#
  1857. +# Native Language Support
  1858. +#
  1859. +# CONFIG_NLS is not set
  1860. +
  1861. +#
  1862. +# Debug
  1863. +#
  1864. +# CONFIG_COREDUMP_PRINTK is not set
  1865. +
  1866. +#
  1867. +# Kernel hacking
  1868. +#
  1869. +# CONFIG_FULLDEBUG is not set
  1870. +# CONFIG_FRAME_POINTER is not set
  1871. +# CONFIG_MAGIC_SYSRQ is not set
  1872. +# CONFIG_NO_KERNEL_MSG is not set
  1873. +CONFIG_LOG_BUF_SHIFT=14
  1874. +
  1875. +#
  1876. +# Security options
  1877. +#
  1878. +# CONFIG_KEYS is not set
  1879. +# CONFIG_SECURITY is not set
  1880. +
  1881. +#
  1882. +# Cryptographic options
  1883. +#
  1884. +# CONFIG_CRYPTO is not set
  1885. +
  1886. +#
  1887. +# Library routines
  1888. +#
  1889. +# CONFIG_CRC_CCITT is not set
  1890. +# CONFIG_CRC16 is not set
  1891. +CONFIG_CRC32=y
  1892. +# CONFIG_LIBCRC32C is not set
  1893. +CONFIG_ZLIB_INFLATE=y
  1894. +CONFIG_PLIST=y
  1895. diff --git a/arch/nios2nommu/drivers/Kconfig b/arch/nios2nommu/drivers/Kconfig
  1896. new file mode 100644
  1897. index 0000000..2fde3a8
  1898. --- /dev/null
  1899. +++ b/arch/nios2nommu/drivers/Kconfig
  1900. @@ -0,0 +1,45 @@
  1901. +# Platfrom drivers configuration
  1902. +
  1903. +source "arch/nios2nommu/drivers/pci/Kconfig"
  1904. +
  1905. +config FB_ALTERA
  1906. + tristate "Avalon VGA controller support"
  1907. + default N
  1908. + select FB
  1909. + select FB_CFB_FILLRECT
  1910. + select FB_CFB_COPYAREA
  1911. + select FB_CFB_IMAGEBLIT
  1912. + help
  1913. + This is the frame buffer device driver for the VGA controller
  1914. + in SOPC Builder.
  1915. +
  1916. +config SERIO_ALTPS2
  1917. + tristate "PS2 controller"
  1918. + select VT
  1919. + default N
  1920. + select SERIO
  1921. +
  1922. +config I2C_NIOS2_GPIO
  1923. + tristate "GPIO-Based I2C Interface"
  1924. + default N
  1925. + select I2C
  1926. + select I2C_ALGOBIT
  1927. + help
  1928. + Say Y here if you use GPIO lines for an I2C bus.
  1929. +
  1930. +config BLK_DEV_ALTCF
  1931. + tristate "Altera CF (IDE mode) interface (Avalon bus) support"
  1932. + select IDE
  1933. + select BLK_DEV_IDE
  1934. + default N
  1935. + help
  1936. + This driver provides support for the Altera Compact flash core (with
  1937. + Avalon interface) support. If you have an Altera or Microtronix
  1938. + development board you can build support into the FPGA device for this.
  1939. +
  1940. +config NIOS_SPI
  1941. + bool "Nios SPI device support"
  1942. + depends on NIOS || NIOS2
  1943. + help
  1944. + This driver supports the Nios softcore SPI device.
  1945. +
  1946. diff --git a/arch/nios2nommu/drivers/Makefile b/arch/nios2nommu/drivers/Makefile
  1947. new file mode 100644
  1948. index 0000000..f6a273e
  1949. --- /dev/null
  1950. +++ b/arch/nios2nommu/drivers/Makefile
  1951. @@ -0,0 +1,10 @@
  1952. +#
  1953. +# Makefile for the Linux nios2-specific device drivers.
  1954. +#
  1955. +
  1956. +obj-$(CONFIG_PCI) += pci/
  1957. +obj-$(CONFIG_FB_ALTERA) += altfb.o
  1958. +obj-$(CONFIG_SERIO_ALTPS2) += altps2.o
  1959. +obj-$(CONFIG_I2C_NIOS2_GPIO) += i2c-gpio.o
  1960. +obj-$(CONFIG_BLK_DEV_ALTCF) += altcf.o
  1961. +obj-$(CONFIG_NIOS_SPI) += spi.o
  1962. diff --git a/arch/nios2nommu/drivers/altcf.c b/arch/nios2nommu/drivers/altcf.c
  1963. new file mode 100644
  1964. index 0000000..80275c6
  1965. --- /dev/null
  1966. +++ b/arch/nios2nommu/drivers/altcf.c
  1967. @@ -0,0 +1,266 @@
  1968. +/*
  1969. + * linux/drivers/ide/altcf.c
  1970. + * Support for Altera CompactFlash core with Avalon interface.
  1971. + *
  1972. + * Copyright (C) 2004 Microtronix Datacom Ltd
  1973. + *
  1974. + * This program is free software; you can redistribute it and/or
  1975. + * modify it under the terms of the GNU General Public License
  1976. + * as published by the Free Software Foundation; either version
  1977. + * 2 of the License, or (at your option) any later version.
  1978. + *
  1979. + * Written by Wentao Xu <wentao@microtronix.com>
  1980. + */
  1981. +
  1982. +#include <linux/module.h>
  1983. +#include <linux/types.h>
  1984. +#include <linux/kernel.h>
  1985. +#include <linux/delay.h>
  1986. +#include <linux/timer.h>
  1987. +#include <linux/mm.h>
  1988. +#include <linux/ioport.h>
  1989. +#include <linux/blkdev.h>
  1990. +#include <linux/hdreg.h>
  1991. +#include <linux/ide.h>
  1992. +#include <linux/init.h>
  1993. +#include <asm/io.h>
  1994. +#include <asm/nios.h>
  1995. +
  1996. +MODULE_AUTHOR("Microtronix Datacom Ltd.");
  1997. +MODULE_DESCRIPTION("Driver of Altera CompactFlash core with Avalon interface");
  1998. +MODULE_LICENSE("GPL");
  1999. +
  2000. +#define PDEBUG printk
  2001. +/* Altera Avalon Compact Flash core registers */
  2002. +#define REG_CFCTL 0
  2003. +#define REG_IDECTL 4
  2004. +
  2005. +/* CFCTL bits */
  2006. +#define CFCTL_DET 1 /* detect status */
  2007. +#define CFCTL_PWR 2 /* Power */
  2008. +#define CFCTL_RST 4 /* Reset */
  2009. +#define CFCTL_IDET 8 /* Detect int enable*/
  2010. +
  2011. +/* IDECTL bits */
  2012. +#define IDECTL_IIDE 1 /* IDE int enable */
  2013. +
  2014. +struct cf_dev {
  2015. + int base;
  2016. + int irq;
  2017. + int ide_base;
  2018. + int ide_irq;
  2019. + int configured;
  2020. + ide_hwif_t *hwif;
  2021. + struct delayed_work wcf;
  2022. +};
  2023. +
  2024. +static struct cf_dev cf_devices[MAX_HWIFS] = {
  2025. +#if MAX_HWIFS > 0
  2026. + {na_ide_ctl, na_ide_ctl_irq, na_ide_ide, na_ide_ide_irq, 0, NULL},
  2027. +#endif
  2028. +#if MAX_HWIFS > 1
  2029. + {na_ctl_base1, na_ctl_irq1, na_ide_base1, na_ide_irq1, 0, NULL},
  2030. +#endif
  2031. +#if MAX_HWIFS > 2
  2032. + {na_ctl_base2, na_ctl_irq2, na_ide_base2, na_ide_irq2, 0, NULL},
  2033. +#endif
  2034. +#if MAX_HWIFS > 3
  2035. + {na_ctl_base3, na_ctl_irq3, na_ide_base3, na_ide_irq3, 0, NULL},
  2036. +#endif
  2037. +};
  2038. +
  2039. +static inline void cf_init_hwif_ports(hw_regs_t *hw,
  2040. + unsigned long io_addr,
  2041. + unsigned long ctl_addr,
  2042. + int *irq)
  2043. +{
  2044. + unsigned int i;
  2045. +
  2046. + for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
  2047. + hw->io_ports[i] = io_addr + 4*(i-IDE_DATA_OFFSET);
  2048. +
  2049. + hw->io_ports[IDE_CONTROL_OFFSET] = ctl_addr;
  2050. +
  2051. + if (irq)
  2052. + *irq = 0;
  2053. +
  2054. + hw->io_ports[IDE_IRQ_OFFSET] = 0;
  2055. +
  2056. +}
  2057. +
  2058. +static int cf_release(struct cf_dev* dev)
  2059. +{
  2060. + if (dev) {
  2061. + if ((dev->configured) && (dev->hwif)) {
  2062. + /* disable IDE interrupts */
  2063. + outl(0, dev->base + REG_IDECTL);
  2064. + /* power off the card */
  2065. + //outl(0, dev->base + REG_CFCTL);
  2066. +
  2067. + ide_unregister(dev->hwif->index);
  2068. + dev->configured = 0;
  2069. + dev->hwif = NULL;
  2070. + PDEBUG("CF released\n");
  2071. + return 0;
  2072. + }
  2073. + }
  2074. + return -1;
  2075. +}
  2076. +
  2077. +static int cf_config(struct cf_dev* dev)
  2078. +{
  2079. + hw_regs_t hw;
  2080. + int index;
  2081. + ide_hwif_t *hwif;
  2082. +
  2083. + if (!dev)
  2084. + return -1;
  2085. +
  2086. + if (!dev->configured) {
  2087. + int i;
  2088. + for (i=1; i<=10; i++) {
  2089. + cf_init_hwif_ports(&hw, dev->ide_base, 0, NULL);
  2090. + hw.irq = dev->ide_irq;
  2091. + hw.chipset = ide_generic;
  2092. + outl(IDECTL_IIDE, dev->base + REG_IDECTL);
  2093. + index = ide_register_hw(&hw, 1, &hwif);
  2094. + if (index >=0) {
  2095. + dev->configured = 1;
  2096. + dev->hwif = hwif;
  2097. + return index;
  2098. + }
  2099. +
  2100. + set_current_state(TASK_UNINTERRUPTIBLE);
  2101. + schedule_timeout(HZ/10);
  2102. + }
  2103. + /* register fails */
  2104. + PDEBUG("CF:fail to register\n");
  2105. + /* disable IDE interrupt */
  2106. + outl(0, dev->base + REG_IDECTL);
  2107. + return -1;
  2108. + }
  2109. + return -2; /* already configured */
  2110. +}
  2111. +
  2112. +static irqreturn_t cf_intr(int irq, void *dev_id)
  2113. +{
  2114. + unsigned int cfctl;
  2115. + struct cf_dev* dev = (struct cf_dev *)dev_id;
  2116. +
  2117. + if (!dev)
  2118. + return IRQ_NONE;
  2119. +
  2120. + cfctl=inl(dev->base + REG_CFCTL);
  2121. + /* unpower the card */
  2122. + outl((cfctl & ~(CFCTL_PWR)), dev->base + REG_CFCTL);
  2123. +
  2124. + if ((cfctl & CFCTL_DET))
  2125. + schedule_delayed_work(&dev->wcf, HZ/2);
  2126. + else
  2127. + schedule_work(&dev->wcf.work);
  2128. + return IRQ_HANDLED;
  2129. +}
  2130. +
  2131. +static void cf_event(struct work_struct *work)
  2132. +{
  2133. + struct cf_dev* dev = container_of(work, struct cf_dev, wcf.work);
  2134. +
  2135. + if (dev) {
  2136. + unsigned int cfctl;
  2137. +
  2138. + cfctl=inl(dev->base + REG_CFCTL);
  2139. + if ((cfctl & CFCTL_DET)) {
  2140. + /* a CF card is inserted, power on the card */
  2141. + outl(((cfctl | CFCTL_PWR) & ~(CFCTL_RST) ), dev->base + REG_CFCTL);
  2142. + set_current_state(TASK_UNINTERRUPTIBLE);
  2143. + schedule_timeout(HZ);
  2144. + cf_config(dev);
  2145. + }
  2146. + else {
  2147. + /* a CF card is removed */
  2148. + cf_release(dev);
  2149. + }
  2150. + }
  2151. +}
  2152. +
  2153. +int __init altcf_init(void)
  2154. +{
  2155. + unsigned int cfctl;
  2156. + int i;
  2157. + ide_hwif_t *hwif;
  2158. + hw_regs_t hw;
  2159. + extern ide_hwif_t ide_hwifs[];
  2160. +
  2161. + for (i=0; i<MAX_HWIFS; i++) {
  2162. + cfctl=inl(cf_devices[i].base + REG_CFCTL);
  2163. + PDEBUG("CF: ctl=%d\n", cfctl);
  2164. + if (cfctl & CFCTL_DET)
  2165. + {
  2166. + /* power off the card */
  2167. + outl(CFCTL_RST, cf_devices[i].base + REG_CFCTL);
  2168. + mdelay(500);
  2169. + cfctl=inl(cf_devices[i].base + REG_CFCTL);
  2170. +
  2171. + /* power on the card */
  2172. + outl(((cfctl | CFCTL_PWR) & ~(CFCTL_RST) ), cf_devices[i].base + REG_CFCTL);
  2173. + mdelay(2000);
  2174. + inl(cf_devices[i].base + REG_CFCTL);
  2175. +
  2176. + /* check if card is in right mode */
  2177. + outb(0xa0, cf_devices[i].ide_base+IDE_SELECT_OFFSET*4);
  2178. + mdelay(50);
  2179. + if (inb(cf_devices[i].ide_base+IDE_SELECT_OFFSET*4) == 0xa0) {
  2180. + /* enable IDE interrupt */
  2181. + outl(IDECTL_IIDE, cf_devices[i].base + REG_IDECTL);
  2182. + ide_hwifs[i].chipset = ide_generic;
  2183. + cf_devices[i].hwif = &ide_hwifs[i];
  2184. +
  2185. + memset(&hw, 0, sizeof hw);
  2186. + cf_init_hwif_ports(&hw, cf_devices[i].ide_base, 0, NULL);
  2187. + hw.chipset = ide_generic;
  2188. + hw.irq = cf_devices[i].ide_irq;
  2189. + if (ide_register_hw(&hw, 1, &hwif)>=0) {
  2190. + cf_devices[i].configured = 1;
  2191. + cf_devices[i].hwif = hwif;
  2192. + }
  2193. + else
  2194. + printk("CF register fails\n");
  2195. + }
  2196. + else printk("Unable to initialize compact flash card. Please re-insert\n");
  2197. + }
  2198. +
  2199. + /* register the detection interrupt */
  2200. + if (request_irq(cf_devices[i].irq, cf_intr, IRQF_DISABLED, "cf", &cf_devices[i])) {
  2201. + PDEBUG("CF: unable to get interrupt %d for detecting inf %d\n",
  2202. + cf_devices[i].irq, i );
  2203. + } else {
  2204. + INIT_DELAYED_WORK(&cf_devices[i].wcf, cf_event);
  2205. + /* enable the detection interrupt */
  2206. + cfctl=inl(cf_devices[i].base + REG_CFCTL);
  2207. + outl(cfctl | CFCTL_IDET, cf_devices[i].base + REG_CFCTL);
  2208. + }
  2209. + }
  2210. +
  2211. + return 0;
  2212. +}
  2213. +
  2214. +#ifdef MODULE
  2215. +static void __exit altcf_exit(void)
  2216. +{
  2217. + unsigned int cfctl;
  2218. + for (i=0; i<MAX_HWIFS; i++) {
  2219. + /* disable detection irq */
  2220. + cfctl=inl(cf_devices[i].base + REG_CFCTL);
  2221. + outl(cfctl & ~CFCTL_IDET, cf_devices[i].base + REG_CFCTL);
  2222. +
  2223. + /* free the detection irq */
  2224. + free_irq(cf_devices[i].irq, &cf_devices[i]);
  2225. +
  2226. + /* release the device */
  2227. + cf_release(&cf_devices[i]);
  2228. + }
  2229. +}
  2230. +
  2231. +module_init(altcf_init);
  2232. +module_exit(altcf_exit);
  2233. +#endif
  2234. diff --git a/arch/nios2nommu/drivers/altfb.c b/arch/nios2nommu/drivers/altfb.c
  2235. new file mode 100644
  2236. index 0000000..cebd659
  2237. --- /dev/null
  2238. +++ b/arch/nios2nommu/drivers/altfb.c
  2239. @@ -0,0 +1,234 @@
  2240. +/*
  2241. + * Altera VGA controller
  2242. + *
  2243. + * linux/drivers/video/vfb.c -- Virtual frame buffer device
  2244. + *
  2245. + * Copyright (C) 2002 James Simmons
  2246. + *
  2247. + * Copyright (C) 1997 Geert Uytterhoeven
  2248. + *
  2249. + * This file is subject to the terms and conditions of the GNU General Public
  2250. + * License. See the file COPYING in the main directory of this archive for
  2251. + * more details.
  2252. + */
  2253. +
  2254. +#include <linux/module.h>
  2255. +#include <linux/kernel.h>
  2256. +#include <linux/errno.h>
  2257. +#include <linux/string.h>
  2258. +#include <linux/mm.h>
  2259. +#include <linux/tty.h>
  2260. +#include <linux/slab.h>
  2261. +#include <linux/vmalloc.h>
  2262. +#include <linux/delay.h>
  2263. +#include <linux/interrupt.h>
  2264. +#include <linux/dma-mapping.h>
  2265. +#include <linux/platform_device.h>
  2266. +
  2267. +#include <asm/uaccess.h>
  2268. +#include <linux/fb.h>
  2269. +#include <linux/init.h>
  2270. +
  2271. +#define vgabase na_vga_controller_0
  2272. +#define XRES 640
  2273. +#define YRES 480
  2274. +#define BPX 16
  2275. +
  2276. + /*
  2277. + * RAM we reserve for the frame buffer. This defines the maximum screen
  2278. + * size
  2279. + *
  2280. + * The default can be overridden if the driver is compiled as a module
  2281. + */
  2282. +
  2283. +#define VIDEOMEMSIZE (XRES * YRES * (BPX>>3))
  2284. +
  2285. +static void *videomemory;
  2286. +static u_long videomemorysize = VIDEOMEMSIZE;
  2287. +module_param(videomemorysize, ulong, 0);
  2288. +
  2289. +static struct fb_var_screeninfo altfb_default __initdata = {
  2290. + .xres = XRES,
  2291. + .yres = YRES,
  2292. + .xres_virtual = XRES,
  2293. + .yres_virtual = YRES,
  2294. + .bits_per_pixel = BPX,
  2295. +#if (BPX == 16)
  2296. + .red = { 11, 5, 0 },
  2297. + .green = { 5, 6, 0 },
  2298. + .blue = { 0, 5, 0 },
  2299. +#else // BPX == 24
  2300. + .red = { 16, 8, 0 },
  2301. + .green = { 8, 8, 0 },
  2302. + .blue = { 0, 8, 0 },
  2303. +#endif
  2304. + .activate = FB_ACTIVATE_NOW,
  2305. + .height = -1,
  2306. + .width = -1,
  2307. + // timing useless ?
  2308. + .pixclock = 20000,
  2309. + .left_margin = 64,
  2310. + .right_margin = 64,
  2311. + .upper_margin = 32,
  2312. + .lower_margin = 32,
  2313. + .hsync_len = 64,
  2314. + .vsync_len = 2,
  2315. + .vmode = FB_VMODE_NONINTERLACED,
  2316. +};
  2317. +
  2318. +static struct fb_fix_screeninfo altfb_fix __initdata = {
  2319. + .id = "Altera FB",
  2320. + .type = FB_TYPE_PACKED_PIXELS,
  2321. + .visual = FB_VISUAL_TRUECOLOR,
  2322. + .line_length = (XRES * (BPX>>3)),
  2323. + .xpanstep = 0,
  2324. + .ypanstep = 0,
  2325. + .ywrapstep = 0,
  2326. + .accel = FB_ACCEL_NONE,
  2327. +};
  2328. +
  2329. +static int altfb_mmap(struct fb_info *info,
  2330. + struct vm_area_struct *vma);
  2331. +
  2332. +static struct fb_ops altfb_ops = {
  2333. + .fb_fillrect = cfb_fillrect,
  2334. + .fb_copyarea = cfb_copyarea,
  2335. + .fb_imageblit = cfb_imageblit,
  2336. + .fb_mmap = altfb_mmap,
  2337. +};
  2338. +
  2339. +
  2340. + /*
  2341. + * Most drivers don't need their own mmap function
  2342. + */
  2343. +
  2344. +static int altfb_mmap(struct fb_info *info,
  2345. + struct vm_area_struct *vma)
  2346. +{
  2347. + /* this is uClinux (no MMU) specific code */
  2348. + vma->vm_flags |= (VM_RESERVED | VM_MAYSHARE);
  2349. + vma->vm_start = (unsigned) videomemory;
  2350. + return 0;
  2351. +}
  2352. +
  2353. + /*
  2354. + * Initialisation
  2355. + */
  2356. +
  2357. +static void altfb_platform_release(struct device *device)
  2358. +{
  2359. + // This is called when the reference count goes to zero.
  2360. + dev_err(device, "This driver is broken, please bug the authors so they will fix it.\n");
  2361. +}
  2362. +
  2363. +static int __init altfb_probe(struct platform_device *dev)
  2364. +{
  2365. + struct fb_info *info;
  2366. + int retval = -ENOMEM;
  2367. + dma_addr_t handle;
  2368. +
  2369. + /*
  2370. + * For real video cards we use ioremap.
  2371. + */
  2372. + if (!(videomemory = dma_alloc_coherent(&dev->dev, PAGE_ALIGN(videomemorysize), &handle, GFP_KERNEL))) {
  2373. + printk(KERN_ERR "altfb: unable to allocate screen memory\n");
  2374. + return retval;
  2375. + }
  2376. + altfb_fix.smem_start = handle;
  2377. + altfb_fix.smem_len = videomemorysize;
  2378. +
  2379. + info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
  2380. + if (!info)
  2381. + goto err;
  2382. +
  2383. + info->screen_base = (char __iomem *)videomemory;
  2384. + info->fbops = &altfb_ops;
  2385. + info->var = altfb_default;
  2386. + info->fix = altfb_fix;
  2387. + info->pseudo_palette = info->par;
  2388. + info->par = NULL;
  2389. + info->flags = FBINFO_FLAG_DEFAULT;
  2390. +
  2391. + retval = fb_alloc_cmap(&info->cmap, 256, 0);
  2392. + if (retval < 0)
  2393. + goto err1;
  2394. +
  2395. + retval = register_framebuffer(info);
  2396. + if (retval < 0)
  2397. + goto err2;
  2398. + platform_set_drvdata(dev, info);
  2399. +
  2400. + outl(0x0,vgabase+0); // Reset the VGA controller
  2401. + outl(videomemory,vgabase+4); // Where our frame buffer starts
  2402. + outl(videomemorysize,vgabase+8); // amount of memory needed
  2403. + outl(0x1,vgabase+0); // Set the go bit
  2404. +
  2405. + printk(KERN_INFO
  2406. + "fb%d: Altera frame buffer device, using %ldK of video memory\n",
  2407. + info->node, videomemorysize >> 10);
  2408. + // printk("vga %08x, video %08x+%08x\n",vgabase,videomemory,videomemorysize);
  2409. + return 0;
  2410. +err2:
  2411. + fb_dealloc_cmap(&info->cmap);
  2412. +err1:
  2413. + framebuffer_release(info);
  2414. +err:
  2415. + dma_free_noncoherent(&dev->dev, videomemorysize, videomemory, handle);
  2416. + return retval;
  2417. +}
  2418. +
  2419. +static int altfb_remove(struct platform_device *dev)
  2420. +{
  2421. + struct fb_info *info = platform_get_drvdata(dev);
  2422. +
  2423. + if (info) {
  2424. + unregister_framebuffer(info);
  2425. + dma_free_noncoherent(&dev->dev, videomemorysize, videomemory, altfb_fix.smem_start);
  2426. + framebuffer_release(info);
  2427. + }
  2428. + return 0;
  2429. +}
  2430. +
  2431. +static struct platform_driver altfb_driver = {
  2432. + .probe = altfb_probe,
  2433. + .remove = altfb_remove,
  2434. + .driver = {
  2435. + .name = "altfb",
  2436. + },
  2437. +};
  2438. +
  2439. +static struct platform_device altfb_device = {
  2440. + .name = "altfb",
  2441. + .id = 0,
  2442. + .dev = {
  2443. + .release = altfb_platform_release,
  2444. + }
  2445. +};
  2446. +
  2447. +static int __init altfb_init(void)
  2448. +{
  2449. + int ret = 0;
  2450. +
  2451. + ret = platform_driver_register(&altfb_driver);
  2452. +
  2453. + if (!ret) {
  2454. + ret = platform_device_register(&altfb_device);
  2455. + if (ret)
  2456. + platform_driver_unregister(&altfb_driver);
  2457. + }
  2458. + return ret;
  2459. +}
  2460. +
  2461. +module_init(altfb_init);
  2462. +
  2463. +#ifdef MODULE
  2464. +static void __exit altfb_exit(void)
  2465. +{
  2466. + platform_device_unregister(&altfb_device);
  2467. + platform_driver_unregister(&altfb_driver);
  2468. +}
  2469. +
  2470. +module_exit(altfb_exit);
  2471. +
  2472. +MODULE_LICENSE("GPL");
  2473. +#endif /* MODULE */
  2474. diff --git a/arch/nios2nommu/drivers/altps2.c b/arch/nios2nommu/drivers/altps2.c
  2475. new file mode 100644
  2476. index 0000000..4a6523c
  2477. --- /dev/null
  2478. +++ b/arch/nios2nommu/drivers/altps2.c
  2479. @@ -0,0 +1,193 @@
  2480. +/*
  2481. + * altera DE2 PS/2
  2482. + *
  2483. + * linux/drivers/input/serio/sa1111ps2.c
  2484. + *
  2485. + * Copyright (C) 2002 Russell King
  2486. + *
  2487. + * This program is free software; you can redistribute it and/or modify
  2488. + * it under the terms of the GNU General Public License as published by
  2489. + * the Free Software Foundation; either version 2 of the License.
  2490. + */
  2491. +#include <linux/module.h>
  2492. +#include <linux/init.h>
  2493. +#include <linux/input.h>
  2494. +#include <linux/serio.h>
  2495. +#include <linux/errno.h>
  2496. +#include <linux/interrupt.h>
  2497. +#include <linux/ioport.h>
  2498. +#include <linux/delay.h>
  2499. +#include <linux/platform_device.h>
  2500. +#include <linux/slab.h>
  2501. +
  2502. +#include <asm/io.h>
  2503. +#include <asm/system.h>
  2504. +
  2505. +
  2506. +struct ps2if {
  2507. + struct serio *io;
  2508. + struct platform_device *dev;
  2509. + unsigned base;
  2510. + unsigned irq;
  2511. +};
  2512. +
  2513. +/*
  2514. + * Read all bytes waiting in the PS2 port. There should be
  2515. + * at the most one, but we loop for safety. If there was a
  2516. + * framing error, we have to manually clear the status.
  2517. + */
  2518. +static irqreturn_t ps2_rxint(int irq, void *dev_id)
  2519. +{
  2520. + struct ps2if *ps2if = dev_id;
  2521. + unsigned int status;
  2522. + int handled = IRQ_NONE;
  2523. +
  2524. + while ((status = inl(ps2if->base)) & 0xffff0000) {
  2525. + serio_interrupt(ps2if->io, status & 0xff, 0);
  2526. + handled = IRQ_HANDLED;
  2527. + }
  2528. + return handled;
  2529. +}
  2530. +
  2531. +/*
  2532. + * Write a byte to the PS2 port. We have to wait for the
  2533. + * port to indicate that the transmitter is empty.
  2534. + */
  2535. +static int ps2_write(struct serio *io, unsigned char val)
  2536. +{
  2537. + struct ps2if *ps2if = io->port_data;
  2538. + outl(val,ps2if->base);
  2539. + // should check command send error
  2540. + if (inl(ps2if->base+4) & (1<<10))
  2541. + {
  2542. + // printk("ps2 write error %02x\n",val);
  2543. + }
  2544. + return 0;
  2545. +}
  2546. +
  2547. +static int ps2_open(struct serio *io)
  2548. +{
  2549. + struct ps2if *ps2if = io->port_data;
  2550. + int ret;
  2551. +
  2552. + ret = request_irq(ps2if->irq, ps2_rxint, 0,
  2553. + "altps2", ps2if);
  2554. + if (ret) {
  2555. + printk(KERN_ERR "altps2: could not allocate IRQ%d: %d\n",
  2556. + ps2if->irq, ret);
  2557. + return ret;
  2558. + }
  2559. + outl(1,ps2if->base+4); // enable rx irq
  2560. + return 0;
  2561. +}
  2562. +
  2563. +static void ps2_close(struct serio *io)
  2564. +{
  2565. + struct ps2if *ps2if = io->port_data;
  2566. + outl(0,ps2if->base); // disable rx irq
  2567. + free_irq(ps2if->irq, ps2if);
  2568. +}
  2569. +
  2570. +/*
  2571. + * Add one device to this driver.
  2572. + */
  2573. +static int ps2_probe(struct platform_device *dev)
  2574. +{
  2575. + struct ps2if *ps2if;
  2576. + struct serio *serio;
  2577. + unsigned int status;
  2578. + int ret;
  2579. +
  2580. + ps2if = kmalloc(sizeof(struct ps2if), GFP_KERNEL);
  2581. + serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
  2582. + if (!ps2if || !serio) {
  2583. + ret = -ENOMEM;
  2584. + goto free;
  2585. + }
  2586. +
  2587. + memset(ps2if, 0, sizeof(struct ps2if));
  2588. + memset(serio, 0, sizeof(struct serio));
  2589. +
  2590. + serio->id.type = SERIO_8042;
  2591. + serio->write = ps2_write;
  2592. + serio->open = ps2_open;
  2593. + serio->close = ps2_close;
  2594. + strlcpy(serio->name, dev->dev.bus_id, sizeof(serio->name));
  2595. + strlcpy(serio->phys, dev->dev.bus_id, sizeof(serio->phys));
  2596. + serio->port_data = ps2if;
  2597. + serio->dev.parent = &dev->dev;
  2598. + ps2if->io = serio;
  2599. + ps2if->dev = dev;
  2600. + platform_set_drvdata(dev, ps2if);
  2601. +
  2602. + /*
  2603. + * Request the physical region for this PS2 port.
  2604. + */
  2605. + if (dev->num_resources < 2) {
  2606. + ret = -ENODEV;
  2607. + goto out;
  2608. + }
  2609. + if (!request_mem_region(dev->resource[0].start,
  2610. + 4,
  2611. + "altps2")) {
  2612. + ret = -EBUSY;
  2613. + goto free;
  2614. + }
  2615. + ps2if->base = dev->resource[0].start;
  2616. + ps2if->irq = dev->resource[1].start;
  2617. + printk("altps2 : base %08x irq %d\n",ps2if->base,ps2if->irq);
  2618. + // clear fifo
  2619. + while ((status = inl(ps2if->base)) & 0xffff0000) {
  2620. + }
  2621. +
  2622. + serio_register_port(ps2if->io);
  2623. + return 0;
  2624. +
  2625. + out:
  2626. + release_mem_region(dev->resource[0].start,4);
  2627. + free:
  2628. + platform_set_drvdata(dev, NULL);
  2629. + kfree(ps2if);
  2630. + kfree(serio);
  2631. + return ret;
  2632. +}
  2633. +
  2634. +/*
  2635. + * Remove one device from this driver.
  2636. + */
  2637. +static int ps2_remove(struct platform_device *dev)
  2638. +{
  2639. + struct ps2if *ps2if = platform_get_drvdata(dev);
  2640. +
  2641. + platform_set_drvdata(dev, NULL);
  2642. + serio_unregister_port(ps2if->io);
  2643. + release_mem_region(dev->resource[0].start,4);
  2644. +
  2645. + kfree(ps2if);
  2646. +
  2647. + return 0;
  2648. +}
  2649. +
  2650. +/*
  2651. + * Our device driver structure
  2652. + */
  2653. +static struct platform_driver ps2_driver = {
  2654. + .probe = ps2_probe,
  2655. + .remove = ps2_remove,
  2656. + .driver = {
  2657. + .name = "altps2",
  2658. + },
  2659. +};
  2660. +
  2661. +static int __init ps2_init(void)
  2662. +{
  2663. + return platform_driver_register(&ps2_driver);
  2664. +}
  2665. +
  2666. +static void __exit ps2_exit(void)
  2667. +{
  2668. + platform_driver_unregister(&ps2_driver);
  2669. +}
  2670. +
  2671. +module_init(ps2_init);
  2672. +module_exit(ps2_exit);
  2673. diff --git a/arch/nios2nommu/drivers/i2c-gpio.c b/arch/nios2nommu/drivers/i2c-gpio.c
  2674. new file mode 100644
  2675. index 0000000..3f5e51a
  2676. --- /dev/null
  2677. +++ b/arch/nios2nommu/drivers/i2c-gpio.c
  2678. @@ -0,0 +1,166 @@
  2679. +/*
  2680. + * drivers/i2c/busses/i2c-gpio.c for Nios2
  2681. + *
  2682. + * drivers/i2c/busses/i2c-ixp2000.c
  2683. + *
  2684. + * I2C adapter for IXP2000 systems using GPIOs for I2C bus
  2685. + *
  2686. + * Author: Deepak Saxena <dsaxena@plexity.net>
  2687. + * Based on IXDP2400 code by: Naeem M. Afzal <naeem.m.afzal@intel.com>
  2688. + * Made generic by: Jeff Daly <jeffrey.daly@intel.com>
  2689. + *
  2690. + * Copyright (c) 2003-2004 MontaVista Software Inc.
  2691. + *
  2692. + * This file is licensed under the terms of the GNU General Public
  2693. + * License version 2. This program is licensed "as is" without any
  2694. + * warranty of any kind, whether express or implied.
  2695. + *
  2696. + * From Jeff Daly:
  2697. + *
  2698. + * I2C adapter driver for Intel IXDP2xxx platforms. This should work for any
  2699. + * IXP2000 platform if it uses the HW GPIO in the same manner. Basically,
  2700. + * SDA and SCL GPIOs have external pullups. Setting the respective GPIO to
  2701. + * an input will make the signal a '1' via the pullup. Setting them to
  2702. + * outputs will pull them down.
  2703. + *
  2704. + * The GPIOs are open drain signals and are used as configuration strap inputs
  2705. + * during power-up so there's generally a buffer on the board that needs to be
  2706. + * 'enabled' to drive the GPIOs.
  2707. + */
  2708. +
  2709. +#include <linux/kernel.h>
  2710. +#include <linux/init.h>
  2711. +#include <linux/platform_device.h>
  2712. +#include <linux/module.h>
  2713. +#include <linux/i2c.h>
  2714. +#include <linux/i2c-algo-bit.h>
  2715. +#include <linux/i2c-id.h>
  2716. +
  2717. +#include <asm/io.h>
  2718. +#include <asm/gpio.h>
  2719. +
  2720. +static inline int gpio_scl_pin(void *data)
  2721. +{
  2722. + return ((struct gpio_i2c_pins*)data)->scl_pin;
  2723. +}
  2724. +
  2725. +static inline int gpio_sda_pin(void *data)
  2726. +{
  2727. + return ((struct gpio_i2c_pins*)data)->sda_pin;
  2728. +}
  2729. +
  2730. +
  2731. +static void gpio_bit_setscl(void *data, int val)
  2732. +{
  2733. + int i = 5000;
  2734. +
  2735. + if (val) {
  2736. + outl(3,gpio_scl_pin(data));
  2737. + while(!(inl(gpio_scl_pin(data)) & 1) && i--);
  2738. + } else {
  2739. + outl(2,gpio_scl_pin(data));
  2740. + }
  2741. +}
  2742. +
  2743. +static void gpio_bit_setsda(void *data, int val)
  2744. +{
  2745. + if (val) {
  2746. + outl(1,gpio_sda_pin(data));
  2747. + } else {
  2748. + outl(0,gpio_sda_pin(data));
  2749. + }
  2750. +}
  2751. +
  2752. +static int gpio_bit_getscl(void *data)
  2753. +{
  2754. + return inl(gpio_scl_pin(data)) & 1;
  2755. +}
  2756. +
  2757. +static int gpio_bit_getsda(void *data)
  2758. +{
  2759. + return inl(gpio_sda_pin(data)) & 1;
  2760. +}
  2761. +
  2762. +struct gpio_i2c_data {
  2763. + struct gpio_i2c_pins *gpio_pins;
  2764. + struct i2c_adapter adapter;
  2765. + struct i2c_algo_bit_data algo_data;
  2766. +};
  2767. +
  2768. +static int gpio_i2c_remove(struct platform_device *plat_dev)
  2769. +{
  2770. + struct gpio_i2c_data *drv_data = platform_get_drvdata(plat_dev);
  2771. +
  2772. + platform_set_drvdata(plat_dev, NULL);
  2773. +
  2774. + i2c_del_adapter(&drv_data->adapter);
  2775. +
  2776. + kfree(drv_data);
  2777. +
  2778. + return 0;
  2779. +}
  2780. +
  2781. +static int gpio_i2c_probe(struct platform_device *plat_dev)
  2782. +{
  2783. + int err;
  2784. + struct gpio_i2c_pins *gpio = plat_dev->dev.platform_data;
  2785. + struct gpio_i2c_data *drv_data =
  2786. + kzalloc(sizeof(struct gpio_i2c_data), GFP_KERNEL);
  2787. +
  2788. + if (!drv_data)
  2789. + return -ENOMEM;
  2790. + drv_data->gpio_pins = gpio;
  2791. +
  2792. + drv_data->algo_data.data = gpio;
  2793. + drv_data->algo_data.setsda = gpio_bit_setsda;
  2794. + drv_data->algo_data.setscl = gpio_bit_setscl;
  2795. + drv_data->algo_data.getsda = gpio_bit_getsda;
  2796. + drv_data->algo_data.getscl = gpio_bit_getscl;
  2797. + drv_data->algo_data.udelay = 6;
  2798. + drv_data->algo_data.timeout = 100;
  2799. +
  2800. + drv_data->adapter.id = I2C_HW_B_IXP2000, // borrowed,
  2801. + strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name,
  2802. + I2C_NAME_SIZE);
  2803. + drv_data->adapter.algo_data = &drv_data->algo_data,
  2804. +
  2805. + drv_data->adapter.dev.parent = &plat_dev->dev;
  2806. + drv_data->adapter.class = I2C_CLASS_ALL;
  2807. +
  2808. + outl(1,gpio->sda_pin);
  2809. + outl(1,gpio->scl_pin);
  2810. +
  2811. + if ((err = i2c_bit_add_bus(&drv_data->adapter)) != 0) {
  2812. + dev_err(&plat_dev->dev, "Could not install, error %d\n", err);
  2813. + kfree(drv_data);
  2814. + return err;
  2815. + }
  2816. +
  2817. + platform_set_drvdata(plat_dev, drv_data);
  2818. + printk("i2c-gpio driver at %08x\n",gpio->sda_pin);
  2819. +
  2820. + return 0;
  2821. +}
  2822. +
  2823. +static struct platform_driver gpio_i2c_driver = {
  2824. + .probe = gpio_i2c_probe,
  2825. + .remove = gpio_i2c_remove,
  2826. + .driver = {
  2827. + .name = "GPIO-I2C",
  2828. + .owner = THIS_MODULE,
  2829. + },
  2830. +};
  2831. +
  2832. +static int __init gpio_i2c_init(void)
  2833. +{
  2834. + return platform_driver_register(&gpio_i2c_driver);
  2835. +}
  2836. +
  2837. +static void __exit gpio_i2c_exit(void)
  2838. +{
  2839. + platform_driver_unregister(&gpio_i2c_driver);
  2840. +}
  2841. +
  2842. +module_init(gpio_i2c_init);
  2843. +module_exit(gpio_i2c_exit);
  2844. +
  2845. diff --git a/arch/nios2nommu/drivers/pci/Kconfig b/arch/nios2nommu/drivers/pci/Kconfig
  2846. new file mode 100644
  2847. index 0000000..6c3b175
  2848. --- /dev/null
  2849. +++ b/arch/nios2nommu/drivers/pci/Kconfig
  2850. @@ -0,0 +1,4 @@
  2851. +config PCI_ALTPCI
  2852. + bool "Altera PCI host bridge"
  2853. + select PCI
  2854. + default n
  2855. diff --git a/arch/nios2nommu/drivers/pci/Makefile b/arch/nios2nommu/drivers/pci/Makefile
  2856. new file mode 100644
  2857. index 0000000..b027e1e
  2858. --- /dev/null
  2859. +++ b/arch/nios2nommu/drivers/pci/Makefile
  2860. @@ -0,0 +1,6 @@
  2861. +#
  2862. +# Makefile for the PCI specific kernel interface routines under Linux.
  2863. +#
  2864. +
  2865. +obj-y += pci.o
  2866. +obj-$(CONFIG_PCI_ALTPCI) += altpci.o setup-irq.o pci-auto.o
  2867. diff --git a/arch/nios2nommu/drivers/pci/altpci.c b/arch/nios2nommu/drivers/pci/altpci.c
  2868. new file mode 100644
  2869. index 0000000..85959ea
  2870. --- /dev/null
  2871. +++ b/arch/nios2nommu/drivers/pci/altpci.c
  2872. @@ -0,0 +1,204 @@
  2873. +/* arch/sh/kernel/pci.c
  2874. + * $Id: altpci.c,v 1.1 2006/07/05 06:23:17 gerg Exp $
  2875. + *
  2876. + * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org>
  2877. + *
  2878. + *
  2879. + * These functions are collected here to reduce duplication of common
  2880. + * code amongst the many platform-specific PCI support code files.
  2881. + *
  2882. + * These routines require the following board-specific routines:
  2883. + * void pcibios_fixup_irqs();
  2884. + *
  2885. + * See include/asm-sh/pci.h for more information.
  2886. + */
  2887. +
  2888. +#include <linux/kernel.h>
  2889. +#include <linux/pci.h>
  2890. +#include <linux/init.h>
  2891. +
  2892. +/*
  2893. + * Direct access to PCI hardware...
  2894. + */
  2895. +#define pcicfg_space (na_pci_compiler_0_PCI_Bus_Access) // avalon space
  2896. +#define pciio (pcicfg_space+0x100000) // pci io device base in avalon space
  2897. +#define pcimm (pcicfg_space+0x200000) // pci mem device base in avalon space
  2898. + // idsel of ad11=dev0,ad12=dev1 , using type 0 config request
  2899. +#define pcicfg(dev,fun,reg) (pcicfg_space | ((dev)<<11) | ((fun)<<8) | (reg)) // cfg space
  2900. +
  2901. +// FIX ME for your board, dram device for external pci masters access
  2902. +static int __init alt_pci_init(void)
  2903. +{
  2904. + unsigned dev,fun;
  2905. + // setup dram bar
  2906. + dev=0; fun=0;
  2907. + outl(nasys_program_mem,pcicfg(dev,fun,0x10)); // mem space
  2908. + outw(0x0006,pcicfg(dev,fun,0x04)); // enable master, mem space
  2909. + return 0;
  2910. +}
  2911. +
  2912. +subsys_initcall(alt_pci_init);
  2913. +
  2914. +#define PCICFG(bus, devfn, where) (pcicfg_space | (bus->number << 16) | (devfn << 8) | (where & ~3))
  2915. +#define ALT_PCI_IO_BASE (pciio)
  2916. +#define ALT_PCI_IO_SIZE 0x100000
  2917. +#define ALT_PCI_MEMORY_BASE (pcimm)
  2918. +#define ALT_PCI_MEM_SIZE 0x100000
  2919. +
  2920. +/*
  2921. + * Functions for accessing PCI configuration space with type 1 accesses
  2922. + */
  2923. +
  2924. +// FIX ME for your board, number of pci bus, and number of devices
  2925. +static inline int pci_range_ck(struct pci_bus *bus, unsigned int devfn)
  2926. +{
  2927. + if (bus->number > 0 || PCI_SLOT(devfn) == 0 || PCI_SLOT(devfn) > 2)
  2928. + return -1;
  2929. +
  2930. + return 0;
  2931. +}
  2932. +
  2933. +static int alt_pci_read(struct pci_bus *bus, unsigned int devfn,
  2934. + int where, int size, u32 *val)
  2935. +{
  2936. + u32 data;
  2937. +
  2938. + if (pci_range_ck(bus, devfn))
  2939. + return PCIBIOS_DEVICE_NOT_FOUND;
  2940. +
  2941. + // local_irq_save(flags);
  2942. + data = inl(PCICFG(bus, devfn, where));
  2943. + // local_irq_restore(flags);
  2944. +
  2945. + switch (size) {
  2946. + case 1:
  2947. + *val = (data >> ((where & 3) << 3)) & 0xff;
  2948. + break;
  2949. + case 2:
  2950. + *val = (data >> ((where & 2) << 3)) & 0xffff;
  2951. + break;
  2952. + case 4:
  2953. + *val = data;
  2954. + break;
  2955. + default:
  2956. + return PCIBIOS_FUNC_NOT_SUPPORTED;
  2957. + }
  2958. +
  2959. + return PCIBIOS_SUCCESSFUL;
  2960. +}
  2961. +
  2962. +/*
  2963. + * we'll do a read,
  2964. + * mask,write operation.
  2965. + * We'll allow an odd byte offset, though it should be illegal.
  2966. + */
  2967. +static int alt_pci_write(struct pci_bus *bus, unsigned int devfn,
  2968. + int where, int size, u32 val)
  2969. +{
  2970. + int shift;
  2971. + u32 data;
  2972. +
  2973. + if (pci_range_ck(bus, devfn))
  2974. + return PCIBIOS_DEVICE_NOT_FOUND;
  2975. +
  2976. + // local_irq_save(flags);
  2977. + data = inl(PCICFG(bus, devfn, where));
  2978. + // local_irq_restore(flags);
  2979. +
  2980. + switch (size) {
  2981. + case 1:
  2982. + shift = (where & 3) << 3;
  2983. + data &= ~(0xff << shift);
  2984. + data |= ((val & 0xff) << shift);
  2985. + break;
  2986. + case 2:
  2987. + shift = (where & 2) << 3;
  2988. + data &= ~(0xffff << shift);
  2989. + data |= ((val & 0xffff) << shift);
  2990. + break;
  2991. + case 4:
  2992. + data = val;
  2993. + break;
  2994. + default:
  2995. + return PCIBIOS_FUNC_NOT_SUPPORTED;
  2996. + }
  2997. +
  2998. + outl(data, PCICFG(bus, devfn, where));
  2999. +
  3000. + return PCIBIOS_SUCCESSFUL;
  3001. +}
  3002. +
  3003. +struct pci_ops alt_pci_ops = {
  3004. + .read = alt_pci_read,
  3005. + .write = alt_pci_write,
  3006. +};
  3007. +
  3008. +static struct resource alt_io_resource = {
  3009. + .name = "ALTPCI IO",
  3010. + .start = ALT_PCI_IO_BASE,
  3011. + .end = ALT_PCI_IO_BASE + ALT_PCI_IO_SIZE - 1,
  3012. + .flags = IORESOURCE_IO
  3013. +};
  3014. +
  3015. +static struct resource alt_mem_resource = {
  3016. + .name = "ALTPCI mem",
  3017. + .start = ALT_PCI_MEMORY_BASE,
  3018. + .end = ALT_PCI_MEMORY_BASE + ALT_PCI_MEM_SIZE - 1,
  3019. + .flags = IORESOURCE_MEM
  3020. +};
  3021. +
  3022. +extern struct pci_ops alt_pci_ops;
  3023. +
  3024. +struct pci_channel board_pci_channels[] = {
  3025. + { &alt_pci_ops, &alt_io_resource, &alt_mem_resource, 0, 0xff },
  3026. + { NULL, NULL, NULL, 0, 0 },
  3027. +};
  3028. +
  3029. +char *pcibios_setup(char *option)
  3030. +{
  3031. + /* Nothing for us to handle. */
  3032. + return(option);
  3033. +}
  3034. +
  3035. +void pcibios_fixup_bus(struct pci_bus *b)
  3036. +{
  3037. +}
  3038. +
  3039. +/*
  3040. + * IRQ functions
  3041. + */
  3042. +static u8 __init altpci_no_swizzle(struct pci_dev *dev, u8 *pin)
  3043. +{
  3044. + /* no swizzling */
  3045. + return PCI_SLOT(dev->devfn);
  3046. +}
  3047. +
  3048. +// FIX ME for your board, nios2 irqn mapping
  3049. +int __init pcibios_map_platform_irq(u8 slot, u8 pin)
  3050. +{
  3051. + int irq = na_irqn_0_irq + ((slot-1)*4) + (pin-1);
  3052. + // printk("map slot %d pin %d irq %d\n",slot,pin,irq);
  3053. + return irq;
  3054. +}
  3055. +
  3056. +static int altpci_pci_lookup_irq(struct pci_dev *dev, u8 slot, u8 pin)
  3057. +{
  3058. + int irq = -1;
  3059. +
  3060. + /* now lookup the actual IRQ on a platform specific basis (pci-'platform'.c) */
  3061. + irq = pcibios_map_platform_irq(slot,pin);
  3062. + if( irq < 0 ) {
  3063. + // printk("PCI: Error mapping IRQ on device %s\n", pci_name(dev));
  3064. + return irq;
  3065. + }
  3066. +
  3067. + // printk("Setting IRQ for slot %s to %d\n", pci_name(dev), irq);
  3068. +
  3069. + return irq;
  3070. +}
  3071. +
  3072. +void __init pcibios_fixup_irqs(void)
  3073. +{
  3074. + pci_fixup_irqs(altpci_no_swizzle, altpci_pci_lookup_irq);
  3075. +}
  3076. +
  3077. diff --git a/arch/nios2nommu/drivers/pci/pci-auto.c b/arch/nios2nommu/drivers/pci/pci-auto.c
  3078. new file mode 100644
  3079. index 0000000..e1cdfdc
  3080. --- /dev/null
  3081. +++ b/arch/nios2nommu/drivers/pci/pci-auto.c
  3082. @@ -0,0 +1,559 @@
  3083. +/*
  3084. + * PCI autoconfiguration library
  3085. + *
  3086. + * Author: Matt Porter <mporter@mvista.com>
  3087. + *
  3088. + * Copyright 2000, 2001 MontaVista Software Inc.
  3089. + * Copyright 2001 Bradley D. LaRonde <brad@ltc.com>
  3090. + * Copyright 2003 Paul Mundt <lethal@linux-sh.org>
  3091. + *
  3092. + * This program is free software; you can redistribute it and/or modify it
  3093. + * under the terms of the GNU General Public License as published by the
  3094. + * Free Software Foundation; either version 2 of the License, or (at your
  3095. + * option) any later version.
  3096. + */
  3097. +
  3098. +/*
  3099. + * Modified for MIPS by Jun Sun, jsun@mvista.com
  3100. + *
  3101. + * . Simplify the interface between pci_auto and the rest: a single function.
  3102. + * . Assign resources from low address to upper address.
  3103. + * . change most int to u32.
  3104. + *
  3105. + * Further modified to include it as mips generic code, ppopov@mvista.com.
  3106. + *
  3107. + * 2001-10-26 Bradley D. LaRonde <brad@ltc.com>
  3108. + * - Add a top_bus argument to the "early config" functions so that
  3109. + * they can set a fake parent bus pointer to convince the underlying
  3110. + * pci ops to use type 1 configuration for sub busses.
  3111. + * - Set bridge base and limit registers correctly.
  3112. + * - Align io and memory base properly before and after bridge setup.
  3113. + * - Don't fall through to pci_setup_bars for bridge.
  3114. + * - Reformat the debug output to look more like lspci's output.
  3115. + *
  3116. + * Cloned for SuperH by M. R. Brown, mrbrown@0xd6.org
  3117. + *
  3118. + * 2003-08-05 Paul Mundt <lethal@linux-sh.org>
  3119. + * - Don't update the BAR values on systems that already have valid addresses
  3120. + * and don't want these updated for whatever reason, by way of a new config
  3121. + * option check. However, we still read in the old BAR values so that they
  3122. + * can still be reported through the debug output.
  3123. + */
  3124. +
  3125. +#include <linux/kernel.h>
  3126. +#include <linux/init.h>
  3127. +#include <linux/types.h>
  3128. +#include <linux/pci.h>
  3129. +
  3130. +#undef DEBUG
  3131. +#define DEBUG // you can remove debug message here
  3132. +
  3133. +#ifdef DEBUG
  3134. +#define DBG(x...) printk(x)
  3135. +#else
  3136. +#define DBG(x...)
  3137. +#endif
  3138. +
  3139. +/*
  3140. + * These functions are used early on before PCI scanning is done
  3141. + * and all of the pci_dev and pci_bus structures have been created.
  3142. + */
  3143. +static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
  3144. + int top_bus, int busnr, int devfn)
  3145. +{
  3146. + static struct pci_dev dev;
  3147. + static struct pci_bus bus;
  3148. +
  3149. + dev.bus = &bus;
  3150. + dev.sysdata = hose;
  3151. + dev.devfn = devfn;
  3152. + bus.number = busnr;
  3153. + bus.ops = hose->pci_ops;
  3154. +
  3155. + if(busnr != top_bus)
  3156. + /* Fake a parent bus structure. */
  3157. + bus.parent = &bus;
  3158. + else
  3159. + bus.parent = NULL;
  3160. +
  3161. + return &dev;
  3162. +}
  3163. +
  3164. +#define EARLY_PCI_OP(rw, size, type) \
  3165. +int early_##rw##_config_##size(struct pci_channel *hose, \
  3166. + int top_bus, int bus, int devfn, int offset, type value) \
  3167. +{ \
  3168. + return pci_##rw##_config_##size( \
  3169. + fake_pci_dev(hose, top_bus, bus, devfn), \
  3170. + offset, value); \
  3171. +}
  3172. +
  3173. +EARLY_PCI_OP(read, byte, u8 *)
  3174. +EARLY_PCI_OP(read, word, u16 *)
  3175. +EARLY_PCI_OP(read, dword, u32 *)
  3176. +EARLY_PCI_OP(write, byte, u8)
  3177. +EARLY_PCI_OP(write, word, u16)
  3178. +EARLY_PCI_OP(write, dword, u32)
  3179. +
  3180. +static struct resource *io_resource_inuse;
  3181. +static struct resource *mem_resource_inuse;
  3182. +
  3183. +static u32 pciauto_lower_iospc;
  3184. +static u32 pciauto_upper_iospc;
  3185. +
  3186. +static u32 pciauto_lower_memspc;
  3187. +static u32 pciauto_upper_memspc;
  3188. +
  3189. +static void __init
  3190. +pciauto_setup_bars(struct pci_channel *hose,
  3191. + int top_bus,
  3192. + int current_bus,
  3193. + int pci_devfn,
  3194. + int bar_limit)
  3195. +{
  3196. + u32 bar_response, bar_size, bar_value;
  3197. + u32 bar, addr_mask, bar_nr = 0;
  3198. + u32 * upper_limit;
  3199. + u32 * lower_limit;
  3200. + int found_mem64 = 0;
  3201. +
  3202. + for (bar = PCI_BASE_ADDRESS_0; bar <= bar_limit; bar+=4) {
  3203. +#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
  3204. + u32 bar_addr;
  3205. +
  3206. + /* Read the old BAR value */
  3207. + early_read_config_dword(hose, top_bus,
  3208. + current_bus,
  3209. + pci_devfn,
  3210. + bar,
  3211. + &bar_addr);
  3212. +#endif
  3213. +
  3214. + /* Tickle the BAR and get the response */
  3215. + early_write_config_dword(hose, top_bus,
  3216. + current_bus,
  3217. + pci_devfn,
  3218. + bar,
  3219. + 0xffffffff);
  3220. +
  3221. + early_read_config_dword(hose, top_bus,
  3222. + current_bus,
  3223. + pci_devfn,
  3224. + bar,
  3225. + &bar_response);
  3226. +
  3227. +#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
  3228. + /*
  3229. + * Write the old BAR value back out, only update the BAR
  3230. + * if we implicitly want resources to be updated, which
  3231. + * is done by the generic code further down. -- PFM.
  3232. + */
  3233. + early_write_config_dword(hose, top_bus,
  3234. + current_bus,
  3235. + pci_devfn,
  3236. + bar,
  3237. + bar_addr);
  3238. +#endif
  3239. +
  3240. + /* If BAR is not implemented go to the next BAR */
  3241. + if (!bar_response)
  3242. + continue;
  3243. +
  3244. + /*
  3245. + * Workaround for a BAR that doesn't use its upper word,
  3246. + * like the ALi 1535D+ PCI DC-97 Controller Modem (M5457).
  3247. + * bdl <brad@ltc.com>
  3248. + */
  3249. + if (!(bar_response & 0xffff0000))
  3250. + bar_response |= 0xffff0000;
  3251. +
  3252. +retry:
  3253. + /* Check the BAR type and set our address mask */
  3254. + if (bar_response & PCI_BASE_ADDRESS_SPACE) {
  3255. + addr_mask = PCI_BASE_ADDRESS_IO_MASK;
  3256. + upper_limit = &pciauto_upper_iospc;
  3257. + lower_limit = &pciauto_lower_iospc;
  3258. + DBG(" I/O");
  3259. + } else {
  3260. + if ((bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==
  3261. + PCI_BASE_ADDRESS_MEM_TYPE_64)
  3262. + found_mem64 = 1;
  3263. +
  3264. + addr_mask = PCI_BASE_ADDRESS_MEM_MASK;
  3265. + upper_limit = &pciauto_upper_memspc;
  3266. + lower_limit = &pciauto_lower_memspc;
  3267. + DBG(" Mem");
  3268. + }
  3269. +
  3270. +
  3271. + /* Calculate requested size */
  3272. + bar_size = ~(bar_response & addr_mask) + 1;
  3273. +
  3274. + /* Allocate a base address */
  3275. + bar_value = ((*lower_limit - 1) & ~(bar_size - 1)) + bar_size;
  3276. +
  3277. + if ((bar_value + bar_size) > *upper_limit) {
  3278. + if (bar_response & PCI_BASE_ADDRESS_SPACE) {
  3279. + if (io_resource_inuse->child) {
  3280. + io_resource_inuse =
  3281. + io_resource_inuse->child;
  3282. + pciauto_lower_iospc =
  3283. + io_resource_inuse->start;
  3284. + pciauto_upper_iospc =
  3285. + io_resource_inuse->end + 1;
  3286. + goto retry;
  3287. + }
  3288. +
  3289. + } else {
  3290. + if (mem_resource_inuse->child) {
  3291. + mem_resource_inuse =
  3292. + mem_resource_inuse->child;
  3293. + pciauto_lower_memspc =
  3294. + mem_resource_inuse->start;
  3295. + pciauto_upper_memspc =
  3296. + mem_resource_inuse->end + 1;
  3297. + goto retry;
  3298. + }
  3299. + }
  3300. + DBG(" unavailable -- skipping, value %x size %x\n",
  3301. + bar_value, bar_size);
  3302. + continue;
  3303. + }
  3304. +
  3305. +#if 1
  3306. + /* Write it out and update our limit */
  3307. + early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
  3308. + bar, bar_value);
  3309. +#endif
  3310. +
  3311. + *lower_limit = bar_value + bar_size;
  3312. +
  3313. + /*
  3314. + * If we are a 64-bit decoder then increment to the
  3315. + * upper 32 bits of the bar and force it to locate
  3316. + * in the lower 4GB of memory.
  3317. + */
  3318. + if (found_mem64) {
  3319. + bar += 4;
  3320. + early_write_config_dword(hose, top_bus,
  3321. + current_bus,
  3322. + pci_devfn,
  3323. + bar,
  3324. + 0x00000000);
  3325. + }
  3326. +
  3327. + DBG(" at 0x%.8x [size=0x%x]\n", bar_value, bar_size);
  3328. +
  3329. + bar_nr++;
  3330. + }
  3331. +
  3332. +}
  3333. +
  3334. +static void __init
  3335. +pciauto_prescan_setup_bridge(struct pci_channel *hose,
  3336. + int top_bus,
  3337. + int current_bus,
  3338. + int pci_devfn,
  3339. + int sub_bus)
  3340. +{
  3341. + /* Configure bus number registers */
  3342. + early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
  3343. + PCI_PRIMARY_BUS, current_bus);
  3344. + early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
  3345. + PCI_SECONDARY_BUS, sub_bus + 1);
  3346. + early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
  3347. + PCI_SUBORDINATE_BUS, 0xff);
  3348. +
  3349. + /* Align memory and I/O to 1MB and 4KB boundaries. */
  3350. + pciauto_lower_memspc = (pciauto_lower_memspc + (0x100000 - 1))
  3351. + & ~(0x100000 - 1);
  3352. + pciauto_lower_iospc = (pciauto_lower_iospc + (0x1000 - 1))
  3353. + & ~(0x1000 - 1);
  3354. +
  3355. + /* Set base (lower limit) of address range behind bridge. */
  3356. + early_write_config_word(hose, top_bus, current_bus, pci_devfn,
  3357. + PCI_MEMORY_BASE, pciauto_lower_memspc >> 16);
  3358. + early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
  3359. + PCI_IO_BASE, (pciauto_lower_iospc & 0x0000f000) >> 8);
  3360. + early_write_config_word(hose, top_bus, current_bus, pci_devfn,
  3361. + PCI_IO_BASE_UPPER16, pciauto_lower_iospc >> 16);
  3362. +
  3363. + /* We don't support prefetchable memory for now, so disable */
  3364. + early_write_config_word(hose, top_bus, current_bus, pci_devfn,
  3365. + PCI_PREF_MEMORY_BASE, 0);
  3366. + early_write_config_word(hose, top_bus, current_bus, pci_devfn,
  3367. + PCI_PREF_MEMORY_LIMIT, 0);
  3368. +}
  3369. +
  3370. +static void __init
  3371. +pciauto_postscan_setup_bridge(struct pci_channel *hose,
  3372. + int top_bus,
  3373. + int current_bus,
  3374. + int pci_devfn,
  3375. + int sub_bus)
  3376. +{
  3377. + u32 temp;
  3378. +
  3379. + /*
  3380. + * [jsun] we always bump up baselines a little, so that if there
  3381. + * nothing behind P2P bridge, we don't wind up overlapping IO/MEM
  3382. + * spaces.
  3383. + */
  3384. + pciauto_lower_memspc += 1;
  3385. + pciauto_lower_iospc += 1;
  3386. +
  3387. + /* Configure bus number registers */
  3388. + early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
  3389. + PCI_SUBORDINATE_BUS, sub_bus);
  3390. +
  3391. + /* Set upper limit of address range behind bridge. */
  3392. + early_write_config_word(hose, top_bus, current_bus, pci_devfn,
  3393. + PCI_MEMORY_LIMIT, pciauto_lower_memspc >> 16);
  3394. + early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
  3395. + PCI_IO_LIMIT, (pciauto_lower_iospc & 0x0000f000) >> 8);
  3396. + early_write_config_word(hose, top_bus, current_bus, pci_devfn,
  3397. + PCI_IO_LIMIT_UPPER16, pciauto_lower_iospc >> 16);
  3398. +
  3399. + /* Align memory and I/O to 1MB and 4KB boundaries. */
  3400. + pciauto_lower_memspc = (pciauto_lower_memspc + (0x100000 - 1))
  3401. + & ~(0x100000 - 1);
  3402. + pciauto_lower_iospc = (pciauto_lower_iospc + (0x1000 - 1))
  3403. + & ~(0x1000 - 1);
  3404. +
  3405. + /* Enable memory and I/O accesses, enable bus master */
  3406. + early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
  3407. + PCI_COMMAND, &temp);
  3408. + early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
  3409. + PCI_COMMAND, temp | PCI_COMMAND_IO | PCI_COMMAND_MEMORY
  3410. + | PCI_COMMAND_MASTER);
  3411. +}
  3412. +
  3413. +static void __init
  3414. +pciauto_prescan_setup_cardbus_bridge(struct pci_channel *hose,
  3415. + int top_bus,
  3416. + int current_bus,
  3417. + int pci_devfn,
  3418. + int sub_bus)
  3419. +{
  3420. + /* Configure bus number registers */
  3421. + early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
  3422. + PCI_PRIMARY_BUS, current_bus);
  3423. + early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
  3424. + PCI_SECONDARY_BUS, sub_bus + 1);
  3425. + early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
  3426. + PCI_SUBORDINATE_BUS, 0xff);
  3427. +
  3428. + /* Align memory and I/O to 4KB and 4 byte boundaries. */
  3429. + pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1))
  3430. + & ~(0x1000 - 1);
  3431. + pciauto_lower_iospc = (pciauto_lower_iospc + (0x4 - 1))
  3432. + & ~(0x4 - 1);
  3433. +
  3434. + early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
  3435. + PCI_CB_MEMORY_BASE_0, pciauto_lower_memspc);
  3436. + early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
  3437. + PCI_CB_IO_BASE_0, pciauto_lower_iospc);
  3438. +}
  3439. +
  3440. +static void __init
  3441. +pciauto_postscan_setup_cardbus_bridge(struct pci_channel *hose,
  3442. + int top_bus,
  3443. + int current_bus,
  3444. + int pci_devfn,
  3445. + int sub_bus)
  3446. +{
  3447. + u32 temp;
  3448. +
  3449. +#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
  3450. + /*
  3451. + * [jsun] we always bump up baselines a little, so that if there
  3452. + * nothing behind P2P bridge, we don't wind up overlapping IO/MEM
  3453. + * spaces.
  3454. + */
  3455. + pciauto_lower_memspc += 1;
  3456. + pciauto_lower_iospc += 1;
  3457. +#endif
  3458. +
  3459. + /*
  3460. + * Configure subordinate bus number. The PCI subsystem
  3461. + * bus scan will renumber buses (reserving three additional
  3462. + * for this PCI<->CardBus bridge for the case where a CardBus
  3463. + * adapter contains a P2P or CB2CB bridge.
  3464. + */
  3465. +
  3466. + early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
  3467. + PCI_SUBORDINATE_BUS, sub_bus);
  3468. +
  3469. + /*
  3470. + * Reserve an additional 4MB for mem space and 16KB for
  3471. + * I/O space. This should cover any additional space
  3472. + * requirement of unusual CardBus devices with
  3473. + * additional bridges that can consume more address space.
  3474. + *
  3475. + * Although pcmcia-cs currently will reprogram bridge
  3476. + * windows, the goal is to add an option to leave them
  3477. + * alone and use the bridge window ranges as the regions
  3478. + * that are searched for free resources upon hot-insertion
  3479. + * of a device. This will allow a PCI<->CardBus bridge
  3480. + * configured by this routine to happily live behind a
  3481. + * P2P bridge in a system.
  3482. + */
  3483. +#if defined(CONFIG_SH_HS7751RVOIP) || defined(CONFIG_SH_RTS7751R2D)
  3484. + pciauto_lower_memspc += 0x00400000;
  3485. + pciauto_lower_iospc += 0x00004000;
  3486. +#endif
  3487. +
  3488. + /* Align memory and I/O to 4KB and 4 byte boundaries. */
  3489. + pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1))
  3490. + & ~(0x1000 - 1);
  3491. + pciauto_lower_iospc = (pciauto_lower_iospc + (0x4 - 1))
  3492. + & ~(0x4 - 1);
  3493. + /* Set up memory and I/O filter limits, assume 32-bit I/O space */
  3494. + early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
  3495. + PCI_CB_MEMORY_LIMIT_0, pciauto_lower_memspc - 1);
  3496. + early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
  3497. + PCI_CB_IO_LIMIT_0, pciauto_lower_iospc - 1);
  3498. +
  3499. + /* Enable memory and I/O accesses, enable bus master */
  3500. + early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
  3501. + PCI_COMMAND, &temp);
  3502. + early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
  3503. + PCI_COMMAND, temp | PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
  3504. + PCI_COMMAND_MASTER);
  3505. +}
  3506. +
  3507. +#define PCIAUTO_IDE_MODE_MASK 0x05
  3508. +
  3509. +static int __init
  3510. +pciauto_bus_scan(struct pci_channel *hose, int top_bus, int current_bus)
  3511. +{
  3512. + int sub_bus;
  3513. + u32 pci_devfn, pci_class, cmdstat, found_multi=0;
  3514. + unsigned short vid, did;
  3515. + unsigned char header_type;
  3516. + int devfn_start = 0;
  3517. + int devfn_stop = 0xff;
  3518. +
  3519. + sub_bus = current_bus;
  3520. +
  3521. + if (hose->first_devfn)
  3522. + devfn_start = hose->first_devfn;
  3523. + if (hose->last_devfn)
  3524. + devfn_stop = hose->last_devfn;
  3525. +
  3526. + for (pci_devfn=devfn_start; pci_devfn<devfn_stop; pci_devfn++) {
  3527. +
  3528. + if (PCI_FUNC(pci_devfn) && !found_multi)
  3529. + continue;
  3530. +
  3531. + early_read_config_word(hose, top_bus, current_bus, pci_devfn,
  3532. + PCI_VENDOR_ID, &vid);
  3533. +
  3534. + if (vid == 0xffff) continue;
  3535. +
  3536. + early_read_config_byte(hose, top_bus, current_bus, pci_devfn,
  3537. + PCI_HEADER_TYPE, &header_type);
  3538. +
  3539. + if (!PCI_FUNC(pci_devfn))
  3540. + found_multi = header_type & 0x80;
  3541. +
  3542. + early_read_config_word(hose, top_bus, current_bus, pci_devfn,
  3543. + PCI_DEVICE_ID, &did);
  3544. +
  3545. + early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
  3546. + PCI_CLASS_REVISION, &pci_class);
  3547. +
  3548. + if ((pci_class & 0xff000000)==0) continue; // devices before pci 2.0
  3549. +
  3550. + DBG("%.2x:%.2x.%x Class %.4x: %.4x:%.4x",
  3551. + current_bus, PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn),
  3552. + pci_class >> 16, vid, did);
  3553. + if (pci_class & 0xff)
  3554. + DBG(" (rev %.2x)", pci_class & 0xff);
  3555. + DBG("\n");
  3556. +
  3557. + if ((pci_class >> 16) == PCI_CLASS_BRIDGE_PCI) {
  3558. + DBG(" Bridge: primary=%.2x, secondary=%.2x\n",
  3559. + current_bus, sub_bus + 1);
  3560. +#if defined(CONFIG_SH_HS7751RVOIP) || defined(CONFIG_SH_RTS7751R2D)
  3561. + pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_1);
  3562. +#endif
  3563. + pciauto_prescan_setup_bridge(hose, top_bus, current_bus,
  3564. + pci_devfn, sub_bus);
  3565. + DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
  3566. + sub_bus + 1,
  3567. + pciauto_lower_iospc, pciauto_lower_memspc);
  3568. + sub_bus = pciauto_bus_scan(hose, top_bus, sub_bus+1);
  3569. + DBG("Back to bus %.2x\n", current_bus);
  3570. + pciauto_postscan_setup_bridge(hose, top_bus, current_bus,
  3571. + pci_devfn, sub_bus);
  3572. + continue;
  3573. + } else if ((pci_class >> 16) == PCI_CLASS_BRIDGE_CARDBUS) {
  3574. + DBG(" CARDBUS Bridge: primary=%.2x, secondary=%.2x\n",
  3575. + current_bus, sub_bus + 1);
  3576. + DBG("PCI Autoconfig: Found CardBus bridge, device %d function %d\n", PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn));
  3577. + /* Place CardBus Socket/ExCA registers */
  3578. + pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_0);
  3579. +
  3580. + pciauto_prescan_setup_cardbus_bridge(hose, top_bus,
  3581. + current_bus, pci_devfn, sub_bus);
  3582. +
  3583. + DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
  3584. + sub_bus + 1,
  3585. + pciauto_lower_iospc, pciauto_lower_memspc);
  3586. + sub_bus = pciauto_bus_scan(hose, top_bus, sub_bus+1);
  3587. + DBG("Back to bus %.2x, sub_bus is %x\n", current_bus, sub_bus);
  3588. + pciauto_postscan_setup_cardbus_bridge(hose, top_bus,
  3589. + current_bus, pci_devfn, sub_bus);
  3590. + continue;
  3591. + } else if ((pci_class >> 16) == PCI_CLASS_STORAGE_IDE) {
  3592. +
  3593. + unsigned char prg_iface;
  3594. +
  3595. + early_read_config_byte(hose, top_bus, current_bus,
  3596. + pci_devfn, PCI_CLASS_PROG, &prg_iface);
  3597. + if (!(prg_iface & PCIAUTO_IDE_MODE_MASK)) {
  3598. + DBG("Skipping legacy mode IDE controller\n");
  3599. + continue;
  3600. + }
  3601. + }
  3602. +
  3603. + /*
  3604. + * Found a peripheral, enable some standard
  3605. + * settings
  3606. + */
  3607. + early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
  3608. + PCI_COMMAND, &cmdstat);
  3609. + early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
  3610. + PCI_COMMAND, cmdstat | PCI_COMMAND_IO |
  3611. + PCI_COMMAND_MEMORY |
  3612. + PCI_COMMAND_MASTER);
  3613. +#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
  3614. + early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
  3615. + PCI_LATENCY_TIMER, 0x80);
  3616. +#endif
  3617. +
  3618. + /* Allocate PCI I/O and/or memory space */
  3619. + pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_5);
  3620. + }
  3621. + return sub_bus;
  3622. +}
  3623. +
  3624. +int __init
  3625. +pciauto_assign_resources(int busno, struct pci_channel *hose)
  3626. +{
  3627. + /* setup resource limits */
  3628. + io_resource_inuse = hose->io_resource;
  3629. + mem_resource_inuse = hose->mem_resource;
  3630. +
  3631. + pciauto_lower_iospc = io_resource_inuse->start;
  3632. + pciauto_upper_iospc = io_resource_inuse->end + 1;
  3633. + pciauto_lower_memspc = mem_resource_inuse->start;
  3634. + pciauto_upper_memspc = mem_resource_inuse->end + 1;
  3635. + DBG("Autoconfig PCI channel 0x%p\n", hose);
  3636. + DBG("Scanning bus %.2x, I/O 0x%.8x:0x%.8x, Mem 0x%.8x:0x%.8x\n",
  3637. + busno, pciauto_lower_iospc, pciauto_upper_iospc,
  3638. + pciauto_lower_memspc, pciauto_upper_memspc);
  3639. +
  3640. + return pciauto_bus_scan(hose, busno, busno);
  3641. +}
  3642. diff --git a/arch/nios2nommu/drivers/pci/pci.c b/arch/nios2nommu/drivers/pci/pci.c
  3643. new file mode 100644
  3644. index 0000000..83436df
  3645. --- /dev/null
  3646. +++ b/arch/nios2nommu/drivers/pci/pci.c
  3647. @@ -0,0 +1,151 @@
  3648. +/* arch/sh/kernel/pci.c
  3649. + * $Id: pci.c,v 1.2 2007/01/25 01:26:48 gerg Exp $
  3650. + *
  3651. + * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org>
  3652. + *
  3653. + *
  3654. + * These functions are collected here to reduce duplication of common
  3655. + * code amongst the many platform-specific PCI support code files.
  3656. + *
  3657. + * These routines require the following board-specific routines:
  3658. + * void pcibios_fixup_irqs();
  3659. + *
  3660. + * See include/asm-sh/pci.h for more information.
  3661. + */
  3662. +
  3663. +#include <linux/kernel.h>
  3664. +#include <linux/pci.h>
  3665. +#include <linux/init.h>
  3666. +
  3667. +static int __init pcibios_init(void)
  3668. +{
  3669. + struct pci_channel *p;
  3670. + struct pci_bus *bus;
  3671. + int busno;
  3672. +
  3673. +#if 1
  3674. + /* assign resources */
  3675. + busno = 0;
  3676. + for (p = board_pci_channels; p->pci_ops != NULL; p++) {
  3677. + busno = pciauto_assign_resources(busno, p) + 1;
  3678. + }
  3679. +#endif
  3680. +
  3681. + /* scan the buses */
  3682. + busno = 0;
  3683. + for (p= board_pci_channels; p->pci_ops != NULL; p++) {
  3684. + bus = pci_scan_bus(busno, p->pci_ops, p);
  3685. + busno = bus->subordinate+1;
  3686. + }
  3687. +
  3688. + /* board-specific fixups */
  3689. + pcibios_fixup_irqs();
  3690. +
  3691. + return 0;
  3692. +}
  3693. +
  3694. +subsys_initcall(pcibios_init);
  3695. +
  3696. +void
  3697. +pcibios_update_resource(struct pci_dev *dev, struct resource *root,
  3698. + struct resource *res, int resource)
  3699. +{
  3700. + u32 new, check;
  3701. + int reg;
  3702. +
  3703. + new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
  3704. + if (resource < 6) {
  3705. + reg = PCI_BASE_ADDRESS_0 + 4*resource;
  3706. + } else if (resource == PCI_ROM_RESOURCE) {
  3707. + res->flags |= IORESOURCE_ROM_ENABLE;
  3708. + new |= PCI_ROM_ADDRESS_ENABLE;
  3709. + reg = dev->rom_base_reg;
  3710. + } else {
  3711. + /* Somebody might have asked allocation of a non-standard resource */
  3712. + return;
  3713. + }
  3714. +
  3715. + pci_write_config_dword(dev, reg, new);
  3716. + pci_read_config_dword(dev, reg, &check);
  3717. + if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
  3718. + printk(KERN_ERR "PCI: Error while updating region "
  3719. + "%s/%d (%08x != %08x)\n", pci_name(dev), resource,
  3720. + new, check);
  3721. + }
  3722. +}
  3723. +
  3724. +/*
  3725. + * We need to avoid collisions with `mirrored' VGA ports
  3726. + * and other strange ISA hardware, so we always want the
  3727. + * addresses to be allocated in the 0x000-0x0ff region
  3728. + * modulo 0x400.
  3729. + */
  3730. +void pcibios_align_resource(void *data, struct resource *res,
  3731. + resource_size_t size, resource_size_t align)
  3732. +{
  3733. + if (res->flags & IORESOURCE_IO) {
  3734. + unsigned long start = res->start;
  3735. +
  3736. + if (start & 0x300) {
  3737. + start = (start + 0x3ff) & ~0x3ff;
  3738. + res->start = start;
  3739. + }
  3740. + }
  3741. +}
  3742. +
  3743. +int pcibios_enable_device(struct pci_dev *dev, int mask)
  3744. +{
  3745. + u16 cmd, old_cmd;
  3746. + int idx;
  3747. + struct resource *r;
  3748. +
  3749. + pci_read_config_word(dev, PCI_COMMAND, &cmd);
  3750. + old_cmd = cmd;
  3751. + for(idx=0; idx<6; idx++) {
  3752. + if (!(mask & (1 << idx)))
  3753. + continue;
  3754. + r = &dev->resource[idx];
  3755. + if (!r->start && r->end) {
  3756. + printk(KERN_ERR "PCI: Device %s not available because "
  3757. + "of resource collisions\n", pci_name(dev));
  3758. + return -EINVAL;
  3759. + }
  3760. + if (r->flags & IORESOURCE_IO)
  3761. + cmd |= PCI_COMMAND_IO;
  3762. + if (r->flags & IORESOURCE_MEM)
  3763. + cmd |= PCI_COMMAND_MEMORY;
  3764. + }
  3765. + if (dev->resource[PCI_ROM_RESOURCE].start)
  3766. + cmd |= PCI_COMMAND_MEMORY;
  3767. + if (cmd != old_cmd) {
  3768. + printk(KERN_INFO "PCI: Enabling device %s (%04x -> %04x)\n",
  3769. + pci_name(dev), old_cmd, cmd);
  3770. + pci_write_config_word(dev, PCI_COMMAND, cmd);
  3771. + }
  3772. + return 0;
  3773. +}
  3774. +
  3775. +/*
  3776. + * If we set up a device for bus mastering, we need to check and set
  3777. + * the latency timer as it may not be properly set.
  3778. + */
  3779. +unsigned int pcibios_max_latency = 255;
  3780. +
  3781. +void pcibios_set_master(struct pci_dev *dev)
  3782. +{
  3783. + u8 lat;
  3784. + pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
  3785. + if (lat < 16)
  3786. + lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
  3787. + else if (lat > pcibios_max_latency)
  3788. + lat = pcibios_max_latency;
  3789. + else
  3790. + return;
  3791. + printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n", pci_name(dev), lat);
  3792. + pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
  3793. +}
  3794. +
  3795. +void __init pcibios_update_irq(struct pci_dev *dev, int irq)
  3796. +{
  3797. + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
  3798. +}
  3799. diff --git a/arch/nios2nommu/drivers/pci/setup-irq.c b/arch/nios2nommu/drivers/pci/setup-irq.c
  3800. new file mode 100644
  3801. index 0000000..0fa8f98
  3802. --- /dev/null
  3803. +++ b/arch/nios2nommu/drivers/pci/setup-irq.c
  3804. @@ -0,0 +1 @@
  3805. +#include "../../../../drivers/pci/setup-irq.c"
  3806. diff --git a/arch/nios2nommu/drivers/spi.c b/arch/nios2nommu/drivers/spi.c
  3807. new file mode 100644
  3808. index 0000000..72a2519
  3809. --- /dev/null
  3810. +++ b/arch/nios2nommu/drivers/spi.c
  3811. @@ -0,0 +1,315 @@
  3812. +#ifdef MODULE
  3813. +#include <linux/module.h>
  3814. +#include <linux/version.h>
  3815. +#else
  3816. +#define MOD_INC_USE_COUNT
  3817. +#define MOD_DEC_USE_COUNT
  3818. +#endif
  3819. +
  3820. +#include <linux/types.h>
  3821. +#include <linux/errno.h>
  3822. +#include <linux/kernel.h>
  3823. +#include <linux/fs.h>
  3824. +#include <linux/major.h>
  3825. +#include <linux/sched.h>
  3826. +#include <linux/slab.h>
  3827. +#include <linux/ioport.h>
  3828. +#include <linux/fcntl.h>
  3829. +#include <linux/unistd.h>
  3830. +#include <linux/init.h>
  3831. +
  3832. +
  3833. +#include <asm/io.h>
  3834. +#include <asm/segment.h>
  3835. +#include <asm/system.h>
  3836. +#include <asm/spi.h>
  3837. +
  3838. +#if !defined(SEEK_SET)
  3839. +#define SEEK_SET 0
  3840. +#endif
  3841. +
  3842. +
  3843. +static unsigned int spi_major = 60; /* a local major, can be overwritten */
  3844. +static int openflag = 0;
  3845. +static np_spi * const spi_ptr = na_spi;
  3846. +
  3847. + /*******************************/
  3848. + /* SPI data transfer routines. */
  3849. + /*******************************/
  3850. +
  3851. +#define SPI_XMIT_READY np_spistatus_trdy_mask
  3852. +#define SPI_RECV_READY np_spistatus_rrdy_mask
  3853. +
  3854. +#define SPI_BUSYPOLL_TIMEOUT 1000
  3855. +
  3856. +// returns -1 if there is no data present, otherwise returns
  3857. +// the value
  3858. +inline int SPI_Recv_Byte(char *pdata )
  3859. +{
  3860. + if (spi_ptr->np_spistatus & SPI_RECV_READY){
  3861. + *pdata = spi_ptr->np_spirxdata & 0xff;
  3862. + return 0;
  3863. + }
  3864. + return -1;
  3865. +}
  3866. +
  3867. +
  3868. +// Sends the 16 bit address+data
  3869. +inline int SPI_Send_Byte( unsigned char address, char data )
  3870. +{
  3871. + u16 value = ((address & 0xFF) << 8) | (data & 0xFF);
  3872. +
  3873. + if ( spi_ptr->np_spistatus & SPI_XMIT_READY ) {
  3874. + spi_ptr->np_spitxdata = value;
  3875. + return 0;
  3876. + }
  3877. +
  3878. + return -1;
  3879. +}
  3880. +
  3881. +
  3882. +
  3883. + /*************************/
  3884. + /* SPI Driver functions. */
  3885. + /*************************/
  3886. +
  3887. +int spi_reset( void )
  3888. +{
  3889. + // Nothing to do: The Nios does _not_
  3890. + // support burst xfers. Chip Enables
  3891. + // (Selects) are inactive after each xfer.
  3892. + return 0;
  3893. +}
  3894. +
  3895. +
  3896. +/***************************************************/
  3897. +/* The SPI Write routine. The first 16 bits are */
  3898. +/* the device register, and the rest of the buffer */
  3899. +/* is data. */
  3900. +/***************************************************/
  3901. +
  3902. +ssize_t spi_write(struct file *filp, const char *buf, size_t count, loff_t *ppos)
  3903. +{
  3904. + int i;
  3905. + unsigned char addr;
  3906. + int timeout;
  3907. + char temp;
  3908. +
  3909. + if ( count < 3 )
  3910. + return -EINVAL; /* Address is 2 bytes: Must have _something_ to send */
  3911. +
  3912. + addr = buf[0]; /* chip register address. */
  3913. + spi_ptr->np_spistatus=0;
  3914. +
  3915. + for ( i = sizeof(u16); i<count; i++ )
  3916. + {
  3917. + timeout=SPI_BUSYPOLL_TIMEOUT;
  3918. + while (SPI_Send_Byte(addr, buf[i])==-1)
  3919. + {
  3920. + if (--timeout==0)
  3921. + {
  3922. + printk("spi_write time out\n");
  3923. + return i; /* return the number of bytes sent */
  3924. + }
  3925. + }
  3926. + /* read the data */
  3927. + timeout=SPI_BUSYPOLL_TIMEOUT;
  3928. + while (SPI_Recv_Byte(&temp)==-1)
  3929. + {
  3930. + if (--timeout==0)
  3931. + break;
  3932. + }
  3933. + }
  3934. + return i;
  3935. +// unsigned char *temp; /* Our pointer to the buffer */
  3936. +// int i;
  3937. +// int addr;
  3938. +//
  3939. +// if ( count < 3 )
  3940. +// return -EINVAL; /* Address is 2 bytes: Must have _something_ to send */
  3941. +//
  3942. +// temp = (char *)buf;
  3943. +// addr = (int)*((u16 *)temp); /* chip register address. */
  3944. +// temp += sizeof(u16);
  3945. +//
  3946. +// for ( i = count - sizeof(u16); i; i--, temp++ )
  3947. +// *temp = (unsigned char)SPI_Transfer( addr, (int)*temp );
  3948. +//
  3949. +//
  3950. +// return count; /* we can always send all data */
  3951. +}
  3952. +
  3953. +//int spi_read( struct inode *inode, struct file *file, char *buf, int count )
  3954. +ssize_t spi_read(struct file *filp, char *buf, size_t count, loff_t *ppos)
  3955. +{
  3956. + int i;
  3957. + unsigned char addr;
  3958. + int timeout;
  3959. + char temp;
  3960. +
  3961. + if ( count < 3 )
  3962. + return -EINVAL; /* Address is 2 bytes: Must have _something_ to send */
  3963. +
  3964. + addr = buf[0]; /* chip register address. */
  3965. + spi_ptr->np_spistatus=0;
  3966. +
  3967. + /* empty the np_spirxdata register */
  3968. + SPI_Recv_Byte(&temp);
  3969. +
  3970. + for ( i = sizeof(u16); i<count; i++ )
  3971. + {
  3972. + /* send the address */
  3973. + timeout=SPI_BUSYPOLL_TIMEOUT;
  3974. + while (SPI_Send_Byte(addr, 0)==-1)
  3975. + {
  3976. + if (--timeout==0)
  3977. + {
  3978. + printk("spi_read write address time out\n");
  3979. + return i;
  3980. + }
  3981. + }
  3982. +
  3983. + /* read the data */
  3984. + timeout=SPI_BUSYPOLL_TIMEOUT;
  3985. + while (SPI_Recv_Byte(&buf[i])==-1)
  3986. + {
  3987. + if (--timeout==0)
  3988. + {
  3989. + printk("spi_read read data time out\n");
  3990. + return i;
  3991. + }
  3992. + }
  3993. +#if 0
  3994. + printk("spi_read time left %d\n", timeout);
  3995. +#endif
  3996. + }
  3997. + return i;
  3998. +}
  3999. +
  4000. +loff_t spi_lseek(struct file *filp, loff_t offset, int origin)
  4001. +{
  4002. +#if 0
  4003. + int bit_count, i;
  4004. +#endif
  4005. +
  4006. + if ( origin != SEEK_SET || offset != (offset & 0xFFFF) )
  4007. + {
  4008. + errno = -EINVAL;
  4009. + return -1;
  4010. + }
  4011. +
  4012. +#if 0
  4013. + /****************************************/
  4014. + /* Nios SPI implementation safeguard: */
  4015. + /* It is possible to have more than */
  4016. + /* one CS active at a time. Check that */
  4017. + /* the given address is a power of two. */
  4018. + /****************************************/
  4019. + bit_count = 0;
  4020. + for ( i = 0; i < sizeof(u16); i++ )
  4021. + {
  4022. + if ( (1 << i) & offset )
  4023. + {
  4024. + if ( ++bit_count > 1 )
  4025. + {
  4026. + errno = -EINVAL;
  4027. + return -1;
  4028. + }
  4029. + }
  4030. + }
  4031. +#endif
  4032. + spi_ptr->np_spislaveselect = offset;
  4033. + return 0;
  4034. +}
  4035. +
  4036. +int spi_open(struct inode *inode, struct file *filp)
  4037. +{
  4038. + preempt_disable();
  4039. + if (openflag) {
  4040. + preempt_enable();
  4041. + return -EBUSY;
  4042. + }
  4043. +
  4044. + MOD_INC_USE_COUNT;
  4045. + openflag = 1;
  4046. + preempt_enable();
  4047. +
  4048. + return 0;
  4049. +}
  4050. +
  4051. +int spi_release(struct inode *inode, struct file *filp)
  4052. +{
  4053. + openflag = 0;
  4054. + MOD_DEC_USE_COUNT;
  4055. + return 0;
  4056. +}
  4057. +
  4058. +
  4059. +/* static struct file_operations spi_fops */
  4060. +
  4061. +static struct file_operations spi_fops = {
  4062. + llseek: spi_lseek, /* Set chip-select line. The offset is used as an address. */
  4063. + read: spi_read,
  4064. + write: spi_write,
  4065. + open: spi_open,
  4066. + release: spi_release,
  4067. +};
  4068. +
  4069. +
  4070. +int register_NIOS_SPI( void )
  4071. +{
  4072. + int result = register_chrdev( spi_major, "spi", &spi_fops );
  4073. + if ( result < 0 )
  4074. + {
  4075. + printk( "SPI: unable to get major %d for SPI bus \n", spi_major );
  4076. + return result;
  4077. + }/*end-if*/
  4078. +
  4079. + if ( spi_major == 0 )
  4080. + spi_major = result; /* here we got our major dynamically */
  4081. +
  4082. + /* reserve our port, but check first if free */
  4083. + if ( check_region( (unsigned int)na_spi, sizeof(np_spi) ) )
  4084. + {
  4085. + printk( "SPI: port at adr 0x%08x already occupied\n", (unsigned int)na_spi );
  4086. + unregister_chrdev( spi_major, "spi" );
  4087. +
  4088. + return result;
  4089. + }/*end-if*/
  4090. +
  4091. + return 0;
  4092. +}
  4093. +
  4094. +void unregister_NIOS_SPI( void )
  4095. +{
  4096. + if ( spi_major > 0 )
  4097. + unregister_chrdev( spi_major, "spi" );
  4098. +
  4099. + release_region( (unsigned int)na_spi, sizeof(np_spi) );
  4100. +}
  4101. +
  4102. +
  4103. +#ifdef MODULE
  4104. +void cleanup_module( void )
  4105. +{
  4106. + unregister_NIOS_SPI();
  4107. +}
  4108. +
  4109. +
  4110. +
  4111. +int init_module( void )
  4112. +{
  4113. + return register_NIOS_SPI();
  4114. +}
  4115. +#endif
  4116. +
  4117. +
  4118. +static int __init nios_spi_init(void)
  4119. +{
  4120. + printk("SPI: Nios SPI bus device version 0.1\n");
  4121. + return register_NIOS_SPI();
  4122. +// if ( register_NIOS_SPI() )
  4123. +// printk("*** Cannot initialize SPI device.\n");
  4124. +}
  4125. +
  4126. +__initcall(nios_spi_init);
  4127. diff --git a/arch/nios2nommu/kernel/ChangeLog b/arch/nios2nommu/kernel/ChangeLog
  4128. new file mode 100644
  4129. index 0000000..7f1449d
  4130. --- /dev/null
  4131. +++ b/arch/nios2nommu/kernel/ChangeLog
  4132. @@ -0,0 +1,27 @@
  4133. +2004-06-17 Ken Hill <khill@microtronix.com>
  4134. +
  4135. + * process.c (machine_restart): Add code to disable interrups and
  4136. + jump to the cpu reset address.
  4137. + (machine_halt): Add code to disable interrupts and spinlock.
  4138. + (machine_power_off): Add code to disable interrupts and spinlock.
  4139. +
  4140. +2004-06-16 Ken Hill <khill@microtronix.com>
  4141. +
  4142. + * nios2_ksyms.c: Remove hard_reset_now.
  4143. +
  4144. +2004-06-10 Ken Hill <khill@microtronix.com>
  4145. +
  4146. + * nios2_ksyms.c: Add EXPORT_SYMBOL_NOVERS(__down) to solve insmod for
  4147. + some modules.
  4148. +
  4149. +2004-06-02 Ken Hill <khill@microtronix.com>
  4150. +
  4151. + * entry.S (software_exception): Add a safety catch for old applications that may
  4152. + have been linked against an older library. This does not add any overhead to
  4153. + system call processing.
  4154. +
  4155. +2004-04-15 Ken Hill <khill@microtronix.com>
  4156. +
  4157. + * setup.c (setup_arch): Remove ROMFS message from debug printk kernel message.
  4158. + Add copyright and GNU license notice.
  4159. +
  4160. diff --git a/arch/nios2nommu/kernel/Makefile b/arch/nios2nommu/kernel/Makefile
  4161. new file mode 100644
  4162. index 0000000..a056ff1
  4163. --- /dev/null
  4164. +++ b/arch/nios2nommu/kernel/Makefile
  4165. @@ -0,0 +1,22 @@
  4166. +#
  4167. +# Makefile for the linux kernel.
  4168. +#
  4169. +# Note! Dependencies are done automagically by 'make dep', which also
  4170. +# removes any old dependencies. DON'T put your own dependencies here
  4171. +# unless it's something special (ie not a .c file).
  4172. +#
  4173. +# Note 2! The CFLAGS definitions are now in the main makefile...
  4174. +
  4175. +extra-y := head.o init_task.o vmlinux.lds
  4176. +
  4177. +obj-y := entry.o traps.o irq.o syscalltable.o \
  4178. + process.o signal.o setup.o sys_nios2.o \
  4179. + semaphore.o io.o usb.o\
  4180. + time.o ptrace.o start.o nios2_ksyms.o
  4181. +
  4182. +obj-$(CONFIG_MODULES) += module.o
  4183. +obj-$(CONFIG_CONSOLE) += console.o
  4184. +obj-$(CONFIG_PIO_DEVICES) += pio.o
  4185. +obj-$(CONFIG_AVALON_DMA) += dma.o
  4186. +
  4187. +
  4188. diff --git a/arch/nios2nommu/kernel/asm-offsets.c b/arch/nios2nommu/kernel/asm-offsets.c
  4189. new file mode 100644
  4190. index 0000000..4877eba
  4191. --- /dev/null
  4192. +++ b/arch/nios2nommu/kernel/asm-offsets.c
  4193. @@ -0,0 +1,201 @@
  4194. +/*
  4195. + * This program is used to generate definitions needed by
  4196. + * assembly language modules.
  4197. + *
  4198. + * We use the technique used in the OSF Mach kernel code:
  4199. + * generate asm statements containing #defines,
  4200. + * compile this file to assembler, and then extract the
  4201. + * #defines from the assembly-language output.
  4202. + */
  4203. +
  4204. +#include <linux/stddef.h>
  4205. +#include <linux/sched.h>
  4206. +#include <linux/kernel_stat.h>
  4207. +#include <linux/ptrace.h>
  4208. +#include <asm/bootinfo.h>
  4209. +#include <asm/irq.h>
  4210. +#include <asm/hardirq.h>
  4211. +#include <asm/nios.h>
  4212. +
  4213. +#define DEFINE(sym, val) \
  4214. + asm volatile("\n->" #sym " %0 " #val : : "i" (val))
  4215. +
  4216. +#define BLANK() asm volatile("\n->" : : )
  4217. +
  4218. +int main(void)
  4219. +{
  4220. +
  4221. + /* offsets into the task struct */
  4222. + DEFINE(TASK_STATE, offsetof(struct task_struct, state));
  4223. + DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
  4224. + DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
  4225. + DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
  4226. + DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
  4227. + DEFINE(TASK_THREAD_INFO, offsetof(struct task_struct, stack));
  4228. + DEFINE(TASK_MM, offsetof(struct task_struct, mm));
  4229. + DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
  4230. +
  4231. + /* offsets into the kernel_stat struct */
  4232. + DEFINE(STAT_IRQ, offsetof(struct kernel_stat, irqs));
  4233. +
  4234. + /* offsets into the irq_cpustat_t struct */
  4235. + DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, __softirq_pending));
  4236. +
  4237. + /* offsets into the irq_node struct */
  4238. + DEFINE(IRQ_HANDLER, offsetof(struct irq_hand, handler));
  4239. + DEFINE(IRQ_FLAGS, offsetof(struct irq_hand, flags));
  4240. + DEFINE(IRQ_DEV_ID, offsetof(struct irq_hand, dev_id));
  4241. + DEFINE(IRQ_DEVNAME, offsetof(struct irq_hand, devname));
  4242. +
  4243. + /* offsets into the thread struct */
  4244. + DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
  4245. + DEFINE(THREAD_KPSR, offsetof(struct thread_struct, kpsr));
  4246. + DEFINE(THREAD_KESR, offsetof(struct thread_struct, kesr));
  4247. + DEFINE(THREAD_FLAGS, offsetof(struct thread_struct, flags));
  4248. +
  4249. + /* offsets into the pt_regs */
  4250. + DEFINE(PT_ORIG_R2, offsetof(struct pt_regs, orig_r2));
  4251. + DEFINE(PT_R1, offsetof(struct pt_regs, r1));
  4252. + DEFINE(PT_R2, offsetof(struct pt_regs, r2));
  4253. + DEFINE(PT_R3, offsetof(struct pt_regs, r3));
  4254. + DEFINE(PT_R4, offsetof(struct pt_regs, r4));
  4255. + DEFINE(PT_R5, offsetof(struct pt_regs, r5));
  4256. + DEFINE(PT_R6, offsetof(struct pt_regs, r6));
  4257. + DEFINE(PT_R7, offsetof(struct pt_regs, r7));
  4258. + DEFINE(PT_R8, offsetof(struct pt_regs, r8));
  4259. + DEFINE(PT_R9, offsetof(struct pt_regs, r9));
  4260. + DEFINE(PT_R10, offsetof(struct pt_regs, r10));
  4261. + DEFINE(PT_R11, offsetof(struct pt_regs, r11));
  4262. + DEFINE(PT_R12, offsetof(struct pt_regs, r12));
  4263. + DEFINE(PT_R13, offsetof(struct pt_regs, r13));
  4264. + DEFINE(PT_R14, offsetof(struct pt_regs, r14));
  4265. + DEFINE(PT_R15, offsetof(struct pt_regs, r15));
  4266. + DEFINE(PT_EA, offsetof(struct pt_regs, ea));
  4267. + DEFINE(PT_RA, offsetof(struct pt_regs, ra));
  4268. + DEFINE(PT_FP, offsetof(struct pt_regs, fp));
  4269. + DEFINE(PT_SP, offsetof(struct pt_regs, sp));
  4270. + DEFINE(PT_GP, offsetof(struct pt_regs, gp));
  4271. + DEFINE(PT_ESTATUS, offsetof(struct pt_regs, estatus));
  4272. + DEFINE(PT_STATUS_EXTENSION, offsetof(struct pt_regs, status_extension));
  4273. + DEFINE(PT_REGS_SIZE, sizeof(struct pt_regs));
  4274. +
  4275. + /* offsets into the switch_stack */
  4276. + DEFINE(SW_R16, offsetof(struct switch_stack, r16));
  4277. + DEFINE(SW_R17, offsetof(struct switch_stack, r17));
  4278. + DEFINE(SW_R18, offsetof(struct switch_stack, r18));
  4279. + DEFINE(SW_R19, offsetof(struct switch_stack, r19));
  4280. + DEFINE(SW_R20, offsetof(struct switch_stack, r20));
  4281. + DEFINE(SW_R21, offsetof(struct switch_stack, r21));
  4282. + DEFINE(SW_R22, offsetof(struct switch_stack, r22));
  4283. + DEFINE(SW_R23, offsetof(struct switch_stack, r23));
  4284. + DEFINE(SW_FP, offsetof(struct switch_stack, fp));
  4285. + DEFINE(SW_GP, offsetof(struct switch_stack, gp));
  4286. + DEFINE(SW_RA, offsetof(struct switch_stack, ra));
  4287. + DEFINE(SWITCH_STACK_SIZE, sizeof(struct switch_stack));
  4288. +
  4289. + DEFINE(PS_S_ASM, PS_S);
  4290. +
  4291. + DEFINE(NIOS2_STATUS_PIE_MSK_ASM, NIOS2_STATUS_PIE_MSK);
  4292. + DEFINE(NIOS2_STATUS_PIE_OFST_ASM, NIOS2_STATUS_PIE_OFST);
  4293. + DEFINE(NIOS2_STATUS_U_MSK_ASM, NIOS2_STATUS_U_MSK);
  4294. + DEFINE(NIOS2_STATUS_U_OFST_ASM, NIOS2_STATUS_U_OFST);
  4295. +
  4296. + /* offsets into the kernel_stat struct */
  4297. + DEFINE(STAT_IRQ, offsetof(struct kernel_stat, irqs));
  4298. +
  4299. + /* Offsets in thread_info structure, used in assembly code */
  4300. + DEFINE(TI_TASK, offsetof(struct thread_info, task));
  4301. + DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
  4302. + DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
  4303. + DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
  4304. + DEFINE(TI_PREEMPT_COUNT, offsetof(struct thread_info, preempt_count));
  4305. +
  4306. + DEFINE(PREEMPT_ACTIVE_ASM, PREEMPT_ACTIVE);
  4307. +
  4308. + DEFINE(THREAD_SIZE_ASM, THREAD_SIZE);
  4309. +
  4310. + DEFINE(TIF_SYSCALL_TRACE_ASM, TIF_SYSCALL_TRACE);
  4311. + DEFINE(TIF_NOTIFY_RESUME_ASM, TIF_NOTIFY_RESUME);
  4312. + DEFINE(TIF_SIGPENDING_ASM, TIF_SIGPENDING);
  4313. + DEFINE(TIF_NEED_RESCHED_ASM, TIF_NEED_RESCHED);
  4314. + DEFINE(TIF_POLLING_NRFLAG_ASM, TIF_POLLING_NRFLAG);
  4315. +
  4316. + DEFINE(_TIF_SYSCALL_TRACE_ASM, _TIF_SYSCALL_TRACE);
  4317. + DEFINE(_TIF_NOTIFY_RESUME_ASM, _TIF_NOTIFY_RESUME);
  4318. + DEFINE(_TIF_SIGPENDING_ASM, _TIF_SIGPENDING);
  4319. + DEFINE(_TIF_NEED_RESCHED_ASM, _TIF_NEED_RESCHED);
  4320. + DEFINE(_TIF_POLLING_NRFLAG_ASM, _TIF_POLLING_NRFLAG);
  4321. +
  4322. + DEFINE(_TIF_WORK_MASK_ASM, _TIF_WORK_MASK);
  4323. +
  4324. +#if defined(na_flash_kernel) && defined(na_flash_kernel_end)
  4325. + /* the flash chip */
  4326. + DEFINE(NIOS_FLASH_START, na_flash_kernel);
  4327. + DEFINE(NIOS_FLASH_END, na_flash_kernel_end);
  4328. +
  4329. + /* the kernel placement in the flash*/
  4330. + DEFINE(KERNEL_FLASH_START, na_flash_kernel);
  4331. + DEFINE(KERNEL_FLASH_LEN, 0x200000);
  4332. +
  4333. + /* the romdisk placement in the flash */
  4334. + DEFINE(LINUX_ROMFS_START, na_flash_kernel+0x200000);
  4335. + DEFINE(LINUX_ROMFS_END, na_flash_kernel_end);
  4336. +#else
  4337. +#error Sorry,you dont have na_flash_kernel or na_flash_kernel_end defined in the core.
  4338. +#endif
  4339. +
  4340. +#if defined(nasys_program_mem) && defined(nasys_program_mem_end)
  4341. + /* the sdram */
  4342. + DEFINE(LINUX_SDRAM_START, nasys_program_mem);
  4343. + DEFINE(LINUX_SDRAM_END, nasys_program_mem_end);
  4344. +#else
  4345. +#error Sorry,you dont have nasys_program_mem or nasys_program_mem_end defined in the core.
  4346. +#endif
  4347. +
  4348. + DEFINE(NIOS2_ICACHE_SIZE, nasys_icache_size);
  4349. + DEFINE(NIOS2_ICACHE_LINE_SIZE, nasys_icache_line_size);
  4350. + DEFINE(NIOS2_DCACHE_SIZE, nasys_dcache_size);
  4351. + DEFINE(NIOS2_DCACHE_LINE_SIZE, nasys_dcache_line_size);
  4352. +
  4353. +#if defined(na_enet)
  4354. + DEFINE(NA_ENET_ASM, na_enet);
  4355. +#endif
  4356. +
  4357. +#if defined(na_enet_reset)
  4358. + DEFINE(NA_ENET_RESET_ASM, na_enet_reset);
  4359. +#endif
  4360. +
  4361. +#if defined(na_enet_reset_n)
  4362. + DEFINE(NA_ENET_RESET_N_ASM, na_enet_reset_n);
  4363. +#endif
  4364. +
  4365. +#if defined(na_ide_interface)
  4366. + DEFINE(NA_IDE_INTERFACE_ASM, na_ide_interface);
  4367. +#endif
  4368. +
  4369. +#if defined(na_timer0)
  4370. + DEFINE(NA_TIMER0_ASM, na_timer0);
  4371. + DEFINE(NP_TIMERCONTROL_ASM, offsetof(np_timer, np_timercontrol));
  4372. + DEFINE(NP_TIMERSTATUS_ASM, offsetof(np_timer, np_timerstatus));
  4373. +#endif
  4374. +
  4375. +#if defined(na_uart0)
  4376. + DEFINE(NA_UART0_ASM, na_uart0);
  4377. + DEFINE(NP_UARTCONTROL_ASM, offsetof(np_uart, np_uartcontrol));
  4378. + DEFINE(NP_UARTSTATUS_ASM, offsetof(np_uart, np_uartstatus));
  4379. +#endif
  4380. +
  4381. +#if defined(na_uart1)
  4382. + DEFINE(NA_UART1_ASM, na_uart1);
  4383. +#endif
  4384. +
  4385. +#if defined(na_uart2)
  4386. + DEFINE(NA_UART2_ASM, na_uart2);
  4387. +#endif
  4388. +
  4389. +#if defined(na_uart3)
  4390. + DEFINE(NA_UART3_ASM, na_uart3);
  4391. +#endif
  4392. +
  4393. + return 0;
  4394. +}
  4395. diff --git a/arch/nios2nommu/kernel/dma.c b/arch/nios2nommu/kernel/dma.c
  4396. new file mode 100644
  4397. index 0000000..f23323b
  4398. --- /dev/null
  4399. +++ b/arch/nios2nommu/kernel/dma.c
  4400. @@ -0,0 +1,342 @@
  4401. +/*
  4402. + * arch/nios2nommu/kernel/dma.c
  4403. + *
  4404. + * Copyright (C) 2005 Microtronix Datacom Ltd
  4405. + *
  4406. + * PC like DMA API for Nios's DMAC.
  4407. + *
  4408. + * This file is subject to the terms and conditions of the GNU General Public
  4409. + * License. See the file "COPYING" in the main directory of this archive
  4410. + * for more details.
  4411. + *
  4412. + * Written by Wentao Xu <wentao@microtronix.com>
  4413. + */
  4414. +
  4415. +#include <linux/init.h>
  4416. +#include <linux/irq.h>
  4417. +#include <linux/interrupt.h>
  4418. +#include <linux/module.h>
  4419. +#include <linux/fs.h>
  4420. +#include <linux/seq_file.h>
  4421. +#include <linux/proc_fs.h>
  4422. +#include <asm/io.h>
  4423. +#include <asm/dma.h>
  4424. +
  4425. +/* nios2 dma controller register map */
  4426. +#define REG_DMA_STATUS 0
  4427. +#define REG_DMA_READADDR 4
  4428. +#define REG_DMA_WRITEADDR 8
  4429. +#define REG_DMA_LENGTH 12
  4430. +#define REG_DMA_CONTROL 24
  4431. +
  4432. +/* status register bits definition */
  4433. +#define ST_DONE 0x01
  4434. +#define ST_BUSY 0x02
  4435. +#define ST_REOP 0x04
  4436. +#define ST_WROP 0x08
  4437. +#define ST_LEN 0x10
  4438. +
  4439. +/* control register bits definition */
  4440. +#define CT_BYTE 0x01
  4441. +#define CT_HW 0x02
  4442. +#define CT_WORD 0x04
  4443. +#define CT_GO 0x08
  4444. +#define CT_IEEN 0x10
  4445. +#define CT_REEN 0x20
  4446. +#define CT_WEEN 0x40
  4447. +#define CT_LEEN 0x80
  4448. +#define CT_RCON 0x100
  4449. +#define CT_WCON 0x200
  4450. +#define CT_DOUBLE 0x400
  4451. +#define CT_QUAD 0x800
  4452. +
  4453. +struct dma_channel {
  4454. + unsigned int addr; /* control address */
  4455. + unsigned int irq; /* interrupt number */
  4456. + atomic_t idle;
  4457. + unsigned int mode; /* dma mode: width, stream etc */
  4458. + int (*handler)(void*, int );
  4459. + void* user;
  4460. +
  4461. + char id[16];
  4462. + char dev_id[16];
  4463. +};
  4464. +static struct dma_channel dma_channels[]={
  4465. +#ifdef na_dma_0
  4466. + {
  4467. + .addr = na_dma_0,
  4468. + .irq = na_dma_0_irq,
  4469. + .idle = ATOMIC_INIT(1),
  4470. + },
  4471. +#endif
  4472. +#ifdef na_dma_1
  4473. + {
  4474. + .addr = na_dma_1,
  4475. + .irq = na_dma_1_irq,
  4476. + .idle = ATOMIC_INIT(1),
  4477. + },
  4478. +#endif
  4479. +};
  4480. +#define MAX_DMA_CHANNELS sizeof(dma_channels)/sizeof(struct dma_channel)
  4481. +
  4482. +void enable_dma(unsigned int dmanr)
  4483. +{
  4484. + if (dmanr < MAX_DMA_CHANNELS) {
  4485. + unsigned int ctl = dma_channels[dmanr].mode;
  4486. + ctl |= CT_GO | CT_IEEN;
  4487. + outl(ctl, dma_channels[dmanr].addr+REG_DMA_CONTROL);
  4488. + }
  4489. +}
  4490. +
  4491. +void disable_dma(unsigned int dmanr)
  4492. +{
  4493. + if (dmanr < MAX_DMA_CHANNELS) {
  4494. + unsigned int ctl = dma_channels[dmanr].mode;
  4495. + ctl &= ~(CT_GO | CT_IEEN);
  4496. + outl(ctl, dma_channels[dmanr].addr+REG_DMA_CONTROL);
  4497. + }
  4498. +}
  4499. +
  4500. +void set_dma_count(unsigned int dmanr, unsigned int count)
  4501. +{
  4502. + if (dmanr < MAX_DMA_CHANNELS) {
  4503. + dma_channels[dmanr].mode |= CT_LEEN;
  4504. + outl(count, dma_channels[dmanr].addr+REG_DMA_LENGTH);
  4505. + }
  4506. +}
  4507. +
  4508. +int get_dma_residue(unsigned int dmanr)
  4509. +{
  4510. + int result =-1;
  4511. + if (dmanr < MAX_DMA_CHANNELS) {
  4512. + result = inl(dma_channels[dmanr].addr+REG_DMA_LENGTH);
  4513. + }
  4514. + return result;
  4515. +}
  4516. +
  4517. +int request_dma(unsigned int chan, const char *dev_id)
  4518. +{
  4519. + struct dma_channel *channel;
  4520. +
  4521. + if ( chan >= MAX_DMA_CHANNELS) {
  4522. + return -EINVAL;
  4523. + }
  4524. +
  4525. + channel = &dma_channels[chan];
  4526. +
  4527. + if (!atomic_dec_and_test(&channel->idle)) {
  4528. + return -EBUSY;
  4529. + }
  4530. +
  4531. + strlcpy(channel->dev_id, dev_id, sizeof(channel->dev_id));
  4532. + channel->handler=NULL;
  4533. + channel->user=NULL;
  4534. + channel->mode =0;
  4535. +
  4536. + return 0;
  4537. +}
  4538. +
  4539. +void free_dma(unsigned int chan)
  4540. +{
  4541. + if ( chan < MAX_DMA_CHANNELS) {
  4542. + dma_channels[chan].handler=NULL;
  4543. + dma_channels[chan].user=NULL;
  4544. + atomic_set(&dma_channels[chan].idle, 1);
  4545. + }
  4546. +}
  4547. +
  4548. +int nios2_request_dma(const char *dev_id)
  4549. +{
  4550. + int chann;
  4551. +
  4552. + for ( chann=0; chann < MAX_DMA_CHANNELS; chann++) {
  4553. + if (request_dma(chann, dev_id)==0)
  4554. + return chann;
  4555. + }
  4556. +
  4557. + return -EINVAL;
  4558. +}
  4559. +void nios2_set_dma_handler(unsigned int dmanr, int (*handler)(void*, int), void* user)
  4560. +{
  4561. + if (dmanr < MAX_DMA_CHANNELS) {
  4562. + dma_channels[dmanr].handler=handler;
  4563. + dma_channels[dmanr].user=user;
  4564. + }
  4565. +}
  4566. +#define NIOS2_DMA_WIDTH_MASK (CT_BYTE | CT_HW | CT_WORD | CT_DOUBLE | CT_QUAD)
  4567. +#define NIOS2_MODE_MASK (NIOS2_DMA_WIDTH_MASK | CT_REEN | CT_WEEN | CT_LEEN | CT_RCON | CT_WCON)
  4568. +void nios2_set_dma_data_width(unsigned int dmanr, unsigned int width)
  4569. +{
  4570. + if (dmanr < MAX_DMA_CHANNELS) {
  4571. + dma_channels[dmanr].mode &= ~NIOS2_DMA_WIDTH_MASK;
  4572. + switch (width) {
  4573. + case 1:
  4574. + dma_channels[dmanr].mode |= CT_BYTE;
  4575. + break;
  4576. + case 2:
  4577. + dma_channels[dmanr].mode |= CT_HW;
  4578. + break;
  4579. + case 8:
  4580. + dma_channels[dmanr].mode |= CT_DOUBLE;
  4581. + break;
  4582. + case 16:
  4583. + dma_channels[dmanr].mode |= CT_QUAD;
  4584. + break;
  4585. + case 4:
  4586. + default:
  4587. + dma_channels[dmanr].mode |= CT_WORD;
  4588. + break;
  4589. + }
  4590. + }
  4591. +}
  4592. +
  4593. +void nios2_set_dma_rcon(unsigned int dmanr,unsigned int set)
  4594. +{
  4595. + if (dmanr < MAX_DMA_CHANNELS) {
  4596. + dma_channels[dmanr].mode &= ~(CT_REEN | CT_RCON);
  4597. + if (set)
  4598. + dma_channels[dmanr].mode |= (CT_REEN | CT_RCON);
  4599. + }
  4600. +}
  4601. +void nios2_set_dma_wcon(unsigned int dmanr,unsigned int set)
  4602. +{
  4603. + if (dmanr < MAX_DMA_CHANNELS) {
  4604. + dma_channels[dmanr].mode &= ~(CT_WEEN | CT_WCON);
  4605. + if (set)
  4606. + dma_channels[dmanr].mode |= (CT_WEEN | CT_WCON);
  4607. + }
  4608. +}
  4609. +void nios2_set_dma_mode(unsigned int dmanr, unsigned int mode)
  4610. +{
  4611. + if (dmanr < MAX_DMA_CHANNELS) {
  4612. + /* set_dma_mode is only allowed to change the bus width,
  4613. + stream setting, etc.
  4614. + */
  4615. + mode &= NIOS2_MODE_MASK;
  4616. + dma_channels[dmanr].mode &= ~NIOS2_MODE_MASK;
  4617. + dma_channels[dmanr].mode |= mode;
  4618. + }
  4619. +}
  4620. +
  4621. +void nios2_set_dma_raddr(unsigned int dmanr, unsigned int a)
  4622. +{
  4623. + if (dmanr < MAX_DMA_CHANNELS) {
  4624. + outl(a, dma_channels[dmanr].addr+REG_DMA_READADDR);
  4625. + }
  4626. +}
  4627. +void nios2_set_dma_waddr(unsigned int dmanr, unsigned int a)
  4628. +{
  4629. + if (dmanr < MAX_DMA_CHANNELS) {
  4630. + outl(a, dma_channels[dmanr].addr+REG_DMA_WRITEADDR);
  4631. + }
  4632. +}
  4633. +
  4634. +
  4635. +static irqreturn_t dma_isr(int irq, void *dev_id)
  4636. +{
  4637. + struct dma_channel *chann=(struct dma_channel*)dev_id;
  4638. +
  4639. + if (chann) {
  4640. + int status = inl(chann->addr+REG_DMA_STATUS);
  4641. + /* ack the interrupt, and clear the DONE bit */
  4642. + outl(0, chann->addr+REG_DMA_STATUS);
  4643. + /* call the peripheral callback */
  4644. + if (chann->handler)
  4645. + chann->handler(chann->user, status);
  4646. + }
  4647. +
  4648. + return IRQ_HANDLED;
  4649. +}
  4650. +
  4651. +
  4652. +
  4653. +#ifdef CONFIG_PROC_FS
  4654. +static int proc_dma_show(struct seq_file *m, void *v)
  4655. +{
  4656. + int i;
  4657. +
  4658. + for (i = 0 ; i < MAX_DMA_CHANNELS ; i++) {
  4659. + if (!atomic_read(&dma_channels[i].idle)) {
  4660. + seq_printf(m, "%2d: %s\n", i,
  4661. + dma_channels[i].dev_id);
  4662. + }
  4663. + }
  4664. + return 0;
  4665. +}
  4666. +
  4667. +static int proc_dma_open(struct inode *inode, struct file *file)
  4668. +{
  4669. + return single_open(file, proc_dma_show, NULL);
  4670. +}
  4671. +static struct file_operations proc_dma_operations = {
  4672. + .open = proc_dma_open,
  4673. + .read = seq_read,
  4674. + .llseek = seq_lseek,
  4675. + .release = single_release,
  4676. +};
  4677. +
  4678. +static int __init proc_dma_init(void)
  4679. +{
  4680. + struct proc_dir_entry *e;
  4681. +
  4682. + e = create_proc_entry("dma", 0, NULL);
  4683. + if (e)
  4684. + e->proc_fops = &proc_dma_operations;
  4685. +
  4686. + return 0;
  4687. +}
  4688. +
  4689. +__initcall(proc_dma_init);
  4690. +
  4691. +#endif /* CONFIG_PROC_FS */
  4692. +
  4693. +int __init init_dma(void)
  4694. +{
  4695. + int i;
  4696. +
  4697. + for (i = 0 ; i < MAX_DMA_CHANNELS ; i++) {
  4698. + sprintf(dma_channels[i].id, "dmac-%d", i);
  4699. + /* disable the dmac channel */
  4700. + disable_dma(i);
  4701. + /* request irq*/
  4702. + if (request_irq(dma_channels[i].irq, dma_isr, 0, dma_channels[i].id, (void*)&dma_channels[i])){
  4703. + printk("DMA controller %d failed to get irq %d\n", i, dma_channels[i].irq);
  4704. + atomic_set(&dma_channels[i].idle, 0);
  4705. + }
  4706. + }
  4707. + return 0;
  4708. +}
  4709. +
  4710. +static void __exit exit_dma(void)
  4711. +{
  4712. + int i;
  4713. +
  4714. + for (i = 0 ; i < MAX_DMA_CHANNELS ; i++) {
  4715. + /* disable the dmac channel */
  4716. + disable_dma(i);
  4717. + free_irq(dma_channels[i].irq, dma_channels[i].id);
  4718. + }
  4719. +}
  4720. +
  4721. +module_init(init_dma);
  4722. +module_exit(exit_dma);
  4723. +
  4724. +MODULE_LICENSE("GPL");
  4725. +
  4726. +//EXPORT_SYMBOL(claim_dma_lock);
  4727. +//EXPORT_SYMBOL(release_dma_lock);
  4728. +EXPORT_SYMBOL(enable_dma);
  4729. +EXPORT_SYMBOL(disable_dma);
  4730. +EXPORT_SYMBOL(set_dma_count);
  4731. +EXPORT_SYMBOL(get_dma_residue);
  4732. +EXPORT_SYMBOL(request_dma);
  4733. +EXPORT_SYMBOL(free_dma);
  4734. +EXPORT_SYMBOL(nios2_request_dma);
  4735. +EXPORT_SYMBOL(nios2_set_dma_handler);
  4736. +EXPORT_SYMBOL(nios2_set_dma_data_width);
  4737. +EXPORT_SYMBOL(nios2_set_dma_rcon);
  4738. +EXPORT_SYMBOL(nios2_set_dma_wcon);
  4739. +EXPORT_SYMBOL(nios2_set_dma_mode);
  4740. +EXPORT_SYMBOL(nios2_set_dma_raddr);
  4741. +EXPORT_SYMBOL(nios2_set_dma_waddr);
  4742. +
  4743. diff --git a/arch/nios2nommu/kernel/entry.S b/arch/nios2nommu/kernel/entry.S
  4744. new file mode 100644
  4745. index 0000000..7f71a01
  4746. --- /dev/null
  4747. +++ b/arch/nios2nommu/kernel/entry.S
  4748. @@ -0,0 +1,898 @@
  4749. +/*
  4750. + * linux/arch/nios2nommu/kernel/entry.S
  4751. + *
  4752. + * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
  4753. + * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
  4754. + * Kenneth Albanowski <kjahds@kjahds.com>,
  4755. + * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
  4756. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  4757. + *
  4758. + * Based on:
  4759. + *
  4760. + * linux/arch/m68knommu/kernel/entry.S
  4761. + *
  4762. + * Copyright (C) 1991, 1992 Linus Torvalds
  4763. + *
  4764. + * This file is subject to the terms and conditions of the GNU General Public
  4765. + * License. See the file README.legal in the main directory of this archive
  4766. + * for more details.
  4767. + *
  4768. + * Linux/m68k support by Hamish Macdonald
  4769. + *
  4770. + * 68060 fixes by Jesper Skov
  4771. + * ColdFire support by Greg Ungerer (gerg@snapgear.com)
  4772. + * 5307 fixes by David W. Miller
  4773. + * linux 2.4 support David McCullough <davidm@snapgear.com>
  4774. + */
  4775. +
  4776. +#include <linux/sys.h>
  4777. +#include <linux/linkage.h>
  4778. +#include <asm/asm-offsets.h>
  4779. +#include <asm/asm-macros.h>
  4780. +#include <asm/thread_info.h>
  4781. +#include <asm/errno.h>
  4782. +#include <asm/setup.h>
  4783. +#include <asm/segment.h>
  4784. +#include <asm/entry.h>
  4785. +#include <asm/unistd.h>
  4786. +#include <asm/traps.h>
  4787. +#include <asm/processor.h>
  4788. +
  4789. +.text
  4790. +.set noat
  4791. +.set nobreak
  4792. +
  4793. +ENTRY(system_call)
  4794. +/* SAVE_ALL */
  4795. + rdctl r10,status /* enable intrs again */
  4796. + ori r10,r10,0x0001
  4797. + wrctl status,r10
  4798. +
  4799. + movi r2,-LENOSYS
  4800. + stw r2,PT_R2(sp) /* default return value in r2 */
  4801. + /* original r2 is in orig_r2 */
  4802. +
  4803. + movui r1,NR_syscalls
  4804. + bgtu r3,r1,ret_from_exception
  4805. + slli r1,r3,2
  4806. + movhi r11,%hiadj(sys_call_table)
  4807. + add r1,r1,r11
  4808. + ldw r1,%lo(sys_call_table)(r1)
  4809. + beq r1,r0,ret_from_exception
  4810. +
  4811. + movi r11,%lo(0xffffe000) /* Get thread info pointer */
  4812. + and r11,sp,r11
  4813. + ldw r11,TI_FLAGS(r11)
  4814. + BTBNZ r11,r11,TIF_SYSCALL_TRACE_ASM,1f
  4815. +
  4816. + callr r1
  4817. + stw r2,PT_R2(sp) /* save the return value */
  4818. + br ret_from_exception
  4819. +1:
  4820. + SAVE_SWITCH_STACK
  4821. + call syscall_trace
  4822. + RESTORE_SWITCH_STACK
  4823. + /* wentao: restore r4-9, since they are trashed by syscall_trace */
  4824. + ldw r4,PT_R4(sp)
  4825. + ldw r5,PT_R5(sp)
  4826. + ldw r6,PT_R6(sp)
  4827. + ldw r7,PT_R7(sp)
  4828. + ldw r8,PT_R8(sp)
  4829. + ldw r9,PT_R9(sp)
  4830. + callr r1
  4831. + stw r2,PT_R2(sp) /* save the return value */
  4832. + SAVE_SWITCH_STACK
  4833. + call syscall_trace
  4834. + RESTORE_SWITCH_STACK
  4835. +
  4836. +ret_from_exception:
  4837. + ldw r1,PT_STATUS_EXTENSION(sp) /* check if returning to kernel */
  4838. + TSTBZ r1,r1,PS_S_ASM,Luser_return /* if so, skip resched, signals */
  4839. +
  4840. +restore_all:
  4841. + rdctl r10,status /* disable intrs */
  4842. + andi r10,r10,0xfffe
  4843. + wrctl status, r10
  4844. + RESTORE_ALL
  4845. + eret
  4846. +
  4847. +Luser_return:
  4848. + GET_THREAD_INFO r24 /* get thread_info pointer */
  4849. + ldw r10,TI_FLAGS(r24) /* get thread_info->flags */
  4850. + ANDI32 r11,r10,_TIF_WORK_MASK_ASM
  4851. + beq r11,r0,restore_all /* Nothing to do */
  4852. + BTBZ r1,r10,TIF_NEED_RESCHED_ASM,Lsignal_return
  4853. +
  4854. +Lwork_resched:
  4855. + call schedule
  4856. + br ret_from_exception
  4857. +
  4858. +Lsignal_return:
  4859. + BTBZ r1,r10,TIF_SIGPENDING_ASM,restore_all
  4860. + mov r5,sp /* pt_regs */
  4861. + SAVE_SWITCH_STACK
  4862. + CLR r4 /* oldset = 0 */
  4863. + call do_signal
  4864. + RESTORE_SWITCH_STACK
  4865. + br restore_all
  4866. +
  4867. +/*
  4868. + * Handle software exceptions. Put here so external interrupts
  4869. + * can fall throught to ret_from_interrupt.
  4870. + */
  4871. +
  4872. +software_exception:
  4873. + ldw r24,-4(ea) // instruction that caused the exception
  4874. + xorhi r24,r24,0x003b // upper half of trap opcode
  4875. + xori r24,r24,0x683a // lower half of trap opcode
  4876. + bne r24,r0,instruction_trap /* N - check for instruction trap */
  4877. + cmpeqi r11,r2,TRAP_ID_SYSCALL /* ? Is this a syscall */
  4878. + bne r11,r0,system_call /* Y - handle syscall */
  4879. + cmpeqi r11,r2,TRAP_ID_APPDEBUG /* ? Is this an application debug */
  4880. + bne r11,r0,app_debug /* Y - handle app_debug */
  4881. + cmpeqi r11,r2,63 /* ? Is this the old syscall number */
  4882. + bne r11,r0,system_call /* Y - handle syscall to catch older apps*/
  4883. + br restore_all /* N - everything else is ignored for now */
  4884. +
  4885. +app_debug:
  4886. + GET_THREAD_INFO r24 /* get thread_info */
  4887. + ldw r1,TI_TASK(r24) /* get thread_info->task */
  4888. + ldw r24,(TASK_THREAD + THREAD_FLAGS)(r1) /* get thread_info->task->thread.flags */
  4889. + ORI32 r24, r24, NIOS2_FLAG_DEBUG /* set the debug flag */
  4890. + stw r24,(TASK_THREAD + THREAD_FLAGS)(r1) /* save thread_info->task->thread.flags */
  4891. + br restore_all
  4892. +
  4893. +/*
  4894. + * This is the generic interrupt handler (for all hardware interrupt
  4895. + * sources). It figures out the vector number and calls the appropriate
  4896. + * interrupt service routine directly.
  4897. + */
  4898. +ENTRY(inthandler)
  4899. + SAVE_ALL
  4900. + /*
  4901. + * Test to see if the exception was a software exception or caused by an
  4902. + * external interrupt, and vector accordingly.
  4903. + */
  4904. +
  4905. + rdctl r24,estatus
  4906. + andi r24,r24,1
  4907. + beq r24,r0,software_exception
  4908. + rdctl r12,ipending
  4909. + beq r12,r0,software_exception
  4910. +
  4911. + movi r24,-1
  4912. + stw r24,PT_ORIG_R2(sp)
  4913. +
  4914. + /*
  4915. + * Process an external hardware interrupt.
  4916. + */
  4917. +
  4918. + addi ea,ea,-4 /* re-issue the interrupted instruction */
  4919. + stw ea,PT_EA(sp)
  4920. + rdctl r9,ienable /* Isolate possible interrupts */
  4921. + and r12,r12,r9
  4922. + beq r12,r0,ret_from_interrupt /* No one to service done */
  4923. + movi r4,%lo(-1) /* Start from bit position 0, highest priority */
  4924. + /* This is the IRQ # for handler call */
  4925. +1: addi r4,r4,1
  4926. + srl r10,r12,r4
  4927. + andi r10,r10,1 /* Isolate bit we are interested in */
  4928. + cmpeqi r11,r4,32 /* ? End of the register */
  4929. + bne r11,r0,ret_from_interrupt /* Y - out of here */
  4930. + beq r10,r0,1b
  4931. + mov r5,sp /* Setup pt_regs pointer for handler call */
  4932. + PUSH r4 /* Save state for return */
  4933. + PUSH r12
  4934. + call process_int
  4935. + POP r12
  4936. + POP r4
  4937. + br 1b /* Check for other interrupts while here */
  4938. +
  4939. +ENTRY(ret_from_interrupt)
  4940. + ldw r4,PT_STATUS_EXTENSION(sp)
  4941. + TSTBZ r4,r4,PS_S_ASM,Luser_return // Returning to user
  4942. +
  4943. +#ifdef CONFIG_PREEMPT
  4944. + GET_THREAD_INFO r1
  4945. + ldw r4,TI_PREEMPT_COUNT(r1)
  4946. + bne r4,r0,restore_all
  4947. +
  4948. +need_resched:
  4949. + ldw r4,TI_FLAGS(r1) // ? Need resched set
  4950. + BTBZ r10,r4,TIF_NEED_RESCHED_ASM,restore_all
  4951. + ldw r4,PT_ESTATUS(sp) // ? Interrupts off
  4952. + BTBZ r10,r4,NIOS2_STATUS_PIE_OFST_ASM,restore_all
  4953. + movia r4,PREEMPT_ACTIVE_ASM
  4954. + stw r4,TI_PREEMPT_COUNT(r1)
  4955. + rdctl r10,status /* enable intrs again */
  4956. + ori r10,r10,0x0001
  4957. + wrctl status,r10
  4958. + PUSH r1
  4959. + call schedule
  4960. + POP r1
  4961. + mov r4,r0
  4962. + stw r4,TI_PREEMPT_COUNT(r1)
  4963. + rdctl r10,status /* disable intrs */
  4964. + andi r10,r10,0xfffe
  4965. + wrctl status, r10
  4966. + br need_resched
  4967. +#else
  4968. + br restore_all
  4969. +#endif
  4970. +
  4971. +
  4972. +/*
  4973. + * Beware - when entering resume, prev (the current task) is
  4974. + * in r4, next (the new task) is in r5, don't change these
  4975. + * registers.
  4976. + */
  4977. +ENTRY(resume)
  4978. +
  4979. + rdctl r7,status /* save thread status reg */
  4980. + stw r7,TASK_THREAD+THREAD_KPSR(r4)
  4981. +
  4982. + andi r7,r7,0x0fffe /* disable interrupts */
  4983. + wrctl status,r7
  4984. +
  4985. + movia r8,status_extension /* save status extension */
  4986. + ldw r7,0(r8)
  4987. + stw r7,TASK_THREAD+THREAD_KESR(r4)
  4988. +
  4989. + SAVE_SWITCH_STACK
  4990. + stw sp,TASK_THREAD+THREAD_KSP(r4) /* save kernel stack pointer */
  4991. + ldw sp,TASK_THREAD+THREAD_KSP(r5) /* restore new thread stack */
  4992. + movia r24,_current_thread /* save thread */
  4993. + GET_THREAD_INFO r1
  4994. + stw r1,0(r24)
  4995. + RESTORE_SWITCH_STACK
  4996. +
  4997. + ldw r7,TASK_THREAD+THREAD_KESR(r5) /* restore extended status reg */
  4998. + stw r7,0(r8)
  4999. +
  5000. + ldw r7,TASK_THREAD+THREAD_KPSR(r5) /* restore thread status reg */
  5001. + wrctl status,r7
  5002. + ret
  5003. +
  5004. +ENTRY(ret_from_fork)
  5005. + call schedule_tail
  5006. + br ret_from_exception
  5007. +
  5008. +ENTRY(sys_fork)
  5009. + mov r4,sp
  5010. + SAVE_SWITCH_STACK
  5011. + call nios2_vfork
  5012. + RESTORE_SWITCH_STACK
  5013. + ret
  5014. +
  5015. +ENTRY(sys_vfork)
  5016. + mov r4,sp
  5017. + SAVE_SWITCH_STACK
  5018. + call nios2_vfork
  5019. + RESTORE_SWITCH_STACK
  5020. + ret
  5021. +
  5022. +ENTRY(sys_execve)
  5023. + mov r4,sp
  5024. + SAVE_SWITCH_STACK
  5025. + call nios2_execve
  5026. + RESTORE_SWITCH_STACK
  5027. + ret
  5028. +
  5029. +ENTRY(sys_clone)
  5030. + mov r4,sp
  5031. + SAVE_SWITCH_STACK
  5032. + call nios2_clone
  5033. + RESTORE_SWITCH_STACK
  5034. + ret
  5035. +
  5036. +ENTRY(sys_sigsuspend)
  5037. + mov r4,sp
  5038. + SAVE_SWITCH_STACK
  5039. + call do_sigsuspend
  5040. + RESTORE_SWITCH_STACK
  5041. + ret
  5042. +
  5043. +ENTRY(sys_rt_sigsuspend)
  5044. + mov r4,sp
  5045. + SAVE_SWITCH_STACK
  5046. + call do_rt_sigsuspend
  5047. + RESTORE_SWITCH_STACK
  5048. + ret
  5049. +
  5050. +ENTRY(sys_sigreturn)
  5051. + mov r4,sp
  5052. + SAVE_SWITCH_STACK
  5053. + call do_sigreturn
  5054. + RESTORE_SWITCH_STACK
  5055. + ret
  5056. +
  5057. +ENTRY(sys_sigaltstack)
  5058. + ldw r4,PT_R4(sp)
  5059. + ldw r5,PT_R5(sp)
  5060. + ldw r6,PT_SP(sp)
  5061. + SAVE_SWITCH_STACK
  5062. + call do_sigaltstack
  5063. + RESTORE_SWITCH_STACK
  5064. + ret
  5065. +
  5066. +ENTRY(sys_rt_sigreturn)
  5067. + SAVE_SWITCH_STACK
  5068. + call do_rt_sigreturn
  5069. + RESTORE_SWITCH_STACK
  5070. + ret
  5071. +
  5072. +/******************************************************************************
  5073. +* *
  5074. +* License Agreement *
  5075. +* *
  5076. +* Copyright (c) 2003 Altera Corporation, San Jose, California, USA. *
  5077. +* All rights reserved. *
  5078. +* *
  5079. +* Permission is hereby granted, free of charge, to any person obtaining a *
  5080. +* copy of this software and associated documentation files (the "Software"), *
  5081. +* to deal in the Software without restriction, including without limitation *
  5082. +* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
  5083. +* and/or sell copies of the Software, and to permit persons to whom the *
  5084. +* Software is furnished to do so, subject to the following conditions: *
  5085. +* *
  5086. +* The above copyright notice and this permission notice shall be included in *
  5087. +* all copies or substantial portions of the Software. *
  5088. +* *
  5089. +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
  5090. +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
  5091. +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
  5092. +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
  5093. +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
  5094. +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
  5095. +* DEALINGS IN THE SOFTWARE. *
  5096. +* *
  5097. +* This agreement shall be governed in all respects by the laws of the State *
  5098. +* of California and by the laws of the United States of America. *
  5099. +* *
  5100. +******************************************************************************/
  5101. +
  5102. + /*
  5103. + * This is the software exception handler for Nios2.
  5104. + */
  5105. +
  5106. + /*
  5107. + * Explicitly allow the use of r1 (the assembler temporary register)
  5108. + * within this code. This register is normally reserved for the use of
  5109. + * the compiler.
  5110. + */
  5111. +
  5112. +ENTRY(instruction_trap)
  5113. + RESTORE_ALL // Clean off our save & setup for emulation
  5114. +
  5115. + /* INSTRUCTION EMULATION
  5116. + * ---------------------
  5117. + *
  5118. + * Nios II processors generate exceptions for unimplemented instructions.
  5119. + * The routines below emulate these instructions. Depending on the
  5120. + * processor core, the only instructions that might need to be emulated
  5121. + * are div, divu, mul, muli, mulxss, mulxsu, and mulxuu.
  5122. + *
  5123. + * The emulations match the instructions, except for the following
  5124. + * limitations:
  5125. + *
  5126. + * 1) The emulation routines do not emulate the use of the exception
  5127. + * temporary register (et) as a source operand because the exception
  5128. + * handler already has modified it.
  5129. + *
  5130. + * 2) The routines do not emulate the use of the stack pointer (sp) or the
  5131. + * exception return address register (ea) as a destination because
  5132. + * modifying these registers crashes the exception handler or the
  5133. + * interrupted routine.
  5134. + *
  5135. + * Detailed Design
  5136. + * ---------------
  5137. + *
  5138. + * The emulation routines expect the contents of integer registers r0-r31
  5139. + * to be on the stack at addresses sp, 4(sp), 8(sp), ... 124(sp). The
  5140. + * routines retrieve source operands from the stack and modify the
  5141. + * destination register's value on the stack prior to the end of the
  5142. + * exception handler. Then all registers except the destination register
  5143. + * are restored to their previous values.
  5144. + *
  5145. + * The instruction that causes the exception is found at address -4(ea).
  5146. + * The instruction's OP and OPX fields identify the operation to be
  5147. + * performed.
  5148. + *
  5149. + * One instruction, muli, is an I-type instruction that is identified by
  5150. + * an OP field of 0x24.
  5151. + *
  5152. + * muli AAAAA,BBBBB,IIIIIIIIIIIIIIII,-0x24-
  5153. + * 27 22 6 0 <-- LSB of field
  5154. + *
  5155. + * The remaining emulated instructions are R-type and have an OP field
  5156. + * of 0x3a. Their OPX fields identify them.
  5157. + *
  5158. + * R-type AAAAA,BBBBB,CCCCC,XXXXXX,NNNNN,-0x3a-
  5159. + * 27 22 17 11 6 0 <-- LSB of field
  5160. + *
  5161. + *
  5162. + * Opcode Encoding. muli is identified by its OP value. Then OPX & 0x02
  5163. + * is used to differentiate between the division opcodes and the remaining
  5164. + * multiplication opcodes.
  5165. + *
  5166. + * Instruction OP OPX OPX & 0x02
  5167. + * ----------- ---- ---- ----------
  5168. + * muli 0x24
  5169. + * divu 0x3a 0x24 0
  5170. + * div 0x3a 0x25 0
  5171. + * mul 0x3a 0x27 != 0
  5172. + * mulxuu 0x3a 0x07 != 0
  5173. + * mulxsu 0x3a 0x17 != 0
  5174. + * mulxss 0x3a 0x1f != 0
  5175. + */
  5176. +
  5177. +
  5178. + /*
  5179. + * Save everything on the stack to make it easy for the emulation routines
  5180. + * to retrieve the source register operands.
  5181. + */
  5182. +
  5183. + addi sp, sp, -128
  5184. + stw zero, 0(sp) // Save zero on stack to avoid special case for r0.
  5185. + stw r1, 4(sp)
  5186. + stw r2, 8(sp)
  5187. + stw r3, 12(sp)
  5188. + stw r4, 16(sp)
  5189. + stw r5, 20(sp)
  5190. + stw r6, 24(sp)
  5191. + stw r7, 28(sp)
  5192. + stw r8, 32(sp)
  5193. + stw r9, 36(sp)
  5194. + stw r10, 40(sp)
  5195. + stw r11, 44(sp)
  5196. + stw r12, 48(sp)
  5197. + stw r13, 52(sp)
  5198. + stw r14, 56(sp)
  5199. + stw r15, 60(sp)
  5200. + stw r16, 64(sp)
  5201. + stw r17, 68(sp)
  5202. + stw r18, 72(sp)
  5203. + stw r19, 76(sp)
  5204. + stw r20, 80(sp)
  5205. + stw r21, 84(sp)
  5206. + stw r22, 88(sp)
  5207. + stw r23, 92(sp)
  5208. + // Don't bother to save et. It's already been changed.
  5209. + stw bt, 100(sp)
  5210. + stw gp, 104(sp)
  5211. + stw sp, 108(sp)
  5212. + stw fp, 112(sp)
  5213. + // Don't bother to save ea. It's already been changed.
  5214. + stw ba, 120(sp)
  5215. + stw ra, 124(sp)
  5216. +
  5217. +
  5218. + /*
  5219. + * Split the instruction into its fields. We need 4*A, 4*B, and 4*C as
  5220. + * offsets to the stack pointer for access to the stored register values.
  5221. + */
  5222. + ldw r2,-4(ea) // r2 = AAAAA,BBBBB,IIIIIIIIIIIIIIII,PPPPPP
  5223. + roli r3,r2,7 // r3 = BBB,IIIIIIIIIIIIIIII,PPPPPP,AAAAA,BB
  5224. + roli r4,r3,3 // r4 = IIIIIIIIIIIIIIII,PPPPPP,AAAAA,BBBBB
  5225. + roli r5,r4,2 // r5 = IIIIIIIIIIIIII,PPPPPP,AAAAA,BBBBB,II
  5226. + srai r4,r4,16 // r4 = (sign-extended) IMM16
  5227. + roli r6,r5,5 // r6 = XXXX,NNNNN,PPPPPP,AAAAA,BBBBB,CCCCC,XX
  5228. + andi r2,r2,0x3f // r2 = 00000000000000000000000000,PPPPPP
  5229. + andi r3,r3,0x7c // r3 = 0000000000000000000000000,AAAAA,00
  5230. + andi r5,r5,0x7c // r5 = 0000000000000000000000000,BBBBB,00
  5231. + andi r6,r6,0x7c // r6 = 0000000000000000000000000,CCCCC,00
  5232. +
  5233. + /* Now
  5234. + * r2 = OP
  5235. + * r3 = 4*A
  5236. + * r4 = IMM16 (sign extended)
  5237. + * r5 = 4*B
  5238. + * r6 = 4*C
  5239. + */
  5240. +
  5241. +
  5242. + /*
  5243. + * Get the operands.
  5244. + *
  5245. + * It is necessary to check for muli because it uses an I-type instruction
  5246. + * format, while the other instructions are have an R-type format.
  5247. + *
  5248. + * Prepare for either multiplication or division loop.
  5249. + * They both loop 32 times.
  5250. + */
  5251. + movi r14,32
  5252. +
  5253. + add r3,r3,sp // r3 = address of A-operand.
  5254. + ldw r3,0(r3) // r3 = A-operand.
  5255. + movi r7,0x24 // muli opcode (I-type instruction format)
  5256. + beq r2,r7,mul_immed // muli doesn't use the B register as a source
  5257. +
  5258. + add r5,r5,sp // r5 = address of B-operand.
  5259. + ldw r5,0(r5) // r5 = B-operand.
  5260. + // r4 = SSSSSSSSSSSSSSSS,-----IMM16------
  5261. + // IMM16 not needed, align OPX portion
  5262. + // r4 = SSSSSSSSSSSSSSSS,CCCCC,-OPX--,00000
  5263. + srli r4,r4,5 // r4 = 00000,SSSSSSSSSSSSSSSS,CCCCC,-OPX--
  5264. + andi r4,r4,0x3f // r4 = 00000000000000000000000000,-OPX--
  5265. +
  5266. + /* Now
  5267. + * r2 = OP
  5268. + * r3 = src1
  5269. + * r5 = src2
  5270. + * r4 = OPX (no longer can be muli)
  5271. + * r6 = 4*C
  5272. + */
  5273. +
  5274. +
  5275. +
  5276. + /*
  5277. + * Multiply or Divide?
  5278. + */
  5279. + andi r7,r4,0x02 // For R-type multiply instructions, OPX & 0x02 != 0
  5280. + bne r7,zero,multiply
  5281. +
  5282. +
  5283. + /* DIVISION
  5284. + *
  5285. + * Divide an unsigned dividend by an unsigned divisor using
  5286. + * a shift-and-subtract algorithm. The example below shows
  5287. + * 43 div 7 = 6 for 8-bit integers. This classic algorithm uses a
  5288. + * single register to store both the dividend and the quotient,
  5289. + * allowing both values to be shifted with a single instruction.
  5290. + *
  5291. + * remainder dividend:quotient
  5292. + * --------- -----------------
  5293. + * initialize 00000000 00101011:
  5294. + * shift 00000000 0101011:_
  5295. + * remainder >= divisor? no 00000000 0101011:0
  5296. + * shift 00000000 101011:0_
  5297. + * remainder >= divisor? no 00000000 101011:00
  5298. + * shift 00000001 01011:00_
  5299. + * remainder >= divisor? no 00000001 01011:000
  5300. + * shift 00000010 1011:000_
  5301. + * remainder >= divisor? no 00000010 1011:0000
  5302. + * shift 00000101 011:0000_
  5303. + * remainder >= divisor? no 00000101 011:00000
  5304. + * shift 00001010 11:00000_
  5305. + * remainder >= divisor? yes 00001010 11:000001
  5306. + * remainder -= divisor - 00000111
  5307. + * ----------
  5308. + * 00000011 11:000001
  5309. + * shift 00000111 1:000001_
  5310. + * remainder >= divisor? yes 00000111 1:0000011
  5311. + * remainder -= divisor - 00000111
  5312. + * ----------
  5313. + * 00000000 1:0000011
  5314. + * shift 00000001 :0000011_
  5315. + * remainder >= divisor? no 00000001 :00000110
  5316. + *
  5317. + * The quotient is 00000110.
  5318. + */
  5319. +
  5320. +divide:
  5321. + /*
  5322. + * Prepare for division by assuming the result
  5323. + * is unsigned, and storing its "sign" as 0.
  5324. + */
  5325. + movi r17,0
  5326. +
  5327. +
  5328. + // Which division opcode?
  5329. + xori r7,r4,0x25 // OPX of div
  5330. + bne r7,zero,unsigned_division
  5331. +
  5332. +
  5333. + /*
  5334. + * OPX is div. Determine and store the sign of the quotient.
  5335. + * Then take the absolute value of both operands.
  5336. + */
  5337. + xor r17,r3,r5 // MSB contains sign of quotient
  5338. + bge r3,zero,dividend_is_nonnegative
  5339. + sub r3,zero,r3 // -r3
  5340. +dividend_is_nonnegative:
  5341. + bge r5,zero,divisor_is_nonnegative
  5342. + sub r5,zero,r5 // -r5
  5343. +divisor_is_nonnegative:
  5344. +
  5345. +
  5346. +unsigned_division:
  5347. + // Initialize the unsigned-division loop.
  5348. + movi r13,0 // remainder = 0
  5349. +
  5350. + /* Now
  5351. + * r3 = dividend : quotient
  5352. + * r4 = 0x25 for div, 0x24 for divu
  5353. + * r5 = divisor
  5354. + * r13 = remainder
  5355. + * r14 = loop counter (already initialized to 32)
  5356. + * r17 = MSB contains sign of quotient
  5357. + */
  5358. +
  5359. +
  5360. + /*
  5361. + * for (count = 32; count > 0; --count)
  5362. + * {
  5363. + */
  5364. +divide_loop:
  5365. +
  5366. + /*
  5367. + * Division:
  5368. + *
  5369. + * (remainder:dividend:quotient) <<= 1;
  5370. + */
  5371. + slli r13,r13,1
  5372. + cmplt r7,r3,zero // r7 = MSB of r3
  5373. + or r13,r13,r7
  5374. + slli r3,r3,1
  5375. +
  5376. +
  5377. + /*
  5378. + * if (remainder >= divisor)
  5379. + * {
  5380. + * set LSB of quotient
  5381. + * remainder -= divisor;
  5382. + * }
  5383. + */
  5384. + bltu r13,r5,div_skip
  5385. + ori r3,r3,1
  5386. + sub r13,r13,r5
  5387. +div_skip:
  5388. +
  5389. + /*
  5390. + * }
  5391. + */
  5392. + subi r14,r14,1
  5393. + bne r14,zero,divide_loop
  5394. +
  5395. +
  5396. + /* Now
  5397. + * r3 = quotient
  5398. + * r4 = 0x25 for div, 0x24 for divu
  5399. + * r6 = 4*C
  5400. + * r17 = MSB contains sign of quotient
  5401. + */
  5402. +
  5403. +
  5404. + /*
  5405. + * Conditionally negate signed quotient. If quotient is unsigned,
  5406. + * the sign already is initialized to 0.
  5407. + */
  5408. + bge r17,zero,quotient_is_nonnegative
  5409. + sub r3,zero,r3 // -r3
  5410. +quotient_is_nonnegative:
  5411. +
  5412. +
  5413. + /*
  5414. + * Final quotient is in r3.
  5415. + */
  5416. + add r6,r6,sp
  5417. + stw r3,0(r6) // write quotient to stack
  5418. + br restore_registers
  5419. +
  5420. +
  5421. +
  5422. +
  5423. + /* MULTIPLICATION
  5424. + *
  5425. + * A "product" is the number that one gets by summing a "multiplicand"
  5426. + * several times. The "multiplier" specifies the number of copies of the
  5427. + * multiplicand that are summed.
  5428. + *
  5429. + * Actual multiplication algorithms don't use repeated addition, however.
  5430. + * Shift-and-add algorithms get the same answer as repeated addition, and
  5431. + * they are faster. To compute the lower half of a product (pppp below)
  5432. + * one shifts the product left before adding in each of the partial products
  5433. + * (a * mmmm) through (d * mmmm).
  5434. + *
  5435. + * To compute the upper half of a product (PPPP below), one adds in the
  5436. + * partial products (d * mmmm) through (a * mmmm), each time following the
  5437. + * add by a right shift of the product.
  5438. + *
  5439. + * mmmm
  5440. + * * abcd
  5441. + * ------
  5442. + * #### = d * mmmm
  5443. + * #### = c * mmmm
  5444. + * #### = b * mmmm
  5445. + * #### = a * mmmm
  5446. + * --------
  5447. + * PPPPpppp
  5448. + *
  5449. + * The example above shows 4 partial products. Computing actual Nios II
  5450. + * products requires 32 partials.
  5451. + *
  5452. + * It is possible to compute the result of mulxsu from the result of mulxuu
  5453. + * because the only difference between the results of these two opcodes is
  5454. + * the value of the partial product associated with the sign bit of rA.
  5455. + *
  5456. + * mulxsu = mulxuu - (rA < 0) ? rB : 0;
  5457. + *
  5458. + * It is possible to compute the result of mulxss from the result of mulxsu
  5459. + * because the only difference between the results of these two opcodes is
  5460. + * the value of the partial product associated with the sign bit of rB.
  5461. + *
  5462. + * mulxss = mulxsu - (rB < 0) ? rA : 0;
  5463. + *
  5464. + */
  5465. +
  5466. +mul_immed:
  5467. + // Opcode is muli. Change it into mul for remainder of algorithm.
  5468. + mov r6,r5 // Field B is dest register, not field C.
  5469. + mov r5,r4 // Field IMM16 is src2, not field B.
  5470. + movi r4,0x27 // OPX of mul is 0x27
  5471. +
  5472. +multiply:
  5473. + // Initialize the multiplication loop.
  5474. + movi r9,0 // mul_product = 0
  5475. + movi r10,0 // mulxuu_product = 0
  5476. + mov r11,r5 // save original multiplier for mulxsu and mulxss
  5477. + mov r12,r5 // mulxuu_multiplier (will be shifted)
  5478. + movi r16,1 // used to create "rori B,A,1" from "ror B,A,r16"
  5479. +
  5480. + /* Now
  5481. + * r3 = multiplicand
  5482. + * r5 = mul_multiplier
  5483. + * r6 = 4 * dest_register (used later as offset to sp)
  5484. + * r7 = temp
  5485. + * r9 = mul_product
  5486. + * r10 = mulxuu_product
  5487. + * r11 = original multiplier
  5488. + * r12 = mulxuu_multiplier
  5489. + * r14 = loop counter (already initialized)
  5490. + * r16 = 1
  5491. + */
  5492. +
  5493. +
  5494. + /*
  5495. + * for (count = 32; count > 0; --count)
  5496. + * {
  5497. + */
  5498. +multiply_loop:
  5499. +
  5500. + /*
  5501. + * mul_product <<= 1;
  5502. + * lsb = multiplier & 1;
  5503. + */
  5504. + slli r9,r9,1
  5505. + andi r7,r12,1
  5506. +
  5507. + /*
  5508. + * if (lsb == 1)
  5509. + * {
  5510. + * mulxuu_product += multiplicand;
  5511. + * }
  5512. + */
  5513. + beq r7,zero,mulx_skip
  5514. + add r10,r10,r3
  5515. + cmpltu r7,r10,r3 // Save the carry from the MSB of mulxuu_product.
  5516. + ror r7,r7,r16 // r7 = 0x80000000 on carry, or else 0x00000000
  5517. +mulx_skip:
  5518. +
  5519. + /*
  5520. + * if (MSB of mul_multiplier == 1)
  5521. + * {
  5522. + * mul_product += multiplicand;
  5523. + * }
  5524. + */
  5525. + bge r5,zero,mul_skip
  5526. + add r9,r9,r3
  5527. +mul_skip:
  5528. +
  5529. + /*
  5530. + * mulxuu_product >>= 1; logical shift
  5531. + * mul_multiplier <<= 1; done with MSB
  5532. + * mulx_multiplier >>= 1; done with LSB
  5533. + */
  5534. + srli r10,r10,1
  5535. + or r10,r10,r7 // OR in the saved carry bit.
  5536. + slli r5,r5,1
  5537. + srli r12,r12,1
  5538. +
  5539. +
  5540. + /*
  5541. + * }
  5542. + */
  5543. + subi r14,r14,1
  5544. + bne r14,zero,multiply_loop
  5545. +
  5546. +
  5547. + /*
  5548. + * Multiply emulation loop done.
  5549. + */
  5550. +
  5551. + /* Now
  5552. + * r3 = multiplicand
  5553. + * r4 = OPX
  5554. + * r6 = 4 * dest_register (used later as offset to sp)
  5555. + * r7 = temp
  5556. + * r9 = mul_product
  5557. + * r10 = mulxuu_product
  5558. + * r11 = original multiplier
  5559. + */
  5560. +
  5561. +
  5562. + // Calculate address for result from 4 * dest_register
  5563. + add r6,r6,sp
  5564. +
  5565. +
  5566. + /*
  5567. + * Select/compute the result based on OPX.
  5568. + */
  5569. +
  5570. +
  5571. + // OPX == mul? Then store.
  5572. + xori r7,r4,0x27
  5573. + beq r7,zero,store_product
  5574. +
  5575. + // It's one of the mulx.. opcodes. Move over the result.
  5576. + mov r9,r10
  5577. +
  5578. + // OPX == mulxuu? Then store.
  5579. + xori r7,r4,0x07
  5580. + beq r7,zero,store_product
  5581. +
  5582. + // Compute mulxsu
  5583. + //
  5584. + // mulxsu = mulxuu - (rA < 0) ? rB : 0;
  5585. + //
  5586. + bge r3,zero,mulxsu_skip
  5587. + sub r9,r9,r11
  5588. +mulxsu_skip:
  5589. +
  5590. + // OPX == mulxsu? Then store.
  5591. + xori r7,r4,0x17
  5592. + beq r7,zero,store_product
  5593. +
  5594. + // Compute mulxss
  5595. + //
  5596. + // mulxss = mulxsu - (rB < 0) ? rA : 0;
  5597. + //
  5598. + bge r11,zero,mulxss_skip
  5599. + sub r9,r9,r3
  5600. +mulxss_skip:
  5601. + // At this point, assume that OPX is mulxss, so store
  5602. +
  5603. +
  5604. +store_product:
  5605. + stw r9,0(r6)
  5606. +
  5607. +
  5608. +restore_registers:
  5609. + // No need to restore r0.
  5610. + ldw r1, 4(sp)
  5611. + ldw r2, 8(sp)
  5612. + ldw r3, 12(sp)
  5613. + ldw r4, 16(sp)
  5614. + ldw r5, 20(sp)
  5615. + ldw r6, 24(sp)
  5616. + ldw r7, 28(sp)
  5617. + ldw r8, 32(sp)
  5618. + ldw r9, 36(sp)
  5619. + ldw r10, 40(sp)
  5620. + ldw r11, 44(sp)
  5621. + ldw r12, 48(sp)
  5622. + ldw r13, 52(sp)
  5623. + ldw r14, 56(sp)
  5624. + ldw r15, 60(sp)
  5625. + ldw r16, 64(sp)
  5626. + ldw r17, 68(sp)
  5627. + ldw r18, 72(sp)
  5628. + ldw r19, 76(sp)
  5629. + ldw r20, 80(sp)
  5630. + ldw r21, 84(sp)
  5631. + ldw r22, 88(sp)
  5632. + ldw r23, 92(sp)
  5633. + ldw et, 96(sp)
  5634. + ldw bt, 100(sp)
  5635. + ldw gp, 104(sp)
  5636. + // Don't corrupt sp.
  5637. + ldw fp, 112(sp)
  5638. + // Don't corrupt ea.
  5639. + ldw ba, 120(sp)
  5640. + ldw ra, 124(sp)
  5641. + addi sp, sp, 128
  5642. + eret
  5643. +
  5644. +.set at
  5645. +.set break
  5646. +
  5647. diff --git a/arch/nios2nommu/kernel/head.S b/arch/nios2nommu/kernel/head.S
  5648. new file mode 100644
  5649. index 0000000..f1cba65
  5650. --- /dev/null
  5651. +++ b/arch/nios2nommu/kernel/head.S
  5652. @@ -0,0 +1,228 @@
  5653. +/*
  5654. + * head.S for Altera's Excalibur development board with nios processor
  5655. + *
  5656. + * (c) Vic Phillips, Microtronix Datacom Ltd., 2001
  5657. + * (C) Copyright 2004 Microtronix Datacom Ltd
  5658. + *
  5659. + * Based on the following from the Excalibur sdk distribution:
  5660. + * NA_MemoryMap.s, NR_JumpToStart.s, NR_Setup.s, NR_CWPManager.s
  5661. + *
  5662. + * This program is free software; you can redistribute it and/or modify it under
  5663. + * the terms of the GNU General Public License as published by the Free
  5664. + * Software Foundation; either version 2 of the License, or (at your option)
  5665. + * any later version.
  5666. + *
  5667. + * This program is distributed in the hope that it will be useful, but WITHOUT
  5668. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  5669. + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  5670. + * more details.
  5671. + *
  5672. + * You should have received a copy of the GNU General Public License along with
  5673. + * this program; if not, write to the Free Software Foundation, Inc., 675
  5674. + * Mass Ave, Cambridge, MA 02139, USA.
  5675. + *
  5676. + */
  5677. +
  5678. +#include <asm/asm-offsets.h>
  5679. +#include <asm/asm-macros.h>
  5680. +
  5681. +
  5682. +#ifdef CONFIG_CRC_CHECK
  5683. +/**********************************************/
  5684. +/* Define where the CRC table lives in flash. */
  5685. +/* The __CRC_Sector_Size is the flash sector */
  5686. +/* size for the address range. */
  5687. +/**********************************************/
  5688. +
  5689. + GEQU __CRC_Table_Begin,(na_flash)+0x4000 /* Second sector of main board flash */
  5690. + GEQU __CRC_Sector_Size,0x2000
  5691. +#endif
  5692. +
  5693. +/*
  5694. + * This global variable is used as an extension to the nios'
  5695. + * STATUS register to emulate a user/supervisor mode.
  5696. + */
  5697. + .data
  5698. + .align 2
  5699. + .set noat
  5700. + .global status_extension
  5701. +status_extension:
  5702. + .long 0
  5703. +
  5704. + .global _current_thread
  5705. +_current_thread:
  5706. + .long 0
  5707. +/*
  5708. + * Input(s): passed from u-boot
  5709. + * r4 - Optional pointer to a board information structure.
  5710. + * r5 - Optional pointer to the physical starting address of the init RAM
  5711. + * disk.
  5712. + * r6 - Optional pointer to the physical ending address of the init RAM
  5713. + * disk.
  5714. + * r7 - Optional pointer to the physical starting address of any kernel
  5715. + * command-line parameters.
  5716. + */
  5717. +
  5718. +/*
  5719. + * First executable code - detected and jumped to by the ROM bootstrap
  5720. + * if the code resides in flash (looks for "Nios" at offset 0x0c from
  5721. + * the potential executable image).
  5722. + */
  5723. + .text
  5724. + .global _start
  5725. +_start:
  5726. + wrctl status,r0 /* Disable interrupts */
  5727. +
  5728. + /* Flush all cache lines within the instruction cache */
  5729. +
  5730. + movia r1,NIOS2_ICACHE_SIZE
  5731. + movui r2,NIOS2_ICACHE_LINE_SIZE
  5732. +
  5733. +text_flush:
  5734. + flushi r1
  5735. + sub r1,r1,r2
  5736. + bgt r1,r0,text_flush
  5737. + br 1f
  5738. +
  5739. + /* This is the default location for the exception
  5740. + * handler. Code in jump to our handler
  5741. + */
  5742. +
  5743. + movia r24,inthandler
  5744. + jmp r24
  5745. +1:
  5746. + /*
  5747. + * After flushing the instruction cache, we must flush the data
  5748. + * cache.
  5749. + */
  5750. +
  5751. + movia r1,NIOS2_DCACHE_SIZE
  5752. + movi r2,NIOS2_DCACHE_LINE_SIZE
  5753. +
  5754. +data_flush:
  5755. + flushd 0(r1)
  5756. + sub r1,r1,r2
  5757. + bgt r1,r0,data_flush
  5758. +
  5759. +NR_MoveStart:
  5760. +#ifdef CONFIG_BREAK_ON_START
  5761. + break
  5762. +#endif //CONFIG_BREAK_ON_START
  5763. + nextpc r1 /* Find out where we are */
  5764. +chkadr:
  5765. + movia r2,chkadr
  5766. + beq r1,r2,finish_move /* We are running in RAM done */
  5767. + addi r1,r1,(_start - chkadr) /* Source */
  5768. + movia r2,_start /* Destination */
  5769. + movia r3,__bss_start /* End of copy */
  5770. +
  5771. +loop_move: // r1: src, r2: dest, r3: last dest
  5772. + ldw r8,0(r1) // load a word from [r1]
  5773. + stw r8,0(r2) // stort a word to dest [r2]
  5774. + flushd 0(r2) // Flush cache for safty
  5775. + addi r1,r1,4 // inc the src addr
  5776. + addi r2,r2,4 // inc the dest addr
  5777. + blt r2,r3,loop_move
  5778. +
  5779. + movia r1,finish_move // VMA(_start)->l1
  5780. + jmp r1 // jmp to _start
  5781. +
  5782. +finish_move:
  5783. +
  5784. + //------------------------------------
  5785. + // Disable interrupts on known devices
  5786. + //
  5787. +#ifdef NA_ENET_ASM
  5788. +#ifdef NA_ENET_RESET_ASM
  5789. + movia r1,NA_ENET_RESET_ASM // ethernet reset address
  5790. + stwio r0,0(r1) // reset
  5791. +#endif
  5792. +#ifdef NA_ENET_RESET_N_ASM
  5793. + movia r1,NA_ENET_RESET_N_ASM // ethernet reset address
  5794. + stwio r0,0(r1) // reset
  5795. +#endif
  5796. + nop // give it some time
  5797. + nop //
  5798. + nop //
  5799. + nop //
  5800. +#endif
  5801. +#ifdef NA_TIMER0_ASM
  5802. + movia r1,NA_TIMER0_ASM // get timer address
  5803. + stwio r0,NP_TIMERCONTROL_ASM(r1) // clear interrupt enable
  5804. + stwio r0,NP_TIMERSTATUS_ASM(r1) // clear interrupt condition
  5805. +#endif
  5806. +#ifdef NA_UART0_ASM
  5807. + movia r1,NA_UART0_ASM
  5808. + stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
  5809. + stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
  5810. +#endif
  5811. +#ifdef NA_UART1_ASM
  5812. + movia r1,NA_UART1_ASM
  5813. + stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
  5814. + stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
  5815. +#endif
  5816. +#ifdef NA_UART2_ASM
  5817. + movia r1,NA_UART2_ASM
  5818. + stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
  5819. + stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
  5820. +#endif
  5821. +#ifdef NA_UART3_ASM
  5822. + movia r1,NA_UART3_ASM
  5823. + stwio r0,NP_UARTCONTROL_ASM(r1) // clear interrupt enable
  5824. + stwio r0,NP_UARTSTATUS_ASM(r1) // clear interrupt status
  5825. +#endif
  5826. +#ifdef NA_IDE_INTERFACE_ASM
  5827. + movia r1,NA_IDE_INTERFACE_ASM // ATA reset
  5828. + stwio r0,0(r1) // write to control register
  5829. +#endif
  5830. +#ifdef NA_ENET_ASM
  5831. +#ifdef NA_ENET_RESET_ASM
  5832. + movia r1,NA_ENET_RESET_ASM // ethernet reset address
  5833. + movui r2,1 // reset
  5834. + stwio r2,0(r1) //
  5835. +#endif
  5836. +#ifdef NA_ENET_RESET_N_ASM
  5837. + movia r1,NA_ENET_RESET_N_ASM // ethernet reset address
  5838. + movui r2,1 // reset
  5839. + stwio r2,0(r1) //
  5840. +#endif
  5841. +#endif
  5842. + wrctl ienable,r0 // Mask off all possible interrupts
  5843. +
  5844. + //------------------------------------------------------
  5845. + // Zero out the .bss segment (uninitialized common data)
  5846. + //
  5847. + movia r2,__bss_start // presume nothing is between
  5848. + movia r1,_end // the .bss and _end.
  5849. +1:
  5850. + stb r0,0(r2)
  5851. + addi r2,r2,1
  5852. + bne r1,r2,1b
  5853. +
  5854. + //------------------------------------------------------
  5855. + // Call main() with interrupts disabled
  5856. + //
  5857. + movia r1,status_extension // get the STATUS extension address
  5858. + movi r2,PS_S_ASM // set initial mode = supervisor
  5859. + stw r2,0(r1)
  5860. +
  5861. + movia r1,init_thread_union // set stack at top of the task union
  5862. + addi sp,r1,THREAD_SIZE_ASM
  5863. + movia r2,_current_thread // Remember current thread
  5864. + stw r1,0(r2)
  5865. +
  5866. + movia r1,nios2_boot_init // save args r4-r7 passed from u-boot
  5867. + callr r1
  5868. +
  5869. + movia r1,main // call main as a subroutine
  5870. + callr r1
  5871. +
  5872. + //------------------------------------------------------------------
  5873. + // If we return from main, break to the oci debugger and buggered we are
  5874. + //
  5875. + break
  5876. +
  5877. + /* End of startup code */
  5878. +.set at
  5879. +
  5880. +
  5881. diff --git a/arch/nios2nommu/kernel/init_task.c b/arch/nios2nommu/kernel/init_task.c
  5882. new file mode 100644
  5883. index 0000000..867e8fb
  5884. --- /dev/null
  5885. +++ b/arch/nios2nommu/kernel/init_task.c
  5886. @@ -0,0 +1,69 @@
  5887. +/*--------------------------------------------------------------------
  5888. + *
  5889. + * arch/nios2nommu/kernel/init_task.c
  5890. + *
  5891. + * Ported from arch/m68knommu/kernel/init_task.c
  5892. + *
  5893. + * Copyright (C) 2003, Microtronix Datacom Ltd.
  5894. + *
  5895. + * All rights reserved.
  5896. + *
  5897. + * This program is free software; you can redistribute it and/or modify
  5898. + * it under the terms of the GNU General Public License as published by
  5899. + * the Free Software Foundation; either version 2 of the License, or
  5900. + * (at your option) any later version.
  5901. + *
  5902. + * This program is distributed in the hope that it will be useful, but
  5903. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  5904. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  5905. + * NON INFRINGEMENT. See the GNU General Public License for more
  5906. + * details.
  5907. + *
  5908. + * You should have received a copy of the GNU General Public License
  5909. + * along with this program; if not, write to the Free Software
  5910. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  5911. + *
  5912. + *
  5913. + * Jan/20/2004 dgt NiosII
  5914. + *
  5915. + ---------------------------------------------------------------------*/
  5916. +
  5917. +#include <linux/mm.h>
  5918. +#include <linux/module.h>
  5919. +#include <linux/sched.h>
  5920. +#include <linux/init.h>
  5921. +#include <linux/init_task.h>
  5922. +#include <linux/fs.h>
  5923. +#include <linux/mqueue.h>
  5924. +
  5925. +#include <asm/uaccess.h>
  5926. +#include <asm/pgtable.h>
  5927. +
  5928. +static struct fs_struct init_fs = INIT_FS;
  5929. +static struct files_struct init_files = INIT_FILES;
  5930. +static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
  5931. +static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
  5932. +struct mm_struct init_mm = INIT_MM(init_mm);
  5933. +
  5934. +EXPORT_SYMBOL(init_mm);
  5935. +
  5936. +/*
  5937. + * Initial task structure.
  5938. + *
  5939. + * All other task structs will be allocated on slabs in fork.c
  5940. + */
  5941. +__asm__(".align 2");
  5942. +struct task_struct init_task = INIT_TASK(init_task);
  5943. +
  5944. +
  5945. +/*
  5946. + * Initial thread structure.
  5947. + *
  5948. + * We need to make sure that this is 8192-byte aligned due to the
  5949. + * way process stacks are handled. This is done by having a special
  5950. + * "init_task" linker map entry..
  5951. + */
  5952. +union thread_union init_thread_union
  5953. + __attribute__((__section__(".data.init_task"))) =
  5954. + { INIT_THREAD_INFO(init_task) };
  5955. +
  5956. diff --git a/arch/nios2nommu/kernel/io.c b/arch/nios2nommu/kernel/io.c
  5957. new file mode 100644
  5958. index 0000000..e1b0b12
  5959. --- /dev/null
  5960. +++ b/arch/nios2nommu/kernel/io.c
  5961. @@ -0,0 +1,143 @@
  5962. +/*--------------------------------------------------------------------
  5963. + *
  5964. + * Optimized IO string functions.
  5965. + *
  5966. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  5967. + *
  5968. + * Copyright (C) 2004 Microtronix Datacom Ltd
  5969. + *
  5970. + * This program is free software; you can redistribute it and/or modify
  5971. + * it under the terms of the GNU General Public License as published by
  5972. + * the Free Software Foundation; either version 2 of the License, or
  5973. + * (at your option) any later version.
  5974. + *
  5975. + * This program is distributed in the hope that it will be useful,
  5976. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  5977. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5978. + * GNU General Public License for more details.
  5979. + *
  5980. + *
  5981. + * Jan/20/2004 dgt NiosII
  5982. + *
  5983. + ---------------------------------------------------------------------*/
  5984. +
  5985. +
  5986. +#include <asm/io.h>
  5987. +
  5988. +void insl(unsigned long port, void *dst, unsigned long count)
  5989. +{
  5990. + unsigned long read32;
  5991. +
  5992. + if ((unsigned long)dst & 2){
  5993. + /* Unaligned destination pointer, need to do
  5994. + * two 16 bit writes for each read.
  5995. + */
  5996. + unsigned short *p=(unsigned short*)dst;
  5997. + while (count--){
  5998. + read32 = inl(port);
  5999. + *p++ = read32 & 0xFFFF;
  6000. + *p++ = read32 >> 16;
  6001. + }
  6002. + }
  6003. + else {
  6004. + unsigned long *p=(unsigned long*)dst;
  6005. + while (count--)
  6006. + *p++ = inl(port);
  6007. + }
  6008. +}
  6009. +
  6010. +void insw(unsigned long port, void *dst, unsigned long count)
  6011. +{
  6012. + unsigned long dst1=(unsigned long)dst;
  6013. + if (count > 8) {
  6014. + /* Long word align buffer ptr */
  6015. + if (dst1 & 2) {
  6016. + *(unsigned short*)dst1 = inw(port);
  6017. + dst1 += sizeof(unsigned short);
  6018. + count--;
  6019. + }
  6020. +
  6021. + /* Input pairs of short and store as longs */
  6022. + while (count >= 8) {
  6023. + *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
  6024. + *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
  6025. + *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
  6026. + *((unsigned long *)dst1) = inw(port) + (inw(port) << 16); dst1+=sizeof(unsigned long);
  6027. + count -= 8;
  6028. + }
  6029. + }
  6030. +
  6031. + /* Input remaining shorts */
  6032. + while (count--) {
  6033. + *((unsigned short *)dst1) = inw(port);
  6034. + dst1 += sizeof(unsigned short);
  6035. + }
  6036. +}
  6037. +
  6038. +
  6039. +void outsl(unsigned long port, void *src, unsigned long count)
  6040. +{
  6041. + unsigned long src1=(unsigned long)src;
  6042. + unsigned long write32;
  6043. +
  6044. + if (src1 & 2){
  6045. + /* Unaligned source pointer, need to read
  6046. + * two 16 bit shorts before writing to register.
  6047. + */
  6048. + while (count--){
  6049. + write32 = *(unsigned short *)src1;
  6050. + src1+=sizeof(unsigned short);
  6051. + write32 |= *((unsigned short *)src1) << 16;
  6052. + src1+=sizeof(unsigned short);
  6053. + outl(write32,port);
  6054. + }
  6055. + }
  6056. + else {
  6057. + while (count--) {
  6058. + outl(*(unsigned long *)src1,port);
  6059. + src1+=sizeof(unsigned long);
  6060. + }
  6061. + }
  6062. +}
  6063. +
  6064. +void outsw(unsigned long port, void *src, unsigned long count)
  6065. +{
  6066. + unsigned int lw;
  6067. + unsigned long src1=(unsigned long)src;
  6068. +
  6069. + if (count > 8) {
  6070. + /* Long word align buffer ptr */
  6071. + if (src1 & 2) {
  6072. + outw( *(unsigned short *)src1, port );
  6073. + count--;
  6074. + src1 += sizeof(unsigned short);
  6075. + }
  6076. +
  6077. + /* Read long words and output as pairs of short */
  6078. + while (count >= 8) {
  6079. + lw = *(unsigned long *)src1;
  6080. + src1+=sizeof(unsigned long);
  6081. + outw(lw, port);
  6082. + outw((lw >> 16), port);
  6083. + lw = *(unsigned long *)src1;
  6084. + src1+=sizeof(unsigned long);
  6085. + outw(lw, port);
  6086. + outw((lw >> 16), port);
  6087. + lw = *(unsigned long *)src1;
  6088. + src1+=sizeof(unsigned long);
  6089. + outw(lw, port);
  6090. + outw((lw >> 16), port);
  6091. + lw = *(unsigned long *)src1;
  6092. + src1+=sizeof(unsigned long);
  6093. + outw(lw, port);
  6094. + outw((lw >> 16), port);
  6095. + count -= 8;
  6096. + }
  6097. + }
  6098. +
  6099. + /* Output remaining shorts */
  6100. + while (count--) {
  6101. + outw( *(unsigned short *)src1, port );
  6102. + src1 += sizeof(unsigned short);
  6103. + }
  6104. +}
  6105. diff --git a/arch/nios2nommu/kernel/irq.c b/arch/nios2nommu/kernel/irq.c
  6106. new file mode 100644
  6107. index 0000000..f1b2347
  6108. --- /dev/null
  6109. +++ b/arch/nios2nommu/kernel/irq.c
  6110. @@ -0,0 +1,245 @@
  6111. +/*
  6112. + * linux/arch/$(ARCH)/irq.c -- general exception handling code
  6113. + *
  6114. + * Cloned from Linux/m68k.
  6115. + *
  6116. + * No original Copyright holder listed,
  6117. + * Probabily original (C) Roman Zippel (assigned DJD, 1999)
  6118. + *
  6119. + * Copyright 1999-2000 D. Jeff Dionne, <jeff@rt-control.com>
  6120. + *
  6121. + * This file is subject to the terms and conditions of the GNU General Public
  6122. + * License. See the file COPYING in the main directory of this archive
  6123. + * for more details.
  6124. + */
  6125. +
  6126. +#include <linux/types.h>
  6127. +#include <linux/module.h>
  6128. +#include <linux/sched.h>
  6129. +#include <linux/kernel_stat.h>
  6130. +#include <linux/errno.h>
  6131. +#include <linux/init.h>
  6132. +#include <linux/seq_file.h>
  6133. +
  6134. +#include <asm/system.h>
  6135. +#include <asm/irq.h>
  6136. +#include <asm/page.h>
  6137. +#include <asm/nios.h>
  6138. +#include <asm/hardirq.h>
  6139. +
  6140. +/* table for system interrupt handlers */
  6141. +irq_hand_t irq_list[NR_IRQS];
  6142. +
  6143. +/* The number of spurious interrupts */
  6144. +volatile unsigned int num_spurious;
  6145. +
  6146. +#define NUM_IRQ_NODES 16
  6147. +static irq_node_t nodes[NUM_IRQ_NODES];
  6148. +
  6149. +void __init init_irq_proc(void)
  6150. +{
  6151. + /* Insert /proc/irq driver here */
  6152. +}
  6153. +
  6154. +static irqreturn_t default_irq_handler(int irq, void *ptr)
  6155. +{
  6156. +#if 1
  6157. + printk(KERN_INFO "%s(%d): default irq handler vec=%d [0x%x]\n",
  6158. + __FILE__, __LINE__, irq, irq);
  6159. +#endif
  6160. + disable_irq(irq);
  6161. + return(IRQ_NONE);
  6162. +}
  6163. +
  6164. +/*
  6165. + * void init_IRQ(void)
  6166. + *
  6167. + * Parameters: None
  6168. + *
  6169. + * Returns: Nothing
  6170. + *
  6171. + * This function should be called during kernel startup to initialize
  6172. + * the IRQ handling routines.
  6173. + */
  6174. +
  6175. +void __init init_IRQ(void)
  6176. +{
  6177. + int i;
  6178. +
  6179. + for (i = 0; i < NR_IRQS; i++) {
  6180. + irq_list[i].handler = default_irq_handler;
  6181. + irq_list[i].flags = IRQ_FLG_STD;
  6182. + irq_list[i].dev_id = NULL;
  6183. + irq_list[i].devname = NULL;
  6184. + }
  6185. +
  6186. + for (i = 0; i < NUM_IRQ_NODES; i++)
  6187. + nodes[i].handler = NULL;
  6188. +
  6189. + /* turn off all interrupts */
  6190. + clrimr(0);
  6191. +
  6192. +#ifdef DEBUG
  6193. + printk("init_IRQ done\n");
  6194. +#endif
  6195. +}
  6196. +
  6197. +irq_node_t *new_irq_node(void)
  6198. +{
  6199. + irq_node_t *node;
  6200. + short i;
  6201. +
  6202. + for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
  6203. + if (!node->handler)
  6204. + return node;
  6205. +
  6206. + printk (KERN_INFO "new_irq_node: out of nodes\n");
  6207. + return NULL;
  6208. +}
  6209. +
  6210. +int request_irq(unsigned int irq,
  6211. + irq_handler_t handler,
  6212. + unsigned long flags,
  6213. + const char *devname,
  6214. + void *dev_id)
  6215. +{
  6216. + if (irq >= NR_IRQS) {
  6217. + printk (KERN_ERR "%s: Unknown IRQ %d from %s\n", __FUNCTION__, irq, devname);
  6218. + return -ENXIO;
  6219. + }
  6220. +
  6221. + if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
  6222. + if (irq_list[irq].flags & IRQ_FLG_LOCK) {
  6223. + printk(KERN_ERR "%s: IRQ %d from %s is not replaceable\n",
  6224. + __FUNCTION__, irq, irq_list[irq].devname);
  6225. + return -EBUSY;
  6226. + }
  6227. + if (flags & IRQ_FLG_REPLACE) {
  6228. + printk(KERN_ERR "%s: %s can't replace IRQ %d from %s\n",
  6229. + __FUNCTION__, devname, irq, irq_list[irq].devname);
  6230. + return -EBUSY;
  6231. + }
  6232. + }
  6233. + irq_list[irq].handler = handler;
  6234. + irq_list[irq].flags = flags;
  6235. + irq_list[irq].dev_id = dev_id;
  6236. + irq_list[irq].devname = devname;
  6237. +
  6238. + setimr(1<<irq);
  6239. +
  6240. + return 0;
  6241. +}
  6242. +
  6243. +void free_irq(unsigned int irq, void *dev_id)
  6244. +{
  6245. + if (irq >= NR_IRQS) {
  6246. + printk (KERN_ERR "%s: Unknown IRQ %d\n", __FUNCTION__, irq);
  6247. + return;
  6248. + }
  6249. +
  6250. + if (irq_list[irq].dev_id != dev_id)
  6251. + printk(KERN_ERR "%s: Removing probably wrong IRQ %d from %s\n",
  6252. + __FUNCTION__, irq, irq_list[irq].devname);
  6253. +
  6254. + irq_list[irq].handler = default_irq_handler;
  6255. + irq_list[irq].flags = IRQ_FLG_STD;
  6256. + irq_list[irq].dev_id = NULL;
  6257. + irq_list[irq].devname = NULL;
  6258. +
  6259. + clrimr(~(1<<irq));
  6260. +}
  6261. +
  6262. +/* usually not useful in embedded systems */
  6263. +unsigned long probe_irq_on (void)
  6264. +{
  6265. + return 0;
  6266. +}
  6267. +
  6268. +int probe_irq_off (unsigned long irqs)
  6269. +{
  6270. + return 0;
  6271. +}
  6272. +
  6273. +void enable_irq(unsigned int irq)
  6274. +{
  6275. + setimr(1<<irq);
  6276. +}
  6277. +
  6278. +void disable_irq(unsigned int irq)
  6279. +{
  6280. + clrimr(~(1<<irq));
  6281. +}
  6282. +
  6283. +int show_interrupts(struct seq_file *p, void *v)
  6284. +{
  6285. + int i = *(loff_t *) v;
  6286. +
  6287. + if (i == 0) {
  6288. + seq_printf(p, " : %10u spurious\n", num_spurious);
  6289. + }
  6290. +
  6291. + if ((i < NR_IRQS) && (!(irq_list[i].flags & IRQ_FLG_STD))) {
  6292. + seq_printf(p, "%3d: %10u ", i, kstat_cpu(0).irqs[i]);
  6293. + if (irq_list[i].flags & IRQ_FLG_LOCK)
  6294. + seq_printf(p, "L ");
  6295. + else
  6296. + seq_printf(p, " ");
  6297. + seq_printf(p, "%s\n", irq_list[i].devname);
  6298. + }
  6299. +
  6300. + return 0;
  6301. +}
  6302. +
  6303. +#ifdef CONFIG_PREEMPT_TIMES
  6304. +extern void latency_cause(int,int);
  6305. +#else
  6306. +#define latency_cause(a, b)
  6307. +#endif
  6308. +asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
  6309. +{
  6310. +
  6311. + /* give the machine specific code a crack at it first */
  6312. + irq_enter();
  6313. + kstat_cpu(0).irqs[vec]++;
  6314. + latency_cause(-99,~vec);
  6315. +
  6316. + if (irq_list[vec].handler) {
  6317. + if ((irq_list[vec].handler(vec, irq_list[vec].dev_id))==IRQ_NONE)
  6318. + ;
  6319. + } else
  6320. +#ifdef DEBUG
  6321. + {
  6322. + printk(KERN_ERR "No interrupt handler for level %ld\n", vec);
  6323. +//// asm("trap 5");
  6324. + }
  6325. +#else
  6326. + #if 1
  6327. + printk(KERN_ERR "Ignoring interrupt %ld: no handler\n", vec);
  6328. + #else
  6329. + panic("No interrupt handler for level %ld\n", vec);
  6330. + #endif
  6331. +#endif
  6332. +
  6333. + irq_exit();
  6334. +}
  6335. +
  6336. +int get_irq_list(char *buf)
  6337. +{
  6338. + int i, len = 0;
  6339. +
  6340. + /* autovector interrupts */
  6341. + for (i = 0; i < NR_IRQS; i++) {
  6342. + if (irq_list[i].handler) {
  6343. + len += sprintf(buf+len, "auto %2d: %10u ", i,
  6344. + i ? kstat_cpu(0).irqs[i] : num_spurious);
  6345. + if (irq_list[i].flags & IRQ_FLG_LOCK)
  6346. + len += sprintf(buf+len, "L ");
  6347. + else
  6348. + len += sprintf(buf+len, " ");
  6349. + len += sprintf(buf+len, "%s\n", irq_list[i].devname);
  6350. + }
  6351. + }
  6352. + return len;
  6353. +}
  6354. +EXPORT_SYMBOL(request_irq);
  6355. +EXPORT_SYMBOL(free_irq);
  6356. diff --git a/arch/nios2nommu/kernel/module.c b/arch/nios2nommu/kernel/module.c
  6357. new file mode 100644
  6358. index 0000000..99b270f
  6359. --- /dev/null
  6360. +++ b/arch/nios2nommu/kernel/module.c
  6361. @@ -0,0 +1,173 @@
  6362. +/* Kernel module help for Nios2.
  6363. + Copyright (C) 2004 Microtronix Datacom Ltd.
  6364. + Copyright (C) 2001,03 Rusty Russell
  6365. +
  6366. + This program is free software; you can redistribute it and/or modify
  6367. + it under the terms of the GNU General Public License as published by
  6368. + the Free Software Foundation; either version 2 of the License, or
  6369. + (at your option) any later version.
  6370. +
  6371. + This program is distributed in the hope that it will be useful,
  6372. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6373. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6374. + GNU General Public License for more details.
  6375. +
  6376. + You should have received a copy of the GNU General Public License
  6377. + along with this program; if not, write to the Free Software
  6378. + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  6379. +
  6380. + Written by Wentao Xu <xuwentao@microtronix.com>
  6381. +*/
  6382. +#include <linux/moduleloader.h>
  6383. +#include <linux/elf.h>
  6384. +#include <linux/vmalloc.h>
  6385. +#include <linux/fs.h>
  6386. +#include <linux/string.h>
  6387. +#include <linux/kernel.h>
  6388. +
  6389. +#if 0
  6390. +#define DEBUGP printk
  6391. +#else
  6392. +#define DEBUGP(fmt , ...)
  6393. +#endif
  6394. +
  6395. +void *module_alloc(unsigned long size)
  6396. +{
  6397. + if (size == 0)
  6398. + return NULL;
  6399. + return vmalloc(size);
  6400. +}
  6401. +
  6402. +
  6403. +/* Free memory returned from module_alloc */
  6404. +void module_free(struct module *mod, void *module_region)
  6405. +{
  6406. + vfree(module_region);
  6407. + /* FIXME: If module_region == mod->init_region, trim exception
  6408. + table entries. */
  6409. +}
  6410. +
  6411. +/* We don't need anything special. */
  6412. +int module_frob_arch_sections(Elf_Ehdr *hdr,
  6413. + Elf_Shdr *sechdrs,
  6414. + char *secstrings,
  6415. + struct module *mod)
  6416. +{
  6417. + return 0;
  6418. +}
  6419. +
  6420. +int apply_relocate(Elf32_Shdr *sechdrs,
  6421. + const char *strtab,
  6422. + unsigned int symindex,
  6423. + unsigned int relsec,
  6424. + struct module *me)
  6425. +{
  6426. + printk(KERN_ERR "module %s: NO-ADD RELOCATION unsupported\n",
  6427. + me->name);
  6428. + return -ENOEXEC;
  6429. +}
  6430. +
  6431. +
  6432. +int apply_relocate_add (Elf32_Shdr *sechdrs, const char *strtab,
  6433. + unsigned int symindex, unsigned int relsec,
  6434. + struct module *mod)
  6435. +{
  6436. + unsigned int i;
  6437. + Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr;
  6438. +
  6439. + DEBUGP ("Applying relocate section %u to %u\n", relsec,
  6440. + sechdrs[relsec].sh_info);
  6441. +
  6442. + for (i = 0; i < sechdrs[relsec].sh_size / sizeof (*rela); i++) {
  6443. + /* This is where to make the change */
  6444. + uint32_t word;
  6445. + uint32_t *loc
  6446. + = ((void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
  6447. + + rela[i].r_offset);
  6448. + /* This is the symbol it is referring to. Note that all
  6449. + undefined symbols have been resolved. */
  6450. + Elf32_Sym *sym
  6451. + = ((Elf32_Sym *)sechdrs[symindex].sh_addr
  6452. + + ELF32_R_SYM (rela[i].r_info));
  6453. + uint32_t v = sym->st_value + rela[i].r_addend;
  6454. +
  6455. + switch (ELF32_R_TYPE (rela[i].r_info)) {
  6456. + case R_NIOS2_NONE:
  6457. + break;
  6458. +
  6459. + case R_NIOS2_BFD_RELOC_32:
  6460. + *loc += v;
  6461. + break;
  6462. +
  6463. + case R_NIOS2_PCREL16:
  6464. + v -= (uint32_t)loc + 4;
  6465. + if ((int32_t)v > 0x7fff ||
  6466. + (int32_t)v < -(int32_t)0x8000) {
  6467. + printk(KERN_ERR
  6468. + "module %s: relocation overflow\n",
  6469. + mod->name);
  6470. + return -ENOEXEC;
  6471. + }
  6472. + word = *loc;
  6473. + *loc = ((((word >> 22) << 16) | (v & 0xffff)) << 6) | (word & 0x3f);
  6474. + break;
  6475. +
  6476. + case R_NIOS2_CALL26:
  6477. + if (v & 3) {
  6478. + printk(KERN_ERR
  6479. + "module %s: dangerous relocation\n",
  6480. + mod->name);
  6481. + return -ENOEXEC;
  6482. + }
  6483. + if ((v >> 28) != ((uint32_t)loc >> 28)) {
  6484. + printk(KERN_ERR
  6485. + "module %s: relocation overflow\n",
  6486. + mod->name);
  6487. + return -ENOEXEC;
  6488. + }
  6489. + *loc = (*loc & 0x3f) | ((v >> 2) << 6);
  6490. + break;
  6491. +
  6492. + case R_NIOS2_HI16:
  6493. + word = *loc;
  6494. + *loc = ((((word >> 22) << 16) | ((v >>16) & 0xffff)) << 6) |
  6495. + (word & 0x3f);
  6496. + break;
  6497. +
  6498. + case R_NIOS2_LO16:
  6499. + word = *loc;
  6500. + *loc = ((((word >> 22) << 16) | (v & 0xffff)) << 6) |
  6501. + (word & 0x3f);
  6502. + break;
  6503. +
  6504. + case R_NIOS2_HIADJ16:
  6505. + {
  6506. + Elf32_Addr word2;
  6507. +
  6508. + word = *loc;
  6509. + word2 = ((v >> 16) + ((v >> 15) & 1)) & 0xffff;
  6510. + *loc = ((((word >> 22) << 16) | word2) << 6) |
  6511. + (word & 0x3f);
  6512. + }
  6513. + break;
  6514. +
  6515. + default:
  6516. + printk (KERN_ERR "module %s: Unknown reloc: %u\n",
  6517. + mod->name, ELF32_R_TYPE (rela[i].r_info));
  6518. + return -ENOEXEC;
  6519. + }
  6520. + }
  6521. +
  6522. + return 0;
  6523. +}
  6524. +
  6525. +int module_finalize(const Elf_Ehdr *hdr,
  6526. + const Elf_Shdr *sechdrs,
  6527. + struct module *me)
  6528. +{
  6529. + return 0;
  6530. +}
  6531. +
  6532. +void module_arch_cleanup(struct module *mod)
  6533. +{
  6534. +}
  6535. diff --git a/arch/nios2nommu/kernel/nios2_ksyms.c b/arch/nios2nommu/kernel/nios2_ksyms.c
  6536. new file mode 100644
  6537. index 0000000..720f007
  6538. --- /dev/null
  6539. +++ b/arch/nios2nommu/kernel/nios2_ksyms.c
  6540. @@ -0,0 +1,113 @@
  6541. +/*--------------------------------------------------------------------
  6542. + *
  6543. + * arch/nios2nommu/kernel/nios_ksyms.c
  6544. + *
  6545. + * Derived from Nios1
  6546. + *
  6547. + * Copyright (C) 2004 Microtronix Datacom Ltd
  6548. + *
  6549. + * This program is free software; you can redistribute it and/or modify
  6550. + * it under the terms of the GNU General Public License as published by
  6551. + * the Free Software Foundation; either version 2 of the License, or
  6552. + * (at your option) any later version.
  6553. + *
  6554. + * This program is distributed in the hope that it will be useful,
  6555. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6556. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6557. + * GNU General Public License for more details.
  6558. + *
  6559. + *
  6560. + * vic - copied from v850
  6561. + * Jan/20/2004 dgt NiosII
  6562. + *
  6563. + ---------------------------------------------------------------------*/
  6564. +
  6565. +
  6566. +//;dgt2;tmp;
  6567. +
  6568. +#include <linux/module.h>
  6569. +#include <linux/linkage.h>
  6570. +#include <linux/sched.h>
  6571. +#include <linux/string.h>
  6572. +#include <linux/mm.h>
  6573. +#include <linux/user.h>
  6574. +#include <linux/elfcore.h>
  6575. +#include <linux/in6.h>
  6576. +#include <linux/interrupt.h>
  6577. +
  6578. +#include <asm/setup.h>
  6579. +#include <asm/pgalloc.h>
  6580. +#include <asm/irq.h>
  6581. +#include <asm/io.h>
  6582. +#include <asm/semaphore.h>
  6583. +#include <asm/checksum.h>
  6584. +#include <asm/hardirq.h>
  6585. +#include <asm/current.h>
  6586. +
  6587. +extern void dump_thread(struct pt_regs *, struct user *);
  6588. +/* platform dependent support */
  6589. +
  6590. +EXPORT_SYMBOL(__ioremap);
  6591. +EXPORT_SYMBOL(iounmap);
  6592. +EXPORT_SYMBOL(dump_fpu);
  6593. +EXPORT_SYMBOL(dump_thread);
  6594. +
  6595. +EXPORT_SYMBOL(kernel_thread);
  6596. +
  6597. +/* Networking helper routines. */
  6598. +EXPORT_SYMBOL(csum_partial_copy);
  6599. +
  6600. +EXPORT_SYMBOL(memcpy);
  6601. +EXPORT_SYMBOL(memset);
  6602. +EXPORT_SYMBOL(memmove);
  6603. +
  6604. +EXPORT_SYMBOL(__down);
  6605. +EXPORT_SYMBOL(__down_interruptible);
  6606. +EXPORT_SYMBOL(__down_trylock);
  6607. +EXPORT_SYMBOL(__up);
  6608. +
  6609. +EXPORT_SYMBOL(get_wchan);
  6610. +
  6611. +/*
  6612. + * libgcc functions - functions that are used internally by the
  6613. + * compiler... (prototypes are not correct though, but that
  6614. + * doesn't really matter since they're not versioned).
  6615. + */
  6616. +extern void __gcc_bcmp(void);
  6617. +extern void __ashldi3(void);
  6618. +extern void __ashrdi3(void);
  6619. +extern void __cmpdi2(void);
  6620. +extern void __divdi3(void);
  6621. +extern void __divsi3(void);
  6622. +extern void __lshrdi3(void);
  6623. +extern void __moddi3(void);
  6624. +extern void __modsi3(void);
  6625. +extern void __muldi3(void);
  6626. +extern void __mulsi3(void);
  6627. +extern void __negdi2(void);
  6628. +extern void __ucmpdi2(void);
  6629. +extern void __udivdi3(void);
  6630. +extern void __udivmoddi4(void);
  6631. +extern void __udivsi3(void);
  6632. +extern void __umoddi3(void);
  6633. +extern void __umodsi3(void);
  6634. +
  6635. + /* gcc lib functions */
  6636. +EXPORT_SYMBOL(__gcc_bcmp);
  6637. +EXPORT_SYMBOL(__ashldi3);
  6638. +EXPORT_SYMBOL(__ashrdi3);
  6639. +EXPORT_SYMBOL(__cmpdi2);
  6640. +EXPORT_SYMBOL(__divdi3);
  6641. +EXPORT_SYMBOL(__divsi3);
  6642. +EXPORT_SYMBOL(__lshrdi3);
  6643. +EXPORT_SYMBOL(__moddi3);
  6644. +EXPORT_SYMBOL(__modsi3);
  6645. +EXPORT_SYMBOL(__muldi3);
  6646. +EXPORT_SYMBOL(__mulsi3);
  6647. +EXPORT_SYMBOL(__negdi2);
  6648. +EXPORT_SYMBOL(__ucmpdi2);
  6649. +EXPORT_SYMBOL(__udivdi3);
  6650. +EXPORT_SYMBOL(__udivmoddi4);
  6651. +EXPORT_SYMBOL(__udivsi3);
  6652. +EXPORT_SYMBOL(__umoddi3);
  6653. +EXPORT_SYMBOL(__umodsi3);
  6654. diff --git a/arch/nios2nommu/kernel/nios_gdb_stub.c b/arch/nios2nommu/kernel/nios_gdb_stub.c
  6655. new file mode 100644
  6656. index 0000000..103925b
  6657. --- /dev/null
  6658. +++ b/arch/nios2nommu/kernel/nios_gdb_stub.c
  6659. @@ -0,0 +1,1456 @@
  6660. +// Modified for uClinux - Vic - Apr 2002
  6661. +// From:
  6662. +
  6663. +// File: nios_gdb_stub.c
  6664. +// Date: 2000 June 20
  6665. +// Author dvb \ Altera Santa Cruz
  6666. +
  6667. +#ifndef __KERNEL__
  6668. +#include "nios.h"
  6669. +#else
  6670. +#include <linux/kernel.h>
  6671. +#include <linux/sched.h>
  6672. +#include <asm/nios.h>
  6673. +#endif
  6674. +
  6675. +#include "nios_gdb_stub.h"
  6676. +
  6677. +#define na_debug_peripheral_irq 8
  6678. +
  6679. +enum
  6680. +{
  6681. + na_BreakpointTrap = 3,
  6682. + na_SingleStepTrap = 4,
  6683. + na_StartGDBTrap = 5
  6684. +};
  6685. +
  6686. +
  6687. +#ifdef __KERNEL__
  6688. +
  6689. +extern int _etext;
  6690. +
  6691. +static void puts( unsigned char *s )
  6692. +{
  6693. + while(*s) {
  6694. + while (!(nasys_printf_uart->np_uartstatus & np_uartstatus_trdy_mask));
  6695. + nasys_printf_uart->np_uarttxdata = *s++;
  6696. + }
  6697. +}
  6698. +
  6699. +#endif // __KERNEL__
  6700. +
  6701. +// --------------------------------
  6702. +// Local Prototypes
  6703. +
  6704. +#if GDB_DEBUG_PRINT
  6705. +
  6706. +static void StringFit(char *s,int w);
  6707. +
  6708. +// --------------------------------
  6709. +// Debugging The Debugger
  6710. +
  6711. +void GDB_RawMessage(char *s)
  6712. + {
  6713. + StringFit(s,32);
  6714. + nr_pio_lcdwritescreen(s);
  6715. + }
  6716. +#else
  6717. + #define GDB_RawMessage(a,b,c) // define away to nothing
  6718. +#endif
  6719. +
  6720. +#if GDB_DEBUG_PRINT
  6721. +void GDB_Print2(char *s,int n1,int n2)
  6722. + {
  6723. + char st[1000];
  6724. +
  6725. + sprintf(st,s,n1,n2);
  6726. + GDB_RawMessage(st);
  6727. + }
  6728. +#else
  6729. + #define GDB_Print2(a,b,c) // define away to nothing
  6730. +#endif
  6731. +
  6732. +// If string is longer than w, cut out the middle.
  6733. +
  6734. +#if GDB_DEBUG_PRINT
  6735. +int StringLen(char *s)
  6736. + {
  6737. + int l = 0;
  6738. +
  6739. + while(*s++)
  6740. + l++;
  6741. + return l;
  6742. + }
  6743. +
  6744. +static void StringFit(char *s,int w)
  6745. + {
  6746. + if(StringLen(s) > w)
  6747. + {
  6748. + int i;
  6749. +
  6750. +
  6751. + w = w / 2;
  6752. +
  6753. + for(i = 0; i < w; i++)
  6754. + {
  6755. + s[i + w] = s[StringLen(s) - w + i];
  6756. + }
  6757. + s[w + w] = 0;
  6758. + }
  6759. + }
  6760. +#endif
  6761. +
  6762. +// ---------------------------------------------
  6763. +// Generic routines for dealing with
  6764. +// hex input, output, and parsing
  6765. +// (Adapted from other stubs.)
  6766. +
  6767. +NiosGDBGlobals gdb = {0}; // not static: the ISR uses it!
  6768. +
  6769. +static char dHexChars[16] = "0123456789abcdef";
  6770. +
  6771. +/*
  6772. + * HexCharToValue -- convert a characters
  6773. + * to its hex value, or -1 if not.
  6774. + */
  6775. +char HexCharToValue(char c)
  6776. +{
  6777. + char result=0;
  6778. +
  6779. + if(c >= '0' && c <= '9')
  6780. + result = c - '0';
  6781. + else if(c >= 'a' && c <= 'f')
  6782. + result = c - 'a' + 10;
  6783. + else if(c >= 'A' && c <= 'F')
  6784. + result = c - 'A' + 10;
  6785. + else
  6786. + result = -1;
  6787. + return result;
  6788. +}
  6789. +
  6790. +/*
  6791. + * HexStringToValue -- convert a 2*byte_width string of characters
  6792. + * to its little endian hex value,
  6793. + * or -1 if not.
  6794. + * This routine is for strings of hex values
  6795. + */
  6796. +unsigned long HexStringToValue(char *c, int byte_width)
  6797. +{
  6798. + unsigned long result=0;
  6799. + unsigned char a,b;
  6800. + int i=0;
  6801. +
  6802. + while (i < byte_width)
  6803. + {
  6804. + a = HexCharToValue(*c++);
  6805. + if (a & 0x80) return a;
  6806. + b = HexCharToValue(*c++);
  6807. + if (b & 0x80) return b;
  6808. + b = (a<<4) | (b&0x0f);
  6809. + result |= b << (i*8);
  6810. + i++;
  6811. + }
  6812. + return result;
  6813. +}
  6814. +
  6815. +/*
  6816. + * Hex2Value -- convert a non-hex char delimited string
  6817. + * to its big endian hex value.
  6818. + * This routine is for address and byte count values
  6819. + */
  6820. +
  6821. +char *Hex2Value(char *hexIn, int *valueOut)
  6822. + {
  6823. + char c;
  6824. + int digitValue;
  6825. + int value = 0;
  6826. +
  6827. + while(1)
  6828. + {
  6829. + c = *hexIn;
  6830. + digitValue = HexCharToValue(c);
  6831. + if(digitValue < 0)
  6832. + {
  6833. + *valueOut = value;
  6834. + return hexIn;
  6835. + }
  6836. + hexIn++;
  6837. + value = (value << 4) + digitValue;
  6838. + }
  6839. + }
  6840. +
  6841. +/*
  6842. + * HexToMem -- convert a string to a specified
  6843. + * number of bytes in memory.
  6844. + *
  6845. + * JMB -- make this thing a bit smarter so
  6846. + * that it selects the byte width to
  6847. + * write based on the number of bytes
  6848. + * and the destination address alignment.
  6849. + * This is to support writes to non-byte enabled
  6850. + * peripheral registers...I don't like it.
  6851. + * Beware! there are cases where it wont work
  6852. + */
  6853. +char *HexToMem(char *hexIn, char *memOut, int memByteCount)
  6854. +{
  6855. + int i;
  6856. + unsigned long x;
  6857. + short *memOutS=0;
  6858. + long *memOutL=0;
  6859. + int byte_width;
  6860. +
  6861. + //determine maximum byte width
  6862. + if (((memByteCount%2) != 0) || (((unsigned int)memOut%2) != 0))
  6863. + byte_width = 1;
  6864. + else if (((memByteCount % 4) != 0) || (((unsigned int)memOut % 4) != 0))
  6865. + {
  6866. + byte_width = 2;
  6867. + memOutS = (short *)memOut;
  6868. + }
  6869. + else
  6870. + {
  6871. + byte_width = 4;
  6872. + memOutL = (long *)memOut;
  6873. + }
  6874. + for(i = 0; i < memByteCount; i+=byte_width)
  6875. + {
  6876. + x = HexStringToValue(hexIn,byte_width);
  6877. + hexIn += byte_width*2;
  6878. + switch (byte_width)
  6879. + {
  6880. + case 1:
  6881. + *memOut++ = (unsigned char) 0x000000ff & x;
  6882. + break;
  6883. + case 2:
  6884. + *memOutS++ = (unsigned short) 0x0000ffff & x;
  6885. + break;
  6886. + case 4:
  6887. + *memOutL++ = x;
  6888. + break;
  6889. + default:
  6890. + //How could this ever happen???
  6891. + break;
  6892. + }
  6893. + }
  6894. +
  6895. + return hexIn;
  6896. +}
  6897. +
  6898. +char *MemToHex(char *memIn, char *hexOut, int memByteCount)
  6899. +{
  6900. + int i,j;
  6901. + int byte_width;
  6902. + unsigned long x=0;
  6903. + unsigned short *memInS=0;
  6904. + unsigned long *memInL=0;
  6905. +
  6906. + //determine maximum byte width
  6907. + if (((memByteCount % 2) != 0) || (((unsigned int)memIn % 2) != 0))
  6908. + byte_width = 1;
  6909. + else if (((memByteCount % 4) != 0) || (((unsigned int)memIn % 4) != 0))
  6910. + {
  6911. + byte_width = 2;
  6912. + memInS = (short *)memIn;
  6913. + }
  6914. + else
  6915. + {
  6916. + byte_width = 4;
  6917. + memInL = (long *)memIn;
  6918. + }
  6919. +
  6920. + for(i = 0; i < memByteCount; i+=byte_width)
  6921. + {
  6922. + switch (byte_width)
  6923. + {
  6924. + case 1:
  6925. + x = *memIn++;
  6926. + break;
  6927. + case 2:
  6928. + x = *memInS++;
  6929. + break;
  6930. + case 4:
  6931. + x = *memInL++;
  6932. + break;
  6933. + default:
  6934. + //How would we get here?
  6935. + break;
  6936. + }
  6937. +
  6938. + for (j=0; j<byte_width; j++)
  6939. + {
  6940. + *hexOut++ = dHexChars[(x&0x000000f0)>>4];
  6941. + *hexOut++ = dHexChars[x&0x0000000f];
  6942. + x = x>>8;
  6943. + }
  6944. + }
  6945. +
  6946. + *hexOut = 0;
  6947. +
  6948. + return hexOut;
  6949. +}
  6950. +
  6951. +//Send just the + or - to indicate
  6952. +//ACK or NACK
  6953. +void GDBPutAck (char ack)
  6954. +{
  6955. + if (gdb.comlink == ne_gdb_serial)
  6956. + GDBPutChar (ack);
  6957. +#ifdef ETHER_DEBUG
  6958. +#ifdef ethernet_exists
  6959. + else
  6960. + {
  6961. + if (gdb.host_ip_address != 0)
  6962. + nr_plugs_send_to (gdb.gdb_eth_plug, &ack, 1, 0,
  6963. + gdb.host_ip_address,
  6964. + gdb.host_port_number);
  6965. + }
  6966. +#endif
  6967. +#endif
  6968. +}
  6969. +
  6970. +/*
  6971. + * Once a $ comes in, use GetGDBPacket to
  6972. + * retrieve a full gdb packet, and verify
  6973. + * checksum, and reply + or -.
  6974. + */
  6975. +int GetGDBPacket(char *aBuffer)
  6976. +{
  6977. + int checksum=0;
  6978. + int length=0;
  6979. + char c;
  6980. + int x=0;
  6981. +
  6982. + if (gdb.comlink == ne_gdb_serial)
  6983. + {
  6984. + while ((c = GDBGetChar ()) != '$') ;
  6985. +
  6986. +startPacket:
  6987. + length = 0;
  6988. + checksum = 0;
  6989. + while(((c = GDBGetChar()) != '#') && (length < kTextBufferSize))
  6990. + {
  6991. + if(c == '$')
  6992. + goto startPacket;
  6993. + checksum += c;
  6994. + aBuffer[length++] = c;
  6995. + aBuffer[length] = 0;
  6996. + }
  6997. +
  6998. + c = GDBGetChar();
  6999. + x = HexCharToValue(c) << 4;
  7000. + c = GDBGetChar();
  7001. + x += HexCharToValue(c);
  7002. +
  7003. +
  7004. + checksum &= 0xff;
  7005. +
  7006. + GDB_Print2("GetPacket %d",length,0);
  7007. + }
  7008. +#ifdef ETHER_DEBUG
  7009. +#ifdef ethernet_exists
  7010. + else
  7011. + {
  7012. + int srcidx;
  7013. + // wait till beginning of packet
  7014. + while (gdb.textBuffer[0] != '$') nr_plugs_idle();
  7015. +startEPacket:
  7016. + length = 0;
  7017. + checksum = 0;
  7018. + srcidx = 1;
  7019. +
  7020. + //loop until packet terminator
  7021. + //leave enough room for the checksum at the end
  7022. + while (((c = gdb.textBuffer[srcidx++]) != '#') && (srcidx < kTextBufferSize-2))
  7023. + {
  7024. + if (c == '$')
  7025. + goto startEPacket;
  7026. +
  7027. + checksum += c;
  7028. + aBuffer[length++] = c;
  7029. + }
  7030. +
  7031. + c = gdb.textBuffer[srcidx++];
  7032. + x = HexCharToValue(c) << 4;
  7033. + c = gdb.textBuffer[srcidx++];
  7034. + x += HexCharToValue (c);
  7035. +
  7036. + aBuffer[length++] = 0;
  7037. +
  7038. + checksum &= 0xff;
  7039. +
  7040. + GDB_Print2("GetPacket %d",length,0);
  7041. + }
  7042. +#endif
  7043. +#endif
  7044. +
  7045. + if(checksum != x)
  7046. + {
  7047. + GDBPutAck('-');
  7048. + length = 0;
  7049. + }
  7050. + else
  7051. + {
  7052. + GDBPutAck('+');
  7053. + }
  7054. + return length;
  7055. +}
  7056. +
  7057. +//Wait for acknowledgement
  7058. +//Should we have some way of timing out???
  7059. +//return TRUE if ACK
  7060. +//return FALSE if NACK
  7061. +int GDBGetACK (void)
  7062. +{
  7063. + char c;
  7064. + if (gdb.comlink == ne_gdb_serial)
  7065. + {
  7066. + while (1)
  7067. + {
  7068. + c = GDBGetChar ();
  7069. + if (c == '+') return (1);
  7070. + else if (c == '-') return (0);
  7071. + }
  7072. +
  7073. + }
  7074. +#ifdef ETHER_DEBUG
  7075. +#ifdef ethernet_exists
  7076. + else
  7077. + {
  7078. + gdb.ACKstatus = ne_gdb_ack_waiting;
  7079. + while (1)
  7080. + {
  7081. + nr_plugs_idle ();
  7082. + if (gdb.ACKstatus == ne_gdb_ack_acked)
  7083. + {
  7084. + gdb.ACKstatus = ne_gdb_ack_notwaiting;
  7085. + return (1);
  7086. + }
  7087. + else if (gdb.ACKstatus == ne_gdb_ack_nacked)
  7088. + {
  7089. + gdb.ACKstatus = ne_gdb_ack_notwaiting;
  7090. + return (0);
  7091. + }
  7092. + }
  7093. + }
  7094. +#endif
  7095. +#endif
  7096. + return(0);
  7097. +}
  7098. +
  7099. +/*
  7100. + * Send a packet, preceded by $,
  7101. + * and followed by #checksum.
  7102. + */
  7103. +void PutGDBPacket(char *aBuffer)
  7104. +{
  7105. + int checksum;
  7106. + char c;
  7107. + char *origPtr;
  7108. + int cnt=0;
  7109. +
  7110. + origPtr = aBuffer; // Remember in case we get a NACK
  7111. + if (gdb.comlink == ne_gdb_serial)
  7112. + {
  7113. +startPutSerial:
  7114. + GDBPutChar('$');
  7115. + checksum = 0;
  7116. + while((c = *aBuffer++) != 0)
  7117. + {
  7118. + checksum += c;
  7119. + GDBPutChar(c);
  7120. + }
  7121. + GDBPutChar('#');
  7122. + GDBPutChar(dHexChars[(checksum >> 4) & 15]);
  7123. + GDBPutChar(dHexChars[checksum & 15]);
  7124. +
  7125. + if (!GDBGetACK ())
  7126. + {
  7127. + aBuffer = origPtr;
  7128. + if (++cnt < GDB_RETRY_CNT) goto startPutSerial;
  7129. + }
  7130. + }
  7131. +#ifdef ETHER_DEBUG
  7132. +#ifdef ethernet_exists
  7133. + else
  7134. + {
  7135. + if (gdb.host_ip_address != 0)
  7136. + {
  7137. + int i;
  7138. + int result;
  7139. + char c1;
  7140. +
  7141. + i = 0;
  7142. + c = aBuffer[i];
  7143. + if (c==0) return; //there is no data in packet, so why bother sending
  7144. + aBuffer[i++] = '$';
  7145. + checksum = 0;
  7146. + do
  7147. + {
  7148. + checksum += c;
  7149. + c1 = aBuffer[i];
  7150. + aBuffer[i++] = c;
  7151. + c = c1;
  7152. + } while (c != 0);
  7153. +
  7154. + aBuffer[i++] = '#';
  7155. + aBuffer[i++] = dHexChars[(checksum >> 4) & 15];
  7156. + aBuffer[i++] = dHexChars[checksum & 15];
  7157. + aBuffer[i++] = 0;
  7158. +startPutEth:
  7159. + result = nr_plugs_send_to (gdb.gdb_eth_plug, aBuffer, i, 0,
  7160. + gdb.host_ip_address,
  7161. + gdb.host_port_number);
  7162. +
  7163. + if (!GDBGetACK ())
  7164. + {
  7165. + if (++cnt < GDB_RETRY_CNT) goto startPutEth;
  7166. + }
  7167. + aBuffer[0] = 0; //clear packet to
  7168. + }
  7169. + }
  7170. +#endif
  7171. +#endif
  7172. +}
  7173. +
  7174. +int PutTracePacket(char *aBuffer, int size)
  7175. +{
  7176. + int checksum;
  7177. +#ifdef ethernet_exists
  7178. + char c;
  7179. +#endif
  7180. + int i;
  7181. + int cnt=0;
  7182. +
  7183. + if (gdb.comlink == ne_gdb_serial)
  7184. + {
  7185. +startPutSerial:
  7186. + GDBPutChar('$');
  7187. + checksum = 0;
  7188. + for (i=0; i<size; i++)
  7189. + {
  7190. + checksum += aBuffer[i];
  7191. + GDBPutChar (aBuffer[i]);
  7192. + }
  7193. + GDBPutChar('#');
  7194. + GDBPutChar(dHexChars[(checksum >> 4) & 15]);
  7195. + GDBPutChar(dHexChars[checksum & 15]);
  7196. +
  7197. + if (!GDBGetACK ())
  7198. + {
  7199. + if (++cnt < GDB_RETRY_CNT) goto startPutSerial;
  7200. + }
  7201. + }
  7202. +#ifdef ETHER_DEBUG
  7203. +#ifdef ethernet_exists
  7204. + else
  7205. + {
  7206. + int result;
  7207. + char c1;
  7208. +
  7209. + checksum = 0;
  7210. + c = '$';
  7211. + for (i=0; i<size; i++)
  7212. + {
  7213. + checksum += aBuffer[i];
  7214. + c1 = aBuffer[i];
  7215. + aBuffer[i] = c;
  7216. + c = c1;
  7217. + }
  7218. + aBuffer[i++] = c;
  7219. +
  7220. + aBuffer[i++] = '#';
  7221. + aBuffer[i++] = dHexChars[(checksum >> 4) & 15];
  7222. + aBuffer[i++] = dHexChars[checksum & 15];
  7223. + aBuffer[i++] = 0;
  7224. +ethResend:
  7225. + if (gdb.host_ip_address != 0)
  7226. + {
  7227. + result = nr_plugs_send_to (gdb.gdb_eth_plug, aBuffer, i, 0,
  7228. + gdb.host_ip_address,
  7229. + gdb.host_port_number);
  7230. + }
  7231. + if (!GDBGetACK ())
  7232. + {
  7233. + if (++cnt < GDB_RETRY_CNT) goto ethResend;
  7234. + }
  7235. + aBuffer[0]=0;
  7236. + }
  7237. +#endif
  7238. +#endif
  7239. + if (cnt < GDB_RETRY_CNT) return 1;
  7240. + else return 0;
  7241. +}
  7242. +
  7243. +void PutGDBOKPacket(char *aBuffer)
  7244. + {
  7245. + aBuffer[0] = 'O';
  7246. + aBuffer[1] = 'K';
  7247. + aBuffer[2] = 0;
  7248. + PutGDBPacket(aBuffer);
  7249. + }
  7250. +
  7251. +#if nasys_debug_core
  7252. +
  7253. +//some defines used exclusively for TRACE data xfer
  7254. +//stepsize is the ascii hex step value i.e. twice the binary length
  7255. +#define stepsize (2*(2*sizeof(int) + sizeof (char)))
  7256. +#define MAX_TRACE_BYTES (((int)((2*MAX_DATA_SIZE-2)/stepsize))*stepsize)
  7257. +
  7258. +int Trace_Read_Intercept (char *aBuffer)
  7259. +{
  7260. + int cnt=0;
  7261. + unsigned int data;
  7262. + unsigned char code;
  7263. + int byteCount;
  7264. + unsigned char *w;
  7265. + unsigned short dataAccumulate;
  7266. + int status;
  7267. +
  7268. + w = aBuffer;
  7269. + w++; //skip past the m
  7270. + if (*w++ == 't') //see if this is a special "memory trace" packet
  7271. + {
  7272. + w = Hex2Value(w,&byteCount); //get the number of bytes to transfer
  7273. +
  7274. + //turn byteCount to a multiple of stepsize
  7275. + byteCount = ((int)(byteCount/stepsize))*stepsize;
  7276. +
  7277. + //wait until fifo empties
  7278. + nm_debug_get_reg(status, np_debug_write_status);
  7279. + while (status&np_debug_write_status_writing_mask) nm_debug_get_reg(status,np_debug_write_status);
  7280. +
  7281. + // loop through total size
  7282. + while (byteCount > 0)
  7283. + {
  7284. + w=aBuffer; //reset w to beginning of buffer
  7285. +
  7286. + //calculate the number of bytes in this packet
  7287. + if (byteCount > MAX_TRACE_BYTES) dataAccumulate = MAX_TRACE_BYTES;
  7288. + else dataAccumulate = byteCount;
  7289. +
  7290. + //insert data size at beginning of packet
  7291. + w = MemToHex((char *)&dataAccumulate, w, sizeof (dataAccumulate));
  7292. +
  7293. + byteCount -= dataAccumulate; //decrement byteCount
  7294. +
  7295. + // accumulate a full buffer
  7296. + for (cnt=0; cnt<dataAccumulate; cnt+=stepsize)
  7297. + {
  7298. + int valid;
  7299. + nm_debug_set_reg (1, np_debug_read_sample); //begin transaction
  7300. +
  7301. + //wait until data is ready
  7302. + nm_debug_get_reg (valid, np_debug_data_valid);
  7303. + while (!valid) nm_debug_get_reg(valid,np_debug_data_valid) ;
  7304. +
  7305. + nm_debug_get_reg (data, np_debug_trace_address);
  7306. + w = MemToHex ((char *)&data, w, sizeof (int));
  7307. +
  7308. + nm_debug_get_reg (data, np_debug_trace_data);
  7309. + w = MemToHex ((char *)&data, w, sizeof (int));
  7310. +
  7311. + nm_debug_get_reg (data, np_debug_trace_code);
  7312. + w = MemToHex ((char *)&data, w, sizeof (char));
  7313. + }
  7314. +
  7315. + //if one of our data packets doesn't make it, stop sending them
  7316. + //if (PutTracePacket (aBuffer,dataAccumulate+4) != 1) //+4 for size filed
  7317. + // byteCount = 0;
  7318. + /* kenw - My module can't handle the incoming data fast enough. So
  7319. + * send this one packet, and wait for another mt command.
  7320. + */
  7321. + PutTracePacket (aBuffer,dataAccumulate+4);
  7322. + byteCount = 0;
  7323. + }
  7324. + return 1;
  7325. + }
  7326. + return 0;
  7327. +}
  7328. +
  7329. +/*
  7330. +#undef stepsize
  7331. +#undef MAX_TRACE_BYTES
  7332. +*/
  7333. +
  7334. +#endif
  7335. +
  7336. +void DoGDBCommand_m(char *aBuffer)
  7337. + {
  7338. + char *w;
  7339. + int startAddr,byteCount;
  7340. +
  7341. +#if nasys_debug_core
  7342. + /* intercept some access to the dbg peripheral */
  7343. + if (Trace_Read_Intercept (aBuffer)) return;
  7344. +#endif
  7345. +
  7346. + w = aBuffer;
  7347. + w++; // past 'm'
  7348. + w = Hex2Value(w,&startAddr);
  7349. + w++; // past ','
  7350. + w = Hex2Value(w,&byteCount);
  7351. +
  7352. + if (byteCount > MAX_DATA_SIZE) byteCount = MAX_DATA_SIZE;
  7353. +
  7354. + // mA,L -- request memory
  7355. + w = aBuffer;
  7356. + w = MemToHex((char *)startAddr,w,byteCount);
  7357. + PutGDBPacket(aBuffer);
  7358. + }
  7359. +
  7360. +void DoGDBCommand_M(char *aBuffer)
  7361. + {
  7362. + char *w;
  7363. + int startAddr,byteCount;
  7364. +
  7365. + w = aBuffer;
  7366. + w++; // past 'M'
  7367. + w = Hex2Value(w,&startAddr);
  7368. + w++; // past ','
  7369. + w = Hex2Value(w,&byteCount);
  7370. + w++; // past ':'
  7371. +
  7372. + GDB_Print2("M from %x to %x",startAddr,byteCount);
  7373. +
  7374. + // MA,L:values -- write to memory
  7375. +
  7376. + w = HexToMem(w,(char *)startAddr,byteCount);
  7377. +
  7378. + // Send "OK"
  7379. + PutGDBOKPacket(aBuffer);
  7380. + }
  7381. +
  7382. +int Debug_Read_Intercept (char *aBuffer)
  7383. +{
  7384. + unsigned int data;
  7385. + int index;
  7386. + unsigned char *w;
  7387. +
  7388. + w = aBuffer;
  7389. + w++; //skip past the g
  7390. + if (*w++ == 'g') //see if this is a special "register read" packet
  7391. + {
  7392. + w = Hex2Value(w,&index); //get the index of the register to be read
  7393. +
  7394. + nm_debug_get_reg (data, index);
  7395. +
  7396. + //assemble the output packet
  7397. + w=aBuffer; //reset w to beginning of buffer
  7398. + w = MemToHex((char *)&data, w, sizeof (data));
  7399. + *w++ = 0;
  7400. +
  7401. + //now send it
  7402. + PutTracePacket (aBuffer,sizeof (data) * 2);
  7403. +
  7404. + return 1;
  7405. + }
  7406. + return 0;
  7407. +}
  7408. +
  7409. +// Return the values of all the registers
  7410. +void DoGDBCommand_g(NiosGDBGlobals *g)
  7411. + {
  7412. + char *w;
  7413. +
  7414. + if (Debug_Read_Intercept (g->textBuffer)) return;
  7415. +
  7416. + w = g->textBuffer;
  7417. +
  7418. + w = MemToHex((char *)(&g->registers),w,sizeof(g->registers));
  7419. + PutGDBPacket(g->textBuffer);
  7420. + GDB_Print2("Sent Registers",0,0);
  7421. + }
  7422. +
  7423. +int Debug_Write_Intercept (char *aBuffer)
  7424. +{
  7425. + unsigned int data;
  7426. + int index;
  7427. + unsigned char *w;
  7428. +
  7429. + w = aBuffer;
  7430. + w++; //skip past the g
  7431. + if (*w++ == 'g') //see if this is a special "register read" packet
  7432. + {
  7433. + w = Hex2Value(w,&index); //get the index of the register to be written
  7434. + w++; // past ','
  7435. + w = Hex2Value(w,&data);
  7436. +
  7437. + nm_debug_set_reg (data, index);
  7438. +
  7439. + //now send it
  7440. + // Send "OK"
  7441. + PutGDBOKPacket(aBuffer);
  7442. +
  7443. + return 1;
  7444. + }
  7445. + return 0;
  7446. +}
  7447. +
  7448. +void DoGDBCommand_G(NiosGDBGlobals *g)
  7449. + {
  7450. + char *w;
  7451. +
  7452. + if (Debug_Write_Intercept (g->textBuffer)) return;
  7453. +
  7454. + w = g->textBuffer;
  7455. + w++; // skip past 'G'
  7456. + w = HexToMem(w,(char *)(&g->registers), sizeof(g->registers) );
  7457. +
  7458. + // Send "OK"
  7459. + PutGDBOKPacket(g->textBuffer);
  7460. +
  7461. + GDB_Print2("Received Registers",0,0);
  7462. + }
  7463. +
  7464. +// Return last signal value
  7465. +void DoGDBCommand_qm(NiosGDBGlobals *g)
  7466. + {
  7467. + char *w;
  7468. +
  7469. + w = g->textBuffer;
  7470. +
  7471. + *w++ = 'S';
  7472. + *w++ = '2';
  7473. + *w++ = '3'; // make up a signal for now...
  7474. + *w++ = 0;
  7475. + PutGDBPacket(g->textBuffer);
  7476. + }
  7477. +
  7478. +void DoGDBCommand_q(NiosGDBGlobals *g)
  7479. +{
  7480. +#ifdef na_ssram_detect_in
  7481. + short int* ssram_exists;
  7482. +#endif
  7483. + char *w;
  7484. + w = g->textBuffer;
  7485. +
  7486. + w++; /* skip past the q */
  7487. + switch (*w) {
  7488. + case ('A'):
  7489. + w = g->textBuffer;
  7490. +
  7491. + /* handle intialization information */
  7492. + /* is nios_ocd available? */
  7493. +#ifdef nasys_debug_core
  7494. + *w++ = nasys_debug_core + '0';
  7495. +#else
  7496. + *w++ = '0';
  7497. +#endif
  7498. + *w++ = ',';
  7499. +
  7500. + /* determine if the SSRAM debugger board is
  7501. + * physically present */
  7502. +#ifdef na_ssram_detect_in
  7503. + ssram_exists = (short int*) na_ssram_detect_in;
  7504. + *w++ = !(*ssram_exists) + '0';
  7505. +#else
  7506. + *w++ = '0';
  7507. +#endif
  7508. + *w++ = ',';
  7509. +
  7510. + /* print out the max size of a trace packet */
  7511. +#if nasys_debug_core
  7512. + sprintf (w, "%04x", MAX_TRACE_BYTES);
  7513. +#else
  7514. + sprintf (w, "0000");
  7515. +#endif
  7516. +
  7517. + break;
  7518. + case ('B'):
  7519. + w = g->textBuffer;
  7520. +
  7521. + /* returns 1 if it was an OCD interrupt
  7522. + * returns 0 if it was software breakpoint */
  7523. + if (gdb.trapNumber == nasys_debug_core_irq) {
  7524. + *w++ = '1';
  7525. + } else {
  7526. + *w++ = '0';
  7527. + }
  7528. +
  7529. + *w++ = 0;
  7530. + break;
  7531. + default:
  7532. + w = g->textBuffer;
  7533. +
  7534. + *w = 0;
  7535. + break;
  7536. + }
  7537. +
  7538. + PutGDBPacket(g->textBuffer);
  7539. +}
  7540. +
  7541. +
  7542. +void GDBInsertBreakpoint(NiosGDBGlobals *g,short *address)
  7543. + {
  7544. + NiosGDBBreakpoint *b;
  7545. +
  7546. + GDB_Print2("breakpoint 0x%x",(int)address,0);
  7547. + if(g->breakpointCount < kMaximumBreakpoints)
  7548. + {
  7549. + b = &g->breakpoint[g->breakpointCount++];
  7550. + b->address = address;
  7551. + b->oldContents = *b->address;
  7552. + *b->address = 0x7904;
  7553. + }
  7554. + }
  7555. +
  7556. +void GDBRemoveBreakpoints(NiosGDBGlobals *g)
  7557. + {
  7558. + NiosGDBBreakpoint *b;
  7559. + int i;
  7560. +
  7561. + for(i = 0; i < g->breakpointCount; i++)
  7562. + {
  7563. + b = &g->breakpoint[i];
  7564. + *b->address = b->oldContents;
  7565. + b->address = 0;
  7566. + }
  7567. +
  7568. + g->breakpointCount = 0;
  7569. + }
  7570. +
  7571. +int NiosInstructionIsTrap5(unsigned short instruction)
  7572. + {
  7573. + return instruction == 0x7905;
  7574. + }
  7575. +
  7576. +int NiosInstructionIsPrefix(unsigned short instruction)
  7577. + {
  7578. + return (instruction >> 11) == 0x13;
  7579. + }
  7580. +
  7581. +int NiosInstructionIsSkip(unsigned short instruction)
  7582. + {
  7583. + int op6;
  7584. + int op11;
  7585. +
  7586. + op6 = (instruction >> 10);
  7587. + op11 = (instruction >> 5);
  7588. +
  7589. + return (op6 == 0x14 // SKP0
  7590. + || op6 == 0x15 // SKP1
  7591. + || op11 == 0x3f6 // SKPRz
  7592. + || op11 == 0x3f7 // SKPS
  7593. + || op11 == 0x3fa); // SKPRnz
  7594. + }
  7595. +
  7596. +int NiosInstructionIsBranch(unsigned short instruction,short *pc,short **branchTargetOut)
  7597. + {
  7598. + int op4;
  7599. + int op7;
  7600. + int op10;
  7601. + short *branchTarget = 0;
  7602. + int result = 0;
  7603. +
  7604. + op4 = (instruction >> 12);
  7605. + op7 = (instruction >> 9);
  7606. + op10 = (instruction >> 6);
  7607. +
  7608. + if(op4 == 0x08) // BR, BSR
  7609. + {
  7610. + int offset;
  7611. +
  7612. + result = 1;
  7613. + offset = instruction & 0x07ff;
  7614. + if(offset & 0x400) // sign extend
  7615. + offset |= 0xffffF800;
  7616. + branchTarget = pc + offset + 1; // short * gets x2 scaling automatically
  7617. + }
  7618. + else if(op10 == 0x1ff) // JMP, CALL
  7619. + {
  7620. + result = 1;
  7621. + branchTarget = (short *)(gdb.registers.r[instruction & 31] * 2);
  7622. + }
  7623. + else if(op7 == 0x3d) // JMPC, CALLC
  7624. + {
  7625. + result = 1;
  7626. + branchTarget = pc + 1 + (instruction & 0x0ffff);
  7627. +#ifdef __nios32__
  7628. + branchTarget = (short *)((int)branchTarget & 0xffffFFFc); // align 32...
  7629. +#else
  7630. + branchTarget = (short *)((int)branchTarget & 0xFFFe); // align 16...
  7631. +#endif
  7632. + branchTarget = (short *)(*(int *)branchTarget);
  7633. + }
  7634. +
  7635. + if(branchTargetOut)
  7636. + *branchTargetOut = branchTarget;
  7637. +
  7638. + return result;
  7639. + }
  7640. +
  7641. +// -------------------------
  7642. +// Step at address
  7643. +//
  7644. +// "stepping" involves inserting a
  7645. +// breakpoint at some reasonable
  7646. +// spot later than the current program
  7647. +// counter
  7648. +//
  7649. +// On the Nios processor, this is
  7650. +// nontrivial. For example, we should
  7651. +// not break up a PFX instruction.
  7652. +
  7653. +void DoGDBCommand_s(NiosGDBGlobals *g)
  7654. + {
  7655. + char *w;
  7656. + int x;
  7657. + short *pc;
  7658. + short *branchTarget;
  7659. + unsigned short instruction;
  7660. + int stepType;
  7661. +
  7662. + /*
  7663. + * First, if there's an argument to the packet,
  7664. + * set the new program-counter value
  7665. + */
  7666. +
  7667. + w = g->textBuffer;
  7668. + w++;
  7669. + if(HexCharToValue(*w) >= 0)
  7670. + {
  7671. + w = Hex2Value(w,&x);
  7672. + g->registers.pc = x;
  7673. + }
  7674. +
  7675. + /*
  7676. + * Scan forward to see what the
  7677. + * most appropriate location(s) for
  7678. + * a breakpoint will be.
  7679. + *
  7680. + * The rules are:
  7681. + * 1. If *pc == PFX, break after modified instruction.
  7682. + * 2. If *pc == BR,BSR,JMP,CALL, break at destination
  7683. + * 3. If *pc == SKIP, break right after SKIP AND after optional instruction,
  7684. + which might, of course, be prefixed.
  7685. + * 4. Anything else, just drop in the breakpoint.
  7686. + */
  7687. +
  7688. + pc = (short *)(int)g->registers.pc;
  7689. +
  7690. + instruction = *pc;
  7691. + stepType = 0;
  7692. +
  7693. + if(NiosInstructionIsPrefix(instruction))
  7694. + {
  7695. + /*
  7696. + * PFX instruction: skip til after it
  7697. + */
  7698. + while(NiosInstructionIsPrefix(instruction))
  7699. + {
  7700. + pc++;
  7701. + instruction = *pc;
  7702. + }
  7703. +
  7704. + GDBInsertBreakpoint(g,pc + 1);
  7705. + stepType = 1;
  7706. + }
  7707. + else if(NiosInstructionIsBranch(instruction,pc,&branchTarget))
  7708. + {
  7709. + GDBInsertBreakpoint(g,branchTarget);
  7710. + stepType = 2;
  7711. + }
  7712. + else if(NiosInstructionIsSkip(instruction))
  7713. + {
  7714. + short *pc2;
  7715. + stepType = 3;
  7716. +
  7717. + /*
  7718. + * Skip gets to breaks: one after the skippable instruction,
  7719. + * and the skippable instruction itself.
  7720. + *
  7721. + * Since Skips know how to skip over PFX's, we have to, too.
  7722. + */
  7723. + pc2 = pc; // the Skip instruction
  7724. + do
  7725. + {
  7726. + pc2++;
  7727. + } while(NiosInstructionIsPrefix(*pc2));
  7728. + // pc2 now points to first non-PFX after Skip
  7729. + GDBInsertBreakpoint(g,pc2+1);
  7730. + GDBInsertBreakpoint(g,pc+1);
  7731. + }
  7732. + else
  7733. + GDBInsertBreakpoint(g,pc+1); // the genericest case
  7734. +
  7735. + GDB_Print2("Program Steppingat 0x%x (%d)",g->registers.pc,stepType);
  7736. + }
  7737. +
  7738. +// -----------------------------
  7739. +// Continue at address
  7740. +
  7741. +void DoGDBCommand_c(NiosGDBGlobals *g)
  7742. + {
  7743. + char *w;
  7744. + int x;
  7745. + w = g->textBuffer;
  7746. +
  7747. + w++; // past command
  7748. +
  7749. + // Anything in the packet? if so,
  7750. + // use it to set the PC value
  7751. +
  7752. + if(HexCharToValue(*w) >= 0)
  7753. + {
  7754. + w = Hex2Value(w,&x);
  7755. + g->registers.pc = x;
  7756. + }
  7757. +
  7758. + GDB_Print2("Program Running at 0x%x",g->registers.pc,0);
  7759. + }
  7760. +
  7761. +// ----------------------
  7762. +// Kill
  7763. +
  7764. +void DoGDBCommand_k(NiosGDBGlobals *g)
  7765. + {
  7766. + return;
  7767. + }
  7768. +
  7769. +
  7770. +/*
  7771. + * If we've somehow skidded
  7772. + * to a stop just after a PFX instruction
  7773. + * back up the program counter by one.
  7774. + *
  7775. + * That way, we can't end up with an accidentally-unprefixed
  7776. + * instruction.
  7777. + *
  7778. + * We do this just before we begin running
  7779. + * again, so that when the host queries our
  7780. + * registers, we report the place we actually
  7781. + * stopped.
  7782. + */
  7783. +
  7784. +void MaybeAdjustProgramCounter(NiosGDBGlobals *g)
  7785. + {
  7786. + short instruction;
  7787. + if(g->registers.pc)
  7788. + {
  7789. + instruction = *(short *)(int)(g->registers.pc - 2);
  7790. + if(NiosInstructionIsPrefix(instruction))
  7791. + g->registers.pc -= 2;
  7792. + else
  7793. + {
  7794. + // If the *current* instruction is Trap5, we must skip it!
  7795. + instruction = *(short *)(int)(g->registers.pc);
  7796. + if(NiosInstructionIsTrap5(instruction))
  7797. + g->registers.pc += 2;
  7798. + }
  7799. + }
  7800. + }
  7801. +
  7802. +/*
  7803. + * GDBMainLoop - this is the main processing loop
  7804. + * for the GDB stub.
  7805. + */
  7806. +void GDBMainLoop (void)
  7807. +{
  7808. + while(1)
  7809. + {
  7810. + if (GetGDBPacket(gdb.textBuffer) > 0)
  7811. + {
  7812. +
  7813. + GDB_Print2(gdb.textBuffer,0,0);
  7814. + switch(gdb.textBuffer[0])
  7815. + {
  7816. + case 's':
  7817. + DoGDBCommand_s(&gdb);
  7818. + goto startRunning;
  7819. + break;
  7820. +
  7821. + case 'c': // continue
  7822. + DoGDBCommand_c(&gdb);
  7823. +
  7824. + // if the PC is something other than 0, it's
  7825. + // probably ok to exit and go there
  7826. +
  7827. + startRunning:
  7828. + if(gdb.registers.pc)
  7829. + {
  7830. + MaybeAdjustProgramCounter(&gdb);
  7831. + return;
  7832. + }
  7833. + break;
  7834. +
  7835. + case 'm': // memory read
  7836. + DoGDBCommand_m(gdb.textBuffer);
  7837. + break;
  7838. +
  7839. + case 'M': // memory set
  7840. + DoGDBCommand_M(gdb.textBuffer);
  7841. + break;
  7842. +
  7843. + case 'g': // registers read
  7844. + DoGDBCommand_g(&gdb);
  7845. + break;
  7846. +
  7847. + case 'G': //registers set
  7848. + DoGDBCommand_G(&gdb);
  7849. + break;
  7850. +
  7851. + case 'k': //kill process
  7852. + DoGDBCommand_k(&gdb);
  7853. + break;
  7854. +
  7855. + case '?': // last exception value
  7856. + DoGDBCommand_qm(&gdb);
  7857. + break;
  7858. +
  7859. + case 'q':
  7860. + DoGDBCommand_q(&gdb);
  7861. + break;
  7862. +
  7863. + default: // return empty packet, means "yeah yeah".
  7864. + gdb.textBuffer[0] = 0;
  7865. + PutGDBPacket(gdb.textBuffer);
  7866. + break;
  7867. + }
  7868. + }
  7869. + }
  7870. +
  7871. +}
  7872. +
  7873. +// ----------main------------
  7874. +void GDBMain(void)
  7875. +{
  7876. + int i;
  7877. +
  7878. + for(i = 0; i < kTextBufferSize; i++)
  7879. + gdb.textBuffer[i] = i;
  7880. +
  7881. + GDBRemoveBreakpoints(&gdb);
  7882. +
  7883. +#ifdef __KERNEL__
  7884. +/*
  7885. + * Inform the user that they need to add the symbol file for the application
  7886. + * that is just starting up. Display the .text .data .bss regions.
  7887. + */
  7888. + if (gdb.trapNumber == 5) {
  7889. + extern struct task_struct *_current_task;
  7890. + sprintf(gdb.textBuffer,
  7891. + "\r\n\nGDB: trap 5 at 0x%08lX", gdb.registers.pc);
  7892. + puts(gdb.textBuffer);
  7893. + if (_current_task) {
  7894. + if ( _current_task->mm->start_code > _etext )
  7895. + sprintf(gdb.textBuffer,
  7896. + "\r\nGDB: Enter the following command in the nios-elf-gdb Console Window:"
  7897. + "\r\nGDB: add-symbol-file %s.abself 0x%08lX 0x%08lX 0x%08lX\r\n\n",
  7898. + _current_task->comm,
  7899. + (unsigned long)_current_task->mm->start_code,
  7900. + (unsigned long)_current_task->mm->start_data,
  7901. + (unsigned long)_current_task->mm->end_data );
  7902. + else
  7903. + sprintf(gdb.textBuffer,
  7904. + ", kernel process: %s\r\n", _current_task->comm );
  7905. + } else
  7906. + sprintf(gdb.textBuffer,
  7907. + ", kernel process unknown\r\n" );
  7908. + puts(gdb.textBuffer);
  7909. + }
  7910. +#endif
  7911. +
  7912. + // Send trapnumber for breakpoint encountered. No other signals.
  7913. +
  7914. + gdb.textBuffer[0] = 'S';
  7915. + gdb.textBuffer[1] = '0';
  7916. +
  7917. +#if nasys_debug_core
  7918. + if (gdb.trapNumber == nasys_debug_core_irq)
  7919. + {
  7920. + /* gdb.textBuffer[2] = '8'; */
  7921. + gdb.textBuffer[2] = '5';
  7922. + }
  7923. + else
  7924. + {
  7925. + gdb.textBuffer[2] = '5';
  7926. + }
  7927. +#else
  7928. + gdb.textBuffer[2] = '5';
  7929. +#endif
  7930. + gdb.textBuffer[3] = 0;
  7931. + PutGDBPacket(gdb.textBuffer);
  7932. +
  7933. + GDB_Print2("Trap %2d At 0x%x",
  7934. + gdb.trapNumber,gdb.registers.pc);
  7935. +// printf ("Trap %d at 0x%x\n",gdb.trapNumber,gdb.registers.pc);
  7936. +// for (i=0;i<32;i++) printf (" register[%d] = 0x%x\n",i,gdb.registers.r[i]);
  7937. +
  7938. + GDBMainLoop ();
  7939. +}
  7940. +
  7941. +// +----------------------------------
  7942. +// | gdb_eth_proc -- gets called for udp packets
  7943. +// | from the host bound for gdb stub
  7944. +#ifdef ETHER_DEBUG
  7945. +#ifdef ethernet_exists
  7946. +int gdb_eth_proc(int plug_handle,
  7947. + void *context,
  7948. + ns_plugs_packet *p,
  7949. + void *payload,
  7950. + int payload_length)
  7951. +{
  7952. + int i;
  7953. + char *buf = (char *)payload;
  7954. + // if this is a stop request, set a flag to stop after nr_plugs_idle
  7955. + // leave it up to the host to prevent stops from being sent while stub is running???
  7956. +
  7957. + if (*buf == 3) gdb.stop = 1;
  7958. +
  7959. + // if we're waiting for an ack, check that here
  7960. + if (gdb.ACKstatus == ne_gdb_ack_waiting)
  7961. + {
  7962. + if (buf[0] == '+')
  7963. + {
  7964. + gdb.ACKstatus = ne_gdb_ack_acked;
  7965. + return 0;
  7966. + }
  7967. + else if (buf[0] == '-')
  7968. + {
  7969. + gdb.ACKstatus = ne_gdb_ack_nacked;
  7970. + return 0;
  7971. + }
  7972. + }
  7973. + strcpy (gdb.textBuffer, buf); //all commands should be zero terminated strings
  7974. +
  7975. + gdb.textBuffer[payload_length] = 0; //terminate string
  7976. +
  7977. + gdb.host_ip_address=((ns_plugs_ip_packet *)(p[ne_plugs_ip].header))->source_ip_address;
  7978. + gdb.host_port_number=((ns_plugs_udp_packet *)(p[ne_plugs_udp].header))->source_port;
  7979. +
  7980. + return 0;
  7981. +}
  7982. +
  7983. +int nr_dbg_plugs_idle (void)
  7984. +{
  7985. + int result;
  7986. +
  7987. + result = nr_plugs_idle ();
  7988. + if (gdb.stop)
  7989. + {
  7990. + gdb.stop = 0;
  7991. +//;dgt2;tmp; asm ("TRAP #5");
  7992. + }
  7993. + return result;
  7994. +}
  7995. +#endif
  7996. +#endif
  7997. +
  7998. +
  7999. +/*
  8000. + * int main(void)
  8001. + *
  8002. + * All we really do here is install our trap # 3,
  8003. + * and call it once, so that we're living down in
  8004. + * the GDBMain, trap handler.
  8005. + */
  8006. +
  8007. +extern int StubBreakpointHandler;
  8008. +extern int StubHarmlessHandler;
  8009. +#if nasys_debug_core
  8010. +extern int StubHWBreakpointHandler;
  8011. +#endif
  8012. +#ifdef nasys_debug_uart
  8013. +extern int StubUartHandler;
  8014. +#endif
  8015. +
  8016. +void gdb_local_install(int active)
  8017. +{
  8018. + unsigned int *vectorTable;
  8019. + unsigned int stubBreakpointHandler;
  8020. + unsigned int stubHarmlessHandler;
  8021. +#if nasys_debug_core
  8022. + unsigned int stubHWBreakpointHandler;
  8023. +#endif
  8024. +
  8025. + gdb.breakpointCount = 0;
  8026. + gdb.textBuffer[0] = 0;
  8027. +
  8028. + vectorTable = (int *)nasys_vector_table;
  8029. + stubBreakpointHandler = ( (unsigned int)(&StubBreakpointHandler) ) >> 1;
  8030. + stubHarmlessHandler = ( (unsigned int)(&StubHarmlessHandler) ) >> 1;
  8031. +#if nasys_debug_core
  8032. + stubHWBreakpointHandler = ( (unsigned int)(&StubHWBreakpointHandler) ) >> 1;
  8033. +#endif
  8034. +
  8035. + /*
  8036. + * Breakpoint & single step both go here
  8037. + */
  8038. + vectorTable[na_BreakpointTrap] = stubBreakpointHandler;
  8039. + vectorTable[na_SingleStepTrap] = stubBreakpointHandler;
  8040. + vectorTable[na_StartGDBTrap] = active ? stubBreakpointHandler : stubHarmlessHandler;
  8041. + /*
  8042. + * If it exists, Hardware Breakpoint has a different entry point
  8043. + */
  8044. +#if nasys_debug_core
  8045. + vectorTable[na_debug_peripheral_irq] = stubHWBreakpointHandler;
  8046. +#endif
  8047. +
  8048. +#ifndef __KERNEL__
  8049. +#ifdef nasys_debug_uart
  8050. + if (gdb.comlink == ne_gdb_serial)
  8051. + {
  8052. + np_uart *uart = (np_uart *)nasys_debug_uart;
  8053. + unsigned int stubUartHandler = ((unsigned int)(&StubUartHandler)) >> 1;
  8054. +
  8055. + vectorTable[nasys_debug_uart_irq] = stubUartHandler; //set Uart int vector
  8056. + uart->np_uartcontrol = np_uartcontrol_irrdy_mask; //enable Rx intr
  8057. + }
  8058. +#endif
  8059. +#endif
  8060. +}
  8061. +
  8062. +void nios_gdb_install(int active)
  8063. +{
  8064. + gdb.comlink = ne_gdb_serial;
  8065. + gdb_local_install (active);
  8066. +}
  8067. +
  8068. +#ifdef ETHER_DEBUG
  8069. +#ifdef ethernet_exists
  8070. +void nios_gdb_install_ethernet (int active)
  8071. +{
  8072. + int result;
  8073. + host_16 host_port = GDB_ETH_PORT;
  8074. +
  8075. + gdb.comlink = ne_gdb_ethernet;
  8076. + gdb_local_install (active);
  8077. +
  8078. + result = nr_plugs_create (&gdb.gdb_eth_plug, ne_plugs_udp, host_port, gdb_eth_proc, 0, 0);
  8079. + //if unabled to open ethernet plug, switch back to default serial interface
  8080. + if (result)
  8081. + {
  8082. + printf ("nr_plugs_create failed %d\n",result);
  8083. + gdb.comlink = ne_gdb_serial;
  8084. + return;
  8085. + }
  8086. + result = nr_plugs_connect (gdb.gdb_eth_plug, 0, -1, -1);
  8087. + if (result)
  8088. + {
  8089. + printf ("nr_plugs_connect fialed %d\n",result);
  8090. + gdb.comlink = ne_gdb_serial;
  8091. + return;
  8092. + }
  8093. +}
  8094. +#endif
  8095. +#endif
  8096. +
  8097. +#ifdef nios_gdb_breakpoint
  8098. + #undef nios_gdb_breakpoint
  8099. +#endif
  8100. +
  8101. +void nios_gdb_breakpoint(void)
  8102. + {
  8103. + /*
  8104. + * If you arrived here, you didn't include
  8105. + * the file "nios_peripherals.h", which
  8106. + * defines nios_gdb_breakpoint as a
  8107. + * macro that expands to TRAP 5.
  8108. + *
  8109. + * (No problem, you can step out
  8110. + * of this routine.)
  8111. + */
  8112. +//;dgt2;tmp; asm("TRAP 5");
  8113. + }
  8114. +
  8115. +// end of file
  8116. diff --git a/arch/nios2nommu/kernel/nios_gdb_stub.h b/arch/nios2nommu/kernel/nios_gdb_stub.h
  8117. new file mode 100644
  8118. index 0000000..3900109
  8119. --- /dev/null
  8120. +++ b/arch/nios2nommu/kernel/nios_gdb_stub.h
  8121. @@ -0,0 +1,105 @@
  8122. +// file: nios_gdb_stub.h
  8123. +// Author: Altera Santa Cruz \ 2000
  8124. +//
  8125. +// You can modify this header file to
  8126. +// enable some features useful for
  8127. +// debugging the debugger. They're
  8128. +// good features also to just show
  8129. +// signs of life on your Nios board.
  8130. +// But they consume valuable peripherals!
  8131. +//
  8132. +// The 'GDB_DEBUG_PRINT' option ties
  8133. +// up the LCD living on the 5v port,
  8134. +// showing useful internals of the stub.
  8135. +//
  8136. +// dvb@altera.com
  8137. +//
  8138. +
  8139. +#ifdef ETHER_DEBUG
  8140. +#ifdef na_enet
  8141. +#define ethernet_exists
  8142. +#endif
  8143. +#endif
  8144. +
  8145. +#ifdef ETHER_DEBUG
  8146. +#ifdef ethernet_exists
  8147. +#include "plugs.h"
  8148. +#endif
  8149. +#endif
  8150. +
  8151. +#define MAX_DATA_SIZE 650
  8152. +#define kTextBufferSize ((2*MAX_DATA_SIZE)+4)
  8153. +#define kMaximumBreakpoints 4
  8154. +#define GDB_ETH_PORT 7070
  8155. +#define GDB_WHOLE_PACKET 0
  8156. +#define GDB_SKIP_FIRST 1
  8157. +#define GDB_RETRY_CNT 3
  8158. +
  8159. +/*
  8160. + * This register structure must match
  8161. + * its counterpart in the GDB host, since
  8162. + * it is blasted across in byte notation.
  8163. + */
  8164. +typedef struct
  8165. + {
  8166. + int r[32];
  8167. + long pc;
  8168. + short ctl0;
  8169. + short ctl1;
  8170. + short ctl2;
  8171. + short ctl3;
  8172. + } NiosGDBRegisters;
  8173. +
  8174. +typedef struct
  8175. + {
  8176. + short *address;
  8177. + short oldContents;
  8178. + } NiosGDBBreakpoint;
  8179. +
  8180. +typedef struct
  8181. + {
  8182. + NiosGDBRegisters registers;
  8183. + int trapNumber; // stashed by ISR, to distinguish types
  8184. + char textBuffer[kTextBufferSize];
  8185. + int breakpointCount; // breakpoints used for stepping
  8186. + int comlink;
  8187. + int stop;
  8188. + int gdb_eth_plug;
  8189. + NiosGDBBreakpoint breakpoint[kMaximumBreakpoints];
  8190. +#ifdef ETHER_DEBUG
  8191. +#ifdef ethernet_exists
  8192. + volatile int ACKstatus;
  8193. + net_32 host_ip_address;
  8194. + net_16 host_port_number;
  8195. +#endif
  8196. +#endif
  8197. + } NiosGDBGlobals;
  8198. +
  8199. +#ifdef ETHER_DEBUG
  8200. +#ifdef ethernet_exists
  8201. +enum
  8202. +{
  8203. + ne_gdb_ack_notwaiting,
  8204. + ne_gdb_ack_waiting,
  8205. + ne_gdb_ack_acked,
  8206. + ne_gdb_ack_nacked
  8207. +};
  8208. +#endif
  8209. +#endif
  8210. +
  8211. +enum
  8212. +{
  8213. + ne_gdb_serial,
  8214. + ne_gdb_ethernet
  8215. +};
  8216. +
  8217. +#ifndef GDB_DEBUG_PRINT
  8218. + #define GDB_DEBUG_PRINT 0
  8219. +#endif
  8220. +
  8221. +void GDB_Main(void); // initialize gdb and begin.
  8222. +
  8223. +char GDBGetChar(void);
  8224. +void GDBPutChar(char c);
  8225. +void GDB_Print2(char *s,int v1,int v2);
  8226. +
  8227. diff --git a/arch/nios2nommu/kernel/nios_gdb_stub_io.c b/arch/nios2nommu/kernel/nios_gdb_stub_io.c
  8228. new file mode 100644
  8229. index 0000000..e0d8f82
  8230. --- /dev/null
  8231. +++ b/arch/nios2nommu/kernel/nios_gdb_stub_io.c
  8232. @@ -0,0 +1,39 @@
  8233. +// Modified for uClinux - Vic - Apr 2002
  8234. +// From:
  8235. +
  8236. +// file: nios_gdb_stub_IO.c
  8237. +//
  8238. +// Single character I/O for Nios GDB Stub
  8239. +
  8240. +#ifndef __KERNEL__
  8241. +#include "nios.h"
  8242. +#else
  8243. +#include <asm/nios.h>
  8244. +#endif
  8245. +
  8246. +#include "nios_gdb_stub.h"
  8247. +
  8248. +#ifdef nasys_debug_uart
  8249. + #define GDB_UART nasys_debug_uart
  8250. +#endif
  8251. +
  8252. +char GDBGetChar(void)
  8253. +{
  8254. + char c = 0;
  8255. +
  8256. +#ifdef GDB_UART
  8257. + while( (c = (char)nr_uart_rxchar(GDB_UART)) < 0 )
  8258. + ;
  8259. +#endif
  8260. +
  8261. + return c;
  8262. +}
  8263. +
  8264. +void GDBPutChar(char c)
  8265. +{
  8266. +#ifdef GDB_UART
  8267. + nr_uart_txchar(c, GDB_UART);
  8268. +#endif
  8269. +}
  8270. +
  8271. +// End of file
  8272. diff --git a/arch/nios2nommu/kernel/nios_gdb_stub_isr.S b/arch/nios2nommu/kernel/nios_gdb_stub_isr.S
  8273. new file mode 100644
  8274. index 0000000..c4af09a
  8275. --- /dev/null
  8276. +++ b/arch/nios2nommu/kernel/nios_gdb_stub_isr.S
  8277. @@ -0,0 +1,99 @@
  8278. +/*--------------------------------------------------------------------
  8279. + *
  8280. + * Assembly language portions of Nios GDB Stub
  8281. + *
  8282. + * arch\nios2nommu\kernel\switch.S
  8283. + *
  8284. + * Derived from Nios1
  8285. + *
  8286. + * Copyright (C) 2004 Microtronix Datacom Ltd
  8287. + *
  8288. + * This program is free software; you can redistribute it and/or modify
  8289. + * it under the terms of the GNU General Public License as published by
  8290. + * the Free Software Foundation; either version 2 of the License, or
  8291. + * (at your option) any later version.
  8292. + *
  8293. + * This program is distributed in the hope that it will be useful,
  8294. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8295. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8296. + * GNU General Public License for more details.
  8297. + *
  8298. + * Modified for uClinux - Vic - Apr 2002
  8299. + * Jan/20/2004 dgt NiosII
  8300. + *
  8301. + ---------------------------------------------------------------------*/
  8302. +
  8303. +
  8304. +//;dgt2;tmp;
  8305. +
  8306. + .equ ethernet_exists, 1
  8307. +
  8308. +
  8309. + .equ gdbRegistersGeneral,0
  8310. + .equ gdbRegistersPC,32
  8311. + .equ gdbRegistersCtl0Ctl1,33
  8312. + .equ gdbRegistersCtl2Ctl3,34
  8313. + .equ gdbTrapNumber,35 ; ISR can report trap number here
  8314. +
  8315. +
  8316. + .text
  8317. +
  8318. + .global StubBreakpointHandler
  8319. + .global StubHarmlessHandler
  8320. + .global StubButtonHandler
  8321. + .global StubHWBreakpointHandler
  8322. + .global GDBMain
  8323. +
  8324. + .comm _gdb_stub_stack,1024,4 ; Local stack, statically allocated.
  8325. + .equ gdbStubStacktop,_gdb_stub_stack+992
  8326. +
  8327. +
  8328. +StubHarmlessHandler:
  8329. +//;dgt2;tmp
  8330. +
  8331. + .equ gdbBreakChar,0x3
  8332. + .global StubUartHandler
  8333. +
  8334. +StubUartHandler:
  8335. +//;dgt2;tmp
  8336. +
  8337. +StubUartRx:
  8338. +//;dgt2;tmp
  8339. +
  8340. +StubHWBreakpointHandler:
  8341. +//;dgt2;tmp
  8342. +
  8343. +StubBreakpointHandler:
  8344. +//;dgt2;tmp
  8345. +
  8346. +#ifdef __KERNEL__
  8347. +;----------------------------------------
  8348. +; Name: nr_uart_rxchar
  8349. +; Description: Read character if available
  8350. +; Input: %o0: UART base to use
  8351. +; Output: %o0 = character 0-0xff, or -1 if none present
  8352. +; Side Effects: %g0 & %g1 altered
  8353. +; CWP Depth: 0
  8354. +;
  8355. +
  8356. + .global nr_uart_rxchar
  8357. +nr_uart_rxchar:
  8358. +//;dgt2;tmp
  8359. +
  8360. +
  8361. +;----------------------------------------
  8362. +; Name: nr_uart_txchar
  8363. +; Description: Send a single byte out the UART
  8364. +; Input: %o0 = A character
  8365. +; %o1 = the UART to use, 0 for default
  8366. +; Output: none
  8367. +; Side Effects: %g0 & %g1 altered, CPU waits for UART
  8368. +; CWP Depth: 0
  8369. +;
  8370. +
  8371. +; nr_uart_txchar
  8372. + .global nr_uart_txchar
  8373. +nr_uart_txchar:
  8374. +//;dgt2;tmp
  8375. +
  8376. +#endif
  8377. diff --git a/arch/nios2nommu/kernel/pio.c b/arch/nios2nommu/kernel/pio.c
  8378. new file mode 100644
  8379. index 0000000..013a64b
  8380. --- /dev/null
  8381. +++ b/arch/nios2nommu/kernel/pio.c
  8382. @@ -0,0 +1,154 @@
  8383. +/*
  8384. + * linux/arch/nios2nommu/kernel/pio.c
  8385. + * "Example" drivers(LEDs and 7 seg displays) of the PIO interface
  8386. + * on Nios Development Kit.
  8387. + *
  8388. + * Copyright (C) 2004 Microtronix Datacom Ltd
  8389. + *
  8390. + * This program is free software; you can redistribute it and/or
  8391. + * modify it under the terms of the GNU General Public License
  8392. + * as published by the Free Software Foundation; either version
  8393. + * 2 of the License, or (at your option) any later version.
  8394. + *
  8395. + * Written by Wentao Xu <wentao@microtronix.com>
  8396. + */
  8397. +
  8398. +#include <linux/module.h>
  8399. +#include <linux/types.h>
  8400. +#include <linux/kernel.h>
  8401. +#include <linux/delay.h>
  8402. +#include <linux/timer.h>
  8403. +#include <linux/init.h>
  8404. +#include <linux/interrupt.h>
  8405. +#include <linux/ioport.h>
  8406. +#include <asm/io.h>
  8407. +
  8408. +MODULE_AUTHOR("Microtronix Datacom Ltd.");
  8409. +MODULE_DESCRIPTION("Drivers of PIO devices (LEDs and 7 seg) on Nios kit");
  8410. +MODULE_LICENSE("GPL");
  8411. +
  8412. +#undef CONFIG_PIO_SEG
  8413. +#ifdef na_seven_seg_pio
  8414. +#define CONFIG_PIO_SEG
  8415. +#define PIO_SEG_IO na_seven_seg_pio
  8416. +#endif
  8417. +
  8418. +#undef CONFIG_PIO_LED
  8419. +#ifdef na_led_pio
  8420. +#define CONFIG_PIO_LED
  8421. +#define PIO_LED_IO na_led_pio
  8422. +#endif
  8423. +
  8424. +#define PDEBUG printk
  8425. +
  8426. +/* routines for 7-segment hex display */
  8427. +#ifdef CONFIG_PIO_SEG
  8428. +static unsigned char _hex_digits_data[] = {
  8429. + 0x01, 0x4f, 0x12, 0x06, 0x4c, /* 0-4 */
  8430. + 0x24, 0x20, 0x0f, 0x00, 0x04, /* 5-9 */
  8431. + 0x08, 0x60, 0x72, 0x42, 0x30, /* a-e */
  8432. + 0x38 /* f */
  8433. +};
  8434. +
  8435. +void pio_seg_write(int value)
  8436. +{
  8437. + int led_value;
  8438. +
  8439. + /* Left Hand Digit, goes to PIO bits 8-14 */
  8440. + led_value = _hex_digits_data[value & 0xF];
  8441. + led_value |= (_hex_digits_data[(value >> 4) & 0xF]) << 8;
  8442. +
  8443. + outl(led_value, &(PIO_SEG_IO->np_piodata));
  8444. +}
  8445. +
  8446. +static void __init pio_seg_init(void)
  8447. +{
  8448. + pio_seg_write(0);
  8449. +}
  8450. +#endif
  8451. +
  8452. +
  8453. +/* routines for LED display */
  8454. +#ifdef CONFIG_PIO_LED
  8455. +void pio_led_write(int value)
  8456. +{
  8457. + np_pio *pio=(np_pio *)(PIO_LED_IO);
  8458. +
  8459. + //outl(-1, &pio->np_piodirection);
  8460. + outl(value, &pio->np_piodata);
  8461. +}
  8462. +
  8463. +static void __init pio_led_init(void)
  8464. +{
  8465. + np_pio *pio=(np_pio *)(PIO_LED_IO);
  8466. +
  8467. + outl(-1, &pio->np_piodirection);
  8468. + outl(0x0, &pio->np_piodata);
  8469. +}
  8470. +#endif
  8471. +
  8472. +/* timing routines */
  8473. +#if defined(CONFIG_PIO_SEG) || defined(CONFIG_PIO_LED)
  8474. +static struct timer_list display_timer;
  8475. +static int restart_timer=1;
  8476. +static int timer_counter=0;
  8477. +static void display_timeout(unsigned long unused)
  8478. +{
  8479. +#ifdef CONFIG_PIO_SEG
  8480. + pio_seg_write(++timer_counter);
  8481. +#endif
  8482. +
  8483. +#ifdef CONFIG_PIO_LED
  8484. + pio_led_write(timer_counter);
  8485. +#endif
  8486. + if (restart_timer) {
  8487. + display_timer.expires = jiffies + HZ; /* one second */
  8488. + add_timer(&display_timer);
  8489. + }
  8490. +}
  8491. +#endif
  8492. +
  8493. +int __init pio_init(void)
  8494. +{
  8495. +#ifdef CONFIG_PIO_SEG
  8496. + request_mem_region((unsigned long)PIO_SEG_IO, sizeof(np_pio), "pio_7seg");
  8497. + pio_seg_init();
  8498. +#endif
  8499. +
  8500. +#ifdef CONFIG_PIO_LED
  8501. + request_mem_region((unsigned long)PIO_LED_IO, sizeof(np_pio), "pio_led");
  8502. + pio_led_init();
  8503. +#endif
  8504. +
  8505. +#if defined(CONFIG_PIO_SEG) || defined(CONFIG_PIO_LED)
  8506. + /* init timer */
  8507. + init_timer(&display_timer);
  8508. + display_timer.function = display_timeout;
  8509. + display_timer.data = 0;
  8510. + display_timer.expires = jiffies + HZ * 10; /* 10 seconds */
  8511. + add_timer(&display_timer);
  8512. +#endif
  8513. +
  8514. + return 0;
  8515. +}
  8516. +
  8517. +static void __exit pio_exit(void)
  8518. +{
  8519. +#ifdef CONFIG_PIO_SEG
  8520. + pio_seg_write(0);
  8521. + release_mem_region((unsigned long)PIO_SEG_IO, sizeof(np_pio));
  8522. +#endif
  8523. +
  8524. +#ifdef CONFIG_PIO_LED
  8525. + pio_led_write(0);
  8526. + release_mem_region((unsigned long)PIO_LED_IO, sizeof(np_pio));
  8527. +#endif
  8528. +
  8529. +#if defined(CONFIG_PIO_SEG) || defined(CONFIG_PIO_LED)
  8530. + restart_timer=0;
  8531. + del_timer_sync(&display_timer);
  8532. +#endif
  8533. +}
  8534. +module_init(pio_init);
  8535. +module_exit(pio_exit);
  8536. +
  8537. diff --git a/arch/nios2nommu/kernel/process.c b/arch/nios2nommu/kernel/process.c
  8538. new file mode 100644
  8539. index 0000000..4cd353c
  8540. --- /dev/null
  8541. +++ b/arch/nios2nommu/kernel/process.c
  8542. @@ -0,0 +1,578 @@
  8543. +/*--------------------------------------------------------------------
  8544. + *
  8545. + * arch/nios2nommu/kernel/process.c
  8546. + *
  8547. + * Derived from M68knommu
  8548. + *
  8549. + * Copyright (C) 1995 Hamish Macdonald
  8550. + * Copyright (C) 2000-2002, David McCullough <davidm@snapgear.com>
  8551. + * Copyright (C) 2004 Microtronix Datacom Ltd
  8552. + *
  8553. + * This program is free software; you can redistribute it and/or modify
  8554. + * it under the terms of the GNU General Public License as published by
  8555. + * the Free Software Foundation; either version 2 of the License, or
  8556. + * (at your option) any later version.
  8557. + *
  8558. + * This program is distributed in the hope that it will be useful,
  8559. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8560. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8561. + * GNU General Public License for more details.
  8562. + *
  8563. + *
  8564. + * 68060 fixes by Jesper Skov
  8565. + * Jan/20/2004 dgt NiosII
  8566. + * rdusp() === (pt_regs *) regs->sp
  8567. + * Monday:
  8568. + * asm-nios2nommu\processor.h now bears
  8569. + * inline thread_saved_pc
  8570. + * (struct thread_struct *t)
  8571. + * Friday: it's back here now
  8572. + *
  8573. + ---------------------------------------------------------------------*/
  8574. +
  8575. +
  8576. +/*
  8577. + * This file handles the architecture-dependent parts of process handling..
  8578. + */
  8579. +
  8580. +#include <linux/module.h>
  8581. +#include <linux/errno.h>
  8582. +#include <linux/sched.h>
  8583. +#include <linux/kernel.h>
  8584. +#include <linux/mm.h>
  8585. +#include <linux/smp.h>
  8586. +#include <linux/smp_lock.h>
  8587. +#include <linux/stddef.h>
  8588. +#include <linux/unistd.h>
  8589. +#include <linux/ptrace.h>
  8590. +#include <linux/slab.h>
  8591. +#include <linux/user.h>
  8592. +#include <linux/a.out.h>
  8593. +#include <linux/interrupt.h>
  8594. +#include <linux/reboot.h>
  8595. +#include <linux/uaccess.h>
  8596. +#include <linux/fs.h>
  8597. +#include <linux/err.h>
  8598. +
  8599. +#include <asm/system.h>
  8600. +#include <asm/traps.h>
  8601. +#include <asm/setup.h>
  8602. +#include <asm/pgtable.h>
  8603. +#include <asm/cacheflush.h>
  8604. +
  8605. +asmlinkage void ret_from_fork(void);
  8606. +
  8607. +/*
  8608. + * The following aren't currently used.
  8609. + */
  8610. +void (*pm_idle)(void) = NULL;
  8611. +EXPORT_SYMBOL(pm_idle);
  8612. +
  8613. +void (*pm_power_off)(void) = NULL;
  8614. +EXPORT_SYMBOL(pm_power_off);
  8615. +
  8616. +void default_idle(void)
  8617. +{
  8618. + local_irq_disable();
  8619. + if (!need_resched()) {
  8620. + local_irq_enable();
  8621. + __asm__("nop"); // was asm sleep
  8622. + } else
  8623. + local_irq_enable();
  8624. +}
  8625. +
  8626. +void (*idle)(void) = default_idle;
  8627. +
  8628. +/*
  8629. + * The idle thread. There's no useful work to be
  8630. + * done, so just try to conserve power and have a
  8631. + * low exit latency (ie sit in a loop waiting for
  8632. + * somebody to say that they'd like to reschedule)
  8633. + */
  8634. +void cpu_idle(void)
  8635. +{
  8636. + while (1) {
  8637. + while (!need_resched())
  8638. + idle();
  8639. + preempt_enable_no_resched();
  8640. + schedule();
  8641. + preempt_disable();
  8642. + }
  8643. +}
  8644. +
  8645. +/*
  8646. + * The development boards have no way to pull a board
  8647. + * reset. Just jump to the cpu reset address and let
  8648. + * the code in head.S take care of disabling peripherals.
  8649. + */
  8650. +
  8651. +void machine_restart(char * __unused)
  8652. +{
  8653. + local_irq_disable();
  8654. + __asm__ __volatile__ (
  8655. + "jmp %0\n\t"
  8656. + :
  8657. + : "r" (CPU_RESET_ADDRESS)
  8658. + : "r4");
  8659. +}
  8660. +
  8661. +EXPORT_SYMBOL(machine_restart);
  8662. +
  8663. +void machine_halt(void)
  8664. +{
  8665. + local_irq_disable();
  8666. + for (;;);
  8667. +}
  8668. +
  8669. +EXPORT_SYMBOL(machine_halt);
  8670. +
  8671. +void exit_thread(void)
  8672. +{
  8673. +}
  8674. +
  8675. +void release_thread(struct task_struct *dead_task)
  8676. +{
  8677. + /* nothing to do ... */
  8678. +}
  8679. +
  8680. +/*
  8681. + * There is no way to power off the development
  8682. + * boards. So just spin lock for now. If you have
  8683. + * your own board with power down circuits add you
  8684. + * specific code here.
  8685. + */
  8686. +
  8687. +void machine_power_off(void)
  8688. +{
  8689. + local_irq_disable();
  8690. + for (;;);
  8691. +}
  8692. +
  8693. +EXPORT_SYMBOL(machine_power_off);
  8694. +
  8695. +void show_regs(struct pt_regs * regs)
  8696. +{
  8697. + printk(KERN_NOTICE "\n");
  8698. +
  8699. + printk(KERN_NOTICE "r1: %08lx r2: %08lx r3: %08lx r4: %08lx\n",
  8700. + regs->r1, regs->r2, regs->r3, regs->r4);
  8701. +
  8702. + printk(KERN_NOTICE "r5: %08lx r6: %08lx r7: %08lx r8: %08lx\n",
  8703. + regs->r5, regs->r6, regs->r7, regs->r8);
  8704. +
  8705. + printk(KERN_NOTICE "r9: %08lx r10: %08lx r11: %08lx r12: %08lx\n",
  8706. + regs->r9, regs->r10, regs->r11, regs->r12);
  8707. +
  8708. + printk(KERN_NOTICE "r13: %08lx r14: %08lx r15: %08lx\n",
  8709. + regs->r13, regs->r14, regs->r15);
  8710. +
  8711. + printk(KERN_NOTICE "ra: %08lx fp: %08lx sp: %08lx gp: %08lx\n",
  8712. + regs->ra, regs->fp, regs->sp, regs->gp);
  8713. +
  8714. + printk(KERN_NOTICE "ea: %08lx estatus: %08lx statusx: %08lx\n",
  8715. + regs->ea, regs->estatus, regs->status_extension);
  8716. +}
  8717. +
  8718. +/*
  8719. + * Create a kernel thread
  8720. + */
  8721. +int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
  8722. +{
  8723. + long retval;
  8724. + long clone_arg = flags | CLONE_VM;
  8725. + mm_segment_t fs;
  8726. +
  8727. + fs = get_fs();
  8728. + set_fs(KERNEL_DS);
  8729. +
  8730. + __asm__ __volatile(
  8731. +
  8732. + " movi r2, %6\n\t" /* TRAP_ID_SYSCALL */
  8733. + " movi r3, %1\n\t" /* __NR_clone */
  8734. + " mov r4, %5\n\t" /* (clone_arg */
  8735. + /* (flags | CLONE_VM)) */
  8736. + " movia r5, -1\n\t" /* usp: -1 */
  8737. + " trap\n\t" /* sys_clone */
  8738. + "\n\t"
  8739. + " cmpeq r4, r3, zero\n\t"/*2nd return valu in r3 */
  8740. + " bne r4, zero, 1f\n\t"/* 0: parent, just return. */
  8741. + /* See copy_thread, called */
  8742. + /* by do_fork, called by */
  8743. + /* nios2_clone, called by */
  8744. + /* sys_clone, called by */
  8745. + /* syscall trap handler. */
  8746. +
  8747. + " mov r4, %4\n\t" /* fn's parameter (arg) */
  8748. + "\n\t"
  8749. + "\n\t"
  8750. + " callr %3\n\t" /* Call function (fn) */
  8751. + "\n\t"
  8752. + " mov r4, r2\n\t" /* fn's rtn code//;dgt2;tmp;*/
  8753. + " movi r2, %6\n\t" /* TRAP_ID_SYSCALL */
  8754. + " movi r3, %2\n\t" /* __NR_exit */
  8755. + " trap\n\t" /* sys_exit() */
  8756. +
  8757. + /* Not reached by child. */
  8758. + "1:\n\t"
  8759. + " mov %0, r2\n\t" /* error rtn code (retval) */
  8760. +
  8761. + : "=r" (retval) /* %0 */
  8762. +
  8763. + : "i" (__NR_clone) /* %1 */
  8764. + , "i" (__NR_exit) /* %2 */
  8765. + , "r" (fn) /* %3 */
  8766. + , "r" (arg) /* %4 */
  8767. + , "r" (clone_arg) /* %5 (flags | CLONE_VM) */
  8768. + , "i" (TRAP_ID_SYSCALL) /* %6 */
  8769. +
  8770. + : "r2" /* Clobbered */
  8771. + , "r3" /* Clobbered */
  8772. + , "r4" /* Clobbered */
  8773. + , "r5" /* Clobbered */
  8774. + , "ra" /* Clobbered //;mex1 */
  8775. + );
  8776. +
  8777. + set_fs(fs);
  8778. + return retval;
  8779. +}
  8780. +
  8781. +void flush_thread(void)
  8782. +{
  8783. + /* Now, this task is no longer a kernel thread. */
  8784. + current->thread.flags &= ~NIOS2_FLAG_KTHREAD;
  8785. +
  8786. +#ifdef CONFIG_FPU
  8787. + unsigned long zero = 0;
  8788. +#endif
  8789. + set_fs(USER_DS);
  8790. +#ifdef CONFIG_FPU
  8791. + if (!FPU_IS_EMU)
  8792. +...;dgt2;
  8793. + asm volatile (".chip 68k/68881\n\t"
  8794. + "frestore %0@\n\t"
  8795. + ".chip 68k" : : "a" (&zero));
  8796. +#endif
  8797. +}
  8798. +
  8799. +/*
  8800. + * "nios2_fork()".. By the time we get here, the
  8801. + * non-volatile registers have also been saved on the
  8802. + * stack. We do some ugly pointer stuff here.. (see
  8803. + * also copy_thread)
  8804. + */
  8805. +
  8806. +asmlinkage int nios2_fork(struct pt_regs *regs)
  8807. +{
  8808. + /* fork almost works, enough to trick you into looking elsewhere :-( */
  8809. + return(-EINVAL);
  8810. +}
  8811. +
  8812. +/*
  8813. + * nios2_execve() executes a new program.
  8814. + */
  8815. +asmlinkage int nios2_execve(struct pt_regs *regs)
  8816. +{
  8817. + int error;
  8818. + char * filename;
  8819. +
  8820. + lock_kernel();
  8821. + filename = getname((char *) regs->r4);
  8822. + error = PTR_ERR(filename);
  8823. + if (IS_ERR(filename))
  8824. + goto out;
  8825. + error = do_execve(filename,
  8826. + (char **) regs->r5,
  8827. + (char **) regs->r6,
  8828. + regs);
  8829. + putname(filename);
  8830. +out:
  8831. + unlock_kernel();
  8832. + return error;
  8833. +}
  8834. +
  8835. +asmlinkage int nios2_vfork(struct pt_regs *regs)
  8836. +{
  8837. + return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, 0, NULL, NULL);
  8838. +}
  8839. +
  8840. +asmlinkage int nios2_clone(struct pt_regs *regs)
  8841. +{
  8842. + /* r4: clone_flags, r5: child_stack (usp) */
  8843. +
  8844. + unsigned long clone_flags;
  8845. + unsigned long newsp;
  8846. +
  8847. + clone_flags = regs->r4;
  8848. + newsp = regs->r5;
  8849. + if (!newsp)
  8850. + newsp = regs->sp;
  8851. + return do_fork(clone_flags, newsp, regs, 0, NULL, NULL);
  8852. +}
  8853. +
  8854. +int copy_thread(int nr, unsigned long clone_flags,
  8855. + unsigned long usp, unsigned long topstk,
  8856. + struct task_struct * p, struct pt_regs * regs)
  8857. +{
  8858. + struct pt_regs * childregs;
  8859. + struct switch_stack * childstack, *stack;
  8860. + unsigned long stack_offset, *retp;
  8861. +
  8862. + stack_offset = THREAD_SIZE - sizeof(struct pt_regs);
  8863. + childregs = (struct pt_regs *) ((unsigned long) p->stack + stack_offset);
  8864. + p->thread.kregs = childregs;
  8865. +
  8866. + *childregs = *regs;
  8867. + childregs->r2 = 0; //;dgt2;...redundant?...see "rtnvals" below
  8868. +
  8869. + retp = ((unsigned long *) regs);
  8870. + stack = ((struct switch_stack *) retp) - 1;
  8871. +
  8872. + childstack = ((struct switch_stack *) childregs) - 1;
  8873. + *childstack = *stack;
  8874. + childstack->ra = (unsigned long)ret_from_fork;
  8875. +
  8876. + if (usp == -1)
  8877. + p->thread.kregs->sp = (unsigned long) childstack;
  8878. + else
  8879. + p->thread.kregs->sp = usp;
  8880. +
  8881. + p->thread.ksp = (unsigned long)childstack;
  8882. +
  8883. +#ifdef CONFIG_FPU
  8884. + if (!FPU_IS_EMU) {
  8885. + /* Copy the current fpu state */
  8886. +...;dgt2;
  8887. + asm volatile ("fsave %0" : : "m" (p->thread.fpstate[0]) : "memory");
  8888. +
  8889. + if (p->thread.fpstate[0])
  8890. + asm volatile ("fmovemx %/fp0-%/fp7,%0\n\t"
  8891. + "fmoveml %/fpiar/%/fpcr/%/fpsr,%1"
  8892. + : : "m" (p->thread.fp[0]), "m" (p->thread.fpcntl[0])
  8893. + : "memory");
  8894. + /* Restore the state in case the fpu was busy */
  8895. + asm volatile ("frestore %0" : : "m" (p->thread.fpstate[0]));
  8896. + }
  8897. +#endif
  8898. +
  8899. + /* Set the return value for the child. */
  8900. + childregs->r2 = 0; //;dgt2;...redundant?...see childregs->r2 above
  8901. + childregs->r3 = 1; //;dgt2;...eg: kernel_thread parent test
  8902. +
  8903. + /* Set the return value for the parent. */
  8904. + regs->r2 = p->pid; // Return child pid to parent
  8905. + regs->r3 = 0; //;dgt2;...eg: kernel_thread parent test
  8906. +
  8907. + return 0;
  8908. +}
  8909. +
  8910. +/* Fill in the fpu structure for a core dump. */
  8911. +
  8912. +int dump_fpu(struct pt_regs *regs, struct user_m68kfp_struct *fpu)
  8913. +{
  8914. +#ifdef CONFIG_FPU
  8915. + char fpustate[216];
  8916. +
  8917. + if (FPU_IS_EMU) {
  8918. + int i;
  8919. +
  8920. + memcpy(fpu->fpcntl, current->thread.fpcntl, 12);
  8921. + memcpy(fpu->fpregs, current->thread.fp, 96);
  8922. + /* Convert internal fpu reg representation
  8923. + * into long double format
  8924. + */
  8925. + for (i = 0; i < 24; i += 3)
  8926. + fpu->fpregs[i] = ((fpu->fpregs[i] & 0xffff0000) << 15) |
  8927. + ((fpu->fpregs[i] & 0x0000ffff) << 16);
  8928. + return 1;
  8929. + }
  8930. +
  8931. + /* First dump the fpu context to avoid protocol violation. */
  8932. +...;dgt2;tmp;
  8933. + asm volatile ("fsave %0" :: "m" (fpustate[0]) : "memory");
  8934. + if (!fpustate[0])
  8935. + return 0;
  8936. +
  8937. + asm volatile ("fmovem %/fpiar/%/fpcr/%/fpsr,%0"
  8938. + :: "m" (fpu->fpcntl[0])
  8939. + : "memory");
  8940. + asm volatile ("fmovemx %/fp0-%/fp7,%0"
  8941. + :: "m" (fpu->fpregs[0])
  8942. + : "memory");
  8943. +#endif
  8944. + return 1;
  8945. +}
  8946. +
  8947. +/*
  8948. + * fill in the user structure for a core dump..
  8949. + */
  8950. +void dump_thread(struct pt_regs * regs, struct user * dump)
  8951. +{
  8952. + struct switch_stack *sw;
  8953. +
  8954. + /* changed the size calculations - should hopefully work better. lbt */
  8955. + dump->magic = CMAGIC;
  8956. + dump->start_code = 0;
  8957. + dump->start_stack = regs->sp & ~(PAGE_SIZE - 1);
  8958. + dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
  8959. + dump->u_dsize = ((unsigned long) (current->mm->brk +
  8960. + (PAGE_SIZE-1))) >> PAGE_SHIFT;
  8961. + dump->u_dsize -= dump->u_tsize;
  8962. + dump->u_ssize = 0;
  8963. +
  8964. + if (dump->start_stack < TASK_SIZE)
  8965. + dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
  8966. +
  8967. + dump->u_ar0 = (struct user_regs_struct *)((int)&dump->regs - (int)dump);
  8968. + sw = ((struct switch_stack *)regs) - 1;
  8969. + dump->regs.r1 = regs->r1;
  8970. + dump->regs.r2 = regs->r2;
  8971. + dump->regs.r3 = regs->r3;
  8972. + dump->regs.r4 = regs->r4;
  8973. + dump->regs.r5 = regs->r5;
  8974. + dump->regs.r6 = regs->r6;
  8975. + dump->regs.r7 = regs->r7;
  8976. + dump->regs.r8 = regs->r8;
  8977. + dump->regs.r9 = regs->r9;
  8978. + dump->regs.r10 = regs->r10;
  8979. + dump->regs.r11 = regs->r11;
  8980. + dump->regs.r12 = regs->r12;
  8981. + dump->regs.r13 = regs->r13;
  8982. + dump->regs.r14 = regs->r14;
  8983. + dump->regs.r15 = regs->r15;
  8984. + dump->regs.r16 = sw->r16;
  8985. + dump->regs.r17 = sw->r17;
  8986. + dump->regs.r18 = sw->r18;
  8987. + dump->regs.r19 = sw->r19;
  8988. + dump->regs.r20 = sw->r20;
  8989. + dump->regs.r21 = sw->r21;
  8990. + dump->regs.r22 = sw->r22;
  8991. + dump->regs.r23 = sw->r23;
  8992. + dump->regs.ra = sw->ra;
  8993. + dump->regs.fp = sw->fp;
  8994. + dump->regs.gp = sw->gp;
  8995. + dump->regs.sp = regs->sp;
  8996. + dump->regs.orig_r2 = regs->orig_r2;
  8997. + dump->regs.estatus = regs->estatus;
  8998. + dump->regs.ea = regs->ea;
  8999. + /* dump floating point stuff */
  9000. + // dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
  9001. +}
  9002. +
  9003. +/*
  9004. + * Generic dumping code. Used for panic and debug.
  9005. + */
  9006. +void dump(struct pt_regs *fp)
  9007. +{
  9008. + unsigned long *sp;
  9009. + unsigned char *tp;
  9010. + int i;
  9011. +
  9012. + printk(KERN_EMERG "\nCURRENT PROCESS:\n\n");
  9013. + printk(KERN_EMERG "COMM=%s PID=%d\n", current->comm, current->pid);
  9014. +
  9015. + if (current->mm) {
  9016. + printk(KERN_EMERG "TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
  9017. + (int) current->mm->start_code,
  9018. + (int) current->mm->end_code,
  9019. + (int) current->mm->start_data,
  9020. + (int) current->mm->end_data,
  9021. + (int) current->mm->end_data,
  9022. + (int) current->mm->brk);
  9023. + printk(KERN_EMERG "USER-STACK=%08x KERNEL-STACK=%08x\n\n",
  9024. + (int) current->mm->start_stack,
  9025. + (int)(((unsigned long) current) + THREAD_SIZE));
  9026. + }
  9027. +
  9028. + printk(KERN_EMERG "PC: %08lx\n", fp->ea);
  9029. + printk(KERN_EMERG "SR: %08lx SP: %08lx\n", (long) fp->estatus, (long) fp);
  9030. + printk(KERN_EMERG "r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n",
  9031. + fp->r4, fp->r5, fp->r6, fp->r7);
  9032. + printk(KERN_EMERG "r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n",
  9033. + fp->r8, fp->r9, fp->r10, fp->r11);
  9034. + printk(KERN_EMERG "\nUSP: %08x TRAPFRAME: %08x\n", (unsigned int) fp->sp,
  9035. + (unsigned int) fp);
  9036. +
  9037. + printk(KERN_EMERG "\nCODE:");
  9038. + tp = ((unsigned char *) fp->ea) - 0x20;
  9039. + for (sp = (unsigned long *) tp, i = 0; (i < 0x40); i += 4) {
  9040. + if ((i % 0x10) == 0)
  9041. + printk(KERN_EMERG "\n%08x: ", (int) (tp + i));
  9042. + printk(KERN_EMERG "%08x ", (int) *sp++);
  9043. + }
  9044. + printk(KERN_EMERG "\n");
  9045. +
  9046. + printk(KERN_EMERG "\nKERNEL STACK:");
  9047. + tp = ((unsigned char *) fp) - 0x40;
  9048. + for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
  9049. + if ((i % 0x10) == 0)
  9050. + printk(KERN_EMERG "\n%08x: ", (int) (tp + i));
  9051. + printk(KERN_EMERG "%08x ", (int) *sp++);
  9052. + }
  9053. + printk(KERN_EMERG "\n");
  9054. + printk(KERN_EMERG "\n");
  9055. +
  9056. + printk(KERN_EMERG "\nUSER STACK:");
  9057. + tp = (unsigned char *) (fp->sp - 0x10);
  9058. + for (sp = (unsigned long *) tp, i = 0; (i < 0x80); i += 4) {
  9059. + if ((i % 0x10) == 0)
  9060. + printk(KERN_EMERG "\n%08x: ", (int) (tp + i));
  9061. + printk(KERN_EMERG "%08x ", (int) *sp++);
  9062. + }
  9063. + printk(KERN_EMERG "\n\n");
  9064. +}
  9065. +
  9066. +/*
  9067. + * These bracket the sleeping functions..
  9068. + */
  9069. +extern void scheduling_functions_start_here(void);
  9070. +extern void scheduling_functions_end_here(void);
  9071. +#define first_sched ((unsigned long) scheduling_functions_start_here)
  9072. +#define last_sched ((unsigned long) scheduling_functions_end_here)
  9073. +
  9074. +unsigned long get_wchan(struct task_struct *p)
  9075. +{
  9076. + unsigned long fp, pc;
  9077. + unsigned long stack_page;
  9078. + int count = 0;
  9079. + if (!p || p == current || p->state == TASK_RUNNING)
  9080. + return 0;
  9081. +
  9082. + stack_page = (unsigned long)p;
  9083. + fp = ((struct switch_stack *)p->thread.ksp)->fp; //;dgt2
  9084. + do {
  9085. + if (fp < stack_page+sizeof(struct task_struct) ||
  9086. + fp >= 8184+stack_page) //;dgt2;tmp
  9087. + return 0;
  9088. + pc = ((unsigned long *)fp)[1];
  9089. + if (!in_sched_functions(pc))
  9090. + return pc;
  9091. + fp = *(unsigned long *) fp;
  9092. + } while (count++ < 16); //;dgt2;tmp
  9093. + return 0;
  9094. +}
  9095. +
  9096. +/* Return saved PC of a blocked thread. */
  9097. +unsigned long thread_saved_pc(struct task_struct *t)
  9098. +{
  9099. + return (t->thread.kregs->ea);
  9100. +}
  9101. +
  9102. +/*
  9103. + * Do necessary setup to start up a newly executed thread.
  9104. + * Will statup in user mode (status_extension = 0).
  9105. + */
  9106. +void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
  9107. +{
  9108. + memset((void *) regs, 0, sizeof(struct pt_regs));
  9109. + regs->estatus = NIOS2_STATUS_PIE_MSK; // No user mode setting, at least not for now
  9110. + regs->ea = pc;
  9111. + regs->sp = sp;
  9112. +
  9113. + /* check if debug flag is set */
  9114. + if (current->thread.flags & NIOS2_FLAG_DEBUG ) {
  9115. + if ( *(u32*)pc == NIOS2_OP_NOP ) {
  9116. + *(u32*)pc = NIOS2_OP_BREAK;
  9117. + flush_icache_range(pc, pc+4);
  9118. + }
  9119. + }
  9120. +}
  9121. diff --git a/arch/nios2nommu/kernel/ptrace.c b/arch/nios2nommu/kernel/ptrace.c
  9122. new file mode 100644
  9123. index 0000000..e6ff3b3
  9124. --- /dev/null
  9125. +++ b/arch/nios2nommu/kernel/ptrace.c
  9126. @@ -0,0 +1,352 @@
  9127. +/*
  9128. + * linux/arch/m68knommu/kernel/ptrace.c
  9129. + *
  9130. + * Copyright (C) 1994 by Hamish Macdonald
  9131. + * Taken from linux/kernel/ptrace.c and modified for M680x0.
  9132. + * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
  9133. + *
  9134. + * This file is subject to the terms and conditions of the GNU General
  9135. + * Public License. See the file COPYING in the main directory of
  9136. + * this archive for more details.
  9137. + */
  9138. +
  9139. +#include <linux/kernel.h>
  9140. +#include <linux/sched.h>
  9141. +#include <linux/mm.h>
  9142. +#include <linux/smp.h>
  9143. +#include <linux/smp_lock.h>
  9144. +#include <linux/errno.h>
  9145. +#include <linux/ptrace.h>
  9146. +#include <linux/user.h>
  9147. +
  9148. +#include <asm/uaccess.h>
  9149. +#include <asm/page.h>
  9150. +#include <asm/pgtable.h>
  9151. +#include <asm/system.h>
  9152. +#include <asm/processor.h>
  9153. +
  9154. +/*
  9155. + * does not yet catch signals sent when the child dies.
  9156. + * in exit.c or in signal.c.
  9157. + */
  9158. +
  9159. +/* determines which bits in the SR the user has access to. */
  9160. +/* 1 = access 0 = no access */
  9161. +#define SR_MASK 0x00000000
  9162. +
  9163. +/* Find the stack offset for a register, relative to thread.ksp. */
  9164. +#define PT_REG(reg) ((long)&((struct pt_regs *)0)->reg)
  9165. +#define SW_REG(reg) ((long)&((struct switch_stack *)0)->reg \
  9166. + - sizeof(struct switch_stack))
  9167. +/* Mapping from PT_xxx to the stack offset at which the register is
  9168. + saved. Notice that usp has no stack-slot and needs to be treated
  9169. + specially (see get_reg/put_reg below). */
  9170. +static int regoff[] = {
  9171. + -1, PT_REG(r1), PT_REG(r2), PT_REG(r3), PT_REG(r4),
  9172. + PT_REG(r5), PT_REG(r6), PT_REG(r7), PT_REG(r8),
  9173. + PT_REG(r9), PT_REG(r10), PT_REG(r11), PT_REG(r12),
  9174. + PT_REG(r13), PT_REG(r14), PT_REG(r15), SW_REG(r16),
  9175. + SW_REG(r17), SW_REG(r18), SW_REG(r19), SW_REG(r20),
  9176. + SW_REG(r21), SW_REG(r22), SW_REG(r23), -1, -1,
  9177. + PT_REG(gp), PT_REG(sp), -1, -1, PT_REG(ra), -1,
  9178. + PT_REG(estatus), -1, -1, -1
  9179. +};
  9180. +
  9181. +/*
  9182. + * Get contents of register REGNO in task TASK.
  9183. + */
  9184. +static inline long get_reg(struct task_struct *task, int regno)
  9185. +{
  9186. + unsigned long *addr;
  9187. +
  9188. + if (regno == PTR_R0)
  9189. + return 0;
  9190. + else if (regno == PTR_BA)
  9191. + return 0;
  9192. + else if (regno == PTR_STATUS)
  9193. + return 0;
  9194. + else if (regno == PTR_IENABLE)
  9195. + return 0;
  9196. + else if (regno == PTR_IPENDING)
  9197. + return 0;
  9198. + else if (regno < sizeof(regoff)/sizeof(regoff[0]))
  9199. + addr = (unsigned long *)(task->thread.kregs + regoff[regno]);
  9200. + else
  9201. + return 0;
  9202. + return *addr;
  9203. +}
  9204. +
  9205. +/*
  9206. + * Write contents of register REGNO in task TASK.
  9207. + */
  9208. +static inline int put_reg(struct task_struct *task, int regno,
  9209. + unsigned long data)
  9210. +{
  9211. + unsigned long *addr;
  9212. +
  9213. + if (regno == PTR_R0)
  9214. + return -1;
  9215. + else if (regno == PTR_BA)
  9216. + return -1;
  9217. + else if (regno == PTR_STATUS)
  9218. + return -1;
  9219. + else if (regno == PTR_IENABLE)
  9220. + return -1;
  9221. + else if (regno == PTR_IPENDING)
  9222. + return -1;
  9223. + else if (regno < sizeof(regoff)/sizeof(regoff[0]))
  9224. + addr = (unsigned long *) (task->thread.kregs + regoff[regno]);
  9225. + else
  9226. + return -1;
  9227. + *addr = data;
  9228. + return 0;
  9229. +}
  9230. +
  9231. +/*
  9232. + * Called by kernel/ptrace.c when detaching..
  9233. + *
  9234. + * Nothing special to do here, no processor debug support.
  9235. + */
  9236. +void ptrace_disable(struct task_struct *child)
  9237. +{
  9238. +}
  9239. +
  9240. +long arch_ptrace(struct task_struct *child, long request, long addr, long data)
  9241. +{
  9242. + int ret;
  9243. +
  9244. + switch (request) {
  9245. + /* when I and D space are separate, these will need to be fixed. */
  9246. + case PTRACE_PEEKTEXT: /* read word at location addr. */
  9247. + case PTRACE_PEEKDATA: {
  9248. + unsigned long tmp;
  9249. + int copied;
  9250. +
  9251. + copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
  9252. + ret = -EIO;
  9253. + if (copied != sizeof(tmp))
  9254. + break;
  9255. + ret = put_user(tmp,(unsigned long *) data);
  9256. + break;
  9257. + }
  9258. +
  9259. + /* read the word at location addr in the USER area. */
  9260. + case PTRACE_PEEKUSR: {
  9261. + unsigned long tmp;
  9262. +
  9263. + ret = -EIO;
  9264. + if ((addr & 3) || addr < 0 ||
  9265. + addr > sizeof(struct user) - 3)
  9266. + break;
  9267. +
  9268. + tmp = 0; /* Default return condition */
  9269. + addr = addr >> 2; /* temporary hack. */
  9270. + ret = -EIO;
  9271. + if (addr < 19) {
  9272. + tmp = get_reg(child, addr);
  9273. +#if 0 // No FPU stuff
  9274. + } else if (addr >= 21 && addr < 49) {
  9275. + tmp = child->thread.fp[addr - 21];
  9276. +#ifdef CONFIG_M68KFPU_EMU
  9277. + /* Convert internal fpu reg representation
  9278. + * into long double format
  9279. + */
  9280. + if (FPU_IS_EMU && (addr < 45) && !(addr % 3))
  9281. + tmp = ((tmp & 0xffff0000) << 15) |
  9282. + ((tmp & 0x0000ffff) << 16);
  9283. +#endif
  9284. +#endif
  9285. + } else if (addr == 49) {
  9286. + tmp = child->mm->start_code;
  9287. + } else if (addr == 50) {
  9288. + tmp = child->mm->start_data;
  9289. + } else if (addr == 51) {
  9290. + tmp = child->mm->end_code;
  9291. + } else
  9292. + break;
  9293. + ret = put_user(tmp,(unsigned long *) data);
  9294. + break;
  9295. + }
  9296. +
  9297. + /* when I and D space are separate, this will have to be fixed. */
  9298. + case PTRACE_POKETEXT: /* write the word at location addr. */
  9299. + case PTRACE_POKEDATA:
  9300. + ret = 0;
  9301. + if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data))
  9302. + break;
  9303. + ret = -EIO;
  9304. + break;
  9305. +
  9306. + case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
  9307. + ret = -EIO;
  9308. + if ((addr & 3) || addr < 0 ||
  9309. + addr > sizeof(struct user) - 3)
  9310. + break;
  9311. +
  9312. + addr = addr >> 2; /* temporary hack. */
  9313. +
  9314. + if (addr == PTR_ESTATUS) {
  9315. + data &= SR_MASK;
  9316. + data |= get_reg(child, PTR_ESTATUS) & ~(SR_MASK);
  9317. + }
  9318. + if (addr < 19) {
  9319. + if (put_reg(child, addr, data))
  9320. + break;
  9321. + ret = 0;
  9322. + break;
  9323. + }
  9324. +#if 0 // No FPU stuff
  9325. + if (addr >= 21 && addr < 48)
  9326. + {
  9327. +#ifdef CONFIG_M68KFPU_EMU
  9328. + /* Convert long double format
  9329. + * into internal fpu reg representation
  9330. + */
  9331. + if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) {
  9332. + data = (unsigned long)data << 15;
  9333. + data = (data & 0xffff0000) |
  9334. + ((data & 0x0000ffff) >> 1);
  9335. + }
  9336. +#endif
  9337. + child->thread.fp[addr - 21] = data;
  9338. + ret = 0;
  9339. + }
  9340. +#endif
  9341. + break;
  9342. +
  9343. + case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
  9344. + case PTRACE_CONT: { /* restart after signal. */
  9345. +
  9346. + ret = -EIO;
  9347. + if ((unsigned long) data > _NSIG)
  9348. + break;
  9349. + if (request == PTRACE_SYSCALL)
  9350. + set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
  9351. + else
  9352. + clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
  9353. + child->exit_code = data;
  9354. + wake_up_process(child);
  9355. + ret = 0;
  9356. + break;
  9357. + }
  9358. +
  9359. + /*
  9360. + * make the child exit. Best I can do is send it a sigkill.
  9361. + * perhaps it should be put in the status that it wants to
  9362. + * exit.
  9363. + */
  9364. + case PTRACE_KILL: {
  9365. +
  9366. + ret = 0;
  9367. + if (child->state == EXIT_ZOMBIE) /* already dead */
  9368. + break;
  9369. + child->exit_code = SIGKILL;
  9370. + wake_up_process(child);
  9371. + break;
  9372. + }
  9373. +
  9374. + /*
  9375. + * Single stepping requires placing break instructions in
  9376. + * the code to break back. If you are stepping through a
  9377. + * conditional branch you need to decode the test and put
  9378. + * the break in the correct location.
  9379. + */
  9380. + case PTRACE_SINGLESTEP: { /* set the trap flag. */
  9381. +
  9382. + ret = -EIO;
  9383. + if ((unsigned long) data > _NSIG)
  9384. + break;
  9385. + clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
  9386. +
  9387. + child->exit_code = data;
  9388. + /* give it a chance to run. */
  9389. + wake_up_process(child);
  9390. + ret = 0;
  9391. + break;
  9392. + }
  9393. +
  9394. + case PTRACE_DETACH: /* detach a process that was attached. */
  9395. + ret = ptrace_detach(child, data);
  9396. + break;
  9397. +
  9398. + case PTRACE_GETREGS: { /* Get all gp regs from the child. */
  9399. + int i;
  9400. + unsigned long tmp;
  9401. + for (i = 0; i < 19; i++) {
  9402. + tmp = get_reg(child, i);
  9403. + if (put_user(tmp, (unsigned long *) data)) {
  9404. + ret = -EFAULT;
  9405. + break;
  9406. + }
  9407. + data += sizeof(long);
  9408. + }
  9409. + ret = 0;
  9410. + break;
  9411. + }
  9412. +
  9413. + case PTRACE_SETREGS: { /* Set all gp regs in the child. */
  9414. + int i;
  9415. + unsigned long tmp;
  9416. + for (i = 0; i < 19; i++) {
  9417. + if (get_user(tmp, (unsigned long *) data)) {
  9418. + ret = -EFAULT;
  9419. + break;
  9420. + }
  9421. + if (i == PTR_ESTATUS) {
  9422. + tmp &= SR_MASK;
  9423. + tmp |= get_reg(child, PTR_ESTATUS) & ~(SR_MASK);
  9424. + }
  9425. + put_reg(child, i, tmp);
  9426. + data += sizeof(long);
  9427. + }
  9428. + ret = 0;
  9429. + break;
  9430. + }
  9431. +
  9432. +#ifdef PTRACE_GETFPREGS
  9433. + case PTRACE_GETFPREGS: { /* Get the child FPU state. */
  9434. + ret = 0;
  9435. + if (copy_to_user((void *)data, &child->thread.fp,
  9436. + sizeof(struct user_m68kfp_struct)))
  9437. + ret = -EFAULT;
  9438. + break;
  9439. + }
  9440. +#endif
  9441. +
  9442. +#ifdef PTRACE_SETFPREGS
  9443. + case PTRACE_SETFPREGS: { /* Set the child FPU state. */
  9444. + ret = 0;
  9445. + if (copy_from_user(&child->thread.fp, (void *)data,
  9446. + sizeof(struct user_m68kfp_struct)))
  9447. + ret = -EFAULT;
  9448. + break;
  9449. + }
  9450. +#endif
  9451. +
  9452. + default:
  9453. + ret = -EIO;
  9454. + break;
  9455. + }
  9456. + return ret;
  9457. +}
  9458. +
  9459. +asmlinkage void syscall_trace(void)
  9460. +{
  9461. + if (!test_thread_flag(TIF_SYSCALL_TRACE))
  9462. + return;
  9463. + if (!(current->ptrace & PT_PTRACED))
  9464. + return;
  9465. + current->exit_code = SIGTRAP;
  9466. + current->state = TASK_STOPPED;
  9467. + ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
  9468. + ? 0x80 : 0));
  9469. + /*
  9470. + * this isn't the same as continuing with a signal, but it will do
  9471. + * for normal use. strace only continues with a signal if the
  9472. + * stopping signal is not SIGTRAP. -brl
  9473. + */
  9474. + if (current->exit_code) {
  9475. + send_sig(current->exit_code, current, 1);
  9476. + current->exit_code = 0;
  9477. + }
  9478. +}
  9479. diff --git a/arch/nios2nommu/kernel/semaphore.c b/arch/nios2nommu/kernel/semaphore.c
  9480. new file mode 100644
  9481. index 0000000..0c7d11b
  9482. --- /dev/null
  9483. +++ b/arch/nios2nommu/kernel/semaphore.c
  9484. @@ -0,0 +1,155 @@
  9485. +/*--------------------------------------------------------------------
  9486. + *
  9487. + * arch/nios2nommu/kernel/semaphore.c
  9488. + *
  9489. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  9490. + *
  9491. + * Copyright (C) 2004 Microtronix Datacom Ltd
  9492. + *
  9493. + * This program is free software; you can redistribute it and/or modify
  9494. + * it under the terms of the GNU General Public License as published by
  9495. + * the Free Software Foundation; either version 2 of the License, or
  9496. + * (at your option) any later version.
  9497. + *
  9498. + * This program is distributed in the hope that it will be useful,
  9499. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9500. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9501. + * GNU General Public License for more details.
  9502. + *
  9503. + *
  9504. + * Jan/20/2004 dgt NiosII
  9505. + *
  9506. + ---------------------------------------------------------------------*/
  9507. +
  9508. +/*
  9509. + * Generic semaphore code. Buyer beware. Do your own
  9510. + * specific changes in <asm/semaphore-helper.h>
  9511. + */
  9512. +
  9513. +#include <linux/sched.h>
  9514. +#include <linux/err.h>
  9515. +#include <asm/semaphore-helper.h>
  9516. +
  9517. +#ifndef CONFIG_RMW_INSNS
  9518. +spinlock_t semaphore_wake_lock;
  9519. +#endif
  9520. +
  9521. +/*
  9522. + * Semaphores are implemented using a two-way counter:
  9523. + * The "count" variable is decremented for each process
  9524. + * that tries to sleep, while the "waking" variable is
  9525. + * incremented when the "up()" code goes to wake up waiting
  9526. + * processes.
  9527. + *
  9528. + * Notably, the inline "up()" and "down()" functions can
  9529. + * efficiently test if they need to do any extra work (up
  9530. + * needs to do something only if count was negative before
  9531. + * the increment operation.
  9532. + *
  9533. + * waking_non_zero() (from asm/semaphore.h) must execute
  9534. + * atomically.
  9535. + *
  9536. + * When __up() is called, the count was negative before
  9537. + * incrementing it, and we need to wake up somebody.
  9538. + *
  9539. + * This routine adds one to the count of processes that need to
  9540. + * wake up and exit. ALL waiting processes actually wake up but
  9541. + * only the one that gets to the "waking" field first will gate
  9542. + * through and acquire the semaphore. The others will go back
  9543. + * to sleep.
  9544. + *
  9545. + * Note that these functions are only called when there is
  9546. + * contention on the lock, and as such all this is the
  9547. + * "non-critical" part of the whole semaphore business. The
  9548. + * critical part is the inline stuff in <asm/semaphore.h>
  9549. + * where we want to avoid any extra jumps and calls.
  9550. + */
  9551. +asmlinkage void __up(struct semaphore *sem)
  9552. +{
  9553. + wake_one_more(sem);
  9554. + wake_up(&sem->wait);
  9555. +}
  9556. +
  9557. +/*
  9558. + * Perform the "down" function. Return zero for semaphore acquired,
  9559. + * return negative for signalled out of the function.
  9560. + *
  9561. + * If called from __down, the return is ignored and the wait loop is
  9562. + * not interruptible. This means that a task waiting on a semaphore
  9563. + * using "down()" cannot be killed until someone does an "up()" on
  9564. + * the semaphore.
  9565. + *
  9566. + * If called from __down_interruptible, the return value gets checked
  9567. + * upon return. If the return value is negative then the task continues
  9568. + * with the negative value in the return register (it can be tested by
  9569. + * the caller).
  9570. + *
  9571. + * Either form may be used in conjunction with "up()".
  9572. + *
  9573. + */
  9574. +
  9575. +
  9576. +#define DOWN_HEAD(task_state) \
  9577. + \
  9578. + \
  9579. + current->state = (task_state); \
  9580. + add_wait_queue(&sem->wait, &wait); \
  9581. + \
  9582. + /* \
  9583. + * Ok, we're set up. sem->count is known to be less than zero \
  9584. + * so we must wait. \
  9585. + * \
  9586. + * We can let go the lock for purposes of waiting. \
  9587. + * We re-acquire it after awaking so as to protect \
  9588. + * all semaphore operations. \
  9589. + * \
  9590. + * If "up()" is called before we call waking_non_zero() then \
  9591. + * we will catch it right away. If it is called later then \
  9592. + * we will have to go through a wakeup cycle to catch it. \
  9593. + * \
  9594. + * Multiple waiters contend for the semaphore lock to see \
  9595. + * who gets to gate through and who has to wait some more. \
  9596. + */ \
  9597. + for (;;) {
  9598. +
  9599. +#define DOWN_TAIL(task_state) \
  9600. + current->state = (task_state); \
  9601. + } \
  9602. + current->state = TASK_RUNNING; \
  9603. + remove_wait_queue(&sem->wait, &wait);
  9604. +
  9605. +void __sched __down(struct semaphore * sem)
  9606. +{
  9607. + DECLARE_WAITQUEUE(wait, current);
  9608. +
  9609. + DOWN_HEAD(TASK_UNINTERRUPTIBLE)
  9610. + if (waking_non_zero(sem))
  9611. + break;
  9612. + schedule();
  9613. + DOWN_TAIL(TASK_UNINTERRUPTIBLE)
  9614. +}
  9615. +
  9616. +int __sched __down_interruptible(struct semaphore * sem)
  9617. +{
  9618. + DECLARE_WAITQUEUE(wait, current);
  9619. + int ret = 0;
  9620. +
  9621. + DOWN_HEAD(TASK_INTERRUPTIBLE)
  9622. +
  9623. + ret = waking_non_zero_interruptible(sem, current);
  9624. + if (ret)
  9625. + {
  9626. + if (ret == 1)
  9627. + /* ret != 0 only if we get interrupted -arca */
  9628. + ret = 0;
  9629. + break;
  9630. + }
  9631. + schedule();
  9632. + DOWN_TAIL(TASK_INTERRUPTIBLE)
  9633. + return ret;
  9634. +}
  9635. +
  9636. +int __down_trylock(struct semaphore * sem)
  9637. +{
  9638. + return waking_non_zero_trylock(sem);
  9639. +}
  9640. diff --git a/arch/nios2nommu/kernel/setup.c b/arch/nios2nommu/kernel/setup.c
  9641. new file mode 100644
  9642. index 0000000..1f1627b
  9643. --- /dev/null
  9644. +++ b/arch/nios2nommu/kernel/setup.c
  9645. @@ -0,0 +1,663 @@
  9646. +/*
  9647. + 21Mar2001 1.1 dgt/microtronix: Altera Excalibur/Nios32 port
  9648. + 30Jun2003 kenw/microtronix: Remove cmdline check in flash
  9649. +*/
  9650. +
  9651. +/*
  9652. + * linux/arch/niosnommu/kernel/setup.c
  9653. + *
  9654. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  9655. + * Copyright (C) 2001 Vic Phillips {vic@microtronix.com}
  9656. + * Copyleft (C) 2000 James D. Schettine {james@telos-systems.com}
  9657. + * Copyright (C) 1999 Greg Ungerer (gerg@moreton.com.au)
  9658. + * Copyright (C) 1998,2000 D. Jeff Dionne <jeff@lineo.ca>
  9659. + * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
  9660. + * Copyright (C) 1995 Hamish Macdonald
  9661. + *
  9662. + * All rights reserved.
  9663. + *
  9664. + * This program is free software; you can redistribute it and/or modify
  9665. + * it under the terms of the GNU General Public License as published by
  9666. + * the Free Software Foundation; either version 2 of the License, or
  9667. + * (at your option) any later version.
  9668. + *
  9669. + * This program is distributed in the hope that it will be useful, but
  9670. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  9671. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  9672. + * NON INFRINGEMENT. See the GNU General Public License for more
  9673. + * details.
  9674. + *
  9675. + * You should have received a copy of the GNU General Public License
  9676. + * along with this program; if not, write to the Free Software
  9677. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  9678. + *
  9679. + */
  9680. +
  9681. +/*
  9682. + * This file handles the architecture-dependent parts of system setup
  9683. + */
  9684. +
  9685. +#include <linux/kernel.h>
  9686. +#include <linux/sched.h>
  9687. +#include <linux/platform_device.h>
  9688. +#include <linux/delay.h>
  9689. +#include <linux/interrupt.h>
  9690. +#include <linux/fs.h>
  9691. +#include <linux/fb.h>
  9692. +#include <linux/module.h>
  9693. +#include <linux/console.h>
  9694. +#include <linux/genhd.h>
  9695. +#include <linux/errno.h>
  9696. +#include <linux/string.h>
  9697. +#include <linux/major.h>
  9698. +#include <linux/bootmem.h>
  9699. +#include <linux/initrd.h>
  9700. +#include <linux/seq_file.h>
  9701. +
  9702. +#include <asm/irq.h>
  9703. +#include <asm/byteorder.h>
  9704. +#include <asm/asm-offsets.h>
  9705. +#include <asm/pgtable.h>
  9706. +
  9707. +#ifdef CONFIG_BLK_DEV_INITRD
  9708. +#include <linux/blk.h>
  9709. +#endif
  9710. +
  9711. +#ifdef CONFIG_NIOS_SPI
  9712. +#include <asm/spi.h>
  9713. +extern ssize_t spi_write(struct file *filp, const char *buf, size_t count, loff_t *ppos);
  9714. +extern ssize_t spi_read (struct file *filp, char *buf, size_t count, loff_t *ppos);
  9715. +extern loff_t spi_lseek (struct file *filp, loff_t offset, int origin);
  9716. +extern int spi_open (struct inode *inode, struct file *filp);
  9717. +extern int spi_release (struct inode *inode, struct file *filp);
  9718. +#endif
  9719. +
  9720. +#ifdef CONFIG_CONSOLE
  9721. +extern struct consw *conswitchp;
  9722. +#endif
  9723. +
  9724. +unsigned long rom_length;
  9725. +unsigned long memory_start;
  9726. +unsigned long memory_end;
  9727. +
  9728. +EXPORT_SYMBOL(memory_start);
  9729. +EXPORT_SYMBOL(memory_end);
  9730. +
  9731. +#ifndef CONFIG_CMDLINE
  9732. +#define CONFIG_CMDLINE "CONSOLE=/dev/ttyS0 root=/dev/rom0 ro"
  9733. +#endif
  9734. +
  9735. +#ifndef CONFIG_PASS_CMDLINE
  9736. +static char default_command_line[] = CONFIG_CMDLINE;
  9737. +#endif
  9738. +static char __initdata command_line[COMMAND_LINE_SIZE] = { 0, };
  9739. +
  9740. +
  9741. +/* r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11*/
  9742. +/* r12 r13 r14 r15 or2 ra fp sp gp es ste ea*/
  9743. +static struct pt_regs fake_regs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\
  9744. + 0, 0, 0, 0, 0, (unsigned long)cpu_idle, 0, 0, 0, 0, 0, 0};
  9745. +
  9746. +#define CPU "NIOS2"
  9747. +
  9748. +#if defined (CONFIG_CS89x0) || defined (CONFIG_SMC91111) || defined (CONFIG_OPEN_ETH) || defined (CONFIG_MTIP1000_ETH) || defined (CONFIG_DM9000_ETH) || defined (CONFIG_SMC91X) || defined (CONFIG_DM9000) || defined (CONFIG_DM9KS)
  9749. + #if defined (CONFIG_MTIP1000_ETH) //;dgt3;
  9750. + #include <../drivers/net/mtip1000.h> //;dgt3;
  9751. + #endif //;dgt3;
  9752. +
  9753. + unsigned char *excalibur_enet_hwaddr;
  9754. + unsigned char excalibur_enet_hwaddr_array[6];
  9755. +#endif
  9756. +
  9757. +// save args passed from u-boot, called from head.S
  9758. +void nios2_boot_init(unsigned r4,unsigned r5,unsigned r6,unsigned r7)
  9759. +{
  9760. +#if defined(CONFIG_PASS_CMDLINE)
  9761. + if (r4 == 0x534f494e) // r4 is magic NIOS, to become board info check in the future
  9762. + {
  9763. +#if defined(CONFIG_BLK_DEV_INITRD)
  9764. + /*
  9765. + * If the init RAM disk has been configured in, and there's a valid
  9766. + * starting address for it, set it up.
  9767. + */
  9768. + if (r5) {
  9769. + initrd_start = r5;
  9770. + initrd_end = r6;
  9771. + }
  9772. +#endif /* CONFIG_BLK_DEV_INITRD */
  9773. + if (r7)
  9774. + strncpy(command_line, (char *)r7, COMMAND_LINE_SIZE);
  9775. + }
  9776. +#endif
  9777. +}
  9778. +
  9779. +inline void flash_command(int base, int offset, short data)
  9780. +{
  9781. + volatile unsigned short * ptr=(unsigned short*) (base);
  9782. +
  9783. + ptr[0x555]=0xaa;
  9784. + ptr[0x2aa]=0x55;
  9785. + ptr[offset]=data;
  9786. +}
  9787. +
  9788. +inline void exit_se_flash(int base)
  9789. +{
  9790. + flash_command(base, 0x555, 0x90);
  9791. + *(unsigned short*)base=0;
  9792. +}
  9793. +
  9794. +void __init setup_arch(char **cmdline_p)
  9795. +{
  9796. + int bootmap_size;
  9797. + extern int _stext, _etext;
  9798. + extern int _edata, _end;
  9799. +#ifdef DEBUG
  9800. + extern int _sdata, _sbss, _ebss;
  9801. +#ifdef CONFIG_BLK_DEV_BLKMEM
  9802. + extern int *romarray;
  9803. +#endif
  9804. +#endif
  9805. +#if 0 // krh
  9806. + unsigned char *psrc=(unsigned char *)((NIOS_FLASH_START + NIOS_FLASH_END)>>1);
  9807. + int i=0;
  9808. +#endif // krh
  9809. +
  9810. + memory_start = PAGE_ALIGN((unsigned long)&_end);
  9811. + memory_end = (unsigned long) nasys_program_mem_end;
  9812. +
  9813. +#if 0 //;kenw;
  9814. + /* copy the command line from booting paramter region */
  9815. + #if defined (nasys_am29lv065d_flash_0) //;dgt;
  9816. + { //;dgt;
  9817. + // ...TBA... //;dgt;
  9818. + } //;dgt;
  9819. + #else //;dgt;
  9820. + flash_command((int)psrc, 0x555, 0x88);
  9821. + while ((*psrc!=0xFF) && (i<sizeof(command_line))) {
  9822. + command_line[i++]=*psrc++;
  9823. + }
  9824. + command_line[i]=0;
  9825. + exit_se_flash(((NIOS_FLASH_START + NIOS_FLASH_END)>>1) );
  9826. + if (command_line[0]==0)
  9827. + #endif //;dgt;
  9828. +#endif //;kenw;
  9829. +#ifndef CONFIG_PASS_CMDLINE
  9830. + memcpy(command_line, default_command_line, sizeof(default_command_line));
  9831. +#endif
  9832. +
  9833. + printk("\x0F\r\n\nuClinux/Nios II\n");
  9834. + printk("Altera Nios II support (C) 2004 Microtronix Datacom Ltd.\n");
  9835. +
  9836. +#ifdef DEBUG
  9837. + printk("KERNEL -> TEXT=0x%08x-0x%08x DATA=0x%08x-0x%08x "
  9838. + "BSS=0x%08x-0x%08x\n", (int) &_stext, (int) &_etext,
  9839. + (int) &_sdata, (int) &_edata,
  9840. + (int) &_sbss, (int) &_ebss);
  9841. + printk("KERNEL -> MEM=0x%06x-0x%06x STACK=0x%06x-0x%06x\n",
  9842. + (int) memory_start, (int) memory_end,
  9843. + (int) memory_end, (int) nasys_program_mem_end);
  9844. +#endif
  9845. +
  9846. + init_mm.start_code = (unsigned long) &_stext;
  9847. + init_mm.end_code = (unsigned long) &_etext;
  9848. + init_mm.end_data = (unsigned long) &_edata;
  9849. + init_mm.brk = (unsigned long) 0;
  9850. + init_task.thread.kregs = &fake_regs;
  9851. +
  9852. +#if 0
  9853. + ROOT_DEV = MKDEV(BLKMEM_MAJOR,0);
  9854. +#endif
  9855. +
  9856. + /* Keep a copy of command line */
  9857. + *cmdline_p = &command_line[0];
  9858. +
  9859. + memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
  9860. + saved_command_line[COMMAND_LINE_SIZE-1] = 0;
  9861. +
  9862. +#ifdef DEBUG
  9863. + if (strlen(*cmdline_p))
  9864. + printk("Command line: '%s'\n", *cmdline_p);
  9865. + else
  9866. + printk("No Command line passed\n");
  9867. +#endif
  9868. +
  9869. +
  9870. +#if defined (CONFIG_CS89x0) || defined (CONFIG_SMC91111) || defined (CONFIG_OPEN_ETH) || defined (CONFIG_MTIP1000_ETH) || defined (CONFIG_DM9000_ETH) || defined (CONFIG_SMC91X) || defined (CONFIG_DM9000) || defined (CONFIG_DM9KS)
  9871. +
  9872. + #if defined (CONFIG_MTIP1000_ETH) //;dgt3;
  9873. + (*((np_mtip_mac *) //;dgt3;
  9874. + (na_mtip_mac_control_port))). //;dgt3;
  9875. + COMMAND_CONFIG = 0; //;dgt3;
  9876. + #endif //;dgt3;
  9877. +
  9878. + /* now read the hwaddr of the ethernet --wentao*/
  9879. +
  9880. + #if 1 //;dgt2;
  9881. +// #if defined (nasys_am29lv065d_flash_0) //;dgt;
  9882. + { //;dgt;
  9883. + unsigned char *flashptr = //;dgt;
  9884. + ((unsigned char *) //;dgt;
  9885. + (( //;dgt;
  9886. + #if defined (na_flash_kernel_end) //;dgt2;
  9887. + na_flash_kernel_end //;dgt2;
  9888. + #else //;dgt2;
  9889. + #if defined (na_flash_kernel_base) //;dgt2;
  9890. + na_flash_kernel_base + //;dgt;
  9891. + #else //;dgt2;
  9892. + na_flash_kernel + //;dgt2;
  9893. + #endif //;dgt2;
  9894. + na_flash_kernel_size //;dgt2;
  9895. + #endif //;dgt2;
  9896. + - 0x00010000))); //;dgt;
  9897. + // last 64K of Altera stratix/cyclone flash //;dgt;
  9898. + //;dgt;
  9899. + if((*((unsigned long *) flashptr)) == 0x00005AFE) //;dgt;
  9900. + { //;dgt;
  9901. + memcpy(excalibur_enet_hwaddr_array, //;dgt;
  9902. + ((void*) (flashptr+4)),6); //;dgt;
  9903. + } //;dgt;
  9904. + else //;dgt;
  9905. + { //;dgt;
  9906. + printk("\nsetup_arch: No persistant network" //;dgt;
  9907. + " settings signature at %08lX\n", //;dgt;
  9908. + ((unsigned long) flashptr)); //;dgt;
  9909. + *((unsigned long *) //;dgt;
  9910. + (&(excalibur_enet_hwaddr_array[0]))) = //;dgt;
  9911. + 0x00ED0700; //;dgt2;
  9912. + /* 0x00-07-ED: Altera Corporation. //;dgt; */
  9913. + *((unsigned short *) //;dgt;
  9914. + (&(excalibur_enet_hwaddr_array[4]))) = //;dgt;
  9915. + 0x0000; //;dgt;
  9916. + /* Should be: 0x-00-07-ED-0A-03-(Random# 0-256) //;dgt2; */
  9917. + /* 0x-00-07-ED-0A-xx-yy Vermont boards //;dgt2; */
  9918. + /* 0x-00-07-ED-0B-xx-yy Rhode Island boards //;dgt2; */
  9919. + /* 0x-00-07-ED-0C-xx-yy Delaware boards //;dgt2; */
  9920. + /* 00 Internal Altera //;dgt2; */
  9921. + /* 01 Beta, pre-production//;dgt2; */
  9922. + /* 02 Beta, pre-production//;dgt2; */
  9923. + /* 03 Customer use //;dgt2; */
  9924. + } //;dgt;
  9925. + } //;dgt;
  9926. + #else //;dgt;
  9927. + flash_command(NIOS_FLASH_START, 0x555, 0x88);
  9928. + memcpy(excalibur_enet_hwaddr_array,(void*)NIOS_FLASH_START,6);
  9929. + exit_se_flash(NIOS_FLASH_START);;
  9930. + #endif //;dgt;
  9931. +
  9932. + /* now do the checking, make sure we got a valid addr */
  9933. + if (excalibur_enet_hwaddr_array[0] & (unsigned char)1)
  9934. + {
  9935. + printk("Ethernet hardware address:Clearing invalid bit #0\n");
  9936. + excalibur_enet_hwaddr_array[0] ^= (unsigned char)1;
  9937. + }
  9938. + excalibur_enet_hwaddr=excalibur_enet_hwaddr_array;
  9939. +#ifdef DEBUG
  9940. + printk("Setup the hardware addr for ethernet\n\t %02x %02x %02x %02x %02x %02x\n",
  9941. + excalibur_enet_hwaddr[0],excalibur_enet_hwaddr[1],
  9942. + excalibur_enet_hwaddr[2],excalibur_enet_hwaddr[3],
  9943. + excalibur_enet_hwaddr[4],excalibur_enet_hwaddr[5]);
  9944. +#endif
  9945. +#endif
  9946. +
  9947. +
  9948. + /*
  9949. + * give all the memory to the bootmap allocator, tell it to put the
  9950. + * boot mem_map at the start of memory
  9951. + */
  9952. + bootmap_size = init_bootmem_node(
  9953. + NODE_DATA(0),
  9954. + memory_start >> PAGE_SHIFT, /* map goes here */
  9955. + PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
  9956. + memory_end >> PAGE_SHIFT);
  9957. + /*
  9958. + * free the usable memory, we have to make sure we do not free
  9959. + * the bootmem bitmap so we then reserve it after freeing it :-)
  9960. + */
  9961. + free_bootmem(memory_start, memory_end - memory_start);
  9962. + reserve_bootmem(memory_start, bootmap_size);
  9963. +#ifdef CONFIG_BLK_DEV_INITRD
  9964. + if (initrd_start) reserve_bootmem(virt_to_phys((void *)initrd_start), initrd_end - initrd_start);
  9965. +#endif /* CONFIG_BLK_DEV_INITRD */
  9966. + /*
  9967. + * get kmalloc into gear
  9968. + */
  9969. + paging_init();
  9970. +#ifdef CONFIG_VT
  9971. +#if defined(CONFIG_DUMMY_CONSOLE)
  9972. + conswitchp = &dummy_con;
  9973. +#endif
  9974. +#endif
  9975. +
  9976. +#ifdef DEBUG
  9977. + printk("Done setup_arch\n");
  9978. +#endif
  9979. +
  9980. +}
  9981. +
  9982. +int get_cpuinfo(char * buffer)
  9983. +{
  9984. + char *cpu, *mmu, *fpu;
  9985. + u_long clockfreq;
  9986. +
  9987. + cpu = CPU;
  9988. + mmu = "none";
  9989. + fpu = "none";
  9990. +
  9991. + clockfreq = nasys_clock_freq;
  9992. +
  9993. + return(sprintf(buffer, "CPU:\t\t%s\n"
  9994. + "MMU:\t\t%s\n"
  9995. + "FPU:\t\t%s\n"
  9996. + "Clocking:\t%lu.%1luMHz\n"
  9997. + "BogoMips:\t%lu.%02lu\n"
  9998. + "Calibration:\t%lu loops\n",
  9999. + cpu, mmu, fpu,
  10000. + clockfreq/1000000,(clockfreq/100000)%10,
  10001. + (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
  10002. + (loops_per_jiffy*HZ)));
  10003. +
  10004. +}
  10005. +
  10006. +/*
  10007. + * Get CPU information for use by the procfs.
  10008. + */
  10009. +
  10010. +static int show_cpuinfo(struct seq_file *m, void *v)
  10011. +{
  10012. + char *cpu, *mmu, *fpu;
  10013. + u_long clockfreq;
  10014. +
  10015. + cpu = CPU;
  10016. + mmu = "none";
  10017. + fpu = "none";
  10018. +
  10019. + clockfreq = nasys_clock_freq;
  10020. +
  10021. + seq_printf(m, "CPU:\t\t%s\n"
  10022. + "MMU:\t\t%s\n"
  10023. + "FPU:\t\t%s\n"
  10024. + "Clocking:\t%lu.%1luMHz\n"
  10025. + "BogoMips:\t%lu.%02lu\n"
  10026. + "Calibration:\t%lu loops\n",
  10027. + cpu, mmu, fpu,
  10028. + clockfreq/1000000,(clockfreq/100000)%10,
  10029. + (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
  10030. + (loops_per_jiffy*HZ));
  10031. +
  10032. + return 0;
  10033. +}
  10034. +
  10035. +#ifdef CONFIG_NIOS_SPI
  10036. +
  10037. +static int bcd2char( int x )
  10038. +{
  10039. + if ( (x & 0xF) > 0x90 || (x & 0x0F) > 0x09 )
  10040. + return 99;
  10041. +
  10042. + return (((x & 0xF0) >> 4) * 10) + (x & 0x0F);
  10043. +}
  10044. +
  10045. +#endif // CONFIG_NIOS_SPI
  10046. +
  10047. +
  10048. +void arch_gettod(int *year, int *month, int *date, int *hour, int *min, int *sec)
  10049. +{
  10050. +#ifdef CONFIG_NIOS_SPI
  10051. + /********************************************************************/
  10052. + /* Read the CMOS clock on the Microtronix Datacom O/S Support card. */
  10053. + /* Use the SPI driver code, but circumvent the file system by using */
  10054. + /* its internal functions. */
  10055. + /********************************************************************/
  10056. + int hr;
  10057. +
  10058. + struct /*********************************/
  10059. + { /* The SPI payload. Warning: the */
  10060. + unsigned short register_addr; /* sizeof() operator will return */
  10061. + unsigned char value; /* a length of 4 instead of 3! */
  10062. + } spi_data; /*********************************/
  10063. +
  10064. +
  10065. + if ( spi_open( NULL, NULL ) )
  10066. + {
  10067. + printk( "Cannot open SPI driver to read system CMOS clock.\n" );
  10068. + *year = *month = *date = *hour = *min = *sec = 0;
  10069. + return;
  10070. + }
  10071. +
  10072. + spi_lseek( NULL, clockCS, 0 /* == SEEK_SET */ );
  10073. +
  10074. + spi_data.register_addr = clock_write_control;
  10075. + spi_data.value = 0x40; // Write protect
  10076. + spi_write( NULL, (const char *)&spi_data, 3, NULL );
  10077. +
  10078. + spi_data.register_addr = clock_read_sec;
  10079. + spi_data.value = 0;
  10080. + spi_read( NULL, (char *)&spi_data, 3, NULL );
  10081. + *sec = (int)bcd2char( spi_data.value );
  10082. +
  10083. + spi_data.register_addr = clock_read_min;
  10084. + spi_data.value = 0;
  10085. + spi_read( NULL, (char *)&spi_data, 3, NULL );
  10086. + *min = (int)bcd2char( spi_data.value );
  10087. +
  10088. + spi_data.register_addr = clock_read_hour;
  10089. + spi_data.value = 0;
  10090. + spi_read( NULL, (char *)&spi_data, 3, NULL );
  10091. + hr = (int)bcd2char( spi_data.value );
  10092. + if ( hr & 0x40 ) // Check 24-hr bit
  10093. + hr = (hr & 0x3F) + 12; // Convert to 24-hr
  10094. +
  10095. + *hour = hr;
  10096. +
  10097. +
  10098. +
  10099. + spi_data.register_addr = clock_read_date;
  10100. + spi_data.value = 0;
  10101. + spi_read( NULL, (char *)&spi_data, 3, NULL );
  10102. + *date = (int)bcd2char( spi_data.value );
  10103. +
  10104. + spi_data.register_addr = clock_read_month;
  10105. + spi_data.value = 0;
  10106. + spi_read( NULL, (char *)&spi_data, 3, NULL );
  10107. + *month = (int)bcd2char( spi_data.value );
  10108. +
  10109. + spi_data.register_addr = clock_read_year;
  10110. + spi_data.value = 0;
  10111. + spi_read( NULL, (char *)&spi_data, 3, NULL );
  10112. + *year = (int)bcd2char( spi_data.value );
  10113. +
  10114. +
  10115. + spi_release( NULL, NULL );
  10116. +#else
  10117. + *year = *month = *date = *hour = *min = *sec = 0;
  10118. +
  10119. +#endif
  10120. +}
  10121. +
  10122. +static void *cpuinfo_start (struct seq_file *m, loff_t *pos)
  10123. +{
  10124. + return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
  10125. +}
  10126. +
  10127. +static void *cpuinfo_next (struct seq_file *m, void *v, loff_t *pos)
  10128. +{
  10129. + ++*pos;
  10130. + return cpuinfo_start (m, pos);
  10131. +}
  10132. +
  10133. +static void cpuinfo_stop (struct seq_file *m, void *v)
  10134. +{
  10135. +}
  10136. +
  10137. +struct seq_operations cpuinfo_op = {
  10138. + start: cpuinfo_start,
  10139. + next: cpuinfo_next,
  10140. + stop: cpuinfo_stop,
  10141. + show: show_cpuinfo
  10142. +};
  10143. +
  10144. +
  10145. +// adapted from linux/arch/arm/mach-versatile/core.c and mach-bast
  10146. +// note, hardware MAC address is still undefined
  10147. +
  10148. +#if defined(CONFIG_SMC91X) && defined(na_enet)
  10149. +
  10150. +#ifndef LAN91C111_REGISTERS_OFFSET
  10151. +#define LAN91C111_REGISTERS_OFFSET 0x300
  10152. +#endif
  10153. +
  10154. +static struct resource smc91x_resources[] = {
  10155. + [0] = {
  10156. + .start = na_enet + LAN91C111_REGISTERS_OFFSET,
  10157. + .end = na_enet + LAN91C111_REGISTERS_OFFSET + 0x100 - 1, // 32bits,64k, LAN91C111_REGISTERS_OFFSET 0x0300 ?
  10158. + .flags = IORESOURCE_MEM,
  10159. + },
  10160. + [1] = {
  10161. + .start = na_enet_irq,
  10162. + .end = na_enet_irq,
  10163. + .flags = IORESOURCE_IRQ,
  10164. + },
  10165. +};
  10166. +static struct platform_device smc91x_device = {
  10167. + .name = "smc91x",
  10168. + .id = 0,
  10169. + .num_resources = ARRAY_SIZE(smc91x_resources),
  10170. + .resource = smc91x_resources,
  10171. +};
  10172. +static int __init smc91x_device_init(void)
  10173. +{
  10174. + /* customizes platform devices, or adds new ones */
  10175. + platform_device_register(&smc91x_device);
  10176. + return 0;
  10177. +}
  10178. +arch_initcall(smc91x_device_init);
  10179. +#endif // CONFIG_SMC91X
  10180. +
  10181. +
  10182. +#if defined(na_DM9000A) && !defined(na_dm9000) // defs for DE2
  10183. +#define na_dm9000 na_DM9000A
  10184. +#define na_dm9000_irq na_DM9000A_irq
  10185. +#endif
  10186. +
  10187. +#if defined(CONFIG_DM9000) && defined(na_dm9000)
  10188. +#include <linux/dm9000.h>
  10189. +static struct resource dm9k_resource[] = {
  10190. + [0] = {
  10191. + .start = na_dm9000,
  10192. + .end = na_dm9000 + 3,
  10193. + .flags = IORESOURCE_MEM,
  10194. + },
  10195. + [1] = {
  10196. + .start = na_dm9000 + 4,
  10197. + .end = na_dm9000 + 4 + 3,
  10198. + .flags = IORESOURCE_MEM,
  10199. + },
  10200. + [2] = {
  10201. + .start = na_dm9000_irq,
  10202. + .end = na_dm9000_irq,
  10203. + .flags = IORESOURCE_IRQ,
  10204. + }
  10205. +
  10206. +};
  10207. +static struct dm9000_plat_data dm9k_platdata = {
  10208. + .flags = DM9000_PLATF_16BITONLY,
  10209. +};
  10210. +static struct platform_device dm9k_device = {
  10211. + .name = "dm9000",
  10212. + .id = 0,
  10213. + .num_resources = ARRAY_SIZE(dm9k_resource),
  10214. + .resource = dm9k_resource,
  10215. + .dev = {
  10216. + .platform_data = &dm9k_platdata,
  10217. + }
  10218. +};
  10219. +static int __init dm9k_device_init(void)
  10220. +{
  10221. + /* customizes platform devices, or adds new ones */
  10222. + platform_device_register(&dm9k_device);
  10223. + return 0;
  10224. +}
  10225. +arch_initcall(dm9k_device_init);
  10226. +#endif // CONFIG_DM9000
  10227. +
  10228. +
  10229. +#if defined(CONFIG_SERIO_ALTPS2) && defined(na_ps2_0)
  10230. +
  10231. +static struct resource altps2_0_resources[] = {
  10232. + [0] = {
  10233. + .start = na_ps2_0,
  10234. + .end = na_ps2_0 + 0x8 - 1,
  10235. + .flags = IORESOURCE_MEM,
  10236. + },
  10237. + [1] = {
  10238. + .start = na_ps2_0_irq,
  10239. + .end = na_ps2_0_irq,
  10240. + .flags = IORESOURCE_IRQ,
  10241. + },
  10242. +};
  10243. +static struct platform_device altps2_0_device = {
  10244. + .name = "altps2",
  10245. + .id = 0,
  10246. + .num_resources = ARRAY_SIZE(altps2_0_resources),
  10247. + .resource = altps2_0_resources,
  10248. +};
  10249. +
  10250. +#if defined(na_ps2_1)
  10251. +static struct resource altps2_1_resources[] = {
  10252. + [0] = {
  10253. + .start = na_ps2_1,
  10254. + .end = na_ps2_1 + 0x8 - 1,
  10255. + .flags = IORESOURCE_MEM,
  10256. + },
  10257. + [1] = {
  10258. + .start = na_ps2_1_irq,
  10259. + .end = na_ps2_1_irq,
  10260. + .flags = IORESOURCE_IRQ,
  10261. + },
  10262. +};
  10263. +static struct platform_device altps2_1_device = {
  10264. + .name = "altps2",
  10265. + .id = 0,
  10266. + .num_resources = ARRAY_SIZE(altps2_1_resources),
  10267. + .resource = altps2_1_resources,
  10268. +};
  10269. +#endif // na_ps2_1
  10270. +
  10271. +static int __init altps2_device_init(void)
  10272. +{
  10273. + /* customizes platform devices, or adds new ones */
  10274. + platform_device_register(&altps2_0_device);
  10275. +#if defined(na_ps2_1)
  10276. + platform_device_register(&altps2_1_device);
  10277. +#endif // na_ps2_1
  10278. + return 0;
  10279. +}
  10280. +arch_initcall(altps2_device_init);
  10281. +#endif // CONFIG_SERIO_ALTPS2
  10282. +
  10283. +#if defined(CONFIG_I2C_NIOS2_GPIO) && defined(na_gpio_0)
  10284. +#include <asm/gpio.h>
  10285. +
  10286. +static struct gpio_i2c_pins i2c_gpio_0_pins = {
  10287. + .sda_pin = (na_gpio_0+(0<<2)),
  10288. + .scl_pin = (na_gpio_0+(1<<2)),
  10289. +};
  10290. +
  10291. +static struct platform_device i2c_gpio_0_controller = {
  10292. + .name = "GPIO-I2C",
  10293. + .id = 0,
  10294. + .dev = {
  10295. + .platform_data = &i2c_gpio_0_pins,
  10296. + },
  10297. + .num_resources = 0
  10298. +};
  10299. +
  10300. +static int __init i2c_gpio_device_init(void)
  10301. +{
  10302. + /* customizes platform devices, or adds new ones */
  10303. + platform_device_register(&i2c_gpio_0_controller);
  10304. + return 0;
  10305. +}
  10306. +arch_initcall(i2c_gpio_device_init);
  10307. +
  10308. +#endif // CONFIG_I2C_NIOS2_GPIO
  10309. diff --git a/arch/nios2nommu/kernel/signal.c b/arch/nios2nommu/kernel/signal.c
  10310. new file mode 100644
  10311. index 0000000..d8c30dc
  10312. --- /dev/null
  10313. +++ b/arch/nios2nommu/kernel/signal.c
  10314. @@ -0,0 +1,738 @@
  10315. +/*
  10316. + * linux/arch/nios2nommu/kernel/signal.c
  10317. + *
  10318. + * Copyright (C) 1991, 1992 Linus Torvalds
  10319. + * Copyright (C) 2004 Microtronix Datacom Ltd
  10320. + *
  10321. + * This file is subject to the terms and conditions of the GNU General Public
  10322. + * License. See the file COPYING in the main directory of this archive
  10323. + * for more details.
  10324. + *
  10325. + * Linux/m68k support by Hamish Macdonald
  10326. + *
  10327. + * 68060 fixes by Jesper Skov
  10328. + *
  10329. + * 1997-12-01 Modified for POSIX.1b signals by Andreas Schwab
  10330. + *
  10331. + * mathemu support by Roman Zippel
  10332. + * (Note: fpstate in the signal context is completely ignored for the emulator
  10333. + * and the internal floating point format is put on stack)
  10334. + *
  10335. + * ++roman (07/09/96): implemented signal stacks (specially for tosemu on
  10336. + * Atari :-) Current limitation: Only one sigstack can be active at one time.
  10337. + * If a second signal with SA_ONSTACK set arrives while working on a sigstack,
  10338. + * SA_ONSTACK is ignored. This behaviour avoids lots of trouble with nested
  10339. + * signal handlers!
  10340. + *
  10341. + * Jan/20/2004 dgt NiosII
  10342. + *
  10343. + */
  10344. +
  10345. +#include <linux/sched.h>
  10346. +#include <linux/mm.h>
  10347. +#include <linux/kernel.h>
  10348. +#include <linux/signal.h>
  10349. +#include <linux/errno.h>
  10350. +#include <linux/wait.h>
  10351. +#include <linux/ptrace.h>
  10352. +#include <linux/unistd.h>
  10353. +#include <linux/stddef.h>
  10354. +#include <linux/highuid.h>
  10355. +#include <linux/tty.h>
  10356. +#include <linux/personality.h>
  10357. +#include <linux/binfmts.h>
  10358. +
  10359. +#include <asm/setup.h>
  10360. +#include <asm/uaccess.h>
  10361. +#include <asm/pgtable.h>
  10362. +#include <asm/traps.h>
  10363. +#include <asm/ucontext.h>
  10364. +
  10365. +#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
  10366. +
  10367. +asmlinkage long sys_wait4(pid_t pid, unsigned int * stat_addr, int options,
  10368. + struct rusage * ru);
  10369. +asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs);
  10370. +
  10371. +/*
  10372. + * Atomically swap in the new signal mask, and wait for a signal.
  10373. + */
  10374. +asmlinkage int do_sigsuspend(struct pt_regs *regs)
  10375. +{
  10376. + old_sigset_t mask = regs->r4; // Verify correct syscall reg
  10377. + sigset_t saveset;
  10378. +
  10379. + mask &= _BLOCKABLE;
  10380. + spin_lock_irq(&current->sighand->siglock);
  10381. + saveset = current->blocked;
  10382. + siginitset(&current->blocked, mask);
  10383. + recalc_sigpending();
  10384. + spin_unlock_irq(&current->sighand->siglock);
  10385. +
  10386. + regs->r2 = -EINTR;
  10387. + while (1) {
  10388. + current->state = TASK_INTERRUPTIBLE;
  10389. + schedule();
  10390. + if (do_signal(&saveset, regs))
  10391. + return -EINTR;
  10392. + }
  10393. +}
  10394. +
  10395. +asmlinkage int
  10396. +do_rt_sigsuspend(struct pt_regs *regs)
  10397. +{
  10398. + sigset_t *unewset = (sigset_t *)regs->r4;
  10399. + size_t sigsetsize = (size_t)regs->r5;
  10400. + sigset_t saveset, newset;
  10401. +
  10402. + /* XXX: Don't preclude handling different sized sigset_t's. */
  10403. + if (sigsetsize != sizeof(sigset_t))
  10404. + return -EINVAL;
  10405. +
  10406. + if (copy_from_user(&newset, unewset, sizeof(newset)))
  10407. + return -EFAULT;
  10408. + sigdelsetmask(&newset, ~_BLOCKABLE);
  10409. +
  10410. + spin_lock_irq(&current->sighand->siglock);
  10411. + saveset = current->blocked;
  10412. + current->blocked = newset;
  10413. + recalc_sigpending();
  10414. + spin_unlock_irq(&current->sighand->siglock);
  10415. +
  10416. + regs->r2 = -EINTR;
  10417. + while (1) {
  10418. + current->state = TASK_INTERRUPTIBLE;
  10419. + schedule();
  10420. + if (do_signal(&saveset, regs))
  10421. + return -EINTR;
  10422. + }
  10423. +}
  10424. +
  10425. +asmlinkage int
  10426. +sys_sigaction(int sig, const struct old_sigaction *act,
  10427. + struct old_sigaction *oact)
  10428. +{
  10429. + struct k_sigaction new_ka, old_ka;
  10430. + int ret;
  10431. +
  10432. + if (act) {
  10433. + old_sigset_t mask;
  10434. + if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
  10435. + __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
  10436. + __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
  10437. + return -EFAULT;
  10438. + __get_user(new_ka.sa.sa_flags, &act->sa_flags);
  10439. + __get_user(mask, &act->sa_mask);
  10440. + siginitset(&new_ka.sa.sa_mask, mask);
  10441. + }
  10442. +
  10443. + ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
  10444. +
  10445. + if (!ret && oact) {
  10446. + if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
  10447. + __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
  10448. + __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
  10449. + return -EFAULT;
  10450. + __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
  10451. + __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
  10452. + }
  10453. +
  10454. + return ret;
  10455. +}
  10456. +
  10457. +/*
  10458. + * Do a signal return; undo the signal stack.
  10459. + *
  10460. + * Keep the return code on the stack quadword aligned!
  10461. + * That makes the cache flush below easier.
  10462. + */
  10463. +
  10464. +
  10465. +struct sigframe
  10466. +{
  10467. + char retcode[12];
  10468. + unsigned long extramask[_NSIG_WORDS-1];
  10469. + struct sigcontext sc;
  10470. +};
  10471. +
  10472. +struct rt_sigframe
  10473. +{
  10474. + char retcode[12];
  10475. + struct siginfo info;
  10476. + struct ucontext uc;
  10477. +};
  10478. +
  10479. +#ifdef CONFIG_FPU
  10480. +
  10481. +static unsigned char fpu_version = 0; /* version number of fpu, set by setup_frame */
  10482. +
  10483. +static inline int restore_fpu_state(struct sigcontext *sc)
  10484. +{
  10485. + int err = 1;
  10486. +
  10487. + if (FPU_IS_EMU) {
  10488. + /* restore registers */
  10489. + memcpy(current->thread.fpcntl, sc->sc_fpcntl, 12);
  10490. + memcpy(current->thread.fp, sc->sc_fpregs, 24);
  10491. + return 0;
  10492. + }
  10493. +
  10494. + if (sc->sc_fpstate[0]) {
  10495. + /* Verify the frame format. */
  10496. + if (sc->sc_fpstate[0] != fpu_version)
  10497. + goto out;
  10498. +
  10499. + __asm__ volatile ("Nios II FPU"
  10500. + : /* no outputs */
  10501. + : );
  10502. + }
  10503. + __asm__ volatile ("Nios II FPU"
  10504. + : : );
  10505. + err = 0;
  10506. +
  10507. +out:
  10508. + return err;
  10509. +}
  10510. +
  10511. +#define FPCONTEXT_SIZE 216
  10512. +#define uc_fpstate uc_filler[0]
  10513. +#define uc_formatvec uc_filler[FPCONTEXT_SIZE/4]
  10514. +#define uc_extra uc_filler[FPCONTEXT_SIZE/4+1]
  10515. +
  10516. +static inline int rt_restore_fpu_state(struct ucontext *uc)
  10517. +{
  10518. + unsigned char fpstate[FPCONTEXT_SIZE];
  10519. + int context_size = 0;
  10520. + fpregset_t fpregs;
  10521. + int err = 1;
  10522. +
  10523. + if (FPU_IS_EMU) {
  10524. + /* restore fpu control register */
  10525. + if (__copy_from_user(current->thread.fpcntl,
  10526. + &uc->uc_mcontext.fpregs.f_pcr, 12))
  10527. + goto out;
  10528. + /* restore all other fpu register */
  10529. + if (__copy_from_user(current->thread.fp,
  10530. + uc->uc_mcontext.fpregs.f_fpregs, 96))
  10531. + goto out;
  10532. + return 0;
  10533. + }
  10534. +
  10535. + if (__get_user(*(long *)fpstate, (long *)&uc->uc_fpstate))
  10536. + goto out;
  10537. + if (fpstate[0]) {
  10538. + context_size = fpstate[1];
  10539. +
  10540. + /* Verify the frame format. */
  10541. + if (fpstate[0] != fpu_version)
  10542. + goto out;
  10543. + if (__copy_from_user(&fpregs, &uc->uc_mcontext.fpregs,
  10544. + sizeof(fpregs)))
  10545. + goto out;
  10546. + __asm__ volatile ("Nios II FPU"
  10547. + : /* no outputs */
  10548. + : );
  10549. + }
  10550. + if (context_size &&
  10551. + __copy_from_user(fpstate + 4, (long *)&uc->uc_fpstate + 1,
  10552. + context_size))
  10553. + goto out;
  10554. + __asm__ volatile ("Nios II FPU"
  10555. + : : );
  10556. + err = 0;
  10557. +
  10558. +out:
  10559. + return err;
  10560. +}
  10561. +
  10562. +#endif
  10563. +
  10564. +static inline int
  10565. +restore_sigcontext(struct pt_regs *regs, struct sigcontext *usc, void *fp,
  10566. + int *pr2)
  10567. +{
  10568. + int err = 0;
  10569. + int estatus;
  10570. +
  10571. + estatus = regs->estatus;
  10572. +
  10573. + /* get previous pt_regs */
  10574. + if (copy_from_user(regs, &usc->regs, sizeof(*regs)))
  10575. + goto badframe;
  10576. +
  10577. + /* Prevent user from being able to change
  10578. + * certain processor status bits. Currently nothing.
  10579. + */
  10580. + regs->estatus = (estatus & 0xffffffff) | (regs->estatus & 0);
  10581. +
  10582. + *pr2 = regs->r2;
  10583. + regs->orig_r2 = -1; /* disable syscall checks */
  10584. +
  10585. +#ifdef CONFIG_FPU
  10586. + err |= restore_fpu_state(&context);
  10587. +#endif
  10588. +
  10589. + return err;
  10590. +
  10591. +badframe:
  10592. + return 1;
  10593. +}
  10594. +
  10595. +static inline int
  10596. +rt_restore_ucontext(struct pt_regs *regs, struct switch_stack *sw,
  10597. + struct ucontext *uc, int *pr2)
  10598. +{
  10599. + int temp;
  10600. + greg_t *gregs = uc->uc_mcontext.gregs;
  10601. + unsigned long usp;
  10602. + int err;
  10603. +
  10604. + err = __get_user(temp, &uc->uc_mcontext.version);
  10605. + if (temp != MCONTEXT_VERSION)
  10606. + goto badframe;
  10607. + /* restore passed registers */
  10608. + err |= __get_user(regs->r1, &gregs[0]);
  10609. + err |= __get_user(regs->r2, &gregs[1]);
  10610. + err |= __get_user(regs->r3, &gregs[2]);
  10611. + err |= __get_user(regs->r4, &gregs[3]);
  10612. + err |= __get_user(regs->r5, &gregs[4]);
  10613. + err |= __get_user(regs->r6, &gregs[5]);
  10614. + err |= __get_user(regs->r7, &gregs[6]);
  10615. + err |= __get_user(regs->r8, &gregs[7]);
  10616. + err |= __get_user(regs->r9, &gregs[8]);
  10617. + err |= __get_user(regs->r10, &gregs[9]);
  10618. + err |= __get_user(regs->r11, &gregs[10]);
  10619. + err |= __get_user(regs->r12, &gregs[11]);
  10620. + err |= __get_user(regs->r13, &gregs[12]);
  10621. + err |= __get_user(regs->r14, &gregs[13]);
  10622. + err |= __get_user(regs->r15, &gregs[14]);
  10623. + err |= __get_user(sw->r16, &gregs[15]);
  10624. + err |= __get_user(sw->r17, &gregs[16]);
  10625. + err |= __get_user(sw->r18, &gregs[17]);
  10626. + err |= __get_user(sw->r19, &gregs[18]);
  10627. + err |= __get_user(sw->r20, &gregs[19]);
  10628. + err |= __get_user(sw->r21, &gregs[20]);
  10629. + err |= __get_user(sw->r22, &gregs[21]);
  10630. + err |= __get_user(sw->r23, &gregs[22]);
  10631. + err |= __get_user(usp, &gregs[23]);
  10632. + err |= __get_user(sw->fp, &gregs[24]); // Verify, should this be settable
  10633. + err |= __get_user(sw->gp, &gregs[25]); // Verify, should this be settable
  10634. +
  10635. + err |= __get_user(temp, &gregs[26]); // Not really necessary no user settable bits
  10636. + regs->estatus = (regs->estatus & 0xffffffff) | (temp & 0x0);
  10637. + err |= __get_user(regs->status_extension,
  10638. + &uc->uc_mcontext.status_extension);
  10639. + regs->orig_r2 = -1; /* disable syscall checks */
  10640. +
  10641. + if (do_sigaltstack(&uc->uc_stack, NULL, usp) == -EFAULT)
  10642. + goto badframe;
  10643. +
  10644. + *pr2 = regs->r2;
  10645. + return err;
  10646. +
  10647. +badframe:
  10648. + return 1;
  10649. +}
  10650. +
  10651. +asmlinkage int do_sigreturn(struct pt_regs *regs)
  10652. +{
  10653. + struct sigframe *frame = (struct sigframe *) regs->sp;
  10654. + sigset_t set;
  10655. + int rval;
  10656. +
  10657. + if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
  10658. + goto badframe;
  10659. + if (__get_user(set.sig[0], &frame->sc.sc_mask) ||
  10660. + (_NSIG_WORDS > 1 &&
  10661. + __copy_from_user(&set.sig[1], &frame->extramask,
  10662. + sizeof(frame->extramask))))
  10663. + goto badframe;
  10664. +
  10665. + sigdelsetmask(&set, ~_BLOCKABLE);
  10666. + spin_lock_irq(&current->sighand->siglock);
  10667. + current->blocked = set;
  10668. + recalc_sigpending();
  10669. + spin_unlock_irq(&current->sighand->siglock);
  10670. +
  10671. + if (restore_sigcontext(regs, &frame->sc, frame + 1, &rval))
  10672. + goto badframe;
  10673. + return rval;
  10674. +
  10675. +badframe:
  10676. + force_sig(SIGSEGV, current);
  10677. + return 0;
  10678. +}
  10679. +
  10680. +asmlinkage int do_rt_sigreturn(struct switch_stack *sw)
  10681. +{
  10682. + struct pt_regs *regs = (struct pt_regs *) sw + 1;
  10683. + struct rt_sigframe *frame = (struct rt_sigframe *) regs->sp; // Verify, can we follow the stack back
  10684. + sigset_t set;
  10685. + int rval;
  10686. +
  10687. + if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
  10688. + goto badframe;
  10689. + if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
  10690. + goto badframe;
  10691. +
  10692. + sigdelsetmask(&set, ~_BLOCKABLE);
  10693. + spin_lock_irq(&current->sighand->siglock);
  10694. + current->blocked = set;
  10695. + recalc_sigpending();
  10696. + spin_unlock_irq(&current->sighand->siglock);
  10697. +
  10698. + if (rt_restore_ucontext(regs, sw, &frame->uc, &rval))
  10699. + goto badframe;
  10700. + return rval;
  10701. +
  10702. +badframe:
  10703. + force_sig(SIGSEGV, current);
  10704. + return 0;
  10705. +}
  10706. +
  10707. +#ifdef CONFIG_FPU
  10708. +/*
  10709. + * Set up a signal frame.
  10710. + *
  10711. + * Not converted, no FPU support at moment.
  10712. + */
  10713. +
  10714. +static inline int save_fpu_state(struct sigcontext *sc, struct pt_regs *regs)
  10715. +{
  10716. + int err = 0;
  10717. +
  10718. + if (FPU_IS_EMU) {
  10719. + /* save registers */
  10720. + err |= copy_to_user(&sc->sc_fpcntl, current->thread.fpcntl, 12);
  10721. + err |= copy_to_user(&sc->sc_fpregs, current->thread.fp, 24);
  10722. + return err;
  10723. + }
  10724. +
  10725. + __asm__ volatile ("Nios II FPUt"
  10726. + : : );
  10727. +
  10728. + if (sc->sc_fpstate[0]) {
  10729. + fpu_version = sc->sc_fpstate[0];
  10730. + __asm__ volatile ("Nios II FPU"
  10731. + : /* no outputs */
  10732. + :
  10733. + : );
  10734. + }
  10735. + return err;
  10736. +}
  10737. +
  10738. +static inline int rt_save_fpu_state(struct ucontext *uc, struct pt_regs *regs)
  10739. +{
  10740. + unsigned char fpstate[FPCONTEXT_SIZE];
  10741. + int context_size = 0;
  10742. + int err = 0;
  10743. +
  10744. + if (FPU_IS_EMU) {
  10745. + /* save fpu control register */
  10746. + err |= copy_to_user(&uc->uc_mcontext.fpregs.f_pcr,
  10747. + current->thread.fpcntl, 12);
  10748. + /* save all other fpu register */
  10749. + err |= copy_to_user(uc->uc_mcontext.fpregs.f_fpregs,
  10750. + current->thread.fp, 96);
  10751. + return err;
  10752. + }
  10753. +
  10754. + __asm__ volatile ("Nios II FPU"
  10755. + : : : );
  10756. +
  10757. + err |= __put_user(*(long *)fpstate, (long *)&uc->uc_fpstate);
  10758. + if (fpstate[0]) {
  10759. + fpregset_t fpregs;
  10760. + context_size = fpstate[1];
  10761. + fpu_version = fpstate[0];
  10762. + __asm__ volatile ("Nios II FPU"
  10763. + : /* no outputs */
  10764. + :
  10765. + : );
  10766. + err |= copy_to_user(&uc->uc_mcontext.fpregs, &fpregs,
  10767. + sizeof(fpregs));
  10768. + }
  10769. + if (context_size)
  10770. + err |= copy_to_user((long *)&uc->uc_fpstate + 1, fpstate + 4,
  10771. + context_size);
  10772. + return err;
  10773. +}
  10774. +
  10775. +#endif
  10776. +
  10777. +static int setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
  10778. + unsigned long mask)
  10779. +{
  10780. + int err = 0;
  10781. +
  10782. + err |= __put_user(mask, &sc->sc_mask);
  10783. + err |= copy_to_user(&sc->regs, regs, sizeof(*regs));
  10784. +#ifdef CONFIG_FPU
  10785. + err |= save_fpu_state(sc, regs);
  10786. +#endif
  10787. + return err;
  10788. +}
  10789. +
  10790. +static inline int rt_setup_ucontext(struct ucontext *uc, struct pt_regs *regs)
  10791. +{
  10792. + struct switch_stack *sw = (struct switch_stack *)regs - 1;
  10793. + greg_t *gregs = uc->uc_mcontext.gregs;
  10794. + int err = 0;
  10795. +
  10796. + err |= __put_user(MCONTEXT_VERSION, &uc->uc_mcontext.version);
  10797. + err |= __put_user(regs->status_extension,
  10798. + &uc->uc_mcontext.status_extension);
  10799. + err |= __put_user(regs->r1, &gregs[0]);
  10800. + err |= __put_user(regs->r2, &gregs[1]);
  10801. + err |= __put_user(regs->r3, &gregs[2]);
  10802. + err |= __put_user(regs->r4, &gregs[3]);
  10803. + err |= __put_user(regs->r5, &gregs[4]);
  10804. + err |= __put_user(regs->r6, &gregs[5]);
  10805. + err |= __put_user(regs->r7, &gregs[6]);
  10806. + err |= __put_user(regs->r8, &gregs[7]);
  10807. + err |= __put_user(regs->r9, &gregs[8]);
  10808. + err |= __put_user(regs->r10, &gregs[9]);
  10809. + err |= __put_user(regs->r11, &gregs[10]);
  10810. + err |= __put_user(regs->r12, &gregs[11]);
  10811. + err |= __put_user(regs->r13, &gregs[12]);
  10812. + err |= __put_user(regs->r14, &gregs[13]);
  10813. + err |= __put_user(regs->r15, &gregs[14]);
  10814. + err |= __put_user(sw->r16, &gregs[15]);
  10815. + err |= __put_user(sw->r17, &gregs[16]);
  10816. + err |= __put_user(sw->r18, &gregs[17]);
  10817. + err |= __put_user(sw->r19, &gregs[18]);
  10818. + err |= __put_user(sw->r20, &gregs[19]);
  10819. + err |= __put_user(sw->r21, &gregs[20]);
  10820. + err |= __put_user(sw->r22, &gregs[21]);
  10821. + err |= __put_user(sw->r23, &gregs[22]);
  10822. + err |= __put_user(regs->sp, &gregs[23]);
  10823. + err |= __put_user(sw->fp, &gregs[24]);
  10824. + err |= __put_user(sw->gp, &gregs[25]);
  10825. +#ifdef CONFIG_FPU
  10826. + err |= rt_save_fpu_state(uc, regs);
  10827. +#endif
  10828. + return err;
  10829. +}
  10830. +
  10831. +extern void cache_push_v (unsigned long vaddr, int len);
  10832. +
  10833. +static inline void push_cache (unsigned long vaddr)
  10834. +{
  10835. + cache_push_v(vaddr,12);
  10836. +}
  10837. +
  10838. +static inline void *
  10839. +get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
  10840. +{
  10841. + unsigned long usp;
  10842. +
  10843. + /* Default to using normal stack. */
  10844. + usp = regs->sp;
  10845. +
  10846. + /* This is the X/Open sanctioned signal stack switching. */
  10847. + if (ka->sa.sa_flags & SA_ONSTACK) {
  10848. + if (!on_sig_stack(usp))
  10849. + usp = current->sas_ss_sp + current->sas_ss_size;
  10850. + }
  10851. + return (void *)((usp - frame_size) & -8UL); // Verify, is it 32 or 64 bit aligned
  10852. +}
  10853. +
  10854. +static void setup_frame (int sig, struct k_sigaction *ka,
  10855. + sigset_t *set, struct pt_regs *regs)
  10856. +{
  10857. + struct sigframe *frame;
  10858. + int err = 0;
  10859. +
  10860. + frame = get_sigframe(ka, regs, sizeof(*frame));
  10861. +
  10862. + if (_NSIG_WORDS > 1)
  10863. + err |= copy_to_user(frame->extramask, &set->sig[1],
  10864. + sizeof(frame->extramask));
  10865. +
  10866. + err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
  10867. +
  10868. + /* Set up to return from userspace. */
  10869. + regs->ra = (unsigned long) &frame->retcode[0];
  10870. + /* movi r3,__NR_sigreturn */
  10871. + err |= __put_user(0x00c00004 + (__NR_sigreturn << 6), (long *)(frame->retcode));
  10872. + /* mov r2,r0 */
  10873. + err |= __put_user(0x0005883a, (long *)(frame->retcode + 4));
  10874. + /* trap */
  10875. + err |= __put_user(0x003b683a, (long *)(frame->retcode + 8));
  10876. +
  10877. + if (err)
  10878. + goto give_sigsegv;
  10879. +
  10880. + push_cache ((unsigned long) &frame->retcode);
  10881. +
  10882. + /* Set up registers for signal handler */
  10883. + regs->sp = (unsigned long) frame;
  10884. + regs->r4 = (unsigned long) (current_thread_info()->exec_domain
  10885. + && current_thread_info()->exec_domain->signal_invmap
  10886. + && sig < 32
  10887. + ? current_thread_info()->exec_domain->signal_invmap[sig]
  10888. + : sig);
  10889. + regs->ea = (unsigned long) ka->sa.sa_handler;
  10890. + return;
  10891. +
  10892. +give_sigsegv:
  10893. + if (sig == SIGSEGV)
  10894. + ka->sa.sa_handler = SIG_DFL;
  10895. + force_sig(SIGSEGV, current);
  10896. +}
  10897. +
  10898. +static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
  10899. + sigset_t *set, struct pt_regs *regs)
  10900. +{
  10901. + struct rt_sigframe *frame;
  10902. + int err = 0;
  10903. +
  10904. + frame = get_sigframe(ka, regs, sizeof(*frame));
  10905. +
  10906. + err |= copy_siginfo_to_user(&frame->info, info);
  10907. +
  10908. + /* Create the ucontext. */
  10909. + err |= __put_user(0, &frame->uc.uc_flags);
  10910. + err |= __put_user(0, &frame->uc.uc_link);
  10911. + err |= __put_user((void *)current->sas_ss_sp,
  10912. + &frame->uc.uc_stack.ss_sp);
  10913. + err |= __put_user(sas_ss_flags(regs->sp),
  10914. + &frame->uc.uc_stack.ss_flags);
  10915. + err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
  10916. + err |= rt_setup_ucontext(&frame->uc, regs);
  10917. + err |= copy_to_user (&frame->uc.uc_sigmask, set, sizeof(*set));
  10918. +
  10919. + /* Set up to return from userspace. */
  10920. + regs->ra = (unsigned long) &frame->retcode[0];
  10921. + /* movi r3,__NR_rt_sigreturn */
  10922. + err |= __put_user(0x00c00004 + (__NR_rt_sigreturn << 6), (long *)(frame->retcode));
  10923. + /* mov r2,r0 */
  10924. + err |= __put_user(0x0005883a, (long *)(frame->retcode + 4));
  10925. + /* trap */
  10926. + err |= __put_user(0x003b683a, (long *)(frame->retcode + 8));
  10927. +
  10928. + if (err)
  10929. + goto give_sigsegv;
  10930. +
  10931. + push_cache ((unsigned long) &frame->retcode);
  10932. +
  10933. + /* Set up registers for signal handler */
  10934. + regs->sp = (unsigned long) frame;
  10935. + regs->r4 = (unsigned long) (current_thread_info()->exec_domain
  10936. + && current_thread_info()->exec_domain->signal_invmap
  10937. + && sig < 32
  10938. + ? current_thread_info()->exec_domain->signal_invmap[sig]
  10939. + : sig);
  10940. + regs->r5 = (unsigned long) &frame->info;
  10941. + regs->r6 = (unsigned long) &frame->uc;
  10942. + regs->ea = (unsigned long) ka->sa.sa_handler;
  10943. + return;
  10944. +
  10945. +give_sigsegv:
  10946. + if (sig == SIGSEGV)
  10947. + ka->sa.sa_handler = SIG_DFL;
  10948. + force_sig(SIGSEGV, current);
  10949. +}
  10950. +
  10951. +static inline void
  10952. +handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
  10953. +{
  10954. + switch (regs->r2) {
  10955. + case -ERESTARTNOHAND:
  10956. + if (!has_handler)
  10957. + goto do_restart;
  10958. + regs->r2 = -EINTR;
  10959. + break;
  10960. +
  10961. + case -ERESTARTSYS:
  10962. + if (has_handler && !(ka->sa.sa_flags & SA_RESTART)) {
  10963. + regs->r2 = -EINTR;
  10964. + break;
  10965. + }
  10966. + /* fallthrough */
  10967. + case -ERESTARTNOINTR:
  10968. + do_restart:
  10969. + regs->r2 = regs->orig_r2;
  10970. + regs->ea -= 4;
  10971. + break;
  10972. + }
  10973. +}
  10974. +
  10975. +/*
  10976. + * OK, we're invoking a handler
  10977. + */
  10978. +static void
  10979. +handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
  10980. + sigset_t *oldset, struct pt_regs *regs)
  10981. +{
  10982. + /* are we from a system call? */
  10983. + if (regs->orig_r2 >= 0)
  10984. + /* If so, check system call restarting.. */
  10985. + handle_restart(regs, ka, 1);
  10986. +
  10987. + /* set up the stack frame */
  10988. + if (ka->sa.sa_flags & SA_SIGINFO)
  10989. + setup_rt_frame(sig, ka, info, oldset, regs);
  10990. + else
  10991. + setup_frame(sig, ka, oldset, regs);
  10992. +
  10993. + if (ka->sa.sa_flags & SA_ONESHOT)
  10994. + ka->sa.sa_handler = SIG_DFL;
  10995. +
  10996. + if (!(ka->sa.sa_flags & SA_NODEFER)) {
  10997. + spin_lock_irq(&current->sighand->siglock);
  10998. + sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
  10999. + sigaddset(&current->blocked,sig);
  11000. + recalc_sigpending();
  11001. + spin_unlock_irq(&current->sighand->siglock);
  11002. + }
  11003. +}
  11004. +
  11005. +/*
  11006. + * Note that 'init' is a special process: it doesn't get signals it doesn't
  11007. + * want to handle. Thus you cannot kill init even with a SIGKILL even by
  11008. + * mistake.
  11009. + */
  11010. +asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs)
  11011. +{
  11012. + struct k_sigaction ka;
  11013. + siginfo_t info;
  11014. + int signr;
  11015. +
  11016. + /*
  11017. + * We want the common case to go fast, which
  11018. + * is why we may in certain cases get here from
  11019. + * kernel mode. Just return without doing anything
  11020. + * if so.
  11021. + */
  11022. + if (!user_mode(regs))
  11023. + return 1;
  11024. +
  11025. + /* FIXME - Do we still need to do this ? */
  11026. + current->thread.kregs = regs;
  11027. +
  11028. + if (!oldset)
  11029. + oldset = &current->blocked;
  11030. +
  11031. + signr = get_signal_to_deliver(&info, &ka, regs, NULL);
  11032. + if (signr > 0) {
  11033. + /* Whee! Actually deliver the signal. */
  11034. + handle_signal(signr, &ka, &info, oldset, regs);
  11035. + return 1;
  11036. + }
  11037. +
  11038. + /* Did we come from a system call? */
  11039. + if (regs->orig_r2 >= 0){
  11040. + /* Restart the system call - no handlers present */
  11041. + if (regs->r2 == -ERESTARTNOHAND
  11042. + || regs->r2 == -ERESTARTSYS
  11043. + || regs->r2 == -ERESTARTNOINTR) {
  11044. + regs->r2 = regs->orig_r2;
  11045. + regs->ea -= 4;
  11046. + } else if (regs->r2 == -ERESTART_RESTARTBLOCK) {
  11047. + regs->r2 = __NR_restart_syscall;
  11048. + regs->ea -= 4;
  11049. + }
  11050. + }
  11051. + return 0;
  11052. +}
  11053. diff --git a/arch/nios2nommu/kernel/start.c b/arch/nios2nommu/kernel/start.c
  11054. new file mode 100644
  11055. index 0000000..bca81fc
  11056. --- /dev/null
  11057. +++ b/arch/nios2nommu/kernel/start.c
  11058. @@ -0,0 +1,502 @@
  11059. +/*--------------------------------------------------------------------
  11060. + *
  11061. + * arch/nios2nommu/kernel/start.c
  11062. + *
  11063. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  11064. + *
  11065. + * Copyright (C) 2004 Microtronix Datacom Ltd
  11066. + *
  11067. + * This program is free software; you can redistribute it and/or modify
  11068. + * it under the terms of the GNU General Public License as published by
  11069. + * the Free Software Foundation; either version 2 of the License, or
  11070. + * (at your option) any later version.
  11071. + *
  11072. + * This program is distributed in the hope that it will be useful,
  11073. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11074. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11075. + * GNU General Public License for more details.
  11076. + *
  11077. + *
  11078. + * Jan/20/2004 dgt NiosII
  11079. + * May/20/2005 dgt Altera NiosII Custom shift instr(s)
  11080. + * possibly assumed by memcpy, etc; ensure
  11081. + * "correct" core loaded therefore if so.
  11082. + *
  11083. + ---------------------------------------------------------------------*/
  11084. +
  11085. +
  11086. +#include <asm/system.h>
  11087. +#include <asm/nios.h>
  11088. +#include <linux/kernel.h>
  11089. +#include <linux/ctype.h>
  11090. +#include <linux/string.h>
  11091. +#include <linux/time.h>
  11092. +#include <linux/start_kernel.h>
  11093. +
  11094. + #ifdef CONFIG_SERIAL_AJUART //;dgt;20may05;
  11095. + #ifdef CONFIG_SERIAL_AJUART_CONSOLE //;dgt;20may05;
  11096. +
  11097. + #include <linux/console.h> //;dgt;20may05;
  11098. + #include <asm/altera_juart.h> //;dgt;20may05;
  11099. +
  11100. + extern struct console juart_console; //;dgt;20may05;
  11101. +
  11102. + #endif // CONFIG_SERIAL_AJUART //;dgt;20may05;
  11103. + #endif // CONFIG_SERIAL_AJUART_CONSOLE //;dgt;20may05;
  11104. +
  11105. +//;dgt;20may05; #ifdef CONFIG_CRC_CHECK
  11106. +
  11107. +// #if defined(CONFIG_NIOS_SERIAL) //;dgt;20may05;
  11108. +// #if defined(CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;20may05;
  11109. + #if defined(nasys_printf_uart) //;dgt;20may05;
  11110. + static void putsNoNewLine( unsigned char *s )
  11111. + {
  11112. + while(*s) {
  11113. + while (!(nasys_printf_uart->np_uartstatus &
  11114. + np_uartstatus_trdy_mask));
  11115. + nasys_printf_uart->np_uarttxdata = *s++;
  11116. + }
  11117. + }
  11118. +
  11119. + #define NL "\r\n"
  11120. + static void puts(unsigned char *s)
  11121. + {
  11122. + putsNoNewLine( s );
  11123. + putsNoNewLine( NL );
  11124. + }
  11125. + #endif // nasys_printf_uart //;dgt;20may05;
  11126. +// #endif // CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;20may05;
  11127. +// #endif // CONFIG_NIOS_SERIAL) //;dgt;20may05;
  11128. +
  11129. +#ifdef CONFIG_CRC_CHECK //;dgt;20may05;
  11130. +
  11131. +#if 1
  11132. +#define outchar(X) { \
  11133. + while (!(nasys_printf_uart->np_uartstatus & np_uartstatus_trdy_mask)); \
  11134. + nasys_printf_uart->np_uarttxdata = (X); }
  11135. +#else
  11136. +#define outchar(X) putchar(X)
  11137. +#endif
  11138. +#define outhex(X,Y) { \
  11139. + unsigned long __w; \
  11140. + __w = ((X) >> (Y)) & 0xf; \
  11141. + __w = __w > 0x9 ? 'A' + __w - 0xa : '0' + __w; \
  11142. + outchar(__w); }
  11143. +#define outhex8(X) { \
  11144. + outhex(X,4); \
  11145. + outhex(X,0); }
  11146. +#define outhex16(X) { \
  11147. + outhex(X,12); \
  11148. + outhex(X,8); \
  11149. + outhex(X,4); \
  11150. + outhex(X,0); }
  11151. +#define outhex32(X) { \
  11152. + outhex(X,28); \
  11153. + outhex(X,24); \
  11154. + outhex(X,20); \
  11155. + outhex(X,16); \
  11156. + outhex(X,12); \
  11157. + outhex(X,8); \
  11158. + outhex(X,4); \
  11159. + outhex(X,0); }
  11160. +#endif
  11161. +
  11162. +#if 0
  11163. +static unsigned long testvar = 0xdeadbeef;
  11164. +#endif
  11165. +
  11166. +#ifdef CONFIG_CRC_CHECK
  11167. +
  11168. +
  11169. +/******************************************************/
  11170. +
  11171. +
  11172. +extern unsigned long __CRC_Table_Begin;
  11173. +
  11174. +typedef unsigned char U8;
  11175. +typedef unsigned long U32;
  11176. +
  11177. +/* Table of CRC-32's of all single byte values */
  11178. +const U32 crc_32_tab[] = {
  11179. + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
  11180. + 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
  11181. + 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
  11182. + 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
  11183. + 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
  11184. + 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
  11185. + 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
  11186. + 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
  11187. + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
  11188. + 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
  11189. + 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
  11190. + 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
  11191. + 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
  11192. + 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
  11193. + 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
  11194. + 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
  11195. + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
  11196. + 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
  11197. + 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
  11198. + 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
  11199. + 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
  11200. + 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
  11201. + 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
  11202. + 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
  11203. + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
  11204. + 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
  11205. + 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
  11206. + 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
  11207. + 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
  11208. + 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
  11209. + 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
  11210. + 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
  11211. + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
  11212. + 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
  11213. + 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
  11214. + 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
  11215. + 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
  11216. + 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
  11217. + 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
  11218. + 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
  11219. + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
  11220. + 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
  11221. + 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
  11222. + 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
  11223. + 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
  11224. + 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
  11225. + 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
  11226. + 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
  11227. + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
  11228. + 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
  11229. + 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
  11230. + 0x2d02ef8dL
  11231. +};
  11232. +
  11233. +U32 Calc_CRC( const U8 *p, U32 len )
  11234. +{
  11235. + U32 crc = (U32)~0L;
  11236. + while (len--)
  11237. + crc = crc_32_tab[0xFF & (crc ^ *p++)] ^ (crc >> 8);
  11238. +
  11239. + return crc ^ (U32)~0L;
  11240. +}
  11241. +
  11242. +
  11243. +
  11244. +/******************************************************/
  11245. +
  11246. +
  11247. +/* hjz: Following time stuff is hacked and modified from uC-libc (various files), which in turn was... */
  11248. +/* This is adapted from glibc */
  11249. +/* Copyright (C) 1991, 1993 Free Software Foundation, Inc */
  11250. +
  11251. +#define SECS_PER_HOUR 3600L
  11252. +#define SECS_PER_DAY 86400L
  11253. +typedef unsigned long time_t;
  11254. +
  11255. +
  11256. +static const unsigned short int __mon_lengths[2][12] = {
  11257. + /* Normal years. */
  11258. + {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
  11259. + /* Leap years. */
  11260. + {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
  11261. +};
  11262. +/* This global is exported to the wide world in keeping
  11263. + * with the interface in time.h */
  11264. +long int timezone = 0;
  11265. +
  11266. +static const char *dayOfWeek[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
  11267. +static const char *month[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  11268. + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
  11269. +
  11270. +/* Nonzero if YEAR is a leap year (every 4 years,
  11271. + except every 100th isn't, and every 400th is). */
  11272. +# define __isleap(year) ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
  11273. +
  11274. +struct tm
  11275. +{
  11276. + int tm_sec; /* Seconds. [0-60] (1 leap second) */
  11277. + int tm_min; /* Minutes. [0-59] */
  11278. + int tm_hour; /* Hours. [0-23] */
  11279. + int tm_mday; /* Day. [1-31] */
  11280. + int tm_mon; /* Month. [0-11] */
  11281. + int tm_year; /* Year - 1900. */
  11282. + int tm_wday; /* Day of week. [0-6] */
  11283. + int tm_yday; /* Days in year.[0-365] */
  11284. + int tm_isdst; /* DST. [-1/0/1]*/
  11285. +
  11286. +# ifdef __USE_BSD
  11287. + long int tm_gmtoff; /* Seconds east of UTC. */
  11288. + __const char *tm_zone; /* Timezone abbreviation. */
  11289. +# else
  11290. + long int __tm_gmtoff; /* Seconds east of UTC. */
  11291. + __const char *__tm_zone; /* Timezone abbreviation. */
  11292. +# endif
  11293. +};
  11294. +
  11295. +void __tm_conv(struct tm *tmbuf, time_t *t, time_t offset)
  11296. +{
  11297. + long days, rem;
  11298. + register int y;
  11299. + register const unsigned short int *ip;
  11300. +
  11301. + timezone = -offset;
  11302. +
  11303. + days = *t / SECS_PER_DAY;
  11304. + rem = *t % SECS_PER_DAY;
  11305. + rem += offset;
  11306. + while (rem < 0)
  11307. + {
  11308. + rem += SECS_PER_DAY;
  11309. + days--;
  11310. + }
  11311. + while (rem >= SECS_PER_DAY)
  11312. + {
  11313. + rem -= SECS_PER_DAY;
  11314. + days++;
  11315. + }
  11316. +
  11317. + tmbuf->tm_hour = rem / SECS_PER_HOUR;
  11318. + rem %= SECS_PER_HOUR;
  11319. + tmbuf->tm_min = rem / 60;
  11320. + tmbuf->tm_sec = rem % 60;
  11321. +
  11322. + /* January 1, 1970 was a Thursday. */
  11323. + tmbuf->tm_wday = (4 + days) % 7;
  11324. + if (tmbuf->tm_wday < 0)
  11325. + tmbuf->tm_wday += 7;
  11326. +
  11327. + y = 1970;
  11328. + while (days >= (rem = __isleap(y) ? 366 : 365))
  11329. + {
  11330. + y++;
  11331. + days -= rem;
  11332. + }
  11333. +
  11334. + while (days < 0)
  11335. + {
  11336. + y--;
  11337. + days += __isleap(y) ? 366 : 365;
  11338. + }
  11339. +
  11340. + tmbuf->tm_year = y - 1900;
  11341. + tmbuf->tm_yday = days;
  11342. +
  11343. + ip = __mon_lengths[__isleap(y)];
  11344. + for (y = 0; days >= ip[y]; ++y)
  11345. + days -= ip[y];
  11346. +
  11347. + tmbuf->tm_mon = y;
  11348. + tmbuf->tm_mday = days + 1;
  11349. + tmbuf->tm_isdst = -1;
  11350. +}
  11351. +
  11352. +
  11353. +
  11354. +/* hjz: NOT your traditional ctime: This one includes timezone */
  11355. +/* (UTC) and excludes the traditional trailing newline. */
  11356. +char *CTime( time_t *t )
  11357. +{
  11358. + static char theTime[29];
  11359. + struct tm tm;
  11360. +
  11361. + __tm_conv( &tm, t, 0 );
  11362. + sprintf( theTime, "%s %s %02d %02d:%02d:%02d UTC %04d",
  11363. + dayOfWeek[tm.tm_wday], month[tm.tm_mon], tm.tm_mday,
  11364. + tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_year + 1900 );
  11365. +
  11366. + return theTime;
  11367. +}
  11368. +
  11369. +/******************************************************/
  11370. +
  11371. +
  11372. +/* hjz: polled-I/O: Get a char if one is ready, or return -1 */
  11373. +int getc( void )
  11374. +{
  11375. + if ( nasys_printf_uart->np_uartstatus & np_uartstatus_rrdy_mask )
  11376. + return nasys_printf_uart->np_uartrxdata;
  11377. + else
  11378. + return -1;
  11379. +}
  11380. +
  11381. +
  11382. +typedef unsigned long off_t;
  11383. +typedef struct
  11384. +{
  11385. + U8 *startAddr;
  11386. + U8 *endAddr;
  11387. + U32 CRC;
  11388. + time_t mtime;
  11389. + off_t size; // File size
  11390. + char id[44]; // Filename. If path exceeds available size, name is "..." + last 40 chars of given filename
  11391. + char host[32]; // hostname. If name exceeds available size name is first 28 chars of hostname + "..."
  11392. +} FLASH_REGION_DESC;
  11393. +
  11394. +
  11395. +int Test_Flash_Regions(void)
  11396. +{
  11397. + FLASH_REGION_DESC *pRegion = (FLASH_REGION_DESC *)&__CRC_Table_Begin;
  11398. + U32 crc;
  11399. + char cBuff[256];
  11400. + int nrFailedRegions = 0;
  11401. + int regionStatus;
  11402. + int i;
  11403. + unsigned int startAddr = (int) pRegion->startAddr;
  11404. + unsigned int endAddr = (int) pRegion->endAddr;
  11405. +
  11406. + puts( "***Checking flash CRC's" );
  11407. + if ( (startAddr == -1) || (startAddr >= endAddr)
  11408. + || !( ((startAddr >= (int) NIOS_FLASH_START) && (endAddr < (int) NIOS_FLASH_END))
  11409. + || ((startAddr >= (int) na_flash) && (endAddr < (int) na_flash_end)) ) )
  11410. + {
  11411. + puts( " No Flash regions defined." );
  11412. + return -1;
  11413. + }
  11414. +
  11415. +
  11416. + for ( i = 0; pRegion->startAddr && pRegion->startAddr != (U8 *)~0L; pRegion++, i++ )
  11417. + {
  11418. + crc = Calc_CRC( pRegion->startAddr, pRegion->endAddr - pRegion->startAddr );
  11419. + if ( crc != pRegion->CRC )
  11420. + {
  11421. + regionStatus = 1;
  11422. + nrFailedRegions++;
  11423. + }
  11424. + else
  11425. + regionStatus = 0;
  11426. +
  11427. + sprintf( cBuff, " Region %d: 0x%08lX - 0x%08lX, CRC = 0x%08lX --> %s" NL
  11428. + " From file `%s' on host `%s'" NL
  11429. + " Dated %s, size = %lu bytes",
  11430. + i, (U32)pRegion->startAddr, (U32)pRegion->endAddr, pRegion->CRC,
  11431. + regionStatus ? "***Failed" : "Passed",
  11432. + pRegion->id, pRegion->host, CTime( &pRegion->mtime ), pRegion->size
  11433. + );
  11434. + puts( cBuff );
  11435. + }
  11436. +
  11437. + return nrFailedRegions;
  11438. +}
  11439. +#endif /* CONFIG_CRC_CHECK */
  11440. +
  11441. +
  11442. +int main(void) {
  11443. +
  11444. +#ifdef DEBUG
  11445. + puts("MAIN: starting c\n");
  11446. +#endif
  11447. +
  11448. +#ifdef CONFIG_KGDB /* builtin GDB stub */
  11449. +
  11450. +/* Set up GDB stub, and make the first trap into it */
  11451. + nios_gdb_install(1);
  11452. +#ifdef CONFIG_BREAK_ON_START
  11453. + puts( "MAIN: trapping to debugger - make sure nios-elf-gdb is running on host." );
  11454. + nios_gdb_breakpoint();
  11455. + nop();
  11456. +#endif
  11457. +
  11458. +#endif /* CONFIG_KGDB */
  11459. +
  11460. +#ifdef CONFIG_CRC_CHECK
  11461. + #ifdef CONFIG_PROMPT_ON_MISSING_CRC_TABLES
  11462. + if ( Test_Flash_Regions() )
  11463. + #else
  11464. + if ( Test_Flash_Regions() > 0 )
  11465. + #endif
  11466. + {
  11467. + int c;
  11468. + char tmp[3];
  11469. + while ( getc() != -1 ) // flush input
  11470. + ;
  11471. +
  11472. + putsNoNewLine( " Do you wish to continue (Y/N) ? " );
  11473. + while ( 1 )
  11474. + {
  11475. + c = getc();
  11476. + if ( c == -1 )
  11477. + continue;
  11478. +
  11479. + if ( !isprint( c ) )
  11480. + c = '?';
  11481. +
  11482. + sprintf( tmp, "\b%c", c );
  11483. + putsNoNewLine( tmp );
  11484. + c = toupper( c );
  11485. + if ( c == 'Y' )
  11486. + {
  11487. + puts( "" );
  11488. + break;
  11489. + }
  11490. +
  11491. + if ( c == 'N' )
  11492. + {
  11493. + puts( NL "***Trapping to monitor..." );
  11494. + return -1;
  11495. + }
  11496. + }
  11497. + }
  11498. + puts( "***Starting kernel..." );
  11499. +
  11500. +#endif
  11501. +
  11502. + // Altera NiosII Custom shift instr(s) possibly //;dgt;
  11503. + // assumed by memcpy, etc; ensure "correct" core //;dgt;
  11504. + // loaded therefore if so. //;dgt;
  11505. +
  11506. + #if defined(ALT_CI_ALIGN_32_N) //;dgt;
  11507. + if(ALT_CI_ALIGN_32(1, 0xA9876543, //;dgt;
  11508. + 0xB210FEDC) != 0x10FEDCA9) //;dgt;
  11509. + { //;dgt;
  11510. + goto badshiftci_label; //;dgt;
  11511. + } //;dgt;
  11512. + if(ALT_CI_ALIGN_32(2, 0xA9876543, //;dgt;
  11513. + 0xB210FEDC) != 0xFEDCA987) //;dgt;
  11514. + { //;dgt;
  11515. + goto badshiftci_label; //;dgt;
  11516. + } //;dgt;
  11517. + if(ALT_CI_ALIGN_32(3, 0xA9876543, //;dgt;
  11518. + 0xB210FEDC) != 0xDCA98765) //;dgt;
  11519. + { //;dgt;
  11520. + goto badshiftci_label; //;dgt;
  11521. + } //;dgt;
  11522. + #endif //;dgt;
  11523. + goto gudshiftci_label; //;dgt;
  11524. +badshiftci_label: //;dgt;
  11525. + { //;dgt;
  11526. + unsigned char BadCImsg[] = //;dgt;
  11527. + "?...ALT_CI_ALIGNn_321() NOT expected" //;dgt;
  11528. + " NiosII custom instruction\n"; //;dgt;
  11529. + unsigned char CIabortMsg[] = //;dgt;
  11530. + " ...aborting uClinux startup..."; //;dgt;
  11531. +
  11532. + #ifdef CONFIG_SERIAL_AJUART //;dgt;
  11533. + #ifdef CONFIG_SERIAL_AJUART_CONSOLE //;dgt;
  11534. + juart_console.index = 0; //;dgt;
  11535. + jtaguart_console_write(&(juart_console), //;dgt;
  11536. + BadCImsg, //;dgt;
  11537. + strlen(BadCImsg)); //;dgt;
  11538. + jtaguart_console_write(&(juart_console), //;dgt;
  11539. + CIabortMsg, //;dgt;
  11540. + strlen(CIabortMsg)); //;dgt;
  11541. + #endif // CONFIG_SERIAL_AJUART //;dgt;
  11542. + #endif // CONFIG_SERIAL_AJUART_CONSOLE //;dgt;
  11543. +
  11544. +// #if defined(CONFIG_NIOS_SERIAL) //;dgt;
  11545. +// #if defined(CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;
  11546. + #if defined(nasys_printf_uart) //;dgt;
  11547. + puts(BadCImsg); //;dgt;
  11548. + puts(CIabortMsg); //;dgt;
  11549. + #endif // nasys_printf_uart //;dgt;
  11550. +// #endif // CONFIG_NIOS_SERIAL_CONSOLE) //;dgt;
  11551. +// #endif // CONFIG_NIOS_SERIAL) //;dgt;
  11552. +
  11553. + panic(" ...wrong fpga core?..."); //;dgt;
  11554. + } //;dgt;
  11555. +
  11556. +gudshiftci_label: //;dgt;
  11557. +
  11558. + start_kernel();
  11559. + return 0;
  11560. +}
  11561. diff --git a/arch/nios2nommu/kernel/sys_nios2.c b/arch/nios2nommu/kernel/sys_nios2.c
  11562. new file mode 100644
  11563. index 0000000..8018fb0
  11564. --- /dev/null
  11565. +++ b/arch/nios2nommu/kernel/sys_nios2.c
  11566. @@ -0,0 +1,248 @@
  11567. +/*
  11568. + * linux/arch/nios2nommu/kernel/sys_nios2.c
  11569. + *
  11570. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  11571. + *
  11572. + * This file contains various random system calls that
  11573. + * have a non-standard calling sequence on the Linux/nios2nommu
  11574. + * platform.
  11575. + *
  11576. + * All rights reserved.
  11577. + *
  11578. + * This program is free software; you can redistribute it and/or modify
  11579. + * it under the terms of the GNU General Public License as published by
  11580. + * the Free Software Foundation; either version 2 of the License, or
  11581. + * (at your option) any later version.
  11582. + *
  11583. + * This program is distributed in the hope that it will be useful, but
  11584. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  11585. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11586. + * NON INFRINGEMENT. See the GNU General Public License for more
  11587. + * details.
  11588. + *
  11589. + * You should have received a copy of the GNU General Public License
  11590. + * along with this program; if not, write to the Free Software
  11591. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  11592. + *
  11593. +*/
  11594. +
  11595. +#include <linux/errno.h>
  11596. +#include <linux/sched.h>
  11597. +#include <linux/mm.h>
  11598. +#include <linux/smp.h>
  11599. +#include <linux/smp_lock.h>
  11600. +#include <linux/sem.h>
  11601. +#include <linux/msg.h>
  11602. +#include <linux/shm.h>
  11603. +#include <linux/stat.h>
  11604. +#include <linux/syscalls.h>
  11605. +#include <linux/mman.h>
  11606. +#include <linux/file.h>
  11607. +#include <linux/utsname.h>
  11608. +#include <linux/fs.h>
  11609. +#include <linux/uaccess.h>
  11610. +#include <linux/ipc.h>
  11611. +#include <linux/unistd.h>
  11612. +
  11613. +#include <asm/setup.h>
  11614. +#include <asm/cachectl.h>
  11615. +#include <asm/traps.h>
  11616. +#include <asm/ipc.h>
  11617. +#include <asm/cacheflush.h>
  11618. +
  11619. +/*
  11620. + * sys_pipe() is the normal C calling standard for creating
  11621. + * a pipe. It's not the way unix traditionally does this, though.
  11622. + */
  11623. +asmlinkage int sys_pipe(unsigned long * fildes)
  11624. +{
  11625. + int fd[2];
  11626. + int error;
  11627. +
  11628. + error = do_pipe(fd);
  11629. + if (!error) {
  11630. + if (copy_to_user(fildes, fd, 2*sizeof(int)))
  11631. + error = -EFAULT;
  11632. + }
  11633. + return error;
  11634. +}
  11635. +
  11636. +/* common code for old and new mmaps */
  11637. +static inline long do_mmap2(
  11638. + unsigned long addr, unsigned long len,
  11639. + unsigned long prot, unsigned long flags,
  11640. + unsigned long fd, unsigned long pgoff)
  11641. +{
  11642. + int error = -EBADF;
  11643. + struct file * file = NULL;
  11644. +
  11645. + flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
  11646. + if (!(flags & MAP_ANONYMOUS)) {
  11647. + file = fget(fd);
  11648. + if (!file)
  11649. + goto out;
  11650. + }
  11651. +
  11652. + down_write(&current->mm->mmap_sem);
  11653. + error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
  11654. + up_write(&current->mm->mmap_sem);
  11655. +
  11656. + if (file)
  11657. + fput(file);
  11658. +out:
  11659. + return error;
  11660. +}
  11661. +
  11662. +asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
  11663. + unsigned long prot, unsigned long flags,
  11664. + unsigned long fd, unsigned long pgoff)
  11665. +{
  11666. + return do_mmap2(addr, len, prot, flags, fd, pgoff);
  11667. +}
  11668. +
  11669. +/*
  11670. + * Perform the select(nd, in, out, ex, tv) and mmap() system
  11671. + * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
  11672. + * handle more than 4 system call parameters, so these system calls
  11673. + * used a memory block for parameter passing..
  11674. + */
  11675. +
  11676. +struct mmap_arg_struct {
  11677. + unsigned long addr;
  11678. + unsigned long len;
  11679. + unsigned long prot;
  11680. + unsigned long flags;
  11681. + unsigned long fd;
  11682. + unsigned long offset;
  11683. +};
  11684. +
  11685. +asmlinkage int old_mmap(struct mmap_arg_struct *arg)
  11686. +{
  11687. + struct mmap_arg_struct a;
  11688. + int error = -EFAULT;
  11689. +
  11690. + if (copy_from_user(&a, arg, sizeof(a)))
  11691. + goto out;
  11692. +
  11693. + error = -EINVAL;
  11694. + if (a.offset & ~PAGE_MASK)
  11695. + goto out;
  11696. +
  11697. + a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
  11698. +
  11699. + error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
  11700. +out:
  11701. + return error;
  11702. +}
  11703. +
  11704. +struct sel_arg_struct {
  11705. + unsigned long n;
  11706. + fd_set *inp, *outp, *exp;
  11707. + struct timeval *tvp;
  11708. +};
  11709. +
  11710. +asmlinkage int old_select(struct sel_arg_struct *arg)
  11711. +{
  11712. + struct sel_arg_struct a;
  11713. +
  11714. + if (copy_from_user(&a, arg, sizeof(a)))
  11715. + return -EFAULT;
  11716. + /* sys_select() does the appropriate kernel locking */
  11717. + return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
  11718. +}
  11719. +
  11720. +/*
  11721. + * sys_ipc() is the de-multiplexer for the SysV IPC calls..
  11722. + *
  11723. + * This is really horribly ugly.
  11724. + */
  11725. +asmlinkage int sys_ipc (uint call, int first, int second,
  11726. + int third, void *ptr, long fifth)
  11727. +{
  11728. + int version;
  11729. +
  11730. + version = call >> 16; /* hack for backward compatibility */
  11731. + call &= 0xffff;
  11732. +
  11733. + if (call <= SEMCTL)
  11734. + switch (call) {
  11735. + case SEMOP:
  11736. + return sys_semop (first, (struct sembuf *)ptr, second);
  11737. + case SEMGET:
  11738. + return sys_semget (first, second, third);
  11739. + case SEMCTL: {
  11740. + union semun fourth;
  11741. + if (!ptr)
  11742. + return -EINVAL;
  11743. + if (get_user(fourth.__pad, (void **) ptr))
  11744. + return -EFAULT;
  11745. + return sys_semctl (first, second, third, fourth);
  11746. + }
  11747. + default:
  11748. + return -EINVAL;
  11749. + }
  11750. + if (call <= MSGCTL)
  11751. + switch (call) {
  11752. + case MSGSND:
  11753. + return sys_msgsnd (first, (struct msgbuf *) ptr,
  11754. + second, third);
  11755. + case MSGRCV:
  11756. + switch (version) {
  11757. + case 0: {
  11758. + struct ipc_kludge tmp;
  11759. + if (!ptr)
  11760. + return -EINVAL;
  11761. + if (copy_from_user (&tmp,
  11762. + (struct ipc_kludge *)ptr,
  11763. + sizeof (tmp)))
  11764. + return -EFAULT;
  11765. + return sys_msgrcv (first, tmp.msgp, second,
  11766. + tmp.msgtyp, third);
  11767. + }
  11768. + default:
  11769. + return sys_msgrcv (first,
  11770. + (struct msgbuf *) ptr,
  11771. + second, fifth, third);
  11772. + }
  11773. + case MSGGET:
  11774. + return sys_msgget ((key_t) first, second);
  11775. + case MSGCTL:
  11776. + return sys_msgctl (first, second,
  11777. + (struct msqid_ds *) ptr);
  11778. + default:
  11779. + return -EINVAL;
  11780. + }
  11781. +
  11782. + return -EINVAL;
  11783. +}
  11784. +
  11785. +/* sys_cacheflush -- flush the processor cache. */
  11786. +asmlinkage int
  11787. +sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
  11788. +{
  11789. + flush_cache_all();
  11790. + return(0);
  11791. +}
  11792. +
  11793. +asmlinkage int sys_getpagesize(void)
  11794. +{
  11795. + return PAGE_SIZE;
  11796. +}
  11797. +
  11798. +/*
  11799. + * Do a system call from kernel instead of calling sys_execve so we
  11800. + * end up with proper pt_regs.
  11801. + */
  11802. +int kernel_execve(const char *filename, char *const argv[], char *const envp[])
  11803. +{
  11804. + register long __res __asm__ ("r2") = TRAP_ID_SYSCALL;
  11805. + register long __sc __asm__ ("r3") = __NR_execve;
  11806. + register long __a __asm__ ("r4") = (long) filename;
  11807. + register long __b __asm__ ("r5") = (long) argv;
  11808. + register long __c __asm__ ("r6") = (long) envp;
  11809. + __asm__ __volatile__ ("trap" : "=r" (__res)
  11810. + : "0" (__res), "r" (__sc), "r" (__a), "r" (__b), "r" (__c)
  11811. + : "memory");
  11812. +
  11813. + return __res;
  11814. +}
  11815. diff --git a/arch/nios2nommu/kernel/syscalltable.S b/arch/nios2nommu/kernel/syscalltable.S
  11816. new file mode 100644
  11817. index 0000000..3507e24
  11818. --- /dev/null
  11819. +++ b/arch/nios2nommu/kernel/syscalltable.S
  11820. @@ -0,0 +1,362 @@
  11821. +/*--------------------------------------------------------------------
  11822. + *
  11823. + * arch/nios2nommu/kernel/syscalltable.S
  11824. + *
  11825. + * Derived from M68knommu
  11826. + *
  11827. + * Copyright (C) 2004 Microtronix Datacom Ltd
  11828. + * Copyright (C) 2002, Greg Ungerer (gerg@snapgear.com)
  11829. + * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
  11830. + * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
  11831. + * Kenneth Albanowski <kjahds@kjahds.com>,
  11832. + * Copyright (C) 1991, 1992 Linus Torvalds
  11833. + *
  11834. + * This program is free software; you can redistribute it and/or modify
  11835. + * it under the terms of the GNU General Public License as published by
  11836. + * the Free Software Foundation; either version 2 of the License, or
  11837. + * (at your option) any later version.
  11838. + *
  11839. + * This program is distributed in the hope that it will be useful,
  11840. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11841. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11842. + * GNU General Public License for more details.
  11843. + *
  11844. + * Jan/20/2004 dgt NiosII
  11845. + *
  11846. + ---------------------------------------------------------------------*/
  11847. +
  11848. +#include <linux/sys.h>
  11849. +#include <linux/linkage.h>
  11850. +#include <asm/unistd.h>
  11851. +#include <asm/asm-macros.h>
  11852. +
  11853. +.text
  11854. +ALIGN
  11855. +ENTRY(sys_call_table)
  11856. + .long sys_ni_syscall /* 0 - old "setup()" system call*/
  11857. + .long sys_exit
  11858. + .long sys_fork
  11859. + .long sys_read
  11860. + .long sys_write
  11861. + .long sys_open /* 5 */
  11862. + .long sys_close
  11863. + .long sys_waitpid
  11864. + .long sys_creat
  11865. + .long sys_link
  11866. + .long sys_unlink /* 10 */
  11867. + .long sys_execve
  11868. + .long sys_chdir
  11869. + .long sys_time
  11870. + .long sys_mknod
  11871. + .long sys_chmod /* 15 */
  11872. + .long sys_chown16
  11873. + .long sys_ni_syscall /* old break syscall holder */
  11874. + .long sys_stat
  11875. + .long sys_lseek
  11876. + .long sys_getpid /* 20 */
  11877. + .long sys_mount
  11878. + .long sys_oldumount
  11879. + .long sys_setuid16
  11880. + .long sys_getuid16
  11881. + .long sys_stime /* 25 */
  11882. + .long sys_ptrace
  11883. + .long sys_alarm
  11884. + .long sys_fstat
  11885. + .long sys_pause
  11886. + .long sys_utime /* 30 */
  11887. + .long sys_ni_syscall /* old stty syscall holder */
  11888. + .long sys_ni_syscall /* old gtty syscall holder */
  11889. + .long sys_access
  11890. + .long sys_nice
  11891. + .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
  11892. + .long sys_sync
  11893. + .long sys_kill
  11894. + .long sys_rename
  11895. + .long sys_mkdir
  11896. + .long sys_rmdir /* 40 */
  11897. + .long sys_dup
  11898. + .long sys_pipe
  11899. + .long sys_times
  11900. + .long sys_ni_syscall /* old prof syscall holder */
  11901. + .long sys_brk /* 45 */
  11902. + .long sys_setgid16
  11903. + .long sys_getgid16
  11904. + .long sys_signal
  11905. + .long sys_geteuid16
  11906. + .long sys_getegid16 /* 50 */
  11907. + .long sys_acct
  11908. + .long sys_umount /* recycled never used phys() */
  11909. + .long sys_ni_syscall /* old lock syscall holder */
  11910. + .long sys_ioctl
  11911. + .long sys_fcntl /* 55 */
  11912. + .long sys_ni_syscall /* old mpx syscall holder */
  11913. + .long sys_setpgid
  11914. + .long sys_ni_syscall /* old ulimit syscall holder */
  11915. + .long sys_ni_syscall
  11916. + .long sys_umask /* 60 */
  11917. + .long sys_chroot
  11918. + .long sys_ustat
  11919. + .long sys_dup2
  11920. + .long sys_getppid
  11921. + .long sys_getpgrp /* 65 */
  11922. + .long sys_setsid
  11923. + .long sys_sigaction
  11924. + .long sys_sgetmask
  11925. + .long sys_ssetmask
  11926. + .long sys_setreuid16 /* 70 */
  11927. + .long sys_setregid16
  11928. + .long sys_sigsuspend
  11929. + .long sys_sigpending
  11930. + .long sys_sethostname
  11931. + .long sys_setrlimit /* 75 */
  11932. + .long sys_old_getrlimit
  11933. + .long sys_getrusage
  11934. + .long sys_gettimeofday
  11935. + .long sys_settimeofday
  11936. + .long sys_getgroups16 /* 80 */
  11937. + .long sys_setgroups16
  11938. + .long old_select
  11939. + .long sys_symlink
  11940. + .long sys_lstat
  11941. + .long sys_readlink /* 85 */
  11942. + .long sys_uselib
  11943. + .long sys_ni_syscall /* sys_swapon */
  11944. + .long sys_reboot
  11945. + .long old_readdir
  11946. + .long old_mmap /* 90 */
  11947. + .long sys_munmap
  11948. + .long sys_truncate
  11949. + .long sys_ftruncate
  11950. + .long sys_fchmod
  11951. + .long sys_fchown16 /* 95 */
  11952. + .long sys_getpriority
  11953. + .long sys_setpriority
  11954. + .long sys_ni_syscall /* old profil syscall holder */
  11955. + .long sys_statfs
  11956. + .long sys_fstatfs /* 100 */
  11957. + .long sys_ni_syscall /* was ioperm */
  11958. + .long sys_socketcall
  11959. + .long sys_syslog
  11960. + .long sys_setitimer
  11961. + .long sys_getitimer /* 105 */
  11962. + .long sys_newstat
  11963. + .long sys_newlstat
  11964. + .long sys_newfstat
  11965. + .long sys_ni_syscall
  11966. + .long sys_ni_syscall /* iopl for i386 */ /* 110 */
  11967. + .long sys_vhangup
  11968. + .long sys_ni_syscall /* obsolete idle() syscall */
  11969. + .long sys_ni_syscall /* vm86old for i386 */
  11970. + .long sys_wait4
  11971. + .long sys_ni_syscall /* 115 */ /* sys_swapoff */
  11972. + .long sys_sysinfo
  11973. + .long sys_ipc
  11974. + .long sys_fsync
  11975. + .long sys_sigreturn
  11976. + .long sys_clone /* 120 */
  11977. + .long sys_setdomainname
  11978. + .long sys_newuname
  11979. + .long sys_cacheflush /* modify_ldt for i386 */
  11980. + .long sys_adjtimex
  11981. + .long sys_ni_syscall /* 125 */ /* sys_mprotect */
  11982. + .long sys_sigprocmask
  11983. + .long sys_ni_syscall /* old "creat_module" */
  11984. + .long sys_init_module
  11985. + .long sys_delete_module
  11986. + .long sys_ni_syscall /* 130: old "get_kernel_syms" */
  11987. + .long sys_quotactl
  11988. + .long sys_getpgid
  11989. + .long sys_fchdir
  11990. + .long sys_bdflush
  11991. + .long sys_sysfs /* 135 */
  11992. + .long sys_personality
  11993. + .long sys_ni_syscall /* for afs_syscall */
  11994. + .long sys_setfsuid16
  11995. + .long sys_setfsgid16
  11996. + .long sys_llseek /* 140 */
  11997. + .long sys_getdents
  11998. + .long sys_select
  11999. + .long sys_flock
  12000. + .long sys_ni_syscall /* sys_msync */
  12001. + .long sys_readv /* 145 */
  12002. + .long sys_writev
  12003. + .long sys_getsid
  12004. + .long sys_fdatasync
  12005. + .long sys_sysctl
  12006. + .long sys_ni_syscall /* 150 */ /* sys_mlock */
  12007. + .long sys_ni_syscall /* sys_munlock */
  12008. + .long sys_ni_syscall /* sys_mlockall */
  12009. + .long sys_ni_syscall /* sys_munlockall */
  12010. + .long sys_sched_setparam
  12011. + .long sys_sched_getparam /* 155 */
  12012. + .long sys_sched_setscheduler
  12013. + .long sys_sched_getscheduler
  12014. + .long sys_sched_yield
  12015. + .long sys_sched_get_priority_max
  12016. + .long sys_sched_get_priority_min /* 160 */
  12017. + .long sys_sched_rr_get_interval
  12018. + .long sys_nanosleep
  12019. + .long sys_ni_syscall /* sys_mremap */
  12020. + .long sys_setresuid16
  12021. + .long sys_getresuid16 /* 165 */
  12022. + .long sys_getpagesize /* sys_getpagesize */
  12023. + .long sys_ni_syscall /* old "query_module" */
  12024. + .long sys_poll
  12025. + .long sys_ni_syscall /* sys_nfsservctl */
  12026. + .long sys_setresgid16 /* 170 */
  12027. + .long sys_getresgid16
  12028. + .long sys_prctl
  12029. + .long sys_rt_sigreturn
  12030. + .long sys_rt_sigaction
  12031. + .long sys_rt_sigprocmask /* 175 */
  12032. + .long sys_rt_sigpending
  12033. + .long sys_rt_sigtimedwait
  12034. + .long sys_rt_sigqueueinfo
  12035. + .long sys_rt_sigsuspend
  12036. + .long sys_pread64 /* 180 */
  12037. + .long sys_pwrite64
  12038. + .long sys_lchown16
  12039. + .long sys_getcwd
  12040. + .long sys_capget
  12041. + .long sys_capset /* 185 */
  12042. + .long sys_sigaltstack
  12043. + .long sys_sendfile
  12044. + .long sys_ni_syscall /* streams1 */
  12045. + .long sys_ni_syscall /* streams2 */
  12046. + .long sys_vfork /* 190 */
  12047. + .long sys_getrlimit
  12048. + .long sys_mmap2
  12049. + .long sys_truncate64
  12050. + .long sys_ftruncate64
  12051. + .long sys_stat64 /* 195 */
  12052. + .long sys_lstat64
  12053. + .long sys_fstat64
  12054. + .long sys_chown
  12055. + .long sys_getuid
  12056. + .long sys_getgid /* 200 */
  12057. + .long sys_geteuid
  12058. + .long sys_getegid
  12059. + .long sys_setreuid
  12060. + .long sys_setregid
  12061. + .long sys_getgroups /* 205 */
  12062. + .long sys_setgroups
  12063. + .long sys_fchown
  12064. + .long sys_setresuid
  12065. + .long sys_getresuid
  12066. + .long sys_setresgid /* 210 */
  12067. + .long sys_getresgid
  12068. + .long sys_lchown
  12069. + .long sys_setuid
  12070. + .long sys_setgid
  12071. + .long sys_setfsuid /* 215 */
  12072. + .long sys_setfsgid
  12073. + .long sys_pivot_root
  12074. + .long sys_ni_syscall
  12075. + .long sys_ni_syscall
  12076. + .long sys_getdents64 /* 220 */
  12077. + .long sys_gettid
  12078. + .long sys_tkill
  12079. + .long sys_setxattr
  12080. + .long sys_lsetxattr
  12081. + .long sys_fsetxattr /* 225 */
  12082. + .long sys_getxattr
  12083. + .long sys_lgetxattr
  12084. + .long sys_fgetxattr
  12085. + .long sys_listxattr
  12086. + .long sys_llistxattr /* 230 */
  12087. + .long sys_flistxattr
  12088. + .long sys_removexattr
  12089. + .long sys_lremovexattr
  12090. + .long sys_fremovexattr
  12091. + .long sys_futex /* 235 */
  12092. + .long sys_sendfile64
  12093. + .long sys_ni_syscall /* sys_mincore */
  12094. + .long sys_ni_syscall /* sys_madvise */
  12095. + .long sys_fcntl64
  12096. + .long sys_readahead /* 240 */
  12097. + .long sys_io_setup
  12098. + .long sys_io_destroy
  12099. + .long sys_io_getevents
  12100. + .long sys_io_submit
  12101. + .long sys_io_cancel /* 245 */
  12102. + .long sys_fadvise64
  12103. + .long sys_exit_group
  12104. + .long sys_lookup_dcookie
  12105. + .long sys_epoll_create
  12106. + .long sys_epoll_ctl /* 250 */
  12107. + .long sys_epoll_wait
  12108. + .long sys_ni_syscall /* sys_remap_file_pages */
  12109. + .long sys_set_tid_address
  12110. + .long sys_timer_create
  12111. + .long sys_timer_settime /* 255 */
  12112. + .long sys_timer_gettime
  12113. + .long sys_timer_getoverrun
  12114. + .long sys_timer_delete
  12115. + .long sys_clock_settime
  12116. + .long sys_clock_gettime /* 260 */
  12117. + .long sys_clock_getres
  12118. + .long sys_clock_nanosleep
  12119. + .long sys_statfs64
  12120. + .long sys_fstatfs64
  12121. + .long sys_tgkill /* 265 */
  12122. + .long sys_utimes
  12123. + .long sys_fadvise64_64
  12124. + .long sys_mbind
  12125. + .long sys_get_mempolicy
  12126. + .long sys_set_mempolicy /* 270 */
  12127. + .long sys_mq_open
  12128. + .long sys_mq_unlink
  12129. + .long sys_mq_timedsend
  12130. + .long sys_mq_timedreceive
  12131. + .long sys_mq_notify /* 275 */
  12132. + .long sys_mq_getsetattr
  12133. + .long sys_waitid
  12134. + .long sys_ni_syscall /* sys_setaltroot */
  12135. + .long sys_ni_syscall /* sys_add_key */
  12136. + .long sys_ni_syscall /* 280 */ /* sys_request_key */
  12137. + .long sys_ni_syscall /* sys_keyctl */
  12138. + .long sys_ioprio_set
  12139. + .long sys_ioprio_get
  12140. + .long sys_inotify_init
  12141. + .long sys_inotify_add_watch /* 285 */
  12142. + .long sys_inotify_rm_watch
  12143. + .long sys_migrate_pages
  12144. + .long sys_openat
  12145. + .long sys_mkdirat
  12146. + .long sys_mknodat /* 290 */
  12147. + .long sys_fchownat
  12148. + .long sys_futimesat
  12149. + .long sys_fstatat64
  12150. + .long sys_unlinkat
  12151. + .long sys_renameat /* 295 */
  12152. + .long sys_linkat
  12153. + .long sys_symlinkat
  12154. + .long sys_readlinkat
  12155. + .long sys_fchmodat
  12156. + .long sys_faccessat /* 300 */
  12157. + .long sys_ni_syscall /* Reserved for pselect6 */
  12158. + .long sys_ni_syscall /* Reserved for ppoll */
  12159. + .long sys_unshare
  12160. + .long sys_set_robust_list
  12161. + .long sys_get_robust_list /* 305 */
  12162. + .long sys_splice
  12163. + .long sys_sync_file_range
  12164. + .long sys_tee
  12165. + .long sys_vmsplice
  12166. + .long sys_move_pages /* 310 */
  12167. + .long sys_sched_setaffinity
  12168. + .long sys_sched_getaffinity
  12169. + .long sys_kexec_load
  12170. + .long sys_getcpu
  12171. + .long sys_epoll_pwait /* 315 */
  12172. + .long sys_utimensat
  12173. + .long sys_signalfd
  12174. + .long sys_timerfd
  12175. + .long sys_eventfd
  12176. + .long sys_pread64
  12177. + .long sys_pwrite64 /* 321 */
  12178. +
  12179. + .rept NR_syscalls - 322
  12180. + .long sys_ni_syscall
  12181. + .endr
  12182. +
  12183. diff --git a/arch/nios2nommu/kernel/time.c b/arch/nios2nommu/kernel/time.c
  12184. new file mode 100644
  12185. index 0000000..3b536fe
  12186. --- /dev/null
  12187. +++ b/arch/nios2nommu/kernel/time.c
  12188. @@ -0,0 +1,219 @@
  12189. +/*--------------------------------------------------------------------
  12190. + *
  12191. + * arch/nios2nommu/kernel/time.c
  12192. + *
  12193. + * Architecture specific time handling details.
  12194. + *
  12195. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  12196. + *
  12197. + * Most of the stuff is located in the machine specific files.
  12198. + *
  12199. + * Copyright (C) 2004 Microtronix Datacom Ltd
  12200. + * Copyright (C) 1998-2000 D. Jeff Dionne <jeff@lineo.ca>,
  12201. + * Kenneth Albanowski <kjahds@kjahds.com>,
  12202. + * Copyright (C) 1991, 1992, 1995 Linus Torvalds
  12203. + *
  12204. + * This program is free software; you can redistribute it and/or modify
  12205. + * it under the terms of the GNU General Public License as published by
  12206. + * the Free Software Foundation; either version 2 of the License, or
  12207. + * (at your option) any later version.
  12208. + *
  12209. + * This program is distributed in the hope that it will be useful,
  12210. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12211. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12212. + * GNU General Public License for more details.
  12213. + *
  12214. + *
  12215. + * Jan/20/2004 dgt NiosII
  12216. + *
  12217. + ---------------------------------------------------------------------*/
  12218. +
  12219. +
  12220. +#include <linux/errno.h>
  12221. +#include <linux/sched.h>
  12222. +#include <linux/kernel.h>
  12223. +#include <linux/param.h>
  12224. +#include <linux/string.h>
  12225. +#include <linux/mm.h>
  12226. +#include <linux/interrupt.h>
  12227. +#include <linux/time.h>
  12228. +#include <linux/timex.h>
  12229. +#include <linux/profile.h>
  12230. +#include <linux/module.h>
  12231. +#include <linux/irq.h>
  12232. +
  12233. +#include <asm/segment.h>
  12234. +#include <asm/io.h>
  12235. +#include <asm/nios.h>
  12236. +
  12237. +#define TICK_SIZE (tick_nsec / 1000)
  12238. +
  12239. +unsigned long cpu_khz;
  12240. +static inline int set_rtc_mmss(unsigned long nowtime)
  12241. +{
  12242. + return 0;
  12243. +}
  12244. +
  12245. +/* Timer timeout status */
  12246. +#define nios2_timer_TO (inw(&na_timer0->np_timerstatus) & np_timerstatus_to_mask)
  12247. +
  12248. +/* Timer snapshot */
  12249. +static inline unsigned long nios2_read_timercount(void)
  12250. +{
  12251. + unsigned long count;
  12252. +
  12253. + outw(0, &na_timer0->np_timersnapl);
  12254. + count = inw(&na_timer0->np_timersnaph) << 16 | inw(&na_timer0->np_timersnapl);
  12255. +
  12256. + return count;
  12257. +}
  12258. +
  12259. +/*
  12260. + * Should return useconds since last timer tick
  12261. + */
  12262. +static unsigned long gettimeoffset(void)
  12263. +{
  12264. + unsigned long offset;
  12265. + unsigned long count;
  12266. +
  12267. + count = nios2_read_timercount();
  12268. + offset = ((nasys_clock_freq/HZ)-1 - nios2_read_timercount()) \
  12269. + / (nasys_clock_freq / USEC_PER_SEC);
  12270. +
  12271. + /* Check if we just wrapped the counters and maybe missed a tick */
  12272. + if (nios2_timer_TO && (offset < (100000 / HZ / 2)))
  12273. + offset += (USEC_PER_SEC / HZ);
  12274. +
  12275. + return offset;
  12276. +}
  12277. +
  12278. +/*
  12279. + * timer_interrupt() needs to keep up the real-time clock,
  12280. + * as well as call the "do_timer()" routine every clocktick
  12281. + */
  12282. +irqreturn_t timer_interrupt(int irq, void *dummy)
  12283. +{
  12284. + /* last time the cmos clock got updated */
  12285. + static long last_rtc_update=0;
  12286. +
  12287. + write_seqlock(&xtime_lock);
  12288. + na_timer0->np_timerstatus = 0; /* Clear the interrupt condition */
  12289. +
  12290. + do_timer(1);
  12291. +#ifndef CONFIG_SMP
  12292. + update_process_times(user_mode(get_irq_regs()));
  12293. +#endif
  12294. + profile_tick(CPU_PROFILING);
  12295. + /*
  12296. + * If we have an externally synchronized Linux clock, then update
  12297. + * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
  12298. + * called as close as possible to 500 ms before the new second starts.
  12299. + */
  12300. + if (ntp_synced() &&
  12301. + xtime.tv_sec > last_rtc_update + 660 &&
  12302. + (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
  12303. + (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) {
  12304. + if (set_rtc_mmss(xtime.tv_sec) == 0)
  12305. + last_rtc_update = xtime.tv_sec;
  12306. + else
  12307. + last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
  12308. + }
  12309. +
  12310. + write_sequnlock(&xtime_lock);
  12311. + return(IRQ_HANDLED);
  12312. +}
  12313. +
  12314. +void __init time_init(void)
  12315. +{
  12316. + unsigned int year, mon, day, hour, min, sec;
  12317. + int err;
  12318. +
  12319. + extern void arch_gettod(int *year, int *mon, int *day, int *hour,
  12320. + int *min, int *sec);
  12321. +
  12322. + cpu_khz=nasys_clock_freq_1000;
  12323. + arch_gettod(&year, &mon, &day, &hour, &min, &sec);
  12324. +
  12325. + if ((year += 1900) < 1970)
  12326. + year += 100;
  12327. + xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
  12328. + xtime.tv_nsec = 0;
  12329. + wall_to_monotonic.tv_sec = -xtime.tv_sec;
  12330. +
  12331. + err = request_irq(na_timer0_irq, timer_interrupt, IRQ_FLG_LOCK, "timer", NULL);
  12332. + if(err)
  12333. + printk(KERN_ERR "%s() failed - errno = %d\n", __FUNCTION__, -err);
  12334. + na_timer0->np_timerperiodl = (nasys_clock_freq/HZ)-1;
  12335. + na_timer0->np_timerperiodh = ((nasys_clock_freq/HZ)-1) >> 16;
  12336. +
  12337. + /* interrupt enable + continuous + start */
  12338. + na_timer0->np_timercontrol = np_timercontrol_start_mask
  12339. + + np_timercontrol_cont_mask
  12340. + + np_timercontrol_ito_mask;
  12341. +}
  12342. +
  12343. +/*
  12344. + * This version of gettimeofday has near microsecond resolution.
  12345. + */
  12346. +void do_gettimeofday(struct timeval *tv)
  12347. +{
  12348. + unsigned long flags;
  12349. + unsigned long seq;
  12350. + unsigned long usec, sec;
  12351. +
  12352. + do {
  12353. + seq = read_seqbegin_irqsave(&xtime_lock, flags);
  12354. + usec = gettimeoffset();
  12355. + sec = xtime.tv_sec;
  12356. + usec += (xtime.tv_nsec / 1000);
  12357. + } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
  12358. +
  12359. + while (usec >= 1000000) {
  12360. + usec -= 1000000;
  12361. + sec++;
  12362. + }
  12363. +
  12364. + tv->tv_sec = sec;
  12365. + tv->tv_usec = usec;
  12366. +}
  12367. +EXPORT_SYMBOL(do_gettimeofday);
  12368. +
  12369. +int do_settimeofday(struct timespec *tv)
  12370. +{
  12371. + time_t wtm_sec, sec = tv->tv_sec;
  12372. + long wtm_nsec, nsec = tv->tv_nsec;
  12373. +
  12374. + if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
  12375. + return -EINVAL;
  12376. +
  12377. + write_seqlock_irq(&xtime_lock);
  12378. + /*
  12379. + * This is revolting. We need to set "xtime" correctly. However, the
  12380. + * value in this location is the value at the last tick.
  12381. + * Discover what correction gettimeofday() would have
  12382. + * made, and then undo it!
  12383. + */
  12384. + nsec -= gettimeoffset() * NSEC_PER_USEC;
  12385. +
  12386. + wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
  12387. + wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
  12388. +
  12389. + set_normalized_timespec(&xtime, sec, nsec);
  12390. + set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
  12391. +
  12392. + ntp_clear();
  12393. +
  12394. + write_sequnlock_irq(&xtime_lock);
  12395. + clock_was_set();
  12396. +
  12397. + return 0;
  12398. +}
  12399. +EXPORT_SYMBOL(do_settimeofday);
  12400. +
  12401. +/*
  12402. + * Scheduler clock - returns current time in nanosec units.
  12403. + */
  12404. +unsigned long long sched_clock(void)
  12405. +{
  12406. + return (unsigned long long)jiffies * (1000000000 / HZ);
  12407. +}
  12408. diff --git a/arch/nios2nommu/kernel/traps.c b/arch/nios2nommu/kernel/traps.c
  12409. new file mode 100644
  12410. index 0000000..14b7e4c
  12411. --- /dev/null
  12412. +++ b/arch/nios2nommu/kernel/traps.c
  12413. @@ -0,0 +1,178 @@
  12414. +/*
  12415. + * arch/niosnommu/kernel/traps.c
  12416. + *
  12417. + * Copyright 2004 Microtronix Datacom Ltd.
  12418. + * Copyright 2001 Vic Phillips
  12419. + * Copyright 1995 David S. Miller (davem@caip.rutgers.edu)
  12420. + *
  12421. + * hacked from:
  12422. + *
  12423. + * arch/sparcnommu/kernel/traps.c
  12424. + *
  12425. + * All rights reserved.
  12426. + *
  12427. + * This program is free software; you can redistribute it and/or modify
  12428. + * it under the terms of the GNU General Public License as published by
  12429. + * the Free Software Foundation; either version 2 of the License, or
  12430. + * (at your option) any later version.
  12431. + *
  12432. + * This program is distributed in the hope that it will be useful, but
  12433. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  12434. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  12435. + * NON INFRINGEMENT. See the GNU General Public License for more
  12436. + * details.
  12437. + *
  12438. + * You should have received a copy of the GNU General Public License
  12439. + * along with this program; if not, write to the Free Software
  12440. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  12441. + *
  12442. + */
  12443. +
  12444. +#include <linux/sched.h> /* for jiffies */
  12445. +#include <linux/kernel.h>
  12446. +#include <linux/signal.h>
  12447. +#include <linux/module.h>
  12448. +
  12449. +#include <asm/delay.h>
  12450. +#include <asm/system.h>
  12451. +#include <asm/ptrace.h>
  12452. +#include <asm/page.h>
  12453. +#include <asm/pgtable.h>
  12454. +#include <asm/unistd.h>
  12455. +
  12456. +#include <asm/nios.h>
  12457. +
  12458. +/* #define TRAP_DEBUG */
  12459. +
  12460. +#if 0
  12461. +void dumpit(unsigned long l1, unsigned long l2)
  12462. +{
  12463. + printk("0x%08x l1 0x%08x l2\n");
  12464. + while(1);
  12465. +}
  12466. +
  12467. +struct trap_trace_entry {
  12468. + unsigned long pc;
  12469. + unsigned long type;
  12470. +};
  12471. +
  12472. +int trap_curbuf = 0;
  12473. +struct trap_trace_entry trapbuf[1024];
  12474. +
  12475. +void syscall_trace_entry(struct pt_regs *regs)
  12476. +{
  12477. + printk("%s[%d]: ", current->comm, current->pid);
  12478. + printk("scall<%d> (could be %d)\n", (int) regs->r3,
  12479. + (int) regs->r4);
  12480. +}
  12481. +
  12482. +void syscall_trace_exit(struct pt_regs *regs)
  12483. +{
  12484. +}
  12485. +#endif
  12486. +
  12487. +/*
  12488. + * The architecture-independent backtrace generator
  12489. + */
  12490. +void dump_stack(void)
  12491. +{
  12492. + unsigned long stack;
  12493. +
  12494. + show_stack(current, &stack);
  12495. +}
  12496. +
  12497. +EXPORT_SYMBOL(dump_stack);
  12498. +
  12499. +/*
  12500. + * The show_stack is an external API which we do not use ourselves.
  12501. + * The oops is printed in die_if_kernel.
  12502. + */
  12503. +
  12504. +int kstack_depth_to_print = 48;
  12505. +
  12506. +void show_stack(struct task_struct *task, unsigned long *stack)
  12507. +{
  12508. + unsigned long *endstack, addr;
  12509. + extern char _start, _etext;
  12510. + int i;
  12511. +
  12512. + if (!stack) {
  12513. + if (task)
  12514. + stack = (unsigned long *)task->thread.ksp;
  12515. + else
  12516. + stack = (unsigned long *)&stack;
  12517. + }
  12518. +
  12519. + addr = (unsigned long) stack;
  12520. + endstack = (unsigned long *) PAGE_ALIGN(addr);
  12521. +
  12522. + printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack);
  12523. + for (i = 0; i < kstack_depth_to_print; i++) {
  12524. + if (stack + 1 > endstack)
  12525. + break;
  12526. + if (i % 8 == 0)
  12527. + printk(KERN_EMERG "\n ");
  12528. + printk(KERN_EMERG " %08lx", *stack++);
  12529. + }
  12530. +
  12531. + printk(KERN_EMERG "\nCall Trace:");
  12532. + i = 0;
  12533. + while (stack + 1 <= endstack) {
  12534. + addr = *stack++;
  12535. + /*
  12536. + * If the address is either in the text segment of the
  12537. + * kernel, or in the region which contains vmalloc'ed
  12538. + * memory, it *may* be the address of a calling
  12539. + * routine; if so, print it so that someone tracing
  12540. + * down the cause of the crash will be able to figure
  12541. + * out the call path that was taken.
  12542. + */
  12543. + if (((addr >= (unsigned long) &_start) &&
  12544. + (addr <= (unsigned long) &_etext))) {
  12545. + if (i % 4 == 0)
  12546. + printk(KERN_EMERG "\n ");
  12547. + printk(KERN_EMERG " [<%08lx>]", addr);
  12548. + i++;
  12549. + }
  12550. + }
  12551. + printk(KERN_EMERG "\n");
  12552. +}
  12553. +
  12554. +void die_if_kernel(char *str, struct pt_regs *pregs)
  12555. +{
  12556. + unsigned long pc;
  12557. +
  12558. + pc = pregs->ra;
  12559. + printk("0x%08lx\n trapped to die_if_kernel\n",pregs->ra);
  12560. + show_regs(pregs);
  12561. + if(pregs->status_extension & PS_S)
  12562. + do_exit(SIGKILL);
  12563. + do_exit(SIGSEGV);
  12564. +}
  12565. +
  12566. +void do_hw_interrupt(unsigned long type, unsigned long psr, unsigned long pc)
  12567. +{
  12568. + if(type < 0x10) {
  12569. + printk("Unimplemented Nios2 TRAP, type = %02lx\n", type);
  12570. + die_if_kernel("Whee... Hello Mr. Penguin", current->thread.kregs);
  12571. + }
  12572. +}
  12573. +
  12574. +#if 0
  12575. +void handle_watchpoint(struct pt_regs *regs, unsigned long pc, unsigned long psr)
  12576. +{
  12577. +#ifdef TRAP_DEBUG
  12578. + printk("Watchpoint detected at PC %08lx PSR %08lx\n", pc, psr);
  12579. +#endif
  12580. + if(psr & PSR_SUPERVISOR)
  12581. + panic("Tell me what a watchpoint trap is, and I'll then deal "
  12582. + "with such a beast...");
  12583. +}
  12584. +#endif
  12585. +
  12586. +void trap_init(void)
  12587. +{
  12588. +#ifdef DEBUG
  12589. + printk("trap_init reached\n");
  12590. +#endif
  12591. +}
  12592. diff --git a/arch/nios2nommu/kernel/usb.c b/arch/nios2nommu/kernel/usb.c
  12593. new file mode 100644
  12594. index 0000000..65655b6
  12595. --- /dev/null
  12596. +++ b/arch/nios2nommu/kernel/usb.c
  12597. @@ -0,0 +1,341 @@
  12598. +/*
  12599. + * arch/nios2nommu/kernel/usb.c -- platform level USB initialization
  12600. + *
  12601. + * This program is free software; you can redistribute it and/or modify
  12602. + * it under the terms of the GNU General Public License as published by
  12603. + * the Free Software Foundation; either version 2 of the License, or
  12604. + * (at your option) any later version.
  12605. + *
  12606. + * This program is distributed in the hope that it will be useful,
  12607. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12608. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12609. + * GNU General Public License for more details.
  12610. + *
  12611. + * You should have received a copy of the GNU General Public License
  12612. + * along with this program; if not, write to the Free Software
  12613. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  12614. + */
  12615. +
  12616. +#undef DEBUG
  12617. +
  12618. +#include <linux/module.h>
  12619. +#include <linux/kernel.h>
  12620. +#include <linux/types.h>
  12621. +#include <linux/errno.h>
  12622. +#include <linux/init.h>
  12623. +#include <linux/platform_device.h>
  12624. +#include <linux/delay.h>
  12625. +
  12626. +#include <asm/io.h>
  12627. +#include <asm/irq.h>
  12628. +#include <asm/system.h>
  12629. +#include <asm/nios.h>
  12630. +
  12631. +#if defined(CONFIG_USB_SL811_HCD) || defined (CONFIG_USB_SL811_HCD_MODULE)
  12632. +#if defined(CONFIG_MICROTRONIX_STRATIX) || defined (CONFIG_MICROTRONIX_CYCLONE)
  12633. +
  12634. +#include <linux/usb/sl811.h>
  12635. +#define SL811_ADDR ((unsigned int)na_usb)
  12636. +#define SL811_IRQ na_usb_irq
  12637. +
  12638. +static void sl811_port_power(struct device *dev, int is_on)
  12639. +{
  12640. +}
  12641. +
  12642. +static void sl811_port_reset(struct device *dev)
  12643. +{
  12644. + writeb(0xA, (SL811_ADDR+8));
  12645. + mdelay(10);
  12646. + writeb(4, (SL811_ADDR+8));
  12647. +}
  12648. +
  12649. +static struct resource sl811hs_resources[] = {
  12650. + {
  12651. + .start = (SL811_ADDR),
  12652. + .end = (SL811_ADDR + 3),
  12653. + .flags = IORESOURCE_MEM,
  12654. + },
  12655. + {
  12656. + .start = (SL811_ADDR + 4),
  12657. + .end = (SL811_ADDR + 7),
  12658. + .flags = IORESOURCE_MEM,
  12659. + },
  12660. + {
  12661. + .start = SL811_IRQ,
  12662. + .flags = IORESOURCE_IRQ,
  12663. + },
  12664. +};
  12665. +
  12666. +static struct sl811_platform_data sl811_data = {
  12667. + .can_wakeup = 0,
  12668. + .potpg = 0,
  12669. + .power = 250,
  12670. + .port_power = sl811_port_power,
  12671. + .reset = sl811_port_reset,
  12672. +};
  12673. +
  12674. +static struct platform_device sl811hs_device = {
  12675. + .name = "sl811-hcd",
  12676. + .id = -1,
  12677. + .dev = {
  12678. + //.release = usb_release,
  12679. + //.dma_mask = &ohci_dmamask,
  12680. + .coherent_dma_mask = 0x0fffffff,
  12681. + .platform_data = &sl811_data,
  12682. + },
  12683. + .num_resources = ARRAY_SIZE(sl811hs_resources),
  12684. + .resource = sl811hs_resources,
  12685. +};
  12686. +
  12687. +
  12688. +static int __init mtx_kit_usb_init(void)
  12689. +{
  12690. + int status;
  12691. +
  12692. + status = platform_device_register(&sl811hs_device);
  12693. + if (status) {
  12694. + pr_debug("can't register sl811hs device, %d\n", status);
  12695. + return -1;
  12696. + }
  12697. +
  12698. + writeb(4, (SL811_ADDR+8));
  12699. + return 0;
  12700. +}
  12701. +
  12702. +subsys_initcall(mtx_kit_usb_init);
  12703. +#endif /* (CONFIG_MICROTRONIX_STRATIX) || (CONFIG_MICROTRONIX_CYCLONE)*/
  12704. +#endif /*(CONFIG_USB_SL811_HCD) ||(CONFIG_USB_SL811_HCD_MODULE) */
  12705. +
  12706. +#if defined(CONFIG_USB_ISP116X_HCD) || defined (CONFIG_USB_ISP116X_HCD_MODULE)
  12707. +
  12708. +#include <linux/usb/isp116x.h>
  12709. +
  12710. +#define ISP116X_HCD_ADDR ((unsigned int)na_usb)
  12711. +#define ISP116X_HCD_IRQ na_usb_irq
  12712. +
  12713. +static void isp116x_delay(struct device *dev, int delay)
  12714. +{
  12715. + ndelay(delay);
  12716. +}
  12717. +
  12718. +static struct resource isp116x_hcd_resources[] = {
  12719. + {
  12720. + .start = (ISP116X_HCD_ADDR),
  12721. + .end = (ISP116X_HCD_ADDR + 3),
  12722. + .flags = IORESOURCE_MEM,
  12723. + },
  12724. + {
  12725. + .start = (ISP116X_HCD_ADDR + 4),
  12726. + .end = (ISP116X_HCD_ADDR + 7),
  12727. + .flags = IORESOURCE_MEM,
  12728. + },
  12729. + {
  12730. + .start = ISP116X_HCD_IRQ,
  12731. + .flags = IORESOURCE_IRQ,
  12732. + },
  12733. +};
  12734. +
  12735. +static struct isp116x_platform_data isp116x_data = {
  12736. + // Enable internal resistors on downstream ports
  12737. + .sel15Kres = 1,
  12738. + // On-chip overcurrent protection
  12739. + .oc_enable = 1,
  12740. + // INT output polarity
  12741. + .int_act_high = 0,
  12742. + // INT edge or level triggered
  12743. + .int_edge_triggered = 0,
  12744. + // Wakeup by devices on usb bus enabled
  12745. + .remote_wakeup_enable = 0,
  12746. + .delay = isp116x_delay,
  12747. +};
  12748. +
  12749. +static struct platform_device isp116x_hcd = {
  12750. + .name = "isp116x-hcd",
  12751. + .id = -1,
  12752. + .dev = {
  12753. + //.release = usb_release,
  12754. + //.dma_mask = &ohci_dmamask,
  12755. + .coherent_dma_mask = 0x0fffffff,
  12756. + .platform_data = &isp116x_data,
  12757. + },
  12758. + .num_resources = ARRAY_SIZE(isp116x_hcd_resources),
  12759. + .resource = isp116x_hcd_resources,
  12760. +};
  12761. +
  12762. +static int __init usb_hcd_init(void)
  12763. +{
  12764. + int status;
  12765. +
  12766. + status = platform_device_register(&isp116x_hcd);
  12767. + if (status) {
  12768. + pr_debug("can't register isp116x host controller, %d\n", status);
  12769. + return -1;
  12770. + }
  12771. +
  12772. + return 0;
  12773. +}
  12774. +subsys_initcall(usb_hcd_init);
  12775. +#endif /*(CONFIG_USB_ISP116X_HCD) ||(CONFIG_USB_ISP116X_HCD_MODULE) */
  12776. +
  12777. +#if defined(CONFIG_USB_ISP1161X) || defined(CONFIG_USB_ISP1161X_MODULE)
  12778. +#include <linux/usb_isp116x_dc.h>
  12779. +
  12780. +#define ISP116X_UDC_ADDR ((unsigned int)na_usb+8)
  12781. +#define ISP116X_UDC_IRQ na_int2_usb_irq
  12782. +
  12783. +static struct resource isp116x_udc_resources[] = {
  12784. + {
  12785. + .start = (ISP116X_UDC_ADDR),
  12786. + .end = (ISP116X_UDC_ADDR + 3),
  12787. + .flags = IORESOURCE_MEM,
  12788. + },
  12789. + {
  12790. + .start = (ISP116X_UDC_ADDR + 4),
  12791. + .end = (ISP116X_UDC_ADDR + 7),
  12792. + .flags = IORESOURCE_MEM,
  12793. + },
  12794. + {
  12795. + .start = ISP116X_UDC_IRQ,
  12796. + .flags = IORESOURCE_IRQ,
  12797. + },
  12798. +};
  12799. +static void isp116x_udc_delay()
  12800. +{
  12801. + __asm__ __volatile__(
  12802. + "1: \n\t"
  12803. + " beq %0,zero,2f\n\t"
  12804. + " addi %0, %0, -1\n\t"
  12805. + " br 1b\n\t"
  12806. + "2: \n\t"
  12807. + :
  12808. + : "r" (nasys_clock_freq_1000 * 180 / 2000000)
  12809. + );
  12810. +
  12811. +}
  12812. +struct isp116x_dc_platform_data isp116x_udc_data = {
  12813. + .ext_pullup_enable =0,
  12814. + .no_lazy =1,
  12815. + .eot_act_high =0,
  12816. + .remote_wakeup_enable=1,
  12817. + .power_off_enable =1,
  12818. + .int_edge_triggered =0,
  12819. + .int_act_high =0,
  12820. + .clkout_freq =12,
  12821. + .delay = isp116x_udc_delay
  12822. +};
  12823. +
  12824. +static struct platform_device isp116x_udc = {
  12825. + .name = "isp1161a_udc",
  12826. + .id = -1,
  12827. + .dev = {
  12828. + //.release = usb_release,
  12829. + //.dma_mask = &ohci_dmamask,
  12830. + .coherent_dma_mask = 0x0fffffff,
  12831. + .platform_data = &isp116x_udc_data,
  12832. + },
  12833. + .num_resources = ARRAY_SIZE(isp116x_udc_resources),
  12834. + .resource = isp116x_udc_resources,
  12835. +};
  12836. +
  12837. +static int __init usb_udc_init(void)
  12838. +{
  12839. + int status;
  12840. + np_pio* pio;
  12841. +
  12842. + status = platform_device_register(&isp116x_udc);
  12843. + if (status) {
  12844. + pr_debug("can't register isp116x device controller, %d\n", status);
  12845. + return -1;
  12846. + }
  12847. +
  12848. + /* enable interrupts */
  12849. + pio = (np_pio*)na_int2_usb;
  12850. + //outw(0, &pio->np_piodata);
  12851. + //outw(0, &pio->np_pioedgecapture);
  12852. + outw(1, &pio->np_piointerruptmask);
  12853. +
  12854. + return 0;
  12855. +}
  12856. +subsys_initcall(usb_udc_init);
  12857. +#endif
  12858. +
  12859. +#if defined(na_ISP1362_avalonS) // for DE2 dev board, FIX ME otehrwise
  12860. +#define na_usb na_ISP1362_avalonS
  12861. +#define na_usb_irq na_ISP1362_avalonS_irq
  12862. +#endif
  12863. +
  12864. +#if defined(na_ISP1362_avalon_slave_0) // for DE2 dev board, FIX ME otehrwise
  12865. +#define na_usb na_ISP1362_avalon_slave_0
  12866. +#define na_usb_irq na_ISP1362_avalon_slave_0_irq
  12867. +#endif
  12868. +
  12869. +#if defined(CONFIG_USB_ISP1362_HCD) && defined(na_usb)
  12870. +
  12871. +#include <linux/usb_isp1362.h>
  12872. +#define ISP1362_HCD_ADDR ((unsigned int)na_usb)
  12873. +#define ISP1362_HCD_IRQ na_usb_irq
  12874. +
  12875. +static struct resource isp1362_hcd_resources[] = {
  12876. + {
  12877. + .start = (ISP1362_HCD_ADDR),
  12878. + .end = (ISP1362_HCD_ADDR + 3),
  12879. + .flags = IORESOURCE_MEM,
  12880. + },
  12881. + {
  12882. + .start = (ISP1362_HCD_ADDR + 4),
  12883. + .end = (ISP1362_HCD_ADDR + 7),
  12884. + .flags = IORESOURCE_MEM,
  12885. + },
  12886. + {
  12887. + .start = ISP1362_HCD_IRQ,
  12888. + .flags = IORESOURCE_IRQ,
  12889. + },
  12890. +};
  12891. +
  12892. +static struct isp1362_platform_data isp1362_data = {
  12893. + // Enable internal resistors on downstream ports
  12894. + .sel15Kres = 1,
  12895. + // Clock cannot be stopped
  12896. + .clknotstop = 0,
  12897. + // On-chip overcurrent protection
  12898. + .oc_enable = 0,
  12899. + // INT output polarity
  12900. + .int_act_high = 0,
  12901. + // INT edge or level triggered
  12902. + .int_edge_triggered = 0,
  12903. + // WAKEUP pin connected
  12904. + .remote_wakeup_connected = 0,
  12905. + // Switch or not to switch (keep always powered)
  12906. + .no_power_switching = 1,
  12907. + // Ganged port power switching (0) or individual port power switching (1)
  12908. + .power_switching_mode = 0,
  12909. +};
  12910. +
  12911. +static struct platform_device isp1362_hcd = {
  12912. + .name = "isp1362-hcd",
  12913. + .id = -1,
  12914. + .dev = {
  12915. + //.release = usb_release,
  12916. + //.dma_mask = &ohci_dmamask,
  12917. + .coherent_dma_mask = 0x0fffffff,
  12918. + .platform_data = &isp1362_data,
  12919. + },
  12920. + .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  12921. + .resource = isp1362_hcd_resources,
  12922. +};
  12923. +
  12924. +static int __init usb_hcd_init(void)
  12925. +{
  12926. + int status;
  12927. +
  12928. + status = platform_device_register(&isp1362_hcd);
  12929. + if (status) {
  12930. + pr_debug("can't register isp1362 host controller, %d\n", status);
  12931. + return -1;
  12932. + }
  12933. +
  12934. + return 0;
  12935. +}
  12936. +subsys_initcall(usb_hcd_init);
  12937. +#endif
  12938. +
  12939. diff --git a/arch/nios2nommu/kernel/vmlinux.lds.S b/arch/nios2nommu/kernel/vmlinux.lds.S
  12940. new file mode 100644
  12941. index 0000000..491901c
  12942. --- /dev/null
  12943. +++ b/arch/nios2nommu/kernel/vmlinux.lds.S
  12944. @@ -0,0 +1,141 @@
  12945. +#include <asm-generic/vmlinux.lds.h>
  12946. +#include <asm/nios.h>
  12947. +
  12948. +OUTPUT_FORMAT("elf32-littlenios2", "elf32-littlenios2", "elf32-littlenios2")
  12949. +
  12950. +OUTPUT_ARCH(nios)
  12951. +ENTRY(_start) /* Defined in head.S */
  12952. +
  12953. +jiffies = jiffies_64;
  12954. +
  12955. +SECTIONS
  12956. +{
  12957. + . = nasys_program_mem;
  12958. + /* read-only */
  12959. + _stext = . ;
  12960. + _text = .; /* Text and read-only data */
  12961. + .text : {
  12962. + TEXT_TEXT
  12963. + SCHED_TEXT
  12964. + LOCK_TEXT
  12965. + *(.fixup)
  12966. + *(.gnu.warning)
  12967. + } =0
  12968. +
  12969. + . = ALIGN(4) ;
  12970. + _etext = .; /* End of text section */
  12971. +
  12972. + . = ALIGN(32); /* Exception table */
  12973. + __start___ex_table = .;
  12974. + __ex_table : { *(__ex_table) }
  12975. + __stop___ex_table = .;
  12976. +
  12977. + RODATA
  12978. +
  12979. + /* writeable */
  12980. + .data : { /* Data */
  12981. + /*
  12982. + * This ALIGN is needed as a workaround for a bug a gcc bug upto 4.1 which
  12983. + * limits the maximum alignment to at most 32kB and results in the following
  12984. + * warning:
  12985. + *
  12986. + * CC arch/mips/kernel/init_task.o
  12987. + * arch/mips/kernel/init_task.c:30: warning: alignment of ‘init_thread_union’
  12988. + * is greater than maximum object file alignment. Using 32768
  12989. + */
  12990. + . = ALIGN(4096);
  12991. + *(.data.init_task)
  12992. +
  12993. + *(.data)
  12994. +
  12995. + CONSTRUCTORS
  12996. + }
  12997. +
  12998. + .lit8 : { *(.lit8) }
  12999. + .lit4 : { *(.lit4) }
  13000. + /* We want the small data sections together, so single-instruction offsets
  13001. + can access them all, and initialized data all before uninitialized, so
  13002. + we can shorten the on-disk segment size. */
  13003. + .sdata : { *(.sdata) }
  13004. +
  13005. + . = ALIGN(4096);
  13006. + __nosave_begin = .;
  13007. + .data_nosave : { *(.data.nosave) }
  13008. + . = ALIGN(4096);
  13009. + __nosave_end = .;
  13010. +
  13011. + . = ALIGN(32);
  13012. + .data.cacheline_aligned : { *(.data.cacheline_aligned) }
  13013. +
  13014. + _edata = .; /* End of data section */
  13015. +
  13016. + /* will be freed after init */
  13017. + . = ALIGN(4096); /* Init code and data */
  13018. + __init_begin = .;
  13019. + .init.text : {
  13020. + _sinittext = .;
  13021. + *(.init.text)
  13022. + _einittext = .;
  13023. + }
  13024. + .init.data : { *(.init.data) }
  13025. + . = ALIGN(16);
  13026. + __setup_start = .;
  13027. + .init.setup : { *(.init.setup) }
  13028. + __setup_end = .;
  13029. +
  13030. + __initcall_start = .;
  13031. + .initcall.init : {
  13032. + INITCALLS
  13033. + }
  13034. + __initcall_end = .;
  13035. +
  13036. + __con_initcall_start = .;
  13037. + .con_initcall.init : { *(.con_initcall.init) }
  13038. + __con_initcall_end = .;
  13039. + SECURITY_INIT
  13040. + /* .exit.text is discarded at runtime, not link time, to deal with
  13041. + references from .rodata */
  13042. + .exit.text : { *(.exit.text) }
  13043. + .exit.data : { *(.exit.data) }
  13044. + . = ALIGN(4096);
  13045. + __initramfs_start = .;
  13046. + .init.ramfs : { *(.init.ramfs) }
  13047. + __initramfs_end = .;
  13048. + . = ALIGN(32);
  13049. + __per_cpu_start = .;
  13050. + .data.percpu : { *(.data.percpu) }
  13051. + __per_cpu_end = .;
  13052. + . = ALIGN(4096);
  13053. + __init_end = .;
  13054. + /* freed after init ends here */
  13055. +
  13056. + __bss_start = .; /* BSS */
  13057. + .sbss : {
  13058. + *(.sbss)
  13059. + *(.scommon)
  13060. + }
  13061. + .bss : {
  13062. + *(.bss)
  13063. + *(COMMON)
  13064. + }
  13065. + __bss_stop = .;
  13066. +
  13067. + _end = . ;
  13068. +
  13069. + /* Sections to be discarded */
  13070. + /DISCARD/ : {
  13071. + *(.exit.text)
  13072. + *(.exit.data)
  13073. + *(.exitcall.exit)
  13074. + }
  13075. +
  13076. +
  13077. + STABS_DEBUG
  13078. +
  13079. + DWARF_DEBUG
  13080. +
  13081. + /* These must appear regardless of . */
  13082. + .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
  13083. + .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
  13084. + .note : { *(.note) }
  13085. +}
  13086. diff --git a/arch/nios2nommu/lib/Makefile b/arch/nios2nommu/lib/Makefile
  13087. new file mode 100644
  13088. index 0000000..1315c57
  13089. --- /dev/null
  13090. +++ b/arch/nios2nommu/lib/Makefile
  13091. @@ -0,0 +1,17 @@
  13092. +#
  13093. +# Copyright (C) 2005 Microtronix Datacom Ltd
  13094. +#
  13095. +# This program is free software; you can redistribute it and/or modify it under
  13096. +# the terms of the GNU Library General Public License as published by the Free
  13097. +# Software Foundation; either version 2 of the License, or (at your option) any
  13098. +# later version.
  13099. +#
  13100. +# This program is distributed in the hope that it will be useful, but WITHOUT
  13101. +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13102. +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
  13103. +# details.
  13104. +
  13105. +####CSRC := $(wildcard *.c)
  13106. +####lib-y =$(patsubst %.c,%.o, $(CSRC))
  13107. +####wapos!
  13108. +lib-y =checksum.o string.o memcpy.o
  13109. diff --git a/arch/nios2nommu/lib/checksum.c b/arch/nios2nommu/lib/checksum.c
  13110. new file mode 100644
  13111. index 0000000..475f1a3
  13112. --- /dev/null
  13113. +++ b/arch/nios2nommu/lib/checksum.c
  13114. @@ -0,0 +1,73 @@
  13115. +/*--------------------------------------------------------------------
  13116. + *
  13117. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  13118. + *
  13119. + * Copyright (C) 2004 Microtronix Datacom Ltd
  13120. + *
  13121. + * This program is free software; you can redistribute it and/or modify
  13122. + * it under the terms of the GNU General Public License as published by
  13123. + * the Free Software Foundation; either version 2 of the License, or
  13124. + * (at your option) any later version.
  13125. + *
  13126. + * This program is distributed in the hope that it will be useful,
  13127. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13128. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13129. + * GNU General Public License for more details.
  13130. + *
  13131. + *
  13132. + * Jan/20/2004 dgt NiosII
  13133. + *
  13134. + ---------------------------------------------------------------------*/
  13135. +
  13136. +#include <net/checksum.h>
  13137. +#include <asm/checksum.h>
  13138. +
  13139. +/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  13140. +
  13141. +/*
  13142. + * computes the checksum of a memory block at buff, length len,
  13143. + * and adds in "sum" (32-bit)
  13144. + *
  13145. + * returns a 32-bit number suitable for feeding into itself
  13146. + * or csum_tcpudp_magic
  13147. + *
  13148. + * this function must be called with even lengths, except
  13149. + * for the last fragment, which may be odd
  13150. + *
  13151. + * it's best to have buff aligned on a 32-bit boundary
  13152. + */
  13153. +
  13154. +unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
  13155. +{
  13156. +#if 0
  13157. + __asm__ __volatile__ ...//;dgt2;tmp;not (yet) available...
  13158. + ...//;dgt2;tmp;NiosI didn't offer either...
  13159. +#else
  13160. + unsigned int result = do_csum(buff, len);
  13161. +
  13162. + /* add in old sum, and carry.. */
  13163. + result += sum;
  13164. + if (sum > result)
  13165. + result += 1;
  13166. + return result;
  13167. +#endif
  13168. +}
  13169. +
  13170. +
  13171. +/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  13172. +
  13173. +
  13174. +/*
  13175. + * the same as csum_partial, but copies from fs:src while it
  13176. + * checksums
  13177. + *
  13178. + * here even more important to align src and dst on a 32-bit (or even
  13179. + * better 64-bit) boundary
  13180. + */
  13181. +
  13182. +unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum)
  13183. +{
  13184. + memcpy(dst, src, len);
  13185. + return csum_partial(dst, len, sum);
  13186. +
  13187. +}
  13188. diff --git a/arch/nios2nommu/lib/memcpy.c b/arch/nios2nommu/lib/memcpy.c
  13189. new file mode 100644
  13190. index 0000000..6586b99
  13191. --- /dev/null
  13192. +++ b/arch/nios2nommu/lib/memcpy.c
  13193. @@ -0,0 +1,62 @@
  13194. +/*--------------------------------------------------------------------
  13195. + *
  13196. + * arch/nios2nommu/lib/memcpy.c
  13197. + *
  13198. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  13199. + *
  13200. + * Copyright (C) 2004 Microtronix Datacom Ltd
  13201. + *
  13202. + * This program is free software; you can redistribute it and/or modify
  13203. + * it under the terms of the GNU General Public License as published by
  13204. + * the Free Software Foundation; either version 2 of the License, or
  13205. + * (at your option) any later version.
  13206. + *
  13207. + * This program is distributed in the hope that it will be useful,
  13208. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13209. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13210. + * GNU General Public License for more details.
  13211. + *
  13212. + *
  13213. + * Jun/09/2004 dgt Split out separate source file from string.c
  13214. + *
  13215. + ---------------------------------------------------------------------*/
  13216. +
  13217. +#include <linux/types.h>
  13218. +#include <linux/autoconf.h>
  13219. +#include <asm/nios.h>
  13220. +#include <asm/string.h>
  13221. +
  13222. +#ifdef __HAVE_ARCH_MEMCPY
  13223. + void * memcpy(void * d, const void * s, size_t count)
  13224. + {
  13225. + unsigned long dst, src;
  13226. + dst = (unsigned long) d;
  13227. + src = (unsigned long) s;
  13228. +
  13229. + if ((count < 8) || ((dst ^ src) & 3))
  13230. + goto restup;
  13231. +
  13232. + if (dst & 1) {
  13233. + *(char*)dst++=*(char*)src++;
  13234. + count--;
  13235. + }
  13236. + if (dst & 2) {
  13237. + *(short*)dst=*(short*)src;
  13238. + src += 2;
  13239. + dst += 2;
  13240. + count -= 2;
  13241. + }
  13242. + while (count > 3) {
  13243. + *(long*)dst=*(long*)src;
  13244. + src += 4;
  13245. + dst += 4;
  13246. + count -= 4;
  13247. + }
  13248. +
  13249. + restup:
  13250. + while (count--)
  13251. + *(char*)dst++=*(char*)src++;
  13252. +
  13253. + return d;
  13254. + }
  13255. +#endif
  13256. diff --git a/arch/nios2nommu/lib/string.c b/arch/nios2nommu/lib/string.c
  13257. new file mode 100644
  13258. index 0000000..b87c195
  13259. --- /dev/null
  13260. +++ b/arch/nios2nommu/lib/string.c
  13261. @@ -0,0 +1,180 @@
  13262. +/*--------------------------------------------------------------------
  13263. + *
  13264. + * arch/nios2nommu/lib/string.c
  13265. + *
  13266. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  13267. + *
  13268. + * Copyright (C) 2004 Microtronix Datacom Ltd
  13269. + *
  13270. + * This program is free software; you can redistribute it and/or modify
  13271. + * it under the terms of the GNU General Public License as published by
  13272. + * the Free Software Foundation; either version 2 of the License, or
  13273. + * (at your option) any later version.
  13274. + *
  13275. + * This program is distributed in the hope that it will be useful,
  13276. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13277. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13278. + * GNU General Public License for more details.
  13279. + *
  13280. + *
  13281. + * Jan/20/2004 dgt NiosII
  13282. + * Jun/09/2004 dgt Split out memcpy into separate source file
  13283. + *
  13284. + ---------------------------------------------------------------------*/
  13285. +
  13286. +#include <linux/types.h>
  13287. +#include <linux/autoconf.h>
  13288. +#include <asm/nios.h>
  13289. +#include <asm/string.h>
  13290. +
  13291. +#ifdef __HAVE_ARCH_MEMSET
  13292. +void * memset(void * s,int c,size_t count)
  13293. +{
  13294. +
  13295. + if (count > 8) {
  13296. + int destptr, charcnt, dwordcnt, fill8reg, wrkrega;
  13297. + __asm__ __volatile__ (
  13298. + // fill8 %3, %5 (c & 0xff)\n\t"
  13299. + //
  13300. + " slli %4, %5, 8\n\t"
  13301. + " or %4, %4, %5\n\t"
  13302. + " slli %3, %4, 16\n\t"
  13303. + " or %3, %3, %4\n\t"
  13304. + //
  13305. + // Word-align %0 (s) if necessary
  13306. + //
  13307. + " andi %4, %0, 0x01\n\t"
  13308. + " beq %4, zero, 1f\n\t"
  13309. + " addi %1, %1, -1\n\t"
  13310. + " stb %3, 0(%0)\n\t"
  13311. + " addi %0, %0, 1\n\t"
  13312. + "1: \n\t"
  13313. + " mov %2, %1\n\t"
  13314. + //
  13315. + // Dword-align %0 (s) if necessary
  13316. + //
  13317. + " andi %4, %0, 0x02\n\t"
  13318. + " beq %4, zero, 2f\n\t"
  13319. + " addi %1, %1, -2\n\t"
  13320. + " sth %3, 0(%0)\n\t"
  13321. + " addi %0, %0, 2\n\t"
  13322. + " mov %2, %1\n\t"
  13323. + "2: \n\t"
  13324. + // %1 and %2 are how many more bytes to set
  13325. + //
  13326. + " srli %2, %2, 2\n\t"
  13327. + //
  13328. + // %2 is how many dwords to set
  13329. + //
  13330. + "3: ;\n\t"
  13331. + " stw %3, 0(%0)\n\t"
  13332. + " addi %0, %0, 4\n\t"
  13333. + " addi %2, %2, -1\n\t"
  13334. + " bne %2, zero, 3b\n\t"
  13335. + //
  13336. + // store residual word and/or byte if necessary
  13337. + //
  13338. + " andi %4, %1, 0x02\n\t"
  13339. + " beq %4, zero, 4f\n\t"
  13340. + " sth %3, 0(%0)\n\t"
  13341. + " addi %0, %0, 2\n\t"
  13342. + "4: \n\t"
  13343. + // store residual byte if necessary
  13344. + //
  13345. + " andi %4, %1, 0x01\n\t"
  13346. + " beq %4, zero, 5f\n\t"
  13347. + " stb %3, 0(%0)\n\t"
  13348. + "5: \n\t"
  13349. +
  13350. + : "=r" (destptr), /* %0 Output */
  13351. + "=r" (charcnt), /* %1 Output */
  13352. + "=r" (dwordcnt), /* %2 Output */
  13353. + "=r" (fill8reg), /* %3 Output */
  13354. + "=r" (wrkrega) /* %4 Output */
  13355. +
  13356. + : "r" (c & 0xff), /* %5 Input */
  13357. + "0" (s), /* %0 Input/Output */
  13358. + "1" (count) /* %1 Input/Output */
  13359. +
  13360. + : "memory" /* clobbered */
  13361. + );
  13362. + }
  13363. + else {
  13364. + char* xs=(char*)s;
  13365. + while (count--)
  13366. + *xs++ = c;
  13367. + }
  13368. + return s;
  13369. +}
  13370. +#endif
  13371. +
  13372. +#ifdef __HAVE_ARCH_MEMMOVE
  13373. +void * memmove(void * d, const void * s, size_t count)
  13374. +{
  13375. + unsigned long dst, src;
  13376. +
  13377. + if (d < s) {
  13378. + dst = (unsigned long) d;
  13379. + src = (unsigned long) s;
  13380. +
  13381. + if ((count < 8) || ((dst ^ src) & 3))
  13382. + goto restup;
  13383. +
  13384. + if (dst & 1) {
  13385. + *(char*)dst++=*(char*)src++;
  13386. + count--;
  13387. + }
  13388. + if (dst & 2) {
  13389. + *(short*)dst=*(short*)src;
  13390. + src += 2;
  13391. + dst += 2;
  13392. + count -= 2;
  13393. + }
  13394. + while (count > 3) {
  13395. + *(long*)dst=*(long*)src;
  13396. + src += 4;
  13397. + dst += 4;
  13398. + count -= 4;
  13399. + }
  13400. +
  13401. + restup:
  13402. + while (count--)
  13403. + *(char*)dst++=*(char*)src++;
  13404. + } else {
  13405. + dst = (unsigned long) d + count;
  13406. + src = (unsigned long) s + count;
  13407. +
  13408. + if ((count < 8) || ((dst ^ src) & 3))
  13409. + goto restdown;
  13410. +
  13411. + if (dst & 1) {
  13412. + src--;
  13413. + dst--;
  13414. + count--;
  13415. + *(char*)dst=*(char*)src;
  13416. + }
  13417. + if (dst & 2) {
  13418. + src -= 2;
  13419. + dst -= 2;
  13420. + count -= 2;
  13421. + *(short*)dst=*(short*)src;
  13422. + }
  13423. + while (count > 3) {
  13424. + src -= 4;
  13425. + dst -= 4;
  13426. + count -= 4;
  13427. + *(long*)dst=*(long*)src;
  13428. + }
  13429. +
  13430. + restdown:
  13431. + while (count--) {
  13432. + src--;
  13433. + dst--;
  13434. + *(char*)dst=*(char*)src;
  13435. + }
  13436. + }
  13437. +
  13438. + return d;
  13439. +
  13440. +}
  13441. +#endif
  13442. diff --git a/arch/nios2nommu/mm/Makefile b/arch/nios2nommu/mm/Makefile
  13443. new file mode 100644
  13444. index 0000000..b007a11
  13445. --- /dev/null
  13446. +++ b/arch/nios2nommu/mm/Makefile
  13447. @@ -0,0 +1,12 @@
  13448. +# $Id: Makefile,v 1.1 2006/07/05 06:23:18 gerg Exp $
  13449. +# Makefile for the linux Sparc-specific parts of the memory manager.
  13450. +#
  13451. +# Note! Dependencies are done automagically by 'make dep', which also
  13452. +# removes any old dependencies. DON'T put your own dependencies here
  13453. +# unless it's something special (ie not a .c file).
  13454. +#
  13455. +# Note 2! The CFLAGS definition is now in the main makefile...
  13456. +
  13457. +obj-y := init.o ioremap.o extable.o memory.o
  13458. +obj-y += dma-noncoherent.o
  13459. +
  13460. diff --git a/arch/nios2nommu/mm/dma-noncoherent.c b/arch/nios2nommu/mm/dma-noncoherent.c
  13461. new file mode 100644
  13462. index 0000000..5649940
  13463. --- /dev/null
  13464. +++ b/arch/nios2nommu/mm/dma-noncoherent.c
  13465. @@ -0,0 +1,373 @@
  13466. +/*
  13467. + * This file is subject to the terms and conditions of the GNU General Public
  13468. + * License. See the file "COPYING" in the main directory of this archive
  13469. + * for more details.
  13470. + *
  13471. + * Copyright (C) 2000 Ani Joshi <ajoshi@unixbox.com>
  13472. + * Copyright (C) 2000, 2001 Ralf Baechle <ralf@gnu.org>
  13473. + * swiped from i386, and cloned for MIPS by Geert, polished by Ralf.
  13474. + */
  13475. +#include <linux/types.h>
  13476. +#include <linux/mm.h>
  13477. +#include <linux/module.h>
  13478. +#include <linux/string.h>
  13479. +#include <linux/dma-mapping.h>
  13480. +
  13481. +#include <asm/cache.h>
  13482. +#include <asm/cacheflush.h>
  13483. +#include <asm/io.h>
  13484. +
  13485. +#define UNCAC_ADDR(addr) ((void *)((unsigned long)(addr) | 0x80000000))
  13486. +#define CAC_ADDR(addr) ((void *)((unsigned long)(addr) & ~0x80000000))
  13487. +
  13488. +/*
  13489. + * Warning on the terminology - Linux calls an uncached area coherent;
  13490. + * MIPS terminology calls memory areas with hardware maintained coherency
  13491. + * coherent.
  13492. + */
  13493. +
  13494. +void *dma_alloc_noncoherent(struct device *dev, size_t size,
  13495. + dma_addr_t * dma_handle, gfp_t gfp)
  13496. +{
  13497. + void *ret;
  13498. + /* ignore region specifiers */
  13499. + gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
  13500. +
  13501. + if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
  13502. + gfp |= GFP_DMA;
  13503. + ret = (void *) __get_free_pages(gfp, get_order(size));
  13504. +
  13505. + if (ret != NULL) {
  13506. + memset(ret, 0, size);
  13507. + *dma_handle = virt_to_phys(ret);
  13508. + }
  13509. +
  13510. + return ret;
  13511. +}
  13512. +
  13513. +EXPORT_SYMBOL(dma_alloc_noncoherent);
  13514. +
  13515. +void *dma_alloc_coherent(struct device *dev, size_t size,
  13516. + dma_addr_t * dma_handle, gfp_t gfp)
  13517. +{
  13518. + void *ret;
  13519. +
  13520. + ret = dma_alloc_noncoherent(dev, size, dma_handle, gfp);
  13521. + if (ret) {
  13522. + dma_cache_wback_inv((unsigned long) ret, size);
  13523. + ret = UNCAC_ADDR(ret);
  13524. + }
  13525. +
  13526. + return ret;
  13527. +}
  13528. +
  13529. +EXPORT_SYMBOL(dma_alloc_coherent);
  13530. +
  13531. +void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr,
  13532. + dma_addr_t dma_handle)
  13533. +{
  13534. + free_pages((unsigned long) vaddr, get_order(size));
  13535. +}
  13536. +
  13537. +EXPORT_SYMBOL(dma_free_noncoherent);
  13538. +
  13539. +void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
  13540. + dma_addr_t dma_handle)
  13541. +{
  13542. + unsigned long addr = (unsigned long) vaddr;
  13543. +
  13544. + addr = (unsigned long) CAC_ADDR(addr);
  13545. + free_pages(addr, get_order(size));
  13546. +}
  13547. +
  13548. +EXPORT_SYMBOL(dma_free_coherent);
  13549. +
  13550. +static inline void __dma_sync(unsigned long addr, size_t size,
  13551. + enum dma_data_direction direction)
  13552. +{
  13553. + switch (direction) {
  13554. + case DMA_TO_DEVICE:
  13555. + dma_cache_wback(addr, size);
  13556. + break;
  13557. +
  13558. + case DMA_FROM_DEVICE:
  13559. + dma_cache_inv(addr, size);
  13560. + break;
  13561. +
  13562. + case DMA_BIDIRECTIONAL:
  13563. + dma_cache_wback_inv(addr, size);
  13564. + break;
  13565. +
  13566. + default:
  13567. + BUG();
  13568. + }
  13569. +}
  13570. +
  13571. +dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
  13572. + enum dma_data_direction direction)
  13573. +{
  13574. + unsigned long addr = (unsigned long) ptr;
  13575. +
  13576. + __dma_sync(addr, size, direction);
  13577. +
  13578. + return virt_to_phys(ptr);
  13579. +}
  13580. +
  13581. +EXPORT_SYMBOL(dma_map_single);
  13582. +
  13583. +void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
  13584. + enum dma_data_direction direction)
  13585. +{
  13586. + unsigned long addr;
  13587. + addr = dma_addr + PAGE_OFFSET;
  13588. +
  13589. + //__dma_sync(addr, size, direction);
  13590. +}
  13591. +
  13592. +EXPORT_SYMBOL(dma_unmap_single);
  13593. +
  13594. +int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
  13595. + enum dma_data_direction direction)
  13596. +{
  13597. + int i;
  13598. +
  13599. + BUG_ON(direction == DMA_NONE);
  13600. +
  13601. + for (i = 0; i < nents; i++, sg++) {
  13602. + unsigned long addr;
  13603. +
  13604. + addr = (unsigned long) page_address(sg->page);
  13605. + if (addr) {
  13606. + __dma_sync(addr + sg->offset, sg->length, direction);
  13607. + sg->dma_address = (dma_addr_t)page_to_phys(sg->page)
  13608. + + sg->offset;
  13609. + }
  13610. + }
  13611. +
  13612. + return nents;
  13613. +}
  13614. +
  13615. +EXPORT_SYMBOL(dma_map_sg);
  13616. +
  13617. +dma_addr_t dma_map_page(struct device *dev, struct page *page,
  13618. + unsigned long offset, size_t size, enum dma_data_direction direction)
  13619. +{
  13620. + unsigned long addr;
  13621. +
  13622. + BUG_ON(direction == DMA_NONE);
  13623. +
  13624. + addr = (unsigned long) page_address(page) + offset;
  13625. + dma_cache_wback_inv(addr, size);
  13626. +
  13627. + return page_to_phys(page) + offset;
  13628. +}
  13629. +
  13630. +EXPORT_SYMBOL(dma_map_page);
  13631. +
  13632. +void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
  13633. + enum dma_data_direction direction)
  13634. +{
  13635. + BUG_ON(direction == DMA_NONE);
  13636. +
  13637. + if (direction != DMA_TO_DEVICE) {
  13638. + unsigned long addr;
  13639. +
  13640. + addr = dma_address + PAGE_OFFSET;
  13641. + dma_cache_wback_inv(addr, size);
  13642. + }
  13643. +}
  13644. +
  13645. +EXPORT_SYMBOL(dma_unmap_page);
  13646. +
  13647. +void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
  13648. + enum dma_data_direction direction)
  13649. +{
  13650. + unsigned long addr;
  13651. + int i;
  13652. +
  13653. + BUG_ON(direction == DMA_NONE);
  13654. +
  13655. + if (direction == DMA_TO_DEVICE)
  13656. + return;
  13657. +
  13658. + for (i = 0; i < nhwentries; i++, sg++) {
  13659. + addr = (unsigned long) page_address(sg->page);
  13660. + if (addr)
  13661. + __dma_sync(addr + sg->offset, sg->length, direction);
  13662. + }
  13663. +}
  13664. +
  13665. +EXPORT_SYMBOL(dma_unmap_sg);
  13666. +
  13667. +void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
  13668. + size_t size, enum dma_data_direction direction)
  13669. +{
  13670. + unsigned long addr;
  13671. +
  13672. + BUG_ON(direction == DMA_NONE);
  13673. +
  13674. + addr = dma_handle + PAGE_OFFSET;
  13675. + __dma_sync(addr, size, direction);
  13676. +}
  13677. +
  13678. +EXPORT_SYMBOL(dma_sync_single_for_cpu);
  13679. +
  13680. +void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
  13681. + size_t size, enum dma_data_direction direction)
  13682. +{
  13683. + unsigned long addr;
  13684. +
  13685. + BUG_ON(direction == DMA_NONE);
  13686. +
  13687. + addr = dma_handle + PAGE_OFFSET;
  13688. + __dma_sync(addr, size, direction);
  13689. +}
  13690. +
  13691. +EXPORT_SYMBOL(dma_sync_single_for_device);
  13692. +
  13693. +void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
  13694. + unsigned long offset, size_t size, enum dma_data_direction direction)
  13695. +{
  13696. + unsigned long addr;
  13697. +
  13698. + BUG_ON(direction == DMA_NONE);
  13699. +
  13700. + addr = dma_handle + offset + PAGE_OFFSET;
  13701. + __dma_sync(addr, size, direction);
  13702. +}
  13703. +
  13704. +EXPORT_SYMBOL(dma_sync_single_range_for_cpu);
  13705. +
  13706. +void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
  13707. + unsigned long offset, size_t size, enum dma_data_direction direction)
  13708. +{
  13709. + unsigned long addr;
  13710. +
  13711. + BUG_ON(direction == DMA_NONE);
  13712. +
  13713. + addr = dma_handle + offset + PAGE_OFFSET;
  13714. + __dma_sync(addr, size, direction);
  13715. +}
  13716. +
  13717. +EXPORT_SYMBOL(dma_sync_single_range_for_device);
  13718. +
  13719. +void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
  13720. + enum dma_data_direction direction)
  13721. +{
  13722. + int i;
  13723. +
  13724. + BUG_ON(direction == DMA_NONE);
  13725. +
  13726. + /* Make sure that gcc doesn't leave the empty loop body. */
  13727. + for (i = 0; i < nelems; i++, sg++)
  13728. + __dma_sync((unsigned long)page_address(sg->page),
  13729. + sg->length, direction);
  13730. +}
  13731. +
  13732. +EXPORT_SYMBOL(dma_sync_sg_for_cpu);
  13733. +
  13734. +void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
  13735. + enum dma_data_direction direction)
  13736. +{
  13737. + int i;
  13738. +
  13739. + BUG_ON(direction == DMA_NONE);
  13740. +
  13741. + /* Make sure that gcc doesn't leave the empty loop body. */
  13742. + for (i = 0; i < nelems; i++, sg++)
  13743. + __dma_sync((unsigned long)page_address(sg->page),
  13744. + sg->length, direction);
  13745. +}
  13746. +
  13747. +EXPORT_SYMBOL(dma_sync_sg_for_device);
  13748. +
  13749. +int dma_mapping_error(dma_addr_t dma_addr)
  13750. +{
  13751. + return 0;
  13752. +}
  13753. +
  13754. +EXPORT_SYMBOL(dma_mapping_error);
  13755. +
  13756. +int dma_supported(struct device *dev, u64 mask)
  13757. +{
  13758. + /*
  13759. + * we fall back to GFP_DMA when the mask isn't all 1s,
  13760. + * so we can't guarantee allocations that must be
  13761. + * within a tighter range than GFP_DMA..
  13762. + */
  13763. + if (mask < 0x00ffffff)
  13764. + return 0;
  13765. +
  13766. + return 1;
  13767. +}
  13768. +
  13769. +EXPORT_SYMBOL(dma_supported);
  13770. +
  13771. +int dma_is_consistent(dma_addr_t dma_addr)
  13772. +{
  13773. + return 1;
  13774. +}
  13775. +
  13776. +EXPORT_SYMBOL(dma_is_consistent);
  13777. +
  13778. +void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction direction)
  13779. +{
  13780. + if (direction == DMA_NONE)
  13781. + return;
  13782. +
  13783. + dma_cache_wback_inv((unsigned long)vaddr, size);
  13784. +}
  13785. +
  13786. +EXPORT_SYMBOL(dma_cache_sync);
  13787. +
  13788. +/* The DAC routines are a PCIism.. */
  13789. +
  13790. +#ifdef CONFIG_PCI
  13791. +
  13792. +#include <linux/pci.h>
  13793. +
  13794. +dma64_addr_t pci_dac_page_to_dma(struct pci_dev *pdev,
  13795. + struct page *page, unsigned long offset, int direction)
  13796. +{
  13797. + return (dma64_addr_t)page_to_phys(page) + offset;
  13798. +}
  13799. +
  13800. +EXPORT_SYMBOL(pci_dac_page_to_dma);
  13801. +
  13802. +struct page *pci_dac_dma_to_page(struct pci_dev *pdev,
  13803. + dma64_addr_t dma_addr)
  13804. +{
  13805. + return mem_map + (dma_addr >> PAGE_SHIFT);
  13806. +}
  13807. +
  13808. +EXPORT_SYMBOL(pci_dac_dma_to_page);
  13809. +
  13810. +unsigned long pci_dac_dma_to_offset(struct pci_dev *pdev,
  13811. + dma64_addr_t dma_addr)
  13812. +{
  13813. + return dma_addr & ~PAGE_MASK;
  13814. +}
  13815. +
  13816. +EXPORT_SYMBOL(pci_dac_dma_to_offset);
  13817. +
  13818. +void pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev,
  13819. + dma64_addr_t dma_addr, size_t len, int direction)
  13820. +{
  13821. + BUG_ON(direction == PCI_DMA_NONE);
  13822. +
  13823. + dma_cache_wback_inv(dma_addr + PAGE_OFFSET, len);
  13824. +}
  13825. +
  13826. +EXPORT_SYMBOL(pci_dac_dma_sync_single_for_cpu);
  13827. +
  13828. +void pci_dac_dma_sync_single_for_device(struct pci_dev *pdev,
  13829. + dma64_addr_t dma_addr, size_t len, int direction)
  13830. +{
  13831. + BUG_ON(direction == PCI_DMA_NONE);
  13832. +
  13833. + dma_cache_wback_inv(dma_addr + PAGE_OFFSET, len);
  13834. +}
  13835. +
  13836. +EXPORT_SYMBOL(pci_dac_dma_sync_single_for_device);
  13837. +
  13838. +#endif /* CONFIG_PCI */
  13839. diff --git a/arch/nios2nommu/mm/extable.c b/arch/nios2nommu/mm/extable.c
  13840. new file mode 100644
  13841. index 0000000..e23778f
  13842. --- /dev/null
  13843. +++ b/arch/nios2nommu/mm/extable.c
  13844. @@ -0,0 +1,29 @@
  13845. +/*
  13846. + * linux/arch/niosnommu/mm/extable.c
  13847. + */
  13848. +
  13849. +#include <linux/module.h>
  13850. +#include <linux/spinlock.h>
  13851. +#include <asm/uaccess.h>
  13852. +
  13853. +/* Simple binary search */
  13854. +const struct exception_table_entry *
  13855. +search_extable(const struct exception_table_entry *first,
  13856. + const struct exception_table_entry *last,
  13857. + unsigned long value)
  13858. +{
  13859. + while (first <= last) {
  13860. + const struct exception_table_entry *mid;
  13861. + long diff;
  13862. +
  13863. + mid = (last - first) / 2 + first;
  13864. + diff = mid->insn - value;
  13865. + if (diff == 0)
  13866. + return mid;
  13867. + else if (diff < 0)
  13868. + first = mid+1;
  13869. + else
  13870. + last = mid-1;
  13871. + }
  13872. + return NULL;
  13873. +}
  13874. diff --git a/arch/nios2nommu/mm/init.c b/arch/nios2nommu/mm/init.c
  13875. new file mode 100644
  13876. index 0000000..21fe61b
  13877. --- /dev/null
  13878. +++ b/arch/nios2nommu/mm/init.c
  13879. @@ -0,0 +1,231 @@
  13880. +/*
  13881. + * linux/arch/nios2nommu/mm/init.c
  13882. + *
  13883. + * Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>,
  13884. + * Kenneth Albanowski <kjahds@kjahds.com>,
  13885. + * Copyright (C) 2000 Lineo, Inc. (www.lineo.com)
  13886. + * Copyright (C) 2004 Microtronix Datacom Ltd
  13887. + *
  13888. + * Based on:
  13889. + *
  13890. + * linux/arch/m68k/mm/init.c
  13891. + *
  13892. + * Copyright (C) 1995 Hamish Macdonald
  13893. + *
  13894. + * JAN/1999 -- hacked to support ColdFire (gerg@snapgear.com)
  13895. + * DEC/2000 -- linux 2.4 support <davidm@snapgear.com>
  13896. + * Jan/20/2004 dgt NiosII
  13897. + *
  13898. + */
  13899. +
  13900. +#include <linux/signal.h>
  13901. +#include <linux/sched.h>
  13902. +#include <linux/kernel.h>
  13903. +#include <linux/errno.h>
  13904. +#include <linux/string.h>
  13905. +#include <linux/types.h>
  13906. +#include <linux/ptrace.h>
  13907. +#include <linux/mman.h>
  13908. +#include <linux/mm.h>
  13909. +#include <linux/swap.h>
  13910. +#include <linux/init.h>
  13911. +#include <linux/highmem.h>
  13912. +#include <linux/pagemap.h>
  13913. +#include <linux/bootmem.h>
  13914. +#include <linux/slab.h>
  13915. +
  13916. +#include <asm/setup.h>
  13917. +#include <asm/segment.h>
  13918. +#include <asm/page.h>
  13919. +#include <asm/pgtable.h>
  13920. +#include <asm/system.h>
  13921. +//;dgt2;#include <asm/machdep.h>
  13922. +//;dgt2;#include <asm/shglcore.h>
  13923. +
  13924. +#undef DEBUG
  13925. +
  13926. +extern void die_if_kernel(char *,struct pt_regs *,long);
  13927. +extern void free_initmem(void);
  13928. +
  13929. +/*
  13930. + * BAD_PAGE is the page that is used for page faults when linux
  13931. + * is out-of-memory. Older versions of linux just did a
  13932. + * do_exit(), but using this instead means there is less risk
  13933. + * for a process dying in kernel mode, possibly leaving a inode
  13934. + * unused etc..
  13935. + *
  13936. + * BAD_PAGETABLE is the accompanying page-table: it is initialized
  13937. + * to point to BAD_PAGE entries.
  13938. + *
  13939. + * ZERO_PAGE is a special page that is used for zero-initialized
  13940. + * data and COW.
  13941. + */
  13942. +static unsigned long empty_bad_page_table;
  13943. +
  13944. +static unsigned long empty_bad_page;
  13945. +
  13946. +unsigned long empty_zero_page;
  13947. +
  13948. +extern unsigned long rom_length;
  13949. +
  13950. +void show_mem(void)
  13951. +{
  13952. + unsigned long i;
  13953. + int free = 0, total = 0, reserved = 0, shared = 0;
  13954. + int cached = 0;
  13955. +
  13956. + printk(KERN_INFO "\nMem-info:\n");
  13957. + show_free_areas();
  13958. + i = max_mapnr;
  13959. + while (i-- > 0) {
  13960. + total++;
  13961. + if (PageReserved(mem_map+i))
  13962. + reserved++;
  13963. + else if (PageSwapCache(mem_map+i))
  13964. + cached++;
  13965. + else if (!page_count(mem_map+i))
  13966. + free++;
  13967. + else
  13968. + shared += page_count(mem_map+i) - 1;
  13969. + }
  13970. + printk(KERN_INFO "%d pages of RAM\n",total);
  13971. + printk(KERN_INFO "%d free pages\n",free);
  13972. + printk(KERN_INFO "%d reserved pages\n",reserved);
  13973. + printk(KERN_INFO "%d pages shared\n",shared);
  13974. + printk(KERN_INFO "%d pages swap cached\n",cached);
  13975. +}
  13976. +
  13977. +extern unsigned long memory_start;
  13978. +extern unsigned long memory_end;
  13979. +
  13980. +/*
  13981. + * paging_init() continues the virtual memory environment setup which
  13982. + * was begun by the code in arch/head.S.
  13983. + * The parameters are pointers to where to stick the starting and ending
  13984. + * addresses of available kernel virtual memory.
  13985. + */
  13986. +void __init paging_init(void)
  13987. +{
  13988. + /*
  13989. + * Make sure start_mem is page aligned, otherwise bootmem and
  13990. + * page_alloc get different views of the world.
  13991. + */
  13992. +#ifdef DEBUG
  13993. + unsigned long start_mem = PAGE_ALIGN(memory_start);
  13994. +#endif
  13995. + unsigned long end_mem = memory_end & PAGE_MASK;
  13996. +
  13997. +#ifdef DEBUG
  13998. + printk (KERN_DEBUG "start_mem is %#lx\nvirtual_end is %#lx\n",
  13999. + start_mem, end_mem);
  14000. +#endif
  14001. +
  14002. + /*
  14003. + * Initialize the bad page table and bad page to point
  14004. + * to a couple of allocated pages.
  14005. + */
  14006. + empty_bad_page_table = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
  14007. + empty_bad_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
  14008. + empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
  14009. + memset((void *)empty_zero_page, 0, PAGE_SIZE);
  14010. +
  14011. + /*
  14012. + * Set up SFC/DFC registers (user data space).
  14013. + */
  14014. + set_fs (USER_DS);
  14015. +
  14016. +#ifdef DEBUG
  14017. + printk (KERN_DEBUG "before free_area_init\n");
  14018. +
  14019. + printk (KERN_DEBUG "free_area_init -> start_mem is %#lx\nvirtual_end is %#lx\n",
  14020. + start_mem, end_mem);
  14021. +#endif
  14022. +
  14023. + {
  14024. + unsigned long zones_size[MAX_NR_ZONES] = {0, };
  14025. +
  14026. + zones_size[ZONE_DMA] = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT;
  14027. + zones_size[ZONE_NORMAL] = 0;
  14028. +#ifdef CONFIG_HIGHMEM
  14029. + zones_size[ZONE_HIGHMEM] = 0;
  14030. +#endif
  14031. + free_area_init(zones_size);
  14032. + }
  14033. +}
  14034. +
  14035. +void __init mem_init(void)
  14036. +{
  14037. + int codek = 0, datak = 0, initk = 0;
  14038. + unsigned long tmp;
  14039. + extern char _etext, _stext, __init_begin, __init_end, _end;
  14040. + unsigned long start_mem = memory_start; /* DAVIDM - these must start at end of kernel */
  14041. + unsigned long end_mem = memory_end; /* DAVIDM - this must not include kernel stack at top */
  14042. +
  14043. +#ifdef DEBUG
  14044. + printk(KERN_DEBUG "Mem_init: start=%lx, end=%lx\n", start_mem, end_mem);
  14045. +#endif
  14046. +
  14047. + end_mem &= PAGE_MASK;
  14048. + high_memory = (void *) end_mem;
  14049. +
  14050. + start_mem = PAGE_ALIGN(start_mem);
  14051. + max_mapnr = num_physpages = MAP_NR(high_memory);
  14052. +
  14053. + /* this will put all memory onto the freelists */
  14054. + totalram_pages = free_all_bootmem();
  14055. +
  14056. + codek = (&_etext - &_stext) >> 10;
  14057. + datak = (&_end - &_etext) >> 10;
  14058. + initk = (&__init_begin - &__init_end) >> 10;
  14059. +
  14060. + tmp = nr_free_pages() << PAGE_SHIFT;
  14061. + printk(KERN_INFO "Memory available: %luk/%luk RAM, %luk/%luk ROM (%dk kernel code, %dk data)\n",
  14062. + tmp >> 10,
  14063. + (&_end - &_stext) >> 10,
  14064. + (rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
  14065. + rom_length >> 10,
  14066. + codek,
  14067. + datak
  14068. + );
  14069. +}
  14070. +
  14071. +
  14072. +#ifdef CONFIG_BLK_DEV_INITRD
  14073. +void __init free_initrd_mem(unsigned long start, unsigned long end)
  14074. +{
  14075. + int pages = 0;
  14076. + for (; start < end; start += PAGE_SIZE) {
  14077. + ClearPageReserved(virt_to_page(start));
  14078. + init_page_count(virt_to_page(start));
  14079. + free_page(start);
  14080. + totalram_pages++;
  14081. + pages++;
  14082. + }
  14083. + printk (KERN_NOTICE "Freeing initrd memory: %dk freed\n", pages);
  14084. +}
  14085. +#endif
  14086. +
  14087. +void free_initmem(void)
  14088. +{
  14089. +#ifdef CONFIG_RAMKERNEL
  14090. + unsigned long addr;
  14091. + extern char __init_begin, __init_end;
  14092. + /*
  14093. + * The following code should be cool even if these sections
  14094. + * are not page aligned.
  14095. + */
  14096. + addr = PAGE_ALIGN((unsigned long)(&__init_begin));
  14097. + /* next to check that the page we free is not a partial page */
  14098. + for (; addr + PAGE_SIZE < (unsigned long)(&__init_end); addr +=PAGE_SIZE) {
  14099. + ClearPageReserved(virt_to_page(addr));
  14100. + init_page_count(virt_to_page(addr));
  14101. + free_page(addr);
  14102. + totalram_pages++;
  14103. + }
  14104. + printk(KERN_NOTICE "Freeing unused kernel memory: %ldk freed (0x%x - 0x%x)\n",
  14105. + (addr - PAGE_ALIGN((long) &__init_begin)) >> 10,
  14106. + (int)(PAGE_ALIGN((unsigned long)(&__init_begin))),
  14107. + (int)(addr - PAGE_SIZE));
  14108. +#endif
  14109. +}
  14110. +
  14111. diff --git a/arch/nios2nommu/mm/ioremap.c b/arch/nios2nommu/mm/ioremap.c
  14112. new file mode 100644
  14113. index 0000000..1c8b172
  14114. --- /dev/null
  14115. +++ b/arch/nios2nommu/mm/ioremap.c
  14116. @@ -0,0 +1,65 @@
  14117. +/* linux/arch/nios2nommu/mm/ioremap.c, based on:
  14118. + *
  14119. + * linux/arch/m68knommu/mm/kmap.c
  14120. + *
  14121. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  14122. + * Copyright (C) 2000 Lineo, <davidm@lineo.com>
  14123. + *
  14124. + * All rights reserved.
  14125. + *
  14126. + * This program is free software; you can redistribute it and/or modify
  14127. + * it under the terms of the GNU General Public License as published by
  14128. + * the Free Software Foundation; either version 2 of the License, or
  14129. + * (at your option) any later version.
  14130. + *
  14131. + * This program is distributed in the hope that it will be useful, but
  14132. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  14133. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  14134. + * NON INFRINGEMENT. See the GNU General Public License for more
  14135. + * details.
  14136. + *
  14137. + * You should have received a copy of the GNU General Public License
  14138. + * along with this program; if not, write to the Free Software
  14139. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14140. + *
  14141. + */
  14142. +
  14143. +#include <linux/mm.h>
  14144. +#include <linux/kernel.h>
  14145. +#include <linux/string.h>
  14146. +#include <linux/types.h>
  14147. +#include <linux/slab.h>
  14148. +#include <linux/vmalloc.h>
  14149. +
  14150. +#include <asm/setup.h>
  14151. +#include <asm/segment.h>
  14152. +#include <asm/page.h>
  14153. +#include <asm/pgalloc.h>
  14154. +#include <asm/io.h>
  14155. +#include <asm/system.h>
  14156. +
  14157. +/*
  14158. + * Map some physical address range into the kernel address space.
  14159. + */
  14160. +
  14161. +void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag)
  14162. +{
  14163. + return (void *)physaddr;
  14164. +}
  14165. +
  14166. +/*
  14167. + * Unmap a ioremap()ed region again
  14168. + */
  14169. +void iounmap(void *addr)
  14170. +{
  14171. +}
  14172. +
  14173. +/*
  14174. + * __iounmap unmaps nearly everything, so be careful
  14175. + * it doesn't free currently pointer/page tables anymore but it
  14176. + * wans't used anyway and might be added later.
  14177. + */
  14178. +void __iounmap(void *addr, unsigned long size)
  14179. +{
  14180. +}
  14181. +
  14182. diff --git a/arch/nios2nommu/mm/memory.c b/arch/nios2nommu/mm/memory.c
  14183. new file mode 100644
  14184. index 0000000..76d60d9
  14185. --- /dev/null
  14186. +++ b/arch/nios2nommu/mm/memory.c
  14187. @@ -0,0 +1,212 @@
  14188. +/*
  14189. + * linux/arch/nio2nommu/mm/memory.c
  14190. + *
  14191. + * Copyright (C) 1995 Hamish Macdonald
  14192. + * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>,
  14193. + * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
  14194. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  14195. + *
  14196. + * Based on:
  14197. + *
  14198. + * linux/arch/m68k/mm/memory.c
  14199. + *
  14200. + * All rights reserved.
  14201. + *
  14202. + * This program is free software; you can redistribute it and/or modify
  14203. + * it under the terms of the GNU General Public License as published by
  14204. + * the Free Software Foundation; either version 2 of the License, or
  14205. + * (at your option) any later version.
  14206. + *
  14207. + * This program is distributed in the hope that it will be useful, but
  14208. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  14209. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  14210. + * NON INFRINGEMENT. See the GNU General Public License for more
  14211. + * details.
  14212. + *
  14213. + * You should have received a copy of the GNU General Public License
  14214. + * along with this program; if not, write to the Free Software
  14215. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14216. + *
  14217. + */
  14218. +
  14219. +#include <linux/mm.h>
  14220. +#include <linux/kernel.h>
  14221. +#include <linux/string.h>
  14222. +#include <linux/types.h>
  14223. +#include <linux/slab.h>
  14224. +
  14225. +#include <asm/setup.h>
  14226. +#include <asm/segment.h>
  14227. +#include <asm/page.h>
  14228. +#include <asm/pgtable.h>
  14229. +#include <asm/system.h>
  14230. +#include <asm/traps.h>
  14231. +#include <asm/io.h>
  14232. +
  14233. +/*
  14234. + * cache_clear() semantics: Clear any cache entries for the area in question,
  14235. + * without writing back dirty entries first. This is useful if the data will
  14236. + * be overwritten anyway, e.g. by DMA to memory. The range is defined by a
  14237. + * _physical_ address.
  14238. + */
  14239. +
  14240. +void cache_clear (unsigned long paddr, int len)
  14241. +{
  14242. +}
  14243. +
  14244. +
  14245. +/*
  14246. + * Define cache invalidate functions. The instruction and data cache
  14247. + * will need to be flushed. Write back the dirty data cache and invalidate
  14248. + * the instruction cache for the range.
  14249. + *
  14250. + */
  14251. +
  14252. +static __inline__ void cache_invalidate_inst(unsigned long paddr, int len)
  14253. +{
  14254. + unsigned long sset, eset;
  14255. +
  14256. + sset = (paddr & (nasys_icache_size - 1)) & (~(nasys_icache_line_size - 1));
  14257. + eset = (((paddr & (nasys_icache_size - 1)) + len) & (~(nasys_icache_line_size - 1))) + nasys_icache_line_size;
  14258. +
  14259. + __asm__ __volatile__ (
  14260. + "1:\n\t"
  14261. + "flushi %0\n\t"
  14262. + "add %0,%0,%2\n\t"
  14263. + "blt %0,%1,1b\n\t"
  14264. + "flushp\n\t"
  14265. + : : "r" (sset), "r" (eset), "r" (nasys_icache_line_size));
  14266. +
  14267. +}
  14268. +
  14269. +static __inline__ void cache_invalidate_data(unsigned long paddr, int len)
  14270. +{
  14271. + unsigned long sset, eset;
  14272. +
  14273. + sset = (paddr & (nasys_dcache_size - 1)) & (~(nasys_dcache_line_size - 1));
  14274. + eset = (((paddr & (nasys_dcache_size - 1)) + len) & (~(nasys_dcache_line_size - 1))) + nasys_dcache_line_size;
  14275. +
  14276. + __asm__ __volatile__ (
  14277. + "1:\n\t"
  14278. + "flushd 0(%0)\n\t"
  14279. + "add %0,%0,%2\n\t"
  14280. + "blt %0,%1,1b\n\t"
  14281. + : : "r" (sset),"r" (eset), "r" (nasys_dcache_line_size));
  14282. +
  14283. +}
  14284. +
  14285. +static __inline__ void cache_invalidate_lines(unsigned long paddr, int len)
  14286. +{
  14287. + unsigned long sset, eset;
  14288. +
  14289. + sset = (paddr & (nasys_dcache_size - 1)) & (~(nasys_dcache_line_size - 1));
  14290. + eset = (((paddr & (nasys_dcache_size - 1)) + len) & (~(nasys_dcache_line_size - 1))) + nasys_dcache_line_size;
  14291. +
  14292. + __asm__ __volatile__ (
  14293. + "1:\n\t"
  14294. + "flushd 0(%0)\n\t"
  14295. + "add %0,%0,%2\n\t"
  14296. + "blt %0,%1,1b\n\t"
  14297. + : : "r" (sset),"r" (eset), "r" (nasys_dcache_line_size));
  14298. +
  14299. + sset = (paddr & (nasys_icache_size - 1)) & (~(nasys_icache_line_size - 1));
  14300. + eset = (((paddr & (nasys_icache_size - 1)) + len) & (~(nasys_icache_line_size - 1))) + nasys_icache_line_size;
  14301. +
  14302. + __asm__ __volatile__ (
  14303. + "1:\n\t"
  14304. + "flushi %0\n\t"
  14305. + "add %0,%0,%2\n\t"
  14306. + "blt %0,%1,1b\n\t"
  14307. + "flushp\n\t"
  14308. + : : "r" (sset), "r" (eset), "r" (nasys_icache_line_size));
  14309. +
  14310. +}
  14311. +
  14312. +/*
  14313. + * cache_push() semantics: Write back any dirty cache data in the given area,
  14314. + * and invalidate the range in the instruction cache. It needs not (but may)
  14315. + * invalidate those entries also in the data cache. The range is defined by a
  14316. + * _physical_ address.
  14317. + */
  14318. +
  14319. +void cache_push (unsigned long paddr, int len)
  14320. +{
  14321. + cache_invalidate_lines(paddr, len);
  14322. +}
  14323. +
  14324. +
  14325. +/*
  14326. + * cache_push_v() semantics: Write back any dirty cache data in the given
  14327. + * area, and invalidate those entries at least in the instruction cache. This
  14328. + * is intended to be used after data has been written that can be executed as
  14329. + * code later. The range is defined by a _user_mode_ _virtual_ address.
  14330. + */
  14331. +
  14332. +void cache_push_v (unsigned long vaddr, int len)
  14333. +{
  14334. + cache_invalidate_lines(vaddr, len);
  14335. +}
  14336. +
  14337. +/*
  14338. + * cache_push_all() semantics: Invalidate instruction cache and write back
  14339. + * dirty data cache & invalidate.
  14340. + */
  14341. +void cache_push_all (void)
  14342. +{
  14343. + __asm__ __volatile__ (
  14344. + "1:\n\t"
  14345. + "flushd 0(%0)\n\t"
  14346. + "sub %0,%0,%1\n\t"
  14347. + "bgt %0,r0,1b\n\t"
  14348. + : : "r" (nasys_dcache_size), "r" (nasys_dcache_line_size));
  14349. +
  14350. + __asm__ __volatile__ (
  14351. + "1:\n\t"
  14352. + "flushi %0\n\t"
  14353. + "sub %0,%0,%1\n\t"
  14354. + "bgt %0,r0,1b\n\t"
  14355. + "flushp\n\t"
  14356. + : : "r" (nasys_icache_size), "r" (nasys_icache_line_size));
  14357. +
  14358. +}
  14359. +
  14360. +/*
  14361. + * dcache_push() semantics: Write back and dirty data cache and invalidate
  14362. + * the range.
  14363. + */
  14364. +void dcache_push (unsigned long vaddr, int len)
  14365. +{
  14366. + cache_invalidate_data(vaddr, len);
  14367. +}
  14368. +
  14369. +/*
  14370. + * icache_push() semantics: Invalidate instruction cache in the range.
  14371. + */
  14372. +void icache_push (unsigned long vaddr, int len)
  14373. +{
  14374. + cache_invalidate_inst(vaddr, len);
  14375. +}
  14376. +
  14377. +/* Map some physical address range into the kernel address space. The
  14378. + * code is copied and adapted from map_chunk().
  14379. + */
  14380. +
  14381. +unsigned long kernel_map(unsigned long paddr, unsigned long size,
  14382. + int nocacheflag, unsigned long *memavailp )
  14383. +{
  14384. + return paddr;
  14385. +}
  14386. +
  14387. +
  14388. +int is_in_rom(unsigned long addr)
  14389. +{
  14390. + /* Default case, not in ROM */
  14391. + return(0);
  14392. +}
  14393. +
  14394. +int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
  14395. + unsigned long address, int write_access)
  14396. +{
  14397. + BUG();
  14398. + return VM_FAULT_OOM;
  14399. +}
  14400. diff --git a/arch/nios2nommu/scripts/PTF/PTFParser.pm b/arch/nios2nommu/scripts/PTF/PTFParser.pm
  14401. new file mode 100644
  14402. index 0000000..c243c7b
  14403. --- /dev/null
  14404. +++ b/arch/nios2nommu/scripts/PTF/PTFParser.pm
  14405. @@ -0,0 +1,873 @@
  14406. +####################################################################
  14407. +#
  14408. +# This file was generated using Parse::Yapp version 1.05.
  14409. +#
  14410. +# Don't edit this file, use source file instead.
  14411. +#
  14412. +# ANY CHANGE MADE HERE WILL BE LOST !
  14413. +#
  14414. +####################################################################
  14415. +package PTFParser;
  14416. +use vars qw ( @ISA );
  14417. +use strict;
  14418. +
  14419. +@ISA= qw ( Parse::Yapp::Driver );
  14420. +#Included Parse/Yapp/Driver.pm file----------------------------------------
  14421. +{
  14422. +#
  14423. +# Module Parse::Yapp::Driver
  14424. +#
  14425. +# This module is part of the Parse::Yapp package available on your
  14426. +# nearest CPAN
  14427. +#
  14428. +# Any use of this module in a standalone parser make the included
  14429. +# text under the same copyright as the Parse::Yapp module itself.
  14430. +#
  14431. +# This notice should remain unchanged.
  14432. +#
  14433. +# (c) Copyright 1998-2001 Francois Desarmenien, all rights reserved.
  14434. +# (see the pod text in Parse::Yapp module for use and distribution rights)
  14435. +#
  14436. +
  14437. +package Parse::Yapp::Driver;
  14438. +
  14439. +require 5.004;
  14440. +
  14441. +use strict;
  14442. +
  14443. +use vars qw ( $VERSION $COMPATIBLE $FILENAME );
  14444. +
  14445. +$VERSION = '1.05';
  14446. +$COMPATIBLE = '0.07';
  14447. +$FILENAME=__FILE__;
  14448. +
  14449. +use Carp;
  14450. +
  14451. +#Known parameters, all starting with YY (leading YY will be discarded)
  14452. +my(%params)=(YYLEX => 'CODE', 'YYERROR' => 'CODE', YYVERSION => '',
  14453. + YYRULES => 'ARRAY', YYSTATES => 'ARRAY', YYDEBUG => '');
  14454. +#Mandatory parameters
  14455. +my(@params)=('LEX','RULES','STATES');
  14456. +
  14457. +sub new {
  14458. + my($class)=shift;
  14459. + my($errst,$nberr,$token,$value,$check,$dotpos);
  14460. + my($self)={ ERROR => \&_Error,
  14461. + ERRST => \$errst,
  14462. + NBERR => \$nberr,
  14463. + TOKEN => \$token,
  14464. + VALUE => \$value,
  14465. + DOTPOS => \$dotpos,
  14466. + STACK => [],
  14467. + DEBUG => 0,
  14468. + CHECK => \$check };
  14469. +
  14470. + _CheckParams( [], \%params, \@_, $self );
  14471. +
  14472. + exists($$self{VERSION})
  14473. + and $$self{VERSION} < $COMPATIBLE
  14474. + and croak "Yapp driver version $VERSION ".
  14475. + "incompatible with version $$self{VERSION}:\n".
  14476. + "Please recompile parser module.";
  14477. +
  14478. + ref($class)
  14479. + and $class=ref($class);
  14480. +
  14481. + bless($self,$class);
  14482. +}
  14483. +
  14484. +sub YYParse {
  14485. + my($self)=shift;
  14486. + my($retval);
  14487. +
  14488. + _CheckParams( \@params, \%params, \@_, $self );
  14489. +
  14490. + if($$self{DEBUG}) {
  14491. + _DBLoad();
  14492. + $retval = eval '$self->_DBParse()';#Do not create stab entry on compile
  14493. + $@ and die $@;
  14494. + }
  14495. + else {
  14496. + $retval = $self->_Parse();
  14497. + }
  14498. + $retval
  14499. +}
  14500. +
  14501. +sub YYData {
  14502. + my($self)=shift;
  14503. +
  14504. + exists($$self{USER})
  14505. + or $$self{USER}={};
  14506. +
  14507. + $$self{USER};
  14508. +
  14509. +}
  14510. +
  14511. +sub YYErrok {
  14512. + my($self)=shift;
  14513. +
  14514. + ${$$self{ERRST}}=0;
  14515. + undef;
  14516. +}
  14517. +
  14518. +sub YYNberr {
  14519. + my($self)=shift;
  14520. +
  14521. + ${$$self{NBERR}};
  14522. +}
  14523. +
  14524. +sub YYRecovering {
  14525. + my($self)=shift;
  14526. +
  14527. + ${$$self{ERRST}} != 0;
  14528. +}
  14529. +
  14530. +sub YYAbort {
  14531. + my($self)=shift;
  14532. +
  14533. + ${$$self{CHECK}}='ABORT';
  14534. + undef;
  14535. +}
  14536. +
  14537. +sub YYAccept {
  14538. + my($self)=shift;
  14539. +
  14540. + ${$$self{CHECK}}='ACCEPT';
  14541. + undef;
  14542. +}
  14543. +
  14544. +sub YYError {
  14545. + my($self)=shift;
  14546. +
  14547. + ${$$self{CHECK}}='ERROR';
  14548. + undef;
  14549. +}
  14550. +
  14551. +sub YYSemval {
  14552. + my($self)=shift;
  14553. + my($index)= $_[0] - ${$$self{DOTPOS}} - 1;
  14554. +
  14555. + $index < 0
  14556. + and -$index <= @{$$self{STACK}}
  14557. + and return $$self{STACK}[$index][1];
  14558. +
  14559. + undef; #Invalid index
  14560. +}
  14561. +
  14562. +sub YYCurtok {
  14563. + my($self)=shift;
  14564. +
  14565. + @_
  14566. + and ${$$self{TOKEN}}=$_[0];
  14567. + ${$$self{TOKEN}};
  14568. +}
  14569. +
  14570. +sub YYCurval {
  14571. + my($self)=shift;
  14572. +
  14573. + @_
  14574. + and ${$$self{VALUE}}=$_[0];
  14575. + ${$$self{VALUE}};
  14576. +}
  14577. +
  14578. +sub YYExpect {
  14579. + my($self)=shift;
  14580. +
  14581. + keys %{$self->{STATES}[$self->{STACK}[-1][0]]{ACTIONS}}
  14582. +}
  14583. +
  14584. +sub YYLexer {
  14585. + my($self)=shift;
  14586. +
  14587. + $$self{LEX};
  14588. +}
  14589. +
  14590. +
  14591. +#################
  14592. +# Private stuff #
  14593. +#################
  14594. +
  14595. +
  14596. +sub _CheckParams {
  14597. + my($mandatory,$checklist,$inarray,$outhash)=@_;
  14598. + my($prm,$value);
  14599. + my($prmlst)={};
  14600. +
  14601. + while(($prm,$value)=splice(@$inarray,0,2)) {
  14602. + $prm=uc($prm);
  14603. + exists($$checklist{$prm})
  14604. + or croak("Unknow parameter '$prm'");
  14605. + ref($value) eq $$checklist{$prm}
  14606. + or croak("Invalid value for parameter '$prm'");
  14607. + $prm=unpack('@2A*',$prm);
  14608. + $$outhash{$prm}=$value;
  14609. + }
  14610. + for (@$mandatory) {
  14611. + exists($$outhash{$_})
  14612. + or croak("Missing mandatory parameter '".lc($_)."'");
  14613. + }
  14614. +}
  14615. +
  14616. +sub _Error {
  14617. + print "Parse error.\n";
  14618. +}
  14619. +
  14620. +sub _DBLoad {
  14621. + {
  14622. + no strict 'refs';
  14623. +
  14624. + exists(${__PACKAGE__.'::'}{_DBParse})#Already loaded ?
  14625. + and return;
  14626. + }
  14627. + my($fname)=__FILE__;
  14628. + my(@drv);
  14629. + open(DRV,"<$fname") or die "Report this as a BUG: Cannot open $fname";
  14630. + while(<DRV>) {
  14631. + /^\s*sub\s+_Parse\s*{\s*$/ .. /^\s*}\s*#\s*_Parse\s*$/
  14632. + and do {
  14633. + s/^#DBG>//;
  14634. + push(@drv,$_);
  14635. + }
  14636. + }
  14637. + close(DRV);
  14638. +
  14639. + $drv[0]=~s/_P/_DBP/;
  14640. + eval join('',@drv);
  14641. +}
  14642. +
  14643. +#Note that for loading debugging version of the driver,
  14644. +#this file will be parsed from 'sub _Parse' up to '}#_Parse' inclusive.
  14645. +#So, DO NOT remove comment at end of sub !!!
  14646. +sub _Parse {
  14647. + my($self)=shift;
  14648. +
  14649. + my($rules,$states,$lex,$error)
  14650. + = @$self{ 'RULES', 'STATES', 'LEX', 'ERROR' };
  14651. + my($errstatus,$nberror,$token,$value,$stack,$check,$dotpos)
  14652. + = @$self{ 'ERRST', 'NBERR', 'TOKEN', 'VALUE', 'STACK', 'CHECK', 'DOTPOS' };
  14653. +
  14654. +#DBG> my($debug)=$$self{DEBUG};
  14655. +#DBG> my($dbgerror)=0;
  14656. +
  14657. +#DBG> my($ShowCurToken) = sub {
  14658. +#DBG> my($tok)='>';
  14659. +#DBG> for (split('',$$token)) {
  14660. +#DBG> $tok.= (ord($_) < 32 or ord($_) > 126)
  14661. +#DBG> ? sprintf('<%02X>',ord($_))
  14662. +#DBG> : $_;
  14663. +#DBG> }
  14664. +#DBG> $tok.='<';
  14665. +#DBG> };
  14666. +
  14667. + $$errstatus=0;
  14668. + $$nberror=0;
  14669. + ($$token,$$value)=(undef,undef);
  14670. + @$stack=( [ 0, undef ] );
  14671. + $$check='';
  14672. +
  14673. + while(1) {
  14674. + my($actions,$act,$stateno);
  14675. +
  14676. + $stateno=$$stack[-1][0];
  14677. + $actions=$$states[$stateno];
  14678. +
  14679. +#DBG> print STDERR ('-' x 40),"\n";
  14680. +#DBG> $debug & 0x2
  14681. +#DBG> and print STDERR "In state $stateno:\n";
  14682. +#DBG> $debug & 0x08
  14683. +#DBG> and print STDERR "Stack:[".
  14684. +#DBG> join(',',map { $$_[0] } @$stack).
  14685. +#DBG> "]\n";
  14686. +
  14687. +
  14688. + if (exists($$actions{ACTIONS})) {
  14689. +
  14690. + defined($$token)
  14691. + or do {
  14692. + ($$token,$$value)=&$lex($self);
  14693. +#DBG> $debug & 0x01
  14694. +#DBG> and print STDERR "Need token. Got ".&$ShowCurToken."\n";
  14695. + };
  14696. +
  14697. + $act= exists($$actions{ACTIONS}{$$token})
  14698. + ? $$actions{ACTIONS}{$$token}
  14699. + : exists($$actions{DEFAULT})
  14700. + ? $$actions{DEFAULT}
  14701. + : undef;
  14702. + }
  14703. + else {
  14704. + $act=$$actions{DEFAULT};
  14705. +#DBG> $debug & 0x01
  14706. +#DBG> and print STDERR "Don't need token.\n";
  14707. + }
  14708. +
  14709. + defined($act)
  14710. + and do {
  14711. +
  14712. + $act > 0
  14713. + and do { #shift
  14714. +
  14715. +#DBG> $debug & 0x04
  14716. +#DBG> and print STDERR "Shift and go to state $act.\n";
  14717. +
  14718. + $$errstatus
  14719. + and do {
  14720. + --$$errstatus;
  14721. +
  14722. +#DBG> $debug & 0x10
  14723. +#DBG> and $dbgerror
  14724. +#DBG> and $$errstatus == 0
  14725. +#DBG> and do {
  14726. +#DBG> print STDERR "**End of Error recovery.\n";
  14727. +#DBG> $dbgerror=0;
  14728. +#DBG> };
  14729. + };
  14730. +
  14731. +
  14732. + push(@$stack,[ $act, $$value ]);
  14733. +
  14734. + $$token ne '' #Don't eat the eof
  14735. + and $$token=$$value=undef;
  14736. + next;
  14737. + };
  14738. +
  14739. + #reduce
  14740. + my($lhs,$len,$code,@sempar,$semval);
  14741. + ($lhs,$len,$code)=@{$$rules[-$act]};
  14742. +
  14743. +#DBG> $debug & 0x04
  14744. +#DBG> and $act
  14745. +#DBG> and print STDERR "Reduce using rule ".-$act." ($lhs,$len): ";
  14746. +
  14747. + $act
  14748. + or $self->YYAccept();
  14749. +
  14750. + $$dotpos=$len;
  14751. +
  14752. + unpack('A1',$lhs) eq '@' #In line rule
  14753. + and do {
  14754. + $lhs =~ /^\@[0-9]+\-([0-9]+)$/
  14755. + or die "In line rule name '$lhs' ill formed: ".
  14756. + "report it as a BUG.\n";
  14757. + $$dotpos = $1;
  14758. + };
  14759. +
  14760. + @sempar = $$dotpos
  14761. + ? map { $$_[1] } @$stack[ -$$dotpos .. -1 ]
  14762. + : ();
  14763. +
  14764. + $semval = $code ? &$code( $self, @sempar )
  14765. + : @sempar ? $sempar[0] : undef;
  14766. +
  14767. + splice(@$stack,-$len,$len);
  14768. +
  14769. + $$check eq 'ACCEPT'
  14770. + and do {
  14771. +
  14772. +#DBG> $debug & 0x04
  14773. +#DBG> and print STDERR "Accept.\n";
  14774. +
  14775. + return($semval);
  14776. + };
  14777. +
  14778. + $$check eq 'ABORT'
  14779. + and do {
  14780. +
  14781. +#DBG> $debug & 0x04
  14782. +#DBG> and print STDERR "Abort.\n";
  14783. +
  14784. + return(undef);
  14785. +
  14786. + };
  14787. +
  14788. +#DBG> $debug & 0x04
  14789. +#DBG> and print STDERR "Back to state $$stack[-1][0], then ";
  14790. +
  14791. + $$check eq 'ERROR'
  14792. + or do {
  14793. +#DBG> $debug & 0x04
  14794. +#DBG> and print STDERR
  14795. +#DBG> "go to state $$states[$$stack[-1][0]]{GOTOS}{$lhs}.\n";
  14796. +
  14797. +#DBG> $debug & 0x10
  14798. +#DBG> and $dbgerror
  14799. +#DBG> and $$errstatus == 0
  14800. +#DBG> and do {
  14801. +#DBG> print STDERR "**End of Error recovery.\n";
  14802. +#DBG> $dbgerror=0;
  14803. +#DBG> };
  14804. +
  14805. + push(@$stack,
  14806. + [ $$states[$$stack[-1][0]]{GOTOS}{$lhs}, $semval ]);
  14807. + $$check='';
  14808. + next;
  14809. + };
  14810. +
  14811. +#DBG> $debug & 0x04
  14812. +#DBG> and print STDERR "Forced Error recovery.\n";
  14813. +
  14814. + $$check='';
  14815. +
  14816. + };
  14817. +
  14818. + #Error
  14819. + $$errstatus
  14820. + or do {
  14821. +
  14822. + $$errstatus = 1;
  14823. + &$error($self);
  14824. + $$errstatus # if 0, then YYErrok has been called
  14825. + or next; # so continue parsing
  14826. +
  14827. +#DBG> $debug & 0x10
  14828. +#DBG> and do {
  14829. +#DBG> print STDERR "**Entering Error recovery.\n";
  14830. +#DBG> ++$dbgerror;
  14831. +#DBG> };
  14832. +
  14833. + ++$$nberror;
  14834. +
  14835. + };
  14836. +
  14837. + $$errstatus == 3 #The next token is not valid: discard it
  14838. + and do {
  14839. + $$token eq '' # End of input: no hope
  14840. + and do {
  14841. +#DBG> $debug & 0x10
  14842. +#DBG> and print STDERR "**At eof: aborting.\n";
  14843. + return(undef);
  14844. + };
  14845. +
  14846. +#DBG> $debug & 0x10
  14847. +#DBG> and print STDERR "**Dicard invalid token ".&$ShowCurToken.".\n";
  14848. +
  14849. + $$token=$$value=undef;
  14850. + };
  14851. +
  14852. + $$errstatus=3;
  14853. +
  14854. + while( @$stack
  14855. + and ( not exists($$states[$$stack[-1][0]]{ACTIONS})
  14856. + or not exists($$states[$$stack[-1][0]]{ACTIONS}{error})
  14857. + or $$states[$$stack[-1][0]]{ACTIONS}{error} <= 0)) {
  14858. +
  14859. +#DBG> $debug & 0x10
  14860. +#DBG> and print STDERR "**Pop state $$stack[-1][0].\n";
  14861. +
  14862. + pop(@$stack);
  14863. + }
  14864. +
  14865. + @$stack
  14866. + or do {
  14867. +
  14868. +#DBG> $debug & 0x10
  14869. +#DBG> and print STDERR "**No state left on stack: aborting.\n";
  14870. +
  14871. + return(undef);
  14872. + };
  14873. +
  14874. + #shift the error token
  14875. +
  14876. +#DBG> $debug & 0x10
  14877. +#DBG> and print STDERR "**Shift \$error token and go to state ".
  14878. +#DBG> $$states[$$stack[-1][0]]{ACTIONS}{error}.
  14879. +#DBG> ".\n";
  14880. +
  14881. + push(@$stack, [ $$states[$$stack[-1][0]]{ACTIONS}{error}, undef ]);
  14882. +
  14883. + }
  14884. +
  14885. + #never reached
  14886. + croak("Error in driver logic. Please, report it as a BUG");
  14887. +
  14888. +}#_Parse
  14889. +#DO NOT remove comment
  14890. +
  14891. +1;
  14892. +
  14893. +}
  14894. +#End of include--------------------------------------------------
  14895. +
  14896. +
  14897. +#line 1 "PTFParser.yp"
  14898. +#
  14899. +# Altera PTF file parser
  14900. +#
  14901. +# Copyright (c) 2004 Microtronix Datacom Ltd.
  14902. +#
  14903. +
  14904. +package PTFParser;
  14905. +
  14906. +use PTF::PTFSection;
  14907. +
  14908. +#global variables should go here.
  14909. +
  14910. +#my $line = 0; # for error messages
  14911. +#my @sectionStack = (); # used to keep track of ptf sections
  14912. +#my $root;
  14913. +
  14914. +my $fh;
  14915. +
  14916. +sub new {
  14917. + my($class)=shift;
  14918. + ref($class)
  14919. + and $class=ref($class);
  14920. +
  14921. + my($self)=$class->SUPER::new( yyversion => '1.05',
  14922. + yystates =>
  14923. +[
  14924. + {#State 0
  14925. + ACTIONS => {
  14926. + 'IDENTIFIER' => 1
  14927. + },
  14928. + GOTOS => {
  14929. + 'section' => 2,
  14930. + 'section_title' => 3
  14931. + }
  14932. + },
  14933. + {#State 1
  14934. + ACTIONS => {
  14935. + 'IDENTIFIER' => 4,
  14936. + 'STRING_LITERAL' => 6,
  14937. + 'NUMBER' => 7
  14938. + },
  14939. + DEFAULT => -3,
  14940. + GOTOS => {
  14941. + 'section_name' => 5
  14942. + }
  14943. + },
  14944. + {#State 2
  14945. + ACTIONS => {
  14946. + '' => 8
  14947. + }
  14948. + },
  14949. + {#State 3
  14950. + ACTIONS => {
  14951. + "{" => 9
  14952. + }
  14953. + },
  14954. + {#State 4
  14955. + DEFAULT => -4
  14956. + },
  14957. + {#State 5
  14958. + DEFAULT => -2
  14959. + },
  14960. + {#State 6
  14961. + DEFAULT => -6
  14962. + },
  14963. + {#State 7
  14964. + DEFAULT => -5
  14965. + },
  14966. + {#State 8
  14967. + DEFAULT => 0
  14968. + },
  14969. + {#State 9
  14970. + ACTIONS => {
  14971. + 'IDENTIFIER' => 11,
  14972. + 'HIERARCHICAL_NAME' => 13
  14973. + },
  14974. + DEFAULT => -7,
  14975. + GOTOS => {
  14976. + 'assignment_name' => 10,
  14977. + 'assignment' => 12,
  14978. + 'section_element' => 14,
  14979. + 'section' => 15,
  14980. + 'section_title' => 3
  14981. + }
  14982. + },
  14983. + {#State 10
  14984. + ACTIONS => {
  14985. + "=" => 16
  14986. + }
  14987. + },
  14988. + {#State 11
  14989. + ACTIONS => {
  14990. + 'IDENTIFIER' => 4,
  14991. + 'STRING_LITERAL' => 6,
  14992. + 'NUMBER' => 7,
  14993. + "=" => -11
  14994. + },
  14995. + DEFAULT => -3,
  14996. + GOTOS => {
  14997. + 'section_name' => 5
  14998. + }
  14999. + },
  15000. + {#State 12
  15001. + ACTIONS => {
  15002. + 'IDENTIFIER' => 11,
  15003. + 'HIERARCHICAL_NAME' => 13
  15004. + },
  15005. + DEFAULT => -7,
  15006. + GOTOS => {
  15007. + 'assignment_name' => 10,
  15008. + 'assignment' => 12,
  15009. + 'section_element' => 17,
  15010. + 'section' => 15,
  15011. + 'section_title' => 3
  15012. + }
  15013. + },
  15014. + {#State 13
  15015. + DEFAULT => -12
  15016. + },
  15017. + {#State 14
  15018. + ACTIONS => {
  15019. + "}" => 18
  15020. + }
  15021. + },
  15022. + {#State 15
  15023. + ACTIONS => {
  15024. + 'IDENTIFIER' => 11,
  15025. + 'HIERARCHICAL_NAME' => 13
  15026. + },
  15027. + DEFAULT => -7,
  15028. + GOTOS => {
  15029. + 'assignment_name' => 10,
  15030. + 'assignment' => 12,
  15031. + 'section_element' => 19,
  15032. + 'section' => 15,
  15033. + 'section_title' => 3
  15034. + }
  15035. + },
  15036. + {#State 16
  15037. + ACTIONS => {
  15038. + 'STRING_LITERAL' => 20,
  15039. + 'NUMBER' => 22
  15040. + },
  15041. + GOTOS => {
  15042. + 'assignment_value' => 21
  15043. + }
  15044. + },
  15045. + {#State 17
  15046. + DEFAULT => -8
  15047. + },
  15048. + {#State 18
  15049. + DEFAULT => -1
  15050. + },
  15051. + {#State 19
  15052. + DEFAULT => -9
  15053. + },
  15054. + {#State 20
  15055. + DEFAULT => -13
  15056. + },
  15057. + {#State 21
  15058. + ACTIONS => {
  15059. + ";" => 23
  15060. + }
  15061. + },
  15062. + {#State 22
  15063. + DEFAULT => -14
  15064. + },
  15065. + {#State 23
  15066. + DEFAULT => -10
  15067. + }
  15068. +],
  15069. + yyrules =>
  15070. +[
  15071. + [#Rule 0
  15072. + '$start', 2, undef
  15073. + ],
  15074. + [#Rule 1
  15075. + 'section', 4,
  15076. +sub
  15077. +#line 20 "PTFParser.yp"
  15078. +{
  15079. + my $sectionStack = $_[0]->YYData->{sectionStack};
  15080. + pop @{$sectionStack};
  15081. + }
  15082. + ],
  15083. + [#Rule 2
  15084. + 'section_title', 2,
  15085. +sub
  15086. +#line 26 "PTFParser.yp"
  15087. +{
  15088. + my $section = PTFSection->new (type => $_[1], name => $_[2]);
  15089. + my $sectionStack = $_[0]->YYData->{sectionStack};
  15090. +
  15091. + if (scalar(@{$sectionStack}) == 0) {
  15092. + $_[0]->YYData->{root} = $section;
  15093. + } else {
  15094. + my $parent = $sectionStack->[$#{$sectionStack}];
  15095. + $parent->addSection ($section);
  15096. + }
  15097. +
  15098. + push @{$sectionStack}, $section;
  15099. + }
  15100. + ],
  15101. + [#Rule 3
  15102. + 'section_name', 0, undef
  15103. + ],
  15104. + [#Rule 4
  15105. + 'section_name', 1, undef
  15106. + ],
  15107. + [#Rule 5
  15108. + 'section_name', 1, undef
  15109. + ],
  15110. + [#Rule 6
  15111. + 'section_name', 1, undef
  15112. + ],
  15113. + [#Rule 7
  15114. + 'section_element', 0, undef
  15115. + ],
  15116. + [#Rule 8
  15117. + 'section_element', 2, undef
  15118. + ],
  15119. + [#Rule 9
  15120. + 'section_element', 2, undef
  15121. + ],
  15122. + [#Rule 10
  15123. + 'assignment', 4,
  15124. +sub
  15125. +#line 52 "PTFParser.yp"
  15126. +{
  15127. + my $sectionStack = $_[0]->YYData->{sectionStack};
  15128. + my $parent= $sectionStack->[$#{$sectionStack}];
  15129. + $parent->addAssignment ($_[1], $_[3]);
  15130. + }
  15131. + ],
  15132. + [#Rule 11
  15133. + 'assignment_name', 1, undef
  15134. + ],
  15135. + [#Rule 12
  15136. + 'assignment_name', 1, undef
  15137. + ],
  15138. + [#Rule 13
  15139. + 'assignment_value', 1, undef
  15140. + ],
  15141. + [#Rule 14
  15142. + 'assignment_value', 1, undef
  15143. + ]
  15144. +],
  15145. + @_);
  15146. + bless($self,$class);
  15147. +}
  15148. +
  15149. +#line 67 "PTFParser.yp"
  15150. +
  15151. +
  15152. +sub _Error {
  15153. +# TODO: update this error function to be more useful
  15154. + exists $_[0]->YYData->{ERRMSG}
  15155. + and do {
  15156. + print $_[0]->YYData->{ERRMSG};
  15157. + delete $_[0]->YYData->{ERRMSG};
  15158. + return;
  15159. + };
  15160. + print "Syntax error on line $_[0]->YYData->{line}.\n";
  15161. +}
  15162. +
  15163. +sub _Lexer {
  15164. + my($parser)=shift;
  15165. +
  15166. + if (! $parser->YYData->{INPUT}) {
  15167. + if ($parser->YYData->{INPUT} = <$fh>) {
  15168. + $parser->YYData->{line} += 1;
  15169. + } else {
  15170. + return ('', undef);
  15171. + }
  15172. + }
  15173. +
  15174. + $parser->YYData->{INPUT} and
  15175. + $parser->YYData->{INPUT} =~ s/^\s*//;
  15176. +
  15177. + while (1) {
  15178. +
  15179. + # skip blank lines
  15180. + if ($parser->YYData->{INPUT} =~ s/^[ \t\r\n]*$//) {
  15181. + if ($parser->YYData->{INPUT} = <$fh>) {
  15182. + $parser->YYData->{line} += 1;
  15183. + } else {
  15184. + return ('', undef);
  15185. + }
  15186. + $parser->YYData->{INPUT} and
  15187. + $parser->YYData->{INPUT} =~ s/^\s*//;
  15188. + next;
  15189. + }
  15190. +
  15191. + # Skip comments
  15192. + if ($parser->YYData->{INPUT} =~ s/^#.*//) {
  15193. + if ($parser->YYData->{INPUT} = <$fh>) {
  15194. + $parser->YYData->{line} += 1;
  15195. + } else {
  15196. + return ('', undef);
  15197. + }
  15198. + $parser->YYData->{INPUT} and
  15199. + $parser->YYData->{INPUT} =~ s/^\s*//;
  15200. + next;
  15201. + }
  15202. +
  15203. + # Don't continue if the line length is 0;
  15204. + if (length $parser->YYData->{INPUT} == 0) {
  15205. + if ($parser->YYData->{INPUT} = <$fh>) {
  15206. + $parser->YYData->{line} += 1;
  15207. + } else {
  15208. + return ('', undef);
  15209. + }
  15210. + $parser->YYData->{INPUT} and
  15211. + $parser->YYData->{INPUT} =~ s/^\s*//;
  15212. + next;
  15213. + }
  15214. +
  15215. + # tokenize input
  15216. + $parser->YYData->{INPUT} =~ s/^([a-zA-Z_][a-zA-Z_0-9\/]*)//
  15217. + and return('IDENTIFIER',$1);
  15218. + $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)"//
  15219. + and return('STRING_LITERAL',$1);
  15220. + $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)//
  15221. + and do {
  15222. + my $literal = $1;
  15223. +
  15224. + do {
  15225. + if ($parser->YYData->{INPUT} = <$fh>) {
  15226. + $parser->YYData->{line} += 1;
  15227. + } else {
  15228. + return ('', undef);
  15229. + }
  15230. +
  15231. + $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)"//
  15232. + and do {
  15233. + $literal .= $1;
  15234. + return ('STRING_LITERAL', $literal);
  15235. + };
  15236. +
  15237. + $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)//
  15238. + and $literal .= $1;
  15239. + } while (1);
  15240. + };
  15241. + $parser->YYData->{INPUT} =~ s/^([0-9]+)//
  15242. + and return('NUMBER',$1);
  15243. + $parser->YYData->{INPUT} =~ s/^([\$]{1,2}[a-zA-Z0-9 \/_]+)//
  15244. + and return('HIERARCHICAL_NAME',$1);
  15245. + $parser->YYData->{INPUT} =~ s/^(.)//
  15246. + and return($1,$1);
  15247. + }
  15248. +}
  15249. +
  15250. +sub readPTF {
  15251. + my $self = shift;
  15252. + my $filename = shift;
  15253. +
  15254. + # store information for later use
  15255. + $self->YYData->{line} = 0;
  15256. + $self->YYData->{sectionStack} = [];
  15257. + undef $self->YYData->{root};
  15258. +
  15259. + if (-e $filename) {
  15260. + open (PTFFILE, $filename);
  15261. + $fh = \*PTFFILE;
  15262. + } else {
  15263. + $fh = \*STDIN;
  15264. + }
  15265. +
  15266. + $self->YYParse (
  15267. + yylex => \&_Lexer,
  15268. + yyerror => \&_Error,
  15269. + );
  15270. +
  15271. + if (-e $filename) {
  15272. + close PTFFILE;
  15273. + }
  15274. +
  15275. + return $self->YYData->{root};
  15276. +}
  15277. +
  15278. +1;
  15279. diff --git a/arch/nios2nommu/scripts/PTF/PTFParser.yp b/arch/nios2nommu/scripts/PTF/PTFParser.yp
  15280. new file mode 100644
  15281. index 0000000..e105e6a
  15282. --- /dev/null
  15283. +++ b/arch/nios2nommu/scripts/PTF/PTFParser.yp
  15284. @@ -0,0 +1,178 @@
  15285. +%{#
  15286. +# Altera PTF file parser
  15287. +#
  15288. +# Copyright (c) 2004 Microtronix Datacom Ltd.
  15289. +#
  15290. +
  15291. +package PTFParser;
  15292. +
  15293. +use PTF::PTFSection;
  15294. +
  15295. +%}
  15296. +
  15297. +%%
  15298. +section: section_title '{' section_element '}' {
  15299. + my $sectionStack = $_[0]->YYData->{sectionStack};
  15300. + pop @{$sectionStack};
  15301. + }
  15302. +;
  15303. +
  15304. +section_title: IDENTIFIER section_name {
  15305. + my $section = PTFSection->new (type => $_[1], name => $_[2]);
  15306. + my $sectionStack = $_[0]->YYData->{sectionStack};
  15307. +
  15308. + if (scalar(@{$sectionStack}) == 0) {
  15309. + $_[0]->YYData->{root} = $section;
  15310. + } else {
  15311. + my $parent = $sectionStack->[$#{$sectionStack}];
  15312. + $parent->addSection ($section);
  15313. + }
  15314. +
  15315. + push @{$sectionStack}, $section;
  15316. + }
  15317. +;
  15318. +
  15319. +section_name: # empty string
  15320. + | IDENTIFIER
  15321. + | NUMBER
  15322. + | STRING_LITERAL
  15323. +;
  15324. +
  15325. +section_element: # empty element
  15326. + | assignment section_element
  15327. + | section section_element
  15328. +;
  15329. +
  15330. +assignment: assignment_name '=' assignment_value ';' {
  15331. + my $sectionStack = $_[0]->YYData->{sectionStack};
  15332. + my $parent= $sectionStack->[$#{$sectionStack}];
  15333. + $parent->addAssignment ($_[1], $_[3]);
  15334. + }
  15335. +;
  15336. +
  15337. +assignment_name: IDENTIFIER
  15338. + | HIERARCHICAL_NAME
  15339. +;
  15340. +
  15341. +assignment_value: STRING_LITERAL
  15342. + | NUMBER
  15343. +;
  15344. +
  15345. +%%
  15346. +
  15347. +sub _Error {
  15348. +# TODO: update this error function to be more useful
  15349. + exists $_[0]->YYData->{ERRMSG}
  15350. + and do {
  15351. + print $_[0]->YYData->{ERRMSG};
  15352. + delete $_[0]->YYData->{ERRMSG};
  15353. + return;
  15354. + };
  15355. + print "Syntax error on line $_[0]->YYData->{line}.\n";
  15356. +}
  15357. +
  15358. +sub _Lexer {
  15359. + my($parser)=shift;
  15360. +
  15361. + if (! $parser->YYData->{INPUT}) {
  15362. + if ($parser->YYData->{INPUT} = <PTFFILE>) {
  15363. + $parser->YYData->{line} += 1;
  15364. + } else {
  15365. + return ('', undef);
  15366. + }
  15367. + }
  15368. +
  15369. + $parser->YYData->{INPUT} and
  15370. + $parser->YYData->{INPUT} =~ s/^\s*//;
  15371. +
  15372. + while (1) {
  15373. +
  15374. + # skip blank lines
  15375. + if ($parser->YYData->{INPUT} =~ s/^[ \t\r\n]*$//) {
  15376. + if ($parser->YYData->{INPUT} = <PTFFILE>) {
  15377. + $parser->YYData->{line} += 1;
  15378. + } else {
  15379. + return ('', undef);
  15380. + }
  15381. + $parser->YYData->{INPUT} and
  15382. + $parser->YYData->{INPUT} =~ s/^\s*//;
  15383. + next;
  15384. + }
  15385. +
  15386. + # Skip comments
  15387. + if ($parser->YYData->{INPUT} =~ s/^#.*//) {
  15388. + if ($parser->YYData->{INPUT} = <PTFFILE>) {
  15389. + $parser->YYData->{line} += 1;
  15390. + } else {
  15391. + return ('', undef);
  15392. + }
  15393. + $parser->YYData->{INPUT} and
  15394. + $parser->YYData->{INPUT} =~ s/^\s*//;
  15395. + next;
  15396. + }
  15397. +
  15398. + # Don't continue if the line length is 0;
  15399. + if (length $parser->YYData->{INPUT} == 0) {
  15400. + if ($parser->YYData->{INPUT} = <PTFFILE>) {
  15401. + $parser->YYData->{line} += 1;
  15402. + } else {
  15403. + return ('', undef);
  15404. + }
  15405. + $parser->YYData->{INPUT} and
  15406. + $parser->YYData->{INPUT} =~ s/^\s*//;
  15407. + next;
  15408. + }
  15409. +
  15410. + # tokenize input
  15411. + $parser->YYData->{INPUT} =~ s/^([a-zA-Z_][a-zA-Z_0-9\/]*)//
  15412. + and return('IDENTIFIER',$1);
  15413. + $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)"//
  15414. + and return('STRING_LITERAL',$1);
  15415. + $parser->YYData->{INPUT} =~ s/^"([^"\\]*(\\.[^"\\]*)*)//
  15416. + and do {
  15417. + my $literal = $1;
  15418. +
  15419. + do {
  15420. + if ($parser->YYData->{INPUT} = <PTFFILE>) {
  15421. + $parser->YYData->{line} += 1;
  15422. + } else {
  15423. + return ('', undef);
  15424. + }
  15425. +
  15426. + $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)"//
  15427. + and do {
  15428. + $literal .= $1;
  15429. + return ('STRING_LITERAL', $literal);
  15430. + };
  15431. +
  15432. + $parser->YYData->{INPUT} =~ s/([^"\\]*(\\.[^"\\]*)*)//
  15433. + and $literal .= $1;
  15434. + } while (1);
  15435. + };
  15436. + $parser->YYData->{INPUT} =~ s/^([0-9]+)//
  15437. + and return('NUMBER',$1);
  15438. + $parser->YYData->{INPUT} =~ s/^([\$]{1,2}[a-zA-Z0-9 \/_]+)//
  15439. + and return('HIERARCHICAL_NAME',$1);
  15440. + $parser->YYData->{INPUT} =~ s/^(.)//
  15441. + and return($1,$1);
  15442. + }
  15443. +}
  15444. +
  15445. +sub readPTF {
  15446. + my $self = shift;
  15447. + my $filename = shift;
  15448. +
  15449. + # store information for later use
  15450. + $self->YYData->{line} = 0;
  15451. + $self->YYData->{sectionStack} = [];
  15452. + undef $self->YYData->{root};
  15453. +
  15454. + open (PTFFILE, $filename) or return undef;
  15455. + $self->YYParse (
  15456. + yylex => \&_Lexer,
  15457. + yyerror => \&_Error,
  15458. + );
  15459. + close PTFFILE;
  15460. +
  15461. + return $self->YYData->{root};
  15462. +}
  15463. diff --git a/arch/nios2nommu/scripts/PTF/PTFSection.pm b/arch/nios2nommu/scripts/PTF/PTFSection.pm
  15464. new file mode 100644
  15465. index 0000000..a88d340
  15466. --- /dev/null
  15467. +++ b/arch/nios2nommu/scripts/PTF/PTFSection.pm
  15468. @@ -0,0 +1,81 @@
  15469. +package PTFSection;
  15470. +
  15471. +use strict;
  15472. +
  15473. +# Fields:
  15474. +# type = type of PTF Section
  15475. +# name = name of PTF Section (can be blank)
  15476. +# sections = array of section references
  15477. +# assignments = hash of assignments
  15478. +
  15479. +sub new {
  15480. + my $invocant = shift;
  15481. + my $class = ref($invocant) || $invocant;
  15482. + my $self = {
  15483. + @_,
  15484. + sections => [],
  15485. + assignments => {},
  15486. + };
  15487. + bless ($self, $class);
  15488. + return $self;
  15489. +}
  15490. +
  15491. +sub addSection {
  15492. + my ($self, $section) = @_;
  15493. + push @{$self->{sections}}, $section;
  15494. +}
  15495. +
  15496. +sub getSections {
  15497. + my ($self, $type) = @_;
  15498. +
  15499. + if (! $type) {
  15500. + return @{$self->{sections}};
  15501. + }
  15502. +
  15503. + my @matchedSections;
  15504. + foreach my $section (@{$self->{sections}}) {
  15505. + if ($section->type eq $type) {
  15506. + push @matchedSections, $section;
  15507. + }
  15508. + }
  15509. +
  15510. + return @matchedSections;
  15511. +}
  15512. +
  15513. +sub getSection {
  15514. + my ($self, $type, $name) = @_;
  15515. +
  15516. + if (! $name) {
  15517. + $name = "";
  15518. + }
  15519. +
  15520. + foreach my $section (@{$self->{sections}}) {
  15521. + if ($section->type eq $type and $section->name eq $name) {
  15522. + return $section;
  15523. + }
  15524. + }
  15525. +
  15526. +}
  15527. +
  15528. +sub addAssignment {
  15529. + my ($self, $name, $value) = @_;
  15530. + $self->{assignments}{$name} = $value;
  15531. +}
  15532. +
  15533. +sub getAssignment {
  15534. + my ($self, $name) = @_;
  15535. + return $self->{assignments}{$name};
  15536. +}
  15537. +
  15538. +sub type {
  15539. + my $self = shift;
  15540. + return $self->{type};
  15541. +}
  15542. +
  15543. +sub name {
  15544. + my $self = shift;
  15545. + return $self->{name};
  15546. +}
  15547. +
  15548. +
  15549. +1;
  15550. diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF.pm b/arch/nios2nommu/scripts/PTF/SystemPTF.pm
  15551. new file mode 100644
  15552. index 0000000..9f44cfe
  15553. --- /dev/null
  15554. +++ b/arch/nios2nommu/scripts/PTF/SystemPTF.pm
  15555. @@ -0,0 +1,149 @@
  15556. +package SystemPTF;
  15557. +
  15558. +use strict;
  15559. +
  15560. +use PTF::PTFParser;
  15561. +use PTF::PTFSection;
  15562. +use PTF::SystemPTF::CPU;
  15563. +use PTF::SystemPTF::Board;
  15564. +use PTF::SystemPTF::Module;
  15565. +
  15566. +# Fields:
  15567. +
  15568. +my %module_order;
  15569. +
  15570. +sub new {
  15571. + my $invocant = shift;
  15572. + my $class = ref($invocant) || $invocant;
  15573. + my $self = {
  15574. + filename => "",
  15575. + @_,
  15576. + };
  15577. +
  15578. + my $parser = PTFParser->new;
  15579. + $self->{root} = $parser->readPTF($self->{filename});
  15580. +
  15581. + # if the specified PTF file could not be read properly, return undef;
  15582. + $self->{root} or return;
  15583. +
  15584. + # if the specified PTF file is not a SYSTEM, return undef.
  15585. + if ($self->{root}->type ne 'SYSTEM') {
  15586. + return;
  15587. + }
  15588. +
  15589. + # initialize the modulemap
  15590. + my @modules = $self->{root}->getSections ("MODULE");
  15591. + my $index = 0;
  15592. + foreach my $module (@modules) {
  15593. + # if the module is not enabled then do not add
  15594. + my $SBI = $module->getSection ('SYSTEM_BUILDER_INFO', '');
  15595. + if ($SBI->getAssignment ('Is_Enabled') eq "1") {
  15596. + $self->{modules}->{$module->name} = $module;
  15597. + $module_order{$module->name} = $index;
  15598. + $index += 1;
  15599. + }
  15600. + }
  15601. +
  15602. + bless ($self, $class);
  15603. + return $self;
  15604. +}
  15605. +
  15606. +sub getName {
  15607. + my ($self) = @_;
  15608. + return $self->{root}->name;
  15609. +}
  15610. +
  15611. +sub getCPUList {
  15612. + my ($self, @classes) = @_;
  15613. + my @cpulist = ();
  15614. +
  15615. + foreach my $module_name (keys (%{$self->{modules}})) {
  15616. + my $module = $self->{modules}->{$module_name};
  15617. + my $module_class = $module->getAssignment ('class');
  15618. + foreach my $class (@classes) {
  15619. + if ($module_class eq $class) {
  15620. + push @cpulist, $module->name;
  15621. + }
  15622. + }
  15623. + }
  15624. +
  15625. + return @cpulist;
  15626. +}
  15627. +
  15628. +sub getCPU {
  15629. + my ($self, $name) = @_;
  15630. +
  15631. + my $cpu = CPU->new (ptf => $self->{modules}->{$name});
  15632. +}
  15633. +
  15634. +sub getModule {
  15635. + my ($self, $name) = @_;
  15636. +
  15637. + my $module = Module->new (ptf => $self->{modules}->{$name});
  15638. +}
  15639. +
  15640. +sub getSlaveModules {
  15641. + my ($self, $master, $type) = @_;
  15642. +
  15643. + # create %connected set with just the master
  15644. + # value of hash key is inconsequential
  15645. + my %connected;
  15646. + $connected{$master} = ( );
  15647. +
  15648. + # create %pool set with all modules
  15649. + # value of hash key is inconsequential
  15650. + my %pool;
  15651. + @pool{keys (%{$self->{modules}})} = ( );
  15652. +
  15653. + my $dirty = 1;
  15654. + while ($dirty) {
  15655. + # %pool = difference (%pool, %connected)
  15656. + delete @pool{ keys %connected };
  15657. +
  15658. + $dirty = 0;
  15659. +
  15660. + foreach my $name (keys %pool) {
  15661. + my $mod = $self->getModule ($name);
  15662. + my %mod_masters;
  15663. + @mod_masters{ $mod->getMasters ($type) } = ( );
  15664. +
  15665. + # if intersection (%masters, %connected) is not empty
  15666. + delete @mod_masters{
  15667. + grep ( ! exists $connected{ $_ },
  15668. + keys %mod_masters) };
  15669. +
  15670. + if (scalar(keys(%mod_masters)) > 0) {
  15671. + $connected{$name} = ( );
  15672. + $dirty = 1;
  15673. + }
  15674. + }
  15675. + }
  15676. +
  15677. + delete $connected{$master};
  15678. +
  15679. + return sort module_comparison keys (%connected);
  15680. +}
  15681. +
  15682. +sub getClockFreq () {
  15683. + my ($self) = @_;
  15684. +
  15685. + my $wsa = $self->{root}->getSection ('WIZARD_SCRIPT_ARGUMENTS', '');
  15686. + $wsa or return;
  15687. +
  15688. + my $result = $wsa->getAssignment ('clock_freq');
  15689. + return $result;
  15690. +}
  15691. +
  15692. +# This is not really a class method... more of a helper function really...
  15693. +sub module_comparison {
  15694. + if ($module_order{$a} > $module_order{$b}) {
  15695. + return 1;
  15696. + } elsif ($module_order{$a} < $module_order{$b}) {
  15697. + return -1;
  15698. + } else {
  15699. + return 0;
  15700. + }
  15701. +}
  15702. +
  15703. +
  15704. +1;
  15705. diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF/Board.pm b/arch/nios2nommu/scripts/PTF/SystemPTF/Board.pm
  15706. new file mode 100644
  15707. index 0000000..fe2bbc8
  15708. --- /dev/null
  15709. +++ b/arch/nios2nommu/scripts/PTF/SystemPTF/Board.pm
  15710. @@ -0,0 +1,2 @@
  15711. +1;
  15712. +
  15713. diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF/CPU.pm b/arch/nios2nommu/scripts/PTF/SystemPTF/CPU.pm
  15714. new file mode 100644
  15715. index 0000000..ea10598
  15716. --- /dev/null
  15717. +++ b/arch/nios2nommu/scripts/PTF/SystemPTF/CPU.pm
  15718. @@ -0,0 +1,89 @@
  15719. +package CPU;
  15720. +
  15721. +use PTF::PTFSection;
  15722. +
  15723. +sub new {
  15724. + my $invocant = shift;
  15725. + my $class = ref($invocant) || $invocant;
  15726. + my $self = {
  15727. + @_,
  15728. + };
  15729. +
  15730. + # if no ptf section was passed in, then return undef
  15731. + $self->{ptf} or return;
  15732. +
  15733. + bless ($self, $class);
  15734. + return $self;
  15735. +}
  15736. +
  15737. +sub getClass {
  15738. + my ($self) = @_;
  15739. +
  15740. + return $self->{ptf}->getAssignment ('class');
  15741. +}
  15742. +
  15743. +sub getVersion {
  15744. + my ($self) = @_;
  15745. +
  15746. + return $self->{ptf}->getAssignment ('class_version');
  15747. +}
  15748. +
  15749. +sub getConstant {
  15750. + my ($self, $name) = @_;
  15751. +
  15752. + # get WSA
  15753. + $wsa = $self->{ptf}->getSection('WIZARD_SCRIPT_ARGUMENTS', '');
  15754. + $wsa or return;
  15755. +
  15756. + # get constants section
  15757. + $constants = $wsa->getSection('CONSTANTS', '');
  15758. + $constants or return;
  15759. +
  15760. + # get section for specific constant
  15761. + $constant = $constants->getSection ('CONSTANT', $name);
  15762. + $constant or return;
  15763. +
  15764. + # get value of constant
  15765. + $value = $constant->getAssignment ('value');
  15766. + return $value;
  15767. +}
  15768. +
  15769. +sub getWSAAssignment {
  15770. + my ($self, $name) = @_;
  15771. +
  15772. + # get WSA
  15773. + $wsa = $self->{ptf}->getSection('WIZARD_SCRIPT_ARGUMENTS', '');
  15774. + $wsa or return;
  15775. +
  15776. + # get value of WSA Assignment
  15777. + $value = $wsa->getAssignment ($name);
  15778. + return $value;
  15779. +}
  15780. +
  15781. +sub getResetLocationOffset {
  15782. + my ($self) = @_;
  15783. +
  15784. + $wsa = $self->{ptf}->getSection('WIZARD_SCRIPT_ARGUMENTS', '');
  15785. + $wsa or return;
  15786. +
  15787. + my $location = $wsa->getAssignment ('reset_slave');
  15788. + my $offset = $wsa->getAssignment ('reset_offset');
  15789. +
  15790. + return ($location, $offset);
  15791. +}
  15792. +
  15793. +sub isEnabled {
  15794. + my ($self) = @_;
  15795. +
  15796. + $sbi = $self->{ptf}->getSection('SYSTEM_BUILDER_INFO', '');
  15797. + $sbi or return;
  15798. +
  15799. + my $enabled = $sbi->getAssignment ('Is_Enabled');
  15800. + if ($enabled eq "1") {
  15801. + return 1;
  15802. + } else {
  15803. + return 0;
  15804. + }
  15805. +}
  15806. +
  15807. +1;
  15808. diff --git a/arch/nios2nommu/scripts/PTF/SystemPTF/Module.pm b/arch/nios2nommu/scripts/PTF/SystemPTF/Module.pm
  15809. new file mode 100644
  15810. index 0000000..48d246b
  15811. --- /dev/null
  15812. +++ b/arch/nios2nommu/scripts/PTF/SystemPTF/Module.pm
  15813. @@ -0,0 +1,267 @@
  15814. +package Module;
  15815. +
  15816. +use PTF::PTFSection;
  15817. +
  15818. +sub new {
  15819. + my $invocant = shift;
  15820. + my $class = ref($invocant) || $invocant;
  15821. + my $self = {
  15822. + @_,
  15823. + };
  15824. +
  15825. + # if no ptf section was passed in, then return undef
  15826. + $self->{ptf} or return;
  15827. +
  15828. + bless ($self, $class);
  15829. + return $self;
  15830. +}
  15831. +
  15832. +sub getClass {
  15833. + my ($self) = @_;
  15834. +
  15835. + return $self->{ptf}->getAssignment ('class');
  15836. +}
  15837. +
  15838. +sub getPorts {
  15839. + my ($self) = @_;
  15840. +
  15841. + my @port_names;
  15842. +
  15843. + my @ports = $self->{ptf}->getSections ('SLAVE');
  15844. + foreach $port (@ports) {
  15845. + push @port_names, $port->name;
  15846. + }
  15847. +
  15848. + return @port_names;
  15849. +}
  15850. +
  15851. +sub getPort {
  15852. + my ($self, $port_name) = @_;
  15853. +
  15854. + my $port;
  15855. +
  15856. + if (! $port_name) {
  15857. + # use first port found
  15858. + my @port_names = $self->getPorts ();
  15859. + $port = $self->{ptf}->getSection ('SLAVE', $port_names[0]);
  15860. + } else {
  15861. + $port = $self->{ptf}->getSection ('SLAVE', $port_name);
  15862. + if (! $port) {
  15863. + # return undef if the PTF section doesn't exist
  15864. + return;
  15865. + }
  15866. + }
  15867. +
  15868. + return $port;
  15869. +}
  15870. +
  15871. +sub getWSAAssignment {
  15872. + my ($self, $assignment) = @_;
  15873. +
  15874. + my $WSA = $self->{ptf}->getSection ('WIZARD_SCRIPT_ARGUMENTS', '');
  15875. + if (! $WSA) {
  15876. + # return undef if the WSA section doesn't exist.
  15877. + return;
  15878. + }
  15879. +
  15880. + my $result = $WSA->getAssignment ($assignment);
  15881. +
  15882. + return $result;
  15883. +
  15884. +}
  15885. +
  15886. +sub getWSAConstant {
  15887. + my ($self, $name) = @_;
  15888. +
  15889. + my $WSA = $self->{ptf}->getSection ('WIZARD_SCRIPT_ARGUMENTS', '');
  15890. + if (! $WSA) {
  15891. + # return undef if the WSA section doesn't exist.
  15892. + return;
  15893. + }
  15894. +
  15895. + my $constants = $WSA->getSection ('CONSTANTS', '');
  15896. + if (! $constants) {
  15897. + # return undef if the CONSTANTS section doesn't exist.
  15898. + return;
  15899. + }
  15900. +
  15901. + my $constant = $constants->getSection ('CONSTANT', $name);
  15902. + if (! $constant) {
  15903. + # return undef if the CONSTANT $name section doesn't exist.
  15904. + return;
  15905. + }
  15906. +
  15907. + my $result = $constant->getAssignment ('value');
  15908. + return $result;
  15909. +
  15910. +}
  15911. +
  15912. +sub isMemoryDevice {
  15913. + my ($self, $port_name) = @_;
  15914. +
  15915. + my $port = $self->getPort ($port_name);
  15916. + if (! $port) {
  15917. + # return undef if the PTF section doesn't exist
  15918. + return;
  15919. + }
  15920. +
  15921. + my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
  15922. + if (! $SBI) {
  15923. + # return undef if the PTF section doesn't exist
  15924. + return;
  15925. + }
  15926. +
  15927. + my $result = $SBI->getAssignment('Is_Memory_Device');
  15928. +
  15929. + return $result;
  15930. +}
  15931. +
  15932. +sub isCustomInstruction {
  15933. + my ($self, $port_name) = @_;
  15934. +
  15935. + my $port = $self->getPort ($port_name);
  15936. + if (! $port) {
  15937. + # return undef if the PTF section doesn't exist
  15938. + return;
  15939. + }
  15940. +
  15941. + my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
  15942. + if (! $SBI) {
  15943. + # return undef if the PTF section doesn't exist
  15944. + return;
  15945. + }
  15946. +
  15947. + my $result = $SBI->getAssignment('Is_Custom_Instruction');
  15948. +
  15949. + return $result;
  15950. +}
  15951. +
  15952. +sub getBaseAddress {
  15953. + my ($self, $port_name) = @_;
  15954. +
  15955. + my $port = $self->getPort ($port_name);
  15956. + if (! $port) {
  15957. + # return undef if the PTF section doesn't exist
  15958. + return;
  15959. + }
  15960. +
  15961. + my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
  15962. + if (! $SBI) {
  15963. + # return undef if the PTF section doesn't exist
  15964. + return;
  15965. + }
  15966. +
  15967. + my $result = $SBI->getAssignment('Base_Address');
  15968. + if ($result eq 'N/A') {
  15969. + return;
  15970. + }
  15971. + return $result;
  15972. +}
  15973. +
  15974. +sub getSize {
  15975. + my ($self, $port_name) = @_;
  15976. +
  15977. + my $port = $self->getPort ($port_name);
  15978. + $port or return; #return undef if the ptf section doesn't exist
  15979. +
  15980. + my $SBI = $port->getSection ('SYSTEM_BUILDER_INFO', '');
  15981. + my $data_width = $SBI->getAssignment ('Data_Width');
  15982. + my $addr_width = $SBI->getAssignment ('Address_Width');
  15983. +
  15984. + if ($data_width == 8) {
  15985. + $size = 1 << $addr_width;
  15986. + } elsif ($data_width == 16) {
  15987. + $size = 1 << ($addr_width + 1);
  15988. + } elsif ($data_width == 32) {
  15989. + $size = 1 << ($addr_width + 2);
  15990. + } elsif ($data_width == 64) {
  15991. + $size = 1 << ($addr_width + 3);
  15992. + } elsif ($data_width == 128) {
  15993. + $size = 1 << ($addr_width + 4);
  15994. + } else {
  15995. + return;
  15996. + }
  15997. +
  15998. + $size_text = sprintf ("%#010x", $size);
  15999. + return $size_text;
  16000. +}
  16001. +
  16002. +sub getIRQ {
  16003. + my ($self, $port_name) = @_;
  16004. +
  16005. + my $port = $self->getPort ($port_name);
  16006. + if (! $port) {
  16007. + # return undef if the PTF section doesn't exist
  16008. + return;
  16009. + }
  16010. +
  16011. + my $SBI = $port->getSection('SYSTEM_BUILDER_INFO', '');
  16012. + if (! $SBI) {
  16013. + # return undef if the PTF section doesn't exist
  16014. + return;
  16015. + }
  16016. +
  16017. + my $result = $SBI->getAssignment('Has_IRQ');
  16018. + if ($result ne "1") {
  16019. + # this device has no associated IRQ
  16020. + return;
  16021. + }
  16022. +
  16023. + my @irq_masters = $SBI->getSections('IRQ_MASTER');
  16024. + return $irq_masters[0]->getAssignment('IRQ_Number');
  16025. +}
  16026. +
  16027. +sub getMasters {
  16028. + my ($self, $type) = @_;
  16029. + my %masters = ();
  16030. +
  16031. + # get list of all slave for device
  16032. + my @slaves = $self->{ptf}->getSections ('SLAVE');
  16033. +
  16034. + # get list of masters of relevant type for all slaves
  16035. + foreach my $slave (@slaves) {
  16036. + # get SBI for slave
  16037. + my $SBI = $slave->getSection ('SYSTEM_BUILDER_INFO', '');
  16038. +
  16039. + # get list of all MASTERED_BY and IRQ_MASTER sections
  16040. + my @mastered_bys = $SBI->getSections ('MASTERED_BY');
  16041. + my @irq_masters = $SBI->getSections ('IRQ_MASTER');
  16042. +
  16043. + # start adding masters to the list
  16044. + foreach my $master (@mastered_bys, @irq_masters) {
  16045. + my $section_name = $master->name;
  16046. + $section_name =~ /(.*)\/(.*)/;
  16047. + my $master_name = $1;
  16048. + my $master_type = $2;
  16049. +
  16050. + if (! $type) {
  16051. + $masters{$master_name} = ();
  16052. + } else {
  16053. + if ($master_type eq $type) {
  16054. + $masters{$master_name} = ();
  16055. + }
  16056. + }
  16057. +
  16058. + }
  16059. +
  16060. + }
  16061. +
  16062. + return keys (%masters);
  16063. +}
  16064. +
  16065. +sub isEnabled {
  16066. + my ($self) = @_;
  16067. +
  16068. + $sbi = $self->{ptf}->getSection('SYSTEM_BUILDER_INFO', '');
  16069. + $sbi or return;
  16070. +
  16071. + my $enabled = $sbi->getAssignment ('Is_Enabled');
  16072. + if ($enabled eq "1") {
  16073. + return 1;
  16074. + } else {
  16075. + return 0;
  16076. + }
  16077. +}
  16078. +
  16079. +1;
  16080. +
  16081. diff --git a/arch/nios2nommu/scripts/gen_nios2_system.h.pl b/arch/nios2nommu/scripts/gen_nios2_system.h.pl
  16082. new file mode 100644
  16083. index 0000000..b7bcff5
  16084. --- /dev/null
  16085. +++ b/arch/nios2nommu/scripts/gen_nios2_system.h.pl
  16086. @@ -0,0 +1,314 @@
  16087. +# This script generates an appropriate hardware.h file for Nios II Linux based
  16088. +# on information within the target hardware's system.ptf file. This script
  16089. +# outputs everything to stdout.
  16090. +#
  16091. +# usage:
  16092. +#
  16093. +# [SOPC Builder]$ perl gen_hardware.h.pl <target cpu> <exec location> \
  16094. +# <upload location>
  16095. +#
  16096. +
  16097. +use PTF::SystemPTF;
  16098. +use strict;
  16099. +use integer;
  16100. +
  16101. +my $target_cpu;
  16102. +my $exec_location;
  16103. +my $upload_location;
  16104. +
  16105. +if (scalar (@ARGV) != 3) {
  16106. + print STDERR "ERROR: Invalid number of parameters.\n";
  16107. + print ("#error Invalid number of parameters.\n");
  16108. + exit;
  16109. +} else {
  16110. + $target_cpu = $ARGV[0];
  16111. + $exec_location = $ARGV[1];
  16112. + $upload_location = $ARGV[2];
  16113. +}
  16114. +
  16115. +#
  16116. +# startup the parser.
  16117. +#
  16118. +my $system = SystemPTF->new;
  16119. +if (!$system) {
  16120. + print STDERR "ERROR: Specified file is not a SYSTEM ptf file.\n";
  16121. + print ("#error Specified file is not a SYSTEM ptf file.\n");
  16122. + exit;
  16123. +}
  16124. +
  16125. +#
  16126. +# print header for nios2_system.h
  16127. +#
  16128. +print <<ENDOFHEADER;
  16129. +#ifndef __NIOS2_SYSTEM_H__
  16130. +#define __NIOS2_SYSTEM_H__
  16131. +
  16132. +/*
  16133. + * This file contains hardware information about the target platform.
  16134. + * The nios2_system.h file is being phased out and will be removed in a
  16135. + * later release.
  16136. + *
  16137. + * All base addresses for non memory devices have their high bit turned on to
  16138. + * bypass the cache.
  16139. + *
  16140. + * This file is automatically generated. Do not modify.
  16141. + */
  16142. +
  16143. +ENDOFHEADER
  16144. +
  16145. +#
  16146. +# generate contents for nios2_system.h
  16147. +#
  16148. +my $result; # dummy variable
  16149. +my $cpu = $system->getCPU ($target_cpu);
  16150. +if (! $cpu) {
  16151. + print STDERR "ERROR: $target_cpu is not a valid CPU in system: " . $system->getName () . ".\n";
  16152. + print "#error $target_cpu is not a valid CPU in system: " . $system->getName () . ".\n";
  16153. + exit 1;
  16154. +}
  16155. +
  16156. +my $exec_module = $system->getModule ($exec_location);
  16157. +if (! $exec_module) {
  16158. + print STDERR "ERROR: $exec_location is not a valid module in the system: " . $system->getName() . ".\n";
  16159. + print "#error $exec_location is not a valid module in system: " . $system->getName () . ".\n";
  16160. + exit 1;
  16161. +}
  16162. +
  16163. +my $upload_module = $system->getModule ($upload_location);
  16164. +if (! $upload_module) {
  16165. + print STDERR "ERROR: $upload_location is not a valid module in the system: " . $system->getName() . ".\n";
  16166. + print "#error $upload_location is not a valid module in system: " . $system->getName () . ".\n";
  16167. + exit 1;
  16168. +}
  16169. +
  16170. +my %found_classes;
  16171. +my @found_classes_order;
  16172. +
  16173. +# the SYSPTF environment variable is set by kernel build process.
  16174. +if ($ENV{SYSPTF} ne "") {
  16175. + print "/* Input System: " . $ENV{SYSPTF} . ":" . $system->getName () . " */\n";
  16176. +} else {
  16177. + print "/* Input System: " . $system->getName () . " */\n";
  16178. +}
  16179. +print "/* Target CPU: " . $target_cpu . " */\n";
  16180. +
  16181. +print "\n";
  16182. +
  16183. +print <<ENDOFCONSTANTS;
  16184. +/* Nios II Constants */
  16185. +#define NIOS2_STATUS_PIE_MSK 0x1
  16186. +#define NIOS2_STATUS_PIE_OFST 0
  16187. +#define NIOS2_STATUS_U_MSK 0x2
  16188. +#define NIOS2_STATUS_U_OFST 1
  16189. +ENDOFCONSTANTS
  16190. +
  16191. +print "\n";
  16192. +
  16193. +print "/*\n";
  16194. +print " * Outputting basic values from system.ptf.\n";
  16195. +print " */\n\n";
  16196. +
  16197. +#
  16198. +# Start outputing information about each module.
  16199. +#
  16200. +my @module_names = $system->getSlaveModules ($target_cpu);
  16201. +foreach my $module_name (@module_names) {
  16202. + my $module = $system->getModule ($module_name);
  16203. + my $module_class = $module->getClass ();
  16204. + my @module_ports = $module->getPorts ();
  16205. + my $mask = 0;
  16206. + my $text_printed = 0;
  16207. + my $output = "";
  16208. +
  16209. + # $output .= "/* $module_name (of type $module_class) */\n";
  16210. +
  16211. + if (! exists $found_classes{$module_class}) {
  16212. + push @found_classes_order, $module_class;
  16213. + }
  16214. + push @{$found_classes{$module_class}}, $module_name;
  16215. +
  16216. + if (! $module->isMemoryDevice () && ! $module->isCustomInstruction ()) {
  16217. + # turn on high bit for base address
  16218. + $mask = 0x80000000;
  16219. + }
  16220. +
  16221. + if (scalar (@module_ports) == 1) {
  16222. + my $base_address;
  16223. + my $mem_size;
  16224. + my $mem_end;
  16225. +
  16226. + # base address information
  16227. + $base_address = $module->getBaseAddress ();
  16228. + if ($base_address) {
  16229. + $output .= sprintf ("#define na_%-50s %#010x\n",
  16230. + ($module_name, hex ($base_address) | $mask));
  16231. + $text_printed = 1;
  16232. + }
  16233. + if ($module->isMemoryDevice()) {
  16234. + # output size and end address
  16235. + $mem_size = $module->getSize();
  16236. + $output .= sprintf ("#define na_%-50s %#010x\n",
  16237. + ($module_name . "_size", hex ($mem_size)));
  16238. + $mem_end = hex ($mem_size) + hex($base_address);
  16239. + $output .= sprintf ("#define na_%-50s %#010x\n",
  16240. + ($module_name . "_end", $mem_end));
  16241. +
  16242. + $text_printed = 1;
  16243. + }
  16244. +
  16245. + # irq information
  16246. + $result = $module->getIRQ ();
  16247. + if (defined ($result)) {
  16248. + $output .= sprintf ("#define na_%-30s %30s\n",
  16249. + ($module_name . "_irq", $result));
  16250. + $text_printed = 1;
  16251. + }
  16252. +
  16253. + } else {
  16254. + # if device has multiple ports
  16255. + foreach my $port_name (@module_ports) {
  16256. + # base address information
  16257. + $result = $module->getBaseAddress ($port_name);
  16258. + if ($result) {
  16259. + $output .= sprintf ("#define na_%-50s %#010x\n",
  16260. + ($module_name . "_" . $port_name, hex ($result) | $mask));
  16261. + $text_printed = 1;
  16262. + }
  16263. +
  16264. + # irq information
  16265. + $result = $module->getIRQ ($port_name);
  16266. + if (defined ($result)) {
  16267. + $output .= sprintf ("#define na_%-30s %30s\n",
  16268. + ($module_name . "_" . $port_name . "_irq", $result));
  16269. + $text_printed = 1;
  16270. + }
  16271. + }
  16272. + }
  16273. +
  16274. + if ($text_printed == 1) {
  16275. + # $output .= "\n";
  16276. + print $output;
  16277. + }
  16278. +}
  16279. +
  16280. +print "\n";
  16281. +
  16282. +#
  16283. +# Handle special cases through customized perl scripts
  16284. +#
  16285. +foreach my $class_name (@found_classes_order) {
  16286. + my $code = "";
  16287. +
  16288. + foreach my $dir (@INC) {
  16289. + if (-e "$dir/nios2_system.h/$class_name.pm") {
  16290. + print "/* Executing ...scripts/nios2_system.h/$class_name.pm */\n";
  16291. + $code .= "require \"$dir/nios2_system.h/BasicModule.pm\";";
  16292. + $code .= "require \"$dir/nios2_system.h/$class_name.pm\";";
  16293. + $code .= $class_name . "::run(\$system, \@{\$found_classes{\$class_name}});";
  16294. + eval $code;
  16295. + if ($@) {
  16296. + print "#warning Could not execute ...scripts/nios2_system.h/$class_name.pm\n";
  16297. + print "#warning Error message is stored in nios2_system.h:\n";
  16298. + print "/*\n";
  16299. + print "$@";
  16300. + print "*/\n";
  16301. + print STDERR "Could not execute ...scripts/nios2_system.h/$class_name.pm\n";
  16302. + print STDERR "Error message follows:\n";
  16303. + print STDERR "$@";
  16304. + }
  16305. + last;
  16306. + }
  16307. + }
  16308. +}
  16309. +
  16310. +#
  16311. +# Write out system information
  16312. +#
  16313. +print "/*\n";
  16314. +print " * Basic System Information\n";
  16315. +print " */\n";
  16316. +
  16317. +$result = $cpu->getWSAAssignment ('cache_icache_size');
  16318. +printf ("#define %-53s %10d\n", ("nasys_icache_size", $result));
  16319. +
  16320. +$result = $cpu->getConstant ('nasys_icache_line_size');
  16321. +printf ("#define %-53s %10d\n", ("nasys_icache_line_size", $result));
  16322. +
  16323. +$result = $cpu->getWSAAssignment ('cache_dcache_size');
  16324. +printf ("#define %-53s %10d\n", ("nasys_dcache_size", $result));
  16325. +
  16326. +$result = $cpu->getConstant ('nasys_dcache_line_size');
  16327. +printf ("#define %-53s %10d\n", ("nasys_dcache_line_size", $result));
  16328. +
  16329. +print "\n";
  16330. +
  16331. +printf ("#define %-33s %30s\n",
  16332. + ("nasys_program_mem", "na_${exec_location}"));
  16333. +printf ("#define %-33s %30s\n",
  16334. + ("nasys_program_mem_size", "na_${exec_location}_size"));
  16335. +printf ("#define %-33s %30s\n",
  16336. + ("nasys_program_mem_end", "na_${exec_location}_end"));
  16337. +
  16338. +print "\n";
  16339. +
  16340. +if ($upload_location eq "flash_kernel") {
  16341. + # nothing to do
  16342. + print ("/* Redefinition of CFI flash memory unecessary */\n");
  16343. +} else {
  16344. + my $module = $system->getModule ("flash_kernel");
  16345. + if ($module) {
  16346. + # there is a conflicting module in the system, error.
  16347. + print STDERR "Error, a SOPC module named flash_kernel already exists but is not the upload location.\n";
  16348. + print "#error The module name \"flash_kernel\" already exists but isn't the upload location.\n";
  16349. + print "#error This will break the kernel.\n";
  16350. + print "#error Please rename the module to something else in SOPC Builder.\n\n";
  16351. + exit 1;
  16352. + } else {
  16353. + print ("/*\n");
  16354. + print (" * Redefining upload location ($upload_location) to flash_kernel.\n");
  16355. + print (" */\n\n");
  16356. + # undefine the original module names and re-define them here.
  16357. + print ("#undef na_${upload_location}\n");
  16358. + print ("#undef na_${upload_location}_size\n");
  16359. + print ("#undef na_${upload_location}_end\n");
  16360. +
  16361. + my $base_address = $upload_module->getBaseAddress ();
  16362. + printf ("#define %-33s %30s\n",
  16363. + ("na_flash_kernel", $base_address));
  16364. +
  16365. + my $mem_size = $upload_module->getSize();
  16366. + printf ("#define %-33s %30s\n",
  16367. + ("na_flash_kernel_size", $mem_size));
  16368. +
  16369. + my $mem_end = hex ($base_address) + hex ($mem_size);
  16370. + printf ("#define %-53s %#010x\n",
  16371. + ("na_flash_kernel_end", $mem_end));
  16372. + }
  16373. +}
  16374. +
  16375. +print "\n";
  16376. +
  16377. +printf ("#define %-33s %30s\n",
  16378. + ("nasys_clock_freq", $system->getClockFreq()));
  16379. +printf ("#define %-33s %30s\n",
  16380. + ("nasys_clock_freq_1000", int ($system->getClockFreq()) / 1000));
  16381. +
  16382. +{
  16383. + my ($reset_location, $reset_offset) = $cpu->getResetLocationOffset();
  16384. + my ($reset_module_name, $reset_port_name) = ($reset_location =~ /(.*)\/(.*)/);
  16385. + my $reset_module = $system->getModule ($reset_module_name);
  16386. + my $reset_address = $reset_module->getBaseAddress ($reset_port_name);
  16387. +
  16388. + $reset_address = hex ($reset_address) + hex ($reset_offset);
  16389. + printf ("#define %-53s %#010x\n",
  16390. + ("CPU_RESET_ADDRESS", $reset_address));
  16391. +}
  16392. +
  16393. +print "\n";
  16394. +
  16395. +#
  16396. +# print footer for nios2_system.h
  16397. +#
  16398. +print <<ENDOFFOOTER;
  16399. +#endif /* __NIOS2_SYSTEM_H__ */
  16400. +ENDOFFOOTER
  16401. diff --git a/arch/nios2nommu/scripts/hwselect.pl b/arch/nios2nommu/scripts/hwselect.pl
  16402. new file mode 100644
  16403. index 0000000..8181bee
  16404. --- /dev/null
  16405. +++ b/arch/nios2nommu/scripts/hwselect.pl
  16406. @@ -0,0 +1,166 @@
  16407. +# This script generates arch/nios2nommu/hardware.mk based on user input
  16408. +
  16409. +# usage:
  16410. +#
  16411. +# [SOPC Builder]$ perl hwselect.pl <ptf file path> <target file path>
  16412. +#
  16413. +
  16414. +use PTF::SystemPTF;
  16415. +use strict;
  16416. +use integer;
  16417. +
  16418. +my $ptf_filename;
  16419. +my $target_filename;
  16420. +my $index;
  16421. +my $system;
  16422. +
  16423. +#
  16424. +# Subroutine: Prompt user for an answer
  16425. +#
  16426. +
  16427. +sub request_answer {
  16428. + my ($min, $max) = @_;
  16429. + my $answer;
  16430. +
  16431. + do {
  16432. + print "Selection: ";
  16433. + $answer = <STDIN>;
  16434. + if (! ($answer >= $min && $answer <= $max)) {
  16435. + print "Invalid response, please try again.\n";
  16436. + }
  16437. + } until $answer >= $min && $answer <= $max;
  16438. +
  16439. + return $answer;
  16440. +}
  16441. +
  16442. +#
  16443. +# Check for correct number of args
  16444. +#
  16445. +
  16446. +if (scalar (@ARGV) != 2) {
  16447. + print STDERR "ERROR: Invalid number of parameters.\n";
  16448. + exit;
  16449. +} else {
  16450. + $ptf_filename = $ARGV[0];
  16451. + $target_filename = $ARGV[1];
  16452. +}
  16453. +
  16454. +#
  16455. +# Check to see if the specified file exists
  16456. +#
  16457. +
  16458. +if (! -e $ptf_filename) {
  16459. + print STDERR "ERROR: Could not open SYSTEM ptf file.\n";
  16460. + exit;
  16461. +}
  16462. +
  16463. +#
  16464. +# startup the parser.
  16465. +#
  16466. +$system = SystemPTF->new (filename => $ptf_filename);
  16467. +if (!$system) {
  16468. + print STDERR "ERROR: Specified file is not a SYSTEM ptf file.\n";
  16469. + exit;
  16470. +}
  16471. +
  16472. +#
  16473. +# Grab listing of Nios II processors and force user to select one:
  16474. +#
  16475. +
  16476. +print "\n--- Please select which CPU you wish to build the kernel against:\n\n";
  16477. +
  16478. +my @cpulist = $system->getCPUList ('altera_nios2');
  16479. +my %cpuinfo;
  16480. +
  16481. +$index = 1;
  16482. +foreach my $cpu (@cpulist) {
  16483. + my $cpu_module = $system->getCPU ($cpu);
  16484. + if ($cpu_module->isEnabled ()) {
  16485. + my $class = $cpu_module->getClass();
  16486. + my $type = $cpu_module->getWSAAssignment('cpu_selection');
  16487. + my $version = $cpu_module->getVersion();
  16488. +
  16489. + print "($index) $cpu - Class: $class Type: $type Version: $version\n";
  16490. + }
  16491. + $index += 1;
  16492. +}
  16493. +
  16494. +print "\n";
  16495. +
  16496. +my $cpu_selection = $cpulist[request_answer (1, $index - 1) - 1];
  16497. +
  16498. +#
  16499. +# Grab list of memory devices that $cpu_selection is hooked up to:
  16500. +#
  16501. +my @modulelist = $system->getSlaveModules ($cpu_selection);
  16502. +my %cfiinfo;
  16503. +my %meminfo;
  16504. +foreach my $module_name (@modulelist) {
  16505. + my $module = $system->getModule ($module_name);
  16506. + my $class = $module->getClass ();
  16507. +
  16508. + if ($module->isEnabled ()) {
  16509. + if ($class eq 'altera_avalon_cfi_flash') {
  16510. + $cfiinfo{$module_name}{class} = $class;
  16511. + $cfiinfo{$module_name}{size} = $module->getSize();
  16512. + }
  16513. +
  16514. + if ($module->isMemoryDevice()) {
  16515. + $meminfo{$module_name}{class} = $class;
  16516. + $meminfo{$module_name}{size} = $module->getSize();
  16517. + }
  16518. + }
  16519. +}
  16520. +
  16521. +#
  16522. +# Select an upload device:
  16523. +#
  16524. +print "\n--- Please select a device to upload the kernel to:\n\n";
  16525. +
  16526. +$index = 1;
  16527. +foreach my $name (keys (%cfiinfo)) {
  16528. + my $size = hex ($cfiinfo{$name}{size});
  16529. + print "($index) $name\n\tClass: $cfiinfo{$name}{class}\n\tSize: $size bytes\n\n";
  16530. + $index += 1;
  16531. +}
  16532. +
  16533. +my @cfilist = keys (%cfiinfo);
  16534. +my $cfi_selected = $cfilist[request_answer (1, $index - 1) - 1];
  16535. +
  16536. +delete $meminfo{$cfi_selected};
  16537. +
  16538. +#
  16539. +# Select program memory to execute kernel from:
  16540. +#
  16541. +print "\n--- Please select a device to execute kernel from:\n\n";
  16542. +
  16543. +$index = 1;
  16544. +foreach my $name (keys (%meminfo)) {
  16545. + my $size = hex ($meminfo{$name}{size});
  16546. + print "($index) $name\n\tClass: $meminfo{$name}{class}\n\tSize: $size bytes\n\n";
  16547. + $index += 1;
  16548. +}
  16549. +
  16550. +my @memlist = keys (%meminfo);
  16551. +my $mem_selected = $memlist[request_answer (1, $index - 1) - 1];
  16552. +
  16553. +print "\n--- Summary using\n\n";
  16554. +print "PTF: $ptf_filename\n";
  16555. +print "CPU: $cpu_selection\n";
  16556. +print "Device to upload to: $cfi_selected\n";
  16557. +print "Program memory to execute from: $mem_selected\n";
  16558. +
  16559. +#
  16560. +# Write settings out to Makefile fragment
  16561. +#
  16562. +open (HWMK, ">$target_filename") ||
  16563. + die "Could not write to $target_filename";
  16564. +
  16565. +print HWMK "SYSPTF = $ptf_filename\n";
  16566. +print HWMK "CPU = $cpu_selection\n";
  16567. +print HWMK "UPLMEM = $cfi_selected\n";
  16568. +print HWMK "EXEMEM = $mem_selected\n";
  16569. +
  16570. +close (HWMK);
  16571. +
  16572. +print "\n--- Settings written to $target_filename\n\n";
  16573. \ No newline at end of file
  16574. diff --git a/arch/nios2nommu/scripts/nios2_system.h/BasicModule.pm b/arch/nios2nommu/scripts/nios2_system.h/BasicModule.pm
  16575. new file mode 100644
  16576. index 0000000..e15c26b
  16577. --- /dev/null
  16578. +++ b/arch/nios2nommu/scripts/nios2_system.h/BasicModule.pm
  16579. @@ -0,0 +1,267 @@
  16580. +package BasicModule;
  16581. +
  16582. +require PTF::SystemPTF;
  16583. +require PTF::SystemPTF::Module;
  16584. +use strict;
  16585. +
  16586. +# Description: Prints an error message to stdout. This should prefix each line
  16587. +# with "#error " so that it can be properly read by the C
  16588. +# pre-processor.
  16589. +# Args: $module_name: name of module that was is required by driver
  16590. +# $class_name: name of device class that module belongs to.
  16591. +sub print_error_name_used {
  16592. + my ($class, $module_name, $class_name) = @_;
  16593. +
  16594. + print "#error The kernel requires that the $class->required_class_name device be named as $module_name.\n";
  16595. + print "#error The current hardware has $module_name defined as a(n) $class_name device.\n";
  16596. + print "#error This will cause the kernel to fail.\n";
  16597. + print "#error Please rename the current $module_name device to something else in SOPC Builder.\n";
  16598. +}
  16599. +
  16600. +# Description: This casts the base address to a specific data type
  16601. +# By default, it does not cast the base address to
  16602. +# anything.
  16603. +sub base_address_cast {
  16604. + my ($class, $port_name) = @_;
  16605. + return;
  16606. +}
  16607. +
  16608. +# Description: This sub-routine prints out a prefix that is shown only once
  16609. +# before any translations take place.
  16610. +sub print_prefix {
  16611. + my ($class, $system) = @_;
  16612. + printf ("\n");
  16613. +}
  16614. +
  16615. +# Description: Prints a set of lines to stdout that re-defines all symbols
  16616. +# related to $module_name to the symbols required by the driver.
  16617. +# Typically starts off with "#undefine ..." statements followed
  16618. +# by one or more "#define statements".
  16619. +# Args: $required_module_name: the module name that's expected by the kernel.
  16620. +# $module_name: the name of the module that was found in the PTF file.
  16621. +sub translate {
  16622. + my ($class, $system, $required_module_name, $module_name) = @_;
  16623. +
  16624. + # get the necessary info about the module
  16625. + my $module = $system->getModule ($module_name);
  16626. + my @port_names = $module->getPorts ();
  16627. +
  16628. + my $boolean_base_address_cast = 0;
  16629. + if (scalar (@port_names) > 1) {
  16630. + foreach my $port_name (@port_names) {
  16631. + my $cast = $class->base_address_cast ($port_name);
  16632. + if (defined ($cast)) {
  16633. + $boolean_base_address_cast = 1;
  16634. + last;
  16635. + }
  16636. + }
  16637. + } else {
  16638. + my $cast = $class->base_address_cast;
  16639. + if (defined ($cast)) {
  16640. + $boolean_base_address_cast = 1;
  16641. + }
  16642. + }
  16643. +
  16644. + if ($module_name eq $required_module_name &&
  16645. + !$boolean_base_address_cast) {
  16646. + printf ("/* No translation necessary for $module_name */\n\n");
  16647. + return;
  16648. + }
  16649. +
  16650. + # undefine the original entries
  16651. + print "/* Redefining $module_name -> $required_module_name */\n";
  16652. + if (scalar (@port_names) == 1) {
  16653. + my $irq = $module->getIRQ ();
  16654. + print "#undef na_" . $module_name . "\n";
  16655. + if (defined ($irq)) {
  16656. + print "#undef na_" . $module_name . "_irq\n";
  16657. + }
  16658. + print "\n";
  16659. + } else {
  16660. + foreach my $port_name (@port_names) {
  16661. + print "#undef na_" . $module_name . "_" .
  16662. + $port_name . "\n";
  16663. + my $irq = $module->getIRQ ($port_name);
  16664. + if (defined ($irq)) {
  16665. + print "#undef na_" . $module_name . "_" .
  16666. + $port_name . "_irq\n";
  16667. + }
  16668. + print "\n";
  16669. + }
  16670. + }
  16671. +
  16672. + if (scalar (@port_names) == 1) {
  16673. + # set up a string to pass to printf that will output the correct
  16674. + # #define base address statement.
  16675. +
  16676. + # turn on the high bit for the base address to bypass cache.
  16677. + my $base_address = $module->getBaseAddress ();
  16678. + $base_address = hex ($base_address) | 0x80000000;
  16679. +
  16680. + my $cast = $class->base_address_cast;
  16681. + $class->print_define_line ($required_module_name,
  16682. + undef, "addr", $cast, $base_address);
  16683. +
  16684. + # print out an IRQ define statement if necessary
  16685. + my $irq = $module->getIRQ ();
  16686. + if (defined ($irq)) {
  16687. + $class->print_define_line ($required_module_name,
  16688. + undef, "irq", undef, $irq);
  16689. + }
  16690. + printf ("\n");
  16691. + } else {
  16692. + foreach my $port_name (@port_names) {
  16693. + my $cast = $class->base_address_cast ($port_name);
  16694. + my $base_address = $module->getBaseAddress ($port_name);
  16695. + $base_address = hex ($base_address) | 0x80000000;
  16696. + $class->print_define_line ($required_module_name,
  16697. + $port_name, "addr", $cast, $base_address);
  16698. +
  16699. + my $irq = $module->getIRQ ($port_name);
  16700. + if (defined ($irq)) {
  16701. + $class->print_define_line (
  16702. + $required_module_name, $port_name,
  16703. + "irq", undef, $irq);
  16704. + }
  16705. +
  16706. + print "\n";
  16707. + }
  16708. + }
  16709. +}
  16710. +
  16711. +# Description: The following sub-routine prints out "undef" or "define"
  16712. +# statements based on the arguments received.
  16713. +# Args: $name: "define" or "undef"
  16714. +# $port: name of port (if applicable)
  16715. +# $type: "addr" or "irq"
  16716. +# $cast: data type to cast base address to (if applicable)
  16717. +# $value: value of symbol to be defined (if applicable)
  16718. +sub print_define_line {
  16719. + my ($class, $name, $port, $type, $cast, $value) = @_;
  16720. +
  16721. + # construct the symbol that is being used
  16722. + my $symbol .= "na_";
  16723. + $symbol .= $name;
  16724. +
  16725. + $symbol .= defined ($port) ? "_" . $port : "";
  16726. + $symbol .= $type eq "irq" ? "_irq" : "";
  16727. +
  16728. + my $string_value;
  16729. + if ($type eq "addr") {
  16730. + $string_value = sprintf ("%#010x", $value);
  16731. + if (defined $cast) {
  16732. + $string_value = "(($cast*) $string_value)";
  16733. + }
  16734. + } else {
  16735. + $string_value = $value;
  16736. + }
  16737. + printf ("%-41s %30s\n", "#define $symbol", $string_value);
  16738. +}
  16739. +
  16740. +# Description: This sub-routine prints out a prefix that is shown only once
  16741. +# after any translations take place.
  16742. +sub print_suffix {
  16743. + my ($class, $system) = @_;
  16744. + # intentionally left empty
  16745. +}
  16746. +
  16747. +# Description: The following function allows the class to further determine if
  16748. +# the module is valid. For instance, the timer class requires
  16749. +# that the selected module does not have a fixed period.
  16750. +# This function returns true by default which basically means
  16751. +# that all modules belonging to class are valid.
  16752. +sub is_module_valid {
  16753. + my ($class, $system, $module_name) = @_;
  16754. + return 1;
  16755. +}
  16756. +
  16757. +# Description: This sub-routine is required. It is executed by the
  16758. +# "../gen_nios2_system_h.pl" script whenever any devices of type
  16759. +# $class->required_class_name are found in the PTF file.
  16760. +#
  16761. +# It looks for any conflicting module names first. If any are
  16762. +# found, "print_error_name_used" is called and this perl module
  16763. +# exits.
  16764. +#
  16765. +# It then goes through the list of module names found in the PTF
  16766. +# file that are of type $class->required_class_name and maps them to the
  16767. +# list of unused names in $class->required_module_names.
  16768. +#
  16769. +# Finally, it will call the "translate" sub-routine to output the
  16770. +# symbols required by the driver.
  16771. +# Args: $system: a variable containing a reference to the system.ptf file that
  16772. +# provides full access to any information in the file.
  16773. +# @found_module_names: a list of module names that are of type
  16774. +# $class->required_class_name
  16775. +sub run2 {
  16776. + my ($class, $system, @found_module_names) = @_;
  16777. +
  16778. + # initialize a mapping of required module names to actual module names
  16779. + my %module_map;
  16780. + foreach my $module_name ($class->required_module_names) {
  16781. + $module_map{$module_name} = "";
  16782. + }
  16783. +
  16784. + # if the required module name is already in use in the PTF file for a
  16785. + # different device class, flag it as an error.
  16786. + my $error_found = 0;
  16787. + foreach my $module_name ($class->required_module_names) {
  16788. + my $module = $system->getModule ($module_name);
  16789. +
  16790. + if (!defined ($module)) {
  16791. + next;
  16792. + }
  16793. +
  16794. + my $class_name = $module->getClass ();
  16795. + if ($class_name ne $class->required_class_name) {
  16796. + $class->print_error_name_used ($class, $module_name, $class_name);
  16797. + $error_found = 1;
  16798. + }
  16799. + }
  16800. +
  16801. + # if errors were found, then there's no point in continuing.
  16802. + if ($error_found == 1) {
  16803. + return;
  16804. + }
  16805. +
  16806. + # Run through list of modules that belong to the class and start
  16807. + # mapping each module name to the first unused required module name
  16808. + # as defined above
  16809. + FOUND_MOD_LOOP: foreach my $module_name (@found_module_names) {
  16810. +
  16811. + # If the module name has already been used, then continue
  16812. + # to the next one.
  16813. + foreach my $required_module_name ($class->required_module_names) {
  16814. + if ($module_map{$required_module_name} eq $module_name) {
  16815. + next FOUND_MOD_LOOP;
  16816. + }
  16817. + }
  16818. +
  16819. + # assertion: $module_name is not mapped yet.
  16820. + foreach my $required_module_name ($class->required_module_names) {
  16821. + if ($module_map{$required_module_name} ne "") {
  16822. + next;
  16823. + }
  16824. +
  16825. + if ($class->is_module_valid ($system, $module_name)) {
  16826. + $module_map{$required_module_name} = $module_name;
  16827. + }
  16828. + last;
  16829. + }
  16830. + }
  16831. +
  16832. + $class->print_prefix ($system);
  16833. +
  16834. + # Now that everything's been mapped (or as close as we're going to get
  16835. + # to it being mapped), start printing out the literal translation.
  16836. + foreach my $required_module_name ($class->required_module_names) {
  16837. + my $module_name = $module_map{$required_module_name};
  16838. + if (length ($module_name) > 0) {
  16839. + $class->translate ($system, $required_module_name, $module_name);
  16840. + }
  16841. + }
  16842. +
  16843. + $class->print_suffix ($system);
  16844. +}
  16845. +
  16846. +1;
  16847. diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_cf.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_cf.pm
  16848. new file mode 100644
  16849. index 0000000..dada452
  16850. --- /dev/null
  16851. +++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_cf.pm
  16852. @@ -0,0 +1,18 @@
  16853. +package altera_avalon_cf;
  16854. +
  16855. +use base qw(BasicModule);
  16856. +use strict;
  16857. +
  16858. +sub required_module_names {
  16859. + "ide"
  16860. +}
  16861. +
  16862. +sub required_class_name {
  16863. + "altera_avalon_cf"
  16864. +}
  16865. +
  16866. +sub run {
  16867. + altera_avalon_cf->run2(@_);
  16868. +}
  16869. +
  16870. +1;
  16871. diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_jtag_uart.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_jtag_uart.pm
  16872. new file mode 100644
  16873. index 0000000..22bb9c9
  16874. --- /dev/null
  16875. +++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_jtag_uart.pm
  16876. @@ -0,0 +1,18 @@
  16877. +package altera_avalon_jtag_uart;
  16878. +
  16879. +use base qw(BasicModule);
  16880. +use strict;
  16881. +
  16882. +sub required_module_names {
  16883. + ("jtag_uart")
  16884. +}
  16885. +
  16886. +sub required_class_name {
  16887. + "altera_avalon_jtag_uart";
  16888. +}
  16889. +
  16890. +sub run {
  16891. + altera_avalon_jtag_uart->run2 (@_);
  16892. +}
  16893. +
  16894. +1;
  16895. diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_lan91c111.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_lan91c111.pm
  16896. new file mode 100644
  16897. index 0000000..5a29b7e
  16898. --- /dev/null
  16899. +++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_lan91c111.pm
  16900. @@ -0,0 +1,38 @@
  16901. +package altera_avalon_lan91c111;
  16902. +
  16903. +require PTF::SystemPTF;
  16904. +require PTF::SystemPTF::Module;
  16905. +use base qw(BasicModule);
  16906. +use strict;
  16907. +
  16908. +sub required_module_names {
  16909. + "enet"
  16910. +}
  16911. +
  16912. +sub required_class_name {
  16913. + "altera_avalon_lan91c111"
  16914. +}
  16915. +
  16916. +sub translate {
  16917. + my $class = shift;
  16918. + my ($system, $required_module_name, $module_name) = @_;
  16919. + $class->SUPER::translate (@_);
  16920. +
  16921. + my $module = $system->getModule ($module_name);
  16922. +
  16923. + my $offset_keyword = "LAN91C111_REGISTERS_OFFSET";
  16924. + my $offset = $module->getWSAConstant ($offset_keyword);
  16925. + printf ("%-41s %30s\n", "#define $offset_keyword", $offset);
  16926. +
  16927. + my $width_keyword = "LAN91C111_DATA_BUS_WIDTH";
  16928. + my $width = $module->getWSAConstant ($width_keyword);
  16929. + printf ("%-41s %30s\n", "#define $width_keyword", $width);
  16930. +
  16931. + print "\n";
  16932. +}
  16933. +
  16934. +sub run {
  16935. + altera_avalon_lan91c111->run2 (@_);
  16936. +}
  16937. +
  16938. +1;
  16939. diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_pio.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_pio.pm
  16940. new file mode 100644
  16941. index 0000000..afdbcae
  16942. --- /dev/null
  16943. +++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_pio.pm
  16944. @@ -0,0 +1,46 @@
  16945. +package altera_avalon_pio;
  16946. +
  16947. +require PTF::SystemPTF;
  16948. +require PTF::SystemPTF::Module;
  16949. +use strict;
  16950. +
  16951. +sub run {
  16952. + my ($system, @pio_names) = @_;
  16953. +
  16954. + print "#ifndef __ASSEMBLY__\n";
  16955. + print "#include <asm/pio_struct.h>\n";
  16956. + print "#endif\n\n";
  16957. +
  16958. + foreach my $pio_name (@pio_names) {
  16959. + my $module = $system->getModule ($pio_name);
  16960. +
  16961. + # get all the relevant information
  16962. + my $base_address = $module->getBaseAddress ();
  16963. + $base_address = hex ($base_address) | 0x80000000;
  16964. + my $irq = $module->getIRQ ();
  16965. +
  16966. + print "/* Casting base addresses to the appropriate structure */\n";
  16967. +
  16968. + # undefine all the old symbols first
  16969. + print "#undef na_${pio_name}\n";
  16970. + if (defined ($irq)) {
  16971. + print "#undef na_${pio_name}_irq\n";
  16972. + print "\n";
  16973. + }
  16974. +
  16975. + # define base address
  16976. + $base_address = sprintf ("%#010x", $base_address);
  16977. + printf ("%-41s %30s\n", "#define na_${pio_name}",
  16978. + "((np_pio*) ${base_address})");
  16979. +
  16980. + # define irq
  16981. + if (defined ($irq)) {
  16982. + printf ("%-41s %30s\n", "#define na_${pio_name}_irq",
  16983. + $irq);
  16984. + }
  16985. +
  16986. + print "\n";
  16987. + }
  16988. +}
  16989. +
  16990. +1;
  16991. diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_spi.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_spi.pm
  16992. new file mode 100644
  16993. index 0000000..719a22c
  16994. --- /dev/null
  16995. +++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_spi.pm
  16996. @@ -0,0 +1,30 @@
  16997. +package altera_avalon_spi;
  16998. +
  16999. +use base qw(BasicModule);
  17000. +use strict;
  17001. +
  17002. +sub required_module_names {
  17003. + "spi"
  17004. +}
  17005. +
  17006. +sub required_class_name {
  17007. + "altera_avalon_spi"
  17008. +}
  17009. +
  17010. +sub base_address_cast {
  17011. + "np_spi"
  17012. +}
  17013. +
  17014. +sub print_prefix {
  17015. + my ($class, $system) = @_;
  17016. +
  17017. + print "#ifndef __ASSEMBLY__\n";
  17018. + print "#include <asm/spi_struct.h>\n";
  17019. + print "#endif\n\n";
  17020. +}
  17021. +
  17022. +sub run {
  17023. + altera_avalon_spi->run2 (@_);
  17024. +}
  17025. +
  17026. +1;
  17027. diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_sysid.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_sysid.pm
  17028. new file mode 100644
  17029. index 0000000..deb9826
  17030. --- /dev/null
  17031. +++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_sysid.pm
  17032. @@ -0,0 +1,18 @@
  17033. +package altera_avalon_sysid;
  17034. +
  17035. +use base qw(BasicModule);
  17036. +use strict;
  17037. +
  17038. +sub required_class_name {
  17039. + "altera_avalon_sysid"
  17040. +}
  17041. +
  17042. +sub required_module_names {
  17043. + "sysid"
  17044. +}
  17045. +
  17046. +sub run {
  17047. + altera_avalon_sysid->run2 (@_);
  17048. +}
  17049. +
  17050. +1;
  17051. diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm
  17052. new file mode 100644
  17053. index 0000000..495ccdc
  17054. --- /dev/null
  17055. +++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_timer.pm
  17056. @@ -0,0 +1,46 @@
  17057. +package altera_avalon_timer;
  17058. +
  17059. +use base qw(BasicModule);
  17060. +use strict;
  17061. +
  17062. +sub required_class_name {
  17063. + "altera_avalon_timer";
  17064. +}
  17065. +
  17066. +sub required_module_names {
  17067. + "timer0"
  17068. +}
  17069. +
  17070. +sub print_prefix {
  17071. + my ($class, $system) = @_;
  17072. +
  17073. + print "\n";
  17074. + print "#ifndef __ASSEMBLY__\n";
  17075. + print "#include <asm/timer_struct.h>\n";
  17076. + print "#endif\n";
  17077. + print "\n";
  17078. +}
  17079. +
  17080. +sub base_address_cast {
  17081. + "np_timer"
  17082. +}
  17083. +
  17084. +# only timers with a non-fixed-period are valid
  17085. +sub is_module_valid {
  17086. + my ($class, $system, $module_name) = @_;
  17087. +
  17088. + my $module = $system->getModule ($module_name);
  17089. + my $fixed_period = $module->getWSAAssignment ('fixed_period');
  17090. +
  17091. + if ($fixed_period eq '0') {
  17092. + return 1;
  17093. + } else {
  17094. + return 0;
  17095. + }
  17096. +}
  17097. +
  17098. +sub run {
  17099. + altera_avalon_timer->run2 (@_);
  17100. +}
  17101. +
  17102. +1;
  17103. diff --git a/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_uart.pm b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_uart.pm
  17104. new file mode 100644
  17105. index 0000000..abf48d7
  17106. --- /dev/null
  17107. +++ b/arch/nios2nommu/scripts/nios2_system.h/altera_avalon_uart.pm
  17108. @@ -0,0 +1,44 @@
  17109. +package altera_avalon_uart;
  17110. +
  17111. +use base qw(BasicModule);
  17112. +use strict;
  17113. +
  17114. +sub required_module_names {
  17115. + ("uart0", "uart1", "uart2", "uart3")
  17116. +}
  17117. +
  17118. +sub required_class_name {
  17119. + "altera_avalon_uart";
  17120. +}
  17121. +
  17122. +sub base_address_cast {
  17123. + "np_uart"
  17124. +}
  17125. +
  17126. +sub print_prefix {
  17127. + my ($class, $system) = @_;
  17128. +
  17129. + print "#ifndef __ASSEMBLY__\n";
  17130. + print "#include <asm/uart_struct.h>\n";
  17131. + print "#endif\n\n";
  17132. +}
  17133. +
  17134. +sub translate {
  17135. + my $class = shift;
  17136. + my ($system, $required_module_name, $module_name) = @_;
  17137. +
  17138. + $class->SUPER::translate (@_);
  17139. +
  17140. + if (!defined ($altera_avalon_uart::default_uart)) {
  17141. + print "/* The default uart is always the first one found in the PTF file */\n";
  17142. + print "#define nasys_printf_uart na_$required_module_name\n\n";
  17143. + $altera_avalon_uart::default_uart = $required_module_name;
  17144. + }
  17145. +
  17146. +}
  17147. +
  17148. +sub run {
  17149. + altera_avalon_uart->run2 (@_);
  17150. +}
  17151. +
  17152. +1;
  17153. diff --git a/arch/nios2nommu/scripts/nios2_system.h/mtip_avalon_10_100_mac.pm b/arch/nios2nommu/scripts/nios2_system.h/mtip_avalon_10_100_mac.pm
  17154. new file mode 100644
  17155. index 0000000..fdd727b
  17156. --- /dev/null
  17157. +++ b/arch/nios2nommu/scripts/nios2_system.h/mtip_avalon_10_100_mac.pm
  17158. @@ -0,0 +1,18 @@
  17159. +package mtip_avalon_10_100_mac;
  17160. +
  17161. +use base qw(BasicModule);
  17162. +use strict;
  17163. +
  17164. +sub required_class_name {
  17165. + "mtip_avalon_10_100_mac";
  17166. +}
  17167. +
  17168. +sub required_module_names {
  17169. + "mtip_mac"
  17170. +}
  17171. +
  17172. +sub run {
  17173. + mtip_avalon_10_100_mac->run2 (@_);
  17174. +}
  17175. +
  17176. +1;
  17177. diff --git a/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_dm9000.pm b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_dm9000.pm
  17178. new file mode 100644
  17179. index 0000000..5985c2f
  17180. --- /dev/null
  17181. +++ b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_dm9000.pm
  17182. @@ -0,0 +1,18 @@
  17183. +package mtx_avalon_dm9000;
  17184. +
  17185. +use base qw(BasicModule);
  17186. +use strict;
  17187. +
  17188. +sub required_module_names {
  17189. + "dm9000"
  17190. +}
  17191. +
  17192. +sub required_class_name {
  17193. + "mtx_avalon_dm9000"
  17194. +}
  17195. +
  17196. +sub run {
  17197. + mtx_avalon_dm9000->run2(@_);
  17198. +}
  17199. +
  17200. +1;
  17201. diff --git a/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_isp1161a1.pm b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_isp1161a1.pm
  17202. new file mode 100644
  17203. index 0000000..e70ffa3
  17204. --- /dev/null
  17205. +++ b/arch/nios2nommu/scripts/nios2_system.h/mtx_avalon_isp1161a1.pm
  17206. @@ -0,0 +1,18 @@
  17207. +package mtx_avalon_isp1161a1;
  17208. +
  17209. +use base qw(BasicModule);
  17210. +use strict;
  17211. +
  17212. +sub required_module_names {
  17213. + "usb"
  17214. +}
  17215. +
  17216. +sub required_class_name {
  17217. + "mtx_avalon_isp1161a1";
  17218. +}
  17219. +
  17220. +sub run {
  17221. + mtx_avalon_isp1161a1->run2(@_);
  17222. +}
  17223. +
  17224. +1;
  17225. diff --git a/arch/nios2nommu/scripts/nios2_system.h/opencores_ethernet_mac.pm b/arch/nios2nommu/scripts/nios2_system.h/opencores_ethernet_mac.pm
  17226. new file mode 100644
  17227. index 0000000..7b580b5
  17228. --- /dev/null
  17229. +++ b/arch/nios2nommu/scripts/nios2_system.h/opencores_ethernet_mac.pm
  17230. @@ -0,0 +1,18 @@
  17231. +package opencores_ethernet_mac;
  17232. +
  17233. +use base qw(BasicModule);
  17234. +use strict;
  17235. +
  17236. +sub required_module_names {
  17237. + "igor_mac"
  17238. +}
  17239. +
  17240. +sub required_class_name {
  17241. + "opencores_ethernet_mac"
  17242. +}
  17243. +
  17244. +sub run {
  17245. + opencores_ethernet_mac->run2 (@_);
  17246. +}
  17247. +
  17248. +1;
  17249. diff --git a/arch/nios2nommu/scripts/nios2_system.h/opencores_i2c.pm b/arch/nios2nommu/scripts/nios2_system.h/opencores_i2c.pm
  17250. new file mode 100644
  17251. index 0000000..512d12c
  17252. --- /dev/null
  17253. +++ b/arch/nios2nommu/scripts/nios2_system.h/opencores_i2c.pm
  17254. @@ -0,0 +1,18 @@
  17255. +package opencores_i2c;
  17256. +
  17257. +use base qw(BasicModule);
  17258. +use strict;
  17259. +
  17260. +sub required_module_names {
  17261. + ("i2c_0", "i2c_1")
  17262. +}
  17263. +
  17264. +sub required_class_name {
  17265. + "opencores_i2c";
  17266. +}
  17267. +
  17268. +sub run {
  17269. + opencores_i2c->run2 (@_);
  17270. +}
  17271. +
  17272. +1;
  17273. diff --git a/include/asm-nios2nommu/ChangeLog b/include/asm-nios2nommu/ChangeLog
  17274. new file mode 100644
  17275. index 0000000..94aaa27
  17276. --- /dev/null
  17277. +++ b/include/asm-nios2nommu/ChangeLog
  17278. @@ -0,0 +1,14 @@
  17279. +2004-06-29 Ken Hill <khill@microtronix.com>
  17280. +
  17281. + * bitops.h (find_next_zero_bit): Fix problem with with masking for found_first
  17282. + handling. The masking of the upper bits for size < 32 bits would set all
  17283. + the bits to 1. Removing any zero's there may have been.
  17284. +
  17285. +2004-06-02 Ken Hill <khill@microtronix.com>
  17286. +
  17287. + * processor.h (TASK_SIZE): Change na_sdram_end to nasys_program_mem_end to remove
  17288. + dependancy on quartus memory component name.
  17289. +
  17290. + * page.h (PAGE_OFFSET): Change na_sdram to nasys_program_mem to remove
  17291. + dependancy on quartus memory component name.
  17292. +
  17293. diff --git a/include/asm-nios2nommu/Kbuild b/include/asm-nios2nommu/Kbuild
  17294. new file mode 100644
  17295. index 0000000..abf0368
  17296. --- /dev/null
  17297. +++ b/include/asm-nios2nommu/Kbuild
  17298. @@ -0,0 +1,4 @@
  17299. +include include/asm-generic/Kbuild.asm
  17300. +
  17301. +header-y += traps.h
  17302. +header-y += io.h
  17303. diff --git a/include/asm-nios2nommu/a.out.h b/include/asm-nios2nommu/a.out.h
  17304. new file mode 100644
  17305. index 0000000..8297687
  17306. --- /dev/null
  17307. +++ b/include/asm-nios2nommu/a.out.h
  17308. @@ -0,0 +1,85 @@
  17309. +/* $Id: a.out.h,v 1.1 2006/07/05 06:20:25 gerg Exp $ */
  17310. +/*
  17311. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  17312. + *
  17313. + * All rights reserved.
  17314. + *
  17315. + * This program is free software; you can redistribute it and/or modify
  17316. + * it under the terms of the GNU General Public License as published by
  17317. + * the Free Software Foundation; either version 2 of the License, or
  17318. + * (at your option) any later version.
  17319. + *
  17320. + * This program is distributed in the hope that it will be useful, but
  17321. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  17322. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  17323. + * NON INFRINGEMENT. See the GNU General Public License for more
  17324. + * details.
  17325. + *
  17326. + * You should have received a copy of the GNU General Public License
  17327. + * along with this program; if not, write to the Free Software
  17328. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17329. + *
  17330. + */
  17331. +#ifndef __NIOS2NOMMU_A_OUT_H__
  17332. +#define __NIOS2NOMMU_A_OUT_H__
  17333. +
  17334. +#define SPARC_PGSIZE 0x1000 /* Thanks to the sun4 architecture... */
  17335. +#define SEGMENT_SIZE SPARC_PGSIZE /* whee... */
  17336. +
  17337. +struct exec {
  17338. + unsigned char a_dynamic:1; /* A __DYNAMIC is in this image */
  17339. + unsigned char a_toolversion:7;
  17340. + unsigned char a_machtype;
  17341. + unsigned short a_info;
  17342. + unsigned long a_text; /* length of text, in bytes */
  17343. + unsigned long a_data; /* length of data, in bytes */
  17344. + unsigned long a_bss; /* length of bss, in bytes */
  17345. + unsigned long a_syms; /* length of symbol table, in bytes */
  17346. + unsigned long a_entry; /* where program begins */
  17347. + unsigned long a_trsize;
  17348. + unsigned long a_drsize;
  17349. +};
  17350. +
  17351. +#define INIT_EXEC { \
  17352. + .a_dynamic = 0, \
  17353. + .a_toolversion = 0, \
  17354. + .a_machtype = 0, \
  17355. + .a_info = 0, \
  17356. + .a_text = 0, \
  17357. + .a_data = 0, \
  17358. + .a_bss = 0, \
  17359. + .a_syms = 0, \
  17360. + .a_entry = 0, \
  17361. + .a_trsize = 0, \
  17362. + .a_drsize = 0, \
  17363. +}
  17364. +
  17365. +/* Where in the file does the text information begin? */
  17366. +#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? 0 : sizeof (struct exec))
  17367. +
  17368. +/* Where do the Symbols start? */
  17369. +#define N_SYMOFF(x) (N_TXTOFF(x) + (x).a_text + \
  17370. + (x).a_data + (x).a_trsize + \
  17371. + (x).a_drsize)
  17372. +
  17373. +/* Where does text segment go in memory after being loaded? */
  17374. +#define N_TXTADDR(x) (((N_MAGIC(x) == ZMAGIC) && \
  17375. + ((x).a_entry < SPARC_PGSIZE)) ? \
  17376. + 0 : SPARC_PGSIZE)
  17377. +
  17378. +/* And same for the data segment.. */
  17379. +#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC ? \
  17380. + (N_TXTADDR(x) + (x).a_text) \
  17381. + : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
  17382. +
  17383. +#define N_TRSIZE(a) ((a).a_trsize)
  17384. +#define N_DRSIZE(a) ((a).a_drsize)
  17385. +#define N_SYMSIZE(a) ((a).a_syms)
  17386. +
  17387. +#ifdef __KERNEL__
  17388. +
  17389. +#define STACK_TOP TASK_SIZE
  17390. +
  17391. +#endif
  17392. +
  17393. +#endif /* __NIOS2NOMMU_A_OUT_H__ */
  17394. diff --git a/include/asm-nios2nommu/altera_juart.h b/include/asm-nios2nommu/altera_juart.h
  17395. new file mode 100644
  17396. index 0000000..da6320d
  17397. --- /dev/null
  17398. +++ b/include/asm-nios2nommu/altera_juart.h
  17399. @@ -0,0 +1,36 @@
  17400. +/*------------------------------------------------------------------------
  17401. + *
  17402. + * linux/drivers/serial/altera_juart.h
  17403. + *
  17404. + * Driver for Altera JTAG UART core with Avalon interface
  17405. + *
  17406. + * Copyright (C) 2004 Microtronix Datacom Ltd
  17407. + *
  17408. + * This program is free software; you can redistribute it and/or modify
  17409. + * it under the terms of the GNU General Public License as published by
  17410. + * the Free Software Foundation; either version 2 of the License, or
  17411. + * (at your option) any later version.
  17412. + *
  17413. + * This program is distributed in the hope that it will be useful,
  17414. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17415. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17416. + * GNU General Public License for more details.
  17417. + *
  17418. + *
  17419. + * History:
  17420. + * Jun/20/2005 DGT Microtronix Datacom NiosII
  17421. + *
  17422. + -----------------------------------------------------------------------*/
  17423. +
  17424. +#ifndef _ALTERA_JUART_H_
  17425. + #define _ALTERA_JUART_H_
  17426. +
  17427. + /* jtag uart details needed outside of the driver itself: */
  17428. + /* by: arch/kernel/start.c - boot time error message(s) */
  17429. +
  17430. + void jtaguart_console_write
  17431. + ( struct console *co,
  17432. + const char *s,
  17433. + unsigned int count);
  17434. +
  17435. +#endif /* _ALTERA_JUART_H_ */
  17436. diff --git a/include/asm-nios2nommu/asm-macros.h b/include/asm-nios2nommu/asm-macros.h
  17437. new file mode 100644
  17438. index 0000000..9dda7cd
  17439. --- /dev/null
  17440. +++ b/include/asm-nios2nommu/asm-macros.h
  17441. @@ -0,0 +1,331 @@
  17442. +/*
  17443. + * Macro used to simplify coding multi-line assembler.
  17444. + * Some of the bit test macro can simplify down to one line
  17445. + * depending on the mask value.
  17446. + *
  17447. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  17448. + *
  17449. + * All rights reserved.
  17450. + *
  17451. + * This program is free software; you can redistribute it and/or modify
  17452. + * it under the terms of the GNU General Public License as published by
  17453. + * the Free Software Foundation; either version 2 of the License, or
  17454. + * (at your option) any later version.
  17455. + *
  17456. + * This program is distributed in the hope that it will be useful, but
  17457. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  17458. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  17459. + * NON INFRINGEMENT. See the GNU General Public License for more
  17460. + * details.
  17461. + *
  17462. + * You should have received a copy of the GNU General Public License
  17463. + * along with this program; if not, write to the Free Software
  17464. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17465. + *
  17466. + */
  17467. +
  17468. +/*
  17469. + * ANDs reg2 with mask and places the result in reg1.
  17470. + *
  17471. + * You cannnot use the same register for reg1 & reg2.
  17472. + */
  17473. +
  17474. +.macro ANDI32 reg1,reg2,mask
  17475. + .if \mask & 0xffff
  17476. + .if \mask & 0xffff0000
  17477. + movhi \reg1,%hi(\mask)
  17478. + movui \reg1,%lo(\mask)
  17479. + and \reg1,\reg1,\reg2
  17480. + .else
  17481. + andi \reg1,\reg2,%lo(\mask)
  17482. + .endif
  17483. + .else
  17484. + andhi \reg1,\reg2,%hi(\mask)
  17485. + .endif
  17486. +.endm
  17487. +
  17488. +/*
  17489. + * ORs reg2 with mask and places the result in reg1.
  17490. + *
  17491. + * It is safe to use the same register for reg1 & reg2.
  17492. + */
  17493. +
  17494. +.macro ORI32 reg1,reg2,mask
  17495. + .if \mask & 0xffff
  17496. + .if \mask & 0xffff0000
  17497. + orhi \reg1,\reg2,%hi(\mask)
  17498. + ori \reg1,\reg2,%lo(\mask)
  17499. + .else
  17500. + ori \reg1,\reg2,%lo(\mask)
  17501. + .endif
  17502. + .else
  17503. + orhi \reg1,\reg2,%hi(\mask)
  17504. + .endif
  17505. +.endm
  17506. +
  17507. +/*
  17508. + * XORs reg2 with mask and places the result in reg1.
  17509. + *
  17510. + * It is safe to use the same register for reg1 & reg2.
  17511. + */
  17512. +
  17513. +.macro XORI32 reg1,reg2,mask
  17514. + .if \mask & 0xffff
  17515. + .if \mask & 0xffff0000
  17516. + xorhi \reg1,\reg2,%hi(\mask)
  17517. + xori \reg1,\reg1,%lo(\mask)
  17518. + .else
  17519. + xori \reg1,\reg2,%lo(\mask)
  17520. + .endif
  17521. + .else
  17522. + xorhi \reg1,\reg2,%hi(\mask)
  17523. + .endif
  17524. +.endm
  17525. +
  17526. +/*
  17527. + * This is a support macro for BTBZ & BTBNZ. It checks
  17528. + * the bit to make sure it is valid 32 value.
  17529. + *
  17530. + * It is safe to use the same register for reg1 & reg2.
  17531. + */
  17532. +
  17533. +.macro BT reg1,reg2,bit
  17534. +.if \bit > 31
  17535. + .err
  17536. +.else
  17537. + .if \bit < 16
  17538. + andi \reg1,\reg2,(1 << \bit)
  17539. + .else
  17540. + andhi \reg1,\reg2,(1 << (\bit - 16))
  17541. + .endif
  17542. +.endif
  17543. +.endm
  17544. +
  17545. +/*
  17546. + * Tests the bit in reg2 and branches to label if the
  17547. + * bit is zero. The result of the bit test is stored in reg1.
  17548. + *
  17549. + * It is safe to use the same register for reg1 & reg2.
  17550. + */
  17551. +
  17552. +.macro BTBZ reg1,reg2,bit,label
  17553. + BT \reg1,\reg2,\bit
  17554. + beq \reg1,r0,\label
  17555. +.endm
  17556. +
  17557. +/*
  17558. + * Tests the bit in reg2 and branches to label if the
  17559. + * bit is non-zero. The result of the bit test is stored in reg1.
  17560. + *
  17561. + * It is safe to use the same register for reg1 & reg2.
  17562. + */
  17563. +
  17564. +.macro BTBNZ reg1,reg2,bit,label
  17565. + BT \reg1,\reg2,\bit
  17566. + bne \reg1,r0,\label
  17567. +.endm
  17568. +
  17569. +/*
  17570. + * Tests the bit in reg2 and then compliments the bit in reg2.
  17571. + * The result of the bit test is stored in reg1.
  17572. + *
  17573. + * It is NOT safe to use the same register for reg1 & reg2.
  17574. + */
  17575. +
  17576. +.macro BTC reg1,reg2,bit
  17577. +.if \bit > 31
  17578. + .err
  17579. +.else
  17580. + .if \bit < 16
  17581. + andi \reg1,\reg2,(1 << \bit)
  17582. + xori \reg2,\reg2,(1 << \bit)
  17583. + .else
  17584. + andhi \reg1,\reg2,(1 << (\bit - 16))
  17585. + xorhi \reg2,\reg2,(1 << (\bit - 16))
  17586. + .endif
  17587. +.endif
  17588. +.endm
  17589. +
  17590. +/*
  17591. + * Tests the bit in reg2 and then sets the bit in reg2.
  17592. + * The result of the bit test is stored in reg1.
  17593. + *
  17594. + * It is NOT safe to use the same register for reg1 & reg2.
  17595. + */
  17596. +
  17597. +.macro BTS reg1,reg2,bit
  17598. +.if \bit > 31
  17599. + .err
  17600. +.else
  17601. + .if \bit < 16
  17602. + andi \reg1,\reg2,(1 << \bit)
  17603. + ori \reg2,\reg2,(1 << \bit)
  17604. + .else
  17605. + andhi \reg1,\reg2,(1 << (\bit - 16))
  17606. + orhi \reg2,\reg2,(1 << (\bit - 16))
  17607. + .endif
  17608. +.endif
  17609. +.endm
  17610. +
  17611. +/*
  17612. + * Tests the bit in reg2 and then resets the bit in reg2.
  17613. + * The result of the bit test is stored in reg1.
  17614. + *
  17615. + * It is NOT safe to use the same register for reg1 & reg2.
  17616. + */
  17617. +
  17618. +.macro BTR reg1,reg2,bit
  17619. +.if \bit > 31
  17620. + .err
  17621. +.else
  17622. + .if \bit < 16
  17623. + andi \reg1,\reg2,(1 << \bit)
  17624. + andi \reg2,\reg2,%lo(~(1 << \bit))
  17625. + .else
  17626. + andhi \reg1,\reg2,(1 << (\bit - 16))
  17627. + andhi \reg2,\reg2,%lo(~(1 << (\bit - 16)))
  17628. + .endif
  17629. +.endif
  17630. +.endm
  17631. +
  17632. +/*
  17633. + * Tests the bit in reg2 and then compliments the bit in reg2.
  17634. + * The result of the bit test is stored in reg1. If the
  17635. + * original bit was zero it branches to label.
  17636. + *
  17637. + * It is NOT safe to use the same register for reg1 & reg2.
  17638. + */
  17639. +
  17640. +.macro BTCBZ reg1,reg2,bit,label
  17641. + BTC \reg1,\reg2,\bit
  17642. + beq \reg1,r0,\label
  17643. +.endm
  17644. +
  17645. +/*
  17646. + * Tests the bit in reg2 and then compliments the bit in reg2.
  17647. + * The result of the bit test is stored in reg1. If the
  17648. + * original bit was non-zero it branches to label.
  17649. + *
  17650. + * It is NOT safe to use the same register for reg1 & reg2.
  17651. + */
  17652. +
  17653. +.macro BTCBNZ reg1,reg2,bit,label
  17654. + BTC \reg1,\reg2,\bit
  17655. + bne \reg1,r0,\label
  17656. +.endm
  17657. +
  17658. +/*
  17659. + * Tests the bit in reg2 and then sets the bit in reg2.
  17660. + * The result of the bit test is stored in reg1. If the
  17661. + * original bit was zero it branches to label.
  17662. + *
  17663. + * It is NOT safe to use the same register for reg1 & reg2.
  17664. + */
  17665. +
  17666. +.macro BTSBZ reg1,reg2,bit,label
  17667. + BTS \reg1,\reg2,\bit
  17668. + beq \reg1,r0,\label
  17669. +.endm
  17670. +
  17671. +/*
  17672. + * Tests the bit in reg2 and then sets the bit in reg2.
  17673. + * The result of the bit test is stored in reg1. If the
  17674. + * original bit was non-zero it branches to label.
  17675. + *
  17676. + * It is NOT safe to use the same register for reg1 & reg2.
  17677. + */
  17678. +
  17679. +.macro BTSBNZ reg1,reg2,bit,label
  17680. + BTS \reg1,\reg2,\bit
  17681. + bne \reg1,r0,\label
  17682. +.endm
  17683. +
  17684. +/*
  17685. + * Tests the bit in reg2 and then resets the bit in reg2.
  17686. + * The result of the bit test is stored in reg1. If the
  17687. + * original bit was zero it branches to label.
  17688. + *
  17689. + * It is NOT safe to use the same register for reg1 & reg2.
  17690. + */
  17691. +
  17692. +.macro BTRBZ reg1,reg2,bit,label
  17693. + BTR \reg1,\reg2,\bit
  17694. + bne \reg1,r0,\label
  17695. +.endm
  17696. +
  17697. +/*
  17698. + * Tests the bit in reg2 and then resets the bit in reg2.
  17699. + * The result of the bit test is stored in reg1. If the
  17700. + * original bit was non-zero it branches to label.
  17701. + *
  17702. + * It is NOT safe to use the same register for reg1 & reg2.
  17703. + */
  17704. +
  17705. +.macro BTRBNZ reg1,reg2,bit,label
  17706. + BTR \reg1,\reg2,\bit
  17707. + bne \reg1,r0,\label
  17708. +.endm
  17709. +
  17710. +/*
  17711. + * Tests the bits in mask against reg2 stores the result in reg1.
  17712. + * If the all the bits in the mask are zero it branches to label.
  17713. + *
  17714. + * It is safe to use the same register for reg1 & reg2.
  17715. + */
  17716. +
  17717. +.macro TSTBZ reg1,reg2,mask,label
  17718. + ANDI32 \reg1,\reg2,\mask
  17719. + beq \reg1,r0,\label
  17720. +.endm
  17721. +
  17722. +/*
  17723. + * Tests the bits in mask against reg2 stores the result in reg1.
  17724. + * If the any of the bits in the mask are 1 it branches to label.
  17725. + *
  17726. + * It is safe to use the same register for reg1 & reg2.
  17727. + */
  17728. +
  17729. +.macro TSTBNZ reg1,reg2,mask,label
  17730. + ANDI32 \reg1,\reg2,\mask
  17731. + bne \reg1,r0,\label
  17732. +.endm
  17733. +
  17734. +/*
  17735. + * Pushes reg onto the stack.
  17736. + */
  17737. +
  17738. +.macro PUSH reg
  17739. + addi sp,sp,-4
  17740. + stw \reg,0(sp)
  17741. +.endm
  17742. +
  17743. +/*
  17744. + * Pops the top of the stack into reg.
  17745. + */
  17746. +
  17747. +.macro POP reg
  17748. + ldw \reg,0(sp)
  17749. + addi sp,sp,4
  17750. +.endm
  17751. +
  17752. +/*
  17753. + * Clears reg
  17754. + */
  17755. +
  17756. +.macro CLR reg
  17757. + mov \reg,r0
  17758. +.endm
  17759. +
  17760. +/*
  17761. + * The preprocessor macro does not work for
  17762. + * the nios2 compiler. Undefine ENTRY and define
  17763. + * a real assembler macro.
  17764. + */
  17765. +#undef ENTRY
  17766. +#define ENTRY(name) ASM_ENTRY name
  17767. +
  17768. +.macro ASM_ENTRY name
  17769. +.globl \name
  17770. +__ALIGN
  17771. + \name:
  17772. +.endm
  17773. diff --git a/include/asm-nios2nommu/atomic.h b/include/asm-nios2nommu/atomic.h
  17774. new file mode 100644
  17775. index 0000000..fb627de
  17776. --- /dev/null
  17777. +++ b/include/asm-nios2nommu/atomic.h
  17778. @@ -0,0 +1,146 @@
  17779. +#ifndef __ASM_SH_ATOMIC_H
  17780. +#define __ASM_SH_ATOMIC_H
  17781. +
  17782. +/*
  17783. + * Atomic operations that C can't guarantee us. Useful for
  17784. + * resource counting etc..
  17785. + *
  17786. + */
  17787. +
  17788. +typedef struct { volatile int counter; } atomic_t;
  17789. +
  17790. +#define ATOMIC_INIT(i) ( (atomic_t) { (i) } )
  17791. +
  17792. +#define atomic_read(v) ((v)->counter)
  17793. +#define atomic_set(v,i) ((v)->counter = (i))
  17794. +
  17795. +#include <asm/system.h>
  17796. +
  17797. +/*
  17798. + * To get proper branch prediction for the main line, we must branch
  17799. + * forward to code at the end of this object's .text section, then
  17800. + * branch back to restart the operation.
  17801. + */
  17802. +
  17803. +static __inline__ void atomic_add(int i, atomic_t * v)
  17804. +{
  17805. + unsigned long flags;
  17806. +
  17807. + local_irq_save(flags);
  17808. + *(long *)v += i;
  17809. + local_irq_restore(flags);
  17810. +}
  17811. +
  17812. +static __inline__ void atomic_sub(int i, atomic_t *v)
  17813. +{
  17814. + unsigned long flags;
  17815. +
  17816. + local_irq_save(flags);
  17817. + *(long *)v -= i;
  17818. + local_irq_restore(flags);
  17819. +}
  17820. +
  17821. +static __inline__ int atomic_add_return(int i, atomic_t * v)
  17822. +{
  17823. + unsigned long temp, flags;
  17824. +
  17825. + local_irq_save(flags);
  17826. + temp = *(long *)v;
  17827. + temp += i;
  17828. + *(long *)v = temp;
  17829. + local_irq_restore(flags);
  17830. +
  17831. + return temp;
  17832. +}
  17833. +
  17834. +#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
  17835. +
  17836. +static __inline__ int atomic_sub_return(int i, atomic_t * v)
  17837. +{
  17838. + unsigned long temp, flags;
  17839. +
  17840. + local_irq_save(flags);
  17841. + temp = *(long *)v;
  17842. + temp -= i;
  17843. + *(long *)v = temp;
  17844. + local_irq_restore(flags);
  17845. +
  17846. + return temp;
  17847. +}
  17848. +
  17849. +#define atomic_dec_return(v) atomic_sub_return(1,(v))
  17850. +#define atomic_inc_return(v) atomic_add_return(1,(v))
  17851. +
  17852. +/*
  17853. + * atomic_inc_and_test - increment and test
  17854. + * @v: pointer of type atomic_t
  17855. + *
  17856. + * Atomically increments @v by 1
  17857. + * and returns true if the result is zero, or false for all
  17858. + * other cases.
  17859. + */
  17860. +#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
  17861. +
  17862. +#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)
  17863. +#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
  17864. +
  17865. +#define atomic_inc(v) atomic_add(1,(v))
  17866. +#define atomic_dec(v) atomic_sub(1,(v))
  17867. +
  17868. +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
  17869. +{
  17870. + int ret;
  17871. + unsigned long flags;
  17872. +
  17873. + local_irq_save(flags);
  17874. + ret = v->counter;
  17875. + if (likely(ret == old))
  17876. + v->counter = new;
  17877. + local_irq_restore(flags);
  17878. +
  17879. + return ret;
  17880. +}
  17881. +
  17882. +#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
  17883. +
  17884. +static inline int atomic_add_unless(atomic_t *v, int a, int u)
  17885. +{
  17886. + int ret;
  17887. + unsigned long flags;
  17888. +
  17889. + local_irq_save(flags);
  17890. + ret = v->counter;
  17891. + if (ret != u)
  17892. + v->counter += a;
  17893. + local_irq_restore(flags);
  17894. +
  17895. + return ret != u;
  17896. +}
  17897. +#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
  17898. +
  17899. +static __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v)
  17900. +{
  17901. + unsigned long flags;
  17902. +
  17903. + local_irq_save(flags);
  17904. + *(long *)v &= ~mask;
  17905. + local_irq_restore(flags);
  17906. +}
  17907. +
  17908. +static __inline__ void atomic_set_mask(unsigned int mask, atomic_t *v)
  17909. +{
  17910. + unsigned long flags;
  17911. +
  17912. + local_irq_save(flags);
  17913. + *(long *)v |= mask;
  17914. + local_irq_restore(flags);
  17915. +}
  17916. +
  17917. +/* Atomic operations are already serializing on SH */
  17918. +#define smp_mb__before_atomic_dec() barrier()
  17919. +#define smp_mb__after_atomic_dec() barrier()
  17920. +#define smp_mb__before_atomic_inc() barrier()
  17921. +#define smp_mb__after_atomic_inc() barrier()
  17922. +
  17923. +#include <asm-generic/atomic.h>
  17924. +#endif /* __ASM_SH_ATOMIC_H */
  17925. diff --git a/include/asm-nios2nommu/auxvec.h b/include/asm-nios2nommu/auxvec.h
  17926. new file mode 100644
  17927. index 0000000..fc21e4d
  17928. --- /dev/null
  17929. +++ b/include/asm-nios2nommu/auxvec.h
  17930. @@ -0,0 +1,4 @@
  17931. +#ifndef __ASM_SH_AUXVEC_H
  17932. +#define __ASM_SH_AUXVEC_H
  17933. +
  17934. +#endif /* __ASM_SH_AUXVEC_H */
  17935. diff --git a/include/asm-nios2nommu/bitops.h b/include/asm-nios2nommu/bitops.h
  17936. new file mode 100644
  17937. index 0000000..7bf1862
  17938. --- /dev/null
  17939. +++ b/include/asm-nios2nommu/bitops.h
  17940. @@ -0,0 +1,11 @@
  17941. +#ifndef __ASM_NIOS2NOMMU_BITOPS_H
  17942. +#define __ASM_NIOS2NOMMU_BITOPS_H
  17943. +
  17944. +#ifdef __KERNEL__
  17945. +#include <asm/system.h>
  17946. +#include <asm-generic/bitops.h>
  17947. +#define smp_mb__before_clear_bit() barrier()
  17948. +#define smp_mb__after_clear_bit() barrier()
  17949. +#endif /* __KERNEL__ */
  17950. +
  17951. +#endif /* __ASM_NIOS2NOMMU_BITOPS_H */
  17952. diff --git a/include/asm-nios2nommu/bootinfo.h b/include/asm-nios2nommu/bootinfo.h
  17953. new file mode 100644
  17954. index 0000000..ee8c39e
  17955. --- /dev/null
  17956. +++ b/include/asm-nios2nommu/bootinfo.h
  17957. @@ -0,0 +1,2 @@
  17958. +
  17959. +/* Nothing for nios2nommu */
  17960. diff --git a/include/asm-nios2nommu/bug.h b/include/asm-nios2nommu/bug.h
  17961. new file mode 100644
  17962. index 0000000..d99ab08
  17963. --- /dev/null
  17964. +++ b/include/asm-nios2nommu/bug.h
  17965. @@ -0,0 +1,4 @@
  17966. +#ifndef _MNIOS2NOMMU_BUG_H
  17967. +#define _MNIOS2NOMMU_BUG_H
  17968. +#include <asm-generic/bug.h>
  17969. +#endif
  17970. diff --git a/include/asm-nios2nommu/bugs.h b/include/asm-nios2nommu/bugs.h
  17971. new file mode 100644
  17972. index 0000000..a0753eb
  17973. --- /dev/null
  17974. +++ b/include/asm-nios2nommu/bugs.h
  17975. @@ -0,0 +1,40 @@
  17976. +#ifndef __ASM_NIOS_BUGS_H
  17977. +#define __ASM_NIOS_BUGS_H
  17978. +
  17979. +/*--------------------------------------------------------------------
  17980. + *
  17981. + * include/asm-nios2nommu/bugs.h
  17982. + *
  17983. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  17984. + *
  17985. + * Copyright (C) 1994 Linus Torvalds
  17986. + * Copyright (C) 2004 Microtronix Datacom Ltd
  17987. + *
  17988. + * This program is free software; you can redistribute it and/or modify
  17989. + * it under the terms of the GNU General Public License as published by
  17990. + * the Free Software Foundation; either version 2 of the License, or
  17991. + * (at your option) any later version.
  17992. + *
  17993. + * This program is distributed in the hope that it will be useful,
  17994. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17995. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17996. + * GNU General Public License for more details.
  17997. + *
  17998. + *
  17999. + * Jan/20/2004 dgt NiosII
  18000. + *
  18001. + ---------------------------------------------------------------------*/
  18002. +
  18003. +
  18004. +/*
  18005. + * This is included by init/main.c to check for architecture-dependent bugs.
  18006. + *
  18007. + * Needs:
  18008. + * void check_bugs(void);
  18009. + */
  18010. +
  18011. +static void check_bugs(void)
  18012. +{
  18013. +}
  18014. +
  18015. +#endif
  18016. diff --git a/include/asm-nios2nommu/byteorder.h b/include/asm-nios2nommu/byteorder.h
  18017. new file mode 100644
  18018. index 0000000..960b6d3
  18019. --- /dev/null
  18020. +++ b/include/asm-nios2nommu/byteorder.h
  18021. @@ -0,0 +1,38 @@
  18022. +#ifndef __ASM_NIOS_BYTEORDER_H
  18023. +#define __ASM_NIOS_BYTEORDER_H
  18024. +
  18025. +/*--------------------------------------------------------------------
  18026. + *
  18027. + * include/asm-nios2nommu/byteorder.h
  18028. + *
  18029. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  18030. + *
  18031. + * Copyright (C) 2004 Microtronix Datacom Ltd
  18032. + *
  18033. + * This program is free software; you can redistribute it and/or modify
  18034. + * it under the terms of the GNU General Public License as published by
  18035. + * the Free Software Foundation; either version 2 of the License, or
  18036. + * (at your option) any later version.
  18037. + *
  18038. + * This program is distributed in the hope that it will be useful,
  18039. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18040. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18041. + * GNU General Public License for more details.
  18042. + *
  18043. + *
  18044. + * Jan/20/2004 dgt NiosII
  18045. + *
  18046. + ---------------------------------------------------------------------*/
  18047. +
  18048. +
  18049. +#include <asm/types.h>
  18050. +
  18051. +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__)
  18052. +# define __BYTEORDER_HAS_U64__
  18053. +# define __SWAB_64_THRU_32__
  18054. +#endif
  18055. +
  18056. +#include <linux/byteorder/little_endian.h>
  18057. +
  18058. +#endif
  18059. +
  18060. diff --git a/include/asm-nios2nommu/cache.h b/include/asm-nios2nommu/cache.h
  18061. new file mode 100644
  18062. index 0000000..82bbd14
  18063. --- /dev/null
  18064. +++ b/include/asm-nios2nommu/cache.h
  18065. @@ -0,0 +1,36 @@
  18066. +/*
  18067. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  18068. + *
  18069. + * All rights reserved.
  18070. + *
  18071. + * This program is free software; you can redistribute it and/or modify
  18072. + * it under the terms of the GNU General Public License as published by
  18073. + * the Free Software Foundation; either version 2 of the License, or
  18074. + * (at your option) any later version.
  18075. + *
  18076. + * This program is distributed in the hope that it will be useful, but
  18077. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  18078. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18079. + * NON INFRINGEMENT. See the GNU General Public License for more
  18080. + * details.
  18081. + *
  18082. + * You should have received a copy of the GNU General Public License
  18083. + * along with this program; if not, write to the Free Software
  18084. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18085. + *
  18086. + */
  18087. +#ifndef __ARCH_NIOS2NOMMU_CACHE_H
  18088. +#define __ARCH_NIOS2NOMMU_CACHE_H
  18089. +
  18090. +#include <asm/nios.h>
  18091. +
  18092. +/* bytes per L1 cache line */
  18093. +#define L1_CACHE_BYTES nasys_icache_line_size /* 32, this need to be at least 1 */
  18094. +#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1))
  18095. +#define L1_CACHE_SHIFT 5
  18096. +
  18097. +
  18098. +#define __cacheline_aligned
  18099. +#define ____cacheline_aligned
  18100. +
  18101. +#endif
  18102. diff --git a/include/asm-nios2nommu/cachectl.h b/include/asm-nios2nommu/cachectl.h
  18103. new file mode 100644
  18104. index 0000000..39d7d9d
  18105. --- /dev/null
  18106. +++ b/include/asm-nios2nommu/cachectl.h
  18107. @@ -0,0 +1,36 @@
  18108. +/*
  18109. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  18110. + *
  18111. + * All rights reserved.
  18112. + *
  18113. + * This program is free software; you can redistribute it and/or modify
  18114. + * it under the terms of the GNU General Public License as published by
  18115. + * the Free Software Foundation; either version 2 of the License, or
  18116. + * (at your option) any later version.
  18117. + *
  18118. + * This program is distributed in the hope that it will be useful, but
  18119. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  18120. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18121. + * NON INFRINGEMENT. See the GNU General Public License for more
  18122. + * details.
  18123. + *
  18124. + * You should have received a copy of the GNU General Public License
  18125. + * along with this program; if not, write to the Free Software
  18126. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18127. + *
  18128. + */
  18129. +
  18130. +#ifndef _NIOS2NOMMU_CACHECTL_H
  18131. +#define _NIOS2NOMMU_CACHECTL_H
  18132. +
  18133. +/* Definitions for the cacheflush system call. */
  18134. +
  18135. +#define FLUSH_SCOPE_LINE 1 /* Flush a cache line */
  18136. +#define FLUSH_SCOPE_PAGE 2 /* Flush a page */
  18137. +#define FLUSH_SCOPE_ALL 3 /* Flush the whole cache -- superuser only */
  18138. +
  18139. +#define FLUSH_CACHE_DATA 1 /* Writeback and flush data cache */
  18140. +#define FLUSH_CACHE_INSN 2 /* Flush instruction cache */
  18141. +#define FLUSH_CACHE_BOTH 3 /* Flush both caches */
  18142. +
  18143. +#endif /* _NIOS2NOMMU_CACHECTL_H */
  18144. diff --git a/include/asm-nios2nommu/cacheflush.h b/include/asm-nios2nommu/cacheflush.h
  18145. new file mode 100644
  18146. index 0000000..4543201
  18147. --- /dev/null
  18148. +++ b/include/asm-nios2nommu/cacheflush.h
  18149. @@ -0,0 +1,59 @@
  18150. +#ifndef _NIOS2NOMMU_CACHEFLUSH_H
  18151. +#define _NIOS2NOMMU_CACHEFLUSH_H
  18152. +
  18153. +/*
  18154. + * Ported from m68knommu.
  18155. + *
  18156. + * (C) Copyright 2003, Microtronix Datacom Ltd.
  18157. + * (C) Copyright 2000-2002, Greg Ungerer <gerg@snapgear.com>
  18158. + *
  18159. + * All rights reserved.
  18160. + *
  18161. + * This program is free software; you can redistribute it and/or modify
  18162. + * it under the terms of the GNU General Public License as published by
  18163. + * the Free Software Foundation; either version 2 of the License, or
  18164. + * (at your option) any later version.
  18165. + *
  18166. + * This program is distributed in the hope that it will be useful, but
  18167. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  18168. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18169. + * NON INFRINGEMENT. See the GNU General Public License for more
  18170. + * details.
  18171. + *
  18172. + * You should have received a copy of the GNU General Public License
  18173. + * along with this program; if not, write to the Free Software
  18174. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18175. + *
  18176. + */
  18177. +#include <linux/mm.h>
  18178. +
  18179. +extern void cache_push (unsigned long vaddr, int len);
  18180. +extern void dcache_push (unsigned long vaddr, int len);
  18181. +extern void icache_push (unsigned long vaddr, int len);
  18182. +extern void cache_push_all (void);
  18183. +extern void cache_clear (unsigned long paddr, int len);
  18184. +
  18185. +#define flush_cache_all() __flush_cache_all()
  18186. +#define flush_cache_mm(mm) do { } while (0)
  18187. +#define flush_cache_range(vma, start, end) cache_push(start, end - start)
  18188. +#define flush_cache_page(vma, vmaddr) do { } while (0)
  18189. +#define flush_dcache_range(start,end) dcache_push(start, end - start)
  18190. +#define flush_dcache_page(page) do { } while (0)
  18191. +#define flush_dcache_mmap_lock(mapping) do { } while (0)
  18192. +#define flush_dcache_mmap_unlock(mapping) do { } while (0)
  18193. +#define flush_icache_range(start,end) cache_push(start, end - start)
  18194. +#define flush_icache_page(vma,pg) do { } while (0)
  18195. +#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
  18196. +
  18197. +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
  18198. + memcpy(dst, src, len)
  18199. +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
  18200. + memcpy(dst, src, len)
  18201. +
  18202. +
  18203. +extern inline void __flush_cache_all(void)
  18204. +{
  18205. + cache_push_all();
  18206. +}
  18207. +
  18208. +#endif /* _NIOS2NOMMU_CACHEFLUSH_H */
  18209. diff --git a/include/asm-nios2nommu/checksum.h b/include/asm-nios2nommu/checksum.h
  18210. new file mode 100644
  18211. index 0000000..1f6879e
  18212. --- /dev/null
  18213. +++ b/include/asm-nios2nommu/checksum.h
  18214. @@ -0,0 +1,320 @@
  18215. +#ifndef __NIOS2_CHECKSUM_H
  18216. +#define __NIOS2_CHECKSUM_H
  18217. +
  18218. +/* checksum.h: IP/UDP/TCP checksum routines on the NIOS.
  18219. + *
  18220. + * Copyright(C) 1995 Linus Torvalds
  18221. + * Copyright(C) 1995 Miguel de Icaza
  18222. + * Copyright(C) 1996 David S. Miller
  18223. + * Copyright(C) 2001 Ken Hill
  18224. + * Copyright(C) 2004 Microtronix Datacom Ltd.
  18225. + *
  18226. + * derived from:
  18227. + * Alpha checksum c-code
  18228. + * ix86 inline assembly
  18229. + * Spar nommu
  18230. + *
  18231. + * All rights reserved.
  18232. + *
  18233. + * This program is free software; you can redistribute it and/or modify
  18234. + * it under the terms of the GNU General Public License as published by
  18235. + * the Free Software Foundation; either version 2 of the License, or
  18236. + * (at your option) any later version.
  18237. + *
  18238. + * This program is distributed in the hope that it will be useful, but
  18239. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  18240. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18241. + * NON INFRINGEMENT. See the GNU General Public License for more
  18242. + * details.
  18243. + *
  18244. + * You should have received a copy of the GNU General Public License
  18245. + * along with this program; if not, write to the Free Software
  18246. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18247. + *
  18248. + */
  18249. +
  18250. +
  18251. +/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  18252. +
  18253. +/*
  18254. + * computes the checksum of the TCP/UDP pseudo-header
  18255. + * returns a 16-bit checksum, already complemented
  18256. + */
  18257. +
  18258. +extern inline unsigned short csum_tcpudp_magic(unsigned long saddr,
  18259. + unsigned long daddr,
  18260. + unsigned short len,
  18261. + unsigned short proto,
  18262. + unsigned int sum)
  18263. +{
  18264. + barrier();
  18265. + __asm__ __volatile__(
  18266. +" add %0, %3, %0\n"
  18267. +" bgeu %0, %3, 1f\n"
  18268. +" addi %0, %0, 1\n"
  18269. +"1: add %0, %4, %0\n"
  18270. +" bgeu %0, %4, 1f\n"
  18271. +" addi %0, %0, 1\n"
  18272. +"1: add %0, %5, %0\n"
  18273. +" bgeu %0, %5, 1f\n"
  18274. +" addi %0, %0, 1\n"
  18275. +"1:\n"
  18276. +/*
  18277. + We need the carry from the addition of 16-bit
  18278. + significant addition, so we zap out the low bits
  18279. + in one half, zap out the high bits in another,
  18280. + shift them both up to the top 16-bits of a word
  18281. + and do the carry producing addition, finally
  18282. + shift the result back down to the low 16-bits.
  18283. +
  18284. + Actually, we can further optimize away two shifts
  18285. + because we know the low bits of the original
  18286. + value will be added to zero-only bits so cannot
  18287. + affect the addition result nor the final carry
  18288. + bit.
  18289. +*/
  18290. +" slli %1,%0, 16\n" /* Need a copy to fold with */
  18291. + /* Bring the LOW 16 bits up */
  18292. +" add %0, %1, %0\n" /* add and set carry, neat eh? */
  18293. +" cmpltu r15, %0, %1\n" /* get remaining carry bit */
  18294. +" srli %0, %0, 16\n" /* shift back down the result */
  18295. +" add %0, %0, r15\n"
  18296. +" nor %0, %0, %0\n" /* negate */
  18297. + : "=&r" (sum), "=&r" (saddr)
  18298. + : "0" (sum), "1" (saddr), "r" (ntohl(len+proto)), "r" (daddr)
  18299. + : "r15");
  18300. + return ((unsigned short) sum);
  18301. + barrier();
  18302. +}
  18303. +
  18304. +
  18305. +/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  18306. +
  18307. +
  18308. + extern inline unsigned short from32to16(unsigned long x)
  18309. + {
  18310. + barrier();
  18311. + __asm__ __volatile__(
  18312. + "add %0, %1, %0\n"
  18313. + "cmpltu r15, %0, %1\n"
  18314. + "srli %0, %0, 16\n"
  18315. + "add %0, %0, r15\n"
  18316. + : "=r" (x)
  18317. + : "r" (x << 16), "0" (x)
  18318. + : "r15");
  18319. + return x;
  18320. + barrier();
  18321. + }
  18322. +
  18323. +
  18324. +/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  18325. +
  18326. +
  18327. +extern inline unsigned long do_csum(const unsigned char * buff, int len)
  18328. +{
  18329. + int odd, count;
  18330. + unsigned long result = 0;
  18331. +
  18332. + barrier();
  18333. + if (len <= 0)
  18334. + goto out;
  18335. + odd = 1 & (unsigned long) buff;
  18336. + if (odd) {
  18337. +////result = *buff; // dgt: Big endian
  18338. + result = *buff << 8; // dgt: Little endian
  18339. +
  18340. + len--;
  18341. + buff++;
  18342. + }
  18343. + count = len >> 1; /* nr of 16-bit words.. */
  18344. + if (count) {
  18345. + if (2 & (unsigned long) buff) {
  18346. + result += *(unsigned short *) buff;
  18347. + count--;
  18348. + len -= 2;
  18349. + buff += 2;
  18350. + }
  18351. + count >>= 1; /* nr of 32-bit words.. */
  18352. + if (count) {
  18353. + unsigned long carry = 0;
  18354. + do {
  18355. + unsigned long w = *(unsigned long *) buff;
  18356. + count--;
  18357. + buff += 4;
  18358. + result += carry;
  18359. + result += w;
  18360. + carry = (w > result);
  18361. + } while (count);
  18362. + result += carry;
  18363. + result = (result & 0xffff) + (result >> 16);
  18364. + }
  18365. + if (len & 2) {
  18366. + result += *(unsigned short *) buff;
  18367. + buff += 2;
  18368. + }
  18369. + }
  18370. + if (len & 1)
  18371. + result += *buff; /* This is little machine, byte is right */
  18372. + result = from32to16(result);
  18373. + if (odd)
  18374. + result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
  18375. +out:
  18376. + return result;
  18377. + barrier();
  18378. + }
  18379. +
  18380. +
  18381. +/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  18382. +
  18383. +
  18384. +/* ihl is always 5 or greater, almost always is 5, iph is always word
  18385. + * aligned but can fail to be dword aligned very often.
  18386. + */
  18387. +
  18388. + extern inline unsigned short ip_fast_csum(const unsigned char *iph, unsigned int ihl)
  18389. + {
  18390. + unsigned int sum;
  18391. +
  18392. + barrier();
  18393. + __asm__ __volatile__(
  18394. +" andi r8, %1, 2\n" /* Remember original alignment */
  18395. +" ldw %0, (%1)\n" /* 16 or 32 bit boundary */
  18396. +" beq r8, r0, 1f\n" /* Aligned on 32 bit boundary, go */
  18397. +" srli %0, %0, 16\n" /* Get correct 16 bits */
  18398. +" addi %2, %2, -1\n" /* Take off for 4 bytes, pickup last 2 at end */
  18399. +" addi %1, %1, 2\n" /* Adjust pointer to 32 bit boundary */
  18400. +" br 2f\n"
  18401. +"1:\n"
  18402. +" addi %2, %2, -1\n"
  18403. +" addi %1, %1, 4\n" /* Bump ptr a long word */
  18404. +"2:\n"
  18405. +" ldw r9, (%1)\n"
  18406. +"1:\n"
  18407. +" add %0, r9, %0\n"
  18408. +" bgeu %0, r9, 2f\n"
  18409. +" addi %0, %0, 1\n"
  18410. +"2:\n"
  18411. +" addi %1, %1, 4\n"
  18412. +" addi %2, %2, -1\n"
  18413. +" ldw r9, (%1)\n"
  18414. +" bne %2, r0, 1b\n"
  18415. +" beq r8, r0, 1f\n" /* 32 bit boundary time to leave */
  18416. +" srli r9, r9, 16\n" /* 16 bit boundary, get correct 16 bits */
  18417. +" add %0, r9, %0\n"
  18418. +" bgeu %0, r9, 1f\n"
  18419. +" addi %0, %0, 1\n"
  18420. +"1:\n"
  18421. +" slli %2, %0, 16\n"
  18422. +" add %0, %2, %0\n"
  18423. +" cmpltu r8, %0, %2\n"
  18424. +" srli %0, %0, 16\n"
  18425. +" add %0, %0, r8\n"
  18426. +" nor %0, %0, %0\n"
  18427. + : "=&r" (sum), "=&r" (iph), "=&r" (ihl)
  18428. + : "1" (iph), "2" (ihl)
  18429. + : "r8", "r9");
  18430. + return sum;
  18431. + barrier();
  18432. + }
  18433. +
  18434. +/*these 2 functions are now in checksum.c */
  18435. +unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);
  18436. +unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum);
  18437. +
  18438. +/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  18439. +
  18440. +/*
  18441. + * the same as csum_partial_copy, but copies from user space.
  18442. + *
  18443. + * here even more important to align src and dst on a 32-bit (or even
  18444. + * better 64-bit) boundary
  18445. + */
  18446. +extern inline unsigned int
  18447. +csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *csum_err)
  18448. +{
  18449. + barrier();
  18450. + if (csum_err) *csum_err = 0;
  18451. + memcpy(dst, src, len);
  18452. + return csum_partial(dst, len, sum);
  18453. + barrier();
  18454. +}
  18455. +
  18456. +#define csum_partial_copy_nocheck(src, dst, len, sum) \
  18457. + csum_partial_copy ((src), (dst), (len), (sum))
  18458. +
  18459. +
  18460. +/*
  18461. + * this routine is used for miscellaneous IP-like checksums, mainly
  18462. + * in icmp.c
  18463. + */
  18464. +
  18465. +extern inline unsigned short ip_compute_csum(unsigned char * buff, int len)
  18466. +{
  18467. + barrier();
  18468. + return ~from32to16(do_csum(buff,len));
  18469. + barrier();
  18470. +}
  18471. +
  18472. +
  18473. +/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  18474. +
  18475. +
  18476. +#define csum_partial_copy_fromuser(s, d, l, w) \
  18477. + csum_partial_copy((char *) (s), (d), (l), (w))
  18478. +
  18479. +
  18480. +/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  18481. +
  18482. +
  18483. +/*
  18484. + * Fold a partial checksum without adding pseudo headers
  18485. + */
  18486. +extern __inline__ unsigned int csum_fold(unsigned int sum)
  18487. +{
  18488. + barrier();
  18489. + __asm__ __volatile__(
  18490. + "add %0, %1, %0\n"
  18491. + "cmpltu r8, %0, %1\n"
  18492. + "srli %0, %0, 16\n"
  18493. + "add %0, %0, r8\n"
  18494. + "nor %0, %0, %0\n"
  18495. + : "=r" (sum)
  18496. + : "r" (sum << 16), "0" (sum)
  18497. + : "r8");
  18498. + return sum;
  18499. + barrier();
  18500. +}
  18501. +
  18502. +
  18503. +/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  18504. +
  18505. +
  18506. +extern __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr,
  18507. + unsigned long daddr,
  18508. + unsigned short len,
  18509. + unsigned short proto,
  18510. + unsigned int sum)
  18511. +{
  18512. + barrier();
  18513. + __asm__ __volatile__(
  18514. + "add %0, %1, %0\n"
  18515. + "cmpltu r8, %0, %1\n"
  18516. + "add %0, %0, r8\n" /* add carry */
  18517. + "add %0, %2, %0\n"
  18518. + "cmpltu r8, %0, %2\n"
  18519. + "add %0, %0, r8\n" /* add carry */
  18520. + "add %0, %3, %0\n"
  18521. + "cmpltu r8, %0, %3\n"
  18522. + "add %0, %0, r8\n" /* add carry */
  18523. + : "=r" (sum), "=r" (saddr)
  18524. + : "r" (daddr), "r" ( (ntohs(len)<<16) + (proto*256) ),
  18525. + "0" (sum),
  18526. + "1" (saddr)
  18527. + : "r8");
  18528. +
  18529. + return sum;
  18530. + barrier();
  18531. +}
  18532. +
  18533. +
  18534. +#endif /* (__NIOS2_CHECKSUM_H) */
  18535. diff --git a/include/asm-nios2nommu/cprefix.h b/include/asm-nios2nommu/cprefix.h
  18536. new file mode 100644
  18537. index 0000000..4983211
  18538. --- /dev/null
  18539. +++ b/include/asm-nios2nommu/cprefix.h
  18540. @@ -0,0 +1,38 @@
  18541. +/* cprefix.h: This file is included by assembly source which needs
  18542. + * to know what the c-label prefixes are. The newer versions
  18543. + * of cpp that come with gcc predefine such things to help
  18544. + * us out. The reason this stuff is needed is to make
  18545. + * solaris compiles of the kernel work.
  18546. + *
  18547. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  18548. + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  18549. + *
  18550. + * All rights reserved.
  18551. + *
  18552. + * This program is free software; you can redistribute it and/or modify
  18553. + * it under the terms of the GNU General Public License as published by
  18554. + * the Free Software Foundation; either version 2 of the License, or
  18555. + * (at your option) any later version.
  18556. + *
  18557. + * This program is distributed in the hope that it will be useful, but
  18558. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  18559. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18560. + * NON INFRINGEMENT. See the GNU General Public License for more
  18561. + * details.
  18562. + *
  18563. + * You should have received a copy of the GNU General Public License
  18564. + * along with this program; if not, write to the Free Software
  18565. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18566. + *
  18567. + */
  18568. +#ifndef __NIOS2_CPREFIX_H
  18569. +#define __NIOS2_CPREFIX_H
  18570. +
  18571. +#define C_LABEL_PREFIX
  18572. +
  18573. +#define CONCAT(a, b) CONCAT2(a, b)
  18574. +#define CONCAT2(a, b) a##b
  18575. +
  18576. +#define C_LABEL(name) CONCAT(C_LABEL_PREFIX, name)
  18577. +
  18578. +#endif /* !(__NIOS2_CPREFIX_H) */
  18579. diff --git a/include/asm-nios2nommu/cpumask.h b/include/asm-nios2nommu/cpumask.h
  18580. new file mode 100644
  18581. index 0000000..86fb365
  18582. --- /dev/null
  18583. +++ b/include/asm-nios2nommu/cpumask.h
  18584. @@ -0,0 +1,28 @@
  18585. +/*
  18586. + * All rights reserved.
  18587. + *
  18588. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  18589. + *
  18590. + * This program is free software; you can redistribute it and/or modify
  18591. + * it under the terms of the GNU General Public License as published by
  18592. + * the Free Software Foundation; either version 2 of the License, or
  18593. + * (at your option) any later version.
  18594. + *
  18595. + * This program is distributed in the hope that it will be useful, but
  18596. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  18597. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18598. + * NON INFRINGEMENT. See the GNU General Public License for more
  18599. + * details.
  18600. + *
  18601. + * You should have received a copy of the GNU General Public License
  18602. + * along with this program; if not, write to the Free Software
  18603. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18604. + *
  18605. + */
  18606. +
  18607. +#ifndef _ASM_NIOS2NOMMU_CPUMASK_H
  18608. +#define _ASM_NIOS2NOMMU_CPUMASK_H
  18609. +
  18610. +#include <asm-generic/cpumask.h>
  18611. +
  18612. +#endif /* _ASM_NIOS2NOMMU_CPUMASK_H */
  18613. diff --git a/include/asm-nios2nommu/cputime.h b/include/asm-nios2nommu/cputime.h
  18614. new file mode 100644
  18615. index 0000000..370e4f2
  18616. --- /dev/null
  18617. +++ b/include/asm-nios2nommu/cputime.h
  18618. @@ -0,0 +1,31 @@
  18619. +/*
  18620. + * cputime.h
  18621. + * (C) Copyright 2004, Microtronix Datacom Ltd.
  18622. + *
  18623. + * Taken from m68knommu
  18624. + *
  18625. + * All rights reserved.
  18626. + *
  18627. + * This program is free software; you can redistribute it and/or modify
  18628. + * it under the terms of the GNU General Public License as published by
  18629. + * the Free Software Foundation; either version 2 of the License, or
  18630. + * (at your option) any later version.
  18631. + *
  18632. + * This program is distributed in the hope that it will be useful, but
  18633. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  18634. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18635. + * NON INFRINGEMENT. See the GNU General Public License for more
  18636. + * details.
  18637. + *
  18638. + * You should have received a copy of the GNU General Public License
  18639. + * along with this program; if not, write to the Free Software
  18640. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18641. + *
  18642. + */
  18643. +
  18644. +#ifndef __NIOS2NOMMU_CPUTIME_H
  18645. +#define __NIOS2NOMMU_CPUTIME_H
  18646. +
  18647. +#include <asm-generic/cputime.h>
  18648. +
  18649. +#endif /* __NIOS@NOMMU_CPUTIME_H */
  18650. diff --git a/include/asm-nios2nommu/current.h b/include/asm-nios2nommu/current.h
  18651. new file mode 100644
  18652. index 0000000..5ac1dbc
  18653. --- /dev/null
  18654. +++ b/include/asm-nios2nommu/current.h
  18655. @@ -0,0 +1,39 @@
  18656. +#ifndef _NIOS2NOMMU_CURRENT_H
  18657. +#define _NIOS2NOMMU_CURRENT_H
  18658. +/*
  18659. + * current.h
  18660. + * (C) Copyright 2000, Lineo, David McCullough <davidm@uclinux.org>
  18661. + * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
  18662. + * (C) Copyright 2004, Microtronix Datacom Ltd.
  18663. + *
  18664. + * All rights reserved.
  18665. + *
  18666. + * This program is free software; you can redistribute it and/or modify
  18667. + * it under the terms of the GNU General Public License as published by
  18668. + * the Free Software Foundation; either version 2 of the License, or
  18669. + * (at your option) any later version.
  18670. + *
  18671. + * This program is distributed in the hope that it will be useful, but
  18672. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  18673. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18674. + * NON INFRINGEMENT. See the GNU General Public License for more
  18675. + * details.
  18676. + *
  18677. + * You should have received a copy of the GNU General Public License
  18678. + * along with this program; if not, write to the Free Software
  18679. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18680. + *
  18681. + */
  18682. +
  18683. +#include <linux/thread_info.h>
  18684. +
  18685. +struct task_struct;
  18686. +
  18687. +static inline struct task_struct *get_current(void)
  18688. +{
  18689. + return(current_thread_info()->task);
  18690. +}
  18691. +
  18692. +#define current get_current()
  18693. +
  18694. +#endif /* _NIOS2NOMMU_CURRENT_H */
  18695. diff --git a/include/asm-nios2nommu/delay.h b/include/asm-nios2nommu/delay.h
  18696. new file mode 100644
  18697. index 0000000..da0a184
  18698. --- /dev/null
  18699. +++ b/include/asm-nios2nommu/delay.h
  18700. @@ -0,0 +1,96 @@
  18701. +#ifndef _NIOS_DELAY_H
  18702. +#define _NIOS_DELAY_H
  18703. +
  18704. +/*--------------------------------------------------------------------
  18705. + *
  18706. + * include/asm-nios2nommu/delay.h
  18707. + *
  18708. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  18709. + *
  18710. + * Copyright (C) 2004 Microtronix Datacom Ltd
  18711. + *
  18712. + * This program is free software; you can redistribute it and/or modify
  18713. + * it under the terms of the GNU General Public License as published by
  18714. + * the Free Software Foundation; either version 2 of the License, or
  18715. + * (at your option) any later version.
  18716. + *
  18717. + * This program is distributed in the hope that it will be useful,
  18718. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18719. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18720. + * GNU General Public License for more details.
  18721. + *
  18722. + *
  18723. + * Jan/20/2004 dgt NiosII
  18724. + *
  18725. + ---------------------------------------------------------------------*/
  18726. +
  18727. +
  18728. +#include <asm/param.h>
  18729. +
  18730. +extern __inline__ void __delay(unsigned long loops)
  18731. +{
  18732. + int dummy;
  18733. +
  18734. + __asm__ __volatile__(
  18735. + "1: \n\t"
  18736. + " beq %0,zero,2f\n\t"
  18737. + " addi %0, %0, -1\n\t"
  18738. + " br 1b\n\t"
  18739. + "2: \n\t"
  18740. +
  18741. + : "=r" (dummy) /* Need output for optimizer */
  18742. +
  18743. + : "0" (loops) /* %0 Input */
  18744. + );
  18745. +}
  18746. +
  18747. +/*
  18748. + * Note that 19 * 226 == 4294 ==~ 2^32 / 10^6, so
  18749. + * loops = (4294 * usecs * loops_per_jiffy * HZ) / 2^32.
  18750. + *
  18751. + * The mul instruction gives us loops = (a * b) / 2^32.
  18752. + * We choose a = usecs * 19 * HZ and b = loops_per_jiffy * 226
  18753. + * because this lets us support a wide range of HZ and
  18754. + * loops_per_jiffy values without either a or b overflowing 2^32.
  18755. + * Thus we need usecs * HZ <= (2^32 - 1) / 19 = 226050910 and
  18756. + * loops_per_jiffy <= (2^32 - 1) / 226 = 19004280
  18757. + * (which corresponds to ~3800 bogomips at HZ = 100).
  18758. + * -- paulus
  18759. + */
  18760. +#define __MAX_UDELAY (226050910UL/HZ) /* maximum udelay argument */
  18761. +#define __MAX_NDELAY (4294967295UL/HZ) /* maximum ndelay argument */
  18762. +
  18763. +extern unsigned long loops_per_jiffy;
  18764. +
  18765. +extern __inline__ void __udelay(unsigned int x)
  18766. +{
  18767. + unsigned int loops;
  18768. +
  18769. + __asm__("mulxuu %0,%1,%2" : "=r" (loops) :
  18770. + "r" (x), "r" (loops_per_jiffy * 226));
  18771. + __delay(loops);
  18772. +}
  18773. +
  18774. +extern __inline__ void __ndelay(unsigned int x)
  18775. +{
  18776. + unsigned int loops;
  18777. +
  18778. + __asm__("mulxuu %0,%1,%2" : "=r" (loops) :
  18779. + "r" (x), "r" (loops_per_jiffy * 5));
  18780. + __delay(loops);
  18781. +}
  18782. +
  18783. +extern void __bad_udelay(void); /* deliberately undefined */
  18784. +extern void __bad_ndelay(void); /* deliberately undefined */
  18785. +
  18786. +#define udelay(n) (__builtin_constant_p(n)? \
  18787. + ((n) > __MAX_UDELAY? __bad_udelay(): __udelay((n) * (19 * HZ))) : \
  18788. + __udelay((n) * (19 * HZ)))
  18789. +
  18790. +#define ndelay(n) (__builtin_constant_p(n)? \
  18791. + ((n) > __MAX_NDELAY? __bad_ndelay(): __ndelay((n) * HZ)) : \
  18792. + __ndelay((n) * HZ))
  18793. +
  18794. +#define muldiv(a, b, c) (((a)*(b))/(c))
  18795. +
  18796. +#endif /* defined(_NIOS_DELAY_H) */
  18797. diff --git a/include/asm-nios2nommu/device.h b/include/asm-nios2nommu/device.h
  18798. new file mode 100644
  18799. index 0000000..d8f9872
  18800. --- /dev/null
  18801. +++ b/include/asm-nios2nommu/device.h
  18802. @@ -0,0 +1,7 @@
  18803. +/*
  18804. + * Arch specific extensions to struct device
  18805. + *
  18806. + * This file is released under the GPLv2
  18807. + */
  18808. +#include <asm-generic/device.h>
  18809. +
  18810. diff --git a/include/asm-nios2nommu/div64.h b/include/asm-nios2nommu/div64.h
  18811. new file mode 100644
  18812. index 0000000..68d72e4
  18813. --- /dev/null
  18814. +++ b/include/asm-nios2nommu/div64.h
  18815. @@ -0,0 +1,31 @@
  18816. +#ifndef __ASMNIOS_DIV64_H
  18817. +#define __ASMNIOS_DIV64_H
  18818. +
  18819. +/*--------------------------------------------------------------------
  18820. + *
  18821. + * include/asm-nios2nommu/div64.h
  18822. + *
  18823. + * Derived from m68knommu
  18824. + *
  18825. + * Copyright (C) 2004 Microtronix Datacom Ltd
  18826. + *
  18827. + * This program is free software; you can redistribute it and/or modify
  18828. + * it under the terms of the GNU General Public License as published by
  18829. + * the Free Software Foundation; either version 2 of the License, or
  18830. + * (at your option) any later version.
  18831. + *
  18832. + * This program is distributed in the hope that it will be useful,
  18833. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18834. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18835. + * GNU General Public License for more details.
  18836. + *
  18837. + *
  18838. + * Jan/20/2004 dgt NiosII
  18839. + *
  18840. + ---------------------------------------------------------------------*/
  18841. +
  18842. +
  18843. +#include <asm-generic/div64.h>
  18844. +
  18845. +#endif
  18846. +
  18847. diff --git a/include/asm-nios2nommu/dma-mapping.h b/include/asm-nios2nommu/dma-mapping.h
  18848. new file mode 100644
  18849. index 0000000..6289370
  18850. --- /dev/null
  18851. +++ b/include/asm-nios2nommu/dma-mapping.h
  18852. @@ -0,0 +1,79 @@
  18853. +#ifndef _ASM_DMA_MAPPING_H
  18854. +#define _ASM_DMA_MAPPING_H
  18855. +
  18856. +#include <asm/scatterlist.h>
  18857. +#include <asm/cache.h>
  18858. +
  18859. +void *dma_alloc_noncoherent(struct device *dev, size_t size,
  18860. + dma_addr_t *dma_handle, gfp_t flag);
  18861. +
  18862. +void dma_free_noncoherent(struct device *dev, size_t size,
  18863. + void *vaddr, dma_addr_t dma_handle);
  18864. +
  18865. +void *dma_alloc_coherent(struct device *dev, size_t size,
  18866. + dma_addr_t *dma_handle, gfp_t flag);
  18867. +
  18868. +void dma_free_coherent(struct device *dev, size_t size,
  18869. + void *vaddr, dma_addr_t dma_handle);
  18870. +
  18871. +extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
  18872. + enum dma_data_direction direction);
  18873. +extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
  18874. + size_t size, enum dma_data_direction direction);
  18875. +extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
  18876. + enum dma_data_direction direction);
  18877. +extern dma_addr_t dma_map_page(struct device *dev, struct page *page,
  18878. + unsigned long offset, size_t size, enum dma_data_direction direction);
  18879. +extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
  18880. + size_t size, enum dma_data_direction direction);
  18881. +extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
  18882. + int nhwentries, enum dma_data_direction direction);
  18883. +extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
  18884. + size_t size, enum dma_data_direction direction);
  18885. +extern void dma_sync_single_for_device(struct device *dev,
  18886. + dma_addr_t dma_handle, size_t size, enum dma_data_direction direction);
  18887. +extern void dma_sync_single_range_for_cpu(struct device *dev,
  18888. + dma_addr_t dma_handle, unsigned long offset, size_t size,
  18889. + enum dma_data_direction direction);
  18890. +extern void dma_sync_single_range_for_device(struct device *dev,
  18891. + dma_addr_t dma_handle, unsigned long offset, size_t size,
  18892. + enum dma_data_direction direction);
  18893. +extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
  18894. + int nelems, enum dma_data_direction direction);
  18895. +extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
  18896. + int nelems, enum dma_data_direction direction);
  18897. +extern int dma_mapping_error(dma_addr_t dma_addr);
  18898. +extern int dma_supported(struct device *dev, u64 mask);
  18899. +
  18900. +static inline int
  18901. +dma_set_mask(struct device *dev, u64 mask)
  18902. +{
  18903. + if(!dev->dma_mask || !dma_supported(dev, mask))
  18904. + return -EIO;
  18905. +
  18906. + *dev->dma_mask = mask;
  18907. +
  18908. + return 0;
  18909. +}
  18910. +
  18911. +static inline int
  18912. +dma_get_cache_alignment(void)
  18913. +{
  18914. + /* XXX Largest on any MIPS */
  18915. + return 128;
  18916. +}
  18917. +
  18918. +extern int dma_is_consistent(dma_addr_t dma_addr);
  18919. +
  18920. +extern void dma_cache_sync(void *vaddr, size_t size,
  18921. + enum dma_data_direction direction);
  18922. +
  18923. +// #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
  18924. +//
  18925. +// extern int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
  18926. +// dma_addr_t device_addr, size_t size, int flags);
  18927. +// extern void dma_release_declared_memory(struct device *dev);
  18928. +// extern void * dma_mark_declared_memory_occupied(struct device *dev,
  18929. +// dma_addr_t device_addr, size_t size);
  18930. +
  18931. +#endif /* _ASM_DMA_MAPPING_H */
  18932. diff --git a/include/asm-nios2nommu/dma.h b/include/asm-nios2nommu/dma.h
  18933. new file mode 100644
  18934. index 0000000..ea098d5
  18935. --- /dev/null
  18936. +++ b/include/asm-nios2nommu/dma.h
  18937. @@ -0,0 +1,63 @@
  18938. +/* $Id: dma.h,v 1.1 2006/07/05 06:20:25 gerg Exp $
  18939. + *
  18940. + * Copyright 2004 (C) Microtronix Datacom Ltd.
  18941. + *
  18942. + * All rights reserved.
  18943. + *
  18944. + * This program is free software; you can redistribute it and/or modify
  18945. + * it under the terms of the GNU General Public License as published by
  18946. + * the Free Software Foundation; either version 2 of the License, or
  18947. + * (at your option) any later version.
  18948. + *
  18949. + * This program is distributed in the hope that it will be useful, but
  18950. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  18951. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18952. + * NON INFRINGEMENT. See the GNU General Public License for more
  18953. + * details.
  18954. + *
  18955. + * You should have received a copy of the GNU General Public License
  18956. + * along with this program; if not, write to the Free Software
  18957. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18958. + *
  18959. + */
  18960. +
  18961. +#ifndef _ASM_NIOS2_DMA_H
  18962. +#define _ASM_NIOS2_DMA_H
  18963. +
  18964. +#include <linux/kernel.h>
  18965. +#include <asm/asm-offsets.h>
  18966. +
  18967. +#define MAX_DMA_ADDRESS (LINUX_SDRAM_END)
  18968. +
  18969. +int request_dma(unsigned int, const char *);
  18970. +void free_dma(unsigned int);
  18971. +void enable_dma(unsigned int dmanr);
  18972. +void disable_dma(unsigned int dmanr);
  18973. +void set_dma_count(unsigned int dmanr, unsigned int count);
  18974. +int get_dma_residue(unsigned int dmanr);
  18975. +void nios2_set_dma_data_width(unsigned int dmanr, unsigned int width);
  18976. +
  18977. +void nios2_set_dma_handler(unsigned int dmanr, int (*handler)(void*, int), void* user);
  18978. +int nios2_request_dma(const char *);
  18979. +
  18980. +void nios2_set_dma_mode(unsigned int dmanr, unsigned int mode);
  18981. +void nios2_set_dma_rcon(unsigned int dmanr, unsigned int set);
  18982. +void nios2_set_dma_wcon(unsigned int dmanr, unsigned int set);
  18983. +void nios2_set_dma_raddr(unsigned int dmanr, unsigned int a);
  18984. +void nios2_set_dma_waddr(unsigned int dmanr, unsigned int a);
  18985. +
  18986. +static inline unsigned long claim_dma_lock(void)
  18987. +{
  18988. +}
  18989. +
  18990. +static inline void release_dma_lock(unsigned long flags)
  18991. +{
  18992. +}
  18993. +
  18994. +#ifdef CONFIG_PCI
  18995. +extern int isa_dma_bridge_buggy;
  18996. +#else
  18997. +#define isa_dma_bridge_buggy (0)
  18998. +#endif
  18999. +
  19000. +#endif /* !(_ASM_NIOS2_DMA_H) */
  19001. diff --git a/include/asm-nios2nommu/elf.h b/include/asm-nios2nommu/elf.h
  19002. new file mode 100644
  19003. index 0000000..94b2ac0
  19004. --- /dev/null
  19005. +++ b/include/asm-nios2nommu/elf.h
  19006. @@ -0,0 +1,140 @@
  19007. +#ifndef __NIOS2_ELF_H
  19008. +#define __NIOS2_ELF_H
  19009. +
  19010. +/*--------------------------------------------------------------------
  19011. + *
  19012. + * include/asm-nios2nommu/elf.h
  19013. + *
  19014. + * Nio2 ELF relocation types
  19015. + *
  19016. + * Derived from M68knommu
  19017. + *
  19018. + * Copyright (C) 2004 Microtronix Datacom Ltd
  19019. + *
  19020. + * This program is free software; you can redistribute it and/or modify
  19021. + * it under the terms of the GNU General Public License as published by
  19022. + * the Free Software Foundation; either version 2 of the License, or
  19023. + * (at your option) any later version.
  19024. + *
  19025. + * This program is distributed in the hope that it will be useful,
  19026. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19027. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19028. + * GNU General Public License for more details.
  19029. + *
  19030. + * Jan/20/2004 dgt NiosII
  19031. + * Mar/18/2004 xwt NiosII relocation types added
  19032. + *
  19033. + ---------------------------------------------------------------------*/
  19034. +
  19035. +#include <asm/ptrace.h>
  19036. +#include <asm/user.h>
  19037. +
  19038. +#define R_NIOS2_NONE 0
  19039. +#define R_NIOS2_S16 1
  19040. +#define R_NIOS2_U16 2
  19041. +#define R_NIOS2_PCREL16 3
  19042. +#define R_NIOS2_CALL26 4
  19043. +#define R_NIOS2_IMM5 5
  19044. +#define R_NIOS2_CACHE_OPX 6
  19045. +#define R_NIOS2_IMM6 7
  19046. +#define R_NIOS2_IMM8 8
  19047. +#define R_NIOS2_HI16 9
  19048. +#define R_NIOS2_LO16 10
  19049. +#define R_NIOS2_HIADJ16 11
  19050. +#define R_NIOS2_BFD_RELOC_32 12
  19051. +#define R_NIOS2_BFD_RELOC_16 13
  19052. +#define R_NIOS2_BFD_RELOC_8 14
  19053. +#define R_NIOS2_GPREL 15
  19054. +#define R_NIOS2_GNU_VTINHERIT 16
  19055. +#define R_NIOS2_GNU_VTENTRY 17
  19056. +#define R_NIOS2_UJMP 18
  19057. +#define R_NIOS2_CJMP 19
  19058. +#define R_NIOS2_CALLR 20
  19059. +#define R_NIOS2_ALIGN 21
  19060. +/* Keep this the last entry. */
  19061. +#define R_NIOS2_NUM 22
  19062. +
  19063. +typedef unsigned long elf_greg_t;
  19064. +
  19065. +#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
  19066. +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  19067. +
  19068. +typedef unsigned long elf_fpregset_t;
  19069. +
  19070. +/*
  19071. + * This is used to ensure we don't load something for the wrong architecture.
  19072. + */
  19073. +#define elf_check_arch(x) \
  19074. + ((x)->e_machine == EM_ALTERA_NIOS2)
  19075. +
  19076. +/*
  19077. + * These are used to set parameters in the core dumps.
  19078. + */
  19079. +#define ELF_CLASS ELFCLASS32
  19080. +#define ELF_DATA ELFDATA2LSB
  19081. +#define ELF_ARCH EM_ALTERA_NIOS2
  19082. +
  19083. +#define ELF_PLAT_INIT(_r, load_addr) _r->a1 = 0
  19084. +
  19085. +#define USE_ELF_CORE_DUMP
  19086. +#define ELF_EXEC_PAGESIZE 4096
  19087. +
  19088. +/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
  19089. + use of this is to invoke "./ld.so someprog" to test out a new version of
  19090. + the loader. We need to make sure that it is out of the way of the program
  19091. + that it will "exec", and that there is sufficient room for the brk. */
  19092. +
  19093. +#define ELF_ET_DYN_BASE 0xD0000000UL
  19094. +
  19095. +/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
  19096. + now struct_user_regs, they are different) */
  19097. +
  19098. +#define ELF_CORE_COPY_REGS(pr_reg, regs) \
  19099. + /* Bleech. */ \
  19100. + pr_reg[0] = regs->r1; \
  19101. + pr_reg[1] = regs->r2; \
  19102. + pr_reg[2] = regs->r3; \
  19103. + pr_reg[3] = regs->r4; \
  19104. + pr_reg[4] = regs->r5; \
  19105. + pr_reg[5] = regs->r6; \
  19106. + pr_reg[6] = regs->r7; \
  19107. + pr_reg[7] = regs->r8; \
  19108. + pr_reg[8] = regs->r9; \
  19109. + pr_reg[9] = regs->r10; \
  19110. + pr_reg[10] = regs->r11; \
  19111. + pr_reg[11] = regs->r12; \
  19112. + pr_reg[12] = regs->r13; \
  19113. + pr_reg[13] = regs->r14; \
  19114. + pr_reg[14] = regs->r15; \
  19115. + pr_reg[23] = regs->sp; \
  19116. + pr_reg[26] = regs->estatus; \
  19117. + { \
  19118. + struct switch_stack *sw = ((struct switch_stack *)regs) - 1; \
  19119. + pr_reg[15] = sw->r16; \
  19120. + pr_reg[16] = sw->r17; \
  19121. + pr_reg[17] = sw->r18; \
  19122. + pr_reg[18] = sw->r19; \
  19123. + pr_reg[19] = sw->r20; \
  19124. + pr_reg[20] = sw->r21; \
  19125. + pr_reg[21] = sw->r22; \
  19126. + pr_reg[22] = sw->r23; \
  19127. + pr_reg[24] = sw->fp; \
  19128. + pr_reg[25] = sw->gp; \
  19129. + }
  19130. +
  19131. +/* This yields a mask that user programs can use to figure out what
  19132. + instruction set this cpu supports. */
  19133. +
  19134. +#define ELF_HWCAP (0)
  19135. +
  19136. +/* This yields a string that ld.so will use to load implementation
  19137. + specific libraries for optimization. This is more specific in
  19138. + intent than poking at uname or /proc/cpuinfo. */
  19139. +
  19140. +#define ELF_PLATFORM (NULL)
  19141. +
  19142. +#ifdef __KERNEL__
  19143. +#define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
  19144. +#endif
  19145. +
  19146. +#endif
  19147. diff --git a/include/asm-nios2nommu/emergency-restart.h b/include/asm-nios2nommu/emergency-restart.h
  19148. new file mode 100644
  19149. index 0000000..108d8c4
  19150. --- /dev/null
  19151. +++ b/include/asm-nios2nommu/emergency-restart.h
  19152. @@ -0,0 +1,6 @@
  19153. +#ifndef _ASM_EMERGENCY_RESTART_H
  19154. +#define _ASM_EMERGENCY_RESTART_H
  19155. +
  19156. +#include <asm-generic/emergency-restart.h>
  19157. +
  19158. +#endif /* _ASM_EMERGENCY_RESTART_H */
  19159. diff --git a/include/asm-nios2nommu/entry.h b/include/asm-nios2nommu/entry.h
  19160. new file mode 100644
  19161. index 0000000..4b1773f
  19162. --- /dev/null
  19163. +++ b/include/asm-nios2nommu/entry.h
  19164. @@ -0,0 +1,187 @@
  19165. +/*
  19166. + * Hacked from m68knommu port.
  19167. + *
  19168. + * Copyright(C) 2004 Microtronix Datacom Ltd.
  19169. + *
  19170. + * All rights reserved.
  19171. + *
  19172. + * This program is free software; you can redistribute it and/or modify
  19173. + * it under the terms of the GNU General Public License as published by
  19174. + * the Free Software Foundation; either version 2 of the License, or
  19175. + * (at your option) any later version.
  19176. + *
  19177. + * This program is distributed in the hope that it will be useful, but
  19178. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  19179. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  19180. + * NON INFRINGEMENT. See the GNU General Public License for more
  19181. + * details.
  19182. + *
  19183. + * You should have received a copy of the GNU General Public License
  19184. + * along with this program; if not, write to the Free Software
  19185. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19186. + *
  19187. + */
  19188. +
  19189. +#ifndef __NIOS2NOMMU_ENTRY_H
  19190. +#define __NIOS2NOMMU_ENTRY_H
  19191. +
  19192. +#ifdef __ASSEMBLY__
  19193. +
  19194. +#include <asm/setup.h>
  19195. +#include <asm/page.h>
  19196. +#include <asm/asm-offsets.h>
  19197. +
  19198. +/*
  19199. + * Stack layout in 'ret_from_exception':
  19200. + *
  19201. + * This allows access to the syscall arguments in registers r4-r8
  19202. + *
  19203. + * 0(sp) - r8
  19204. + * 4(sp) - r9
  19205. + * 8(sp) - r10
  19206. + * C(sp) - r11
  19207. + * 10(sp) - r12
  19208. + * 14(sp) - r13
  19209. + * 18(sp) - r14
  19210. + * 1C(sp) - r15
  19211. + * 20(sp) - r1
  19212. + * 24(sp) - r2
  19213. + * 28(sp) - r3
  19214. + * 2C(sp) - r4
  19215. + * 30(sp) - r5
  19216. + * 34(sp) - r6
  19217. + * 38(sp) - r7
  19218. + * 3C(sp) - orig_r2
  19219. + * 40(sp) - ra
  19220. + * 44(sp) - fp
  19221. + * 48(sp) - sp
  19222. + * 4C(sp) - gp
  19223. + * 50(sp) - estatus
  19224. + * 54(sp) - status_extension
  19225. + * 58(sp) - ea
  19226. + *
  19227. + */
  19228. +
  19229. +/* process bits for task_struct.flags */
  19230. +PF_TRACESYS_OFF = 3
  19231. +PF_TRACESYS_BIT = 5
  19232. +PF_PTRACED_OFF = 3
  19233. +PF_PTRACED_BIT = 4
  19234. +PF_DTRACE_OFF = 1
  19235. +PF_DTRACE_BIT = 5
  19236. +
  19237. +LENOSYS = 38
  19238. +
  19239. +/*
  19240. + * This defines the normal kernel pt-regs layout.
  19241. + *
  19242. + */
  19243. +
  19244. +/*
  19245. + * Standard Nios2 interrupt entry and exit macros.
  19246. + * Must be called with interrupts disabled.
  19247. + */
  19248. +.macro SAVE_ALL
  19249. + movia r24,status_extension // Read status extension
  19250. + ldw r24,0(r24)
  19251. + andi r24,r24,PS_S_ASM
  19252. + bne r24,r0,1f // In supervisor mode, already on kernel stack
  19253. + movia r24,_current_thread // Switch to current kernel stack
  19254. + ldw r24,0(r24) // using the thread_info
  19255. + addi r24,r24,THREAD_SIZE_ASM-PT_REGS_SIZE
  19256. + stw sp,PT_SP(r24) // Save user stack before changing
  19257. + mov sp,r24
  19258. + br 2f
  19259. +
  19260. +1: mov r24,sp
  19261. + addi sp,sp,-PT_REGS_SIZE // Backup the kernel stack pointer
  19262. + stw r24,PT_SP(sp)
  19263. +2: stw r1,PT_R1(sp)
  19264. + stw r2,PT_R2(sp)
  19265. + stw r3,PT_R3(sp)
  19266. + stw r4,PT_R4(sp)
  19267. + stw r5,PT_R5(sp)
  19268. + stw r6,PT_R6(sp)
  19269. + stw r7,PT_R7(sp)
  19270. + stw r8,PT_R8(sp)
  19271. + stw r9,PT_R9(sp)
  19272. + stw r10,PT_R10(sp)
  19273. + stw r11,PT_R11(sp)
  19274. + stw r12,PT_R12(sp)
  19275. + stw r13,PT_R13(sp)
  19276. + stw r14,PT_R14(sp)
  19277. + stw r15,PT_R15(sp)
  19278. + stw r2,PT_ORIG_R2(sp)
  19279. + stw ra,PT_RA(sp)
  19280. + stw fp,PT_FP(sp)
  19281. + stw gp,PT_GP(sp)
  19282. + rdctl r24,estatus
  19283. + stw r24,PT_ESTATUS(sp)
  19284. + movia r24,status_extension // Read status extension
  19285. + ldw r1,0(r24)
  19286. + stw r1,PT_STATUS_EXTENSION(sp) // Store user/supervisor status
  19287. + ORI32 r1,r1,PS_S_ASM // Set supervisor mode
  19288. + stw r1,0(r24)
  19289. + stw ea,PT_EA(sp)
  19290. +.endm
  19291. +
  19292. +.macro RESTORE_ALL
  19293. + ldw r1,PT_STATUS_EXTENSION(sp) // Restore user/supervisor status
  19294. + movia r24,status_extension
  19295. + stw r1,0(r24)
  19296. + ldw r1,PT_R1(sp) // Restore registers
  19297. + ldw r2,PT_R2(sp)
  19298. + ldw r3,PT_R3(sp)
  19299. + ldw r4,PT_R4(sp)
  19300. + ldw r5,PT_R5(sp)
  19301. + ldw r6,PT_R6(sp)
  19302. + ldw r7,PT_R7(sp)
  19303. + ldw r8,PT_R8(sp)
  19304. + ldw r9,PT_R9(sp)
  19305. + ldw r10,PT_R10(sp)
  19306. + ldw r11,PT_R11(sp)
  19307. + ldw r12,PT_R12(sp)
  19308. + ldw r13,PT_R13(sp)
  19309. + ldw r14,PT_R14(sp)
  19310. + ldw r15,PT_R15(sp)
  19311. + ldw ra,PT_RA(sp)
  19312. + ldw fp,PT_FP(sp)
  19313. + ldw gp,PT_GP(sp)
  19314. + ldw r24,PT_ESTATUS(sp)
  19315. + wrctl estatus,r24
  19316. + ldw ea,PT_EA(sp)
  19317. + ldw sp,PT_SP(sp) // Restore sp last
  19318. +.endm
  19319. +
  19320. +.macro SAVE_SWITCH_STACK
  19321. + addi sp,sp,-SWITCH_STACK_SIZE
  19322. + stw r16,SW_R16(sp)
  19323. + stw r17,SW_R17(sp)
  19324. + stw r18,SW_R18(sp)
  19325. + stw r19,SW_R19(sp)
  19326. + stw r20,SW_R20(sp)
  19327. + stw r21,SW_R21(sp)
  19328. + stw r22,SW_R22(sp)
  19329. + stw r23,SW_R23(sp)
  19330. + stw fp,SW_FP(sp)
  19331. + stw gp,SW_GP(sp)
  19332. + stw ra,SW_RA(sp)
  19333. +.endm
  19334. +
  19335. +.macro RESTORE_SWITCH_STACK
  19336. + ldw r16,SW_R16(sp)
  19337. + ldw r17,SW_R17(sp)
  19338. + ldw r18,SW_R18(sp)
  19339. + ldw r19,SW_R19(sp)
  19340. + ldw r20,SW_R20(sp)
  19341. + ldw r21,SW_R21(sp)
  19342. + ldw r22,SW_R22(sp)
  19343. + ldw r23,SW_R23(sp)
  19344. + ldw fp,SW_FP(sp)
  19345. + ldw gp,SW_GP(sp)
  19346. + ldw ra,SW_RA(sp)
  19347. + addi sp,sp,SWITCH_STACK_SIZE
  19348. +.endm
  19349. +
  19350. +#endif /* __ASSEMBLY__ */
  19351. +#endif /* __NIOS2NOMMU_ENTRY_H */
  19352. diff --git a/include/asm-nios2nommu/errno.h b/include/asm-nios2nommu/errno.h
  19353. new file mode 100644
  19354. index 0000000..c2caf21
  19355. --- /dev/null
  19356. +++ b/include/asm-nios2nommu/errno.h
  19357. @@ -0,0 +1,6 @@
  19358. +#ifndef _NIOS2NOMMU_ERRNO_H
  19359. +#define _NIOS2NOMMU_ERRNO_H
  19360. +
  19361. +#include <asm-generic/errno.h>
  19362. +
  19363. +#endif /* _NIOS2NOMMU_ERRNO_H */
  19364. diff --git a/include/asm-nios2nommu/fcntl.h b/include/asm-nios2nommu/fcntl.h
  19365. new file mode 100644
  19366. index 0000000..9d98af2
  19367. --- /dev/null
  19368. +++ b/include/asm-nios2nommu/fcntl.h
  19369. @@ -0,0 +1,11 @@
  19370. +#ifndef _NIOS2_FCNTL_H
  19371. +#define _NIOS2_FCNTL_H
  19372. +
  19373. +#define O_DIRECTORY 040000 /* must be a directory */
  19374. +#define O_NOFOLLOW 0100000 /* don't follow links */
  19375. +#define O_DIRECT 0200000 /* direct disk access hint - currently ignored */
  19376. +#define O_LARGEFILE 0400000
  19377. +
  19378. +#include <asm-generic/fcntl.h>
  19379. +
  19380. +#endif /* _NIOS2_FCNTL_H */
  19381. diff --git a/include/asm-nios2nommu/flat.h b/include/asm-nios2nommu/flat.h
  19382. new file mode 100644
  19383. index 0000000..681329a
  19384. --- /dev/null
  19385. +++ b/include/asm-nios2nommu/flat.h
  19386. @@ -0,0 +1,129 @@
  19387. +/*
  19388. + * include/asm-nios2nommu/flat.h -- uClinux bFLT relocations
  19389. + *
  19390. + * Copyright (C) 2004,05 Microtronix Datacom Ltd
  19391. + *
  19392. + * This file is subject to the terms and conditions of the GNU General
  19393. + * Public License. See the file COPYING in the main directory of this
  19394. + * archive for more details.
  19395. + *
  19396. + * Written by Wentao Xu <wentao@microtronix.com>
  19397. + */
  19398. +
  19399. +#ifndef __NIOS2_FLAT_H__
  19400. +#define __NIOS2_FLAT_H__
  19401. +
  19402. +#define flat_reloc_valid(reloc, size) ((reloc) <= (size + 0x8000))
  19403. +
  19404. +/* The stack is 64-bit aligned for Nios II, so (sp - 1) shall
  19405. + * be 64-bit aligned, where -1 is for argc
  19406. + */
  19407. +#define flat_stack_align(sp) (sp = (unsigned long *)(((unsigned long)sp - 1) & (-8)))
  19408. +
  19409. +/* The uClibc port for Nios II expects the argc is followed by argv and envp */
  19410. +#define flat_argvp_envp_on_stack() 1
  19411. +
  19412. +#define flat_old_ram_flag(flags) (flags)
  19413. +
  19414. +/* We store the type of relocation in the top 4 bits of the `relval.' */
  19415. +
  19416. +/* Convert a relocation entry into an address. */
  19417. +static inline unsigned long
  19418. +flat_get_relocate_addr (unsigned long relval)
  19419. +{
  19420. + return relval & 0x0fffffff; /* Mask out top 4-bits */
  19421. +}
  19422. +
  19423. +#define FLAT_NIOS2_RELOC_TYPE(relval) ((relval) >> 28)
  19424. +
  19425. +#define FLAT_NIOS2_R_32 0 /* Normal 32-bit reloc */
  19426. +#define FLAT_NIOS2_R_HI_LO 1 /* High 16-bits + low 16-bits field */
  19427. +#define FLAT_NIOS2_R_HIADJ_LO 2 /* High 16-bits adjust + low 16-bits field */
  19428. +#define FLAT_NIOS2_R_CALL26 4 /* Call imm26 */
  19429. +
  19430. +#define flat_set_persistent(relval, p) 0
  19431. +
  19432. +/* Extract the address to be relocated from the symbol reference at rp;
  19433. + * relval is the raw relocation-table entry from which RP is derived.
  19434. + * rp shall always be 32-bit aligned
  19435. + */
  19436. +static inline unsigned long flat_get_addr_from_rp (unsigned long *rp,
  19437. + unsigned long relval,
  19438. + unsigned long flags,
  19439. + unsigned long *persistent)
  19440. +{
  19441. + switch (FLAT_NIOS2_RELOC_TYPE(relval))
  19442. + {
  19443. + case FLAT_NIOS2_R_32:
  19444. + /* Simple 32-bit address. The loader expect it in bigger endian */
  19445. + return htonl(*rp);
  19446. +
  19447. + case FLAT_NIOS2_R_HI_LO:
  19448. + /* get the two 16-bit immediate value from instructions, then
  19449. + * construct a 32-bit value. Again the loader expect bigger endian
  19450. + */
  19451. + return htonl ((((rp[0] >> 6) & 0xFFFF) << 16 ) |
  19452. + ((rp[1] >> 6) & 0xFFFF));
  19453. +
  19454. + case FLAT_NIOS2_R_HIADJ_LO:
  19455. + {
  19456. + /* get the two 16-bit immediate value from instructions, then
  19457. + * construct a 32-bit value. Again the loader expect bigger endian
  19458. + */
  19459. + unsigned int low, high;
  19460. + high = (rp[0] >> 6) & 0xFFFF;
  19461. + low = (rp[1] >> 6) & 0xFFFF;
  19462. +
  19463. + if ((low >> 15) & 1) high--;
  19464. +
  19465. + return htonl ((high << 16 ) | low );
  19466. + }
  19467. + case FLAT_NIOS2_R_CALL26:
  19468. + /* the 26-bit immediate value is actually 28-bit */
  19469. + return htonl(((*rp) >> 6) << 2);
  19470. +
  19471. + default:
  19472. + return ~0; /* bogus value */
  19473. + }
  19474. +}
  19475. +
  19476. +/* Insert the address addr into the symbol reference at rp;
  19477. + * relval is the raw relocation-table entry from which rp is derived.
  19478. + * rp shall always be 32-bit aligned
  19479. + */
  19480. +static inline void flat_put_addr_at_rp (unsigned long *rp, unsigned long addr,
  19481. + unsigned long relval)
  19482. +{
  19483. + unsigned long exist_val;
  19484. + switch (FLAT_NIOS2_RELOC_TYPE (relval)) {
  19485. + case FLAT_NIOS2_R_32:
  19486. + /* Simple 32-bit address. */
  19487. + *rp = addr;
  19488. + break;
  19489. +
  19490. + case FLAT_NIOS2_R_HI_LO:
  19491. + exist_val = rp[0];
  19492. + rp[0] = ((((exist_val >> 22) << 16) | (addr >> 16)) << 6) | (exist_val & 0x3F);
  19493. + exist_val = rp[1];
  19494. + rp[1] = ((((exist_val >> 22) << 16) | (addr & 0xFFFF)) << 6) | (exist_val & 0x3F);
  19495. + break;
  19496. +
  19497. + case FLAT_NIOS2_R_HIADJ_LO:
  19498. + {
  19499. + unsigned int high = (addr >> 16);
  19500. + if ((addr >> 15) & 1)
  19501. + high = (high + 1) & 0xFFFF;
  19502. + exist_val = rp[0];
  19503. + rp[0] = ((((exist_val >> 22) << 16) | high) << 6) | (exist_val & 0x3F);
  19504. + exist_val = rp[1];
  19505. + rp[1] = ((((exist_val >> 22) << 16) | (addr & 0xFFFF)) << 6) | (exist_val & 0x3F);
  19506. + break;
  19507. + }
  19508. + case FLAT_NIOS2_R_CALL26:
  19509. + /* the opcode of CALL is 0, so just store the value */
  19510. + *rp = ((addr >> 2) << 6);
  19511. + break;
  19512. + }
  19513. +}
  19514. +
  19515. +#endif /* __NIOS2_FLAT_H__ */
  19516. diff --git a/include/asm-nios2nommu/futex.h b/include/asm-nios2nommu/futex.h
  19517. new file mode 100644
  19518. index 0000000..6a332a9
  19519. --- /dev/null
  19520. +++ b/include/asm-nios2nommu/futex.h
  19521. @@ -0,0 +1,6 @@
  19522. +#ifndef _ASM_FUTEX_H
  19523. +#define _ASM_FUTEX_H
  19524. +
  19525. +#include <asm-generic/futex.h>
  19526. +
  19527. +#endif
  19528. diff --git a/include/asm-nios2nommu/gpio.h b/include/asm-nios2nommu/gpio.h
  19529. new file mode 100644
  19530. index 0000000..b91937b
  19531. --- /dev/null
  19532. +++ b/include/asm-nios2nommu/gpio.h
  19533. @@ -0,0 +1,11 @@
  19534. +#ifndef _ASM_GPIO_H_
  19535. +#define _ASM_GPIO_H_ 1
  19536. +
  19537. +
  19538. +struct gpio_i2c_pins {
  19539. + unsigned sda_pin;
  19540. + unsigned scl_pin;
  19541. +};
  19542. +
  19543. +#endif /*_ASM_GPIO_*/
  19544. +
  19545. diff --git a/include/asm-nios2nommu/hardirq.h b/include/asm-nios2nommu/hardirq.h
  19546. new file mode 100644
  19547. index 0000000..0041f51
  19548. --- /dev/null
  19549. +++ b/include/asm-nios2nommu/hardirq.h
  19550. @@ -0,0 +1,43 @@
  19551. +/*
  19552. + * Ported from m68knommu
  19553. + *
  19554. + * Copyright (C) 2003, Microtronix Datacom Ltd.
  19555. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  19556. + *
  19557. + * All rights reserved.
  19558. + *
  19559. + * This program is free software; you can redistribute it and/or modify
  19560. + * it under the terms of the GNU General Public License as published by
  19561. + * the Free Software Foundation; either version 2 of the License, or
  19562. + * (at your option) any later version.
  19563. + *
  19564. + * This program is distributed in the hope that it will be useful, but
  19565. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  19566. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  19567. + * NON INFRINGEMENT. See the GNU General Public License for more
  19568. + * details.
  19569. + *
  19570. + * You should have received a copy of the GNU General Public License
  19571. + * along with this program; if not, write to the Free Software
  19572. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19573. + *
  19574. + */
  19575. +#ifndef __NIOS2_HARDIRQ_H
  19576. +#define __NIOS2_HARDIRQ_H
  19577. +
  19578. +#include <linux/cache.h>
  19579. +#include <linux/threads.h>
  19580. +
  19581. +typedef struct {
  19582. + unsigned int __softirq_pending;
  19583. +} ____cacheline_aligned irq_cpustat_t;
  19584. +
  19585. +#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
  19586. +
  19587. +#define HARDIRQ_BITS 8
  19588. +
  19589. +#ifdef CONFIG_SMP
  19590. +# error nios2nommu SMP is not available
  19591. +#endif /* CONFIG_SMP */
  19592. +
  19593. +#endif /* __NIOS2_HARDIRQ_H */
  19594. diff --git a/include/asm-nios2nommu/hdreg.h b/include/asm-nios2nommu/hdreg.h
  19595. new file mode 100644
  19596. index 0000000..b4d910a
  19597. --- /dev/null
  19598. +++ b/include/asm-nios2nommu/hdreg.h
  19599. @@ -0,0 +1,30 @@
  19600. +/*
  19601. + * Copyright (C) 1994-1996 Linus Torvalds & authors
  19602. + * Copyright (C) 2002 Wentau Xu (www.microtronix.com)
  19603. + * copyright (C) 2004 Microtronix Datacom Ltd.
  19604. + *
  19605. + * All rights reserved.
  19606. + *
  19607. + * This program is free software; you can redistribute it and/or modify
  19608. + * it under the terms of the GNU General Public License as published by
  19609. + * the Free Software Foundation; either version 2 of the License, or
  19610. + * (at your option) any later version.
  19611. + *
  19612. + * This program is distributed in the hope that it will be useful, but
  19613. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  19614. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  19615. + * NON INFRINGEMENT. See the GNU General Public License for more
  19616. + * details.
  19617. + *
  19618. + * You should have received a copy of the GNU General Public License
  19619. + * along with this program; if not, write to the Free Software
  19620. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19621. + *
  19622. + */
  19623. +
  19624. +#ifndef __NIOS2_HDREG_H
  19625. +#define __NIOS2_HDREG_H
  19626. +
  19627. +typedef unsigned long ide_ioreg_t;
  19628. +
  19629. +#endif /* __NIOS2_HDREG_H */
  19630. diff --git a/include/asm-nios2nommu/hw_irq.h b/include/asm-nios2nommu/hw_irq.h
  19631. new file mode 100644
  19632. index 0000000..d2fd3be
  19633. --- /dev/null
  19634. +++ b/include/asm-nios2nommu/hw_irq.h
  19635. @@ -0,0 +1,16 @@
  19636. +#ifndef _ASM_HW_IRQ_H
  19637. +#define _ASM_HW_IRQ_H
  19638. +
  19639. +/*
  19640. + * linux/include/asm/hw_irq.h
  19641. + *
  19642. + * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
  19643. + *
  19644. + * moved some of the old arch/i386/kernel/irq.h to here. VY
  19645. + *
  19646. + * IRQ/IPI changes taken from work by Thomas Radke
  19647. + * <tomsoft@informatik.tu-chemnitz.de>
  19648. + */
  19649. +
  19650. +
  19651. +#endif /* _ASM_HW_IRQ_H */
  19652. diff --git a/include/asm-nios2nommu/ide.h b/include/asm-nios2nommu/ide.h
  19653. new file mode 100644
  19654. index 0000000..f8ef9ad
  19655. --- /dev/null
  19656. +++ b/include/asm-nios2nommu/ide.h
  19657. @@ -0,0 +1,40 @@
  19658. +/*
  19659. + * linux/include/asm-niosnommu2/ide.h
  19660. + *
  19661. + * Copyright (C) 1994-1996 Linus Torvalds & authors
  19662. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  19663. + *
  19664. + * All rights reserved.
  19665. + *
  19666. + * This program is free software; you can redistribute it and/or modify
  19667. + * it under the terms of the GNU General Public License as published by
  19668. + * the Free Software Foundation; either version 2 of the License, or
  19669. + * (at your option) any later version.
  19670. + *
  19671. + * This program is distributed in the hope that it will be useful, but
  19672. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  19673. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  19674. + * NON INFRINGEMENT. See the GNU General Public License for more
  19675. + * details.
  19676. + *
  19677. + * You should have received a copy of the GNU General Public License
  19678. + * along with this program; if not, write to the Free Software
  19679. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19680. + *
  19681. + */
  19682. +
  19683. +#ifndef __ASMNIOS2_IDE_H
  19684. +#define __ASMNIOS2_IDE_H
  19685. +
  19686. +#ifdef __KERNEL__
  19687. +#undef MAX_HWIFS /* we're going to force it */
  19688. +
  19689. +#ifndef MAX_HWIFS
  19690. +#define MAX_HWIFS 1
  19691. +#endif
  19692. +
  19693. +#include <asm-generic/ide_iops.h>
  19694. +
  19695. +#endif /* __KERNEL__ */
  19696. +
  19697. +#endif /* __ASMNIOS2_IDE_H */
  19698. diff --git a/include/asm-nios2nommu/init.h b/include/asm-nios2nommu/init.h
  19699. new file mode 100644
  19700. index 0000000..8641f4f
  19701. --- /dev/null
  19702. +++ b/include/asm-nios2nommu/init.h
  19703. @@ -0,0 +1,22 @@
  19704. +/*
  19705. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  19706. + *
  19707. + * All rights reserved.
  19708. + *
  19709. + * This program is free software; you can redistribute it and/or modify
  19710. + * it under the terms of the GNU General Public License as published by
  19711. + * the Free Software Foundation; either version 2 of the License, or
  19712. + * (at your option) any later version.
  19713. + *
  19714. + * This program is distributed in the hope that it will be useful, but
  19715. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  19716. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  19717. + * NON INFRINGEMENT. See the GNU General Public License for more
  19718. + * details.
  19719. + *
  19720. + * You should have received a copy of the GNU General Public License
  19721. + * along with this program; if not, write to the Free Software
  19722. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19723. + *
  19724. + */
  19725. +#error "<asm/init.h> should never be used - use <linux/init.h> instead"
  19726. diff --git a/include/asm-nios2nommu/io.h b/include/asm-nios2nommu/io.h
  19727. new file mode 100644
  19728. index 0000000..d0e3741
  19729. --- /dev/null
  19730. +++ b/include/asm-nios2nommu/io.h
  19731. @@ -0,0 +1,277 @@
  19732. +/*
  19733. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  19734. + *
  19735. + * All rights reserved.
  19736. + *
  19737. + * This program is free software; you can redistribute it and/or modify
  19738. + * it under the terms of the GNU General Public License as published by
  19739. + * the Free Software Foundation; either version 2 of the License, or
  19740. + * (at your option) any later version.
  19741. + *
  19742. + * This program is distributed in the hope that it will be useful, but
  19743. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  19744. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  19745. + * NON INFRINGEMENT. See the GNU General Public License for more
  19746. + * details.
  19747. + *
  19748. + * You should have received a copy of the GNU General Public License
  19749. + * along with this program; if not, write to the Free Software
  19750. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19751. + *
  19752. + */
  19753. +
  19754. +#ifndef __NIOS2_IO_H
  19755. +#define __NIOS2_IO_H
  19756. +
  19757. +#ifdef __KERNEL__
  19758. +
  19759. +#include <linux/kernel.h>
  19760. +
  19761. +#include <asm/page.h> /* IO address mapping routines need this */
  19762. +#include <asm/system.h>
  19763. +#include <asm/unaligned.h>
  19764. +
  19765. +extern void insw(unsigned long port, void *dst, unsigned long count);
  19766. +extern void outsw(unsigned long port, void *src, unsigned long count);
  19767. +extern void insl(unsigned long port, void *dst, unsigned long count);
  19768. +extern void outsl(unsigned long port, void *src, unsigned long count);
  19769. +
  19770. +#define readsb(p,d,l) insb(p,d,l)
  19771. +#define readsw(p,d,l) insw(p,d,l)
  19772. +#define readsl(p,d,l) insl(p,d,l)
  19773. +#define writesb(p,d,l) outsb(p,d,l)
  19774. +#define writesw(p,d,l) outsw(p,d,l)
  19775. +#define writesl(p,d,l) outsl(p,d,l)
  19776. +#ifndef irq_canonicalize
  19777. +#define irq_canonicalize(i) (i)
  19778. +#endif
  19779. +
  19780. +#endif /* __KERNEL__ */
  19781. +/* IO macros are needed by userspace programs */
  19782. +
  19783. +/*
  19784. + * readX/writeX() are used to access memory mapped devices. On some
  19785. + * architectures the memory mapped IO stuff needs to be accessed
  19786. + * differently. On the Nios architecture, we just read/write the
  19787. + * memory location directly.
  19788. + */
  19789. +
  19790. +#define readb(addr) \
  19791. +({ \
  19792. + unsigned char __res;\
  19793. + __asm__ __volatile__( \
  19794. + "ldbuio %0, 0(%1)" \
  19795. + : "=r"(__res) \
  19796. + : "r" (addr)); \
  19797. + __res; \
  19798. +})
  19799. +
  19800. +#define readw(addr) \
  19801. +({ \
  19802. + unsigned short __res;\
  19803. + __asm__ __volatile__( \
  19804. + "ldhuio %0, 0(%1)" \
  19805. + : "=r"(__res) \
  19806. + : "r" (addr)); \
  19807. + __res; \
  19808. +})
  19809. +
  19810. +#define readl(addr) \
  19811. +({ \
  19812. + unsigned int __res;\
  19813. + __asm__ __volatile__( \
  19814. + "ldwio %0, 0(%1)" \
  19815. + : "=r"(__res) \
  19816. + : "r" (addr)); \
  19817. + __res; \
  19818. +})
  19819. +
  19820. +#define writeb(b,addr) \
  19821. +({ \
  19822. + __asm__ __volatile__( \
  19823. + "stbio %0, 0(%1)" \
  19824. + : : "r"(b), "r" (addr)); \
  19825. +})
  19826. +
  19827. +#define writew(b,addr) \
  19828. +({ \
  19829. + __asm__ __volatile__( \
  19830. + "sthio %0, 0(%1)" \
  19831. + : : "r"(b), "r" (addr)); \
  19832. +})
  19833. +
  19834. +#define writel(b,addr) \
  19835. +({ \
  19836. + __asm__ __volatile__( \
  19837. + "stwio %0, 0(%1)" \
  19838. + : : "r"(b), "r" (addr)); \
  19839. +})
  19840. +
  19841. +#define __raw_readb readb
  19842. +#define __raw_readw readw
  19843. +#define __raw_readl readl
  19844. +#define __raw_writeb writeb
  19845. +#define __raw_writew writew
  19846. +#define __raw_writel writel
  19847. +
  19848. +#define mmiowb()
  19849. +
  19850. +/*
  19851. + * make the short names macros so specific devices
  19852. + * can override them as required
  19853. + */
  19854. +
  19855. +#define memset_io(addr,c,len) memset((void *)(((unsigned int)(addr)) | 0x80000000),(c),(len))
  19856. +#define memcpy_fromio(to,from,len) memcpy((to),(void *)(((unsigned int)(from)) | 0x80000000),(len))
  19857. +#define memcpy_toio(to,from,len) memcpy((void *)(((unsigned int)(to)) | 0x80000000),(from),(len))
  19858. +
  19859. +#define inb(addr) readb(addr)
  19860. +#define inw(addr) readw(addr)
  19861. +#define inl(addr) readl(addr)
  19862. +
  19863. +#define outb(x,addr) ((void) writeb(x,addr))
  19864. +#define outw(x,addr) ((void) writew(x,addr))
  19865. +#define outl(x,addr) ((void) writel(x,addr))
  19866. +
  19867. +#define inb_p(addr) inb(addr)
  19868. +#define inw_p(addr) inw(addr)
  19869. +#define inl_p(addr) inl(addr)
  19870. +
  19871. +#define outb_p(x,addr) outb(x,addr)
  19872. +#define outw_p(x,addr) outw(x,addr)
  19873. +#define outl_p(x,addr) outl(x,addr)
  19874. +
  19875. +/* IO macros are needed by userspace programs */
  19876. +#ifdef __KERNEL__
  19877. +
  19878. +extern inline void insb(unsigned long port, void *dst, unsigned long count)
  19879. +{
  19880. + unsigned char *p=(unsigned char*)dst;
  19881. + while (count--)
  19882. + *p++ = inb(port);
  19883. +}
  19884. +
  19885. +/* See arch/niosnommu/io.c for optimized version */
  19886. +extern inline void _insw(unsigned long port, void *dst, unsigned long count)
  19887. +{
  19888. + unsigned short *p=(unsigned short*)dst;
  19889. + while (count--)
  19890. + *p++ = inw(port);
  19891. +}
  19892. +
  19893. +/* See arch/niosnommu/kernel/io.c for unaligned destination pointer */
  19894. +extern inline void _insl(unsigned long port, void *dst, unsigned long count)
  19895. +{
  19896. + unsigned long *p=(unsigned long*)dst;
  19897. + while (count--)
  19898. + *p++ = inl(port);
  19899. +}
  19900. +
  19901. +extern inline void outsb(unsigned long port, void *src, unsigned long count)
  19902. +{
  19903. + unsigned char *p=(unsigned char*)src;
  19904. + while (count--)
  19905. + outb( *p++, port );
  19906. +}
  19907. +
  19908. +/* See arch/niosnommu/io.c for optimized version */
  19909. +extern inline void _outsw(unsigned long port, void *src, unsigned long count)
  19910. +{
  19911. + unsigned short *p=(unsigned short*)src;
  19912. + while (count--)
  19913. + outw( *p++, port );
  19914. +}
  19915. +
  19916. +/* See arch/niosnommu/kernel/io.c for unaligned source pointer */
  19917. +extern inline void _outsl(unsigned long port, void *src, unsigned long count)
  19918. +{
  19919. + unsigned long *p=(unsigned long*)src;
  19920. + while (count--)
  19921. + outl( *p++, port );
  19922. +}
  19923. +
  19924. +
  19925. +
  19926. +extern inline void mapioaddr(unsigned long physaddr, unsigned long virt_addr,
  19927. + int bus, int rdonly)
  19928. +{
  19929. + return;
  19930. +}
  19931. +
  19932. +//vic - copied from m68knommu
  19933. +
  19934. +/* Values for nocacheflag and cmode */
  19935. +#define IOMAP_FULL_CACHING 0
  19936. +#define IOMAP_NOCACHE_SER 1
  19937. +#define IOMAP_NOCACHE_NONSER 2
  19938. +#define IOMAP_WRITETHROUGH 3
  19939. +
  19940. +extern void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag);
  19941. +extern void __iounmap(void *addr, unsigned long size);
  19942. +
  19943. +extern inline void *ioremap(unsigned long physaddr, unsigned long size)
  19944. +{
  19945. + return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
  19946. +}
  19947. +extern inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
  19948. +{
  19949. + return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
  19950. +}
  19951. +extern inline void *ioremap_writethrough(unsigned long physaddr, unsigned long size)
  19952. +{
  19953. + return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
  19954. +}
  19955. +extern inline void *ioremap_fullcache(unsigned long physaddr, unsigned long size)
  19956. +{
  19957. + return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
  19958. +}
  19959. +
  19960. +extern void iounmap(void *addr);
  19961. +
  19962. +
  19963. +#define IO_SPACE_LIMIT 0xffffffff
  19964. +
  19965. +#define dma_cache_inv(_start,_size) dcache_push(_start,_size)
  19966. +#define dma_cache_wback(_start,_size) dcache_push(_start,_size)
  19967. +#define dma_cache_wback_inv(_start,_size) dcache_push(_start,_size)
  19968. +
  19969. +/* Pages to physical address... */
  19970. +#define page_to_phys(page) page_to_virt(page)
  19971. +#define page_to_bus(page) page_to_virt(page)
  19972. +
  19973. +#define mm_ptov(vaddr) ((void *) (vaddr))
  19974. +#define mm_vtop(vaddr) ((unsigned long) (vaddr))
  19975. +#define phys_to_virt(vaddr) ((void *) (vaddr))
  19976. +#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
  19977. +
  19978. +#define virt_to_bus virt_to_phys
  19979. +#define bus_to_virt phys_to_virt
  19980. +
  19981. +#define ioport_map(port, nr) ioremap(port, nr)
  19982. +#define ioport_unmap(port) iounmap(port)
  19983. +
  19984. +/*
  19985. + * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  19986. + * access
  19987. + */
  19988. +#define xlate_dev_mem_ptr(p) __va(p)
  19989. +
  19990. +/*
  19991. + * Convert a virtual cached pointer to an uncached pointer
  19992. + */
  19993. +#define xlate_dev_kmem_ptr(p) p
  19994. +
  19995. +#define readsb(p,d,l) insb(p,d,l)
  19996. +#define readsw(p,d,l) insw(p,d,l)
  19997. +#define readsl(p,d,l) insl(p,d,l)
  19998. +#define writesb(p,d,l) outsb(p,d,l)
  19999. +#define writesw(p,d,l) outsw(p,d,l)
  20000. +#define writesl(p,d,l) outsl(p,d,l)
  20001. +#ifndef irq_canonicalize
  20002. +#define irq_canonicalize(i) (i)
  20003. +#endif
  20004. +
  20005. +#endif /* __KERNEL__ */
  20006. +
  20007. +#endif /* !(__NIOS2_IO_H) */
  20008. +
  20009. diff --git a/include/asm-nios2nommu/ioctl.h b/include/asm-nios2nommu/ioctl.h
  20010. new file mode 100644
  20011. index 0000000..c02a36a
  20012. --- /dev/null
  20013. +++ b/include/asm-nios2nommu/ioctl.h
  20014. @@ -0,0 +1,100 @@
  20015. +/* $Id: ioctl.h,v 1.1 2006/07/05 06:20:25 gerg Exp $
  20016. + *
  20017. + * linux/ioctl.h for Linux by H.H. Bergman.
  20018. + *
  20019. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  20020. + *
  20021. + * All rights reserved.
  20022. + *
  20023. + * This program is free software; you can redistribute it and/or modify
  20024. + * it under the terms of the GNU General Public License as published by
  20025. + * the Free Software Foundation; either version 2 of the License, or
  20026. + * (at your option) any later version.
  20027. + *
  20028. + * This program is distributed in the hope that it will be useful, but
  20029. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  20030. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  20031. + * NON INFRINGEMENT. See the GNU General Public License for more
  20032. + * details.
  20033. + *
  20034. + * You should have received a copy of the GNU General Public License
  20035. + * along with this program; if not, write to the Free Software
  20036. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20037. + *
  20038. + */
  20039. +
  20040. +#ifndef _NIOS2_IOCTL_H
  20041. +#define _NIOS2_IOCTL_H
  20042. +
  20043. +/* ioctl command encoding: 32 bits total, command in lower 16 bits,
  20044. + * size of the parameter structure in the lower 14 bits of the
  20045. + * upper 16 bits.
  20046. + * Encoding the size of the parameter structure in the ioctl request
  20047. + * is useful for catching programs compiled with old versions
  20048. + * and to avoid overwriting user space outside the user buffer area.
  20049. + * The highest 2 bits are reserved for indicating the ``access mode''.
  20050. + * NOTE: This limits the max parameter size to 16kB -1 !
  20051. + */
  20052. +
  20053. +/*
  20054. + * I don't really have any idea about what this should look like, so
  20055. + * for the time being, this is heavily based on the PC definitions.
  20056. + */
  20057. +
  20058. +/*
  20059. + * The following is for compatibility across the various Linux
  20060. + * platforms. The i386 ioctl numbering scheme doesn't really enforce
  20061. + * a type field. De facto, however, the top 8 bits of the lower 16
  20062. + * bits are indeed used as a type field, so we might just as well make
  20063. + * this explicit here. Please be sure to use the decoding macros
  20064. + * below from now on.
  20065. + */
  20066. +#define _IOC_NRBITS 8
  20067. +#define _IOC_TYPEBITS 8
  20068. +#define _IOC_SIZEBITS 14
  20069. +#define _IOC_DIRBITS 2
  20070. +
  20071. +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
  20072. +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
  20073. +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
  20074. +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
  20075. +
  20076. +#define _IOC_NRSHIFT 0
  20077. +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
  20078. +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
  20079. +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
  20080. +
  20081. +/*
  20082. + * Direction bits.
  20083. + */
  20084. +#define _IOC_NONE 0U
  20085. +#define _IOC_WRITE 1U
  20086. +#define _IOC_READ 2U
  20087. +
  20088. +#define _IOC(dir,type,nr,size) \
  20089. + (((dir) << _IOC_DIRSHIFT) | \
  20090. + ((type) << _IOC_TYPESHIFT) | \
  20091. + ((nr) << _IOC_NRSHIFT) | \
  20092. + ((size) << _IOC_SIZESHIFT))
  20093. +
  20094. +/* used to create numbers */
  20095. +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
  20096. +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
  20097. +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
  20098. +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
  20099. +
  20100. +/* used to decode ioctl numbers.. */
  20101. +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
  20102. +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
  20103. +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
  20104. +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
  20105. +
  20106. +/* ...and for the drivers/sound files... */
  20107. +
  20108. +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
  20109. +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
  20110. +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
  20111. +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
  20112. +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
  20113. +
  20114. +#endif /* _NIOS2_IOCTL_H */
  20115. diff --git a/include/asm-nios2nommu/ioctls.h b/include/asm-nios2nommu/ioctls.h
  20116. new file mode 100644
  20117. index 0000000..288025c
  20118. --- /dev/null
  20119. +++ b/include/asm-nios2nommu/ioctls.h
  20120. @@ -0,0 +1,103 @@
  20121. +/*
  20122. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  20123. + *
  20124. + * All rights reserved.
  20125. + *
  20126. + * This program is free software; you can redistribute it and/or modify
  20127. + * it under the terms of the GNU General Public License as published by
  20128. + * the Free Software Foundation; either version 2 of the License, or
  20129. + * (at your option) any later version.
  20130. + *
  20131. + * This program is distributed in the hope that it will be useful, but
  20132. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  20133. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  20134. + * NON INFRINGEMENT. See the GNU General Public License for more
  20135. + * details.
  20136. + *
  20137. + * You should have received a copy of the GNU General Public License
  20138. + * along with this program; if not, write to the Free Software
  20139. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20140. + *
  20141. + */
  20142. +
  20143. +#ifndef __ARCH_NIOS2_IOCTLS_H__
  20144. +#define __ARCH_NIOS2_IOCTLS_H__
  20145. +
  20146. +#include <asm/ioctl.h>
  20147. +
  20148. +/* 0x54 is just a magic number to make these relatively unique ('T') */
  20149. +
  20150. +#define TCGETS 0x5401
  20151. +#define TCSETS 0x5402
  20152. +#define TCSETSW 0x5403
  20153. +#define TCSETSF 0x5404
  20154. +#define TCGETA 0x5405
  20155. +#define TCSETA 0x5406
  20156. +#define TCSETAW 0x5407
  20157. +#define TCSETAF 0x5408
  20158. +#define TCSBRK 0x5409
  20159. +#define TCXONC 0x540A
  20160. +#define TCFLSH 0x540B
  20161. +#define TIOCEXCL 0x540C
  20162. +#define TIOCNXCL 0x540D
  20163. +#define TIOCSCTTY 0x540E
  20164. +#define TIOCGPGRP 0x540F
  20165. +#define TIOCSPGRP 0x5410
  20166. +#define TIOCOUTQ 0x5411
  20167. +#define TIOCSTI 0x5412
  20168. +#define TIOCGWINSZ 0x5413
  20169. +#define TIOCSWINSZ 0x5414
  20170. +#define TIOCMGET 0x5415
  20171. +#define TIOCMBIS 0x5416
  20172. +#define TIOCMBIC 0x5417
  20173. +#define TIOCMSET 0x5418
  20174. +#define TIOCGSOFTCAR 0x5419
  20175. +#define TIOCSSOFTCAR 0x541A
  20176. +#define FIONREAD 0x541B
  20177. +#define TIOCINQ FIONREAD
  20178. +#define TIOCLINUX 0x541C
  20179. +#define TIOCCONS 0x541D
  20180. +#define TIOCGSERIAL 0x541E
  20181. +#define TIOCSSERIAL 0x541F
  20182. +#define TIOCPKT 0x5420
  20183. +#define FIONBIO 0x5421
  20184. +#define TIOCNOTTY 0x5422
  20185. +#define TIOCSETD 0x5423
  20186. +#define TIOCGETD 0x5424
  20187. +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
  20188. +#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
  20189. +#define TIOCSBRK 0x5427 /* BSD compatibility */
  20190. +#define TIOCCBRK 0x5428 /* BSD compatibility */
  20191. +#define TIOCGSID 0x5429 /* Return the session ID of FD */
  20192. +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
  20193. +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
  20194. +
  20195. +#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
  20196. +#define FIOCLEX 0x5451
  20197. +#define FIOASYNC 0x5452
  20198. +#define TIOCSERCONFIG 0x5453
  20199. +#define TIOCSERGWILD 0x5454
  20200. +#define TIOCSERSWILD 0x5455
  20201. +#define TIOCGLCKTRMIOS 0x5456
  20202. +#define TIOCSLCKTRMIOS 0x5457
  20203. +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
  20204. +#define TIOCSERGETLSR 0x5459 /* Get line status register */
  20205. +#define TIOCSERGETMULTI 0x545A /* Get multiport config */
  20206. +#define TIOCSERSETMULTI 0x545B /* Set multiport config */
  20207. +
  20208. +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
  20209. +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
  20210. +#define FIOQSIZE 0x545E
  20211. +
  20212. +/* Used for packet mode */
  20213. +#define TIOCPKT_DATA 0
  20214. +#define TIOCPKT_FLUSHREAD 1
  20215. +#define TIOCPKT_FLUSHWRITE 2
  20216. +#define TIOCPKT_STOP 4
  20217. +#define TIOCPKT_START 8
  20218. +#define TIOCPKT_NOSTOP 16
  20219. +#define TIOCPKT_DOSTOP 32
  20220. +
  20221. +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
  20222. +
  20223. +#endif /* __ARCH_NIOS2_IOCTLS_H__ */
  20224. diff --git a/include/asm-nios2nommu/ipc.h b/include/asm-nios2nommu/ipc.h
  20225. new file mode 100644
  20226. index 0000000..cb86a31
  20227. --- /dev/null
  20228. +++ b/include/asm-nios2nommu/ipc.h
  20229. @@ -0,0 +1,51 @@
  20230. +#ifndef __NIOS2_IPC_H__
  20231. +#define __NIOS2_IPC_H__
  20232. +
  20233. +/* Copied from sparc version
  20234. + * These are used to wrap system calls on the Nios.
  20235. + *
  20236. + * See arch/niosnommu/kernel/sys_nios.c for ugly details..
  20237. + *
  20238. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  20239. + *
  20240. + * All rights reserved.
  20241. + *
  20242. + * This program is free software; you can redistribute it and/or modify
  20243. + * it under the terms of the GNU General Public License as published by
  20244. + * the Free Software Foundation; either version 2 of the License, or
  20245. + * (at your option) any later version.
  20246. + *
  20247. + * This program is distributed in the hope that it will be useful, but
  20248. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  20249. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  20250. + * NON INFRINGEMENT. See the GNU General Public License for more
  20251. + * details.
  20252. + *
  20253. + * You should have received a copy of the GNU General Public License
  20254. + * along with this program; if not, write to the Free Software
  20255. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20256. + *
  20257. + */
  20258. +struct ipc_kludge {
  20259. + struct msgbuf *msgp;
  20260. + long msgtyp;
  20261. +};
  20262. +
  20263. +#define SEMOP 1
  20264. +#define SEMGET 2
  20265. +#define SEMCTL 3
  20266. +#define MSGSND 11
  20267. +#define MSGRCV 12
  20268. +#define MSGGET 13
  20269. +#define MSGCTL 14
  20270. +#define SHMAT 21
  20271. +#define SHMDT 22
  20272. +#define SHMGET 23
  20273. +#define SHMCTL 24
  20274. +
  20275. +/* Used by the DIPC package, try and avoid reusing it */
  20276. +#define DIPC 25
  20277. +
  20278. +#define IPCCALL(version,op) ((version)<<16 | (op))
  20279. +
  20280. +#endif
  20281. diff --git a/include/asm-nios2nommu/ipcbuf.h b/include/asm-nios2nommu/ipcbuf.h
  20282. new file mode 100644
  20283. index 0000000..ef59533
  20284. --- /dev/null
  20285. +++ b/include/asm-nios2nommu/ipcbuf.h
  20286. @@ -0,0 +1,49 @@
  20287. +#ifndef __NIOS2_IPCBUF_H__
  20288. +#define __NIOS2_IPCBUF_H__
  20289. +
  20290. +/* Copied from asm-m68k/ipcbuf.h
  20291. + * The user_ipc_perm structure for Nios architecture.
  20292. + * Note extra padding because this structure is passed back and forth
  20293. + * between kernel and user space.
  20294. + *
  20295. + * Pad space is left for:
  20296. + * - 32-bit mode_t and seq
  20297. + * - 2 miscellaneous 32-bit values
  20298. + *
  20299. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  20300. + *
  20301. + * All rights reserved.
  20302. + *
  20303. + * This program is free software; you can redistribute it and/or modify
  20304. + * it under the terms of the GNU General Public License as published by
  20305. + * the Free Software Foundation; either version 2 of the License, or
  20306. + * (at your option) any later version.
  20307. + *
  20308. + * This program is distributed in the hope that it will be useful, but
  20309. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  20310. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  20311. + * NON INFRINGEMENT. See the GNU General Public License for more
  20312. + * details.
  20313. + *
  20314. + * You should have received a copy of the GNU General Public License
  20315. + * along with this program; if not, write to the Free Software
  20316. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20317. + *
  20318. + */
  20319. +
  20320. +struct ipc64_perm
  20321. +{
  20322. + __kernel_key_t key;
  20323. + __kernel_uid32_t uid;
  20324. + __kernel_gid32_t gid;
  20325. + __kernel_uid32_t cuid;
  20326. + __kernel_gid32_t cgid;
  20327. + __kernel_mode_t mode;
  20328. + unsigned short __pad1;
  20329. + unsigned short seq;
  20330. + unsigned short __pad2;
  20331. + unsigned long __unused1;
  20332. + unsigned long __unused2;
  20333. +};
  20334. +
  20335. +#endif /* __NIOS2_IPCBUF_H__ */
  20336. diff --git a/include/asm-nios2nommu/irq.h b/include/asm-nios2nommu/irq.h
  20337. new file mode 100644
  20338. index 0000000..f0e37a2
  20339. --- /dev/null
  20340. +++ b/include/asm-nios2nommu/irq.h
  20341. @@ -0,0 +1,181 @@
  20342. +/*
  20343. + * 21Mar2001 1.1 dgt/microtronix
  20344. + *
  20345. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  20346. + *
  20347. + * All rights reserved.
  20348. + *
  20349. + * This program is free software; you can redistribute it and/or modify
  20350. + * it under the terms of the GNU General Public License as published by
  20351. + * the Free Software Foundation; either version 2 of the License, or
  20352. + * (at your option) any later version.
  20353. + *
  20354. + * This program is distributed in the hope that it will be useful, but
  20355. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  20356. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  20357. + * NON INFRINGEMENT. See the GNU General Public License for more
  20358. + * details.
  20359. + *
  20360. + * You should have received a copy of the GNU General Public License
  20361. + * along with this program; if not, write to the Free Software
  20362. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20363. + *
  20364. + */
  20365. +
  20366. +
  20367. +#ifndef _NIOS2NOMMU_IRQ_H_
  20368. +#define _NIOS2NOMMU_IRQ_H_
  20369. +
  20370. +extern void disable_irq(unsigned int);
  20371. +extern void enable_irq(unsigned int);
  20372. +
  20373. +#include <linux/interrupt.h>
  20374. +
  20375. +#define SYS_IRQS 32
  20376. +#define NR_IRQS SYS_IRQS
  20377. +
  20378. +/*
  20379. + * Interrupt source definitions
  20380. + * General interrupt sources are the level 1-7.
  20381. + * Adding an interrupt service routine for one of these sources
  20382. + * results in the addition of that routine to a chain of routines.
  20383. + * Each one is called in succession. Each individual interrupt
  20384. + * service routine should determine if the device associated with
  20385. + * that routine requires service.
  20386. + */
  20387. +
  20388. +#define IRQ01 (1) /* level 1 interrupt */
  20389. +#define IRQ02 (2) /* level 2 interrupt */
  20390. +#define IRQ03 (3) /* level 3 interrupt */
  20391. +#define IRQ04 (4) /* level 4 interrupt */
  20392. +#define IRQ05 (5) /* level 5 interrupt */
  20393. +#define IRQ06 (6) /* level 6 interrupt */
  20394. +#define IRQ07 (7) /* level 7 interrupt */
  20395. +#define IRQ08 (8) /* level 8 interrupt */
  20396. +#define IRQ09 (9) /* level 9 interrupt */
  20397. +#define IRQ0A (10) /* level 10 interrupt */
  20398. +#define IRQ0B (11) /* level 11 interrupt */
  20399. +#define IRQ0C (12) /* level 12 interrupt */
  20400. +#define IRQ0D (13) /* level 13 interrupt */
  20401. +#define IRQ0E (14) /* level 14 interrupt */
  20402. +#define IRQ0F (15) /* level 15 interrupt */
  20403. +#define IRQ10 (16) /* level 16 interrupt */
  20404. +#define IRQ12 (17) /* level 17 interrupt */
  20405. +#define IRQ13 (18) /* level 18 interrupt */
  20406. +#define IRQ14 (19) /* level 19 interrupt */
  20407. +#define IRQ15 (20) /* level 20 interrupt */
  20408. +#define IRQ16 (21) /* level 21 interrupt */
  20409. +#define IRQ17 (22) /* level 22 interrupt */
  20410. +#define IRQ18 (23) /* level 23 interrupt */
  20411. +#define IRQ19 (24) /* level 24 interrupt */
  20412. +#define IRQ1A (25) /* level 25 interrupt */
  20413. +#define IRQ1B (26) /* level 26 interrupt */
  20414. +#define IRQ1C (27) /* level 27 interrupt */
  20415. +#define IRQ1D (28) /* level 28 interrupt */
  20416. +#define IRQ1E (29) /* level 29 interrupt */
  20417. +#define IRQ1F (30) /* level 30 interrupt */
  20418. +#define IRQ20 (31) /* level 31 interrupt */
  20419. +#define IRQ21 (32) /* level 32 interrupt */
  20420. +
  20421. +#define IRQMAX IRQ21
  20422. +
  20423. +/*
  20424. + * "Generic" interrupt sources
  20425. + */
  20426. +
  20427. +/*
  20428. + * Machine specific interrupt sources.
  20429. + *
  20430. + * Adding an interrupt service routine for a source with this bit
  20431. + * set indicates a special machine specific interrupt source.
  20432. + * The machine specific files define these sources.
  20433. + *
  20434. + * Removed, they are not used by any one.
  20435. + */
  20436. +
  20437. +/*
  20438. + * various flags for request_irq()
  20439. + */
  20440. +#define IRQ_FLG_LOCK (0x0001) /* handler is not replaceable */
  20441. +#define IRQ_FLG_REPLACE (0x0002) /* replace existing handler */
  20442. +#define IRQ_FLG_FAST (0x0004)
  20443. +#define IRQ_FLG_SLOW (0x0008)
  20444. +#define IRQ_FLG_STD (0x8000) /* internally used */
  20445. +
  20446. +/*
  20447. + * Functions to set and clear the interrupt mask.
  20448. + */
  20449. +
  20450. +/*
  20451. + * Use a zero to clean the bit.
  20452. + */
  20453. +static inline void clrimr(int mask)
  20454. +{
  20455. + int flags;
  20456. +
  20457. + local_irq_save(flags);
  20458. + __asm__ __volatile__(
  20459. + "rdctl r8, ienable\n"
  20460. + "and r8,r8,%0\n"
  20461. + "wrctl ienable, r8\n"
  20462. + : /* No output */
  20463. + : "r" (mask)
  20464. + : "r8");
  20465. + local_irq_restore(flags);
  20466. +}
  20467. +
  20468. +/*
  20469. + * Use a one to set the bit.
  20470. + */
  20471. +static inline void setimr(int mask)
  20472. +{
  20473. + int flags;
  20474. +
  20475. + local_irq_save(flags);
  20476. + __asm__ __volatile__(
  20477. + "rdctl r8, ienable\n"
  20478. + "or r8,r8,%0\n"
  20479. + "wrctl ienable, r8\n"
  20480. + : /* No output */
  20481. + : "r" (mask)
  20482. + : "r8");
  20483. + local_irq_restore(flags);
  20484. +}
  20485. +
  20486. +/*
  20487. + * This structure is used to chain together the ISRs for a particular
  20488. + * interrupt source (if it supports chaining).
  20489. + */
  20490. +typedef struct irq_node {
  20491. + irq_handler_t handler;
  20492. + unsigned long flags;
  20493. + void *dev_id;
  20494. + const char *devname;
  20495. + struct irq_node *next;
  20496. +} irq_node_t;
  20497. +
  20498. +/*
  20499. + * This function returns a new irq_node_t
  20500. + */
  20501. +extern irq_node_t *new_irq_node(void);
  20502. +
  20503. +/*
  20504. + * This structure has only 4 elements for speed reasons
  20505. + */
  20506. +typedef struct irq_hand {
  20507. + irq_handler_t handler;
  20508. + unsigned long flags;
  20509. + void *dev_id;
  20510. + const char *devname;
  20511. +} irq_hand_t;
  20512. +
  20513. +/* count of spurious interrupts */
  20514. +extern volatile unsigned int num_spurious;
  20515. +
  20516. +#define disable_irq_nosync(i) disable_irq(i)
  20517. +
  20518. +#ifndef irq_canonicalize
  20519. +#define irq_canonicalize(i) (i)
  20520. +#endif
  20521. +
  20522. +#endif /* _NIOS2NOMMU_IRQ_H_ */
  20523. diff --git a/include/asm-nios2nommu/irq_node.h b/include/asm-nios2nommu/irq_node.h
  20524. new file mode 100644
  20525. index 0000000..24f9763
  20526. --- /dev/null
  20527. +++ b/include/asm-nios2nommu/irq_node.h
  20528. @@ -0,0 +1,36 @@
  20529. +#ifndef _NIOS2NOMMU_IRQNODE_H_
  20530. +#define _NIOS2NOMMU_IRQNODE_H_
  20531. +
  20532. +#include <linux/interrupt.h>
  20533. +
  20534. +/*
  20535. + * This structure is used to chain together the ISRs for a particular
  20536. + * interrupt source (if it supports chaining).
  20537. + */
  20538. +typedef struct irq_node {
  20539. + irqreturn_t (*handler)(int, void *, struct pt_regs *);
  20540. + unsigned long flags;
  20541. + void *dev_id;
  20542. + const char *devname;
  20543. + struct irq_node *next;
  20544. +} irq_node_t;
  20545. +
  20546. +/*
  20547. + * This structure has only 4 elements for speed reasons
  20548. + */
  20549. +typedef struct irq_handler {
  20550. + irqreturn_t (*handler)(int, void *, struct pt_regs *);
  20551. + unsigned long flags;
  20552. + void *dev_id;
  20553. + const char *devname;
  20554. +} irq_handler_t;
  20555. +
  20556. +/* count of spurious interrupts */
  20557. +extern volatile unsigned int num_spurious;
  20558. +
  20559. +/*
  20560. + * This function returns a new irq_node_t
  20561. + */
  20562. +extern irq_node_t *new_irq_node(void);
  20563. +
  20564. +#endif /* _NIOS2NOMMU_IRQNODE_H_ */
  20565. diff --git a/include/asm-nios2nommu/irq_regs.h b/include/asm-nios2nommu/irq_regs.h
  20566. new file mode 100644
  20567. index 0000000..3dd9c0b
  20568. --- /dev/null
  20569. +++ b/include/asm-nios2nommu/irq_regs.h
  20570. @@ -0,0 +1 @@
  20571. +#include <asm-generic/irq_regs.h>
  20572. diff --git a/include/asm-nios2nommu/kdebug.h b/include/asm-nios2nommu/kdebug.h
  20573. new file mode 100644
  20574. index 0000000..6ece1b0
  20575. --- /dev/null
  20576. +++ b/include/asm-nios2nommu/kdebug.h
  20577. @@ -0,0 +1 @@
  20578. +#include <asm-generic/kdebug.h>
  20579. diff --git a/include/asm-nios2nommu/kmap_types.h b/include/asm-nios2nommu/kmap_types.h
  20580. new file mode 100644
  20581. index 0000000..a26b91d
  20582. --- /dev/null
  20583. +++ b/include/asm-nios2nommu/kmap_types.h
  20584. @@ -0,0 +1,43 @@
  20585. +/*
  20586. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  20587. + *
  20588. + * All rights reserved.
  20589. + *
  20590. + * This program is free software; you can redistribute it and/or modify
  20591. + * it under the terms of the GNU General Public License as published by
  20592. + * the Free Software Foundation; either version 2 of the License, or
  20593. + * (at your option) any later version.
  20594. + *
  20595. + * This program is distributed in the hope that it will be useful, but
  20596. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  20597. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  20598. + * NON INFRINGEMENT. See the GNU General Public License for more
  20599. + * details.
  20600. + *
  20601. + * You should have received a copy of the GNU General Public License
  20602. + * along with this program; if not, write to the Free Software
  20603. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20604. + *
  20605. + */
  20606. +
  20607. +#ifndef _ASM_KMAP_TYPES_H
  20608. +#define _ASM_KMAP_TYPES_H
  20609. +
  20610. +enum km_type {
  20611. + KM_BOUNCE_READ,
  20612. + KM_SKB_SUNRPC_DATA,
  20613. + KM_SKB_DATA_SOFTIRQ,
  20614. + KM_USER0,
  20615. + KM_USER1,
  20616. + KM_BIO_SRC_IRQ,
  20617. + KM_BIO_DST_IRQ,
  20618. + KM_PTE0,
  20619. + KM_PTE1,
  20620. + KM_IRQ0,
  20621. + KM_IRQ1,
  20622. + KM_SOFTIRQ0,
  20623. + KM_SOFTIRQ1,
  20624. + KM_TYPE_NR
  20625. +};
  20626. +
  20627. +#endif
  20628. diff --git a/include/asm-nios2nommu/linkage.h b/include/asm-nios2nommu/linkage.h
  20629. new file mode 100644
  20630. index 0000000..db79297
  20631. --- /dev/null
  20632. +++ b/include/asm-nios2nommu/linkage.h
  20633. @@ -0,0 +1,29 @@
  20634. +/*
  20635. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  20636. + *
  20637. + * All rights reserved.
  20638. + *
  20639. + * This program is free software; you can redistribute it and/or modify
  20640. + * it under the terms of the GNU General Public License as published by
  20641. + * the Free Software Foundation; either version 2 of the License, or
  20642. + * (at your option) any later version.
  20643. + *
  20644. + * This program is distributed in the hope that it will be useful, but
  20645. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  20646. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  20647. + * NON INFRINGEMENT. See the GNU General Public License for more
  20648. + * details.
  20649. + *
  20650. + * You should have received a copy of the GNU General Public License
  20651. + * along with this program; if not, write to the Free Software
  20652. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20653. + *
  20654. + */
  20655. +
  20656. +#ifndef __ASM_LINKAGE_H
  20657. +#define __ASM_LINKAGE_H
  20658. +
  20659. +#define __ALIGN .align 3
  20660. +#define __ALIGN_STR ".align 3"
  20661. +
  20662. +#endif
  20663. diff --git a/include/asm-nios2nommu/linux_logo.h b/include/asm-nios2nommu/linux_logo.h
  20664. new file mode 100644
  20665. index 0000000..f9d38e7
  20666. --- /dev/null
  20667. +++ b/include/asm-nios2nommu/linux_logo.h
  20668. @@ -0,0 +1,953 @@
  20669. +/* $Id: linux_logo.h,v 1.1 2006/07/05 06:20:25 gerg Exp $
  20670. + * include/asm-nios/linux_logo.h: This is a linux logo
  20671. + * to be displayed on boot.
  20672. + *
  20673. + * Copyright (C) 1996 Larry Ewing (lewing@isc.tamu.edu)
  20674. + * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  20675. + * Copyright (C) 2004 Micrtronix Datacom Ltd.
  20676. + *
  20677. + * You can put anything here, but:
  20678. + * LINUX_LOGO_COLORS has to be less than 224
  20679. + * image size has to be 80x80
  20680. + * values have to start from 0x20
  20681. + * (i.e. RGB(linux_logo_red[0],
  20682. + * linux_logo_green[0],
  20683. + * linux_logo_blue[0]) is color 0x20)
  20684. + * BW image has to be 80x80 as well, with MS bit
  20685. + * on the left
  20686. + * Serial_console ascii image can be any size,
  20687. + * but should contain %s to display the version
  20688. + *
  20689. + * All rights reserved.
  20690. + *
  20691. + * This program is free software; you can redistribute it and/or modify
  20692. + * it under the terms of the GNU General Public License as published by
  20693. + * the Free Software Foundation; either version 2 of the License, or
  20694. + * (at your option) any later version.
  20695. + *
  20696. + * This program is distributed in the hope that it will be useful, but
  20697. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  20698. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  20699. + * NON INFRINGEMENT. See the GNU General Public License for more
  20700. + * details.
  20701. + *
  20702. + * You should have received a copy of the GNU General Public License
  20703. + * along with this program; if not, write to the Free Software
  20704. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20705. + *
  20706. + */
  20707. +
  20708. +#include <linux/init.h>
  20709. +#include <linux/version.h>
  20710. +
  20711. +#define linux_logo_banner "Linux/NIOS2 version " UTS_RELEASE
  20712. +
  20713. +#define __HAVE_ARCH_LINUX_LOGO
  20714. +#define __HAVE_ARCH_LINUX_LOGO16
  20715. +
  20716. +#define LINUX_LOGO_COLORS 221
  20717. +
  20718. +#ifdef INCLUDE_LINUX_LOGO_DATA
  20719. +
  20720. +unsigned char linux_logo_red[] __initdata = {
  20721. + 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
  20722. + 0x12, 0x00, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
  20723. + 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x02, 0x65,
  20724. + 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
  20725. + 0xc3, 0x65, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
  20726. + 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
  20727. + 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x76, 0x79,
  20728. + 0x62, 0x36, 0x9a, 0xe2, 0xec, 0xe1, 0xb8, 0xd7,
  20729. + 0xaf, 0x25, 0xbc, 0xc0, 0xef, 0xea, 0xe8, 0xe8,
  20730. + 0xf5, 0xf1, 0xda, 0xd3, 0x79, 0xdb, 0xf4, 0xf6,
  20731. + 0xf6, 0xf6, 0xe2, 0x3d, 0xb4, 0xce, 0xe6, 0xee,
  20732. + 0xf6, 0x68, 0xd8, 0xec, 0xf5, 0xc6, 0xc8, 0x9c,
  20733. + 0x89, 0xd2, 0xee, 0xcb, 0xb9, 0xd2, 0x66, 0x5e,
  20734. + 0x8b, 0xbe, 0xa8, 0xd5, 0xca, 0xb6, 0xae, 0x9c,
  20735. + 0xc5, 0xbe, 0xbe, 0xca, 0x90, 0xb2, 0x9a, 0xa8,
  20736. + 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xfe,
  20737. + 0xf6, 0xec, 0xfe, 0xd2, 0xea, 0xf5, 0xf2, 0xf2,
  20738. + 0xe9, 0xee, 0xf6, 0xf2, 0xee, 0xf6, 0xda, 0xd4,
  20739. + 0xfa, 0xca, 0xf2, 0xf6, 0xfe, 0xf2, 0xda, 0xe4,
  20740. + 0xf6, 0xdd, 0xf2, 0xee, 0xfa, 0xf0, 0x12, 0x4a,
  20741. + 0xd6, 0xf2, 0x8e, 0xf2, 0xf6, 0xf6, 0xb5, 0xf1,
  20742. + 0x26, 0x9a, 0xea, 0xf6, 0xe0, 0xd2, 0x16, 0x9a,
  20743. + 0x2e, 0xd2, 0x70, 0xd6, 0x46, 0x7c, 0xb4, 0x62,
  20744. + 0xda, 0xee, 0xd6, 0xa3, 0x74, 0xa7, 0xa2, 0xe0,
  20745. + 0xae, 0xbe, 0xce, 0xe2, 0xa3, 0x8e, 0x6d, 0x8e,
  20746. + 0x32, 0xaf, 0x50, 0x9e, 0x5b, 0x8a, 0x98, 0x82,
  20747. + 0x7a, 0x82, 0x56, 0x7c, 0x8a, 0x56, 0x5e, 0x86,
  20748. + 0x6a, 0x52, 0x59, 0x64, 0x5e,
  20749. +};
  20750. +
  20751. +unsigned char linux_logo_green[] __initdata = {
  20752. + 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
  20753. + 0x12, 0x00, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
  20754. + 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x02, 0x65,
  20755. + 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
  20756. + 0xc3, 0x62, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
  20757. + 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
  20758. + 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x62, 0x5c,
  20759. + 0x4e, 0x26, 0x72, 0xaa, 0xba, 0xaf, 0x90, 0xae,
  20760. + 0x92, 0x1a, 0xa4, 0x85, 0xb6, 0xbe, 0xc3, 0xc8,
  20761. + 0xcf, 0xd0, 0xc2, 0xce, 0x57, 0xa2, 0xd6, 0xda,
  20762. + 0xda, 0xd7, 0xb8, 0x2a, 0x7b, 0x91, 0xae, 0xca,
  20763. + 0xda, 0x45, 0x9e, 0xb2, 0xd7, 0x9b, 0x90, 0x76,
  20764. + 0x5c, 0xa2, 0xbe, 0xa6, 0x85, 0x96, 0x4e, 0x46,
  20765. + 0x66, 0x92, 0x7a, 0x9a, 0x96, 0x9d, 0x9a, 0x6b,
  20766. + 0x8a, 0x8e, 0xb2, 0xca, 0x90, 0xa6, 0x79, 0x7c,
  20767. + 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xfa,
  20768. + 0xea, 0xd7, 0xf6, 0xbc, 0xda, 0xde, 0xda, 0xe6,
  20769. + 0xca, 0xd8, 0xea, 0xe0, 0xcc, 0xf2, 0xce, 0xb2,
  20770. + 0xee, 0xa2, 0xd6, 0xe6, 0xf6, 0xd7, 0xc5, 0xb8,
  20771. + 0xc6, 0xb9, 0xce, 0xde, 0xce, 0xc6, 0x0e, 0x36,
  20772. + 0xae, 0xbe, 0x86, 0xba, 0xbe, 0xe6, 0x8e, 0xc4,
  20773. + 0x1e, 0x8e, 0xae, 0xba, 0xb2, 0xa6, 0x12, 0x7a,
  20774. + 0x20, 0xc6, 0x64, 0xaa, 0x2f, 0x70, 0x85, 0x46,
  20775. + 0xce, 0xd6, 0xa6, 0x6e, 0x51, 0x72, 0x92, 0xa6,
  20776. + 0x87, 0x96, 0xa2, 0xd6, 0x85, 0x7a, 0x6a, 0x6e,
  20777. + 0x22, 0x76, 0x36, 0x76, 0x3c, 0x6e, 0x63, 0x53,
  20778. + 0x66, 0x62, 0x42, 0x50, 0x56, 0x42, 0x56, 0x56,
  20779. + 0x56, 0x3e, 0x51, 0x52, 0x56,
  20780. +};
  20781. +
  20782. +unsigned char linux_logo_blue[] __initdata = {
  20783. + 0x00, 0x06, 0x0a, 0x0e, 0x16, 0x1a, 0x1e, 0x22,
  20784. + 0x12, 0x01, 0x2a, 0x36, 0x42, 0x4e, 0x4a, 0x56,
  20785. + 0x26, 0x46, 0x2e, 0x32, 0x52, 0x3a, 0x06, 0x65,
  20786. + 0x5e, 0x3e, 0x74, 0x8a, 0xa2, 0x9a, 0x86, 0xc6,
  20787. + 0xc3, 0x59, 0xbb, 0xd2, 0xda, 0xd6, 0xe2, 0xf6,
  20788. + 0xfd, 0xae, 0x7b, 0xdd, 0xea, 0x6a, 0xaa, 0xe7,
  20789. + 0xbe, 0x5a, 0xee, 0x9e, 0x95, 0x80, 0x2e, 0x08,
  20790. + 0x0a, 0x06, 0x0a, 0x0b, 0x0b, 0x0f, 0x0c, 0x0f,
  20791. + 0x3d, 0x09, 0x73, 0x09, 0x0d, 0x0a, 0x10, 0x1e,
  20792. + 0x2d, 0x13, 0x86, 0xba, 0x19, 0x0a, 0x36, 0x3c,
  20793. + 0x26, 0x14, 0x0d, 0x06, 0x07, 0x0a, 0x0b, 0x0f,
  20794. + 0x4a, 0x06, 0x0a, 0x0c, 0x2b, 0x0a, 0x0b, 0x0a,
  20795. + 0x06, 0x0a, 0x0a, 0x11, 0x0b, 0x0a, 0x0a, 0x1e,
  20796. + 0x0f, 0x0d, 0x0a, 0x0b, 0x22, 0x6a, 0x72, 0x0b,
  20797. + 0x0b, 0x22, 0x90, 0xca, 0x90, 0x92, 0x3c, 0x2c,
  20798. + 0xb6, 0xf2, 0xce, 0xfa, 0xb2, 0x6e, 0xa6, 0xea,
  20799. + 0xb6, 0x7c, 0xda, 0x8e, 0xa6, 0x87, 0x66, 0xb6,
  20800. + 0x81, 0x6a, 0xc6, 0x9a, 0x5b, 0xd2, 0xb6, 0x6a,
  20801. + 0xca, 0x45, 0x92, 0xb2, 0xca, 0x52, 0x8a, 0x3e,
  20802. + 0x2e, 0x66, 0x66, 0xae, 0x3e, 0x47, 0x06, 0x0e,
  20803. + 0x52, 0x36, 0x6a, 0x0e, 0x0e, 0xbe, 0x2c, 0x0e,
  20804. + 0x0a, 0x5a, 0x0d, 0x0e, 0x3e, 0x0a, 0x06, 0x2e,
  20805. + 0x06, 0x9e, 0x4e, 0x36, 0x06, 0x58, 0x24, 0x06,
  20806. + 0x9e, 0xae, 0x3a, 0x08, 0x08, 0x07, 0x5e, 0x0a,
  20807. + 0x32, 0x2e, 0x2a, 0xb2, 0x43, 0x48, 0x5f, 0x2e,
  20808. + 0x06, 0x06, 0x07, 0x24, 0x06, 0x32, 0x06, 0x06,
  20809. + 0x46, 0x2e, 0x22, 0x06, 0x06, 0x1e, 0x4c, 0x06,
  20810. + 0x3a, 0x22, 0x42, 0x34, 0x42,
  20811. +};
  20812. +
  20813. +unsigned char linux_logo[] __initdata = {
  20814. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20815. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20816. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20817. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20818. + 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22,
  20819. + 0x22, 0x21, 0x21, 0x21, 0x20, 0x20, 0x20, 0x20,
  20820. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20821. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20822. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20823. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20824. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20825. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20826. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20827. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20828. + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
  20829. + 0x26, 0x26, 0x25, 0x28, 0x23, 0x22, 0x21, 0x20,
  20830. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20831. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20832. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20833. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20834. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
  20835. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20836. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20837. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20838. + 0x21, 0x23, 0x25, 0x2a, 0x2b, 0x2c, 0x2d, 0x2d,
  20839. + 0x2d, 0x2e, 0x2c, 0x2b, 0x2a, 0x25, 0x28, 0x22,
  20840. + 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20841. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20842. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20843. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20844. + 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
  20845. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20846. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20847. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
  20848. + 0x24, 0x2a, 0x2c, 0x2f, 0x2c, 0x30, 0x30, 0x24,
  20849. + 0x25, 0x27, 0x2b, 0x2c, 0x2f, 0x31, 0x32, 0x25,
  20850. + 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20851. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20852. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20853. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20854. + 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
  20855. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20856. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20857. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x25,
  20858. + 0x33, 0x34, 0x35, 0x21, 0x36, 0x36, 0x36, 0x36,
  20859. + 0x36, 0x36, 0x36, 0x36, 0x21, 0x2b, 0x2f, 0x2c,
  20860. + 0x30, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
  20861. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20862. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20863. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20864. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20865. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20866. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20867. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24, 0x33,
  20868. + 0x2d, 0x27, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  20869. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x31,
  20870. + 0x2d, 0x32, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
  20871. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20872. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20873. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20874. + 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
  20875. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20876. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20877. + 0x20, 0x20, 0x20, 0x20, 0x21, 0x28, 0x2a, 0x34,
  20878. + 0x25, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  20879. + 0x36, 0x36, 0x36, 0x23, 0x32, 0x27, 0x21, 0x36,
  20880. + 0x2a, 0x2d, 0x2a, 0x28, 0x21, 0x20, 0x20, 0x20,
  20881. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20882. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20883. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20884. + 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x29, 0x20,
  20885. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20886. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20887. + 0x20, 0x20, 0x20, 0x20, 0x22, 0x26, 0x2c, 0x35,
  20888. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  20889. + 0x36, 0x36, 0x36, 0x25, 0x2f, 0x37, 0x32, 0x22,
  20890. + 0x36, 0x35, 0x31, 0x27, 0x22, 0x20, 0x20, 0x20,
  20891. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20892. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20893. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20894. + 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
  20895. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20896. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20897. + 0x20, 0x20, 0x20, 0x20, 0x23, 0x2a, 0x2f, 0x22,
  20898. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  20899. + 0x36, 0x36, 0x36, 0x26, 0x38, 0x38, 0x35, 0x25,
  20900. + 0x36, 0x21, 0x2d, 0x2b, 0x24, 0x21, 0x20, 0x20,
  20901. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20902. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20903. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20904. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20905. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20906. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20907. + 0x20, 0x20, 0x20, 0x21, 0x24, 0x39, 0x39, 0x36,
  20908. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  20909. + 0x36, 0x36, 0x36, 0x25, 0x2b, 0x30, 0x28, 0x22,
  20910. + 0x36, 0x36, 0x27, 0x34, 0x30, 0x23, 0x20, 0x20,
  20911. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20912. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20913. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20914. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
  20915. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20916. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20917. + 0x20, 0x20, 0x20, 0x21, 0x26, 0x2d, 0x26, 0x36,
  20918. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  20919. + 0x36, 0x36, 0x36, 0x22, 0x22, 0x36, 0x36, 0x36,
  20920. + 0x36, 0x36, 0x36, 0x2d, 0x33, 0x28, 0x21, 0x20,
  20921. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20922. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20923. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20924. + 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
  20925. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20926. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20927. + 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x23, 0x36,
  20928. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  20929. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  20930. + 0x36, 0x36, 0x36, 0x2b, 0x2c, 0x25, 0x21, 0x20,
  20931. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20932. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20933. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20934. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x20,
  20935. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20936. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20937. + 0x20, 0x20, 0x20, 0x23, 0x2a, 0x34, 0x36, 0x36,
  20938. + 0x36, 0x21, 0x22, 0x36, 0x36, 0x36, 0x36, 0x36,
  20939. + 0x36, 0x36, 0x36, 0x21, 0x23, 0x22, 0x36, 0x36,
  20940. + 0x36, 0x36, 0x36, 0x28, 0x34, 0x27, 0x22, 0x20,
  20941. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20942. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20943. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20944. + 0x20, 0x20, 0x20, 0x20, 0x29, 0x20, 0x20, 0x20,
  20945. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20946. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20947. + 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x36,
  20948. + 0x21, 0x21, 0x24, 0x27, 0x21, 0x36, 0x36, 0x36,
  20949. + 0x36, 0x36, 0x28, 0x27, 0x22, 0x33, 0x24, 0x36,
  20950. + 0x36, 0x36, 0x36, 0x22, 0x2f, 0x2a, 0x23, 0x20,
  20951. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20952. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20953. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20954. + 0x20, 0x20, 0x20, 0x20, 0x29, 0x29, 0x29, 0x20,
  20955. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20956. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20957. + 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x36,
  20958. + 0x30, 0x3a, 0x38, 0x24, 0x24, 0x36, 0x36, 0x36,
  20959. + 0x23, 0x2f, 0x3b, 0x3c, 0x3d, 0x30, 0x25, 0x21,
  20960. + 0x36, 0x36, 0x36, 0x36, 0x2f, 0x32, 0x23, 0x20,
  20961. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20962. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20963. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20964. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20965. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20966. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20967. + 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x23,
  20968. + 0x3e, 0x3f, 0x40, 0x3a, 0x22, 0x36, 0x36, 0x21,
  20969. + 0x41, 0x42, 0x43, 0x44, 0x45, 0x3e, 0x23, 0x21,
  20970. + 0x36, 0x36, 0x36, 0x36, 0x2f, 0x33, 0x28, 0x21,
  20971. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20972. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20973. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20974. + 0x20, 0x20, 0x29, 0x20, 0x29, 0x29, 0x29, 0x20,
  20975. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20976. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20977. + 0x20, 0x20, 0x20, 0x23, 0x32, 0x2f, 0x36, 0x2b,
  20978. + 0x44, 0x40, 0x46, 0x47, 0x35, 0x36, 0x36, 0x26,
  20979. + 0x43, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x2e, 0x36,
  20980. + 0x36, 0x36, 0x36, 0x36, 0x31, 0x35, 0x24, 0x21,
  20981. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20982. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20983. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20984. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20985. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20986. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20987. + 0x20, 0x20, 0x20, 0x23, 0x32, 0x34, 0x36, 0x4d,
  20988. + 0x4e, 0x25, 0x2f, 0x46, 0x4a, 0x22, 0x23, 0x32,
  20989. + 0x4f, 0x50, 0x21, 0x31, 0x51, 0x52, 0x53, 0x36,
  20990. + 0x36, 0x36, 0x36, 0x36, 0x31, 0x35, 0x24, 0x21,
  20991. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20992. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20993. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20994. + 0x20, 0x20, 0x29, 0x20, 0x29, 0x29, 0x29, 0x20,
  20995. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20996. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  20997. + 0x20, 0x20, 0x20, 0x23, 0x2a, 0x2f, 0x21, 0x3a,
  20998. + 0x4d, 0x21, 0x31, 0x54, 0x55, 0x28, 0x30, 0x2b,
  20999. + 0x4b, 0x4d, 0x36, 0x23, 0x32, 0x50, 0x3f, 0x36,
  21000. + 0x36, 0x36, 0x36, 0x36, 0x2e, 0x39, 0x24, 0x21,
  21001. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21002. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21003. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21004. + 0x20, 0x20, 0x29, 0x20, 0x29, 0x20, 0x29, 0x20,
  21005. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21006. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21007. + 0x20, 0x20, 0x20, 0x23, 0x2a, 0x38, 0x23, 0x37,
  21008. + 0x55, 0x36, 0x28, 0x3a, 0x56, 0x57, 0x57, 0x58,
  21009. + 0x3c, 0x4d, 0x36, 0x36, 0x36, 0x40, 0x40, 0x21,
  21010. + 0x36, 0x36, 0x36, 0x36, 0x2e, 0x39, 0x24, 0x21,
  21011. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21012. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21013. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21014. + 0x20, 0x20, 0x29, 0x29, 0x29, 0x20, 0x29, 0x20,
  21015. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21016. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21017. + 0x20, 0x20, 0x20, 0x22, 0x30, 0x51, 0x23, 0x35,
  21018. + 0x43, 0x25, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e,
  21019. + 0x5f, 0x60, 0x61, 0x36, 0x31, 0x47, 0x3b, 0x36,
  21020. + 0x36, 0x36, 0x36, 0x36, 0x31, 0x2c, 0x25, 0x21,
  21021. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21022. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21023. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21024. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21025. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21026. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21027. + 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x23, 0x22,
  21028. + 0x40, 0x62, 0x63, 0x5d, 0x64, 0x65, 0x66, 0x67,
  21029. + 0x68, 0x69, 0x66, 0x5e, 0x6a, 0x6b, 0x2a, 0x36,
  21030. + 0x36, 0x36, 0x36, 0x36, 0x33, 0x2e, 0x26, 0x21,
  21031. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21032. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21033. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21034. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21035. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21036. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21037. + 0x20, 0x20, 0x20, 0x22, 0x27, 0x2f, 0x23, 0x36,
  21038. + 0x6c, 0x63, 0x6d, 0x64, 0x5c, 0x66, 0x69, 0x6e,
  21039. + 0x6f, 0x70, 0x71, 0x69, 0x69, 0x72, 0x6c, 0x36,
  21040. + 0x36, 0x36, 0x36, 0x36, 0x33, 0x34, 0x27, 0x22,
  21041. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21042. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21043. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21044. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21045. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21046. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21047. + 0x20, 0x20, 0x20, 0x22, 0x27, 0x34, 0x26, 0x73,
  21048. + 0x74, 0x75, 0x76, 0x64, 0x65, 0x77, 0x69, 0x78,
  21049. + 0x70, 0x71, 0x71, 0x71, 0x72, 0x5f, 0x5e, 0x21,
  21050. + 0x36, 0x36, 0x36, 0x36, 0x25, 0x38, 0x2a, 0x23,
  21051. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21052. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21053. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21054. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21055. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21056. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21057. + 0x20, 0x20, 0x20, 0x22, 0x26, 0x2d, 0x33, 0x79,
  21058. + 0x63, 0x7a, 0x7b, 0x5c, 0x66, 0x69, 0x6e, 0x7c,
  21059. + 0x71, 0x71, 0x69, 0x7d, 0x7e, 0x7a, 0x7f, 0x36,
  21060. + 0x36, 0x36, 0x36, 0x36, 0x21, 0x51, 0x2b, 0x28,
  21061. + 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21062. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21063. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21064. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21065. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21066. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21067. + 0x20, 0x20, 0x20, 0x22, 0x26, 0x2d, 0x32, 0x24,
  21068. + 0x80, 0x81, 0x64, 0x82, 0x77, 0x69, 0x71, 0x71,
  21069. + 0x69, 0x83, 0x84, 0x85, 0x7a, 0x85, 0x86, 0x36,
  21070. + 0x21, 0x2b, 0x23, 0x36, 0x36, 0x39, 0x2e, 0x26,
  21071. + 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21072. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21073. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21074. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21075. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21076. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21077. + 0x20, 0x20, 0x20, 0x22, 0x27, 0x2d, 0x33, 0x21,
  21078. + 0x87, 0x88, 0x89, 0x72, 0x67, 0x66, 0x5f, 0x89,
  21079. + 0x8a, 0x63, 0x85, 0x8b, 0x8c, 0x8d, 0x41, 0x36,
  21080. + 0x36, 0x2d, 0x3a, 0x35, 0x36, 0x24, 0x51, 0x32,
  21081. + 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21082. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21083. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21084. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21085. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21086. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21087. + 0x20, 0x20, 0x20, 0x22, 0x30, 0x2f, 0x33, 0x21,
  21088. + 0x55, 0x8e, 0x8f, 0x8a, 0x7d, 0x5e, 0x90, 0x7e,
  21089. + 0x75, 0x75, 0x90, 0x62, 0x40, 0x3f, 0x49, 0x23,
  21090. + 0x36, 0x24, 0x3a, 0x3a, 0x24, 0x36, 0x2e, 0x31,
  21091. + 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21092. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21093. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21094. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21095. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21096. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21097. + 0x20, 0x20, 0x21, 0x28, 0x33, 0x37, 0x25, 0x22,
  21098. + 0x3b, 0x50, 0x8e, 0x8f, 0x90, 0x7e, 0x90, 0x63,
  21099. + 0x74, 0x91, 0x92, 0x42, 0x93, 0x4b, 0x45, 0x2c,
  21100. + 0x36, 0x36, 0x33, 0x39, 0x21, 0x36, 0x22, 0x51,
  21101. + 0x33, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
  21102. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21103. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21104. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21105. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21106. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21107. + 0x20, 0x20, 0x22, 0x27, 0x2e, 0x2e, 0x36, 0x21,
  21108. + 0x94, 0x3f, 0x50, 0x95, 0x96, 0x8f, 0x8f, 0x97,
  21109. + 0x8e, 0x42, 0x50, 0x43, 0x47, 0x48, 0x48, 0x98,
  21110. + 0x21, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x39,
  21111. + 0x2e, 0x27, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20,
  21112. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21113. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21114. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21115. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21116. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21117. + 0x20, 0x22, 0x24, 0x2b, 0x38, 0x28, 0x36, 0x32,
  21118. + 0x4c, 0x4b, 0x50, 0x50, 0x50, 0x42, 0x42, 0x50,
  21119. + 0x50, 0x40, 0x45, 0x99, 0x48, 0x48, 0x48, 0x48,
  21120. + 0x34, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x23,
  21121. + 0x2f, 0x2b, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
  21122. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21123. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21124. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21125. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21126. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21127. + 0x21, 0x28, 0x32, 0x51, 0x32, 0x28, 0x21, 0x98,
  21128. + 0x48, 0x47, 0x9a, 0x50, 0x50, 0x50, 0x50, 0x50,
  21129. + 0x9a, 0x4f, 0x9b, 0x48, 0x48, 0x48, 0x48, 0x48,
  21130. + 0x93, 0x23, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  21131. + 0x2a, 0x2f, 0x2a, 0x28, 0x21, 0x20, 0x20, 0x20,
  21132. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21133. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21134. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21135. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21136. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
  21137. + 0x23, 0x30, 0x2e, 0x2c, 0x36, 0x21, 0x51, 0x9b,
  21138. + 0x48, 0x48, 0x52, 0x3f, 0x50, 0x50, 0x40, 0x4b,
  21139. + 0x47, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
  21140. + 0x48, 0x34, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  21141. + 0x36, 0x2d, 0x31, 0x27, 0x23, 0x21, 0x20, 0x20,
  21142. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21143. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21144. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21145. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21146. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
  21147. + 0x27, 0x2c, 0x2d, 0x21, 0x36, 0x28, 0x44, 0x48,
  21148. + 0x48, 0x48, 0x48, 0x47, 0x46, 0x4f, 0x47, 0x48,
  21149. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
  21150. + 0x48, 0x9c, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  21151. + 0x36, 0x28, 0x51, 0x39, 0x26, 0x22, 0x20, 0x20,
  21152. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21153. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21154. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21155. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21156. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x25,
  21157. + 0x35, 0x51, 0x28, 0x36, 0x36, 0x9d, 0x48, 0x48,
  21158. + 0x48, 0x48, 0x48, 0x48, 0x9b, 0x48, 0x48, 0x48,
  21159. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
  21160. + 0x48, 0x4f, 0x28, 0x36, 0x36, 0x36, 0x36, 0x36,
  21161. + 0x36, 0x36, 0x28, 0x38, 0x2b, 0x25, 0x22, 0x20,
  21162. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21163. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21164. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21165. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21166. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24, 0x33,
  21167. + 0x51, 0x25, 0x36, 0x36, 0x23, 0x40, 0x9b, 0x48,
  21168. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
  21169. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
  21170. + 0x9b, 0x99, 0x2b, 0x36, 0x36, 0x36, 0x36, 0x36,
  21171. + 0x36, 0x36, 0x36, 0x30, 0x2f, 0x33, 0x24, 0x21,
  21172. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21173. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21174. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21175. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21176. + 0x20, 0x20, 0x20, 0x20, 0x21, 0x23, 0x30, 0x34,
  21177. + 0x27, 0x36, 0x36, 0x36, 0x2a, 0x40, 0x47, 0x48,
  21178. + 0x48, 0x48, 0x48, 0x9b, 0x99, 0x99, 0x9b, 0x48,
  21179. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x9b, 0x47, 0x52,
  21180. + 0x46, 0x4f, 0x37, 0x21, 0x36, 0x36, 0x36, 0x36,
  21181. + 0x36, 0x36, 0x36, 0x36, 0x30, 0x34, 0x2a, 0x23,
  21182. + 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21183. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21184. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21185. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21186. + 0x20, 0x20, 0x20, 0x20, 0x22, 0x25, 0x39, 0x2c,
  21187. + 0x36, 0x36, 0x36, 0x21, 0x31, 0x4e, 0x9a, 0x4c,
  21188. + 0x47, 0x9b, 0x9b, 0x52, 0x46, 0x4f, 0x52, 0x9b,
  21189. + 0x9b, 0x9b, 0x47, 0x4f, 0x45, 0x9a, 0x93, 0x93,
  21190. + 0x3f, 0x93, 0x98, 0x28, 0x36, 0x36, 0x36, 0x36,
  21191. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x39, 0x2c, 0x26,
  21192. + 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21193. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21194. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21195. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21196. + 0x20, 0x20, 0x20, 0x20, 0x23, 0x2a, 0x34, 0x28,
  21197. + 0x36, 0x36, 0x36, 0x22, 0x38, 0x98, 0x44, 0x99,
  21198. + 0x9b, 0x48, 0x48, 0x9b, 0x4c, 0x48, 0x48, 0x48,
  21199. + 0x48, 0x48, 0x48, 0x47, 0x52, 0x46, 0x43, 0x93,
  21200. + 0x40, 0x40, 0x43, 0x53, 0x21, 0x23, 0x33, 0x23,
  21201. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x2f, 0x32,
  21202. + 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21203. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21204. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21205. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21206. + 0x20, 0x20, 0x20, 0x21, 0x24, 0x2b, 0x31, 0x36,
  21207. + 0x36, 0x22, 0x36, 0x24, 0x9e, 0x4f, 0x9b, 0x48,
  21208. + 0x48, 0x48, 0x48, 0x9b, 0x99, 0x9f, 0x52, 0x48,
  21209. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x47,
  21210. + 0x4f, 0x9a, 0x3f, 0x46, 0x38, 0x36, 0x21, 0x30,
  21211. + 0x26, 0x36, 0x36, 0x36, 0x36, 0x36, 0x39, 0x2c,
  21212. + 0x25, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21213. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21214. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21215. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21216. + 0x20, 0x20, 0x20, 0x22, 0x26, 0x2e, 0x33, 0x36,
  21217. + 0x25, 0x25, 0x36, 0x4d, 0x52, 0x48, 0x48, 0x48,
  21218. + 0x47, 0x9f, 0x48, 0x48, 0x48, 0xa0, 0xa1, 0xa2,
  21219. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
  21220. + 0x48, 0x47, 0x44, 0x93, 0x43, 0x23, 0x36, 0x36,
  21221. + 0x26, 0x24, 0x36, 0x36, 0x36, 0x36, 0x28, 0x2f,
  21222. + 0x2a, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21223. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21224. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21225. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21226. + 0x20, 0x20, 0x20, 0x23, 0x2a, 0x51, 0x24, 0x36,
  21227. + 0x2a, 0x36, 0x28, 0x44, 0x48, 0x48, 0x48, 0x48,
  21228. + 0xa3, 0xa4, 0x48, 0x48, 0x9f, 0xa5, 0xa6, 0x9f,
  21229. + 0x48, 0x48, 0x48, 0xa2, 0xa7, 0x47, 0x48, 0x48,
  21230. + 0x48, 0x48, 0x9b, 0x4b, 0x44, 0x37, 0x36, 0x23,
  21231. + 0x28, 0x30, 0x22, 0x36, 0x36, 0x36, 0x36, 0x2d,
  21232. + 0x35, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
  21233. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21234. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21235. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21236. + 0x20, 0x20, 0x21, 0x28, 0x2b, 0x34, 0x36, 0x25,
  21237. + 0x24, 0x36, 0x4a, 0x48, 0x48, 0x48, 0x48, 0x48,
  21238. + 0xa8, 0xa1, 0x48, 0x48, 0x9f, 0xa9, 0xa6, 0x9f,
  21239. + 0x48, 0x48, 0xaa, 0xa1, 0xa5, 0x9f, 0x48, 0x48,
  21240. + 0x48, 0x48, 0x48, 0x9b, 0x52, 0x3f, 0x21, 0x30,
  21241. + 0x35, 0x25, 0x30, 0x36, 0x36, 0x36, 0x36, 0x32,
  21242. + 0x2d, 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20,
  21243. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21244. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21245. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21246. + 0x20, 0x20, 0x22, 0x26, 0x2e, 0x35, 0x36, 0x2a,
  21247. + 0x36, 0x24, 0x4f, 0x48, 0x52, 0x52, 0x48, 0x48,
  21248. + 0xab, 0xac, 0xa0, 0x48, 0xad, 0xa6, 0xa6, 0x9f,
  21249. + 0x48, 0xa2, 0xa9, 0xa6, 0xa2, 0x48, 0x48, 0x48,
  21250. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x47, 0x32, 0x30,
  21251. + 0x2a, 0x23, 0x30, 0x23, 0x36, 0x36, 0x36, 0x21,
  21252. + 0x2f, 0x32, 0x23, 0x20, 0x20, 0x20, 0x20, 0x20,
  21253. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21254. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21255. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21256. + 0x20, 0x21, 0x23, 0x2a, 0x51, 0x28, 0x28, 0x25,
  21257. + 0x36, 0x3a, 0x48, 0x48, 0xae, 0xaf, 0x48, 0x48,
  21258. + 0xad, 0xac, 0xa1, 0x9f, 0xa2, 0xa9, 0xa9, 0xa2,
  21259. + 0x48, 0xab, 0x78, 0xa7, 0x48, 0x48, 0x48, 0x48,
  21260. + 0x9f, 0x48, 0x48, 0x48, 0x48, 0x48, 0x38, 0x21,
  21261. + 0x36, 0x36, 0x22, 0x27, 0x36, 0x36, 0x36, 0x36,
  21262. + 0x2e, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20,
  21263. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21264. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21265. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21266. + 0x20, 0x22, 0x25, 0x2c, 0x34, 0x36, 0x30, 0x21,
  21267. + 0x23, 0x43, 0x48, 0x48, 0xb0, 0xb1, 0xb2, 0x9f,
  21268. + 0x48, 0xb3, 0xa5, 0xb3, 0xab, 0xa9, 0xa9, 0xb3,
  21269. + 0xb4, 0xa9, 0xb5, 0xb0, 0x48, 0x48, 0xa0, 0xa5,
  21270. + 0xa1, 0xad, 0x48, 0x48, 0x48, 0x48, 0x94, 0x36,
  21271. + 0x36, 0x36, 0x36, 0x32, 0x36, 0x36, 0x36, 0x36,
  21272. + 0x2a, 0x2e, 0x26, 0x22, 0x20, 0x20, 0x20, 0x20,
  21273. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21274. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21275. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21276. + 0x21, 0x23, 0x2a, 0x51, 0x25, 0x21, 0x2a, 0x36,
  21277. + 0x2e, 0x9b, 0x48, 0x48, 0x48, 0xb6, 0xb7, 0xa4,
  21278. + 0xa2, 0xa7, 0xb5, 0x78, 0x6f, 0x6f, 0x6e, 0x6f,
  21279. + 0xa9, 0xb5, 0xab, 0x48, 0x9f, 0xab, 0xa9, 0xa1,
  21280. + 0xaa, 0x48, 0x48, 0x48, 0x48, 0x48, 0x98, 0x36,
  21281. + 0x36, 0x36, 0x36, 0x32, 0x36, 0x36, 0x36, 0x36,
  21282. + 0x22, 0x2f, 0x30, 0x22, 0x20, 0x20, 0x20, 0x20,
  21283. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21284. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21285. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21286. + 0x22, 0x25, 0x2c, 0x34, 0x36, 0x24, 0x28, 0x36,
  21287. + 0x54, 0x48, 0x48, 0x48, 0x48, 0xa2, 0xa8, 0xa1,
  21288. + 0xa5, 0xa6, 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f,
  21289. + 0x6f, 0x78, 0xa5, 0xa0, 0xa0, 0x78, 0xa6, 0xa2,
  21290. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x9a, 0x36,
  21291. + 0x36, 0x36, 0x36, 0x30, 0x36, 0x36, 0x36, 0x36,
  21292. + 0x21, 0x2f, 0x32, 0x23, 0x20, 0x20, 0x20, 0x20,
  21293. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21294. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21295. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
  21296. + 0x28, 0x32, 0x2f, 0x28, 0x36, 0x27, 0x22, 0x21,
  21297. + 0x43, 0x48, 0x4b, 0xa2, 0x9f, 0x48, 0xa2, 0xa1,
  21298. + 0xb8, 0x6e, 0x6e, 0xb5, 0x78, 0x6f, 0x78, 0x78,
  21299. + 0x6e, 0x6f, 0x78, 0xb5, 0xa6, 0xa1, 0xa0, 0x48,
  21300. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x4b, 0x21,
  21301. + 0x36, 0x36, 0x21, 0x26, 0x36, 0x36, 0x36, 0x36,
  21302. + 0x36, 0x34, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
  21303. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21304. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21305. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
  21306. + 0x25, 0x2c, 0x39, 0x36, 0x36, 0x30, 0x22, 0x25,
  21307. + 0x52, 0x48, 0xa3, 0xb1, 0xb6, 0xb3, 0xaa, 0xac,
  21308. + 0x68, 0x68, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f,
  21309. + 0x78, 0x6f, 0x6f, 0xb5, 0xa6, 0xb4, 0x48, 0x9f,
  21310. + 0xb4, 0xb4, 0xa2, 0x9f, 0x48, 0x48, 0x4f, 0x21,
  21311. + 0x36, 0x36, 0x22, 0x26, 0x36, 0x36, 0x36, 0x36,
  21312. + 0x36, 0x2c, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20,
  21313. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21314. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21315. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
  21316. + 0x30, 0x2d, 0x21, 0x36, 0x36, 0x32, 0x23, 0x2a,
  21317. + 0x47, 0x48, 0xa2, 0xb6, 0xaf, 0xb9, 0xba, 0x68,
  21318. + 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x78,
  21319. + 0x6f, 0x6f, 0xa6, 0x6f, 0xb5, 0xa0, 0xaa, 0xa6,
  21320. + 0xa6, 0xa9, 0xb2, 0xb3, 0x48, 0x48, 0x4c, 0x22,
  21321. + 0x36, 0x36, 0x24, 0x23, 0x36, 0x36, 0x36, 0x36,
  21322. + 0x36, 0x2c, 0x39, 0x24, 0x21, 0x20, 0x20, 0x20,
  21323. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21324. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21325. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
  21326. + 0x33, 0x2e, 0x36, 0x36, 0x23, 0x31, 0x27, 0x39,
  21327. + 0x9b, 0x48, 0x48, 0x48, 0xb0, 0xb0, 0xba, 0xb8,
  21328. + 0x68, 0x68, 0x69, 0x78, 0x6f, 0xb5, 0x6f, 0xb5,
  21329. + 0x78, 0x78, 0x78, 0x78, 0x78, 0xa5, 0xbb, 0xa9,
  21330. + 0xa5, 0x48, 0x48, 0x48, 0x48, 0x48, 0x4c, 0x23,
  21331. + 0x36, 0x36, 0x26, 0x36, 0x36, 0x36, 0x36, 0x36,
  21332. + 0x36, 0x2c, 0x39, 0x24, 0x21, 0x20, 0x20, 0x20,
  21333. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21334. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21335. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
  21336. + 0x2b, 0x39, 0x36, 0x36, 0x36, 0x26, 0x32, 0x31,
  21337. + 0x9b, 0x48, 0x48, 0x48, 0x48, 0x9f, 0xac, 0x68,
  21338. + 0xbc, 0x6e, 0x6e, 0x6e, 0xb5, 0x6f, 0x6e, 0x6f,
  21339. + 0x6f, 0x78, 0x78, 0xb5, 0xb5, 0xa5, 0x9f, 0x9f,
  21340. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x46, 0x22,
  21341. + 0x36, 0x21, 0x26, 0x36, 0x36, 0x36, 0x36, 0x36,
  21342. + 0x36, 0x2c, 0x35, 0x24, 0x21, 0x20, 0x20, 0x20,
  21343. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21344. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21345. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
  21346. + 0x35, 0x39, 0x36, 0x36, 0x36, 0x36, 0x26, 0x2d,
  21347. + 0x9b, 0x48, 0x48, 0xb0, 0xaa, 0xb3, 0xbd, 0xb8,
  21348. + 0xb8, 0x68, 0x6e, 0x6e, 0xb5, 0x6f, 0x78, 0x6e,
  21349. + 0x78, 0x6f, 0x78, 0x78, 0xb5, 0xa9, 0xa2, 0x48,
  21350. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x9a, 0x36,
  21351. + 0x24, 0x27, 0xbe, 0x24, 0x25, 0x28, 0x21, 0x36,
  21352. + 0x36, 0x34, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
  21353. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21354. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21355. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x25,
  21356. + 0x39, 0x4d, 0xbf, 0x84, 0x81, 0x57, 0x21, 0x39,
  21357. + 0x52, 0x48, 0x48, 0x62, 0xb1, 0xc0, 0xc1, 0xc1,
  21358. + 0xb8, 0xb8, 0x68, 0xbc, 0x6e, 0x6e, 0x6e, 0x78,
  21359. + 0x78, 0x78, 0x78, 0x6e, 0x78, 0xa9, 0xa0, 0xab,
  21360. + 0xb3, 0xa2, 0x48, 0x48, 0x48, 0x48, 0x53, 0x28,
  21361. + 0x23, 0x36, 0x36, 0x36, 0x21, 0x28, 0x2c, 0x30,
  21362. + 0x21, 0x38, 0x33, 0x28, 0x21, 0x20, 0x20, 0x20,
  21363. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21364. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21365. + 0x20, 0x20, 0x20, 0x21, 0x22, 0x22, 0x28, 0x30,
  21366. + 0x2d, 0xc2, 0x7a, 0xc3, 0xc4, 0xc4, 0x7f, 0x22,
  21367. + 0x51, 0x52, 0x48, 0x48, 0xb0, 0xaa, 0xa8, 0xbd,
  21368. + 0x68, 0xb8, 0xb8, 0x68, 0x68, 0x6e, 0x6e, 0x6f,
  21369. + 0x6e, 0x6e, 0xb5, 0x6e, 0x78, 0xab, 0xab, 0xb5,
  21370. + 0x78, 0xa6, 0xb3, 0xc5, 0xac, 0xac, 0xc6, 0x61,
  21371. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x30, 0x32,
  21372. + 0x25, 0x4d, 0x2b, 0x28, 0x21, 0x20, 0x20, 0x20,
  21373. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21374. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21375. + 0x20, 0x21, 0x23, 0x24, 0x26, 0x30, 0x33, 0x31,
  21376. + 0x4d, 0x91, 0x5b, 0xc3, 0xc4, 0xc4, 0xc4, 0x5a,
  21377. + 0x21, 0x2e, 0x46, 0x48, 0x48, 0x48, 0xb0, 0x64,
  21378. + 0xc1, 0xb8, 0xb8, 0xb8, 0x68, 0x71, 0x6e, 0x6e,
  21379. + 0x6f, 0x71, 0x6f, 0x6f, 0xa6, 0xa0, 0x9f, 0xb4,
  21380. + 0xb4, 0xa0, 0xa1, 0xb7, 0xc7, 0x69, 0x66, 0xc8,
  21381. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x26, 0x25,
  21382. + 0x83, 0xc9, 0x2c, 0x25, 0x21, 0x20, 0x20, 0x20,
  21383. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21384. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21385. + 0x21, 0x28, 0x30, 0x35, 0x2d, 0x2f, 0x37, 0x4a,
  21386. + 0x60, 0x85, 0xca, 0xcb, 0xc4, 0xc4, 0xc4, 0x82,
  21387. + 0x86, 0x36, 0x32, 0x3f, 0xa2, 0xa4, 0xa8, 0xa9,
  21388. + 0xb8, 0xb8, 0xb8, 0xb8, 0x68, 0x6e, 0x6e, 0x6e,
  21389. + 0x6e, 0x71, 0x6f, 0x71, 0xa6, 0xb4, 0x9f, 0x9f,
  21390. + 0x48, 0x48, 0x48, 0xcc, 0xc3, 0xc7, 0xcd, 0xce,
  21391. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x21, 0x57,
  21392. + 0x77, 0x66, 0x34, 0x27, 0x22, 0x20, 0x20, 0x20,
  21393. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21394. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21395. + 0x23, 0x30, 0x31, 0xcf, 0x91, 0x7e, 0x90, 0x90,
  21396. + 0x8b, 0x5b, 0xc3, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21397. + 0x5d, 0xd0, 0x36, 0x24, 0xd1, 0xb1, 0xaf, 0xaa,
  21398. + 0xba, 0xb8, 0x68, 0x68, 0x68, 0x71, 0x6e, 0x6e,
  21399. + 0x6e, 0x6f, 0x6e, 0x78, 0xa1, 0xa9, 0xa1, 0xb0,
  21400. + 0x9f, 0x9b, 0x99, 0xcc, 0x64, 0x5c, 0x8b, 0xd0,
  21401. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x73, 0x5d,
  21402. + 0x82, 0x5c, 0xd2, 0x2a, 0x23, 0x20, 0x20, 0x20,
  21403. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21404. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
  21405. + 0x24, 0x2b, 0xcf, 0x8b, 0x5b, 0x76, 0x5b, 0x5b,
  21406. + 0x7b, 0xc3, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21407. + 0xc7, 0x5e, 0x22, 0x36, 0x21, 0x3a, 0x99, 0x48,
  21408. + 0xa2, 0xa8, 0xb7, 0xc1, 0xb8, 0x68, 0x68, 0xbc,
  21409. + 0x68, 0x6e, 0xb5, 0xb4, 0xb4, 0xab, 0xb5, 0xa1,
  21410. + 0xb0, 0x4f, 0x3f, 0xd3, 0x7b, 0x7b, 0x85, 0x80,
  21411. + 0xbe, 0x36, 0x36, 0x36, 0x21, 0xd4, 0x7e, 0x7b,
  21412. + 0x64, 0x64, 0xd5, 0x35, 0x24, 0x21, 0x20, 0x20,
  21413. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21414. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
  21415. + 0x26, 0x31, 0xd6, 0x5b, 0x64, 0xc3, 0xc3, 0xcb,
  21416. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21417. + 0xc4, 0x66, 0xd7, 0x36, 0x36, 0x36, 0x2c, 0x4b,
  21418. + 0xd8, 0xd9, 0xb3, 0xa8, 0xbd, 0xbd, 0xbd, 0xbd,
  21419. + 0xa9, 0xab, 0xb3, 0xa5, 0xa2, 0x9f, 0xa2, 0xa1,
  21420. + 0x6a, 0x9a, 0x3f, 0xda, 0x76, 0x76, 0x7a, 0x63,
  21421. + 0xdb, 0xdc, 0x86, 0xdc, 0xdd, 0x90, 0x5b, 0x64,
  21422. + 0xc3, 0xc3, 0xde, 0x2d, 0x27, 0x23, 0x21, 0x20,
  21423. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21424. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
  21425. + 0x26, 0x2d, 0x91, 0x5b, 0x64, 0xc4, 0xc4, 0xc4,
  21426. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21427. + 0xc4, 0xc7, 0x83, 0xce, 0x36, 0x36, 0x36, 0x30,
  21428. + 0xb1, 0xd9, 0x48, 0xa1, 0xb2, 0xb0, 0xb0, 0xb3,
  21429. + 0xa2, 0x48, 0xa7, 0xbd, 0xa9, 0xa2, 0x48, 0x9f,
  21430. + 0xaa, 0x9a, 0x3f, 0xb1, 0x5b, 0x7b, 0xdf, 0x85,
  21431. + 0x7e, 0x90, 0x63, 0x90, 0x85, 0x5b, 0xc3, 0xc4,
  21432. + 0xc4, 0xcb, 0x5d, 0xd5, 0x39, 0x26, 0x23, 0x21,
  21433. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21434. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
  21435. + 0x26, 0x2d, 0xe0, 0xdf, 0x64, 0xc4, 0xc4, 0xc4,
  21436. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21437. + 0xc4, 0xc4, 0xc7, 0x88, 0x36, 0x36, 0x36, 0x36,
  21438. + 0x2d, 0x9b, 0x48, 0xb9, 0xaf, 0xa2, 0xa2, 0xb9,
  21439. + 0xa8, 0x9f, 0x48, 0xa7, 0xb7, 0xd9, 0x48, 0x48,
  21440. + 0x9b, 0x45, 0x3f, 0xe1, 0x6d, 0x7b, 0xca, 0xdf,
  21441. + 0x7a, 0x8b, 0x8b, 0x7a, 0x5b, 0x64, 0xc4, 0xc4,
  21442. + 0xc4, 0xc4, 0xc3, 0xe2, 0x37, 0x35, 0x26, 0x23,
  21443. + 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21444. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
  21445. + 0x26, 0x2e, 0xe0, 0x7a, 0x7b, 0xc4, 0xc4, 0xc4,
  21446. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21447. + 0xc4, 0xc4, 0xc7, 0x72, 0x73, 0x36, 0x36, 0x36,
  21448. + 0x24, 0x52, 0x48, 0xa3, 0xaf, 0x9f, 0x48, 0xb6,
  21449. + 0xaf, 0xa2, 0x48, 0x9f, 0xe3, 0xd8, 0x48, 0x48,
  21450. + 0x48, 0x46, 0x42, 0xd6, 0x7a, 0x7b, 0x64, 0x7b,
  21451. + 0x76, 0x5b, 0x5b, 0x76, 0x7b, 0xc3, 0xc4, 0xc4,
  21452. + 0xc4, 0xc4, 0xcb, 0x64, 0xe2, 0x4d, 0x2c, 0x27,
  21453. + 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21454. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
  21455. + 0x25, 0x31, 0xe4, 0x8b, 0x7b, 0xc4, 0xc4, 0xc4,
  21456. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21457. + 0xc4, 0xc4, 0xc4, 0xc7, 0x89, 0xbe, 0x36, 0x36,
  21458. + 0x32, 0x47, 0x48, 0x4f, 0xa0, 0x48, 0x48, 0xe3,
  21459. + 0x92, 0x9f, 0x48, 0x9f, 0x48, 0x48, 0x48, 0x48,
  21460. + 0x48, 0x4b, 0x2f, 0x8f, 0x7a, 0x7b, 0xc3, 0xcb,
  21461. + 0xc3, 0x64, 0x64, 0xc3, 0xc3, 0xcb, 0xc4, 0xc4,
  21462. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x5d, 0xe5, 0x2c,
  21463. + 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21464. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
  21465. + 0x25, 0x31, 0xe4, 0x85, 0x7b, 0xc4, 0xc4, 0xc4,
  21466. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21467. + 0xc4, 0xc4, 0xc4, 0xc4, 0x66, 0x57, 0x27, 0x4d,
  21468. + 0x4b, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
  21469. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
  21470. + 0x99, 0x34, 0xbe, 0xdb, 0x7a, 0x7b, 0xc3, 0xc4,
  21471. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21472. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0xe4,
  21473. + 0x32, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
  21474. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
  21475. + 0x26, 0x2d, 0xe4, 0x85, 0x7b, 0xcb, 0xc4, 0xc4,
  21476. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21477. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc7, 0x5f, 0x92, 0x48,
  21478. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
  21479. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x44,
  21480. + 0x35, 0x36, 0xce, 0xdd, 0x7a, 0x7b, 0xcb, 0xc4,
  21481. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21482. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0xc3, 0xe1,
  21483. + 0x2b, 0x24, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
  21484. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
  21485. + 0x30, 0x2f, 0xd6, 0x8b, 0x7b, 0xcb, 0xc4, 0xc4,
  21486. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21487. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0x66, 0x89, 0x45,
  21488. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
  21489. + 0x48, 0x48, 0x48, 0x48, 0x48, 0x9b, 0x4e, 0x25,
  21490. + 0x36, 0x36, 0x61, 0xdb, 0x6d, 0x64, 0xcb, 0xc4,
  21491. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21492. + 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x7b, 0xdf, 0xe5,
  21493. + 0x32, 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
  21494. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
  21495. + 0x33, 0xe6, 0x63, 0xdf, 0xc3, 0xc4, 0xc4, 0xc4,
  21496. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21497. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x72, 0x81, 0xe7,
  21498. + 0x46, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
  21499. + 0x48, 0x48, 0x48, 0x48, 0x3f, 0x2c, 0x36, 0x36,
  21500. + 0x36, 0x36, 0xe8, 0x8f, 0x6d, 0x64, 0xcb, 0xc4,
  21501. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21502. + 0xc4, 0xc4, 0xc4, 0xc3, 0xca, 0x8b, 0xcf, 0x2c,
  21503. + 0x26, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21504. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
  21505. + 0x35, 0x96, 0x75, 0xca, 0xc3, 0xcb, 0xc4, 0xc4,
  21506. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21507. + 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x7b, 0x81, 0xdb,
  21508. + 0x73, 0x3b, 0x44, 0x9b, 0x48, 0x48, 0x48, 0x9b,
  21509. + 0x99, 0x43, 0x94, 0x2c, 0x21, 0x36, 0x36, 0x36,
  21510. + 0x36, 0x36, 0x73, 0xdb, 0x7a, 0x7b, 0xc4, 0xc4,
  21511. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21512. + 0xc4, 0x64, 0x76, 0x7a, 0x91, 0xd5, 0x31, 0x30,
  21513. + 0x28, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21514. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x24,
  21515. + 0x39, 0x97, 0x75, 0xdf, 0x7b, 0x64, 0xc3, 0xc3,
  21516. + 0xcb, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc4,
  21517. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0x7b, 0x7a, 0xe9,
  21518. + 0xea, 0x36, 0x21, 0x26, 0x2b, 0x39, 0x33, 0x30,
  21519. + 0x23, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  21520. + 0x36, 0x21, 0xea, 0xdd, 0x8b, 0x7b, 0xc4, 0xc4,
  21521. + 0xc4, 0xc4, 0xc4, 0xc4, 0xc4, 0xc3, 0x64, 0x64,
  21522. + 0x76, 0x85, 0xe0, 0xd5, 0x34, 0x2b, 0x27, 0x28,
  21523. + 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21524. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x28,
  21525. + 0x33, 0xeb, 0x63, 0x7e, 0x7a, 0x6d, 0xdf, 0x5b,
  21526. + 0x76, 0x7b, 0x64, 0x64, 0xc3, 0xcb, 0xc4, 0xc4,
  21527. + 0xc4, 0xc4, 0xc4, 0xc4, 0xcb, 0x76, 0x85, 0xdb,
  21528. + 0x79, 0x22, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  21529. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  21530. + 0x36, 0x21, 0xec, 0xdd, 0x75, 0x76, 0xc3, 0xc4,
  21531. + 0xc4, 0xc4, 0xcb, 0xc3, 0x64, 0x76, 0xdf, 0x8b,
  21532. + 0xd6, 0xd5, 0x2f, 0x35, 0x30, 0x24, 0x22, 0x21,
  21533. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21534. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
  21535. + 0x27, 0x31, 0xed, 0xeb, 0xdd, 0x74, 0x63, 0x90,
  21536. + 0x7e, 0x75, 0x8b, 0x6d, 0xdf, 0x76, 0x64, 0xc3,
  21537. + 0xcb, 0xcb, 0xcb, 0xcb, 0x64, 0x7a, 0x84, 0xee,
  21538. + 0x79, 0xbe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  21539. + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
  21540. + 0x36, 0x21, 0xea, 0xee, 0x63, 0x6d, 0x7b, 0x64,
  21541. + 0xcb, 0xc3, 0x64, 0x7b, 0xdf, 0x75, 0x63, 0x96,
  21542. + 0x38, 0x39, 0x2a, 0x24, 0x23, 0x21, 0x20, 0x20,
  21543. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21544. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
  21545. + 0x28, 0x27, 0x35, 0x2d, 0x41, 0xd5, 0xe7, 0x8f,
  21546. + 0xdb, 0xdd, 0xe9, 0x74, 0x84, 0x90, 0x85, 0x6d,
  21547. + 0x5b, 0x7b, 0x7b, 0xca, 0x6d, 0x90, 0xdb, 0xef,
  21548. + 0xec, 0x22, 0x36, 0x36, 0x28, 0x30, 0x30, 0x30,
  21549. + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x25, 0x36,
  21550. + 0x36, 0x21, 0xd4, 0x80, 0xe9, 0x7e, 0x6d, 0x76,
  21551. + 0xca, 0x76, 0x6d, 0x85, 0x63, 0xdb, 0xd5, 0x34,
  21552. + 0x33, 0x26, 0x23, 0x21, 0x20, 0x20, 0x20, 0x20,
  21553. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21554. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21555. + 0x21, 0x23, 0x24, 0x27, 0x2a, 0x35, 0x2e, 0x2f,
  21556. + 0x41, 0xf0, 0xf1, 0x6c, 0x80, 0xee, 0xdb, 0x74,
  21557. + 0x84, 0x90, 0x75, 0x7e, 0x74, 0x8f, 0xef, 0x79,
  21558. + 0xe8, 0x2b, 0x9d, 0x41, 0x2f, 0x34, 0x2d, 0x2d,
  21559. + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x34, 0x2f, 0x38,
  21560. + 0x4d, 0x37, 0xf2, 0xf3, 0x8f, 0x74, 0x63, 0x7e,
  21561. + 0x75, 0x7e, 0x63, 0xe9, 0x88, 0xe6, 0x31, 0x2a,
  21562. + 0x24, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21563. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21564. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21565. + 0x20, 0x20, 0x21, 0x22, 0x23, 0x24, 0x26, 0x30,
  21566. + 0x33, 0x39, 0x2e, 0x51, 0x41, 0xd2, 0x6c, 0xf3,
  21567. + 0x80, 0xee, 0xee, 0xee, 0xf4, 0xf3, 0xd7, 0xf5,
  21568. + 0x41, 0x34, 0x35, 0x32, 0x30, 0x27, 0x27, 0x27,
  21569. + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x30, 0x2a,
  21570. + 0x2b, 0x34, 0xf6, 0xec, 0xf7, 0x8f, 0xdd, 0xe9,
  21571. + 0xe9, 0xdd, 0xee, 0x6c, 0x41, 0x39, 0x27, 0x28,
  21572. + 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21573. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21574. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21575. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22,
  21576. + 0x28, 0x24, 0x26, 0x2a, 0x33, 0x2c, 0x2f, 0x41,
  21577. + 0xf8, 0xd7, 0x79, 0x79, 0x79, 0xec, 0xf9, 0x51,
  21578. + 0x39, 0x30, 0x24, 0x23, 0x22, 0x22, 0x22, 0x22,
  21579. + 0x22, 0x22, 0x21, 0x22, 0x22, 0x22, 0x22, 0x23,
  21580. + 0x24, 0x2a, 0x31, 0xfa, 0xea, 0x79, 0xf3, 0x80,
  21581. + 0xf7, 0xdc, 0xfb, 0x2f, 0x35, 0x26, 0x23, 0x21,
  21582. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21583. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21584. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21585. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21586. + 0x20, 0x21, 0x22, 0x23, 0x28, 0x25, 0x30, 0x2b,
  21587. + 0x31, 0x2f, 0xf6, 0xfa, 0xfa, 0x2f, 0x2e, 0x33,
  21588. + 0x26, 0x23, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20,
  21589. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21590. + 0x21, 0x28, 0x27, 0x35, 0x34, 0xfa, 0xfa, 0xfa,
  21591. + 0xfc, 0xf6, 0x2e, 0x33, 0x25, 0x23, 0x21, 0x20,
  21592. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21593. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21594. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21595. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21596. + 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x23, 0x28,
  21597. + 0x26, 0x30, 0x32, 0x2b, 0x33, 0x2a, 0x26, 0x28,
  21598. + 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21599. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21600. + 0x20, 0x21, 0x23, 0x25, 0x30, 0x33, 0x35, 0x35,
  21601. + 0x2b, 0x2a, 0x26, 0x28, 0x22, 0x20, 0x20, 0x20,
  21602. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21603. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21604. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21605. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21606. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21,
  21607. + 0x21, 0x22, 0x23, 0x28, 0x28, 0x23, 0x22, 0x21,
  21608. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21609. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21610. + 0x20, 0x20, 0x20, 0x21, 0x23, 0x28, 0x24, 0x24,
  21611. + 0x28, 0x23, 0x22, 0x21, 0x20, 0x20, 0x20, 0x20,
  21612. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21613. + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  21614. +};
  21615. +
  21616. +unsigned char linux_logo16[1];
  21617. +
  21618. +#endif /* INCLUDE_LINUX_LOGO_DATA */
  21619. +
  21620. +#include <linux/linux_logo.h>
  21621. +
  21622. diff --git a/include/asm-nios2nommu/local.h b/include/asm-nios2nommu/local.h
  21623. new file mode 100644
  21624. index 0000000..5ed7d1c
  21625. --- /dev/null
  21626. +++ b/include/asm-nios2nommu/local.h
  21627. @@ -0,0 +1,28 @@
  21628. +/*
  21629. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  21630. + *
  21631. + * All rights reserved.
  21632. + *
  21633. + * This program is free software; you can redistribute it and/or modify
  21634. + * it under the terms of the GNU General Public License as published by
  21635. + * the Free Software Foundation; either version 2 of the License, or
  21636. + * (at your option) any later version.
  21637. + *
  21638. + * This program is distributed in the hope that it will be useful, but
  21639. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  21640. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  21641. + * NON INFRINGEMENT. See the GNU General Public License for more
  21642. + * details.
  21643. + *
  21644. + * You should have received a copy of the GNU General Public License
  21645. + * along with this program; if not, write to the Free Software
  21646. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21647. + *
  21648. + */
  21649. +
  21650. +#ifndef __NIOS2NOMMU_LOCAL_H
  21651. +#define __NIOS2NOMMU_LOCAL_H
  21652. +
  21653. +#include <asm-generic/local.h>
  21654. +
  21655. +#endif /* __NIOS2NOMMU_LOCAL_H */
  21656. diff --git a/include/asm-nios2nommu/mc146818rtc.h b/include/asm-nios2nommu/mc146818rtc.h
  21657. new file mode 100644
  21658. index 0000000..3492fc0
  21659. --- /dev/null
  21660. +++ b/include/asm-nios2nommu/mc146818rtc.h
  21661. @@ -0,0 +1,29 @@
  21662. +/*
  21663. + * Machine dependent access functions for RTC registers.
  21664. + *
  21665. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  21666. + *
  21667. + * All rights reserved.
  21668. + *
  21669. + * This program is free software; you can redistribute it and/or modify
  21670. + * it under the terms of the GNU General Public License as published by
  21671. + * the Free Software Foundation; either version 2 of the License, or
  21672. + * (at your option) any later version.
  21673. + *
  21674. + * This program is distributed in the hope that it will be useful, but
  21675. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  21676. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  21677. + * NON INFRINGEMENT. See the GNU General Public License for more
  21678. + * details.
  21679. + *
  21680. + * You should have received a copy of the GNU General Public License
  21681. + * along with this program; if not, write to the Free Software
  21682. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21683. + *
  21684. + */
  21685. +#ifndef _NIOS2_MC146818RTC_H
  21686. +#define _NIOS2_MC146818RTC_H
  21687. +
  21688. +/* empty include file to satisfy the include in genrtc.c/ide-geometry.c */
  21689. +
  21690. +#endif /* _NIOS2_MC146818RTC_H */
  21691. diff --git a/include/asm-nios2nommu/mman.h b/include/asm-nios2nommu/mman.h
  21692. new file mode 100644
  21693. index 0000000..516ab26
  21694. --- /dev/null
  21695. +++ b/include/asm-nios2nommu/mman.h
  21696. @@ -0,0 +1,68 @@
  21697. +/*
  21698. + * Copied from the m68k port.
  21699. + *
  21700. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  21701. + *
  21702. + * All rights reserved.
  21703. + *
  21704. + * This program is free software; you can redistribute it and/or modify
  21705. + * it under the terms of the GNU General Public License as published by
  21706. + * the Free Software Foundation; either version 2 of the License, or
  21707. + * (at your option) any later version.
  21708. + *
  21709. + * This program is distributed in the hope that it will be useful, but
  21710. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  21711. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  21712. + * NON INFRINGEMENT. See the GNU General Public License for more
  21713. + * details.
  21714. + *
  21715. + * You should have received a copy of the GNU General Public License
  21716. + * along with this program; if not, write to the Free Software
  21717. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21718. + *
  21719. + */
  21720. +
  21721. +#ifndef __NIOS2_MMAN_H__
  21722. +#define __NIOS2_MMAN_H__
  21723. +
  21724. +#define PROT_READ 0x1 /* page can be read */
  21725. +#define PROT_WRITE 0x2 /* page can be written */
  21726. +#define PROT_EXEC 0x4 /* page can be executed */
  21727. +#define PROT_SEM 0x8 /* page may be used for atomic ops */
  21728. +#define PROT_NONE 0x0 /* page can not be accessed */
  21729. +#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
  21730. +#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
  21731. +
  21732. +#define MAP_SHARED 0x01 /* Share changes */
  21733. +#define MAP_PRIVATE 0x02 /* Changes are private */
  21734. +#define MAP_TYPE 0x0f /* Mask for type of mapping */
  21735. +#define MAP_FIXED 0x10 /* Interpret addr exactly */
  21736. +#define MAP_ANONYMOUS 0x20 /* don't use a file */
  21737. +
  21738. +#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
  21739. +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
  21740. +#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
  21741. +#define MAP_LOCKED 0x2000 /* pages are locked */
  21742. +#define MAP_NORESERVE 0x4000 /* don't check for reservations */
  21743. +#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
  21744. +#define MAP_NONBLOCK 0x10000 /* do not block on IO */
  21745. +
  21746. +#define MS_ASYNC 1 /* sync memory asynchronously */
  21747. +#define MS_INVALIDATE 2 /* invalidate the caches */
  21748. +#define MS_SYNC 4 /* synchronous memory sync */
  21749. +
  21750. +#define MCL_CURRENT 1 /* lock all current mappings */
  21751. +#define MCL_FUTURE 2 /* lock all future mappings */
  21752. +
  21753. +#define MADV_NORMAL 0x0 /* default page-in behavior */
  21754. +#define MADV_RANDOM 0x1 /* page-in minimum required */
  21755. +#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */
  21756. +#define MADV_WILLNEED 0x3 /* pre-fault pages */
  21757. +#define MADV_DONTNEED 0x4 /* discard these pages */
  21758. +
  21759. +/* compatibility flags */
  21760. +#define MAP_ANON MAP_ANONYMOUS
  21761. +#define MAP_FILE 0
  21762. +
  21763. +#endif /* __NIOS2_MMAN_H__ */
  21764. +
  21765. diff --git a/include/asm-nios2nommu/mmu.h b/include/asm-nios2nommu/mmu.h
  21766. new file mode 100644
  21767. index 0000000..b6e579d
  21768. --- /dev/null
  21769. +++ b/include/asm-nios2nommu/mmu.h
  21770. @@ -0,0 +1,36 @@
  21771. +/*
  21772. + *
  21773. + * Taken from the m68knommu.
  21774. + *
  21775. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  21776. + *
  21777. + * All rights reserved.
  21778. + *
  21779. + * This program is free software; you can redistribute it and/or modify
  21780. + * it under the terms of the GNU General Public License as published by
  21781. + * the Free Software Foundation; either version 2 of the License, or
  21782. + * (at your option) any later version.
  21783. + *
  21784. + * This program is distributed in the hope that it will be useful, but
  21785. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  21786. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  21787. + * NON INFRINGEMENT. See the GNU General Public License for more
  21788. + * details.
  21789. + *
  21790. + * You should have received a copy of the GNU General Public License
  21791. + * along with this program; if not, write to the Free Software
  21792. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21793. + *
  21794. + */
  21795. +
  21796. +#ifndef __NIOS2NOMMU_MMU_H
  21797. +#define __NIOS2NOMMU_MMU_H
  21798. +
  21799. +/* Copyright (C) 2002, David McCullough <davidm@snapgear.com> */
  21800. +
  21801. +typedef struct {
  21802. + struct vm_list_struct *vmlist;
  21803. + unsigned long end_brk;
  21804. +} mm_context_t;
  21805. +
  21806. +#endif /* __NIOS2NOMMU_MMU_H */
  21807. diff --git a/include/asm-nios2nommu/mmu_context.h b/include/asm-nios2nommu/mmu_context.h
  21808. new file mode 100644
  21809. index 0000000..795cd09
  21810. --- /dev/null
  21811. +++ b/include/asm-nios2nommu/mmu_context.h
  21812. @@ -0,0 +1,57 @@
  21813. +/*
  21814. + *
  21815. + * Taken from the m68knommu.
  21816. + *
  21817. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  21818. + *
  21819. + * All rights reserved.
  21820. + *
  21821. + * This program is free software; you can redistribute it and/or modify
  21822. + * it under the terms of the GNU General Public License as published by
  21823. + * the Free Software Foundation; either version 2 of the License, or
  21824. + * (at your option) any later version.
  21825. + *
  21826. + * This program is distributed in the hope that it will be useful, but
  21827. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  21828. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  21829. + * NON INFRINGEMENT. See the GNU General Public License for more
  21830. + * details.
  21831. + *
  21832. + * You should have received a copy of the GNU General Public License
  21833. + * along with this program; if not, write to the Free Software
  21834. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21835. + *
  21836. + */
  21837. +
  21838. +#ifndef __NIOS2NOMMU_MMU_CONTEXT_H
  21839. +#define __NIOS2NOMMU_MMU_CONTEXT_H
  21840. +
  21841. +#include <asm/setup.h>
  21842. +#include <asm/page.h>
  21843. +#include <asm/pgalloc.h>
  21844. +
  21845. +static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
  21846. +{
  21847. +}
  21848. +
  21849. +extern inline int
  21850. +init_new_context(struct task_struct *tsk, struct mm_struct *mm)
  21851. +{
  21852. + // mm->context = virt_to_phys(mm->pgd);
  21853. + return(0);
  21854. +}
  21855. +
  21856. +#define destroy_context(mm) do { } while(0)
  21857. +
  21858. +static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
  21859. +{
  21860. +}
  21861. +
  21862. +#define deactivate_mm(tsk,mm) do { } while (0)
  21863. +
  21864. +extern inline void activate_mm(struct mm_struct *prev_mm,
  21865. + struct mm_struct *next_mm)
  21866. +{
  21867. +}
  21868. +
  21869. +#endif
  21870. diff --git a/include/asm-nios2nommu/module.h b/include/asm-nios2nommu/module.h
  21871. new file mode 100644
  21872. index 0000000..864f335
  21873. --- /dev/null
  21874. +++ b/include/asm-nios2nommu/module.h
  21875. @@ -0,0 +1,36 @@
  21876. +#ifndef _NIOS2_MODULE_H
  21877. +#define _NIOS2_MODULE_H
  21878. +
  21879. +/*--------------------------------------------------------------------
  21880. + *
  21881. + * include/asm-nios2nommu/module.h
  21882. + *
  21883. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  21884. + *
  21885. + * Copyright (C) 2004 Microtronix Datacom Ltd
  21886. + *
  21887. + * This program is free software; you can redistribute it and/or modify
  21888. + * it under the terms of the GNU General Public License as published by
  21889. + * the Free Software Foundation; either version 2 of the License, or
  21890. + * (at your option) any later version.
  21891. + *
  21892. + * This program is distributed in the hope that it will be useful,
  21893. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21894. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21895. + * GNU General Public License for more details.
  21896. + *
  21897. + *
  21898. + * Jan/20/2004 dgt NiosII
  21899. + *
  21900. + ---------------------------------------------------------------------*/
  21901. +
  21902. +
  21903. +struct mod_arch_specific
  21904. +{
  21905. +};
  21906. +
  21907. +#define Elf_Shdr Elf32_Shdr
  21908. +#define Elf_Sym Elf32_Sym
  21909. +#define Elf_Ehdr Elf32_Ehdr
  21910. +
  21911. +#endif /* _NIOS_MODULE_H */
  21912. diff --git a/include/asm-nios2nommu/msgbuf.h b/include/asm-nios2nommu/msgbuf.h
  21913. new file mode 100644
  21914. index 0000000..4d090f7
  21915. --- /dev/null
  21916. +++ b/include/asm-nios2nommu/msgbuf.h
  21917. @@ -0,0 +1,56 @@
  21918. +/*
  21919. + * Taken from the m68k.
  21920. + *
  21921. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  21922. + *
  21923. + * All rights reserved.
  21924. + *
  21925. + * This program is free software; you can redistribute it and/or modify
  21926. + * it under the terms of the GNU General Public License as published by
  21927. + * the Free Software Foundation; either version 2 of the License, or
  21928. + * (at your option) any later version.
  21929. + *
  21930. + * This program is distributed in the hope that it will be useful, but
  21931. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  21932. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  21933. + * NON INFRINGEMENT. See the GNU General Public License for more
  21934. + * details.
  21935. + *
  21936. + * You should have received a copy of the GNU General Public License
  21937. + * along with this program; if not, write to the Free Software
  21938. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21939. + *
  21940. + */
  21941. +
  21942. +#ifndef _NIOS2_MSGBUF_H
  21943. +#define _NIOS2_MSGBUF_H
  21944. +
  21945. +/*
  21946. + * The msqid64_ds structure for nios2 architecture.
  21947. + * Note extra padding because this structure is passed back and forth
  21948. + * between kernel and user space.
  21949. + *
  21950. + * Pad space is left for:
  21951. + * - 64-bit time_t to solve y2038 problem
  21952. + * - 2 miscellaneous 32-bit values
  21953. + */
  21954. +
  21955. +struct msqid64_ds {
  21956. + struct ipc64_perm msg_perm;
  21957. + __kernel_time_t msg_stime; /* last msgsnd time */
  21958. + unsigned long __unused1;
  21959. + __kernel_time_t msg_rtime; /* last msgrcv time */
  21960. + unsigned long __unused2;
  21961. + __kernel_time_t msg_ctime; /* last change time */
  21962. + unsigned long __unused3;
  21963. + unsigned long msg_cbytes; /* current number of bytes on queue */
  21964. + unsigned long msg_qnum; /* number of messages in queue */
  21965. + unsigned long msg_qbytes; /* max number of bytes on queue */
  21966. + __kernel_pid_t msg_lspid; /* pid of last msgsnd */
  21967. + __kernel_pid_t msg_lrpid; /* last receive pid */
  21968. + unsigned long __unused4;
  21969. + unsigned long __unused5;
  21970. +};
  21971. +
  21972. +#endif /* _NIOS2_MSGBUF_H */
  21973. +
  21974. diff --git a/include/asm-nios2nommu/mutex.h b/include/asm-nios2nommu/mutex.h
  21975. new file mode 100644
  21976. index 0000000..458c1f7
  21977. --- /dev/null
  21978. +++ b/include/asm-nios2nommu/mutex.h
  21979. @@ -0,0 +1,9 @@
  21980. +/*
  21981. + * Pull in the generic implementation for the mutex fastpath.
  21982. + *
  21983. + * TODO: implement optimized primitives instead, or leave the generic
  21984. + * implementation in place, or pick the atomic_xchg() based generic
  21985. + * implementation. (see asm-generic/mutex-xchg.h for details)
  21986. + */
  21987. +
  21988. +#include <asm-generic/mutex-dec.h>
  21989. diff --git a/include/asm-nios2nommu/namei.h b/include/asm-nios2nommu/namei.h
  21990. new file mode 100644
  21991. index 0000000..d925c4e
  21992. --- /dev/null
  21993. +++ b/include/asm-nios2nommu/namei.h
  21994. @@ -0,0 +1,36 @@
  21995. +/*
  21996. + * linux/include/asm-nios/namei.h
  21997. + * Moved from m68k version
  21998. + * Included from linux/fs/namei.c
  21999. + *
  22000. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  22001. + * All rights reserved.
  22002. + *
  22003. + * This program is free software; you can redistribute it and/or modify
  22004. + * it under the terms of the GNU General Public License as published by
  22005. + * the Free Software Foundation; either version 2 of the License, or
  22006. + * (at your option) any later version.
  22007. + *
  22008. + * This program is distributed in the hope that it will be useful, but
  22009. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  22010. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  22011. + * NON INFRINGEMENT. See the GNU General Public License for more
  22012. + * details.
  22013. + *
  22014. + * You should have received a copy of the GNU General Public License
  22015. + * along with this program; if not, write to the Free Software
  22016. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22017. + *
  22018. + */
  22019. +
  22020. +#ifndef __NIOS2_NAMEI_H
  22021. +#define __NIOS2_NAMEI_H
  22022. +
  22023. +/* This dummy routine maybe changed to something useful
  22024. + * for /usr/gnemul/ emulation stuff.
  22025. + * Look at asm-sparc/namei.h for details.
  22026. + */
  22027. +
  22028. +#define __emul_prefix() NULL
  22029. +
  22030. +#endif
  22031. diff --git a/include/asm-nios2nommu/ndma.h b/include/asm-nios2nommu/ndma.h
  22032. new file mode 100644
  22033. index 0000000..6b4604d
  22034. --- /dev/null
  22035. +++ b/include/asm-nios2nommu/ndma.h
  22036. @@ -0,0 +1,64 @@
  22037. +#ifndef __NDMA_H__
  22038. + #define __NDMA_H__
  22039. +
  22040. + #ifndef __ASSEMBLY__
  22041. +
  22042. +// DMA Registers
  22043. +typedef volatile struct
  22044. +{
  22045. + int np_dmastatus; // status register
  22046. + int np_dmareadaddress; // read address
  22047. + int np_dmawriteaddress; // write address
  22048. + int np_dmalength; // length in bytes
  22049. + int np_dmareserved1; // reserved
  22050. + int np_dmareserved2; // reserved
  22051. + int np_dmacontrol; // control register
  22052. + int np_dmareserved3; // control register alternate
  22053. +} np_dma;
  22054. +
  22055. +// DMA Register Bits
  22056. +enum
  22057. +{
  22058. + np_dmacontrol_byte_bit = 0, // Byte transaction
  22059. + np_dmacontrol_hw_bit = 1, // Half-word transaction
  22060. + np_dmacontrol_word_bit = 2, // Word transaction
  22061. + np_dmacontrol_go_bit = 3, // enable execution
  22062. + np_dmacontrol_i_en_bit = 4, // enable interrupt
  22063. + np_dmacontrol_reen_bit = 5, // Enable read end-of-packet
  22064. + np_dmacontrol_ween_bit = 6, // Enable write end-of-packet
  22065. + np_dmacontrol_leen_bit = 7, // Enable length=0 transaction end
  22066. + np_dmacontrol_rcon_bit = 8, // Read from a fixed address
  22067. + np_dmacontrol_wcon_bit = 9, // Write to a fixed address
  22068. + np_dmacontrol_doubleword_bit = 10, // Double-word transaction
  22069. + np_dmacontrol_quadword_bit = 11, // Quad-word transaction
  22070. +
  22071. + np_dmastatus_done_bit = 0, // 1 when done. Status write clears.
  22072. + np_dmastatus_busy_bit = 1, // 1 when busy.
  22073. + np_dmastatus_reop_bit = 2, // read-eop received
  22074. + np_dmastatus_weop_bit = 3, // write-eop received
  22075. + np_dmastatus_len_bit = 4, // requested length transacted
  22076. +
  22077. + np_dmacontrol_byte_mask = (1 << 0), // Byte transaction
  22078. + np_dmacontrol_hw_mask = (1 << 1), // Half-word transaction
  22079. + np_dmacontrol_word_mask = (1 << 2), // Word transaction
  22080. + np_dmacontrol_go_mask = (1 << 3), // enable execution
  22081. + np_dmacontrol_i_en_mask = (1 << 4), // enable interrupt
  22082. + np_dmacontrol_reen_mask = (1 << 5), // Enable read end-of-packet
  22083. + np_dmacontrol_ween_mask = (1 << 6), // Enable write end-of-packet
  22084. + np_dmacontrol_leen_mask = (1 << 7), // Enable length=0 transaction end
  22085. + np_dmacontrol_rcon_mask = (1 << 8), // Read from a fixed address
  22086. + np_dmacontrol_wcon_mask = (1 << 9), // Write to a fixed address
  22087. + np_dmacontrol_doubleword_mask = (1 << 10), // Double-word transaction
  22088. + np_dmacontrol_quadword_mask = (1 << 11), // Quad-word transaction
  22089. +
  22090. + np_dmastatus_done_mask = (1 << 0), // 1 when done. Status write clears.
  22091. + np_dmastatus_busy_mask = (1 << 1), // 1 when busy.
  22092. + np_dmastatus_reop_mask = (1 << 2), // read-eop received
  22093. + np_dmastatus_weop_mask = (1 << 3), // write-eop received
  22094. + np_dmastatus_len_mask = (1 << 4), // requested length transacted
  22095. +};
  22096. +
  22097. + #endif /* __ASSEMBLY__ */
  22098. +
  22099. +#endif
  22100. +/* End of File */
  22101. diff --git a/include/asm-nios2nommu/nios.h b/include/asm-nios2nommu/nios.h
  22102. new file mode 100644
  22103. index 0000000..df17672
  22104. --- /dev/null
  22105. +++ b/include/asm-nios2nommu/nios.h
  22106. @@ -0,0 +1,7 @@
  22107. +#ifndef __NIOS_H__
  22108. +#define __NIOS_H__
  22109. +
  22110. +#include <nios2_system.h>
  22111. +
  22112. +#endif
  22113. +
  22114. diff --git a/include/asm-nios2nommu/page.h b/include/asm-nios2nommu/page.h
  22115. new file mode 100644
  22116. index 0000000..764e73c
  22117. --- /dev/null
  22118. +++ b/include/asm-nios2nommu/page.h
  22119. @@ -0,0 +1,124 @@
  22120. +/*
  22121. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  22122. + *
  22123. + * All rights reserved.
  22124. + *
  22125. + * This program is free software; you can redistribute it and/or modify
  22126. + * it under the terms of the GNU General Public License as published by
  22127. + * the Free Software Foundation; either version 2 of the License, or
  22128. + * (at your option) any later version.
  22129. + *
  22130. + * This program is distributed in the hope that it will be useful, but
  22131. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  22132. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  22133. + * NON INFRINGEMENT. See the GNU General Public License for more
  22134. + * details.
  22135. + *
  22136. + * You should have received a copy of the GNU General Public License
  22137. + * along with this program; if not, write to the Free Software
  22138. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22139. + *
  22140. + */
  22141. +
  22142. +#ifndef _NIOS2_PAGE_H
  22143. +#define _NIOS2_PAGE_H
  22144. +
  22145. +/* copied from m68knommu arch */
  22146. +
  22147. +/* PAGE_SHIFT determines the page size */
  22148. +
  22149. +#define PAGE_SHIFT (12)
  22150. +#define PAGE_SIZE (1UL << PAGE_SHIFT)
  22151. +#define PAGE_MASK (~(PAGE_SIZE-1))
  22152. +
  22153. +#ifdef __KERNEL__
  22154. +
  22155. +#include <asm/setup.h>
  22156. +
  22157. +#if PAGE_SHIFT < 13
  22158. +#define THREAD_SIZE (8192)
  22159. +#else
  22160. +#define THREAD_SIZE PAGE_SIZE
  22161. +#endif
  22162. +
  22163. +#ifndef __ASSEMBLY__
  22164. +
  22165. +#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
  22166. +#define free_user_page(page, addr) free_page(addr)
  22167. +
  22168. +#define clear_page(page) memset((page), 0, PAGE_SIZE)
  22169. +#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
  22170. +
  22171. +#define clear_user_page(page, vaddr, pg) clear_page(page)
  22172. +#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
  22173. +
  22174. +/*
  22175. + * These are used to make use of C type-checking..
  22176. + */
  22177. +typedef struct { unsigned long pte; } pte_t;
  22178. +typedef struct { unsigned long pmd[16]; } pmd_t;
  22179. +typedef struct { unsigned long pgd; } pgd_t;
  22180. +typedef struct { unsigned long pgprot; } pgprot_t;
  22181. +
  22182. +#define pte_val(x) ((x).pte)
  22183. +#define pmd_val(x) ((&x)->pmd[0])
  22184. +#define pgd_val(x) ((x).pgd)
  22185. +#define pgprot_val(x) ((x).pgprot)
  22186. +
  22187. +#define __pte(x) ((pte_t) { (x) } )
  22188. +#define __pmd(x) ((pmd_t) { (x) } )
  22189. +#define __pgd(x) ((pgd_t) { (x) } )
  22190. +#define __pgprot(x) ((pgprot_t) { (x) } )
  22191. +
  22192. +/* to align the pointer to the (next) page boundary */
  22193. +#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
  22194. +
  22195. +extern unsigned long memory_start;
  22196. +extern unsigned long memory_end;
  22197. +
  22198. +#endif /* !__ASSEMBLY__ */
  22199. +#include <asm/nios.h>
  22200. +#define PAGE_OFFSET ((int)(nasys_program_mem))
  22201. +
  22202. +#ifndef __ASSEMBLY__
  22203. +
  22204. +#define __pa(vaddr) virt_to_phys((void *)(vaddr))
  22205. +#define __va(paddr) phys_to_virt((unsigned long)(paddr))
  22206. +
  22207. +#define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)
  22208. +
  22209. +#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
  22210. +#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
  22211. +
  22212. +#define virt_to_page(addr) ((void*) addr < (void*) memory_end ? mem_map + \
  22213. + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT) : 0UL)
  22214. +#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
  22215. +#define VALID_PAGE(page) (((page) - mem_map) < max_mapnr)
  22216. +
  22217. +#define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn))
  22218. +#define page_to_pfn(page) virt_to_pfn(page_to_virt(page))
  22219. +#define pfn_valid(pfn) ((pfn) < max_mapnr)
  22220. +
  22221. +#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
  22222. + ((void *)(kaddr) < (void *)memory_end))
  22223. +
  22224. +#ifdef CONFIG_NO_KERNEL_MSG
  22225. +#define BUG_PRINT()
  22226. +#else
  22227. +#define BUG_PRINT() printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__)
  22228. +#endif
  22229. +
  22230. +#ifdef na_cpu_oci_core
  22231. +#define BUG_PANIC() asm volatile ("break") /* drop to debugger */
  22232. +#else
  22233. +// #define BUG_PANIC() while(1)
  22234. +#define BUG_PANIC() panic("BUG!")
  22235. +#endif
  22236. +
  22237. +#endif /* __ASSEMBLY__ */
  22238. +
  22239. +#include <asm-generic/page.h>
  22240. +
  22241. +#endif /* __KERNEL__ */
  22242. +
  22243. +#endif /* _NIOS2_PAGE_H */
  22244. diff --git a/include/asm-nios2nommu/param.h b/include/asm-nios2nommu/param.h
  22245. new file mode 100644
  22246. index 0000000..e75a355
  22247. --- /dev/null
  22248. +++ b/include/asm-nios2nommu/param.h
  22249. @@ -0,0 +1,49 @@
  22250. +#ifndef _NIOS_PARAM_H
  22251. +#define _NIOS_PARAM_H
  22252. +
  22253. +/*--------------------------------------------------------------------
  22254. + *
  22255. + * include/asm-nios2nommu/param.h
  22256. + *
  22257. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  22258. + *
  22259. + * Copyright (C) 2004 Microtronix Datacom Ltd
  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. + *
  22272. + * Jan/20/2004 dgt NiosII
  22273. + *
  22274. + ---------------------------------------------------------------------*/
  22275. +
  22276. +
  22277. +#ifndef HZ
  22278. +#define HZ 100
  22279. +#endif
  22280. +
  22281. +#ifdef __KERNEL__
  22282. +#define USER_HZ HZ
  22283. +#define CLOCKS_PER_SEC (USER_HZ)
  22284. +#endif
  22285. +
  22286. +#define EXEC_PAGESIZE 4096
  22287. +
  22288. +#ifndef NGROUPS
  22289. +#define NGROUPS 32
  22290. +#endif
  22291. +
  22292. +#ifndef NOGROUP
  22293. +#define NOGROUP (-1)
  22294. +#endif
  22295. +
  22296. +#define MAXHOSTNAMELEN 64 /* max length of hostname */
  22297. +
  22298. +#endif
  22299. diff --git a/include/asm-nios2nommu/pci.h b/include/asm-nios2nommu/pci.h
  22300. new file mode 100644
  22301. index 0000000..be3b3b2
  22302. --- /dev/null
  22303. +++ b/include/asm-nios2nommu/pci.h
  22304. @@ -0,0 +1,126 @@
  22305. +#ifndef __ASM_SH_PCI_H
  22306. +#define __ASM_SH_PCI_H
  22307. +
  22308. +#ifdef __KERNEL__
  22309. +
  22310. +#include <linux/dma-mapping.h>
  22311. +
  22312. +/* Can be used to override the logic in pci_scan_bus for skipping
  22313. + already-configured bus numbers - to be used for buggy BIOSes
  22314. + or architectures with incomplete PCI setup by the loader */
  22315. +
  22316. +#define pcibios_assign_all_busses() 1
  22317. +#define pcibios_scan_all_fns(a, b) 0
  22318. +
  22319. +/*
  22320. + * A board can define one or more PCI channels that represent built-in (or
  22321. + * external) PCI controllers.
  22322. + */
  22323. +struct pci_channel {
  22324. + struct pci_ops *pci_ops;
  22325. + struct resource *io_resource;
  22326. + struct resource *mem_resource;
  22327. + int first_devfn;
  22328. + int last_devfn;
  22329. +};
  22330. +
  22331. +/*
  22332. + * Each board initializes this array and terminates it with a NULL entry.
  22333. + */
  22334. +extern struct pci_channel board_pci_channels[];
  22335. +
  22336. +#define PCIBIOS_MIN_IO board_pci_channels->io_resource->start
  22337. +#define PCIBIOS_MIN_MEM board_pci_channels->mem_resource->start
  22338. +
  22339. +struct pci_dev;
  22340. +
  22341. +extern void pcibios_set_master(struct pci_dev *dev);
  22342. +
  22343. +static inline void pcibios_penalize_isa_irq(int irq, int active)
  22344. +{
  22345. + /* We don't do dynamic PCI IRQ allocation */
  22346. +}
  22347. +
  22348. +/* Dynamic DMA mapping stuff.
  22349. + * SuperH has everything mapped statically like x86.
  22350. + */
  22351. +
  22352. +/* The PCI address space does equal the physical memory
  22353. + * address space. The networking and block device layers use
  22354. + * this boolean for bounce buffer decisions.
  22355. + */
  22356. +#define PCI_DMA_BUS_IS_PHYS (1)
  22357. +
  22358. +#include <linux/types.h>
  22359. +#include <linux/slab.h>
  22360. +#include <asm/scatterlist.h>
  22361. +#include <linux/string.h>
  22362. +#include <asm/io.h>
  22363. +
  22364. +/* pci_unmap_{single,page} being a nop depends upon the
  22365. + * configuration.
  22366. + */
  22367. +#ifdef CONFIG_SH_PCIDMA_NONCOHERENT
  22368. +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
  22369. + dma_addr_t ADDR_NAME;
  22370. +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
  22371. + __u32 LEN_NAME;
  22372. +#define pci_unmap_addr(PTR, ADDR_NAME) \
  22373. + ((PTR)->ADDR_NAME)
  22374. +#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
  22375. + (((PTR)->ADDR_NAME) = (VAL))
  22376. +#define pci_unmap_len(PTR, LEN_NAME) \
  22377. + ((PTR)->LEN_NAME)
  22378. +#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
  22379. + (((PTR)->LEN_NAME) = (VAL))
  22380. +#else
  22381. +#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
  22382. +#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
  22383. +#define pci_unmap_addr(PTR, ADDR_NAME) (0)
  22384. +#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
  22385. +#define pci_unmap_len(PTR, LEN_NAME) (0)
  22386. +#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
  22387. +#endif
  22388. +
  22389. +/* Not supporting more than 32-bit PCI bus addresses now, but
  22390. + * must satisfy references to this function. Change if needed.
  22391. + */
  22392. +#define pci_dac_dma_supported(pci_dev, mask) (0)
  22393. +
  22394. +/* These macros should be used after a pci_map_sg call has been done
  22395. + * to get bus addresses of each of the SG entries and their lengths.
  22396. + * You should only work with the number of sg entries pci_map_sg
  22397. + * returns, or alternatively stop on the first sg_dma_len(sg) which
  22398. + * is 0.
  22399. + */
  22400. +#define sg_dma_address(sg) (virt_to_bus((sg)->dma_address))
  22401. +#define sg_dma_len(sg) ((sg)->length)
  22402. +
  22403. +#ifdef CONFIG_PCI
  22404. +static inline void pci_dma_burst_advice(struct pci_dev *pdev,
  22405. + enum pci_dma_burst_strategy *strat,
  22406. + unsigned long *strategy_parameter)
  22407. +{
  22408. + *strat = PCI_DMA_BURST_INFINITY;
  22409. + *strategy_parameter = ~0UL;
  22410. +}
  22411. +#endif
  22412. +
  22413. +/* Board-specific fixup routines. */
  22414. +extern void pcibios_fixup(void);
  22415. +extern void pcibios_fixup_irqs(void);
  22416. +
  22417. +#ifdef CONFIG_PCI_AUTO
  22418. +extern int pciauto_assign_resources(int busno, struct pci_channel *hose);
  22419. +#endif
  22420. +
  22421. +#endif /* __KERNEL__ */
  22422. +
  22423. +/* generic pci stuff */
  22424. +#include <asm-generic/pci.h>
  22425. +
  22426. +/* generic DMA-mapping stuff */
  22427. +#include <asm-generic/pci-dma-compat.h>
  22428. +
  22429. +#endif /* __ASM_SH_PCI_H */
  22430. +
  22431. diff --git a/include/asm-nios2nommu/percpu.h b/include/asm-nios2nommu/percpu.h
  22432. new file mode 100644
  22433. index 0000000..cd6d4a3
  22434. --- /dev/null
  22435. +++ b/include/asm-nios2nommu/percpu.h
  22436. @@ -0,0 +1,30 @@
  22437. +#ifndef __ARCH_NIOS2NOMMU_PERCPU__
  22438. +#define __ARCH_NIOS2NOMMU_PERCPU__
  22439. +
  22440. +/*--------------------------------------------------------------------
  22441. + *
  22442. + * include/asm-nios2nommu/percpu.h
  22443. + *
  22444. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  22445. + *
  22446. + * Copyright (C) 2004 Microtronix Datacom Ltd
  22447. + *
  22448. + * This program is free software; you can redistribute it and/or modify
  22449. + * it under the terms of the GNU General Public License as published by
  22450. + * the Free Software Foundation; either version 2 of the License, or
  22451. + * (at your option) any later version.
  22452. + *
  22453. + * This program is distributed in the hope that it will be useful,
  22454. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22455. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22456. + * GNU General Public License for more details.
  22457. + *
  22458. + *
  22459. + * Jan/20/2004 dgt NiosII
  22460. + *
  22461. + ---------------------------------------------------------------------*/
  22462. +
  22463. +
  22464. +#include <asm-generic/percpu.h>
  22465. +
  22466. +#endif /* __ARCH_NIOS2NOMMU_PERCPU__ */
  22467. diff --git a/include/asm-nios2nommu/pgalloc.h b/include/asm-nios2nommu/pgalloc.h
  22468. new file mode 100644
  22469. index 0000000..a997ada
  22470. --- /dev/null
  22471. +++ b/include/asm-nios2nommu/pgalloc.h
  22472. @@ -0,0 +1,32 @@
  22473. +#ifndef _NIOS2NOMMU_PGALLOC_H
  22474. +#define _NIOS2NOMMU_PGALLOC_H
  22475. +
  22476. +/*--------------------------------------------------------------------
  22477. + *
  22478. + * include/asm-nios2nommu/pgalloc.h
  22479. + *
  22480. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  22481. + *
  22482. + * Copyright (C) 2004 Microtronix Datacom Ltd
  22483. + *
  22484. + * This program is free software; you can redistribute it and/or modify
  22485. + * it under the terms of the GNU General Public License as published by
  22486. + * the Free Software Foundation; either version 2 of the License, or
  22487. + * (at your option) any later version.
  22488. + *
  22489. + * This program is distributed in the hope that it will be useful,
  22490. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22491. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22492. + * GNU General Public License for more details.
  22493. + *
  22494. + *
  22495. + * Jan/20/2004 dgt NiosII
  22496. + *
  22497. + ---------------------------------------------------------------------*/
  22498. +
  22499. +
  22500. +#include <asm/setup.h>
  22501. +
  22502. +#define check_pgt_cache() do { } while (0)
  22503. +
  22504. +#endif /* _NIOS2NOMMU_PGALLOC_H */
  22505. diff --git a/include/asm-nios2nommu/pgtable.h b/include/asm-nios2nommu/pgtable.h
  22506. new file mode 100644
  22507. index 0000000..4124a33
  22508. --- /dev/null
  22509. +++ b/include/asm-nios2nommu/pgtable.h
  22510. @@ -0,0 +1,112 @@
  22511. +#ifndef _NIOS_PGTABLE_H
  22512. +#define _NIOS_PGTABLE_H
  22513. +
  22514. +/*--------------------------------------------------------------------
  22515. + *
  22516. + * include/asm-nios2nommu/pgtable.h
  22517. + *
  22518. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  22519. + *
  22520. + * Copyright (C) 2004 Microtronix Datacom Ltd
  22521. + *
  22522. + * This program is free software; you can redistribute it and/or modify
  22523. + * it under the terms of the GNU General Public License as published by
  22524. + * the Free Software Foundation; either version 2 of the License, or
  22525. + * (at your option) any later version.
  22526. + *
  22527. + * This program is distributed in the hope that it will be useful,
  22528. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22529. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22530. + * GNU General Public License for more details.
  22531. + *
  22532. + *
  22533. + * Jan/20/2004 dgt NiosII
  22534. + *
  22535. + ---------------------------------------------------------------------*/
  22536. +
  22537. +#include <asm-generic/4level-fixup.h>
  22538. +
  22539. +//vic - this bit copied from m68knommu version
  22540. +#include <asm/setup.h>
  22541. +#include <asm/io.h>
  22542. +#include <linux/sched.h>
  22543. +
  22544. +typedef pte_t *pte_addr_t;
  22545. +
  22546. +#define pgd_present(pgd) (1) /* pages are always present on NO_MM */
  22547. +#define pgd_none(pgd) (0)
  22548. +#define pgd_bad(pgd) (0)
  22549. +#define pgd_clear(pgdp)
  22550. +#define kern_addr_valid(addr) (1)
  22551. +#define pmd_offset(a, b) ((void *)0)
  22552. +
  22553. +#define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */
  22554. +#define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */
  22555. +#define PAGE_COPY __pgprot(0) /* these mean nothing to NO_MM */
  22556. +#define PAGE_READONLY __pgprot(0) /* these mean nothing to NO_MM */
  22557. +#define PAGE_KERNEL __pgprot(0) /* these mean nothing to NO_MM */
  22558. +//vic - this bit copied from m68knommu version
  22559. +
  22560. +extern void paging_init(void);
  22561. +#define swapper_pg_dir ((pgd_t *) 0)
  22562. +
  22563. +#define __swp_type(x) (0)
  22564. +#define __swp_offset(x) (0)
  22565. +#define __swp_entry(typ,off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
  22566. +#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
  22567. +#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
  22568. +
  22569. +static inline int pte_file(pte_t pte) { return 0; }
  22570. +
  22571. +/*
  22572. + * ZERO_PAGE is a global shared page that is always zero: used
  22573. + * for zero-mapped memory areas etc..
  22574. + */
  22575. +#define ZERO_PAGE(vaddr) (virt_to_page(0))
  22576. +
  22577. +extern unsigned int kobjsize(const void *objp);
  22578. +extern int is_in_rom(unsigned long);
  22579. +
  22580. +/*
  22581. + * No page table caches to initialise
  22582. + */
  22583. +#define pgtable_cache_init() do { } while (0)
  22584. +
  22585. +#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
  22586. + remap_pfn_range(vma, vaddr, pfn, size, prot)
  22587. +
  22588. +extern inline void flush_cache_mm(struct mm_struct *mm)
  22589. +{
  22590. +}
  22591. +
  22592. +extern inline void flush_cache_range(struct mm_struct *mm,
  22593. + unsigned long start,
  22594. + unsigned long end)
  22595. +{
  22596. +}
  22597. +
  22598. +/* Push the page at kernel virtual address and clear the icache */
  22599. +extern inline void flush_page_to_ram (unsigned long address)
  22600. +{
  22601. +}
  22602. +
  22603. +/* Push n pages at kernel virtual address and clear the icache */
  22604. +extern inline void flush_pages_to_ram (unsigned long address, int n)
  22605. +{
  22606. +}
  22607. +
  22608. +/*
  22609. + * All 32bit addresses are effectively valid for vmalloc...
  22610. + * Sort of meaningless for non-VM targets.
  22611. + */
  22612. +#define VMALLOC_START 0
  22613. +#define VMALLOC_END 0xffffffff
  22614. +
  22615. +#define arch_enter_lazy_mmu_mode() do {} while (0)
  22616. +#define arch_leave_lazy_mmu_mode() do {} while (0)
  22617. +#define arch_flush_lazy_mmu_mode() do {} while (0)
  22618. +#define arch_enter_lazy_cpu_mode() do {} while (0)
  22619. +#define arch_leave_lazy_cpu_mode() do {} while (0)
  22620. +#define arch_flush_lazy_cpu_mode() do {} while (0)
  22621. +
  22622. +#endif /* _NIOS_PGTABLE_H */
  22623. diff --git a/include/asm-nios2nommu/pio_struct.h b/include/asm-nios2nommu/pio_struct.h
  22624. new file mode 100644
  22625. index 0000000..8ce5176
  22626. --- /dev/null
  22627. +++ b/include/asm-nios2nommu/pio_struct.h
  22628. @@ -0,0 +1,14 @@
  22629. +// PIO Peripheral
  22630. +
  22631. +// PIO Registers
  22632. +typedef volatile struct
  22633. + {
  22634. + int np_piodata; // read/write, up to 32 bits
  22635. + int np_piodirection; // write/readable, up to 32 bits, 1->output bit
  22636. + int np_piointerruptmask; // write/readable, up to 32 bits, 1->enable interrupt
  22637. + int np_pioedgecapture; // read, up to 32 bits, cleared by any write
  22638. + } np_pio;
  22639. +
  22640. +// PIO Routines
  22641. +void nr_pio_showhex(int value); // shows low byte on pio named na_seven_seg_pio
  22642. +
  22643. diff --git a/include/asm-nios2nommu/poll.h b/include/asm-nios2nommu/poll.h
  22644. new file mode 100644
  22645. index 0000000..f6b9ab8
  22646. --- /dev/null
  22647. +++ b/include/asm-nios2nommu/poll.h
  22648. @@ -0,0 +1,48 @@
  22649. +#ifndef __NIOS2_POLL_H
  22650. +#define __NIOS2_POLL_H
  22651. +
  22652. +/*--------------------------------------------------------------------
  22653. + *
  22654. + * include/asm-nios2nommu/poll.h
  22655. + *
  22656. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  22657. + *
  22658. + * Copyright (C) 2004 Microtronix Datacom Ltd
  22659. + *
  22660. + * This program is free software; you can redistribute it and/or modify
  22661. + * it under the terms of the GNU General Public License as published by
  22662. + * the Free Software Foundation; either version 2 of the License, or
  22663. + * (at your option) any later version.
  22664. + *
  22665. + * This program is distributed in the hope that it will be useful,
  22666. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22667. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22668. + * GNU General Public License for more details.
  22669. + *
  22670. + *
  22671. + * Jan/20/2004 dgt NiosII
  22672. + *
  22673. + ---------------------------------------------------------------------*/
  22674. +
  22675. +
  22676. +#define POLLIN 1
  22677. +#define POLLPRI 2
  22678. +#define POLLOUT 4
  22679. +#define POLLERR 8
  22680. +#define POLLHUP 16
  22681. +#define POLLNVAL 32
  22682. +#define POLLRDNORM 64
  22683. +#define POLLWRNORM POLLOUT
  22684. +#define POLLRDBAND 128
  22685. +#define POLLWRBAND 256
  22686. +#define POLLMSG 0x0400
  22687. +#define POLLREMOVE 0x1000
  22688. +#define POLLRDHUP 0x2000
  22689. +
  22690. +struct pollfd {
  22691. + int fd;
  22692. + short events;
  22693. + short revents;
  22694. +};
  22695. +
  22696. +#endif
  22697. diff --git a/include/asm-nios2nommu/posix_types.h b/include/asm-nios2nommu/posix_types.h
  22698. new file mode 100644
  22699. index 0000000..0b019b5
  22700. --- /dev/null
  22701. +++ b/include/asm-nios2nommu/posix_types.h
  22702. @@ -0,0 +1,89 @@
  22703. +#ifndef __ARCH_NIOS2_POSIX_TYPES_H
  22704. +#define __ARCH_NIOS2_POSIX_TYPES_H
  22705. +
  22706. +/*--------------------------------------------------------------------
  22707. + *
  22708. + * include/asm-nios2nommu/posix_types.h
  22709. + *
  22710. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  22711. + *
  22712. + * Copyright (C) 2004 Microtronix Datacom Ltd
  22713. + *
  22714. + * This program is free software; you can redistribute it and/or modify
  22715. + * it under the terms of the GNU General Public License as published by
  22716. + * the Free Software Foundation; either version 2 of the License, or
  22717. + * (at your option) any later version.
  22718. + *
  22719. + * This program is distributed in the hope that it will be useful,
  22720. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22721. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22722. + * GNU General Public License for more details.
  22723. + *
  22724. + *
  22725. + * Jan/20/2004 dgt NiosII
  22726. + *
  22727. + ---------------------------------------------------------------------*/
  22728. +
  22729. +
  22730. +/*
  22731. + * This file is generally used by user-level software, so you need to
  22732. + * be a little careful about namespace pollution etc. Also, we cannot
  22733. + * assume GCC is being used.
  22734. + */
  22735. +
  22736. +typedef unsigned long __kernel_ino_t;
  22737. +typedef unsigned short __kernel_mode_t;
  22738. +typedef unsigned short __kernel_nlink_t;
  22739. +typedef long __kernel_off_t;
  22740. +typedef int __kernel_pid_t;
  22741. +typedef unsigned short __kernel_ipc_pid_t;
  22742. +typedef unsigned short __kernel_uid_t;
  22743. +typedef unsigned short __kernel_gid_t;
  22744. +typedef unsigned int __kernel_size_t;
  22745. +typedef int __kernel_ssize_t;
  22746. +typedef int __kernel_ptrdiff_t;
  22747. +typedef long __kernel_time_t;
  22748. +typedef long __kernel_suseconds_t;
  22749. +typedef long __kernel_clock_t;
  22750. +typedef int __kernel_timer_t;
  22751. +typedef int __kernel_clockid_t;
  22752. +typedef int __kernel_daddr_t;
  22753. +typedef char * __kernel_caddr_t;
  22754. +typedef unsigned short __kernel_uid16_t;
  22755. +typedef unsigned short __kernel_gid16_t;
  22756. +typedef unsigned int __kernel_uid32_t;
  22757. +typedef unsigned int __kernel_gid32_t;
  22758. +
  22759. +typedef unsigned short __kernel_old_uid_t;
  22760. +typedef unsigned short __kernel_old_gid_t;
  22761. +typedef unsigned short __kernel_old_dev_t;
  22762. +
  22763. +#ifdef __GNUC__
  22764. +typedef long long __kernel_loff_t;
  22765. +#endif
  22766. +
  22767. +typedef struct {
  22768. +#if defined(__KERNEL__) || defined(__USE_ALL)
  22769. + int val[2];
  22770. +#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
  22771. + int __val[2];
  22772. +#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
  22773. +} __kernel_fsid_t;
  22774. +
  22775. +#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
  22776. +
  22777. +#undef __FD_SET
  22778. +#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
  22779. +
  22780. +#undef __FD_CLR
  22781. +#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
  22782. +
  22783. +#undef __FD_ISSET
  22784. +#define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
  22785. +
  22786. +#undef __FD_ZERO
  22787. +#define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp)))
  22788. +
  22789. +#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
  22790. +
  22791. +#endif
  22792. diff --git a/include/asm-nios2nommu/preem_latency.h b/include/asm-nios2nommu/preem_latency.h
  22793. new file mode 100644
  22794. index 0000000..6defb5c
  22795. --- /dev/null
  22796. +++ b/include/asm-nios2nommu/preem_latency.h
  22797. @@ -0,0 +1,39 @@
  22798. +#ifndef _ASM_PREEM_LATENCY_H
  22799. +#define _ASM_PREEM_LATENCY_H
  22800. +
  22801. +/*--------------------------------------------------------------------
  22802. + *
  22803. + * include/asm-nios2nommu/preem_latency.h
  22804. + *
  22805. + * timing support for preempt-stats patch
  22806. + *
  22807. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  22808. + *
  22809. + * Copyright (C) 2004 Microtronix Datacom Ltd
  22810. + *
  22811. + * This program is free software; you can redistribute it and/or modify
  22812. + * it under the terms of the GNU General Public License as published by
  22813. + * the Free Software Foundation; either version 2 of the License, or
  22814. + * (at your option) any later version.
  22815. + *
  22816. + * This program is distributed in the hope that it will be useful,
  22817. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22818. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22819. + * GNU General Public License for more details.
  22820. + *
  22821. + *
  22822. + * Jan/20/2004 dgt NiosII
  22823. + *
  22824. + ---------------------------------------------------------------------*/
  22825. +
  22826. +
  22827. +#include <asm/nios.h>
  22828. +
  22829. +#define readclock(low) \
  22830. +do {\
  22831. + *(volatile unsigned long *)na_Counter_64_bit=1; \
  22832. + low=*(volatile unsigned long *)na_Counter_64_bit; \
  22833. +} while (0)
  22834. +#define readclock_init()
  22835. +
  22836. +#endif /* _ASM_PREEM_LATENCY_H */
  22837. diff --git a/include/asm-nios2nommu/processor.h b/include/asm-nios2nommu/processor.h
  22838. new file mode 100644
  22839. index 0000000..5332f94
  22840. --- /dev/null
  22841. +++ b/include/asm-nios2nommu/processor.h
  22842. @@ -0,0 +1,148 @@
  22843. +/*--------------------------------------------------------------------
  22844. + *
  22845. + * include/asm-nios2nommu/processor.h
  22846. + *
  22847. + * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
  22848. + * Copyright (C) 2001 Ken Hill (khill@microtronix.com)
  22849. + * Vic Phillips (vic@microtronix.com)
  22850. + * Copyright (C) 2004 Microtronix Datacom Ltd
  22851. + *
  22852. + * hacked from:
  22853. + * include/asm-sparc/processor.h
  22854. + *
  22855. + * This program is free software; you can redistribute it and/or modify
  22856. + * it under the terms of the GNU General Public License as published by
  22857. + * the Free Software Foundation; either version 2 of the License, or
  22858. + * (at your option) any later version.
  22859. + *
  22860. + * This program is distributed in the hope that it will be useful,
  22861. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22862. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22863. + * GNU General Public License for more details.
  22864. + *
  22865. + *
  22866. + * Jan/20/2004 dgt NiosII
  22867. + * Nov/02/2003 dgt Fix task_size
  22868. + *
  22869. + ---------------------------------------------------------------------*/
  22870. +
  22871. +#ifndef __ASM_NIOS_PROCESSOR_H
  22872. +#define __ASM_NIOS_PROCESSOR_H
  22873. +
  22874. +#define NIOS2_FLAG_KTHREAD 0x00000001 /* task is a kernel thread */
  22875. +#define NIOS2_FLAG_COPROC 0x00000002 /* Thread used coprocess */
  22876. +#define NIOS2_FLAG_DEBUG 0x00000004 /* task is being debugged */
  22877. +
  22878. +#define NIOS2_OP_NOP 0x1883a
  22879. +#define NIOS2_OP_BREAK 0x3da03a
  22880. +
  22881. +#ifndef __ASSEMBLY__
  22882. +
  22883. +/*
  22884. + * Default implementation of macro that returns current
  22885. + * instruction pointer ("program counter").
  22886. + */
  22887. +#define current_text_addr() ({ __label__ _l; _l: &&_l;})
  22888. +
  22889. +#include <linux/a.out.h>
  22890. +#include <linux/string.h>
  22891. +
  22892. +#include <asm/ptrace.h>
  22893. +#include <asm/signal.h>
  22894. +#include <asm/segment.h>
  22895. +#include <asm/current.h>
  22896. +#include <asm/system.h> /* for get_hi_limit */
  22897. +
  22898. +/*
  22899. + * Bus types
  22900. + */
  22901. +#define EISA_bus 0
  22902. +#define EISA_bus__is_a_macro /* for versions in ksyms.c */
  22903. +#define MCA_bus 0
  22904. +#define MCA_bus__is_a_macro /* for versions in ksyms.c */
  22905. +
  22906. +/*
  22907. + * The nios has no problems with write protection
  22908. + */
  22909. +#define wp_works_ok 1
  22910. +#define wp_works_ok__is_a_macro /* for versions in ksyms.c */
  22911. +
  22912. +/* Whee, this is STACK_TOP and the lowest kernel address too... */
  22913. +#if 0
  22914. +#define KERNBASE 0x00000000 /* First address the kernel will eventually be */
  22915. +#define TASK_SIZE (KERNBASE)
  22916. +#define MAX_USER_ADDR TASK_SIZE
  22917. +#define MMAP_SEARCH_START (TASK_SIZE/3)
  22918. +#endif
  22919. +
  22920. +#define TASK_SIZE ((unsigned int) nasys_program_mem_end) //...this is better...
  22921. +
  22922. +/*
  22923. + * This decides where the kernel will search for a free chunk of vm
  22924. + * space during mmap's. We won't be using it
  22925. + */
  22926. +#define TASK_UNMAPPED_BASE 0
  22927. +
  22928. +/* The Nios processor specific thread struct. */
  22929. +struct thread_struct {
  22930. + struct pt_regs *kregs;
  22931. +
  22932. + /* For signal handling */
  22933. + unsigned long sig_address;
  22934. + unsigned long sig_desc;
  22935. +
  22936. + /* Context switch saved kernel state. */
  22937. + unsigned long ksp;
  22938. + unsigned long kpsr;
  22939. + unsigned long kesr;
  22940. +
  22941. + /* Flags are defined below */
  22942. +
  22943. + unsigned long flags;
  22944. + int current_ds;
  22945. + struct exec core_exec; /* just what it says. */
  22946. +};
  22947. +
  22948. +#define INIT_MMAP { &init_mm, (0), (0), \
  22949. + __pgprot(0x0) , VM_READ | VM_WRITE | VM_EXEC }
  22950. +
  22951. +#define INIT_THREAD { \
  22952. + .kregs = 0, \
  22953. + .sig_address = 0, \
  22954. + .sig_desc = 0, \
  22955. + .ksp = 0, \
  22956. + .kpsr = 0, \
  22957. + .kesr = PS_S, \
  22958. + .flags = NIOS2_FLAG_KTHREAD, \
  22959. + .current_ds = __KERNEL_DS, \
  22960. + .core_exec = INIT_EXEC \
  22961. +}
  22962. +
  22963. +/* Free all resources held by a thread. */
  22964. +extern void release_thread(struct task_struct *);
  22965. +
  22966. +extern unsigned long thread_saved_pc(struct task_struct *t);
  22967. +
  22968. +extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
  22969. +
  22970. +/* Prepare to copy thread state - unlazy all lazy status */
  22971. +#define prepare_to_copy(tsk) do { } while (0)
  22972. +
  22973. +extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  22974. +
  22975. +unsigned long get_wchan(struct task_struct *p);
  22976. +
  22977. +#define KSTK_EIP(tsk) ((tsk)->thread.kregs->ea)
  22978. +#define KSTK_ESP(tsk) ((tsk)->thread.kregs->sp)
  22979. +
  22980. +#ifdef __KERNEL__
  22981. +/* Allocation and freeing of basic task resources. */
  22982. +
  22983. +//;dgt2;#define alloc_task_struct() ((struct task_struct *) xx..see..linux..fork..xx __get_free_pages(GFP_KERNEL,1))
  22984. +//;dgt2;#define get_task_struct(tsk) xx..see..linux..sched.h...atomic_inc(&mem_map[MAP_NR(tsk)].count)
  22985. +
  22986. +#endif
  22987. +
  22988. +#define cpu_relax() do { } while (0)
  22989. +#endif /* __ASSEMBLY__ */
  22990. +#endif /* __ASM_NIOS_PROCESSOR_H */
  22991. diff --git a/include/asm-nios2nommu/ptrace.h b/include/asm-nios2nommu/ptrace.h
  22992. new file mode 100644
  22993. index 0000000..d669e08
  22994. --- /dev/null
  22995. +++ b/include/asm-nios2nommu/ptrace.h
  22996. @@ -0,0 +1,140 @@
  22997. +/*
  22998. + * Taken from the m68k port.
  22999. + *
  23000. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  23001. + *
  23002. + * All rights reserved.
  23003. + *
  23004. + * This program is free software; you can redistribute it and/or modify
  23005. + * it under the terms of the GNU General Public License as published by
  23006. + * the Free Software Foundation; either version 2 of the License, or
  23007. + * (at your option) any later version.
  23008. + *
  23009. + * This program is distributed in the hope that it will be useful, but
  23010. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  23011. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  23012. + * NON INFRINGEMENT. See the GNU General Public License for more
  23013. + * details.
  23014. + *
  23015. + * You should have received a copy of the GNU General Public License
  23016. + * along with this program; if not, write to the Free Software
  23017. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23018. + *
  23019. + */
  23020. +#ifndef _NIOS2NOMMU_PTRACE_H
  23021. +#define _NIOS2NOMMU_PTRACE_H
  23022. +
  23023. +#ifndef __ASSEMBLY__
  23024. +
  23025. +#define PTR_R0 0
  23026. +#define PTR_R1 1
  23027. +#define PTR_R2 2
  23028. +#define PTR_R3 3
  23029. +#define PTR_R4 4
  23030. +#define PTR_R5 5
  23031. +#define PTR_R6 6
  23032. +#define PTR_R7 7
  23033. +#define PTR_R8 8
  23034. +#define PTR_R9 9
  23035. +#define PTR_R10 10
  23036. +#define PTR_R11 11
  23037. +#define PTR_R12 12
  23038. +#define PTR_R13 13
  23039. +#define PTR_R14 14
  23040. +#define PTR_R15 15
  23041. +#define PTR_R16 16
  23042. +#define PTR_R17 17
  23043. +#define PTR_R18 18
  23044. +#define PTR_R19 19
  23045. +#define PTR_R20 20
  23046. +#define PTR_R21 21
  23047. +#define PTR_R22 22
  23048. +#define PTR_R23 23
  23049. +#define PTR_R24 24
  23050. +#define PTR_R25 25
  23051. +#define PTR_GP 26
  23052. +#define PTR_SP 27
  23053. +#define PTR_FP 28
  23054. +#define PTR_EA 29
  23055. +#define PTR_BA 30
  23056. +#define PTR_RA 31
  23057. +#define PTR_STATUS 32
  23058. +#define PTR_ESTATUS 33
  23059. +#define PTR_BSTATUS 34
  23060. +#define PTR_IENABLE 35
  23061. +#define PTR_IPENDING 36
  23062. +
  23063. +/* this struct defines the way the registers are stored on the
  23064. + stack during a system call.
  23065. +
  23066. + There is a fake_regs in setup.c that has to match pt_regs.*/
  23067. +
  23068. +struct pt_regs {
  23069. + unsigned long r8;
  23070. + unsigned long r9;
  23071. + unsigned long r10;
  23072. + unsigned long r11;
  23073. + unsigned long r12;
  23074. + unsigned long r13;
  23075. + unsigned long r14;
  23076. + unsigned long r15;
  23077. + unsigned long r1;
  23078. + unsigned long r2;
  23079. + unsigned long r3;
  23080. + unsigned long r4;
  23081. + unsigned long r5;
  23082. + unsigned long r6;
  23083. + unsigned long r7;
  23084. + unsigned long orig_r2;
  23085. + unsigned long ra;
  23086. + unsigned long fp;
  23087. + unsigned long sp;
  23088. + unsigned long gp;
  23089. + unsigned long estatus;
  23090. + unsigned long status_extension;
  23091. + unsigned long ea;
  23092. +};
  23093. +
  23094. +
  23095. +/*
  23096. + * This is the extended stack used by signal handlers and the context
  23097. + * switcher: it's pushed after the normal "struct pt_regs".
  23098. + */
  23099. +struct switch_stack {
  23100. + unsigned long r16;
  23101. + unsigned long r17;
  23102. + unsigned long r18;
  23103. + unsigned long r19;
  23104. + unsigned long r20;
  23105. + unsigned long r21;
  23106. + unsigned long r22;
  23107. + unsigned long r23;
  23108. + unsigned long fp;
  23109. + unsigned long gp;
  23110. + unsigned long ra;
  23111. +};
  23112. +
  23113. +#ifdef __KERNEL__
  23114. +/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
  23115. +#define PTRACE_GETREGS 12
  23116. +#define PTRACE_SETREGS 13
  23117. +#ifdef CONFIG_FPU
  23118. +#define PTRACE_GETFPREGS 14
  23119. +#define PTRACE_SETFPREGS 15
  23120. +#endif
  23121. +
  23122. +#ifndef PS_S
  23123. +#define PS_S (0x00000001)
  23124. +#endif
  23125. +#ifndef PS_T
  23126. +#define PS_T (0x00000002)
  23127. +#endif
  23128. +
  23129. +#define user_mode(regs) (!((regs)->status_extension & PS_S))
  23130. +#define instruction_pointer(regs) ((regs)->ra)
  23131. +#define profile_pc(regs) instruction_pointer(regs)
  23132. +extern void show_regs(struct pt_regs *);
  23133. +
  23134. +#endif /* __KERNEL__ */
  23135. +#endif /* __ASSEMBLY__ */
  23136. +#endif /* _NIOS2NOMMU_PTRACE_H */
  23137. diff --git a/include/asm-nios2nommu/resource.h b/include/asm-nios2nommu/resource.h
  23138. new file mode 100644
  23139. index 0000000..9c2499a
  23140. --- /dev/null
  23141. +++ b/include/asm-nios2nommu/resource.h
  23142. @@ -0,0 +1,6 @@
  23143. +#ifndef __ASM_SH_RESOURCE_H
  23144. +#define __ASM_SH_RESOURCE_H
  23145. +
  23146. +#include <asm-generic/resource.h>
  23147. +
  23148. +#endif /* __ASM_SH_RESOURCE_H */
  23149. diff --git a/include/asm-nios2nommu/rmap.h b/include/asm-nios2nommu/rmap.h
  23150. new file mode 100644
  23151. index 0000000..b3664cc
  23152. --- /dev/null
  23153. +++ b/include/asm-nios2nommu/rmap.h
  23154. @@ -0,0 +1,2 @@
  23155. +/* Do not need anything here */
  23156. +
  23157. diff --git a/include/asm-nios2nommu/scatterlist.h b/include/asm-nios2nommu/scatterlist.h
  23158. new file mode 100644
  23159. index 0000000..20898e2
  23160. --- /dev/null
  23161. +++ b/include/asm-nios2nommu/scatterlist.h
  23162. @@ -0,0 +1,13 @@
  23163. +#ifndef __ASM_SH_SCATTERLIST_H
  23164. +#define __ASM_SH_SCATTERLIST_H
  23165. +
  23166. +struct scatterlist {
  23167. + struct page * page; /* Location for highmem page, if any */
  23168. + unsigned int offset;/* for highmem, page offset */
  23169. + dma_addr_t dma_address;
  23170. + unsigned int length;
  23171. +};
  23172. +
  23173. +#define ISA_DMA_THRESHOLD (0xffffffff)
  23174. +
  23175. +#endif /* !(__ASM_SH_SCATTERLIST_H) */
  23176. diff --git a/include/asm-nios2nommu/sections.h b/include/asm-nios2nommu/sections.h
  23177. new file mode 100644
  23178. index 0000000..61b3f71
  23179. --- /dev/null
  23180. +++ b/include/asm-nios2nommu/sections.h
  23181. @@ -0,0 +1,30 @@
  23182. +#ifndef _NIOS2NOMMU_SECTIONS_H
  23183. +#define _NIOS2NOMMU_SECTIONS_H
  23184. +
  23185. +/*--------------------------------------------------------------------
  23186. + *
  23187. + * include/asm-nios2nommu/sections.h
  23188. + *
  23189. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  23190. + *
  23191. + * Copyright (C) 2004 Microtronix Datacom Ltd
  23192. + *
  23193. + * This program is free software; you can redistribute it and/or modify
  23194. + * it under the terms of the GNU General Public License as published by
  23195. + * the Free Software Foundation; either version 2 of the License, or
  23196. + * (at your option) any later version.
  23197. + *
  23198. + * This program is distributed in the hope that it will be useful,
  23199. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23200. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23201. + * GNU General Public License for more details.
  23202. + *
  23203. + *
  23204. + * Jan/20/2004 dgt NiosII
  23205. + *
  23206. + ---------------------------------------------------------------------*/
  23207. +
  23208. +
  23209. +#include <asm-generic/sections.h>
  23210. +
  23211. +#endif /* _NIOS2NOMMU_SECTIONS_H */
  23212. diff --git a/include/asm-nios2nommu/segment.h b/include/asm-nios2nommu/segment.h
  23213. new file mode 100644
  23214. index 0000000..25871b3
  23215. --- /dev/null
  23216. +++ b/include/asm-nios2nommu/segment.h
  23217. @@ -0,0 +1,75 @@
  23218. +#ifndef _NIOS2NOMMU_SEGMENT_H
  23219. +#define _NIOS2NOMMU_SEGMENT_H
  23220. +
  23221. +/*--------------------------------------------------------------------
  23222. + *
  23223. + * include/asm-nios2nommu/segment.h
  23224. + *
  23225. + * Derived from M68knommu
  23226. + *
  23227. + * Copyright (C) 2004 Microtronix Datacom Ltd
  23228. + *
  23229. + * This program is free software; you can redistribute it and/or modify
  23230. + * it under the terms of the GNU General Public License as published by
  23231. + * the Free Software Foundation; either version 2 of the License, or
  23232. + * (at your option) any later version.
  23233. + *
  23234. + * This program is distributed in the hope that it will be useful,
  23235. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23236. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23237. + * GNU General Public License for more details.
  23238. + *
  23239. + *
  23240. + * Jan/20/2004 dgt NiosII
  23241. + *
  23242. + ---------------------------------------------------------------------*/
  23243. +
  23244. +
  23245. +/* define constants */
  23246. +/* Address spaces (FC0-FC2) */
  23247. +#define USER_DATA (1)
  23248. +#ifndef __USER_DS
  23249. +#define __USER_DS (USER_DATA)
  23250. +#endif
  23251. +#define USER_PROGRAM (2)
  23252. +#define SUPER_DATA (5)
  23253. +#ifndef __KERNEL_DS
  23254. +#define __KERNEL_DS (SUPER_DATA)
  23255. +#endif
  23256. +#define SUPER_PROGRAM (6)
  23257. +#define CPU_SPACE (7)
  23258. +
  23259. +#ifndef __ASSEMBLY__
  23260. +
  23261. +typedef struct {
  23262. + unsigned long seg;
  23263. +} mm_segment_t;
  23264. +
  23265. +#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
  23266. +#define USER_DS MAKE_MM_SEG(__USER_DS)
  23267. +#define KERNEL_DS MAKE_MM_SEG(__KERNEL_DS)
  23268. +
  23269. +/*
  23270. + * Get/set the SFC/DFC registers for MOVES instructions
  23271. + */
  23272. +
  23273. +static inline mm_segment_t get_fs(void)
  23274. +{
  23275. + return USER_DS;
  23276. +}
  23277. +
  23278. +static inline mm_segment_t get_ds(void)
  23279. +{
  23280. + /* return the supervisor data space code */
  23281. + return KERNEL_DS;
  23282. +}
  23283. +
  23284. +static inline void set_fs(mm_segment_t val)
  23285. +{
  23286. +}
  23287. +
  23288. +#define segment_eq(a,b) ((a).seg == (b).seg)
  23289. +
  23290. +#endif /* __ASSEMBLY__ */
  23291. +
  23292. +#endif /* _NIOS2NOMMU_SEGMENT_H */
  23293. diff --git a/include/asm-nios2nommu/semaphore-helper.h b/include/asm-nios2nommu/semaphore-helper.h
  23294. new file mode 100644
  23295. index 0000000..a8905d1
  23296. --- /dev/null
  23297. +++ b/include/asm-nios2nommu/semaphore-helper.h
  23298. @@ -0,0 +1,99 @@
  23299. +#ifndef _NIOS2NOMMU_SEMAPHORE_HELPER_H
  23300. +#define _NIOS2NOMMU_SEMAPHORE_HELPER_H
  23301. +
  23302. +/*--------------------------------------------------------------------
  23303. + *
  23304. + * include/asm-nios2nommu/semaphore.h
  23305. + *
  23306. + * SMP- and interrupt-safe semaphores helper functions.
  23307. + *
  23308. + * Derived from M68knommu
  23309. + *
  23310. + * (C) Copyright 1996 Linus Torvalds
  23311. + * m68k version by Andreas Schwab
  23312. + * Copyright (C) 2004 Microtronix Datacom Ltd
  23313. + *
  23314. + * This program is free software; you can redistribute it and/or modify
  23315. + * it under the terms of the GNU General Public License as published by
  23316. + * the Free Software Foundation; either version 2 of the License, or
  23317. + * (at your option) any later version.
  23318. + *
  23319. + * This program is distributed in the hope that it will be useful,
  23320. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23321. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23322. + * GNU General Public License for more details.
  23323. + *
  23324. + * Jan/20/2004 dgt NiosII
  23325. + *
  23326. + ---------------------------------------------------------------------*/
  23327. +
  23328. +/*
  23329. + * These two _must_ execute atomically wrt each other.
  23330. + */
  23331. +static inline void wake_one_more(struct semaphore * sem)
  23332. +{
  23333. + atomic_inc(&sem->waking);
  23334. +}
  23335. +
  23336. +static inline int waking_non_zero(struct semaphore *sem)
  23337. +{
  23338. + int ret;
  23339. + unsigned long flags;
  23340. +
  23341. + spin_lock_irqsave(&semaphore_wake_lock, flags);
  23342. + ret = 0;
  23343. + if (atomic_read(&sem->waking) > 0) {
  23344. + atomic_dec(&sem->waking);
  23345. + ret = 1;
  23346. + }
  23347. + spin_unlock_irqrestore(&semaphore_wake_lock, flags);
  23348. + return ret;
  23349. +}
  23350. +
  23351. +/*
  23352. + * waking_non_zero_interruptible:
  23353. + * 1 got the lock
  23354. + * 0 go to sleep
  23355. + * -EINTR interrupted
  23356. + */
  23357. +static inline int waking_non_zero_interruptible(struct semaphore *sem,
  23358. + struct task_struct *tsk)
  23359. +{
  23360. + int ret;
  23361. + unsigned long flags;
  23362. +
  23363. + spin_lock_irqsave(&semaphore_wake_lock, flags);
  23364. + ret = 0;
  23365. + if (atomic_read(&sem->waking) > 0) {
  23366. + atomic_dec(&sem->waking);
  23367. + ret = 1;
  23368. + } else if (signal_pending(tsk)) {
  23369. + atomic_inc(&sem->count);
  23370. + ret = -EINTR;
  23371. + }
  23372. + spin_unlock_irqrestore(&semaphore_wake_lock, flags);
  23373. + return ret;
  23374. +}
  23375. +
  23376. +/*
  23377. + * waking_non_zero_trylock:
  23378. + * 1 failed to lock
  23379. + * 0 got the lock
  23380. + */
  23381. +static inline int waking_non_zero_trylock(struct semaphore *sem)
  23382. +{
  23383. + int ret;
  23384. + unsigned long flags;
  23385. +
  23386. + spin_lock_irqsave(&semaphore_wake_lock, flags);
  23387. + ret = 1;
  23388. + if (atomic_read(&sem->waking) > 0) {
  23389. + atomic_dec(&sem->waking);
  23390. + ret = 0;
  23391. + } else
  23392. + atomic_inc(&sem->count);
  23393. + spin_unlock_irqrestore(&semaphore_wake_lock, flags);
  23394. + return ret;
  23395. +}
  23396. +
  23397. +#endif
  23398. diff --git a/include/asm-nios2nommu/semaphore.h b/include/asm-nios2nommu/semaphore.h
  23399. new file mode 100644
  23400. index 0000000..8d66c77
  23401. --- /dev/null
  23402. +++ b/include/asm-nios2nommu/semaphore.h
  23403. @@ -0,0 +1,152 @@
  23404. +#ifndef _NIOS2NOMMU_SEMAPHORE_H
  23405. +#define _NIOS2NOMMU_SEMAPHORE_H
  23406. +
  23407. +/*--------------------------------------------------------------------
  23408. + *
  23409. + * include/asm-nios2nommu/semaphore.h
  23410. + *
  23411. + * Interrupt-safe semaphores..
  23412. + *
  23413. + * Derived from M68knommu
  23414. + *
  23415. + * (C) Copyright 1996 Linus Torvalds
  23416. + * m68k version by Andreas Schwab
  23417. + * Copyright (C) 2004 Microtronix Datacom Ltd
  23418. + *
  23419. + * This program is free software; you can redistribute it and/or modify
  23420. + * it under the terms of the GNU General Public License as published by
  23421. + * the Free Software Foundation; either version 2 of the License, or
  23422. + * (at your option) any later version.
  23423. + *
  23424. + * This program is distributed in the hope that it will be useful,
  23425. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23426. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23427. + * GNU General Public License for more details.
  23428. + *
  23429. + * Jan/20/2004 dgt NiosII
  23430. + *
  23431. + ---------------------------------------------------------------------*/
  23432. +
  23433. +#define RW_LOCK_BIAS 0x01000000
  23434. +
  23435. +#ifndef __ASSEMBLY__
  23436. +
  23437. +#include <linux/linkage.h>
  23438. +#include <linux/wait.h>
  23439. +#include <linux/spinlock.h>
  23440. +#include <linux/rwsem.h>
  23441. +
  23442. +#include <asm/system.h>
  23443. +#include <asm/atomic.h>
  23444. +
  23445. +struct semaphore {
  23446. + atomic_t count;
  23447. + atomic_t waking;
  23448. + wait_queue_head_t wait;
  23449. +};
  23450. +
  23451. +#define __SEMAPHORE_INITIALIZER(name, n) \
  23452. +{ \
  23453. + .count = ATOMIC_INIT(n), \
  23454. + .waking = ATOMIC_INIT(0), \
  23455. + .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
  23456. +}
  23457. +
  23458. +#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
  23459. + struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
  23460. +
  23461. +#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
  23462. +#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
  23463. +
  23464. +static inline void sema_init (struct semaphore *sem, int val)
  23465. +{
  23466. + *sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val);
  23467. +}
  23468. +
  23469. +static inline void init_MUTEX (struct semaphore *sem)
  23470. +{
  23471. + sema_init(sem, 1);
  23472. +}
  23473. +
  23474. +static inline void init_MUTEX_LOCKED (struct semaphore *sem)
  23475. +{
  23476. + sema_init(sem, 0);
  23477. +}
  23478. +
  23479. +asmlinkage void __down_failed(void /* special register calling convention */);
  23480. +asmlinkage int __down_failed_interruptible(void /* params in registers */);
  23481. +asmlinkage int __down_failed_trylock(void /* params in registers */);
  23482. +asmlinkage void __up_wakeup(void /* special register calling convention */);
  23483. +
  23484. +asmlinkage void __down(struct semaphore * sem);
  23485. +asmlinkage int __down_interruptible(struct semaphore * sem);
  23486. +asmlinkage int __down_trylock(struct semaphore * sem);
  23487. +asmlinkage void __up(struct semaphore * sem);
  23488. +
  23489. +extern spinlock_t semaphore_wake_lock;
  23490. +
  23491. +/*
  23492. + * This is ugly, but we want the default case to fall through.
  23493. + * "down_failed" is a special asm handler that calls the C
  23494. + * routine that actually waits.
  23495. + */
  23496. +static inline void down(struct semaphore * sem)
  23497. +{
  23498. + might_sleep();
  23499. +
  23500. + #if 0
  23501. + ...Nios2 has no atomic "decrement memory"....
  23502. + #else
  23503. + if (atomic_dec_return(&sem->count) < 0)
  23504. + __down(sem);
  23505. + #endif
  23506. +}
  23507. +
  23508. +static inline int down_interruptible(struct semaphore * sem)
  23509. +{
  23510. + int ret = 0;
  23511. +
  23512. +
  23513. + might_sleep();
  23514. +
  23515. + #if 0
  23516. + ...Nios2 has no atomic "decrement memory"....
  23517. + #else
  23518. + if(atomic_dec_return(&sem->count) < 0)
  23519. + ret = __down_interruptible(sem);
  23520. + return ret;
  23521. + #endif
  23522. +}
  23523. +
  23524. +static inline int down_trylock(struct semaphore * sem)
  23525. +{
  23526. + #if 0
  23527. + ...Nios2 has no atomic "decrement memory"....
  23528. + #else
  23529. + int ret = 0;
  23530. +
  23531. + if (atomic_dec_return (&sem->count) < 0)
  23532. + ret = __down_trylock(sem);
  23533. + return ret;
  23534. + #endif
  23535. +}
  23536. +
  23537. +/*
  23538. + * Note! This is subtle. We jump to wake people up only if
  23539. + * the semaphore was negative (== somebody was waiting on it).
  23540. + * The default case (no contention) will result in NO
  23541. + * jumps for both down() and up().
  23542. + */
  23543. +static inline void up(struct semaphore * sem)
  23544. +{
  23545. + #if 0
  23546. + ...Nios2 has no atomic "increment memory"....
  23547. + #else
  23548. + if (atomic_inc_return(&sem->count) <= 0)
  23549. + __up(sem);
  23550. + #endif
  23551. +}
  23552. +
  23553. +#endif /* __ASSEMBLY__ */
  23554. +
  23555. +#endif
  23556. diff --git a/include/asm-nios2nommu/sembuf.h b/include/asm-nios2nommu/sembuf.h
  23557. new file mode 100644
  23558. index 0000000..e530cab
  23559. --- /dev/null
  23560. +++ b/include/asm-nios2nommu/sembuf.h
  23561. @@ -0,0 +1,48 @@
  23562. +#ifndef _NIOS_SEMBUF_H
  23563. +#define _NIOS_SEMBUF_H
  23564. +
  23565. +/*--------------------------------------------------------------------
  23566. + *
  23567. + * include/asm-nios2nommu/sembuf.h
  23568. + *
  23569. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  23570. + *
  23571. + * Copyright (C) 2004 Microtronix Datacom Ltd
  23572. + *
  23573. + * This program is free software; you can redistribute it and/or modify
  23574. + * it under the terms of the GNU General Public License as published by
  23575. + * the Free Software Foundation; either version 2 of the License, or
  23576. + * (at your option) any later version.
  23577. + *
  23578. + * This program is distributed in the hope that it will be useful,
  23579. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23580. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23581. + * GNU General Public License for more details.
  23582. + *
  23583. + *
  23584. + * Jan/20/2004 dgt NiosII
  23585. + *
  23586. + ---------------------------------------------------------------------*/
  23587. +
  23588. +
  23589. +/*
  23590. + * Note extra padding because this structure is passed back and forth
  23591. + * between kernel and user space.
  23592. + *
  23593. + * Pad space is left for:
  23594. + * - 64-bit time_t to solve y2038 problem
  23595. + * - 2 miscellaneous 32-bit values
  23596. + */
  23597. +
  23598. +struct semid64_ds {
  23599. + struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
  23600. + __kernel_time_t sem_otime; /* last semop time */
  23601. + unsigned long __unused1;
  23602. + __kernel_time_t sem_ctime; /* last change time */
  23603. + unsigned long __unused2;
  23604. + unsigned long sem_nsems; /* no. of semaphores in array */
  23605. + unsigned long __unused3;
  23606. + unsigned long __unused4;
  23607. +};
  23608. +
  23609. +#endif /* _NIOS_SEMBUF_H */
  23610. diff --git a/include/asm-nios2nommu/setup.h b/include/asm-nios2nommu/setup.h
  23611. new file mode 100644
  23612. index 0000000..c5a655a
  23613. --- /dev/null
  23614. +++ b/include/asm-nios2nommu/setup.h
  23615. @@ -0,0 +1,31 @@
  23616. +/* Copied from i386 port.
  23617. + * Just a place holder. We don't want to have to test x86 before
  23618. + * we include stuff
  23619. + *
  23620. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  23621. + *
  23622. + * All rights reserved.
  23623. + *
  23624. + * This program is free software; you can redistribute it and/or modify
  23625. + * it under the terms of the GNU General Public License as published by
  23626. + * the Free Software Foundation; either version 2 of the License, or
  23627. + * (at your option) any later version.
  23628. + *
  23629. + * This program is distributed in the hope that it will be useful, but
  23630. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  23631. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  23632. + * NON INFRINGEMENT. See the GNU General Public License for more
  23633. + * details.
  23634. + *
  23635. + * You should have received a copy of the GNU General Public License
  23636. + * along with this program; if not, write to the Free Software
  23637. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23638. + *
  23639. + */
  23640. +
  23641. +#ifndef _NIOS2_SETUP_H
  23642. +#define _NIOS2_SETUP_H
  23643. +
  23644. +#define COMMAND_LINE_SIZE 512
  23645. +
  23646. +#endif /* _NIOS2_SETUP_H */
  23647. diff --git a/include/asm-nios2nommu/shmbuf.h b/include/asm-nios2nommu/shmbuf.h
  23648. new file mode 100644
  23649. index 0000000..f6e6e7d
  23650. --- /dev/null
  23651. +++ b/include/asm-nios2nommu/shmbuf.h
  23652. @@ -0,0 +1,64 @@
  23653. +#ifndef _NIOS_SHMBUF_H
  23654. +#define _NIOS_SHMBUF_H
  23655. +
  23656. +/*--------------------------------------------------------------------
  23657. + *
  23658. + * include/asm-nios2nommu/shmbuf.h
  23659. + *
  23660. + * Derived from m68knommu
  23661. + *
  23662. + * Copyright (C) 2004 Microtronix Datacom Ltd
  23663. + *
  23664. + * This program is free software; you can redistribute it and/or modify
  23665. + * it under the terms of the GNU General Public License as published by
  23666. + * the Free Software Foundation; either version 2 of the License, or
  23667. + * (at your option) any later version.
  23668. + *
  23669. + * This program is distributed in the hope that it will be useful,
  23670. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23671. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23672. + * GNU General Public License for more details.
  23673. + *
  23674. + *
  23675. + * Jan/20/2004 dgt NiosII
  23676. + *
  23677. + ---------------------------------------------------------------------*/
  23678. +
  23679. +
  23680. +/* Note extra padding because this structure is passed back and forth
  23681. + * between kernel and user space.
  23682. + *
  23683. + * Pad space is left for:
  23684. + * - 64-bit time_t to solve y2038 problem
  23685. + * - 2 miscellaneous 32-bit values
  23686. + */
  23687. +
  23688. +struct shmid64_ds {
  23689. + struct ipc64_perm shm_perm; /* operation perms */
  23690. + size_t shm_segsz; /* size of segment (bytes) */
  23691. + __kernel_time_t shm_atime; /* last attach time */
  23692. + unsigned long __unused1;
  23693. + __kernel_time_t shm_dtime; /* last detach time */
  23694. + unsigned long __unused2;
  23695. + __kernel_time_t shm_ctime; /* last change time */
  23696. + unsigned long __unused3;
  23697. + __kernel_pid_t shm_cpid; /* pid of creator */
  23698. + __kernel_pid_t shm_lpid; /* pid of last operator */
  23699. + unsigned long shm_nattch; /* no. of current attaches */
  23700. + unsigned long __unused4;
  23701. + unsigned long __unused5;
  23702. +};
  23703. +
  23704. +struct shminfo64 {
  23705. + unsigned long shmmax;
  23706. + unsigned long shmmin;
  23707. + unsigned long shmmni;
  23708. + unsigned long shmseg;
  23709. + unsigned long shmall;
  23710. + unsigned long __unused1;
  23711. + unsigned long __unused2;
  23712. + unsigned long __unused3;
  23713. + unsigned long __unused4;
  23714. +};
  23715. +
  23716. +#endif /* _NIOS_SHMBUF_H */
  23717. diff --git a/include/asm-nios2nommu/shmparam.h b/include/asm-nios2nommu/shmparam.h
  23718. new file mode 100644
  23719. index 0000000..94efe2d
  23720. --- /dev/null
  23721. +++ b/include/asm-nios2nommu/shmparam.h
  23722. @@ -0,0 +1,30 @@
  23723. +#ifndef __NIOS2NOMMU_SHMPARAM_H__
  23724. +#define __NIOS2NOMMU_SHMPARAM_H__
  23725. +
  23726. +/*--------------------------------------------------------------------
  23727. + *
  23728. + * include/asm-nios2nommu/shmparam.h
  23729. + *
  23730. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  23731. + *
  23732. + * Copyright (C) 2004 Microtronix Datacom Ltd
  23733. + *
  23734. + * This program is free software; you can redistribute it and/or modify
  23735. + * it under the terms of the GNU General Public License as published by
  23736. + * the Free Software Foundation; either version 2 of the License, or
  23737. + * (at your option) any later version.
  23738. + *
  23739. + * This program is distributed in the hope that it will be useful,
  23740. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23741. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23742. + * GNU General Public License for more details.
  23743. + *
  23744. + *
  23745. + * Jan/20/2004 dgt NiosII
  23746. + *
  23747. + ---------------------------------------------------------------------*/
  23748. +
  23749. +
  23750. +#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
  23751. +
  23752. +#endif /* __NIOS2NOMMU_SHMPARAM_H__ */
  23753. diff --git a/include/asm-nios2nommu/sigcontext.h b/include/asm-nios2nommu/sigcontext.h
  23754. new file mode 100644
  23755. index 0000000..7321e7d
  23756. --- /dev/null
  23757. +++ b/include/asm-nios2nommu/sigcontext.h
  23758. @@ -0,0 +1,35 @@
  23759. +/*
  23760. + * Taken from the m68knommu.
  23761. + *
  23762. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  23763. + *
  23764. + * All rights reserved.
  23765. + *
  23766. + * This program is free software; you can redistribute it and/or modify
  23767. + * it under the terms of the GNU General Public License as published by
  23768. + * the Free Software Foundation; either version 2 of the License, or
  23769. + * (at your option) any later version.
  23770. + *
  23771. + * This program is distributed in the hope that it will be useful, but
  23772. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  23773. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  23774. + * NON INFRINGEMENT. See the GNU General Public License for more
  23775. + * details.
  23776. + *
  23777. + * You should have received a copy of the GNU General Public License
  23778. + * along with this program; if not, write to the Free Software
  23779. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23780. + *
  23781. + */
  23782. +
  23783. +#ifndef _ASM_NIOS2NOMMU_SIGCONTEXT_H
  23784. +#define _ASM_NIOS2NOMMU_SIGCONTEXT_H
  23785. +
  23786. +#include <asm/ptrace.h>
  23787. +
  23788. +struct sigcontext {
  23789. + struct pt_regs regs;
  23790. + unsigned long sc_mask; /* old sigmask */
  23791. +};
  23792. +
  23793. +#endif
  23794. diff --git a/include/asm-nios2nommu/siginfo.h b/include/asm-nios2nommu/siginfo.h
  23795. new file mode 100644
  23796. index 0000000..c047c0b
  23797. --- /dev/null
  23798. +++ b/include/asm-nios2nommu/siginfo.h
  23799. @@ -0,0 +1,28 @@
  23800. +/*
  23801. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  23802. + *
  23803. + * All rights reserved.
  23804. + *
  23805. + * This program is free software; you can redistribute it and/or modify
  23806. + * it under the terms of the GNU General Public License as published by
  23807. + * the Free Software Foundation; either version 2 of the License, or
  23808. + * (at your option) any later version.
  23809. + *
  23810. + * This program is distributed in the hope that it will be useful, but
  23811. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  23812. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  23813. + * NON INFRINGEMENT. See the GNU General Public License for more
  23814. + * details.
  23815. + *
  23816. + * You should have received a copy of the GNU General Public License
  23817. + * along with this program; if not, write to the Free Software
  23818. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23819. + *
  23820. + */
  23821. +
  23822. +#ifndef _NIOS2NOMMU_SIGINFO_H
  23823. +#define _NIOS2NOMMU_SIGINFO_H
  23824. +
  23825. +#include <asm-generic/siginfo.h>
  23826. +
  23827. +#endif
  23828. diff --git a/include/asm-nios2nommu/signal.h b/include/asm-nios2nommu/signal.h
  23829. new file mode 100644
  23830. index 0000000..c86a20c
  23831. --- /dev/null
  23832. +++ b/include/asm-nios2nommu/signal.h
  23833. @@ -0,0 +1,181 @@
  23834. +/*
  23835. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  23836. + *
  23837. + * All rights reserved.
  23838. + *
  23839. + * This program is free software; you can redistribute it and/or modify
  23840. + * it under the terms of the GNU General Public License as published by
  23841. + * the Free Software Foundation; either version 2 of the License, or
  23842. + * (at your option) any later version.
  23843. + *
  23844. + * This program is distributed in the hope that it will be useful, but
  23845. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  23846. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  23847. + * NON INFRINGEMENT. See the GNU General Public License for more
  23848. + * details.
  23849. + *
  23850. + * You should have received a copy of the GNU General Public License
  23851. + * along with this program; if not, write to the Free Software
  23852. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23853. + *
  23854. + */
  23855. +
  23856. +#ifndef _NIOS2_SIGNAL_H
  23857. +#define _NIOS2_SIGNAL_H
  23858. +
  23859. +#include <linux/types.h>
  23860. +
  23861. +/* Avoid too many header ordering problems. */
  23862. +struct siginfo;
  23863. +
  23864. +#ifdef __KERNEL__
  23865. +/* Most things should be clean enough to redefine this at will, if care
  23866. + is taken to make libc match. */
  23867. +
  23868. +#define _NSIG 64
  23869. +#define _NSIG_BPW 32
  23870. +#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
  23871. +
  23872. +typedef unsigned long old_sigset_t; /* at least 32 bits */
  23873. +
  23874. +typedef struct {
  23875. + unsigned long sig[_NSIG_WORDS];
  23876. +} sigset_t;
  23877. +
  23878. +#else
  23879. +/* Here we must cater to libcs that poke about in kernel headers. */
  23880. +
  23881. +#define NSIG 32
  23882. +typedef unsigned long sigset_t;
  23883. +
  23884. +#endif /* __KERNEL__ */
  23885. +
  23886. +#define SIGHUP 1
  23887. +#define SIGINT 2
  23888. +#define SIGQUIT 3
  23889. +#define SIGILL 4
  23890. +#define SIGTRAP 5
  23891. +#define SIGABRT 6
  23892. +#define SIGIOT 6
  23893. +#define SIGBUS 7
  23894. +#define SIGFPE 8
  23895. +#define SIGKILL 9
  23896. +#define SIGUSR1 10
  23897. +#define SIGSEGV 11
  23898. +#define SIGUSR2 12
  23899. +#define SIGPIPE 13
  23900. +#define SIGALRM 14
  23901. +#define SIGTERM 15
  23902. +#define SIGSTKFLT 16
  23903. +#define SIGCHLD 17
  23904. +#define SIGCONT 18
  23905. +#define SIGSTOP 19
  23906. +#define SIGTSTP 20
  23907. +#define SIGTTIN 21
  23908. +#define SIGTTOU 22
  23909. +#define SIGURG 23
  23910. +#define SIGXCPU 24
  23911. +#define SIGXFSZ 25
  23912. +#define SIGVTALRM 26
  23913. +#define SIGPROF 27
  23914. +#define SIGWINCH 28
  23915. +#define SIGIO 29
  23916. +#define SIGPOLL SIGIO
  23917. +/*
  23918. +#define SIGLOST 29
  23919. +*/
  23920. +#define SIGPWR 30
  23921. +#define SIGSYS 31
  23922. +#define SIGUNUSED 31
  23923. +
  23924. +/* These should not be considered constants from userland. */
  23925. +#define SIGRTMIN 32
  23926. +#define SIGRTMAX _NSIG
  23927. +
  23928. +/*
  23929. + * SA_FLAGS values:
  23930. + *
  23931. + * SA_ONSTACK indicates that a registered stack_t will be used.
  23932. + * SA_RESTART flag to get restarting signals (which were the default long ago)
  23933. + * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
  23934. + * SA_RESETHAND clears the handler when the signal is delivered.
  23935. + * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
  23936. + * SA_NODEFER prevents the current signal from being masked in the handler.
  23937. + *
  23938. + * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
  23939. + * Unix names RESETHAND and NODEFER respectively.
  23940. + */
  23941. +#define SA_NOCLDSTOP 0x00000001
  23942. +#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
  23943. +#define SA_SIGINFO 0x00000004
  23944. +#define SA_ONSTACK 0x08000000
  23945. +#define SA_RESTART 0x10000000
  23946. +#define SA_NODEFER 0x40000000
  23947. +#define SA_RESETHAND 0x80000000
  23948. +
  23949. +#define SA_NOMASK SA_NODEFER
  23950. +#define SA_ONESHOT SA_RESETHAND
  23951. +
  23952. +/*
  23953. + * sigaltstack controls
  23954. + */
  23955. +#define SS_ONSTACK 1
  23956. +#define SS_DISABLE 2
  23957. +
  23958. +#define MINSIGSTKSZ 2048
  23959. +#define SIGSTKSZ 8192
  23960. +
  23961. +#include <asm-generic/signal.h>
  23962. +
  23963. +#ifdef __KERNEL__
  23964. +struct old_sigaction {
  23965. + __sighandler_t sa_handler;
  23966. + old_sigset_t sa_mask;
  23967. + unsigned long sa_flags;
  23968. + void (*sa_restorer)(void);
  23969. +};
  23970. +
  23971. +struct sigaction {
  23972. + __sighandler_t sa_handler;
  23973. + unsigned long sa_flags;
  23974. + void (*sa_restorer)(void);
  23975. + sigset_t sa_mask; /* mask last for extensibility */
  23976. +};
  23977. +
  23978. +struct k_sigaction {
  23979. + struct sigaction sa;
  23980. +};
  23981. +#else
  23982. +/* Here we must cater to libcs that poke about in kernel headers. */
  23983. +
  23984. +struct sigaction {
  23985. + union {
  23986. + __sighandler_t _sa_handler;
  23987. + void (*_sa_sigaction)(int, struct siginfo *, void *);
  23988. + } _u;
  23989. + sigset_t sa_mask;
  23990. + unsigned long sa_flags;
  23991. + void (*sa_restorer)(void);
  23992. +};
  23993. +
  23994. +#define sa_handler _u._sa_handler
  23995. +#define sa_sigaction _u._sa_sigaction
  23996. +
  23997. +#endif /* __KERNEL__ */
  23998. +
  23999. +typedef struct sigaltstack {
  24000. + void *ss_sp;
  24001. + int ss_flags;
  24002. + size_t ss_size;
  24003. +} stack_t;
  24004. +
  24005. +#ifdef __KERNEL__
  24006. +
  24007. +#include <asm/sigcontext.h>
  24008. +#undef __HAVE_ARCH_SIG_BITOPS
  24009. +
  24010. +#define ptrace_signal_deliver(regs, cookie) do { } while (0)
  24011. +
  24012. +#endif /* __KERNEL__ */
  24013. +
  24014. +#endif /* _NIOS2_SIGNAL_H */
  24015. diff --git a/include/asm-nios2nommu/smp.h b/include/asm-nios2nommu/smp.h
  24016. new file mode 100644
  24017. index 0000000..fb23307
  24018. --- /dev/null
  24019. +++ b/include/asm-nios2nommu/smp.h
  24020. @@ -0,0 +1,32 @@
  24021. +#ifndef __ASM_SMP_H
  24022. +#define __ASM_SMP_H
  24023. +
  24024. +/*--------------------------------------------------------------------
  24025. + *
  24026. + * include/asm-nios2nommu/smp.h
  24027. + *
  24028. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  24029. + *
  24030. + * Copyright (C) 2004 Microtronix Datacom Ltd
  24031. + *
  24032. + * This program is free software; you can redistribute it and/or modify
  24033. + * it under the terms of the GNU General Public License as published by
  24034. + * the Free Software Foundation; either version 2 of the License, or
  24035. + * (at your option) any later version.
  24036. + *
  24037. + * This program is distributed in the hope that it will be useful,
  24038. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24039. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24040. + * GNU General Public License for more details.
  24041. + *
  24042. + *
  24043. + * Jan/20/2004 dgt NiosII
  24044. + *
  24045. + ---------------------------------------------------------------------*/
  24046. +
  24047. +
  24048. +#ifdef CONFIG_SMP
  24049. +#error SMP not supported
  24050. +#endif
  24051. +
  24052. +#endif
  24053. diff --git a/include/asm-nios2nommu/socket.h b/include/asm-nios2nommu/socket.h
  24054. new file mode 100644
  24055. index 0000000..5452e2b
  24056. --- /dev/null
  24057. +++ b/include/asm-nios2nommu/socket.h
  24058. @@ -0,0 +1,79 @@
  24059. +#ifndef _ASM_SOCKET_H
  24060. +#define _ASM_SOCKET_H
  24061. +
  24062. +/*--------------------------------------------------------------------
  24063. + *
  24064. + * include/asm-nios2nommu/socket.h
  24065. + *
  24066. + * Derived from m68knommu
  24067. + *
  24068. + * Copyright (C) 2004 Microtronix Datacom Ltd
  24069. + *
  24070. + * This program is free software; you can redistribute it and/or modify
  24071. + * it under the terms of the GNU General Public License as published by
  24072. + * the Free Software Foundation; either version 2 of the License, or
  24073. + * (at your option) any later version.
  24074. + *
  24075. + * This program is distributed in the hope that it will be useful,
  24076. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24077. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24078. + * GNU General Public License for more details.
  24079. + *
  24080. + *
  24081. + * Jan/20/2004 dgt NiosII
  24082. + *
  24083. + ---------------------------------------------------------------------*/
  24084. +
  24085. +
  24086. +#include <asm/sockios.h>
  24087. +
  24088. +/* For setsockopt(2) */
  24089. +#define SOL_SOCKET 1
  24090. +
  24091. +#define SO_DEBUG 1
  24092. +#define SO_REUSEADDR 2
  24093. +#define SO_TYPE 3
  24094. +#define SO_ERROR 4
  24095. +#define SO_DONTROUTE 5
  24096. +#define SO_BROADCAST 6
  24097. +#define SO_SNDBUF 7
  24098. +#define SO_RCVBUF 8
  24099. +#define SO_SNDBUFFORCE 32
  24100. +#define SO_RCVBUFFORCE 33
  24101. +#define SO_KEEPALIVE 9
  24102. +#define SO_OOBINLINE 10
  24103. +#define SO_NO_CHECK 11
  24104. +#define SO_PRIORITY 12
  24105. +#define SO_LINGER 13
  24106. +#define SO_BSDCOMPAT 14
  24107. +/* To add :#define SO_REUSEPORT 15 */
  24108. +#define SO_PASSCRED 16
  24109. +#define SO_PEERCRED 17
  24110. +#define SO_RCVLOWAT 18
  24111. +#define SO_SNDLOWAT 19
  24112. +#define SO_RCVTIMEO 20
  24113. +#define SO_SNDTIMEO 21
  24114. +
  24115. +/* Security levels - as per NRL IPv6 - don't actually do anything */
  24116. +#define SO_SECURITY_AUTHENTICATION 22
  24117. +#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
  24118. +#define SO_SECURITY_ENCRYPTION_NETWORK 24
  24119. +
  24120. +#define SO_BINDTODEVICE 25
  24121. +
  24122. +/* Socket filtering */
  24123. +#define SO_ATTACH_FILTER 26
  24124. +#define SO_DETACH_FILTER 27
  24125. +
  24126. +#define SO_PEERNAME 28
  24127. +#define SO_TIMESTAMP 29
  24128. +#define SCM_TIMESTAMP SO_TIMESTAMP
  24129. +
  24130. +#define SO_ACCEPTCONN 30
  24131. +
  24132. +#define SO_PEERSEC 31 /* ;dgt2;tmp; */
  24133. +#define SO_PASSSEC 34
  24134. +#define SO_TIMESTAMPNS 35
  24135. +#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
  24136. +
  24137. +#endif /* _ASM_SOCKET_H */
  24138. diff --git a/include/asm-nios2nommu/sockios.h b/include/asm-nios2nommu/sockios.h
  24139. new file mode 100644
  24140. index 0000000..c604aa7
  24141. --- /dev/null
  24142. +++ b/include/asm-nios2nommu/sockios.h
  24143. @@ -0,0 +1,39 @@
  24144. +#ifndef _ASM_NIOS_SOCKIOS_H
  24145. +#define _ASM_NIOS_SOCKIOS_H
  24146. +
  24147. +/*--------------------------------------------------------------------
  24148. + *
  24149. + * include/asm-nios2nommu/sockios.h
  24150. + *
  24151. + * Socket-level I/O control calls.
  24152. + *
  24153. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  24154. + *
  24155. + * Copyright (C) 2004 Microtronix Datacom Ltd
  24156. + *
  24157. + * This program is free software; you can redistribute it and/or modify
  24158. + * it under the terms of the GNU General Public License as published by
  24159. + * the Free Software Foundation; either version 2 of the License, or
  24160. + * (at your option) any later version.
  24161. + *
  24162. + * This program is distributed in the hope that it will be useful,
  24163. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24164. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24165. + * GNU General Public License for more details.
  24166. + *
  24167. + *
  24168. + * Jan/20/2004 dgt NiosII
  24169. + *
  24170. + ---------------------------------------------------------------------*/
  24171. +
  24172. +
  24173. +#define FIOSETOWN 0x8901
  24174. +#define SIOCSPGRP 0x8902
  24175. +#define FIOGETOWN 0x8903
  24176. +#define SIOCGPGRP 0x8904
  24177. +#define SIOCATMARK 0x8905
  24178. +#define SIOCGSTAMP 0x8906 /* Get stamp */
  24179. +#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
  24180. +
  24181. +#endif /* !(_ASM_NIOS_SOCKIOS_H) */
  24182. +
  24183. diff --git a/include/asm-nios2nommu/spi.h b/include/asm-nios2nommu/spi.h
  24184. new file mode 100644
  24185. index 0000000..6efb82c
  24186. --- /dev/null
  24187. +++ b/include/asm-nios2nommu/spi.h
  24188. @@ -0,0 +1,92 @@
  24189. +#ifndef _ASM_SPI_H_
  24190. +#define _ASM_SPI_H_ 1
  24191. +
  24192. +/*--------------------------------------------------------------------
  24193. + *
  24194. + * include/asm-nios2nommu/spi.h
  24195. + *
  24196. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  24197. + *
  24198. + * Copyright (C) 2004 Microtronix Datacom Ltd
  24199. + *
  24200. + * This program is free software; you can redistribute it and/or modify
  24201. + * it under the terms of the GNU General Public License as published by
  24202. + * the Free Software Foundation; either version 2 of the License, or
  24203. + * (at your option) any later version.
  24204. + *
  24205. + * This program is distributed in the hope that it will be useful,
  24206. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24207. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24208. + * GNU General Public License for more details.
  24209. + *
  24210. + *
  24211. + * Jan/20/2004 dgt NiosII
  24212. + *
  24213. + ---------------------------------------------------------------------*/
  24214. +
  24215. +
  24216. +#include <asm/nios.h>
  24217. +
  24218. +int register_NIOS_SPI( void );
  24219. +void unregister_NIOS_SPI( void );
  24220. +
  24221. +#if defined(MODULE)
  24222. +void cleanup_module( void );
  24223. +int init_module( void );
  24224. +#endif
  24225. +
  24226. +#if defined(__KERNEL__)
  24227. +int spi_reset ( void );
  24228. +#endif
  24229. +
  24230. +
  24231. +#define clockCS 0x01
  24232. +#define temperatureCS 0x02
  24233. +
  24234. +#define clock_read_base 0x00
  24235. +#define clock_write_base 0x80
  24236. +#define clock_read_control 0x0F
  24237. +#define clock_read_trickle 0x11
  24238. +
  24239. +#define clock_read_sec 0x00
  24240. +#define clock_read_min 0x01
  24241. +#define clock_read_hour 0x02
  24242. +#define clock_read_day 0x03
  24243. +#define clock_read_date 0x04
  24244. +#define clock_read_month 0x05
  24245. +#define clock_read_year 0x06
  24246. +
  24247. +#define clock_write_control 0x8F
  24248. +#define clock_write_trickle 0x91
  24249. +#define clock_write_sec 0x80
  24250. +#define clock_write_min 0x81
  24251. +#define clock_write_hour 0x82
  24252. +#define clock_write_day 0x83
  24253. +#define clock_write_date 0x84
  24254. +#define clock_write_month 0x85
  24255. +#define clock_write_year 0x86
  24256. +
  24257. +#define clock_write_ram_start 0xA0
  24258. +#define clock_write_ram_end 0x100
  24259. +#define clock_read_ram_start 0x20
  24260. +#define clock_read_ram_end 0x80
  24261. +
  24262. +
  24263. +#define clock_sec_def 0x11
  24264. +#define clock_min_def 0x59
  24265. +#define clock_hour_def 0x71
  24266. +#define clock_day_def 0x00
  24267. +#define clock_date_def 0x20
  24268. +#define clock_month_def 0x12
  24269. +#define clock_year_def 0x34
  24270. +
  24271. +#define temp_read_base 0x00
  24272. +#define temp_write_base 0x80
  24273. +#define temp_read_control 0x00
  24274. +#define temp_write_control 0x80
  24275. +#define temp_read_msb 0x02
  24276. +#define temp_read_lsb 0x01
  24277. +
  24278. +#define MAX_TEMP_VAR 10
  24279. +
  24280. +#endif /*_ASM_SPI_H_*/
  24281. diff --git a/include/asm-nios2nommu/spi_struct.h b/include/asm-nios2nommu/spi_struct.h
  24282. new file mode 100644
  24283. index 0000000..c7b2faf
  24284. --- /dev/null
  24285. +++ b/include/asm-nios2nommu/spi_struct.h
  24286. @@ -0,0 +1,57 @@
  24287. +// SPI Registers
  24288. +typedef volatile struct
  24289. + {
  24290. + int np_spirxdata; // Read-only, 1-16 bit
  24291. + int np_spitxdata; // Write-only, same width as rxdata
  24292. + int np_spistatus; // Read-only, 9-bit
  24293. + int np_spicontrol; // Read/Write, 9-bit
  24294. + int np_spireserved; // reserved
  24295. + int np_spislaveselect; // Read/Write, 1-16 bit, master only
  24296. + int np_spiendofpacket; // Read/write, same width as txdata, rxdata.
  24297. + } np_spi;
  24298. +
  24299. +// SPI Status Register Bits
  24300. +enum
  24301. + {
  24302. + np_spistatus_eop_bit = 9,
  24303. + np_spistatus_e_bit = 8,
  24304. + np_spistatus_rrdy_bit = 7,
  24305. + np_spistatus_trdy_bit = 6,
  24306. + np_spistatus_tmt_bit = 5,
  24307. + np_spistatus_toe_bit = 4,
  24308. + np_spistatus_roe_bit = 3,
  24309. +
  24310. + np_spistatus_eop_mask = (1 << 9),
  24311. + np_spistatus_e_mask = (1 << 8),
  24312. + np_spistatus_rrdy_mask = (1 << 7),
  24313. + np_spistatus_trdy_mask = (1 << 6),
  24314. + np_spistatus_tmt_mask = (1 << 5),
  24315. + np_spistatus_toe_mask = (1 << 4),
  24316. + np_spistatus_roe_mask = (1 << 3),
  24317. + };
  24318. +
  24319. +// SPI Control Register Bits
  24320. +enum
  24321. + {
  24322. + np_spicontrol_sso_bit = 10,
  24323. + np_spicontrol_ieop_bit = 9,
  24324. + np_spicontrol_ie_bit = 8,
  24325. + np_spicontrol_irrdy_bit = 7,
  24326. + np_spicontrol_itrdy_bit = 6,
  24327. + np_spicontrol_itoe_bit = 4,
  24328. + np_spicontrol_iroe_bit = 3,
  24329. +
  24330. + np_spicontrol_sso_mask = (1 << 10),
  24331. + np_spicontrol_ieop_mask = (1 << 9),
  24332. + np_spicontrol_ie_mask = (1 << 8),
  24333. + np_spicontrol_irrdy_mask = (1 << 7),
  24334. + np_spicontrol_itrdy_mask = (1 << 6),
  24335. + np_spicontrol_itoe_mask = (1 << 4),
  24336. + np_spicontrol_iroe_mask = (1 << 3),
  24337. + };
  24338. +
  24339. +// SPI Routines.
  24340. +int nr_spi_rxchar(np_spi *spiBase);
  24341. +int nr_spi_txchar(int i, np_spi *spiBase);
  24342. +
  24343. +
  24344. diff --git a/include/asm-nios2nommu/spinlock.h b/include/asm-nios2nommu/spinlock.h
  24345. new file mode 100644
  24346. index 0000000..f518755
  24347. --- /dev/null
  24348. +++ b/include/asm-nios2nommu/spinlock.h
  24349. @@ -0,0 +1,30 @@
  24350. +#ifndef __NIOS_SPINLOCK_H
  24351. +#define __NIOS_SPINLOCK_H
  24352. +
  24353. +/*--------------------------------------------------------------------
  24354. + *
  24355. + * include/asm-nios2nommu/spinlock.h
  24356. + *
  24357. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  24358. + *
  24359. + * Copyright (C) 2004 Microtronix Datacom Ltd
  24360. + *
  24361. + * This program is free software; you can redistribute it and/or modify
  24362. + * it under the terms of the GNU General Public License as published by
  24363. + * the Free Software Foundation; either version 2 of the License, or
  24364. + * (at your option) any later version.
  24365. + *
  24366. + * This program is distributed in the hope that it will be useful,
  24367. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24368. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24369. + * GNU General Public License for more details.
  24370. + *
  24371. + *
  24372. + * Jan/20/2004 dgt NiosII
  24373. + *
  24374. + ---------------------------------------------------------------------*/
  24375. +
  24376. +
  24377. +#error "Nios doesn't do SMP yet"
  24378. +
  24379. +#endif
  24380. diff --git a/include/asm-nios2nommu/stat.h b/include/asm-nios2nommu/stat.h
  24381. new file mode 100644
  24382. index 0000000..bd27a97
  24383. --- /dev/null
  24384. +++ b/include/asm-nios2nommu/stat.h
  24385. @@ -0,0 +1,102 @@
  24386. +#ifndef _ASMNIOS2NOMMU_STAT_H
  24387. +#define _ASMNIOS2NOMMU_STAT_H
  24388. +
  24389. +/*--------------------------------------------------------------------
  24390. + *
  24391. + * include/asm-nios2nommu/stat.h
  24392. + *
  24393. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  24394. + *
  24395. + * Copyright (C) 2004 Microtronix Datacom Ltd
  24396. + *
  24397. + * This program is free software; you can redistribute it and/or modify
  24398. + * it under the terms of the GNU General Public License as published by
  24399. + * the Free Software Foundation; either version 2 of the License, or
  24400. + * (at your option) any later version.
  24401. + *
  24402. + * This program is distributed in the hope that it will be useful,
  24403. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24404. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24405. + * GNU General Public License for more details.
  24406. + *
  24407. + *
  24408. + * Jan/20/2004 dgt NiosII
  24409. + *
  24410. + ---------------------------------------------------------------------*/
  24411. +
  24412. +
  24413. +struct __old_kernel_stat {
  24414. + unsigned short st_dev;
  24415. + unsigned short st_ino;
  24416. + unsigned short st_mode;
  24417. + unsigned short st_nlink;
  24418. + unsigned short st_uid;
  24419. + unsigned short st_gid;
  24420. + unsigned short st_rdev;
  24421. + unsigned long st_size;
  24422. + unsigned long st_atime;
  24423. + unsigned long st_mtime;
  24424. + unsigned long st_ctime;
  24425. +};
  24426. +
  24427. +struct stat {
  24428. + unsigned short st_dev;
  24429. + unsigned short __pad1;
  24430. + unsigned long st_ino;
  24431. + unsigned short st_mode;
  24432. + unsigned short st_nlink;
  24433. + unsigned short st_uid;
  24434. + unsigned short st_gid;
  24435. + unsigned short st_rdev;
  24436. + unsigned short __pad2;
  24437. + unsigned long st_size;
  24438. + unsigned long st_blksize;
  24439. + unsigned long st_blocks;
  24440. + unsigned long st_atime;
  24441. + unsigned long __unused1;
  24442. + unsigned long st_mtime;
  24443. + unsigned long __unused2;
  24444. + unsigned long st_ctime;
  24445. + unsigned long __unused3;
  24446. + unsigned long __unused4;
  24447. + unsigned long __unused5;
  24448. +};
  24449. +
  24450. +/* This matches struct stat64 in glibc2.1, hence the absolutely
  24451. + * insane amounts of padding around dev_t's.
  24452. + */
  24453. +struct stat64 {
  24454. + unsigned long long st_dev;
  24455. + unsigned char __pad1[4];
  24456. +
  24457. +#define STAT64_HAS_BROKEN_ST_INO 1
  24458. + unsigned long __st_ino;
  24459. +
  24460. + unsigned int st_mode;
  24461. + unsigned int st_nlink;
  24462. +
  24463. + unsigned long st_uid;
  24464. + unsigned long st_gid;
  24465. +
  24466. + unsigned long long st_rdev;
  24467. + unsigned char __pad3[4];
  24468. +
  24469. + long long st_size;
  24470. + unsigned long st_blksize;
  24471. +
  24472. + unsigned long __pad4; /* future possible st_blocks high bits */
  24473. + unsigned long st_blocks; /* Number 512-byte blocks allocated. */
  24474. +
  24475. + unsigned long st_atime;
  24476. + unsigned long st_atime_nsec;
  24477. +
  24478. + unsigned long st_mtime;
  24479. + unsigned long st_mtime_nsec;
  24480. +
  24481. + unsigned long st_ctime;
  24482. + unsigned long st_ctime_nsec;
  24483. +
  24484. + unsigned long long st_ino;
  24485. +};
  24486. +
  24487. +#endif
  24488. diff --git a/include/asm-nios2nommu/statfs.h b/include/asm-nios2nommu/statfs.h
  24489. new file mode 100644
  24490. index 0000000..c4637f6
  24491. --- /dev/null
  24492. +++ b/include/asm-nios2nommu/statfs.h
  24493. @@ -0,0 +1,30 @@
  24494. +#ifndef _NIOS2NOMMU_STATFS_H
  24495. +#define _NIOS2NOMMU_STATFS_H
  24496. +
  24497. +/*--------------------------------------------------------------------
  24498. + *
  24499. + * include/asm-nios2nommu/statfs.h
  24500. + *
  24501. + * Derived from M68knommu
  24502. + *
  24503. + * Copyright (C) 2004 Microtronix Datacom Ltd
  24504. + *
  24505. + * This program is free software; you can redistribute it and/or modify
  24506. + * it under the terms of the GNU General Public License as published by
  24507. + * the Free Software Foundation; either version 2 of the License, or
  24508. + * (at your option) any later version.
  24509. + *
  24510. + * This program is distributed in the hope that it will be useful,
  24511. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24512. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24513. + * GNU General Public License for more details.
  24514. + *
  24515. + *
  24516. + * Jan/20/2004 dgt NiosII
  24517. + *
  24518. + ---------------------------------------------------------------------*/
  24519. +
  24520. +
  24521. +#include <asm-generic/statfs.h>
  24522. +
  24523. +#endif /* _NIOS2NOMMU_STATFS_H */
  24524. diff --git a/include/asm-nios2nommu/string.h b/include/asm-nios2nommu/string.h
  24525. new file mode 100644
  24526. index 0000000..7e39479
  24527. --- /dev/null
  24528. +++ b/include/asm-nios2nommu/string.h
  24529. @@ -0,0 +1,45 @@
  24530. +#ifndef __NIOS_STRING_H__
  24531. +#define __NIOS_STRING_H__
  24532. +
  24533. +/*--------------------------------------------------------------------
  24534. + *
  24535. + * include/asm-nios2nommu/string.h
  24536. + *
  24537. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  24538. + *
  24539. + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  24540. + * Copyright (C) 2004 Microtronix Datacom Ltd
  24541. + *
  24542. + * This program is free software; you can redistribute it and/or modify
  24543. + * it under the terms of the GNU General Public License as published by
  24544. + * the Free Software Foundation; either version 2 of the License, or
  24545. + * (at your option) any later version.
  24546. + *
  24547. + * This program is distributed in the hope that it will be useful,
  24548. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24549. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24550. + * GNU General Public License for more details.
  24551. + *
  24552. + *
  24553. + * Jan/20/2004 dgt NiosII
  24554. + *
  24555. + ---------------------------------------------------------------------*/
  24556. +
  24557. +
  24558. +#ifdef __KERNEL__ /* only set these up for kernel code */
  24559. +
  24560. +#define __HAVE_ARCH_MEMMOVE
  24561. +void * memmove(void * d, const void * s, size_t count);
  24562. +#define __HAVE_ARCH_MEMCPY
  24563. +extern void * memcpy(void *d, const void *s, size_t count);
  24564. +#define __HAVE_ARCH_MEMSET
  24565. +extern void * memset(void * s,int c,size_t count);
  24566. +
  24567. +#if 0
  24568. +#define __HAVE_ARCH_BCOPY
  24569. +#define __HAVE_ARCH_STRLEN
  24570. +#endif
  24571. +
  24572. +#endif /* KERNEL */
  24573. +
  24574. +#endif /* !(__NIOS_STRING_H__) */
  24575. diff --git a/include/asm-nios2nommu/system.h b/include/asm-nios2nommu/system.h
  24576. new file mode 100644
  24577. index 0000000..7c35af0
  24578. --- /dev/null
  24579. +++ b/include/asm-nios2nommu/system.h
  24580. @@ -0,0 +1,172 @@
  24581. +/*
  24582. + * Taken from the m68k.
  24583. + *
  24584. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  24585. + *
  24586. + * All rights reserved.
  24587. + *
  24588. + * This program is free software; you can redistribute it and/or modify
  24589. + * it under the terms of the GNU General Public License as published by
  24590. + * the Free Software Foundation; either version 2 of the License, or
  24591. + * (at your option) any later version.
  24592. + *
  24593. + * This program is distributed in the hope that it will be useful, but
  24594. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  24595. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  24596. + * NON INFRINGEMENT. See the GNU General Public License for more
  24597. + * details.
  24598. + *
  24599. + * You should have received a copy of the GNU General Public License
  24600. + * along with this program; if not, write to the Free Software
  24601. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24602. + *
  24603. + */
  24604. +
  24605. +#ifndef _NIOS2NOMMU_SYSTEM_H
  24606. +#define _NIOS2NOMMU_SYSTEM_H
  24607. +
  24608. +#include <linux/linkage.h>
  24609. +#include <linux/compiler.h>
  24610. +#include <asm/segment.h>
  24611. +#include <asm/entry.h>
  24612. +#include <asm/nios.h>
  24613. +
  24614. +/*
  24615. + * switch_to(n) should switch tasks to task ptr, first checking that
  24616. + * ptr isn't the current task, in which case it does nothing. This
  24617. + * also clears the TS-flag if the task we switched to has used the
  24618. + * math co-processor latest.
  24619. + */
  24620. +
  24621. +/*
  24622. + */
  24623. +asmlinkage void resume(void);
  24624. +#define switch_to(prev,next,last) \
  24625. +{ \
  24626. + void *_last; \
  24627. + __asm__ __volatile__( \
  24628. + "mov r4, %1\n" \
  24629. + "mov r5, %2\n" \
  24630. + "call resume\n" \
  24631. + "mov %0,r4\n" \
  24632. + : "=r" (_last) \
  24633. + : "r" (prev), "r" (next) \
  24634. + : "r4","r5","r7","r8","ra"); \
  24635. + (last) = _last; \
  24636. +}
  24637. +
  24638. +#define local_irq_enable() __asm__ __volatile__ ( \
  24639. + "rdctl r8, status\n" \
  24640. + "ori r8, r8, 1\n" \
  24641. + "wrctl status, r8\n" \
  24642. + : : : "r8")
  24643. +
  24644. +#define local_irq_disable() __asm__ __volatile__ ( \
  24645. + "rdctl r8, status\n" \
  24646. + "andi r8, r8, 0xfffe\n" \
  24647. + "wrctl status, r8\n" \
  24648. + : : : "r8")
  24649. +
  24650. +#define local_save_flags(x) __asm__ __volatile__ ( \
  24651. + "rdctl r8, status\n" \
  24652. + "mov %0, r8\n" \
  24653. + :"=r" (x) : : "r8", "memory")
  24654. +
  24655. +#define local_irq_restore(x) __asm__ __volatile__ ( \
  24656. + "mov r8, %0\n" \
  24657. + "wrctl status, r8\n" \
  24658. + : :"r" (x) : "memory")
  24659. +
  24660. +/* For spinlocks etc */
  24661. +#define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } while (0)
  24662. +
  24663. +#define irqs_disabled() \
  24664. +({ \
  24665. + unsigned long flags; \
  24666. + local_save_flags(flags); \
  24667. + ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \
  24668. +})
  24669. +
  24670. +#define iret() __asm__ __volatile__ ("eret": : :"memory", "ea")
  24671. +
  24672. +/*
  24673. + * Force strict CPU ordering.
  24674. + * Not really required on m68k...
  24675. + */
  24676. +#define nop() asm volatile ("nop"::)
  24677. +#define mb() asm volatile ("" : : :"memory")
  24678. +#define rmb() asm volatile ("" : : :"memory")
  24679. +#define wmb() asm volatile ("" : : :"memory")
  24680. +#define set_rmb(var, value) do { xchg(&var, value); } while (0)
  24681. +#define set_mb(var, value) set_rmb(var, value)
  24682. +#define set_wmb(var, value) do { var = value; wmb(); } while (0)
  24683. +
  24684. +#ifdef CONFIG_SMP
  24685. +#define smp_mb() mb()
  24686. +#define smp_rmb() rmb()
  24687. +#define smp_wmb() wmb()
  24688. +#define smp_read_barrier_depends() read_barrier_depends()
  24689. +#else
  24690. +#define smp_mb() barrier()
  24691. +#define smp_rmb() barrier()
  24692. +#define smp_wmb() barrier()
  24693. +#define smp_read_barrier_depends() do { } while(0)
  24694. +#endif
  24695. +
  24696. +#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
  24697. +#define tas(ptr) (xchg((ptr),1))
  24698. +
  24699. +struct __xchg_dummy { unsigned long a[100]; };
  24700. +#define __xg(x) ((volatile struct __xchg_dummy *)(x))
  24701. +
  24702. +static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
  24703. +{
  24704. + unsigned long tmp, flags;
  24705. +
  24706. + local_irq_save(flags);
  24707. +
  24708. + switch (size) {
  24709. + case 1:
  24710. + __asm__ __volatile__( \
  24711. + "ldb %0, %2\n" \
  24712. + "stb %1, %2\n" \
  24713. + : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
  24714. + break;
  24715. + case 2:
  24716. + __asm__ __volatile__( \
  24717. + "ldh %0, %2\n" \
  24718. + "sth %1, %2\n" \
  24719. + : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
  24720. + break;
  24721. + case 4:
  24722. + __asm__ __volatile__( \
  24723. + "ldw %0, %2\n" \
  24724. + "stw %1, %2\n" \
  24725. + : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
  24726. + break;
  24727. + }
  24728. + local_irq_restore(flags);
  24729. + return tmp;
  24730. +}
  24731. +
  24732. +/*
  24733. + * Atomic compare and exchange. Compare OLD with MEM, if identical,
  24734. + * store NEW in MEM. Return the initial value in MEM. Success is
  24735. + * indicated by comparing RETURN with OLD.
  24736. + */
  24737. +#define __HAVE_ARCH_CMPXCHG 1
  24738. +
  24739. +static __inline__ unsigned long
  24740. +cmpxchg(volatile int *p, int old, int new)
  24741. +{
  24742. + unsigned long flags;
  24743. + int prev;
  24744. +
  24745. + local_irq_save(flags);
  24746. + if ((prev = *p) == old)
  24747. + *p = new;
  24748. + local_irq_restore(flags);
  24749. + return(prev);
  24750. +}
  24751. +
  24752. +#endif /* _NIOS2NOMMU_SYSTEM_H */
  24753. diff --git a/include/asm-nios2nommu/termbits.h b/include/asm-nios2nommu/termbits.h
  24754. new file mode 100644
  24755. index 0000000..74ef61d
  24756. --- /dev/null
  24757. +++ b/include/asm-nios2nommu/termbits.h
  24758. @@ -0,0 +1,210 @@
  24759. +#ifndef __ARCH_NIOS_TERMBITS_H__
  24760. +#define __ARCH_NIOS_TERMBITS_H__
  24761. +
  24762. +/*--------------------------------------------------------------------
  24763. + *
  24764. + * include/asm-nios2nommu/termbits.h
  24765. + *
  24766. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  24767. + *
  24768. + * Copyright (C) 2004 Microtronix Datacom Ltd
  24769. + *
  24770. + * This program is free software; you can redistribute it and/or modify
  24771. + * it under the terms of the GNU General Public License as published by
  24772. + * the Free Software Foundation; either version 2 of the License, or
  24773. + * (at your option) any later version.
  24774. + *
  24775. + * This program is distributed in the hope that it will be useful,
  24776. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24777. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24778. + * GNU General Public License for more details.
  24779. + *
  24780. + *
  24781. + * Jan/20/2004 dgt NiosII
  24782. + *
  24783. + ---------------------------------------------------------------------*/
  24784. +
  24785. +
  24786. +#include <linux/posix_types.h>
  24787. +
  24788. +typedef unsigned char cc_t;
  24789. +typedef unsigned int speed_t;
  24790. +typedef unsigned int tcflag_t;
  24791. +
  24792. +#define NCCS 19
  24793. +struct termios {
  24794. + tcflag_t c_iflag; /* input mode flags */
  24795. + tcflag_t c_oflag; /* output mode flags */
  24796. + tcflag_t c_cflag; /* control mode flags */
  24797. + tcflag_t c_lflag; /* local mode flags */
  24798. + cc_t c_line; /* line discipline */
  24799. + cc_t c_cc[NCCS]; /* control characters */
  24800. +};
  24801. +
  24802. +struct ktermios {
  24803. + tcflag_t c_iflag; /* input mode flags */
  24804. + tcflag_t c_oflag; /* output mode flags */
  24805. + tcflag_t c_cflag; /* control mode flags */
  24806. + tcflag_t c_lflag; /* local mode flags */
  24807. + cc_t c_line; /* line discipline */
  24808. + cc_t c_cc[NCCS]; /* control characters */
  24809. + speed_t c_ispeed; /* input speed */
  24810. + speed_t c_ospeed; /* output speed */
  24811. +};
  24812. +
  24813. +/* c_cc characters */
  24814. +#define VINTR 0
  24815. +#define VQUIT 1
  24816. +#define VERASE 2
  24817. +#define VKILL 3
  24818. +#define VEOF 4
  24819. +#define VTIME 5
  24820. +#define VMIN 6
  24821. +#define VSWTC 7
  24822. +#define VSTART 8
  24823. +#define VSTOP 9
  24824. +#define VSUSP 10
  24825. +#define VEOL 11
  24826. +#define VREPRINT 12
  24827. +#define VDISCARD 13
  24828. +#define VWERASE 14
  24829. +#define VLNEXT 15
  24830. +#define VEOL2 16
  24831. +
  24832. +
  24833. +/* c_iflag bits */
  24834. +#define IGNBRK 0000001
  24835. +#define BRKINT 0000002
  24836. +#define IGNPAR 0000004
  24837. +#define PARMRK 0000010
  24838. +#define INPCK 0000020
  24839. +#define ISTRIP 0000040
  24840. +#define INLCR 0000100
  24841. +#define IGNCR 0000200
  24842. +#define ICRNL 0000400
  24843. +#define IUCLC 0001000
  24844. +#define IXON 0002000
  24845. +#define IXANY 0004000
  24846. +#define IXOFF 0010000
  24847. +#define IMAXBEL 0020000
  24848. +#define IUTF8 0040000
  24849. +
  24850. +/* c_oflag bits */
  24851. +#define OPOST 0000001
  24852. +#define OLCUC 0000002
  24853. +#define ONLCR 0000004
  24854. +#define OCRNL 0000010
  24855. +#define ONOCR 0000020
  24856. +#define ONLRET 0000040
  24857. +#define OFILL 0000100
  24858. +#define OFDEL 0000200
  24859. +#define NLDLY 0000400
  24860. +#define NL0 0000000
  24861. +#define NL1 0000400
  24862. +#define CRDLY 0003000
  24863. +#define CR0 0000000
  24864. +#define CR1 0001000
  24865. +#define CR2 0002000
  24866. +#define CR3 0003000
  24867. +#define TABDLY 0014000
  24868. +#define TAB0 0000000
  24869. +#define TAB1 0004000
  24870. +#define TAB2 0010000
  24871. +#define TAB3 0014000
  24872. +#define XTABS 0014000
  24873. +#define BSDLY 0020000
  24874. +#define BS0 0000000
  24875. +#define BS1 0020000
  24876. +#define VTDLY 0040000
  24877. +#define VT0 0000000
  24878. +#define VT1 0040000
  24879. +#define FFDLY 0100000
  24880. +#define FF0 0000000
  24881. +#define FF1 0100000
  24882. +
  24883. +/* c_cflag bit meaning */
  24884. +#define CBAUD 0010017
  24885. +#define B0 0000000 /* hang up */
  24886. +#define B50 0000001
  24887. +#define B75 0000002
  24888. +#define B110 0000003
  24889. +#define B134 0000004
  24890. +#define B150 0000005
  24891. +#define B200 0000006
  24892. +#define B300 0000007
  24893. +#define B600 0000010
  24894. +#define B1200 0000011
  24895. +#define B1800 0000012
  24896. +#define B2400 0000013
  24897. +#define B4800 0000014
  24898. +#define B9600 0000015
  24899. +#define B19200 0000016
  24900. +#define B38400 0000017
  24901. +#define EXTA B19200
  24902. +#define EXTB B38400
  24903. +#define CSIZE 0000060
  24904. +#define CS5 0000000
  24905. +#define CS6 0000020
  24906. +#define CS7 0000040
  24907. +#define CS8 0000060
  24908. +#define CSTOPB 0000100
  24909. +#define CREAD 0000200
  24910. +#define PARENB 0000400
  24911. +#define PARODD 0001000
  24912. +#define HUPCL 0002000
  24913. +#define CLOCAL 0004000
  24914. +#define CBAUDEX 0010000
  24915. +#define B57600 0010001
  24916. +#define B115200 0010002
  24917. +#define B230400 0010003
  24918. +#define B460800 0010004
  24919. +#define B500000 0010005
  24920. +#define B576000 0010006
  24921. +#define B921600 0010007
  24922. +#define B1000000 0010010
  24923. +#define B1152000 0010011
  24924. +#define B1500000 0010012
  24925. +#define B2000000 0010013
  24926. +#define B2500000 0010014
  24927. +#define B3000000 0010015
  24928. +#define B3500000 0010016
  24929. +#define B4000000 0010017
  24930. +#define CIBAUD 002003600000 /* input baud rate (not used) */
  24931. +#define CMSPAR 010000000000 /* mark or space (stick) parity */
  24932. +#define CRTSCTS 020000000000 /* flow control */
  24933. +
  24934. +/* c_lflag bits */
  24935. +#define ISIG 0000001
  24936. +#define ICANON 0000002
  24937. +#define XCASE 0000004
  24938. +#define ECHO 0000010
  24939. +#define ECHOE 0000020
  24940. +#define ECHOK 0000040
  24941. +#define ECHONL 0000100
  24942. +#define NOFLSH 0000200
  24943. +#define TOSTOP 0000400
  24944. +#define ECHOCTL 0001000
  24945. +#define ECHOPRT 0002000
  24946. +#define ECHOKE 0004000
  24947. +#define FLUSHO 0010000
  24948. +#define PENDIN 0040000
  24949. +#define IEXTEN 0100000
  24950. +
  24951. +
  24952. +/* tcflow() and TCXONC use these */
  24953. +#define TCOOFF 0
  24954. +#define TCOON 1
  24955. +#define TCIOFF 2
  24956. +#define TCION 3
  24957. +
  24958. +/* tcflush() and TCFLSH use these */
  24959. +#define TCIFLUSH 0
  24960. +#define TCOFLUSH 1
  24961. +#define TCIOFLUSH 2
  24962. +
  24963. +/* tcsetattr uses these */
  24964. +#define TCSANOW 0
  24965. +#define TCSADRAIN 1
  24966. +#define TCSAFLUSH 2
  24967. +
  24968. +#endif /* __ARCH_NIOS_TERMBITS_H__ */
  24969. diff --git a/include/asm-nios2nommu/termios.h b/include/asm-nios2nommu/termios.h
  24970. new file mode 100644
  24971. index 0000000..db0dddf
  24972. --- /dev/null
  24973. +++ b/include/asm-nios2nommu/termios.h
  24974. @@ -0,0 +1,132 @@
  24975. +#ifndef _NIOS_TERMIOS_H
  24976. +#define _NIOS_TERMIOS_H
  24977. +
  24978. +/*--------------------------------------------------------------------
  24979. + *
  24980. + * include/asm-nios2nommu/termios.h
  24981. + *
  24982. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  24983. + *
  24984. + * Copyright (C) 2004 Microtronix Datacom Ltd
  24985. + *
  24986. + * This program is free software; you can redistribute it and/or modify
  24987. + * it under the terms of the GNU General Public License as published by
  24988. + * the Free Software Foundation; either version 2 of the License, or
  24989. + * (at your option) any later version.
  24990. + *
  24991. + * This program is distributed in the hope that it will be useful,
  24992. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24993. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24994. + * GNU General Public License for more details.
  24995. + *
  24996. + *
  24997. + * Jan/20/2004 dgt NiosII
  24998. + *
  24999. + ---------------------------------------------------------------------*/
  25000. +
  25001. +
  25002. +#include <asm/termbits.h>
  25003. +#include <asm/ioctls.h>
  25004. +
  25005. +struct winsize {
  25006. + unsigned short ws_row;
  25007. + unsigned short ws_col;
  25008. + unsigned short ws_xpixel;
  25009. + unsigned short ws_ypixel;
  25010. +};
  25011. +
  25012. +#define NCC 8
  25013. +struct termio {
  25014. + unsigned short c_iflag; /* input mode flags */
  25015. + unsigned short c_oflag; /* output mode flags */
  25016. + unsigned short c_cflag; /* control mode flags */
  25017. + unsigned short c_lflag; /* local mode flags */
  25018. + unsigned char c_line; /* line discipline */
  25019. + unsigned char c_cc[NCC]; /* control characters */
  25020. +};
  25021. +
  25022. +#ifdef __KERNEL__
  25023. +/* intr=^C quit=^| erase=del kill=^U
  25024. + eof=^D vtime=\0 vmin=\1 sxtc=\0
  25025. + start=^Q stop=^S susp=^Z eol=\0
  25026. + reprint=^R discard=^U werase=^W lnext=^V
  25027. + eol2=\0
  25028. +*/
  25029. +#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
  25030. +#endif
  25031. +
  25032. +/* modem lines */
  25033. +#define TIOCM_LE 0x001
  25034. +#define TIOCM_DTR 0x002
  25035. +#define TIOCM_RTS 0x004
  25036. +#define TIOCM_ST 0x008
  25037. +#define TIOCM_SR 0x010
  25038. +#define TIOCM_CTS 0x020
  25039. +#define TIOCM_CAR 0x040
  25040. +#define TIOCM_RNG 0x080
  25041. +#define TIOCM_DSR 0x100
  25042. +#define TIOCM_CD TIOCM_CAR
  25043. +#define TIOCM_RI TIOCM_RNG
  25044. +#define TIOCM_OUT1 0x2000
  25045. +#define TIOCM_OUT2 0x4000
  25046. +#define TIOCM_LOOP 0x8000
  25047. +
  25048. +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
  25049. +
  25050. +/* line disciplines */
  25051. +#define N_TTY 0
  25052. +#define N_SLIP 1
  25053. +#define N_MOUSE 2
  25054. +#define N_PPP 3
  25055. +#define N_STRIP 4
  25056. +#define N_AX25 5
  25057. +#define N_X25 6 /* X.25 async */
  25058. +#define N_6PACK 7
  25059. +#define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
  25060. +#define N_R3964 9 /* Reserved for Simatic R3964 module */
  25061. +#define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
  25062. +#define N_IRDA 11 /* Linux IrDa - http://irda.sourceforge.net/ */
  25063. +#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
  25064. +#define N_HDLC 13 /* synchronous HDLC */
  25065. +#define N_SYNC_PPP 14
  25066. +#define N_HCI 15 /* Bluetooth HCI UART */
  25067. +
  25068. +#ifdef __KERNEL__
  25069. +
  25070. +/*
  25071. + * Translate a "termio" structure into a "termios". Ugh.
  25072. + */
  25073. +#define user_termio_to_kernel_termios(termios, termio) \
  25074. +({ \
  25075. + unsigned short tmp; \
  25076. + get_user(tmp, &(termio)->c_iflag); \
  25077. + (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
  25078. + get_user(tmp, &(termio)->c_oflag); \
  25079. + (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
  25080. + get_user(tmp, &(termio)->c_cflag); \
  25081. + (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
  25082. + get_user(tmp, &(termio)->c_lflag); \
  25083. + (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
  25084. + get_user((termios)->c_line, &(termio)->c_line); \
  25085. + copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
  25086. +})
  25087. +
  25088. +/*
  25089. + * Translate a "termios" structure into a "termio". Ugh.
  25090. + */
  25091. +#define kernel_termios_to_user_termio(termio, termios) \
  25092. +({ \
  25093. + put_user((termios)->c_iflag, &(termio)->c_iflag); \
  25094. + put_user((termios)->c_oflag, &(termio)->c_oflag); \
  25095. + put_user((termios)->c_cflag, &(termio)->c_cflag); \
  25096. + put_user((termios)->c_lflag, &(termio)->c_lflag); \
  25097. + put_user((termios)->c_line, &(termio)->c_line); \
  25098. + copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
  25099. +})
  25100. +
  25101. +#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
  25102. +#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
  25103. +
  25104. +#endif /* __KERNEL__ */
  25105. +
  25106. +#endif /* _NIOS_TERMIOS_H */
  25107. diff --git a/include/asm-nios2nommu/thread_info.h b/include/asm-nios2nommu/thread_info.h
  25108. new file mode 100644
  25109. index 0000000..6d51e0c
  25110. --- /dev/null
  25111. +++ b/include/asm-nios2nommu/thread_info.h
  25112. @@ -0,0 +1,127 @@
  25113. +/* thread_info.h: niosnommu low-level thread information
  25114. + * adapted from the m68knommu
  25115. + *
  25116. + * Copyright (C) 2004 Microtronix Datacom Ltd.
  25117. + * Copyright (C) 2002 Microtronix Datacom
  25118. + *
  25119. + * - Incorporating suggestions made by Linus Torvalds and Dave Miller
  25120. + *
  25121. + * All rights reserved.
  25122. + *
  25123. + * This program is free software; you can redistribute it and/or modify
  25124. + * it under the terms of the GNU General Public License as published by
  25125. + * the Free Software Foundation; either version 2 of the License, or
  25126. + * (at your option) any later version.
  25127. + *
  25128. + * This program is distributed in the hope that it will be useful, but
  25129. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  25130. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  25131. + * NON INFRINGEMENT. See the GNU General Public License for more
  25132. + * details.
  25133. + *
  25134. + * You should have received a copy of the GNU General Public License
  25135. + * along with this program; if not, write to the Free Software
  25136. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25137. + *
  25138. + */
  25139. +
  25140. +#ifndef _ASM_THREAD_INFO_H
  25141. +#define _ASM_THREAD_INFO_H
  25142. +
  25143. +#include <asm/page.h>
  25144. +
  25145. +#ifdef __KERNEL__
  25146. +
  25147. +#ifndef __ASSEMBLY__
  25148. +
  25149. +/*
  25150. + * low level task data.
  25151. + */
  25152. +struct thread_info {
  25153. + struct task_struct *task; /* main task structure */
  25154. + struct exec_domain *exec_domain; /* execution domain */
  25155. + unsigned long flags; /* low level flags */
  25156. + int cpu; /* cpu we're on */
  25157. + int preempt_count; /* 0 => preemptable, <0 => BUG*/
  25158. + struct restart_block restart_block;
  25159. +};
  25160. +
  25161. +/*
  25162. + * macros/functions for gaining access to the thread information structure
  25163. + */
  25164. +#define INIT_THREAD_INFO(tsk) \
  25165. +{ \
  25166. + .task = &tsk, \
  25167. + .exec_domain = &default_exec_domain, \
  25168. + .flags = 0, \
  25169. + .cpu = 0, \
  25170. + .preempt_count = 1, \
  25171. + .restart_block = { \
  25172. + .fn = do_no_restart_syscall, \
  25173. + }, \
  25174. +}
  25175. +
  25176. +#define init_thread_info (init_thread_union.thread_info)
  25177. +#define init_stack (init_thread_union.stack)
  25178. +
  25179. +
  25180. +/* how to get the thread information struct from C
  25181. + usable only in supervisor mode */
  25182. +static inline struct thread_info *current_thread_info(void)
  25183. +{
  25184. + struct thread_info *ti;
  25185. + __asm__ __volatile__(
  25186. + "mov %0, sp\n"
  25187. + "and %0, %0, %1\n"
  25188. + : "=&r"(ti)
  25189. + : "r" (~(THREAD_SIZE-1))
  25190. + );
  25191. + return ti;
  25192. +}
  25193. +
  25194. +/* thread information allocation */
  25195. +#define alloc_thread_info(tsk) ((struct thread_info *) \
  25196. + __get_free_pages(GFP_KERNEL, 1))
  25197. +#define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
  25198. +#define put_thread_info(ti) put_task_struct((ti)->task)
  25199. +
  25200. +#define PREEMPT_ACTIVE 0x4000000
  25201. +
  25202. +/*
  25203. + * thread information flag bit numbers
  25204. + */
  25205. +#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  25206. +#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
  25207. +#define TIF_SIGPENDING 2 /* signal pending */
  25208. +#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  25209. +#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
  25210. + TIF_NEED_RESCHED */
  25211. +#define TIF_MEMDIE 5
  25212. +
  25213. +/* as above, but as bit values */
  25214. +#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  25215. +#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  25216. +#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  25217. +#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  25218. +#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  25219. +
  25220. +#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
  25221. +
  25222. +#else /* __ASSEMBLY__ */
  25223. +
  25224. +/* how to get the thread information struct from ASM
  25225. + usable only in supervisor mode */
  25226. +.macro GET_THREAD_INFO reg
  25227. +.if THREAD_SIZE & 0xffff0000
  25228. + andhi \reg, sp, %hi(~(THREAD_SIZE-1))
  25229. +.else
  25230. + addi \reg, r0, %lo(~(THREAD_SIZE-1))
  25231. + and \reg, \reg, sp
  25232. +.endif
  25233. +.endm
  25234. +
  25235. +#endif /* __ASSEMBLY__ */
  25236. +
  25237. +#endif /* __KERNEL__ */
  25238. +
  25239. +#endif /* _ASM_THREAD_INFO_H */
  25240. diff --git a/include/asm-nios2nommu/timer_struct.h b/include/asm-nios2nommu/timer_struct.h
  25241. new file mode 100644
  25242. index 0000000..d811a37
  25243. --- /dev/null
  25244. +++ b/include/asm-nios2nommu/timer_struct.h
  25245. @@ -0,0 +1,38 @@
  25246. +
  25247. +// ----------------------------------------------
  25248. +// Timer Peripheral
  25249. +
  25250. +// Timer Registers
  25251. +typedef volatile struct
  25252. + {
  25253. + int np_timerstatus; // read only, 2 bits (any write to clear TO)
  25254. + int np_timercontrol; // write/readable, 4 bits
  25255. + int np_timerperiodl; // write/readable, 16 bits
  25256. + int np_timerperiodh; // write/readable, 16 bits
  25257. + int np_timersnapl; // read only, 16 bits
  25258. + int np_timersnaph; // read only, 16 bits
  25259. + } np_timer;
  25260. +
  25261. +// Timer Register Bits
  25262. +enum
  25263. + {
  25264. + np_timerstatus_run_bit = 1, // timer is running
  25265. + np_timerstatus_to_bit = 0, // timer has timed out
  25266. +
  25267. + np_timercontrol_stop_bit = 3, // stop the timer
  25268. + np_timercontrol_start_bit = 2, // start the timer
  25269. + np_timercontrol_cont_bit = 1, // continous mode
  25270. + np_timercontrol_ito_bit = 0, // enable time out interrupt
  25271. +
  25272. + np_timerstatus_run_mask = (1<<1), // timer is running
  25273. + np_timerstatus_to_mask = (1<<0), // timer has timed out
  25274. +
  25275. + np_timercontrol_stop_mask = (1<<3), // stop the timer
  25276. + np_timercontrol_start_mask = (1<<2), // start the timer
  25277. + np_timercontrol_cont_mask = (1<<1), // continous mode
  25278. + np_timercontrol_ito_mask = (1<<0) // enable time out interrupt
  25279. + };
  25280. +
  25281. +// Timer Routines
  25282. +int nr_timer_milliseconds(void); // Starts on first call, hogs timer1.
  25283. +
  25284. diff --git a/include/asm-nios2nommu/timex.h b/include/asm-nios2nommu/timex.h
  25285. new file mode 100644
  25286. index 0000000..abd48cc
  25287. --- /dev/null
  25288. +++ b/include/asm-nios2nommu/timex.h
  25289. @@ -0,0 +1,48 @@
  25290. +#ifndef _ASMNIOS2NOMMU_TIMEX_H
  25291. +#define _ASMNIOS2NOMMU_TIMEX_H
  25292. +
  25293. +/*--------------------------------------------------------------------
  25294. + *
  25295. + * include/asm-nios2nommu/timex.h
  25296. + *
  25297. + * timex specifications
  25298. + *
  25299. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  25300. + *
  25301. + * Copyright (C) 2004 Microtronix Datacom Ltd
  25302. + *
  25303. + * This program is free software; you can redistribute it and/or modify
  25304. + * it under the terms of the GNU General Public License as published by
  25305. + * the Free Software Foundation; either version 2 of the License, or
  25306. + * (at your option) any later version.
  25307. + *
  25308. + * This program is distributed in the hope that it will be useful,
  25309. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25310. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25311. + * GNU General Public License for more details.
  25312. + *
  25313. + *
  25314. + * Jan/20/2004 dgt NiosII
  25315. + *
  25316. + ---------------------------------------------------------------------*/
  25317. +
  25318. +
  25319. +#include <asm/nios.h>
  25320. +
  25321. +
  25322. +#define CLOCK_TICK_RATE nasys_clock_freq /* Underlying HZ */
  25323. +
  25324. +#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */
  25325. +
  25326. +#define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
  25327. + (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
  25328. + << (SHIFT_SCALE-SHIFT_HZ)) / HZ)
  25329. +
  25330. +typedef unsigned long cycles_t;
  25331. +
  25332. +static inline cycles_t get_cycles(void)
  25333. +{
  25334. + return 0;
  25335. +}
  25336. +
  25337. +#endif
  25338. diff --git a/include/asm-nios2nommu/tlb.h b/include/asm-nios2nommu/tlb.h
  25339. new file mode 100644
  25340. index 0000000..c597b25
  25341. --- /dev/null
  25342. +++ b/include/asm-nios2nommu/tlb.h
  25343. @@ -0,0 +1,35 @@
  25344. +#ifndef __NIOS_TLB_H__
  25345. +#define __NIOS_TLB_H__
  25346. +
  25347. +/*--------------------------------------------------------------------
  25348. + *
  25349. + * include/asm-nios2nommu/tlb.h
  25350. + *
  25351. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  25352. + *
  25353. + * Copyright (C) 2003 Microtronix Datacom Ltd
  25354. + * Copyright (C) 2002 NEC Corporation
  25355. + * Copyright (C) 2002 Miles Bader <miles@gnu.org>
  25356. + *
  25357. + * This program is free software; you can redistribute it and/or modify
  25358. + * it under the terms of the GNU General Public License as published by
  25359. + * the Free Software Foundation; either version 2 of the License, or
  25360. + * (at your option) any later version.
  25361. + *
  25362. + * This program is distributed in the hope that it will be useful,
  25363. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25364. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25365. + * GNU General Public License for more details.
  25366. + *
  25367. + *
  25368. + * Written by Miles Bader <miles@gnu.org>
  25369. + * Jan/20/2004 dgt NiosII
  25370. + *
  25371. + ---------------------------------------------------------------------*/
  25372. +
  25373. +#define tlb_flush(tlb) ((void)0)
  25374. +
  25375. +#include <asm-generic/tlb.h>
  25376. +
  25377. +#endif /* __NIOS_TLB_H__ */
  25378. +
  25379. diff --git a/include/asm-nios2nommu/tlbflush.h b/include/asm-nios2nommu/tlbflush.h
  25380. new file mode 100644
  25381. index 0000000..63cbe52
  25382. --- /dev/null
  25383. +++ b/include/asm-nios2nommu/tlbflush.h
  25384. @@ -0,0 +1,86 @@
  25385. +#ifndef _NIOS2NOMMU_TLBFLUSH_H
  25386. +#define _NIOS2NOMMU_TLBFLUSH_H
  25387. +
  25388. +/*--------------------------------------------------------------------
  25389. + *
  25390. + * include/asm-nios2nommu/tlbflush.h
  25391. + *
  25392. + * Ported from m68knommu.
  25393. + *
  25394. + * Copyright (C) 2003 Microtronix Datacom Ltd.
  25395. + *
  25396. + * All rights reserved.
  25397. + *
  25398. + * This program is free software; you can redistribute it and/or modify
  25399. + * it under the terms of the GNU General Public License as published by
  25400. + * the Free Software Foundation; either version 2 of the License, or
  25401. + * (at your option) any later version.
  25402. + *
  25403. + * This program is distributed in the hope that it will be useful, but
  25404. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  25405. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  25406. + * NON INFRINGEMENT. See the GNU General Public License for more
  25407. + * details.
  25408. + *
  25409. + * You should have received a copy of the GNU General Public License
  25410. + * along with this program; if not, write to the Free Software
  25411. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25412. + *
  25413. + *
  25414. + * Jan/20/2004 dgt NiosII
  25415. + *
  25416. + ---------------------------------------------------------------------*/
  25417. +
  25418. +#include <asm/setup.h>
  25419. +
  25420. +/*
  25421. + * flush all user-space atc entries.
  25422. + */
  25423. +static inline void __flush_tlb(void)
  25424. +{
  25425. + BUG();
  25426. +}
  25427. +
  25428. +static inline void __flush_tlb_one(unsigned long addr)
  25429. +{
  25430. + BUG();
  25431. +}
  25432. +
  25433. +#define flush_tlb() __flush_tlb()
  25434. +
  25435. +/*
  25436. + * flush all atc entries (both kernel and user-space entries).
  25437. + */
  25438. +static inline void flush_tlb_all(void)
  25439. +{
  25440. + BUG();
  25441. +}
  25442. +
  25443. +static inline void flush_tlb_mm(struct mm_struct *mm)
  25444. +{
  25445. + BUG();
  25446. +}
  25447. +
  25448. +static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
  25449. +{
  25450. + BUG();
  25451. +}
  25452. +
  25453. +static inline void flush_tlb_range(struct mm_struct *mm,
  25454. + unsigned long start, unsigned long end)
  25455. +{
  25456. + BUG();
  25457. +}
  25458. +
  25459. +extern inline void flush_tlb_kernel_page(unsigned long addr)
  25460. +{
  25461. + BUG();
  25462. +}
  25463. +
  25464. +extern inline void flush_tlb_pgtables(struct mm_struct *mm,
  25465. + unsigned long start, unsigned long end)
  25466. +{
  25467. + BUG();
  25468. +}
  25469. +
  25470. +#endif /* _NIOS2NOMMU_TLBFLUSH_H */
  25471. diff --git a/include/asm-nios2nommu/topology.h b/include/asm-nios2nommu/topology.h
  25472. new file mode 100644
  25473. index 0000000..cfe1054
  25474. --- /dev/null
  25475. +++ b/include/asm-nios2nommu/topology.h
  25476. @@ -0,0 +1,30 @@
  25477. +#ifndef _ASM_NIOS2NOMMU_TOPOLOGY_H
  25478. +#define _ASM_NIOS2NOMMU_TOPOLOGY_H
  25479. +
  25480. +/*--------------------------------------------------------------------
  25481. + *
  25482. + * include/asm-nios2nommu/topology.h
  25483. + *
  25484. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  25485. + *
  25486. + * Copyright (C) 2004 Microtronix Datacom Ltd
  25487. + *
  25488. + * This program is free software; you can redistribute it and/or modify
  25489. + * it under the terms of the GNU General Public License as published by
  25490. + * the Free Software Foundation; either version 2 of the License, or
  25491. + * (at your option) any later version.
  25492. + *
  25493. + * This program is distributed in the hope that it will be useful,
  25494. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25495. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25496. + * GNU General Public License for more details.
  25497. + *
  25498. + *
  25499. + * Jan/20/2004 dgt NiosII
  25500. + *
  25501. + ---------------------------------------------------------------------*/
  25502. +
  25503. +
  25504. +#include <asm-generic/topology.h>
  25505. +
  25506. +#endif /* _ASM_NIOS2NOMMU_TOPOLOGY_H */
  25507. diff --git a/include/asm-nios2nommu/traps.h b/include/asm-nios2nommu/traps.h
  25508. new file mode 100644
  25509. index 0000000..e03ef7f
  25510. --- /dev/null
  25511. +++ b/include/asm-nios2nommu/traps.h
  25512. @@ -0,0 +1,27 @@
  25513. +/*
  25514. + * Copyright (C) 2004, Microtronix Datacom Ltd.
  25515. + *
  25516. + * All rights reserved.
  25517. + *
  25518. + * This program is free software; you can redistribute it and/or modify
  25519. + * it under the terms of the GNU General Public License as published by
  25520. + * the Free Software Foundation; either version 2 of the License, or
  25521. + * (at your option) any later version.
  25522. + *
  25523. + * This program is distributed in the hope that it will be useful, but
  25524. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  25525. + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  25526. + * NON INFRINGEMENT. See the GNU General Public License for more
  25527. + * details.
  25528. + *
  25529. + * You should have received a copy of the GNU General Public License
  25530. + * along with this program; if not, write to the Free Software
  25531. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25532. + *
  25533. + */
  25534. +#ifndef _NIOS2_TRAPS_H
  25535. +#define _NIOS2_TRAPS_H
  25536. +
  25537. +#define TRAP_ID_SYSCALL 0
  25538. +#define TRAP_ID_APPDEBUG 1
  25539. +#endif /* !(_NIOS2_TRAPS_H) */
  25540. diff --git a/include/asm-nios2nommu/types.h b/include/asm-nios2nommu/types.h
  25541. new file mode 100644
  25542. index 0000000..dd7a48e
  25543. --- /dev/null
  25544. +++ b/include/asm-nios2nommu/types.h
  25545. @@ -0,0 +1,91 @@
  25546. +#ifndef _NIOS_TYPES_H
  25547. +#define _NIOS_TYPES_H
  25548. +
  25549. +/*--------------------------------------------------------------------
  25550. + *
  25551. + * include/asm-nios2nommu/types.h
  25552. + *
  25553. + * Derived from m68knommu
  25554. + *
  25555. + * Copyright (C) 2004 Microtronix Datacom Ltd
  25556. + *
  25557. + * This program is free software; you can redistribute it and/or modify
  25558. + * it under the terms of the GNU General Public License as published by
  25559. + * the Free Software Foundation; either version 2 of the License, or
  25560. + * (at your option) any later version.
  25561. + *
  25562. + * This program is distributed in the hope that it will be useful,
  25563. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25564. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25565. + * GNU General Public License for more details.
  25566. + *
  25567. + *
  25568. + * Jan/20/2004 dgt NiosII
  25569. + *
  25570. + ---------------------------------------------------------------------*/
  25571. +
  25572. +
  25573. +/*
  25574. + * This file is never included by application software unless
  25575. + * explicitly requested (e.g., via linux/types.h) in which case the
  25576. + * application is Linux specific so (user-) name space pollution is
  25577. + * not a major issue. However, for interoperability, libraries still
  25578. + * need to be careful to avoid a name clashes.
  25579. + */
  25580. +
  25581. +#ifndef __ASSEMBLY__
  25582. +
  25583. +typedef unsigned short umode_t;
  25584. +
  25585. +/*
  25586. + * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
  25587. + * header files exported to user space
  25588. + */
  25589. +
  25590. +typedef __signed__ char __s8;
  25591. +typedef unsigned char __u8;
  25592. +
  25593. +typedef __signed__ short __s16;
  25594. +typedef unsigned short __u16;
  25595. +
  25596. +typedef __signed__ int __s32;
  25597. +typedef unsigned int __u32;
  25598. +
  25599. +#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
  25600. +typedef __signed__ long long __s64;
  25601. +typedef unsigned long long __u64;
  25602. +#endif
  25603. +
  25604. +#endif /* __ASSEMBLY__ */
  25605. +
  25606. +/*
  25607. + * These aren't exported outside the kernel to avoid name space clashes
  25608. + */
  25609. +#ifdef __KERNEL__
  25610. +
  25611. +#define BITS_PER_LONG 32
  25612. +
  25613. +#ifndef __ASSEMBLY__
  25614. +
  25615. +typedef signed char s8;
  25616. +typedef unsigned char u8;
  25617. +
  25618. +typedef signed short s16;
  25619. +typedef unsigned short u16;
  25620. +
  25621. +typedef signed int s32;
  25622. +typedef unsigned int u32;
  25623. +
  25624. +typedef signed long long s64;
  25625. +typedef unsigned long long u64;
  25626. +
  25627. +/* DMA addresses are always 32-bits wide */
  25628. +
  25629. +typedef u32 dma_addr_t;
  25630. +typedef u32 dma64_addr_t;
  25631. +
  25632. +#endif /* __ASSEMBLY__ */
  25633. +
  25634. +#endif /* __KERNEL__ */
  25635. +
  25636. +#endif /* _NIOS_TYPES_H */
  25637. diff --git a/include/asm-nios2nommu/uaccess.h b/include/asm-nios2nommu/uaccess.h
  25638. new file mode 100644
  25639. index 0000000..e7ea20a
  25640. --- /dev/null
  25641. +++ b/include/asm-nios2nommu/uaccess.h
  25642. @@ -0,0 +1,184 @@
  25643. +#ifndef __NIOS2NOMMU_UACCESS_H
  25644. +#define __NIOS2NOMMU_UACCESS_H
  25645. +
  25646. +/*--------------------------------------------------------------------
  25647. + *
  25648. + * asm-nios2nommu/uaccess.h
  25649. + *
  25650. + * User space memory access functions
  25651. + *
  25652. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  25653. + *
  25654. + * Copyright (C) 2004 Microtronix Datacom Ltd
  25655. + *
  25656. + * This program is free software; you can redistribute it and/or modify
  25657. + * it under the terms of the GNU General Public License as published by
  25658. + * the Free Software Foundation; either version 2 of the License, or
  25659. + * (at your option) any later version.
  25660. + *
  25661. + * This program is distributed in the hope that it will be useful,
  25662. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25663. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25664. + * GNU General Public License for more details.
  25665. + *
  25666. + *
  25667. + * Ported from asm-m68knommu/uaccess.h --wentao
  25668. + * Jan/20/2004 dgt NiosII
  25669. + *
  25670. + ---------------------------------------------------------------------*/
  25671. +
  25672. +
  25673. +#include <linux/sched.h>
  25674. +#include <linux/mm.h>
  25675. +#include <asm/segment.h>
  25676. +#include <asm/nios.h>
  25677. +
  25678. +#define VERIFY_READ 0
  25679. +#define VERIFY_WRITE 1
  25680. +
  25681. +#define access_ok(type,addr,size) _access_ok((unsigned long)(addr),(size))
  25682. +
  25683. +static inline int _access_ok(unsigned long addr, unsigned long size)
  25684. +{
  25685. + return (((unsigned long)addr < (unsigned long)nasys_program_mem_end) &&
  25686. + (((unsigned long)addr >= (unsigned long)nasys_program_mem)));
  25687. +}
  25688. +
  25689. +extern inline int verify_area(int type, const void * addr, unsigned long size)
  25690. +{
  25691. + return access_ok(type,addr,size)?0:-EFAULT;
  25692. +}
  25693. +
  25694. +/*
  25695. + * The exception table consists of pairs of addresses: the first is the
  25696. + * address of an instruction that is allowed to fault, and the second is
  25697. + * the address at which the program should continue. No registers are
  25698. + * modified, so it is entirely up to the continuation code to figure out
  25699. + * what to do.
  25700. + *
  25701. + * All the routines below use bits of fixup code that are out of line
  25702. + * with the main instruction path. This means when everything is well,
  25703. + * we don't even have to jump over them. Further, they do not intrude
  25704. + * on our cache or tlb entries.
  25705. + */
  25706. +
  25707. +#define ARCH_HAS_SEARCH_EXTABLE
  25708. +//;dgt2;tmp;
  25709. +
  25710. +struct exception_table_entry
  25711. +{
  25712. + unsigned long insn, fixup;
  25713. +};
  25714. +
  25715. +/* Returns 0 if exception not found and fixup otherwise. */
  25716. +extern unsigned long search_exception_table(unsigned long);
  25717. +
  25718. +
  25719. +/*
  25720. + * These are the main single-value transfer routines. They automatically
  25721. + * use the right size if we just have the right pointer type.
  25722. + */
  25723. +
  25724. +#define put_user(x, ptr) \
  25725. +({ \
  25726. + int __pu_err = 0; \
  25727. + typeof(*(ptr)) __pu_val = (x); \
  25728. + switch (sizeof (*(ptr))) { \
  25729. + case 1: \
  25730. + case 2: \
  25731. + case 4: \
  25732. + case 8: \
  25733. + memcpy(ptr, &__pu_val, sizeof (*(ptr))); \
  25734. + break; \
  25735. + default: \
  25736. + __pu_err = __put_user_bad(); \
  25737. + break; \
  25738. + } \
  25739. + __pu_err; \
  25740. +})
  25741. +#define __put_user(x, ptr) put_user(x, ptr)
  25742. +
  25743. +extern int __put_user_bad(void);
  25744. +
  25745. +/*
  25746. + * Tell gcc we read from memory instead of writing: this is because
  25747. + * we do not write to any memory gcc knows about, so there are no
  25748. + * aliasing issues.
  25749. + */
  25750. +
  25751. +#define __ptr(x) ((unsigned long *)(x))
  25752. +
  25753. +#define get_user(x, ptr) \
  25754. +({ \
  25755. + int __gu_err = 0; \
  25756. + typeof(*(ptr)) __gu_val = 0; \
  25757. + switch (sizeof(*(ptr))) { \
  25758. + case 1: \
  25759. + case 2: \
  25760. + case 4: \
  25761. + case 8: \
  25762. + memcpy(&__gu_val, ptr, sizeof (*(ptr))); \
  25763. + break; \
  25764. + default: \
  25765. + __gu_val = 0; \
  25766. + __gu_err = __get_user_bad(); \
  25767. + break; \
  25768. + } \
  25769. + (x) = __gu_val; \
  25770. + __gu_err; \
  25771. +})
  25772. +#define __get_user(x, ptr) get_user(x, ptr)
  25773. +
  25774. +extern int __get_user_bad(void);
  25775. +
  25776. +#define copy_from_user(to, from, n) (memcpy(to, from, n), 0)
  25777. +#define copy_to_user(to, from, n) (memcpy(to, from, n), 0)
  25778. +
  25779. +#define __copy_from_user(to, from, n) copy_from_user(to, from, n)
  25780. +#define __copy_to_user(to, from, n) copy_to_user(to, from, n)
  25781. +#define __copy_to_user_inatomic __copy_to_user
  25782. +#define __copy_from_user_inatomic __copy_from_user
  25783. +
  25784. +#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })
  25785. +
  25786. +#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; })
  25787. +
  25788. +/*
  25789. + * Copy a null terminated string from userspace.
  25790. + */
  25791. +
  25792. +static inline long
  25793. +strncpy_from_user(char *dst, const char *src, long count)
  25794. +{
  25795. + char *tmp;
  25796. + strncpy(dst, src, count);
  25797. + for (tmp = dst; *tmp && count > 0; tmp++, count--)
  25798. + ;
  25799. + return(tmp - dst); /* DAVIDM should we count a NUL ? check getname */
  25800. +}
  25801. +
  25802. +/*
  25803. + * Return the size of a string (including the ending 0)
  25804. + *
  25805. + * Return 0 on exception, a value greater than N if too long
  25806. + */
  25807. +static inline long strnlen_user(const char *src, long n)
  25808. +{
  25809. + return(strlen(src) + 1); /* DAVIDM make safer */
  25810. +}
  25811. +
  25812. +#define strlen_user(str) strnlen_user(str, 32767)
  25813. +
  25814. +/*
  25815. + * Zero Userspace
  25816. + */
  25817. +
  25818. +static inline unsigned long __clear_user(void *to, unsigned long n)
  25819. +{
  25820. + memset(to, 0, n);
  25821. + return(0);
  25822. +}
  25823. +
  25824. +#define clear_user(to, n) __clear_user(to, n)
  25825. +
  25826. +#endif /* _NIOS2NOMMU_UACCESS_H */
  25827. diff --git a/include/asm-nios2nommu/uart_struct.h b/include/asm-nios2nommu/uart_struct.h
  25828. new file mode 100644
  25829. index 0000000..d955192
  25830. --- /dev/null
  25831. +++ b/include/asm-nios2nommu/uart_struct.h
  25832. @@ -0,0 +1,83 @@
  25833. +
  25834. +// UART Registers
  25835. +typedef volatile struct
  25836. + {
  25837. + int np_uartrxdata; // Read-only, 8-bit
  25838. + int np_uarttxdata; // Write-only, 8-bit
  25839. + int np_uartstatus; // Read-only, 8-bit
  25840. + int np_uartcontrol; // Read/Write, 9-bit
  25841. + int np_uartdivisor; // Read/Write, 16-bit, optional
  25842. + int np_uartendofpacket; // Read/Write, end-of-packet character
  25843. + } np_uart;
  25844. +
  25845. +// UART Status Register Bits
  25846. +enum
  25847. + {
  25848. + np_uartstatus_eop_bit = 12,
  25849. + np_uartstatus_cts_bit = 11,
  25850. + np_uartstatus_dcts_bit = 10,
  25851. + np_uartstatus_e_bit = 8,
  25852. + np_uartstatus_rrdy_bit = 7,
  25853. + np_uartstatus_trdy_bit = 6,
  25854. + np_uartstatus_tmt_bit = 5,
  25855. + np_uartstatus_toe_bit = 4,
  25856. + np_uartstatus_roe_bit = 3,
  25857. + np_uartstatus_brk_bit = 2,
  25858. + np_uartstatus_fe_bit = 1,
  25859. + np_uartstatus_pe_bit = 0,
  25860. +
  25861. + np_uartstatus_eop_mask = (1<<12),
  25862. + np_uartstatus_cts_mask = (1<<11),
  25863. + np_uartstatus_dcts_mask = (1<<10),
  25864. + np_uartstatus_e_mask = (1<<8),
  25865. + np_uartstatus_rrdy_mask = (1<<7),
  25866. + np_uartstatus_trdy_mask = (1<<6),
  25867. + np_uartstatus_tmt_mask = (1<<5),
  25868. + np_uartstatus_toe_mask = (1<<4),
  25869. + np_uartstatus_roe_mask = (1<<3),
  25870. + np_uartstatus_brk_mask = (1<<2),
  25871. + np_uartstatus_fe_mask = (1<<1),
  25872. + np_uartstatus_pe_mask = (1<<0)
  25873. + };
  25874. +
  25875. +// UART Control Register Bits
  25876. +enum
  25877. + {
  25878. + np_uartcontrol_ieop_bit = 12,
  25879. + np_uartcontrol_rts_bit = 11,
  25880. + np_uartcontrol_idcts_bit = 10,
  25881. + np_uartcontrol_tbrk_bit = 9,
  25882. + np_uartcontrol_ie_bit = 8,
  25883. + np_uartcontrol_irrdy_bit = 7,
  25884. + np_uartcontrol_itrdy_bit = 6,
  25885. + np_uartcontrol_itmt_bit = 5,
  25886. + np_uartcontrol_itoe_bit = 4,
  25887. + np_uartcontrol_iroe_bit = 3,
  25888. + np_uartcontrol_ibrk_bit = 2,
  25889. + np_uartcontrol_ife_bit = 1,
  25890. + np_uartcontrol_ipe_bit = 0,
  25891. +
  25892. + np_uartcontrol_ieop_mask = (1<<12),
  25893. + np_uartcontrol_rts_mask = (1<<11),
  25894. + np_uartcontrol_idcts_mask = (1<<10),
  25895. + np_uartcontrol_tbrk_mask = (1<<9),
  25896. + np_uartcontrol_ie_mask = (1<<8),
  25897. + np_uartcontrol_irrdy_mask = (1<<7),
  25898. + np_uartcontrol_itrdy_mask = (1<<6),
  25899. + np_uartcontrol_itmt_mask = (1<<5),
  25900. + np_uartcontrol_itoe_mask = (1<<4),
  25901. + np_uartcontrol_iroe_mask = (1<<3),
  25902. + np_uartcontrol_ibrk_mask = (1<<2),
  25903. + np_uartcontrol_ife_mask = (1<<1),
  25904. + np_uartcontrol_ipe_mask = (1<<0)
  25905. + };
  25906. +
  25907. +// UART Routines
  25908. +int nr_uart_rxchar(np_uart *uartBase); // 0 for default UART
  25909. +void nr_uart_txcr(void);
  25910. +void nr_uart_txchar(int c,np_uart *uartBase); // 0 for default UART
  25911. +void nr_uart_txhex(int x); // 16 or 32 bits
  25912. +void nr_uart_txhex16(short x);
  25913. +void nr_uart_txhex32(long x);
  25914. +void nr_uart_txstring(char *s);
  25915. +
  25916. diff --git a/include/asm-nios2nommu/ucontext.h b/include/asm-nios2nommu/ucontext.h
  25917. new file mode 100644
  25918. index 0000000..f2e7ce2
  25919. --- /dev/null
  25920. +++ b/include/asm-nios2nommu/ucontext.h
  25921. @@ -0,0 +1,63 @@
  25922. +#ifndef _NIOSKNOMMU_UCONTEXT_H
  25923. +#define _NIOSKNOMMU_UCONTEXT_H
  25924. +
  25925. +/*--------------------------------------------------------------------
  25926. + *
  25927. + * include/asm-nios2nommu/ucontext.h
  25928. + *
  25929. + * Derived from M68knommu
  25930. + *
  25931. + * Copyright (C) 2004 Microtronix Datacom Ltd
  25932. + *
  25933. + * This program is free software; you can redistribute it and/or modify
  25934. + * it under the terms of the GNU General Public License as published by
  25935. + * the Free Software Foundation; either version 2 of the License, or
  25936. + * (at your option) any later version.
  25937. + *
  25938. + * This program is distributed in the hope that it will be useful,
  25939. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25940. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25941. + * GNU General Public License for more details.
  25942. + *
  25943. + *
  25944. + * Jan/20/2004 dgt NiosII
  25945. + *
  25946. + ---------------------------------------------------------------------*/
  25947. +
  25948. +
  25949. +typedef int greg_t;
  25950. +#define NGREG 32
  25951. +typedef greg_t gregset_t[NGREG];
  25952. +
  25953. +#ifdef CONFIG_FPU
  25954. +typedef struct fpregset {
  25955. + int f_pcr;
  25956. + int f_psr;
  25957. + int f_fpiaddr;
  25958. + int f_fpregs[8][3];
  25959. +} fpregset_t;
  25960. +#endif
  25961. +
  25962. +struct mcontext {
  25963. + int version;
  25964. + int status_extension;
  25965. + gregset_t gregs;
  25966. +#ifdef CONFIG_FPU
  25967. + fpregset_t fpregs;
  25968. +#endif
  25969. +};
  25970. +
  25971. +#define MCONTEXT_VERSION 2
  25972. +
  25973. +struct ucontext {
  25974. + unsigned long uc_flags;
  25975. + struct ucontext *uc_link;
  25976. + stack_t uc_stack;
  25977. + struct mcontext uc_mcontext;
  25978. +#ifdef CONFIG_FPU
  25979. + unsigned long uc_filler[80];
  25980. +#endif
  25981. + sigset_t uc_sigmask; /* mask last for extensibility */
  25982. +};
  25983. +
  25984. +#endif
  25985. diff --git a/include/asm-nios2nommu/unaligned.h b/include/asm-nios2nommu/unaligned.h
  25986. new file mode 100644
  25987. index 0000000..4876185
  25988. --- /dev/null
  25989. +++ b/include/asm-nios2nommu/unaligned.h
  25990. @@ -0,0 +1,6 @@
  25991. +#ifndef __NIOS2_UNALIGNED_H
  25992. +#define __NIOS2_UNALIGNED_H
  25993. +
  25994. +#include <asm-generic/unaligned.h>
  25995. +
  25996. +#endif /* __NIOS2_UNALIGNED_H */
  25997. diff --git a/include/asm-nios2nommu/unistd.h b/include/asm-nios2nommu/unistd.h
  25998. new file mode 100644
  25999. index 0000000..43cd165
  26000. --- /dev/null
  26001. +++ b/include/asm-nios2nommu/unistd.h
  26002. @@ -0,0 +1,395 @@
  26003. +#ifndef _ASM_NIOS_UNISTD_H_
  26004. +#define _ASM_NIOS_UNISTD_H_
  26005. +
  26006. +/*--------------------------------------------------------------------
  26007. + *
  26008. + * include/asm-nios2nommu/unistd.h
  26009. + *
  26010. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  26011. + *
  26012. + * Copyright (C) 2004 Microtronix Datacom Ltd
  26013. + *
  26014. + * This program is free software; you can redistribute it and/or modify
  26015. + * it under the terms of the GNU General Public License as published by
  26016. + * the Free Software Foundation; either version 2 of the License, or
  26017. + * (at your option) any later version.
  26018. + *
  26019. + * This program is distributed in the hope that it will be useful,
  26020. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26021. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26022. + * GNU General Public License for more details.
  26023. + *
  26024. + *
  26025. + * //vic - kernel_thread moved to process.c
  26026. + * Jan/20/2004 dgt NiosII
  26027. + *
  26028. + ---------------------------------------------------------------------*/
  26029. +
  26030. +
  26031. +#include <asm/traps.h>
  26032. +
  26033. +/* TRAP isr expects the trap# (syscall=#TRAP_ID_SYSCALL) in r2,
  26034. + * the syscall # in r3, and arguments in r4, r5, ...
  26035. + * Return argument expected in r2.
  26036. + */
  26037. +
  26038. +#define __NR_restart_syscall 0
  26039. +#define __NR_exit 1
  26040. +#define __NR_fork 2
  26041. +#define __NR_read 3
  26042. +#define __NR_write 4
  26043. +#define __NR_open 5
  26044. +#define __NR_close 6
  26045. +#define __NR_waitpid 7
  26046. +#define __NR_creat 8
  26047. +#define __NR_link 9
  26048. +#define __NR_unlink 10
  26049. +#define __NR_execve 11
  26050. +#define __NR_chdir 12
  26051. +#define __NR_time 13
  26052. +#define __NR_mknod 14
  26053. +#define __NR_chmod 15
  26054. +#define __NR_chown 16
  26055. +#define __NR_break 17
  26056. +#define __NR_oldstat 18
  26057. +#define __NR_lseek 19
  26058. +#define __NR_getpid 20
  26059. +#define __NR_mount 21
  26060. +#define __NR_umount 22
  26061. +#define __NR_setuid 23
  26062. +#define __NR_getuid 24
  26063. +#define __NR_stime 25
  26064. +#define __NR_ptrace 26
  26065. +#define __NR_alarm 27
  26066. +#define __NR_oldfstat 28
  26067. +#define __NR_pause 29
  26068. +#define __NR_utime 30
  26069. +#define __NR_stty 31
  26070. +#define __NR_gtty 32
  26071. +#define __NR_access 33
  26072. +#define __NR_nice 34
  26073. +#define __NR_ftime 35
  26074. +#define __NR_sync 36
  26075. +#define __NR_kill 37
  26076. +#define __NR_rename 38
  26077. +#define __NR_mkdir 39
  26078. +#define __NR_rmdir 40
  26079. +#define __NR_dup 41
  26080. +#define __NR_pipe 42
  26081. +#define __NR_times 43
  26082. +#define __NR_prof 44
  26083. +#define __NR_brk 45
  26084. +#define __NR_setgid 46
  26085. +#define __NR_getgid 47
  26086. +#define __NR_signal 48
  26087. +#define __NR_geteuid 49
  26088. +#define __NR_getegid 50
  26089. +#define __NR_acct 51
  26090. +#define __NR_umount2 52 //vic #define __NR_phys 52
  26091. +#define __NR_lock 53
  26092. +#define __NR_ioctl 54
  26093. +#define __NR_fcntl 55
  26094. +#define __NR_mpx 56
  26095. +#define __NR_setpgid 57
  26096. +#define __NR_ulimit 58
  26097. +#define __NR_oldolduname 59
  26098. +#define __NR_umask 60
  26099. +#define __NR_chroot 61
  26100. +#define __NR_ustat 62
  26101. +#define __NR_dup2 63
  26102. +#define __NR_getppid 64
  26103. +#define __NR_getpgrp 65
  26104. +#define __NR_setsid 66
  26105. +#define __NR_sigaction 67
  26106. +#define __NR_sgetmask 68
  26107. +#define __NR_ssetmask 69
  26108. +#define __NR_setreuid 70
  26109. +#define __NR_setregid 71
  26110. +#define __NR_sigsuspend 72
  26111. +#define __NR_sigpending 73
  26112. +#define __NR_sethostname 74
  26113. +#define __NR_setrlimit 75
  26114. +#define __NR_getrlimit 76
  26115. +#define __NR_getrusage 77
  26116. +#define __NR_gettimeofday 78
  26117. +#define __NR_settimeofday 79
  26118. +#define __NR_getgroups 80
  26119. +#define __NR_setgroups 81
  26120. +#define __NR_select 82
  26121. +#define __NR_symlink 83
  26122. +#define __NR_oldlstat 84
  26123. +#define __NR_readlink 85
  26124. +#define __NR_uselib 86
  26125. +#define __NR_swapon 87
  26126. +#define __NR_reboot 88
  26127. +#define __NR_readdir 89
  26128. +#define __NR_mmap 90
  26129. +#define __NR_munmap 91
  26130. +#define __NR_truncate 92
  26131. +#define __NR_ftruncate 93
  26132. +#define __NR_fchmod 94
  26133. +#define __NR_fchown 95
  26134. +#define __NR_getpriority 96
  26135. +#define __NR_setpriority 97
  26136. +#define __NR_profil 98
  26137. +#define __NR_statfs 99
  26138. +#define __NR_fstatfs 100
  26139. +#define __NR_ioperm 101
  26140. +#define __NR_socketcall 102
  26141. +#define __NR_syslog 103
  26142. +#define __NR_setitimer 104
  26143. +#define __NR_getitimer 105
  26144. +#define __NR_stat 106
  26145. +#define __NR_lstat 107
  26146. +#define __NR_fstat 108
  26147. +#define __NR_olduname 109
  26148. +#define __NR_iopl /* 110 */ not supported
  26149. +#define __NR_vhangup 111
  26150. +#define __NR_idle /* 112 */ Obsolete
  26151. +#define __NR_vm86 /* 113 */ not supported
  26152. +#define __NR_wait4 114
  26153. +#define __NR_swapoff 115
  26154. +#define __NR_sysinfo 116
  26155. +#define __NR_ipc 117
  26156. +#define __NR_fsync 118
  26157. +#define __NR_sigreturn 119
  26158. +#define __NR_clone 120
  26159. +#define __NR_setdomainname 121
  26160. +#define __NR_uname 122
  26161. +#define __NR_cacheflush 123
  26162. +#define __NR_adjtimex 124
  26163. +#define __NR_mprotect 125
  26164. +#define __NR_sigprocmask 126
  26165. +#define __NR_create_module 127
  26166. +#define __NR_init_module 128
  26167. +#define __NR_delete_module 129
  26168. +#define __NR_get_kernel_syms 130
  26169. +#define __NR_quotactl 131
  26170. +#define __NR_getpgid 132
  26171. +#define __NR_fchdir 133
  26172. +#define __NR_bdflush 134
  26173. +#define __NR_sysfs 135
  26174. +#define __NR_personality 136
  26175. +#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
  26176. +#define __NR_setfsuid 138
  26177. +#define __NR_setfsgid 139
  26178. +#define __NR__llseek 140
  26179. +#define __NR_getdents 141
  26180. +#define __NR__newselect 142
  26181. +#define __NR_flock 143
  26182. + /* 144 __NR_msync obsolete */
  26183. +#define __NR_readv 145
  26184. +#define __NR_writev 146
  26185. +#define __NR_getsid 147
  26186. +#define __NR_fdatasync 148
  26187. +#define __NR__sysctl 149
  26188. +#define __NR_mlock 150
  26189. +#define __NR_munlock 151
  26190. +#define __NR_mlockall 152
  26191. +#define __NR_munlockall 153
  26192. +#define __NR_sched_setparam 154
  26193. +#define __NR_sched_getparam 155
  26194. +#define __NR_sched_setscheduler 156
  26195. +#define __NR_sched_getscheduler 157
  26196. +#define __NR_sched_yield 158
  26197. +#define __NR_sched_get_priority_max 159
  26198. +#define __NR_sched_get_priority_min 160
  26199. +#define __NR_sched_rr_get_interval 161
  26200. +#define __NR_nanosleep 162
  26201. +#define __NR_mremap 163
  26202. +#define __NR_setresuid 164
  26203. +#define __NR_getresuid 165
  26204. +#define __NR_getpagesize 166
  26205. +#define __NR_query_module 167
  26206. +#define __NR_poll 168
  26207. +#define __NR_nfsservctl 169
  26208. +#define __NR_setresgid 170
  26209. +#define __NR_getresgid 171
  26210. +#define __NR_prctl 172
  26211. +#define __NR_rt_sigreturn 173
  26212. +#define __NR_rt_sigaction 174
  26213. +#define __NR_rt_sigprocmask 175
  26214. +#define __NR_rt_sigpending 176
  26215. +#define __NR_rt_sigtimedwait 177
  26216. +#define __NR_rt_sigqueueinfo 178
  26217. +#define __NR_rt_sigsuspend 179
  26218. +#define __NR_pread 180
  26219. +#define __NR_pwrite 181
  26220. +#define __NR_lchown 182
  26221. +#define __NR_getcwd 183
  26222. +#define __NR_capget 184
  26223. +#define __NR_capset 185
  26224. +#define __NR_sigaltstack 186
  26225. +#define __NR_sendfile 187
  26226. +#define __NR_getpmsg 188 /* some people actually want streams */
  26227. +#define __NR_putpmsg 189 /* some people actually want streams */
  26228. +#define __NR_vfork 190
  26229. +#define __NR_ugetrlimit 191
  26230. +#define __NR_mmap2 192
  26231. +#define __NR_truncate64 193
  26232. +#define __NR_ftruncate64 194
  26233. +#define __NR_stat64 195
  26234. +#define __NR_lstat64 196
  26235. +#define __NR_fstat64 197
  26236. +#define __NR_chown32 198
  26237. +#define __NR_getuid32 199
  26238. +#define __NR_getgid32 200
  26239. +#define __NR_geteuid32 201
  26240. +#define __NR_getegid32 202
  26241. +#define __NR_setreuid32 203
  26242. +#define __NR_setregid32 204
  26243. +#define __NR_getgroups32 205
  26244. +#define __NR_setgroups32 206
  26245. +#define __NR_fchown32 207
  26246. +#define __NR_setresuid32 208
  26247. +#define __NR_getresuid32 209
  26248. +#define __NR_setresgid32 210
  26249. +#define __NR_getresgid32 211
  26250. +#define __NR_lchown32 212
  26251. +#define __NR_setuid32 213
  26252. +#define __NR_setgid32 214
  26253. +#define __NR_setfsuid32 215
  26254. +#define __NR_setfsgid32 216
  26255. +#define __NR_pivot_root 217
  26256. +/* 218 unused */
  26257. +/* 219 unused */
  26258. +#define __NR_getdents64 220
  26259. +#define __NR_gettid 221
  26260. +#define __NR_tkill 222
  26261. +#define __NR_setxattr 223
  26262. +#define __NR_lsetxattr 224
  26263. +#define __NR_fsetxattr 225
  26264. +#define __NR_getxattr 226
  26265. +#define __NR_lgetxattr 227
  26266. +#define __NR_fgetxattr 228
  26267. +#define __NR_listxattr 229
  26268. +#define __NR_llistxattr 230
  26269. +#define __NR_flistxattr 231
  26270. +#define __NR_removexattr 232
  26271. +#define __NR_lremovexattr 233
  26272. +#define __NR_fremovexattr 234
  26273. +#define __NR_futex 235
  26274. +#define __NR_sendfile64 236
  26275. +#define __NR_mincore 237
  26276. +#define __NR_madvise 238
  26277. +#define __NR_fcntl64 239
  26278. +#define __NR_readahead 240
  26279. +#define __NR_io_setup 241
  26280. +#define __NR_io_destroy 242
  26281. +#define __NR_io_getevents 243
  26282. +#define __NR_io_submit 244
  26283. +#define __NR_io_cancel 245
  26284. +#define __NR_fadvise64 246
  26285. +#define __NR_exit_group 247
  26286. +#define __NR_lookup_dcookie 248
  26287. +#define __NR_epoll_create 249
  26288. +#define __NR_epoll_ctl 250
  26289. +#define __NR_epoll_wait 251
  26290. +#define __NR_remap_file_pages 252
  26291. +#define __NR_set_tid_address 253
  26292. +#define __NR_timer_create 254
  26293. +#define __NR_timer_settime 255
  26294. +#define __NR_timer_gettime 256
  26295. +#define __NR_timer_getoverrun 257
  26296. +#define __NR_timer_delete 258
  26297. +#define __NR_clock_settime 259
  26298. +#define __NR_clock_gettime 260
  26299. +#define __NR_clock_getres 261
  26300. +#define __NR_clock_nanosleep 262
  26301. +#define __NR_statfs64 263
  26302. +#define __NR_fstatfs64 264
  26303. +#define __NR_tgkill 265
  26304. +#define __NR_utimes 266
  26305. +#define __NR_fadvise64_64 267
  26306. +#define __NR_mbind 268
  26307. +#define __NR_get_mempolicy 269
  26308. +#define __NR_set_mempolicy 270
  26309. +#define __NR_mq_open 271
  26310. +#define __NR_mq_unlink 272
  26311. +#define __NR_mq_timedsend 273
  26312. +#define __NR_mq_timedreceive 274
  26313. +#define __NR_mq_notify 275
  26314. +#define __NR_mq_getsetattr 276
  26315. +#define __NR_waitid 277
  26316. +#define __NR_sys_setaltroot 278
  26317. +#define __NR_add_key 279
  26318. +#define __NR_request_key 280
  26319. +#define __NR_keyctl 281
  26320. +#define __NR_ioprio_set 282
  26321. +#define __NR_ioprio_get 283
  26322. +#define __NR_inotify_init 284
  26323. +#define __NR_inotify_add_watch 285
  26324. +#define __NR_inotify_rm_watch 286
  26325. +#define __NR_migrate_pages 287
  26326. +#define __NR_openat 288
  26327. +#define __NR_mkdirat 289
  26328. +#define __NR_mknodat 290
  26329. +#define __NR_fchownat 291
  26330. +#define __NR_futimesat 292
  26331. +#define __NR_fstatat64 293
  26332. +#define __NR_unlinkat 294
  26333. +#define __NR_renameat 295
  26334. +#define __NR_linkat 296
  26335. +#define __NR_symlinkat 297
  26336. +#define __NR_readlinkat 298
  26337. +#define __NR_fchmodat 299
  26338. +#define __NR_faccessat 300
  26339. +#define __NR_pselect6 301
  26340. +#define __NR_ppoll 302
  26341. +#define __NR_unshare 303
  26342. +#define __NR_set_robust_list 304
  26343. +#define __NR_get_robust_list 305
  26344. +#define __NR_splice 306
  26345. +#define __NR_sync_file_range 307
  26346. +#define __NR_tee 308
  26347. +#define __NR_vmsplice 309
  26348. +#define __NR_move_pages 310
  26349. +#define __NR_sched_setaffinity 311
  26350. +#define __NR_sched_getaffinity 312
  26351. +#define __NR_kexec_load 313
  26352. +#define __NR_getcpu 314
  26353. +#define __NR_epoll_pwait 315
  26354. +#define __NR_utimensat 316
  26355. +#define __NR_signalfd 317
  26356. +#define __NR_timerfd 318
  26357. +#define __NR_eventfd 319
  26358. +#define __NR_pread64 320
  26359. +#define __NR_pwrite64 321
  26360. +
  26361. +#ifdef __KERNEL__
  26362. +#define NR_syscalls 322
  26363. +
  26364. +#define __ARCH_WANT_IPC_PARSE_VERSION
  26365. +#define __ARCH_WANT_OLD_READDIR
  26366. +#define __ARCH_WANT_OLD_STAT
  26367. +#define __ARCH_WANT_STAT64
  26368. +#define __ARCH_WANT_SYS_ALARM
  26369. +#define __ARCH_WANT_SYS_GETHOSTNAME
  26370. +#define __ARCH_WANT_SYS_PAUSE
  26371. +#define __ARCH_WANT_SYS_SGETMASK
  26372. +#define __ARCH_WANT_SYS_SIGNAL
  26373. +#define __ARCH_WANT_SYS_TIME
  26374. +#define __ARCH_WANT_SYS_UTIME
  26375. +#define __ARCH_WANT_SYS_WAITPID
  26376. +#define __ARCH_WANT_SYS_SOCKETCALL
  26377. +#define __ARCH_WANT_SYS_FADVISE64
  26378. +#define __ARCH_WANT_SYS_GETPGRP
  26379. +#define __ARCH_WANT_SYS_LLSEEK
  26380. +#define __ARCH_WANT_SYS_NICE
  26381. +#define __ARCH_WANT_SYS_OLD_GETRLIMIT
  26382. +#define __ARCH_WANT_SYS_OLDUMOUNT
  26383. +#define __ARCH_WANT_SYS_SIGPENDING
  26384. +#define __ARCH_WANT_SYS_SIGPROCMASK
  26385. +#define __ARCH_WANT_SYS_RT_SIGACTION
  26386. +
  26387. +/*
  26388. + * "Conditional" syscalls
  26389. + *
  26390. + * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
  26391. + * but it doesn't work on all toolchains, so we just do it by hand
  26392. + */
  26393. +#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall");
  26394. +
  26395. +#endif /* __KERNEL__ */
  26396. +
  26397. +#endif /* _ASM_NIOS_UNISTD_H_ */
  26398. diff --git a/include/asm-nios2nommu/user.h b/include/asm-nios2nommu/user.h
  26399. new file mode 100644
  26400. index 0000000..3cdc2ba
  26401. --- /dev/null
  26402. +++ b/include/asm-nios2nommu/user.h
  26403. @@ -0,0 +1,112 @@
  26404. +#ifndef _NIOS2NOMMU_USER_H
  26405. +#define _NIOS2NOMMU_USER_H
  26406. +
  26407. +/*--------------------------------------------------------------------
  26408. + *
  26409. + * include/asm-nios2nommu/user.h
  26410. + *
  26411. + * Derived from M68knommu
  26412. + *
  26413. + * Copyright (C) 2004 Microtronix Datacom Ltd
  26414. + *
  26415. + * This program is free software; you can redistribute it and/or modify
  26416. + * it under the terms of the GNU General Public License as published by
  26417. + * the Free Software Foundation; either version 2 of the License, or
  26418. + * (at your option) any later version.
  26419. + *
  26420. + * This program is distributed in the hope that it will be useful,
  26421. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26422. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26423. + * GNU General Public License for more details.
  26424. + *
  26425. + *
  26426. + * Jan/20/2004 dgt NiosII
  26427. + *
  26428. + ---------------------------------------------------------------------*/
  26429. +
  26430. +
  26431. +#include <asm/page.h>
  26432. +
  26433. +/* Core file format: The core file is written in such a way that gdb
  26434. + can understand it and provide useful information to the user (under
  26435. + linux we use the 'trad-core' bfd). There are quite a number of
  26436. + obstacles to being able to view the contents of the floating point
  26437. + registers, and until these are solved you will not be able to view the
  26438. + contents of them. Actually, you can read in the core file and look at
  26439. + the contents of the user struct to find out what the floating point
  26440. + registers contain.
  26441. + The actual file contents are as follows:
  26442. + UPAGE: 1 page consisting of a user struct that tells gdb what is present
  26443. + in the file. Directly after this is a copy of the task_struct, which
  26444. + is currently not used by gdb, but it may come in useful at some point.
  26445. + All of the registers are stored as part of the upage. The upage should
  26446. + always be only one page.
  26447. + DATA: The data area is stored. We use current->end_text to
  26448. + current->brk to pick up all of the user variables, plus any memory
  26449. + that may have been malloced. No attempt is made to determine if a page
  26450. + is demand-zero or if a page is totally unused, we just cover the entire
  26451. + range. All of the addresses are rounded in such a way that an integral
  26452. + number of pages is written.
  26453. + STACK: We need the stack information in order to get a meaningful
  26454. + backtrace. We need to write the data from (esp) to
  26455. + current->start_stack, so we round each of these off in order to be able
  26456. + to write an integer number of pages.
  26457. + The minimum core file size is 3 pages, or 12288 bytes.
  26458. +*/
  26459. +
  26460. +struct user_m68kfp_struct {
  26461. + unsigned long fpregs[8*3]; /* fp0-fp7 registers */
  26462. + unsigned long fpcntl[3]; /* fp control regs */
  26463. +};
  26464. +
  26465. +/* This is needs more work, probably should look like gdb useage */
  26466. +struct user_regs_struct {
  26467. + long r1,r2,r3,r4,r5,r6,r7,r8;
  26468. + long r9,r10,r11,r12,r13,r14,r15;
  26469. + long r16,r17,r18,r19,r20,r21,r22,r23;
  26470. + long gp;
  26471. + long sp;
  26472. + long ra;
  26473. + long fp;
  26474. + long orig_r2;
  26475. + long estatus;
  26476. + long status_extension;
  26477. + long ea;
  26478. +};
  26479. +
  26480. +
  26481. +/* When the kernel dumps core, it starts by dumping the user struct -
  26482. + this will be used by gdb to figure out where the data and stack segments
  26483. + are within the file, and what virtual addresses to use. */
  26484. +struct user{
  26485. +/* We start with the registers, to mimic the way that "memory" is returned
  26486. + from the ptrace(3,...) function. */
  26487. + struct user_regs_struct regs; /* Where the registers are actually stored */
  26488. +/* ptrace does not yet supply these. Someday.... */
  26489. + int u_fpvalid; /* True if math co-processor being used. */
  26490. + /* for this mess. Not yet used. */
  26491. + struct user_m68kfp_struct m68kfp; /* Math Co-processor registers. */
  26492. +/* The rest of this junk is to help gdb figure out what goes where */
  26493. + unsigned long int u_tsize; /* Text segment size (pages). */
  26494. + unsigned long int u_dsize; /* Data segment size (pages). */
  26495. + unsigned long int u_ssize; /* Stack segment size (pages). */
  26496. + unsigned long start_code; /* Starting virtual address of text. */
  26497. + unsigned long start_stack; /* Starting virtual address of stack area.
  26498. + This is actually the bottom of the stack,
  26499. + the top of the stack is always found in the
  26500. + esp register. */
  26501. + long int signal; /* Signal that caused the core dump. */
  26502. + int reserved; /* No longer used */
  26503. + struct user_regs_struct *u_ar0;
  26504. + /* Used by gdb to help find the values for */
  26505. + /* the registers. */
  26506. + struct user_m68kfp_struct* u_fpstate; /* Math Co-processor pointer. */
  26507. + unsigned long magic; /* To uniquely identify a core file */
  26508. + char u_comm[32]; /* User command that was responsible */
  26509. +};
  26510. +#define NBPG PAGE_SIZE
  26511. +#define UPAGES 1
  26512. +#define HOST_TEXT_START_ADDR (u.start_code)
  26513. +#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
  26514. +
  26515. +#endif
  26516. diff --git a/include/asm-nios2nommu/virtconvert.h b/include/asm-nios2nommu/virtconvert.h
  26517. new file mode 100644
  26518. index 0000000..89bf899
  26519. --- /dev/null
  26520. +++ b/include/asm-nios2nommu/virtconvert.h
  26521. @@ -0,0 +1,46 @@
  26522. +#ifndef __NIOS_VIRT_CONVERT__
  26523. +#define __NIOS_VIRT_CONVERT__
  26524. +
  26525. +/*--------------------------------------------------------------------
  26526. + *
  26527. + * include/asm-nios2nommu/virtconvert.h
  26528. + *
  26529. + * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
  26530. + *
  26531. + * Copyright (C) 2004 Microtronix Datacom Ltd
  26532. + *
  26533. + * This program is free software; you can redistribute it and/or modify
  26534. + * it under the terms of the GNU General Public License as published by
  26535. + * the Free Software Foundation; either version 2 of the License, or
  26536. + * (at your option) any later version.
  26537. + *
  26538. + * This program is distributed in the hope that it will be useful,
  26539. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26540. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26541. + * GNU General Public License for more details.
  26542. + *
  26543. + *
  26544. + * Jan/20/2004 dgt NiosII
  26545. + *
  26546. + ---------------------------------------------------------------------*/
  26547. +
  26548. +
  26549. +/*
  26550. + * Macros used for converting between virtual and physical mappings.
  26551. + */
  26552. +
  26553. +#ifdef __KERNEL__
  26554. +
  26555. +#include <asm/setup.h>
  26556. +#include <asm/page.h>
  26557. +
  26558. +#define mm_ptov(vaddr) ((void *) (vaddr))
  26559. +#define mm_vtop(vaddr) ((unsigned long) (vaddr))
  26560. +#define phys_to_virt(vaddr) ((void *) (vaddr))
  26561. +#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
  26562. +
  26563. +#define virt_to_bus virt_to_phys
  26564. +#define bus_to_virt phys_to_virt
  26565. +
  26566. +#endif /*__KERNEL__ */
  26567. +#endif /*__NIOS_VIRT_CONVERT__*/