head.S 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942
  1. /* -*- mode: asm -*-
  2. **
  3. ** head.S -- This file contains the initial boot code for the
  4. ** Linux/68k kernel.
  5. **
  6. ** Copyright 1993 by Hamish Macdonald
  7. **
  8. ** 68040 fixes by Michael Rausch
  9. ** 68060 fixes by Roman Hodek
  10. ** MMU cleanup by Randy Thelen
  11. ** Final MMU cleanup by Roman Zippel
  12. **
  13. ** Atari support by Andreas Schwab, using ideas of Robert de Vries
  14. ** and Bjoern Brauel
  15. ** VME Support by Richard Hirst
  16. **
  17. ** 94/11/14 Andreas Schwab: put kernel at PAGESIZE
  18. ** 94/11/18 Andreas Schwab: remove identity mapping of STRAM for Atari
  19. ** ++ Bjoern & Roman: ATARI-68040 support for the Medusa
  20. ** 95/11/18 Richard Hirst: Added MVME166 support
  21. ** 96/04/26 Guenther Kelleter: fixed identity mapping for Falcon with
  22. ** Magnum- and FX-alternate ram
  23. ** 98/04/25 Phil Blundell: added HP300 support
  24. ** 1998/08/30 David Kilzer: Added support for font_desc structures
  25. ** for linux-2.1.115
  26. ** 9/02/11 Richard Zidlicky: added Q40 support (initial vesion 99/01/01)
  27. ** 2004/05/13 Kars de Jong: Finalised HP300 support
  28. **
  29. ** This file is subject to the terms and conditions of the GNU General Public
  30. ** License. See the file README.legal in the main directory of this archive
  31. ** for more details.
  32. **
  33. */
  34. /*
  35. * Linux startup code.
  36. *
  37. * At this point, the boot loader has:
  38. * Disabled interrupts
  39. * Disabled caches
  40. * Put us in supervisor state.
  41. *
  42. * The kernel setup code takes the following steps:
  43. * . Raise interrupt level
  44. * . Set up initial kernel memory mapping.
  45. * . This sets up a mapping of the 4M of memory the kernel is located in.
  46. * . It also does a mapping of any initial machine specific areas.
  47. * . Enable the MMU
  48. * . Enable cache memories
  49. * . Jump to kernel startup
  50. *
  51. * Much of the file restructuring was to accomplish:
  52. * 1) Remove register dependency through-out the file.
  53. * 2) Increase use of subroutines to perform functions
  54. * 3) Increase readability of the code
  55. *
  56. * Of course, readability is a subjective issue, so it will never be
  57. * argued that that goal was accomplished. It was merely a goal.
  58. * A key way to help make code more readable is to give good
  59. * documentation. So, the first thing you will find is exaustive
  60. * write-ups on the structure of the file, and the features of the
  61. * functional subroutines.
  62. *
  63. * General Structure:
  64. * ------------------
  65. * Without a doubt the single largest chunk of head.S is spent
  66. * mapping the kernel and I/O physical space into the logical range
  67. * for the kernel.
  68. * There are new subroutines and data structures to make MMU
  69. * support cleaner and easier to understand.
  70. * First, you will find a routine call "mmu_map" which maps
  71. * a logical to a physical region for some length given a cache
  72. * type on behalf of the caller. This routine makes writing the
  73. * actual per-machine specific code very simple.
  74. * A central part of the code, but not a subroutine in itself,
  75. * is the mmu_init code which is broken down into mapping the kernel
  76. * (the same for all machines) and mapping machine-specific I/O
  77. * regions.
  78. * Also, there will be a description of engaging the MMU and
  79. * caches.
  80. * You will notice that there is a chunk of code which
  81. * can emit the entire MMU mapping of the machine. This is present
  82. * only in debug modes and can be very helpful.
  83. * Further, there is a new console driver in head.S that is
  84. * also only engaged in debug mode. Currently, it's only supported
  85. * on the Macintosh class of machines. However, it is hoped that
  86. * others will plug-in support for specific machines.
  87. *
  88. * ######################################################################
  89. *
  90. * mmu_map
  91. * -------
  92. * mmu_map was written for two key reasons. First, it was clear
  93. * that it was very difficult to read the previous code for mapping
  94. * regions of memory. Second, the Macintosh required such extensive
  95. * memory allocations that it didn't make sense to propagate the
  96. * existing code any further.
  97. * mmu_map requires some parameters:
  98. *
  99. * mmu_map (logical, physical, length, cache_type)
  100. *
  101. * While this essentially describes the function in the abstract, you'll
  102. * find more indepth description of other parameters at the implementation site.
  103. *
  104. * mmu_get_root_table_entry
  105. * ------------------------
  106. * mmu_get_ptr_table_entry
  107. * -----------------------
  108. * mmu_get_page_table_entry
  109. * ------------------------
  110. *
  111. * These routines are used by other mmu routines to get a pointer into
  112. * a table, if necessary a new table is allocated. These routines are working
  113. * basically like pmd_alloc() and pte_alloc() in <asm/pgtable.h>. The root
  114. * table needs of course only to be allocated once in mmu_get_root_table_entry,
  115. * so that here also some mmu specific initialization is done. The second page
  116. * at the start of the kernel (the first page is unmapped later) is used for
  117. * the kernel_pg_dir. It must be at a position known at link time (as it's used
  118. * to initialize the init task struct) and since it needs special cache
  119. * settings, it's the easiest to use this page, the rest of the page is used
  120. * for further pointer tables.
  121. * mmu_get_page_table_entry allocates always a whole page for page tables, this
  122. * means 1024 pages and so 4MB of memory can be mapped. It doesn't make sense
  123. * to manage page tables in smaller pieces as nearly all mappings have that
  124. * size.
  125. *
  126. * ######################################################################
  127. *
  128. *
  129. * ######################################################################
  130. *
  131. * mmu_engage
  132. * ----------
  133. * Thanks to a small helping routine enabling the mmu got quite simple
  134. * and there is only one way left. mmu_engage makes a complete a new mapping
  135. * that only includes the absolute necessary to be able to jump to the final
  136. * postion and to restore the original mapping.
  137. * As this code doesn't need a transparent translation register anymore this
  138. * means all registers are free to be used by machines that needs them for
  139. * other purposes.
  140. *
  141. * ######################################################################
  142. *
  143. * mmu_print
  144. * ---------
  145. * This algorithm will print out the page tables of the system as
  146. * appropriate for an 030 or an 040. This is useful for debugging purposes
  147. * and as such is enclosed in #ifdef MMU_PRINT/#endif clauses.
  148. *
  149. * ######################################################################
  150. *
  151. * console_init
  152. * ------------
  153. * The console is also able to be turned off. The console in head.S
  154. * is specifically for debugging and can be very useful. It is surrounded by
  155. * #ifdef CONSOLE/#endif clauses so it doesn't have to ship in known-good
  156. * kernels. It's basic algorithm is to determine the size of the screen
  157. * (in height/width and bit depth) and then use that information for
  158. * displaying an 8x8 font or an 8x16 (widthxheight). I prefer the 8x8 for
  159. * debugging so I can see more good data. But it was trivial to add support
  160. * for both fonts, so I included it.
  161. * Also, the algorithm for plotting pixels is abstracted so that in
  162. * theory other platforms could add support for different kinds of frame
  163. * buffers. This could be very useful.
  164. *
  165. * console_put_penguin
  166. * -------------------
  167. * An important part of any Linux bring up is the penguin and there's
  168. * nothing like getting the Penguin on the screen! This algorithm will work
  169. * on any machine for which there is a console_plot_pixel.
  170. *
  171. * console_scroll
  172. * --------------
  173. * My hope is that the scroll algorithm does the right thing on the
  174. * various platforms, but it wouldn't be hard to add the test conditions
  175. * and new code if it doesn't.
  176. *
  177. * console_putc
  178. * -------------
  179. *
  180. * ######################################################################
  181. *
  182. * Register usage has greatly simplified within head.S. Every subroutine
  183. * saves and restores all registers that it modifies (except it returns a
  184. * value in there of course). So the only register that needs to be initialized
  185. * is the stack pointer.
  186. * All other init code and data is now placed in the init section, so it will
  187. * be automatically freed at the end of the kernel initialization.
  188. *
  189. * ######################################################################
  190. *
  191. * options
  192. * -------
  193. * There are many options available in a build of this file. I've
  194. * taken the time to describe them here to save you the time of searching
  195. * for them and trying to understand what they mean.
  196. *
  197. * CONFIG_xxx: These are the obvious machine configuration defines created
  198. * during configuration. These are defined in include/linux/autoconf.h.
  199. *
  200. * CONSOLE: There is support for head.S console in this file. This
  201. * console can talk to a Mac frame buffer, but could easily be extrapolated
  202. * to extend it to support other platforms.
  203. *
  204. * TEST_MMU: This is a test harness for running on any given machine but
  205. * getting an MMU dump for another class of machine. The classes of machines
  206. * that can be tested are any of the makes (Atari, Amiga, Mac, VME, etc.)
  207. * and any of the models (030, 040, 060, etc.).
  208. *
  209. * NOTE: TEST_MMU is NOT permanent! It is scheduled to be removed
  210. * When head.S boots on Atari, Amiga, Macintosh, and VME
  211. * machines. At that point the underlying logic will be
  212. * believed to be solid enough to be trusted, and TEST_MMU
  213. * can be dropped. Do note that that will clean up the
  214. * head.S code significantly as large blocks of #if/#else
  215. * clauses can be removed.
  216. *
  217. * MMU_NOCACHE_KERNEL: On the Macintosh platform there was an inquiry into
  218. * determing why devices don't appear to work. A test case was to remove
  219. * the cacheability of the kernel bits.
  220. *
  221. * MMU_PRINT: There is a routine built into head.S that can display the
  222. * MMU data structures. It outputs its result through the serial_putc
  223. * interface. So where ever that winds up driving data, that's where the
  224. * mmu struct will appear. On the Macintosh that's typically the console.
  225. *
  226. * SERIAL_DEBUG: There are a series of putc() macro statements
  227. * scattered through out the code to give progress of status to the
  228. * person sitting at the console. This constant determines whether those
  229. * are used.
  230. *
  231. * DEBUG: This is the standard DEBUG flag that can be set for building
  232. * the kernel. It has the effect adding additional tests into
  233. * the code.
  234. *
  235. * FONT_6x11:
  236. * FONT_8x8:
  237. * FONT_8x16:
  238. * In theory these could be determined at run time or handed
  239. * over by the booter. But, let's be real, it's a fine hard
  240. * coded value. (But, you will notice the code is run-time
  241. * flexible!) A pointer to the font's struct font_desc
  242. * is kept locally in Lconsole_font. It is used to determine
  243. * font size information dynamically.
  244. *
  245. * Atari constants:
  246. * USE_PRINTER: Use the printer port for serial debug.
  247. * USE_SCC_B: Use the SCC port A (Serial2) for serial debug.
  248. * USE_SCC_A: Use the SCC port B (Modem2) for serial debug.
  249. * USE_MFP: Use the ST-MFP port (Modem1) for serial debug.
  250. *
  251. * Macintosh constants:
  252. * MAC_SERIAL_DEBUG: Turns on serial debug output for the Macintosh.
  253. * MAC_USE_SCC_A: Use the SCC port A (modem) for serial debug.
  254. * MAC_USE_SCC_B: Use the SCC port B (printer) for serial debug (default).
  255. */
  256. #include <linux/config.h>
  257. #include <linux/linkage.h>
  258. #include <linux/init.h>
  259. #include <asm/bootinfo.h>
  260. #include <asm/setup.h>
  261. #include <asm/entry.h>
  262. #include <asm/pgtable.h>
  263. #include <asm/page.h>
  264. #include <asm/asm-offsets.h>
  265. #ifdef CONFIG_MAC
  266. #include <asm/machw.h>
  267. /*
  268. * Macintosh console support
  269. */
  270. #ifdef CONFIG_FRAMEBUFFER_CONSOLE
  271. #define CONSOLE
  272. #define CONSOLE_PENGUIN
  273. #endif
  274. /*
  275. * Macintosh serial debug support; outputs boot info to the printer
  276. * and/or modem serial ports
  277. */
  278. #undef MAC_SERIAL_DEBUG
  279. /*
  280. * Macintosh serial debug port selection; define one or both;
  281. * requires MAC_SERIAL_DEBUG to be defined
  282. */
  283. #define MAC_USE_SCC_A /* Macintosh modem serial port */
  284. #define MAC_USE_SCC_B /* Macintosh printer serial port */
  285. #endif /* CONFIG_MAC */
  286. #undef MMU_PRINT
  287. #undef MMU_NOCACHE_KERNEL
  288. #define SERIAL_DEBUG
  289. #undef DEBUG
  290. /*
  291. * For the head.S console, there are three supported fonts, 6x11, 8x16 and 8x8.
  292. * The 8x8 font is harder to read but fits more on the screen.
  293. */
  294. #define FONT_8x8 /* default */
  295. /* #define FONT_8x16 */ /* 2nd choice */
  296. /* #define FONT_6x11 */ /* 3rd choice */
  297. .globl kernel_pg_dir
  298. .globl availmem
  299. .globl m68k_pgtable_cachemode
  300. .globl m68k_supervisor_cachemode
  301. #ifdef CONFIG_MVME16x
  302. .globl mvme_bdid
  303. #endif
  304. #ifdef CONFIG_Q40
  305. .globl q40_mem_cptr
  306. #endif
  307. CPUTYPE_040 = 1 /* indicates an 040 */
  308. CPUTYPE_060 = 2 /* indicates an 060 */
  309. CPUTYPE_0460 = 3 /* if either above are set, this is set */
  310. CPUTYPE_020 = 4 /* indicates an 020 */
  311. /* Translation control register */
  312. TC_ENABLE = 0x8000
  313. TC_PAGE8K = 0x4000
  314. TC_PAGE4K = 0x0000
  315. /* Transparent translation registers */
  316. TTR_ENABLE = 0x8000 /* enable transparent translation */
  317. TTR_ANYMODE = 0x4000 /* user and kernel mode access */
  318. TTR_KERNELMODE = 0x2000 /* only kernel mode access */
  319. TTR_USERMODE = 0x0000 /* only user mode access */
  320. TTR_CI = 0x0400 /* inhibit cache */
  321. TTR_RW = 0x0200 /* read/write mode */
  322. TTR_RWM = 0x0100 /* read/write mask */
  323. TTR_FCB2 = 0x0040 /* function code base bit 2 */
  324. TTR_FCB1 = 0x0020 /* function code base bit 1 */
  325. TTR_FCB0 = 0x0010 /* function code base bit 0 */
  326. TTR_FCM2 = 0x0004 /* function code mask bit 2 */
  327. TTR_FCM1 = 0x0002 /* function code mask bit 1 */
  328. TTR_FCM0 = 0x0001 /* function code mask bit 0 */
  329. /* Cache Control registers */
  330. CC6_ENABLE_D = 0x80000000 /* enable data cache (680[46]0) */
  331. CC6_FREEZE_D = 0x40000000 /* freeze data cache (68060) */
  332. CC6_ENABLE_SB = 0x20000000 /* enable store buffer (68060) */
  333. CC6_PUSH_DPI = 0x10000000 /* disable CPUSH invalidation (68060) */
  334. CC6_HALF_D = 0x08000000 /* half-cache mode for data cache (68060) */
  335. CC6_ENABLE_B = 0x00800000 /* enable branch cache (68060) */
  336. CC6_CLRA_B = 0x00400000 /* clear all entries in branch cache (68060) */
  337. CC6_CLRU_B = 0x00200000 /* clear user entries in branch cache (68060) */
  338. CC6_ENABLE_I = 0x00008000 /* enable instruction cache (680[46]0) */
  339. CC6_FREEZE_I = 0x00004000 /* freeze instruction cache (68060) */
  340. CC6_HALF_I = 0x00002000 /* half-cache mode for instruction cache (68060) */
  341. CC3_ALLOC_WRITE = 0x00002000 /* write allocate mode(68030) */
  342. CC3_ENABLE_DB = 0x00001000 /* enable data burst (68030) */
  343. CC3_CLR_D = 0x00000800 /* clear data cache (68030) */
  344. CC3_CLRE_D = 0x00000400 /* clear entry in data cache (68030) */
  345. CC3_FREEZE_D = 0x00000200 /* freeze data cache (68030) */
  346. CC3_ENABLE_D = 0x00000100 /* enable data cache (68030) */
  347. CC3_ENABLE_IB = 0x00000010 /* enable instruction burst (68030) */
  348. CC3_CLR_I = 0x00000008 /* clear instruction cache (68030) */
  349. CC3_CLRE_I = 0x00000004 /* clear entry in instruction cache (68030) */
  350. CC3_FREEZE_I = 0x00000002 /* freeze instruction cache (68030) */
  351. CC3_ENABLE_I = 0x00000001 /* enable instruction cache (68030) */
  352. /* Miscellaneous definitions */
  353. PAGESIZE = 4096
  354. PAGESHIFT = 12
  355. ROOT_TABLE_SIZE = 128
  356. PTR_TABLE_SIZE = 128
  357. PAGE_TABLE_SIZE = 64
  358. ROOT_INDEX_SHIFT = 25
  359. PTR_INDEX_SHIFT = 18
  360. PAGE_INDEX_SHIFT = 12
  361. #ifdef DEBUG
  362. /* When debugging use readable names for labels */
  363. #ifdef __STDC__
  364. #define L(name) .head.S.##name
  365. #else
  366. #define L(name) .head.S./**/name
  367. #endif
  368. #else
  369. #ifdef __STDC__
  370. #define L(name) .L##name
  371. #else
  372. #define L(name) .L/**/name
  373. #endif
  374. #endif
  375. /* The __INITDATA stuff is a no-op when ftrace or kgdb are turned on */
  376. #ifndef __INITDATA
  377. #define __INITDATA .data
  378. #define __FINIT .previous
  379. #endif
  380. /* Several macros to make the writing of subroutines easier:
  381. * - func_start marks the beginning of the routine which setups the frame
  382. * register and saves the registers, it also defines another macro
  383. * to automatically restore the registers again.
  384. * - func_return marks the end of the routine and simply calls the prepared
  385. * macro to restore registers and jump back to the caller.
  386. * - func_define generates another macro to automatically put arguments
  387. * onto the stack call the subroutine and cleanup the stack again.
  388. */
  389. /* Within subroutines these macros can be used to access the arguments
  390. * on the stack. With STACK some allocated memory on the stack can be
  391. * accessed and ARG0 points to the return address (used by mmu_engage).
  392. */
  393. #define STACK %a6@(stackstart)
  394. #define ARG0 %a6@(4)
  395. #define ARG1 %a6@(8)
  396. #define ARG2 %a6@(12)
  397. #define ARG3 %a6@(16)
  398. #define ARG4 %a6@(20)
  399. .macro func_start name,saveregs,stack=0
  400. L(\name):
  401. linkw %a6,#-\stack
  402. moveml \saveregs,%sp@-
  403. .set stackstart,-\stack
  404. .macro func_return_\name
  405. moveml %sp@+,\saveregs
  406. unlk %a6
  407. rts
  408. .endm
  409. .endm
  410. .macro func_return name
  411. func_return_\name
  412. .endm
  413. .macro func_call name
  414. jbsr L(\name)
  415. .endm
  416. .macro move_stack nr,arg1,arg2,arg3,arg4
  417. .if \nr
  418. move_stack "(\nr-1)",\arg2,\arg3,\arg4
  419. movel \arg1,%sp@-
  420. .endif
  421. .endm
  422. .macro func_define name,nr=0
  423. .macro \name arg1,arg2,arg3,arg4
  424. move_stack \nr,\arg1,\arg2,\arg3,\arg4
  425. func_call \name
  426. .if \nr
  427. lea %sp@(\nr*4),%sp
  428. .endif
  429. .endm
  430. .endm
  431. func_define mmu_map,4
  432. func_define mmu_map_tt,4
  433. func_define mmu_fixup_page_mmu_cache,1
  434. func_define mmu_temp_map,2
  435. func_define mmu_engage
  436. func_define mmu_get_root_table_entry,1
  437. func_define mmu_get_ptr_table_entry,2
  438. func_define mmu_get_page_table_entry,2
  439. func_define mmu_print
  440. func_define get_new_page
  441. #if defined(CONFIG_HP300) || defined(CONFIG_APOLLO)
  442. func_define set_leds
  443. #endif
  444. .macro mmu_map_eq arg1,arg2,arg3
  445. mmu_map \arg1,\arg1,\arg2,\arg3
  446. .endm
  447. .macro get_bi_record record
  448. pea \record
  449. func_call get_bi_record
  450. addql #4,%sp
  451. .endm
  452. func_define serial_putc,1
  453. func_define console_putc,1
  454. func_define console_init
  455. func_define console_put_stats
  456. func_define console_put_penguin
  457. func_define console_plot_pixel,3
  458. func_define console_scroll
  459. .macro putc ch
  460. #if defined(CONSOLE) || defined(SERIAL_DEBUG)
  461. pea \ch
  462. #endif
  463. #ifdef CONSOLE
  464. func_call console_putc
  465. #endif
  466. #ifdef SERIAL_DEBUG
  467. func_call serial_putc
  468. #endif
  469. #if defined(CONSOLE) || defined(SERIAL_DEBUG)
  470. addql #4,%sp
  471. #endif
  472. .endm
  473. .macro dputc ch
  474. #ifdef DEBUG
  475. putc \ch
  476. #endif
  477. .endm
  478. func_define putn,1
  479. .macro dputn nr
  480. #ifdef DEBUG
  481. putn \nr
  482. #endif
  483. .endm
  484. .macro puts string
  485. #if defined(CONSOLE) || defined(SERIAL_DEBUG)
  486. __INITDATA
  487. .Lstr\@:
  488. .string "\string"
  489. __FINIT
  490. pea %pc@(.Lstr\@)
  491. func_call puts
  492. addql #4,%sp
  493. #endif
  494. .endm
  495. .macro dputs string
  496. #ifdef DEBUG
  497. puts "\string"
  498. #endif
  499. .endm
  500. #define is_not_amiga(lab) cmpl &MACH_AMIGA,%pc@(m68k_machtype); jne lab
  501. #define is_not_atari(lab) cmpl &MACH_ATARI,%pc@(m68k_machtype); jne lab
  502. #define is_not_mac(lab) cmpl &MACH_MAC,%pc@(m68k_machtype); jne lab
  503. #define is_not_mvme147(lab) cmpl &MACH_MVME147,%pc@(m68k_machtype); jne lab
  504. #define is_not_mvme16x(lab) cmpl &MACH_MVME16x,%pc@(m68k_machtype); jne lab
  505. #define is_not_bvme6000(lab) cmpl &MACH_BVME6000,%pc@(m68k_machtype); jne lab
  506. #define is_mvme147(lab) cmpl &MACH_MVME147,%pc@(m68k_machtype); jeq lab
  507. #define is_mvme16x(lab) cmpl &MACH_MVME16x,%pc@(m68k_machtype); jeq lab
  508. #define is_bvme6000(lab) cmpl &MACH_BVME6000,%pc@(m68k_machtype); jeq lab
  509. #define is_not_hp300(lab) cmpl &MACH_HP300,%pc@(m68k_machtype); jne lab
  510. #define is_not_apollo(lab) cmpl &MACH_APOLLO,%pc@(m68k_machtype); jne lab
  511. #define is_not_q40(lab) cmpl &MACH_Q40,%pc@(m68k_machtype); jne lab
  512. #define is_not_sun3x(lab) cmpl &MACH_SUN3X,%pc@(m68k_machtype); jne lab
  513. #define hasnt_leds(lab) cmpl &MACH_HP300,%pc@(m68k_machtype); \
  514. jeq 42f; \
  515. cmpl &MACH_APOLLO,%pc@(m68k_machtype); \
  516. jne lab ;\
  517. 42:\
  518. #define is_040_or_060(lab) btst &CPUTYPE_0460,%pc@(L(cputype)+3); jne lab
  519. #define is_not_040_or_060(lab) btst &CPUTYPE_0460,%pc@(L(cputype)+3); jeq lab
  520. #define is_040(lab) btst &CPUTYPE_040,%pc@(L(cputype)+3); jne lab
  521. #define is_060(lab) btst &CPUTYPE_060,%pc@(L(cputype)+3); jne lab
  522. #define is_not_060(lab) btst &CPUTYPE_060,%pc@(L(cputype)+3); jeq lab
  523. #define is_020(lab) btst &CPUTYPE_020,%pc@(L(cputype)+3); jne lab
  524. #define is_not_020(lab) btst &CPUTYPE_020,%pc@(L(cputype)+3); jeq lab
  525. /* On the HP300 we use the on-board LEDs for debug output before
  526. the console is running. Writing a 1 bit turns the corresponding LED
  527. _off_ - on the 340 bit 7 is towards the back panel of the machine. */
  528. .macro leds mask
  529. #if defined(CONFIG_HP300) || defined(CONFIG_APOLLO)
  530. hasnt_leds(.Lled\@)
  531. pea \mask
  532. func_call set_leds
  533. addql #4,%sp
  534. .Lled\@:
  535. #endif
  536. .endm
  537. .text
  538. ENTRY(_stext)
  539. /*
  540. * Version numbers of the bootinfo interface
  541. * The area from _stext to _start will later be used as kernel pointer table
  542. */
  543. bras 1f /* Jump over bootinfo version numbers */
  544. .long BOOTINFOV_MAGIC
  545. .long MACH_AMIGA, AMIGA_BOOTI_VERSION
  546. .long MACH_ATARI, ATARI_BOOTI_VERSION
  547. .long MACH_MVME147, MVME147_BOOTI_VERSION
  548. .long MACH_MVME16x, MVME16x_BOOTI_VERSION
  549. .long MACH_BVME6000, BVME6000_BOOTI_VERSION
  550. .long MACH_MAC, MAC_BOOTI_VERSION
  551. .long MACH_Q40, Q40_BOOTI_VERSION
  552. .long MACH_HP300, HP300_BOOTI_VERSION
  553. .long 0
  554. 1: jra __start
  555. .equ kernel_pg_dir,_stext
  556. .equ .,_stext+PAGESIZE
  557. ENTRY(_start)
  558. jra __start
  559. __INIT
  560. ENTRY(__start)
  561. /*
  562. * Setup initial stack pointer
  563. */
  564. lea %pc@(_stext),%sp
  565. /*
  566. * Record the CPU and machine type.
  567. */
  568. get_bi_record BI_MACHTYPE
  569. lea %pc@(m68k_machtype),%a1
  570. movel %a0@,%a1@
  571. get_bi_record BI_FPUTYPE
  572. lea %pc@(m68k_fputype),%a1
  573. movel %a0@,%a1@
  574. get_bi_record BI_MMUTYPE
  575. lea %pc@(m68k_mmutype),%a1
  576. movel %a0@,%a1@
  577. get_bi_record BI_CPUTYPE
  578. lea %pc@(m68k_cputype),%a1
  579. movel %a0@,%a1@
  580. leds 0x1
  581. #ifdef CONFIG_MAC
  582. /*
  583. * For Macintosh, we need to determine the display parameters early (at least
  584. * while debugging it).
  585. */
  586. is_not_mac(L(test_notmac))
  587. get_bi_record BI_MAC_VADDR
  588. lea %pc@(L(mac_videobase)),%a1
  589. movel %a0@,%a1@
  590. get_bi_record BI_MAC_VDEPTH
  591. lea %pc@(L(mac_videodepth)),%a1
  592. movel %a0@,%a1@
  593. get_bi_record BI_MAC_VDIM
  594. lea %pc@(L(mac_dimensions)),%a1
  595. movel %a0@,%a1@
  596. get_bi_record BI_MAC_VROW
  597. lea %pc@(L(mac_rowbytes)),%a1
  598. movel %a0@,%a1@
  599. #ifdef MAC_SERIAL_DEBUG
  600. get_bi_record BI_MAC_SCCBASE
  601. lea %pc@(L(mac_sccbase)),%a1
  602. movel %a0@,%a1@
  603. #endif /* MAC_SERIAL_DEBUG */
  604. #if 0
  605. /*
  606. * Clear the screen
  607. */
  608. lea %pc@(L(mac_videobase)),%a0
  609. movel %a0@,%a1
  610. lea %pc@(L(mac_dimensions)),%a0
  611. movel %a0@,%d1
  612. swap %d1 /* #rows is high bytes */
  613. andl #0xFFFF,%d1 /* rows */
  614. subl #10,%d1
  615. lea %pc@(L(mac_rowbytes)),%a0
  616. loopy2:
  617. movel %a0@,%d0
  618. subql #1,%d0
  619. loopx2:
  620. moveb #0x55, %a1@+
  621. dbra %d0,loopx2
  622. dbra %d1,loopy2
  623. #endif
  624. L(test_notmac):
  625. #endif /* CONFIG_MAC */
  626. /*
  627. * There are ultimately two pieces of information we want for all kinds of
  628. * processors CpuType and CacheBits. The CPUTYPE was passed in from booter
  629. * and is converted here from a booter type definition to a separate bit
  630. * number which allows for the standard is_0x0 macro tests.
  631. */
  632. movel %pc@(m68k_cputype),%d0
  633. /*
  634. * Assume it's an 030
  635. */
  636. clrl %d1
  637. /*
  638. * Test the BootInfo cputype for 060
  639. */
  640. btst #CPUB_68060,%d0
  641. jeq 1f
  642. bset #CPUTYPE_060,%d1
  643. bset #CPUTYPE_0460,%d1
  644. jra 3f
  645. 1:
  646. /*
  647. * Test the BootInfo cputype for 040
  648. */
  649. btst #CPUB_68040,%d0
  650. jeq 2f
  651. bset #CPUTYPE_040,%d1
  652. bset #CPUTYPE_0460,%d1
  653. jra 3f
  654. 2:
  655. /*
  656. * Test the BootInfo cputype for 020
  657. */
  658. btst #CPUB_68020,%d0
  659. jeq 3f
  660. bset #CPUTYPE_020,%d1
  661. jra 3f
  662. 3:
  663. /*
  664. * Record the cpu type
  665. */
  666. lea %pc@(L(cputype)),%a0
  667. movel %d1,%a0@
  668. /*
  669. * NOTE:
  670. *
  671. * Now the macros are valid:
  672. * is_040_or_060
  673. * is_not_040_or_060
  674. * is_040
  675. * is_060
  676. * is_not_060
  677. */
  678. /*
  679. * Determine the cache mode for pages holding MMU tables
  680. * and for supervisor mode, unused for '020 and '030
  681. */
  682. clrl %d0
  683. clrl %d1
  684. is_not_040_or_060(L(save_cachetype))
  685. /*
  686. * '040 or '060
  687. * d1 := cacheable write-through
  688. * NOTE: The 68040 manual strongly recommends non-cached for MMU tables,
  689. * but we have been using write-through since at least 2.0.29 so I
  690. * guess it is OK.
  691. */
  692. #ifdef CONFIG_060_WRITETHROUGH
  693. /*
  694. * If this is a 68060 board using drivers with cache coherency
  695. * problems, then supervisor memory accesses need to be write-through
  696. * also; otherwise, we want copyback.
  697. */
  698. is_not_060(1f)
  699. movel #_PAGE_CACHE040W,%d0
  700. jra L(save_cachetype)
  701. #endif /* CONFIG_060_WRITETHROUGH */
  702. 1:
  703. movew #_PAGE_CACHE040,%d0
  704. movel #_PAGE_CACHE040W,%d1
  705. L(save_cachetype):
  706. /* Save cache mode for supervisor mode and page tables
  707. */
  708. lea %pc@(m68k_supervisor_cachemode),%a0
  709. movel %d0,%a0@
  710. lea %pc@(m68k_pgtable_cachemode),%a0
  711. movel %d1,%a0@
  712. /*
  713. * raise interrupt level
  714. */
  715. movew #0x2700,%sr
  716. /*
  717. If running on an Atari, determine the I/O base of the
  718. serial port and test if we are running on a Medusa or Hades.
  719. This test is necessary here, because on the Hades the serial
  720. port is only accessible in the high I/O memory area.
  721. The test whether it is a Medusa is done by writing to the byte at
  722. phys. 0x0. This should result in a bus error on all other machines.
  723. ...should, but doesn't. The Afterburner040 for the Falcon has the
  724. same behaviour (0x0..0x7 are no ROM shadow). So we have to do
  725. another test to distinguish Medusa and AB040. This is a
  726. read attempt for 0x00ff82fe phys. that should bus error on a Falcon
  727. (+AB040), but is in the range where the Medusa always asserts DTACK.
  728. The test for the Hades is done by reading address 0xb0000000. This
  729. should give a bus error on the Medusa.
  730. */
  731. #ifdef CONFIG_ATARI
  732. is_not_atari(L(notypetest))
  733. /* get special machine type (Medusa/Hades/AB40) */
  734. moveq #0,%d3 /* default if tag doesn't exist */
  735. get_bi_record BI_ATARI_MCH_TYPE
  736. tstl %d0
  737. jbmi 1f
  738. movel %a0@,%d3
  739. lea %pc@(atari_mch_type),%a0
  740. movel %d3,%a0@
  741. 1:
  742. /* On the Hades, the iobase must be set up before opening the
  743. * serial port. There are no I/O regs at 0x00ffxxxx at all. */
  744. moveq #0,%d0
  745. cmpl #ATARI_MACH_HADES,%d3
  746. jbne 1f
  747. movel #0xff000000,%d0 /* Hades I/O base addr: 0xff000000 */
  748. 1: lea %pc@(L(iobase)),%a0
  749. movel %d0,%a0@
  750. L(notypetest):
  751. #endif
  752. #ifdef CONFIG_VME
  753. is_mvme147(L(getvmetype))
  754. is_bvme6000(L(getvmetype))
  755. is_not_mvme16x(L(gvtdone))
  756. /* See if the loader has specified the BI_VME_TYPE tag. Recent
  757. * versions of VMELILO and TFTPLILO do this. We have to do this
  758. * early so we know how to handle console output. If the tag
  759. * doesn't exist then we use the Bug for output on MVME16x.
  760. */
  761. L(getvmetype):
  762. get_bi_record BI_VME_TYPE
  763. tstl %d0
  764. jbmi 1f
  765. movel %a0@,%d3
  766. lea %pc@(vme_brdtype),%a0
  767. movel %d3,%a0@
  768. 1:
  769. #ifdef CONFIG_MVME16x
  770. is_not_mvme16x(L(gvtdone))
  771. /* Need to get the BRD_ID info to differentiate between 162, 167,
  772. * etc. This is available as a BI_VME_BRDINFO tag with later
  773. * versions of VMELILO and TFTPLILO, otherwise we call the Bug.
  774. */
  775. get_bi_record BI_VME_BRDINFO
  776. tstl %d0
  777. jpl 1f
  778. /* Get pointer to board ID data from Bug */
  779. movel %d2,%sp@-
  780. trap #15
  781. .word 0x70 /* trap 0x70 - .BRD_ID */
  782. movel %sp@+,%a0
  783. 1:
  784. lea %pc@(mvme_bdid),%a1
  785. /* Structure is 32 bytes long */
  786. movel %a0@+,%a1@+
  787. movel %a0@+,%a1@+
  788. movel %a0@+,%a1@+
  789. movel %a0@+,%a1@+
  790. movel %a0@+,%a1@+
  791. movel %a0@+,%a1@+
  792. movel %a0@+,%a1@+
  793. movel %a0@+,%a1@+
  794. #endif
  795. L(gvtdone):
  796. #endif
  797. #ifdef CONFIG_HP300
  798. is_not_hp300(L(nothp))
  799. /* Get the address of the UART for serial debugging */
  800. get_bi_record BI_HP300_UART_ADDR
  801. tstl %d0
  802. jbmi 1f
  803. movel %a0@,%d3
  804. lea %pc@(L(uartbase)),%a0
  805. movel %d3,%a0@
  806. get_bi_record BI_HP300_UART_SCODE
  807. tstl %d0
  808. jbmi 1f
  809. movel %a0@,%d3
  810. lea %pc@(L(uart_scode)),%a0
  811. movel %d3,%a0@
  812. 1:
  813. L(nothp):
  814. #endif
  815. /*
  816. * Initialize serial port
  817. */
  818. jbsr L(serial_init)
  819. /*
  820. * Initialize console
  821. */
  822. #ifdef CONFIG_MAC
  823. is_not_mac(L(nocon))
  824. #ifdef CONSOLE
  825. console_init
  826. #ifdef CONSOLE_PENGUIN
  827. console_put_penguin
  828. #endif /* CONSOLE_PENGUIN */
  829. console_put_stats
  830. #endif /* CONSOLE */
  831. L(nocon):
  832. #endif /* CONFIG_MAC */
  833. putc '\n'
  834. putc 'A'
  835. leds 0x2
  836. dputn %pc@(L(cputype))
  837. dputn %pc@(m68k_supervisor_cachemode)
  838. dputn %pc@(m68k_pgtable_cachemode)
  839. dputc '\n'
  840. /*
  841. * Save physical start address of kernel
  842. */
  843. lea %pc@(L(phys_kernel_start)),%a0
  844. lea %pc@(_stext),%a1
  845. subl #_stext,%a1
  846. addl #PAGE_OFFSET,%a1
  847. movel %a1,%a0@
  848. putc 'B'
  849. leds 0x4
  850. /*
  851. * mmu_init
  852. *
  853. * This block of code does what's necessary to map in the various kinds
  854. * of machines for execution of Linux.
  855. * First map the first 4 MB of kernel code & data
  856. */
  857. mmu_map #PAGE_OFFSET,%pc@(L(phys_kernel_start)),#4*1024*1024,\
  858. %pc@(m68k_supervisor_cachemode)
  859. putc 'C'
  860. #ifdef CONFIG_AMIGA
  861. L(mmu_init_amiga):
  862. is_not_amiga(L(mmu_init_not_amiga))
  863. /*
  864. * mmu_init_amiga
  865. */
  866. putc 'D'
  867. is_not_040_or_060(1f)
  868. /*
  869. * 040: Map the 16Meg range physical 0x0 upto logical 0x8000.0000
  870. */
  871. mmu_map #0x80000000,#0,#0x01000000,#_PAGE_NOCACHE_S
  872. /*
  873. * Map the Zorro III I/O space with transparent translation
  874. * for frame buffer memory etc.
  875. */
  876. mmu_map_tt #1,#0x40000000,#0x20000000,#_PAGE_NOCACHE_S
  877. jbra L(mmu_init_done)
  878. 1:
  879. /*
  880. * 030: Map the 32Meg range physical 0x0 upto logical 0x8000.0000
  881. */
  882. mmu_map #0x80000000,#0,#0x02000000,#_PAGE_NOCACHE030
  883. mmu_map_tt #1,#0x40000000,#0x20000000,#_PAGE_NOCACHE030
  884. jbra L(mmu_init_done)
  885. L(mmu_init_not_amiga):
  886. #endif
  887. #ifdef CONFIG_ATARI
  888. L(mmu_init_atari):
  889. is_not_atari(L(mmu_init_not_atari))
  890. putc 'E'
  891. /* On the Atari, we map the I/O region (phys. 0x00ffxxxx) by mapping
  892. the last 16 MB of virtual address space to the first 16 MB (i.e.
  893. 0xffxxxxxx -> 0x00xxxxxx). For this, an additional pointer table is
  894. needed. I/O ranges are marked non-cachable.
  895. For the Medusa it is better to map the I/O region transparently
  896. (i.e. 0xffxxxxxx -> 0xffxxxxxx), because some I/O registers are
  897. accessible only in the high area.
  898. On the Hades all I/O registers are only accessible in the high
  899. area.
  900. */
  901. /* I/O base addr for non-Medusa, non-Hades: 0x00000000 */
  902. moveq #0,%d0
  903. movel %pc@(atari_mch_type),%d3
  904. cmpl #ATARI_MACH_MEDUSA,%d3
  905. jbeq 2f
  906. cmpl #ATARI_MACH_HADES,%d3
  907. jbne 1f
  908. 2: movel #0xff000000,%d0 /* Medusa/Hades base addr: 0xff000000 */
  909. 1: movel %d0,%d3
  910. is_040_or_060(L(spata68040))
  911. /* Map everything non-cacheable, though not all parts really
  912. * need to disable caches (crucial only for 0xff8000..0xffffff
  913. * (standard I/O) and 0xf00000..0xf3ffff (IDE)). The remainder
  914. * isn't really used, except for sometimes peeking into the
  915. * ROMs (mirror at phys. 0x0), so caching isn't necessary for
  916. * this. */
  917. mmu_map #0xff000000,%d3,#0x01000000,#_PAGE_NOCACHE030
  918. jbra L(mmu_init_done)
  919. L(spata68040):
  920. mmu_map #0xff000000,%d3,#0x01000000,#_PAGE_NOCACHE_S
  921. jbra L(mmu_init_done)
  922. L(mmu_init_not_atari):
  923. #endif
  924. #ifdef CONFIG_Q40
  925. is_not_q40(L(notq40))
  926. /*
  927. * add transparent mapping for 0xff00 0000 - 0xffff ffff
  928. * non-cached serialized etc..
  929. * this includes master chip, DAC, RTC and ISA ports
  930. * 0xfe000000-0xfeffffff is for screen and ROM
  931. */
  932. putc 'Q'
  933. mmu_map_tt #0,#0xfe000000,#0x01000000,#_PAGE_CACHE040W
  934. mmu_map_tt #1,#0xff000000,#0x01000000,#_PAGE_NOCACHE_S
  935. jbra L(mmu_init_done)
  936. L(notq40):
  937. #endif
  938. #ifdef CONFIG_HP300
  939. is_not_hp300(L(nothp300))
  940. /* On the HP300, we map the ROM, INTIO and DIO regions (phys. 0x00xxxxxx)
  941. * by mapping 32MB (on 020/030) or 16 MB (on 040) from 0xf0xxxxxx -> 0x00xxxxxx).
  942. * The ROM mapping is needed because the LEDs are mapped there too.
  943. */
  944. is_040(1f)
  945. /*
  946. * 030: Map the 32Meg range physical 0x0 upto logical 0xf000.0000
  947. */
  948. mmu_map #0xf0000000,#0,#0x02000000,#_PAGE_NOCACHE030
  949. jbra L(mmu_init_done)
  950. 1:
  951. /*
  952. * 040: Map the 16Meg range physical 0x0 upto logical 0xf000.0000
  953. */
  954. mmu_map #0xf0000000,#0,#0x01000000,#_PAGE_NOCACHE_S
  955. jbra L(mmu_init_done)
  956. L(nothp300):
  957. #endif /* CONFIG_HP300 */
  958. #ifdef CONFIG_MVME147
  959. is_not_mvme147(L(not147))
  960. /*
  961. * On MVME147 we have already created kernel page tables for
  962. * 4MB of RAM at address 0, so now need to do a transparent
  963. * mapping of the top of memory space. Make it 0.5GByte for now,
  964. * so we can access on-board i/o areas.
  965. */
  966. mmu_map_tt #1,#0xe0000000,#0x20000000,#_PAGE_NOCACHE030
  967. jbra L(mmu_init_done)
  968. L(not147):
  969. #endif /* CONFIG_MVME147 */
  970. #ifdef CONFIG_MVME16x
  971. is_not_mvme16x(L(not16x))
  972. /*
  973. * On MVME16x we have already created kernel page tables for
  974. * 4MB of RAM at address 0, so now need to do a transparent
  975. * mapping of the top of memory space. Make it 0.5GByte for now.
  976. * Supervisor only access, so transparent mapping doesn't
  977. * clash with User code virtual address space.
  978. * this covers IO devices, PROM and SRAM. The PROM and SRAM
  979. * mapping is needed to allow 167Bug to run.
  980. * IO is in the range 0xfff00000 to 0xfffeffff.
  981. * PROM is 0xff800000->0xffbfffff and SRAM is
  982. * 0xffe00000->0xffe1ffff.
  983. */
  984. mmu_map_tt #1,#0xe0000000,#0x20000000,#_PAGE_NOCACHE_S
  985. jbra L(mmu_init_done)
  986. L(not16x):
  987. #endif /* CONFIG_MVME162 | CONFIG_MVME167 */
  988. #ifdef CONFIG_BVME6000
  989. is_not_bvme6000(L(not6000))
  990. /*
  991. * On BVME6000 we have already created kernel page tables for
  992. * 4MB of RAM at address 0, so now need to do a transparent
  993. * mapping of the top of memory space. Make it 0.5GByte for now,
  994. * so we can access on-board i/o areas.
  995. * Supervisor only access, so transparent mapping doesn't
  996. * clash with User code virtual address space.
  997. */
  998. mmu_map_tt #1,#0xe0000000,#0x20000000,#_PAGE_NOCACHE_S
  999. jbra L(mmu_init_done)
  1000. L(not6000):
  1001. #endif /* CONFIG_BVME6000 */
  1002. /*
  1003. * mmu_init_mac
  1004. *
  1005. * The Macintosh mappings are less clear.
  1006. *
  1007. * Even as of this writing, it is unclear how the
  1008. * Macintosh mappings will be done. However, as
  1009. * the first author of this code I'm proposing the
  1010. * following model:
  1011. *
  1012. * Map the kernel (that's already done),
  1013. * Map the I/O (on most machines that's the
  1014. * 0x5000.0000 ... 0x5300.0000 range,
  1015. * Map the video frame buffer using as few pages
  1016. * as absolutely (this requirement mostly stems from
  1017. * the fact that when the frame buffer is at
  1018. * 0x0000.0000 then we know there is valid RAM just
  1019. * above the screen that we don't want to waste!).
  1020. *
  1021. * By the way, if the frame buffer is at 0x0000.0000
  1022. * then the Macintosh is known as an RBV based Mac.
  1023. *
  1024. * By the way 2, the code currently maps in a bunch of
  1025. * regions. But I'd like to cut that out. (And move most
  1026. * of the mappings up into the kernel proper ... or only
  1027. * map what's necessary.)
  1028. */
  1029. #ifdef CONFIG_MAC
  1030. L(mmu_init_mac):
  1031. is_not_mac(L(mmu_init_not_mac))
  1032. putc 'F'
  1033. is_not_040_or_060(1f)
  1034. moveq #_PAGE_NOCACHE_S,%d3
  1035. jbra 2f
  1036. 1:
  1037. moveq #_PAGE_NOCACHE030,%d3
  1038. 2:
  1039. /*
  1040. * Mac Note: screen address of logical 0xF000.0000 -> <screen physical>
  1041. * we simply map the 4MB that contains the videomem
  1042. */
  1043. movel #VIDEOMEMMASK,%d0
  1044. andl %pc@(L(mac_videobase)),%d0
  1045. mmu_map #VIDEOMEMBASE,%d0,#VIDEOMEMSIZE,%d3
  1046. /* ROM from 4000 0000 to 4200 0000 (only for mac_reset()) */
  1047. mmu_map_eq #0x40000000,#0x02000000,%d3
  1048. /* IO devices (incl. serial port) from 5000 0000 to 5300 0000 */
  1049. mmu_map_eq #0x50000000,#0x03000000,%d3
  1050. /* Nubus slot space (video at 0xF0000000, rom at 0xF0F80000) */
  1051. mmu_map_tt #1,#0xf8000000,#0x08000000,%d3
  1052. jbra L(mmu_init_done)
  1053. L(mmu_init_not_mac):
  1054. #endif
  1055. #ifdef CONFIG_SUN3X
  1056. is_not_sun3x(L(notsun3x))
  1057. /* oh, the pain.. We're gonna want the prom code after
  1058. * starting the MMU, so we copy the mappings, translating
  1059. * from 8k -> 4k pages as we go.
  1060. */
  1061. /* copy maps from 0xfee00000 to 0xff000000 */
  1062. movel #0xfee00000, %d0
  1063. moveq #ROOT_INDEX_SHIFT, %d1
  1064. lsrl %d1,%d0
  1065. mmu_get_root_table_entry %d0
  1066. movel #0xfee00000, %d0
  1067. moveq #PTR_INDEX_SHIFT, %d1
  1068. lsrl %d1,%d0
  1069. andl #PTR_TABLE_SIZE-1, %d0
  1070. mmu_get_ptr_table_entry %a0,%d0
  1071. movel #0xfee00000, %d0
  1072. moveq #PAGE_INDEX_SHIFT, %d1
  1073. lsrl %d1,%d0
  1074. andl #PAGE_TABLE_SIZE-1, %d0
  1075. mmu_get_page_table_entry %a0,%d0
  1076. /* this is where the prom page table lives */
  1077. movel 0xfefe00d4, %a1
  1078. movel %a1@, %a1
  1079. movel #((0x200000 >> 13)-1), %d1
  1080. 1:
  1081. movel %a1@+, %d3
  1082. movel %d3,%a0@+
  1083. addl #0x1000,%d3
  1084. movel %d3,%a0@+
  1085. dbra %d1,1b
  1086. /* setup tt1 for I/O */
  1087. mmu_map_tt #1,#0x40000000,#0x40000000,#_PAGE_NOCACHE_S
  1088. jbra L(mmu_init_done)
  1089. L(notsun3x):
  1090. #endif
  1091. #ifdef CONFIG_APOLLO
  1092. is_not_apollo(L(notapollo))
  1093. putc 'P'
  1094. mmu_map #0x80000000,#0,#0x02000000,#_PAGE_NOCACHE030
  1095. L(notapollo):
  1096. jbra L(mmu_init_done)
  1097. #endif
  1098. L(mmu_init_done):
  1099. putc 'G'
  1100. leds 0x8
  1101. /*
  1102. * mmu_fixup
  1103. *
  1104. * On the 040 class machines, all pages that are used for the
  1105. * mmu have to be fixed up. According to Motorola, pages holding mmu
  1106. * tables should be non-cacheable on a '040 and write-through on a
  1107. * '060. But analysis of the reasons for this, and practical
  1108. * experience, showed that write-through also works on a '040.
  1109. *
  1110. * Allocated memory so far goes from kernel_end to memory_start that
  1111. * is used for all kind of tables, for that the cache attributes
  1112. * are now fixed.
  1113. */
  1114. L(mmu_fixup):
  1115. is_not_040_or_060(L(mmu_fixup_done))
  1116. #ifdef MMU_NOCACHE_KERNEL
  1117. jbra L(mmu_fixup_done)
  1118. #endif
  1119. /* first fix the page at the start of the kernel, that
  1120. * contains also kernel_pg_dir.
  1121. */
  1122. movel %pc@(L(phys_kernel_start)),%d0
  1123. subl #PAGE_OFFSET,%d0
  1124. lea %pc@(_stext),%a0
  1125. subl %d0,%a0
  1126. mmu_fixup_page_mmu_cache %a0
  1127. movel %pc@(L(kernel_end)),%a0
  1128. subl %d0,%a0
  1129. movel %pc@(L(memory_start)),%a1
  1130. subl %d0,%a1
  1131. bra 2f
  1132. 1:
  1133. mmu_fixup_page_mmu_cache %a0
  1134. addw #PAGESIZE,%a0
  1135. 2:
  1136. cmpl %a0,%a1
  1137. jgt 1b
  1138. L(mmu_fixup_done):
  1139. #ifdef MMU_PRINT
  1140. mmu_print
  1141. #endif
  1142. /*
  1143. * mmu_engage
  1144. *
  1145. * This chunk of code performs the gruesome task of engaging the MMU.
  1146. * The reason its gruesome is because when the MMU becomes engaged it
  1147. * maps logical addresses to physical addresses. The Program Counter
  1148. * register is then passed through the MMU before the next instruction
  1149. * is fetched (the instruction following the engage MMU instruction).
  1150. * This may mean one of two things:
  1151. * 1. The Program Counter falls within the logical address space of
  1152. * the kernel of which there are two sub-possibilities:
  1153. * A. The PC maps to the correct instruction (logical PC == physical
  1154. * code location), or
  1155. * B. The PC does not map through and the processor will read some
  1156. * data (or instruction) which is not the logically next instr.
  1157. * As you can imagine, A is good and B is bad.
  1158. * Alternatively,
  1159. * 2. The Program Counter does not map through the MMU. The processor
  1160. * will take a Bus Error.
  1161. * Clearly, 2 is bad.
  1162. * It doesn't take a wiz kid to figure you want 1.A.
  1163. * This code creates that possibility.
  1164. * There are two possible 1.A. states (we now ignore the other above states):
  1165. * A. The kernel is located at physical memory addressed the same as
  1166. * the logical memory for the kernel, i.e., 0x01000.
  1167. * B. The kernel is located some where else. e.g., 0x0400.0000
  1168. *
  1169. * Under some conditions the Macintosh can look like A or B.
  1170. * [A friend and I once noted that Apple hardware engineers should be
  1171. * wacked twice each day: once when they show up at work (as in, Whack!,
  1172. * "This is for the screwy hardware we know you're going to design today."),
  1173. * and also at the end of the day (as in, Whack! "I don't know what
  1174. * you designed today, but I'm sure it wasn't good."). -- rst]
  1175. *
  1176. * This code works on the following premise:
  1177. * If the kernel start (%d5) is within the first 16 Meg of RAM,
  1178. * then create a mapping for the kernel at logical 0x8000.0000 to
  1179. * the physical location of the pc. And, create a transparent
  1180. * translation register for the first 16 Meg. Then, after the MMU
  1181. * is engaged, the PC can be moved up into the 0x8000.0000 range
  1182. * and then the transparent translation can be turned off and then
  1183. * the PC can jump to the correct logical location and it will be
  1184. * home (finally). This is essentially the code that the Amiga used
  1185. * to use. Now, it's generalized for all processors. Which means
  1186. * that a fresh (but temporary) mapping has to be created. The mapping
  1187. * is made in page 0 (an as of yet unused location -- except for the
  1188. * stack!). This temporary mapping will only require 1 pointer table
  1189. * and a single page table (it can map 256K).
  1190. *
  1191. * OK, alternatively, imagine that the Program Counter is not within
  1192. * the first 16 Meg. Then, just use Transparent Translation registers
  1193. * to do the right thing.
  1194. *
  1195. * Last, if _start is already at 0x01000, then there's nothing special
  1196. * to do (in other words, in a degenerate case of the first case above,
  1197. * do nothing).
  1198. *
  1199. * Let's do it.
  1200. *
  1201. *
  1202. */
  1203. putc 'H'
  1204. mmu_engage
  1205. /*
  1206. * After this point no new memory is allocated and
  1207. * the start of available memory is stored in availmem.
  1208. * (The bootmem allocator requires now the physicall address.)
  1209. */
  1210. movel L(memory_start),availmem
  1211. #ifdef CONFIG_AMIGA
  1212. is_not_amiga(1f)
  1213. /* fixup the Amiga custom register location before printing */
  1214. clrl L(custom)
  1215. 1:
  1216. #endif
  1217. #ifdef CONFIG_ATARI
  1218. is_not_atari(1f)
  1219. /* fixup the Atari iobase register location before printing */
  1220. movel #0xff000000,L(iobase)
  1221. 1:
  1222. #endif
  1223. #ifdef CONFIG_MAC
  1224. is_not_mac(1f)
  1225. movel #~VIDEOMEMMASK,%d0
  1226. andl L(mac_videobase),%d0
  1227. addl #VIDEOMEMBASE,%d0
  1228. movel %d0,L(mac_videobase)
  1229. #if defined(CONSOLE)
  1230. movel %pc@(L(phys_kernel_start)),%d0
  1231. subl #PAGE_OFFSET,%d0
  1232. subl %d0,L(console_font)
  1233. subl %d0,L(console_font_data)
  1234. #endif
  1235. #ifdef MAC_SERIAL_DEBUG
  1236. orl #0x50000000,L(mac_sccbase)
  1237. #endif
  1238. 1:
  1239. #endif
  1240. #ifdef CONFIG_HP300
  1241. is_not_hp300(1f)
  1242. /*
  1243. * Fix up the iobase register to point to the new location of the LEDs.
  1244. */
  1245. movel #0xf0000000,L(iobase)
  1246. /*
  1247. * Energise the FPU and caches.
  1248. */
  1249. is_040(1f)
  1250. movel #0x60,0xf05f400c
  1251. jbra 2f
  1252. /*
  1253. * 040: slightly different, apparently.
  1254. */
  1255. 1: movew #0,0xf05f400e
  1256. movew #0x64,0xf05f400e
  1257. 2:
  1258. #endif
  1259. #ifdef CONFIG_SUN3X
  1260. is_not_sun3x(1f)
  1261. /* enable copro */
  1262. oriw #0x4000,0x61000000
  1263. 1:
  1264. #endif
  1265. #ifdef CONFIG_APOLLO
  1266. is_not_apollo(1f)
  1267. /*
  1268. * Fix up the iobase before printing
  1269. */
  1270. movel #0x80000000,L(iobase)
  1271. 1:
  1272. #endif
  1273. putc 'I'
  1274. leds 0x10
  1275. /*
  1276. * Enable caches
  1277. */
  1278. is_not_040_or_060(L(cache_not_680460))
  1279. L(cache680460):
  1280. .chip 68040
  1281. nop
  1282. cpusha %bc
  1283. nop
  1284. is_060(L(cache68060))
  1285. movel #CC6_ENABLE_D+CC6_ENABLE_I,%d0
  1286. /* MMU stuff works in copyback mode now, so enable the cache */
  1287. movec %d0,%cacr
  1288. jra L(cache_done)
  1289. L(cache68060):
  1290. movel #CC6_ENABLE_D+CC6_ENABLE_I+CC6_ENABLE_SB+CC6_PUSH_DPI+CC6_ENABLE_B+CC6_CLRA_B,%d0
  1291. /* MMU stuff works in copyback mode now, so enable the cache */
  1292. movec %d0,%cacr
  1293. /* enable superscalar dispatch in PCR */
  1294. moveq #1,%d0
  1295. .chip 68060
  1296. movec %d0,%pcr
  1297. jbra L(cache_done)
  1298. L(cache_not_680460):
  1299. L(cache68030):
  1300. .chip 68030
  1301. movel #CC3_ENABLE_DB+CC3_CLR_D+CC3_ENABLE_D+CC3_ENABLE_IB+CC3_CLR_I+CC3_ENABLE_I,%d0
  1302. movec %d0,%cacr
  1303. jra L(cache_done)
  1304. .chip 68k
  1305. L(cache_done):
  1306. putc 'J'
  1307. /*
  1308. * Setup initial stack pointer
  1309. */
  1310. lea init_task,%curptr
  1311. lea init_thread_union+THREAD_SIZE,%sp
  1312. putc 'K'
  1313. subl %a6,%a6 /* clear a6 for gdb */
  1314. /*
  1315. * The new 64bit printf support requires an early exception initialization.
  1316. */
  1317. jbsr base_trap_init
  1318. /* jump to the kernel start */
  1319. putc '\n'
  1320. leds 0x55
  1321. jbsr start_kernel
  1322. /*
  1323. * Find a tag record in the bootinfo structure
  1324. * The bootinfo structure is located right after the kernel bss
  1325. * Returns: d0: size (-1 if not found)
  1326. * a0: data pointer (end-of-records if not found)
  1327. */
  1328. func_start get_bi_record,%d1
  1329. movel ARG1,%d0
  1330. lea %pc@(_end),%a0
  1331. 1: tstw %a0@(BIR_TAG)
  1332. jeq 3f
  1333. cmpw %a0@(BIR_TAG),%d0
  1334. jeq 2f
  1335. addw %a0@(BIR_SIZE),%a0
  1336. jra 1b
  1337. 2: moveq #0,%d0
  1338. movew %a0@(BIR_SIZE),%d0
  1339. lea %a0@(BIR_DATA),%a0
  1340. jra 4f
  1341. 3: moveq #-1,%d0
  1342. lea %a0@(BIR_SIZE),%a0
  1343. 4:
  1344. func_return get_bi_record
  1345. /*
  1346. * MMU Initialization Begins Here
  1347. *
  1348. * The structure of the MMU tables on the 68k machines
  1349. * is thus:
  1350. * Root Table
  1351. * Logical addresses are translated through
  1352. * a hierarchical translation mechanism where the high-order
  1353. * seven bits of the logical address (LA) are used as an
  1354. * index into the "root table." Each entry in the root
  1355. * table has a bit which specifies if it's a valid pointer to a
  1356. * pointer table. Each entry defines a 32KMeg range of memory.
  1357. * If an entry is invalid then that logical range of 32M is
  1358. * invalid and references to that range of memory (when the MMU
  1359. * is enabled) will fault. If the entry is valid, then it does
  1360. * one of two things. On 040/060 class machines, it points to
  1361. * a pointer table which then describes more finely the memory
  1362. * within that 32M range. On 020/030 class machines, a technique
  1363. * called "early terminating descriptors" are used. This technique
  1364. * allows an entire 32Meg to be described by a single entry in the
  1365. * root table. Thus, this entry in the root table, contains the
  1366. * physical address of the memory or I/O at the logical address
  1367. * which the entry represents and it also contains the necessary
  1368. * cache bits for this region.
  1369. *
  1370. * Pointer Tables
  1371. * Per the Root Table, there will be one or more
  1372. * pointer tables. Each pointer table defines a 32M range.
  1373. * Not all of the 32M range need be defined. Again, the next
  1374. * seven bits of the logical address are used an index into
  1375. * the pointer table to point to page tables (if the pointer
  1376. * is valid). There will undoubtedly be more than one
  1377. * pointer table for the kernel because each pointer table
  1378. * defines a range of only 32M. Valid pointer table entries
  1379. * point to page tables, or are early terminating entries
  1380. * themselves.
  1381. *
  1382. * Page Tables
  1383. * Per the Pointer Tables, each page table entry points
  1384. * to the physical page in memory that supports the logical
  1385. * address that translates to the particular index.
  1386. *
  1387. * In short, the Logical Address gets translated as follows:
  1388. * bits 31..26 - index into the Root Table
  1389. * bits 25..18 - index into the Pointer Table
  1390. * bits 17..12 - index into the Page Table
  1391. * bits 11..0 - offset into a particular 4K page
  1392. *
  1393. * The algorithms which follows do one thing: they abstract
  1394. * the MMU hardware. For example, there are three kinds of
  1395. * cache settings that are relevant. Either, memory is
  1396. * being mapped in which case it is either Kernel Code (or
  1397. * the RamDisk) or it is MMU data. On the 030, the MMU data
  1398. * option also describes the kernel. Or, I/O is being mapped
  1399. * in which case it has its own kind of cache bits. There
  1400. * are constants which abstract these notions from the code that
  1401. * actually makes the call to map some range of memory.
  1402. *
  1403. *
  1404. *
  1405. */
  1406. #ifdef MMU_PRINT
  1407. /*
  1408. * mmu_print
  1409. *
  1410. * This algorithm will print out the current MMU mappings.
  1411. *
  1412. * Input:
  1413. * %a5 points to the root table. Everything else is calculated
  1414. * from this.
  1415. */
  1416. #define mmu_next_valid 0
  1417. #define mmu_start_logical 4
  1418. #define mmu_next_logical 8
  1419. #define mmu_start_physical 12
  1420. #define mmu_next_physical 16
  1421. #define MMU_PRINT_INVALID -1
  1422. #define MMU_PRINT_VALID 1
  1423. #define MMU_PRINT_UNINITED 0
  1424. #define putZc(z,n) jbne 1f; putc z; jbra 2f; 1: putc n; 2:
  1425. func_start mmu_print,%a0-%a6/%d0-%d7
  1426. movel %pc@(L(kernel_pgdir_ptr)),%a5
  1427. lea %pc@(L(mmu_print_data)),%a0
  1428. movel #MMU_PRINT_UNINITED,%a0@(mmu_next_valid)
  1429. is_not_040_or_060(mmu_030_print)
  1430. mmu_040_print:
  1431. puts "\nMMU040\n"
  1432. puts "rp:"
  1433. putn %a5
  1434. putc '\n'
  1435. #if 0
  1436. /*
  1437. * The following #if/#endif block is a tight algorithm for dumping the 040
  1438. * MMU Map in gory detail. It really isn't that practical unless the
  1439. * MMU Map algorithm appears to go awry and you need to debug it at the
  1440. * entry per entry level.
  1441. */
  1442. movel #ROOT_TABLE_SIZE,%d5
  1443. #if 0
  1444. movel %a5@+,%d7 | Burn an entry to skip the kernel mappings,
  1445. subql #1,%d5 | they (might) work
  1446. #endif
  1447. 1: tstl %d5
  1448. jbeq mmu_print_done
  1449. subq #1,%d5
  1450. movel %a5@+,%d7
  1451. btst #1,%d7
  1452. jbeq 1b
  1453. 2: putn %d7
  1454. andil #0xFFFFFE00,%d7
  1455. movel %d7,%a4
  1456. movel #PTR_TABLE_SIZE,%d4
  1457. putc ' '
  1458. 3: tstl %d4
  1459. jbeq 11f
  1460. subq #1,%d4
  1461. movel %a4@+,%d7
  1462. btst #1,%d7
  1463. jbeq 3b
  1464. 4: putn %d7
  1465. andil #0xFFFFFF00,%d7
  1466. movel %d7,%a3
  1467. movel #PAGE_TABLE_SIZE,%d3
  1468. 5: movel #8,%d2
  1469. 6: tstl %d3
  1470. jbeq 31f
  1471. subq #1,%d3
  1472. movel %a3@+,%d6
  1473. btst #0,%d6
  1474. jbeq 6b
  1475. 7: tstl %d2
  1476. jbeq 8f
  1477. subq #1,%d2
  1478. putc ' '
  1479. jbra 91f
  1480. 8: putc '\n'
  1481. movel #8+1+8+1+1,%d2
  1482. 9: putc ' '
  1483. dbra %d2,9b
  1484. movel #7,%d2
  1485. 91: putn %d6
  1486. jbra 6b
  1487. 31: putc '\n'
  1488. movel #8+1,%d2
  1489. 32: putc ' '
  1490. dbra %d2,32b
  1491. jbra 3b
  1492. 11: putc '\n'
  1493. jbra 1b
  1494. #endif /* MMU 040 Dumping code that's gory and detailed */
  1495. lea %pc@(kernel_pg_dir),%a5
  1496. movel %a5,%a0 /* a0 has the address of the root table ptr */
  1497. movel #0x00000000,%a4 /* logical address */
  1498. moveql #0,%d0
  1499. 40:
  1500. /* Increment the logical address and preserve in d5 */
  1501. movel %a4,%d5
  1502. addil #PAGESIZE<<13,%d5
  1503. movel %a0@+,%d6
  1504. btst #1,%d6
  1505. jbne 41f
  1506. jbsr mmu_print_tuple_invalidate
  1507. jbra 48f
  1508. 41:
  1509. movel #0,%d1
  1510. andil #0xfffffe00,%d6
  1511. movel %d6,%a1
  1512. 42:
  1513. movel %a4,%d5
  1514. addil #PAGESIZE<<6,%d5
  1515. movel %a1@+,%d6
  1516. btst #1,%d6
  1517. jbne 43f
  1518. jbsr mmu_print_tuple_invalidate
  1519. jbra 47f
  1520. 43:
  1521. movel #0,%d2
  1522. andil #0xffffff00,%d6
  1523. movel %d6,%a2
  1524. 44:
  1525. movel %a4,%d5
  1526. addil #PAGESIZE,%d5
  1527. movel %a2@+,%d6
  1528. btst #0,%d6
  1529. jbne 45f
  1530. jbsr mmu_print_tuple_invalidate
  1531. jbra 46f
  1532. 45:
  1533. moveml %d0-%d1,%sp@-
  1534. movel %a4,%d0
  1535. movel %d6,%d1
  1536. andil #0xfffff4e0,%d1
  1537. lea %pc@(mmu_040_print_flags),%a6
  1538. jbsr mmu_print_tuple
  1539. moveml %sp@+,%d0-%d1
  1540. 46:
  1541. movel %d5,%a4
  1542. addq #1,%d2
  1543. cmpib #64,%d2
  1544. jbne 44b
  1545. 47:
  1546. movel %d5,%a4
  1547. addq #1,%d1
  1548. cmpib #128,%d1
  1549. jbne 42b
  1550. 48:
  1551. movel %d5,%a4 /* move to the next logical address */
  1552. addq #1,%d0
  1553. cmpib #128,%d0
  1554. jbne 40b
  1555. .chip 68040
  1556. movec %dtt1,%d0
  1557. movel %d0,%d1
  1558. andiw #0x8000,%d1 /* is it valid ? */
  1559. jbeq 1f /* No, bail out */
  1560. movel %d0,%d1
  1561. andil #0xff000000,%d1 /* Get the address */
  1562. putn %d1
  1563. puts "=="
  1564. putn %d1
  1565. movel %d0,%d6
  1566. jbsr mmu_040_print_flags_tt
  1567. 1:
  1568. movec %dtt0,%d0
  1569. movel %d0,%d1
  1570. andiw #0x8000,%d1 /* is it valid ? */
  1571. jbeq 1f /* No, bail out */
  1572. movel %d0,%d1
  1573. andil #0xff000000,%d1 /* Get the address */
  1574. putn %d1
  1575. puts "=="
  1576. putn %d1
  1577. movel %d0,%d6
  1578. jbsr mmu_040_print_flags_tt
  1579. 1:
  1580. .chip 68k
  1581. jbra mmu_print_done
  1582. mmu_040_print_flags:
  1583. btstl #10,%d6
  1584. putZc(' ','G') /* global bit */
  1585. btstl #7,%d6
  1586. putZc(' ','S') /* supervisor bit */
  1587. mmu_040_print_flags_tt:
  1588. btstl #6,%d6
  1589. jbne 3f
  1590. putc 'C'
  1591. btstl #5,%d6
  1592. putZc('w','c') /* write through or copy-back */
  1593. jbra 4f
  1594. 3:
  1595. putc 'N'
  1596. btstl #5,%d6
  1597. putZc('s',' ') /* serialized non-cacheable, or non-cacheable */
  1598. 4:
  1599. rts
  1600. mmu_030_print_flags:
  1601. btstl #6,%d6
  1602. putZc('C','I') /* write through or copy-back */
  1603. rts
  1604. mmu_030_print:
  1605. puts "\nMMU030\n"
  1606. puts "\nrp:"
  1607. putn %a5
  1608. putc '\n'
  1609. movel %a5,%d0
  1610. andil #0xfffffff0,%d0
  1611. movel %d0,%a0
  1612. movel #0x00000000,%a4 /* logical address */
  1613. movel #0,%d0
  1614. 30:
  1615. movel %a4,%d5
  1616. addil #PAGESIZE<<13,%d5
  1617. movel %a0@+,%d6
  1618. btst #1,%d6 /* is it a table ptr? */
  1619. jbne 31f /* yes */
  1620. btst #0,%d6 /* is it early terminating? */
  1621. jbeq 1f /* no */
  1622. jbsr mmu_030_print_helper
  1623. jbra 38f
  1624. 1:
  1625. jbsr mmu_print_tuple_invalidate
  1626. jbra 38f
  1627. 31:
  1628. movel #0,%d1
  1629. andil #0xfffffff0,%d6
  1630. movel %d6,%a1
  1631. 32:
  1632. movel %a4,%d5
  1633. addil #PAGESIZE<<6,%d5
  1634. movel %a1@+,%d6
  1635. btst #1,%d6 /* is it a table ptr? */
  1636. jbne 33f /* yes */
  1637. btst #0,%d6 /* is it a page descriptor? */
  1638. jbeq 1f /* no */
  1639. jbsr mmu_030_print_helper
  1640. jbra 37f
  1641. 1:
  1642. jbsr mmu_print_tuple_invalidate
  1643. jbra 37f
  1644. 33:
  1645. movel #0,%d2
  1646. andil #0xfffffff0,%d6
  1647. movel %d6,%a2
  1648. 34:
  1649. movel %a4,%d5
  1650. addil #PAGESIZE,%d5
  1651. movel %a2@+,%d6
  1652. btst #0,%d6
  1653. jbne 35f
  1654. jbsr mmu_print_tuple_invalidate
  1655. jbra 36f
  1656. 35:
  1657. jbsr mmu_030_print_helper
  1658. 36:
  1659. movel %d5,%a4
  1660. addq #1,%d2
  1661. cmpib #64,%d2
  1662. jbne 34b
  1663. 37:
  1664. movel %d5,%a4
  1665. addq #1,%d1
  1666. cmpib #128,%d1
  1667. jbne 32b
  1668. 38:
  1669. movel %d5,%a4 /* move to the next logical address */
  1670. addq #1,%d0
  1671. cmpib #128,%d0
  1672. jbne 30b
  1673. mmu_print_done:
  1674. puts "\n\n"
  1675. func_return mmu_print
  1676. mmu_030_print_helper:
  1677. moveml %d0-%d1,%sp@-
  1678. movel %a4,%d0
  1679. movel %d6,%d1
  1680. lea %pc@(mmu_030_print_flags),%a6
  1681. jbsr mmu_print_tuple
  1682. moveml %sp@+,%d0-%d1
  1683. rts
  1684. mmu_print_tuple_invalidate:
  1685. moveml %a0/%d7,%sp@-
  1686. lea %pc@(L(mmu_print_data)),%a0
  1687. tstl %a0@(mmu_next_valid)
  1688. jbmi mmu_print_tuple_invalidate_exit
  1689. movel #MMU_PRINT_INVALID,%a0@(mmu_next_valid)
  1690. putn %a4
  1691. puts "##\n"
  1692. mmu_print_tuple_invalidate_exit:
  1693. moveml %sp@+,%a0/%d7
  1694. rts
  1695. mmu_print_tuple:
  1696. moveml %d0-%d7/%a0,%sp@-
  1697. lea %pc@(L(mmu_print_data)),%a0
  1698. tstl %a0@(mmu_next_valid)
  1699. jble mmu_print_tuple_print
  1700. cmpl %a0@(mmu_next_physical),%d1
  1701. jbeq mmu_print_tuple_increment
  1702. mmu_print_tuple_print:
  1703. putn %d0
  1704. puts "->"
  1705. putn %d1
  1706. movel %d1,%d6
  1707. jbsr %a6@
  1708. mmu_print_tuple_record:
  1709. movel #MMU_PRINT_VALID,%a0@(mmu_next_valid)
  1710. movel %d1,%a0@(mmu_next_physical)
  1711. mmu_print_tuple_increment:
  1712. movel %d5,%d7
  1713. subl %a4,%d7
  1714. addl %d7,%a0@(mmu_next_physical)
  1715. mmu_print_tuple_exit:
  1716. moveml %sp@+,%d0-%d7/%a0
  1717. rts
  1718. mmu_print_machine_cpu_types:
  1719. puts "machine: "
  1720. is_not_amiga(1f)
  1721. puts "amiga"
  1722. jbra 9f
  1723. 1:
  1724. is_not_atari(2f)
  1725. puts "atari"
  1726. jbra 9f
  1727. 2:
  1728. is_not_mac(3f)
  1729. puts "macintosh"
  1730. jbra 9f
  1731. 3: puts "unknown"
  1732. 9: putc '\n'
  1733. puts "cputype: 0"
  1734. is_not_060(1f)
  1735. putc '6'
  1736. jbra 9f
  1737. 1:
  1738. is_not_040_or_060(2f)
  1739. putc '4'
  1740. jbra 9f
  1741. 2: putc '3'
  1742. 9: putc '0'
  1743. putc '\n'
  1744. rts
  1745. #endif /* MMU_PRINT */
  1746. /*
  1747. * mmu_map_tt
  1748. *
  1749. * This is a specific function which works on all 680x0 machines.
  1750. * On 030, 040 & 060 it will attempt to use Transparent Translation
  1751. * registers (tt1).
  1752. * On 020 it will call the standard mmu_map which will use early
  1753. * terminating descriptors.
  1754. */
  1755. func_start mmu_map_tt,%d0/%d1/%a0,4
  1756. dputs "mmu_map_tt:"
  1757. dputn ARG1
  1758. dputn ARG2
  1759. dputn ARG3
  1760. dputn ARG4
  1761. dputc '\n'
  1762. is_020(L(do_map))
  1763. /* Extract the highest bit set
  1764. */
  1765. bfffo ARG3{#0,#32},%d1
  1766. cmpw #8,%d1
  1767. jcc L(do_map)
  1768. /* And get the mask
  1769. */
  1770. moveq #-1,%d0
  1771. lsrl %d1,%d0
  1772. lsrl #1,%d0
  1773. /* Mask the address
  1774. */
  1775. movel %d0,%d1
  1776. notl %d1
  1777. andl ARG2,%d1
  1778. /* Generate the upper 16bit of the tt register
  1779. */
  1780. lsrl #8,%d0
  1781. orl %d0,%d1
  1782. clrw %d1
  1783. is_040_or_060(L(mmu_map_tt_040))
  1784. /* set 030 specific bits (read/write access for supervisor mode
  1785. * (highest function code set, lower two bits masked))
  1786. */
  1787. orw #TTR_ENABLE+TTR_RWM+TTR_FCB2+TTR_FCM1+TTR_FCM0,%d1
  1788. movel ARG4,%d0
  1789. btst #6,%d0
  1790. jeq 1f
  1791. orw #TTR_CI,%d1
  1792. 1: lea STACK,%a0
  1793. dputn %d1
  1794. movel %d1,%a0@
  1795. .chip 68030
  1796. tstl ARG1
  1797. jne 1f
  1798. pmove %a0@,%tt0
  1799. jra 2f
  1800. 1: pmove %a0@,%tt1
  1801. 2: .chip 68k
  1802. jra L(mmu_map_tt_done)
  1803. /* set 040 specific bits
  1804. */
  1805. L(mmu_map_tt_040):
  1806. orw #TTR_ENABLE+TTR_KERNELMODE,%d1
  1807. orl ARG4,%d1
  1808. dputn %d1
  1809. .chip 68040
  1810. tstl ARG1
  1811. jne 1f
  1812. movec %d1,%itt0
  1813. movec %d1,%dtt0
  1814. jra 2f
  1815. 1: movec %d1,%itt1
  1816. movec %d1,%dtt1
  1817. 2: .chip 68k
  1818. jra L(mmu_map_tt_done)
  1819. L(do_map):
  1820. mmu_map_eq ARG2,ARG3,ARG4
  1821. L(mmu_map_tt_done):
  1822. func_return mmu_map_tt
  1823. /*
  1824. * mmu_map
  1825. *
  1826. * This routine will map a range of memory using a pointer
  1827. * table and allocating the pages on the fly from the kernel.
  1828. * The pointer table does not have to be already linked into
  1829. * the root table, this routine will do that if necessary.
  1830. *
  1831. * NOTE
  1832. * This routine will assert failure and use the serial_putc
  1833. * routines in the case of a run-time error. For example,
  1834. * if the address is already mapped.
  1835. *
  1836. * NOTE-2
  1837. * This routine will use early terminating descriptors
  1838. * where possible for the 68020+68851 and 68030 type
  1839. * processors.
  1840. */
  1841. func_start mmu_map,%d0-%d4/%a0-%a4
  1842. dputs "\nmmu_map:"
  1843. dputn ARG1
  1844. dputn ARG2
  1845. dputn ARG3
  1846. dputn ARG4
  1847. dputc '\n'
  1848. /* Get logical address and round it down to 256KB
  1849. */
  1850. movel ARG1,%d0
  1851. andl #-(PAGESIZE*PAGE_TABLE_SIZE),%d0
  1852. movel %d0,%a3
  1853. /* Get the end address
  1854. */
  1855. movel ARG1,%a4
  1856. addl ARG3,%a4
  1857. subql #1,%a4
  1858. /* Get physical address and round it down to 256KB
  1859. */
  1860. movel ARG2,%d0
  1861. andl #-(PAGESIZE*PAGE_TABLE_SIZE),%d0
  1862. movel %d0,%a2
  1863. /* Add page attributes to the physical address
  1864. */
  1865. movel ARG4,%d0
  1866. orw #_PAGE_PRESENT+_PAGE_ACCESSED+_PAGE_DIRTY,%d0
  1867. addw %d0,%a2
  1868. dputn %a2
  1869. dputn %a3
  1870. dputn %a4
  1871. is_not_040_or_060(L(mmu_map_030))
  1872. addw #_PAGE_GLOBAL040,%a2
  1873. /*
  1874. * MMU 040 & 060 Support
  1875. *
  1876. * The MMU usage for the 040 and 060 is different enough from
  1877. * the 030 and 68851 that there is separate code. This comment
  1878. * block describes the data structures and algorithms built by
  1879. * this code.
  1880. *
  1881. * The 040 does not support early terminating descriptors, as
  1882. * the 030 does. Therefore, a third level of table is needed
  1883. * for the 040, and that would be the page table. In Linux,
  1884. * page tables are allocated directly from the memory above the
  1885. * kernel.
  1886. *
  1887. */
  1888. L(mmu_map_040):
  1889. /* Calculate the offset into the root table
  1890. */
  1891. movel %a3,%d0
  1892. moveq #ROOT_INDEX_SHIFT,%d1
  1893. lsrl %d1,%d0
  1894. mmu_get_root_table_entry %d0
  1895. /* Calculate the offset into the pointer table
  1896. */
  1897. movel %a3,%d0
  1898. moveq #PTR_INDEX_SHIFT,%d1
  1899. lsrl %d1,%d0
  1900. andl #PTR_TABLE_SIZE-1,%d0
  1901. mmu_get_ptr_table_entry %a0,%d0
  1902. /* Calculate the offset into the page table
  1903. */
  1904. movel %a3,%d0
  1905. moveq #PAGE_INDEX_SHIFT,%d1
  1906. lsrl %d1,%d0
  1907. andl #PAGE_TABLE_SIZE-1,%d0
  1908. mmu_get_page_table_entry %a0,%d0
  1909. /* The page table entry must not no be busy
  1910. */
  1911. tstl %a0@
  1912. jne L(mmu_map_error)
  1913. /* Do the mapping and advance the pointers
  1914. */
  1915. movel %a2,%a0@
  1916. 2:
  1917. addw #PAGESIZE,%a2
  1918. addw #PAGESIZE,%a3
  1919. /* Ready with mapping?
  1920. */
  1921. lea %a3@(-1),%a0
  1922. cmpl %a0,%a4
  1923. jhi L(mmu_map_040)
  1924. jra L(mmu_map_done)
  1925. L(mmu_map_030):
  1926. /* Calculate the offset into the root table
  1927. */
  1928. movel %a3,%d0
  1929. moveq #ROOT_INDEX_SHIFT,%d1
  1930. lsrl %d1,%d0
  1931. mmu_get_root_table_entry %d0
  1932. /* Check if logical address 32MB aligned,
  1933. * so we can try to map it once
  1934. */
  1935. movel %a3,%d0
  1936. andl #(PTR_TABLE_SIZE*PAGE_TABLE_SIZE*PAGESIZE-1)&(-ROOT_TABLE_SIZE),%d0
  1937. jne 1f
  1938. /* Is there enough to map for 32MB at once
  1939. */
  1940. lea %a3@(PTR_TABLE_SIZE*PAGE_TABLE_SIZE*PAGESIZE-1),%a1
  1941. cmpl %a1,%a4
  1942. jcs 1f
  1943. addql #1,%a1
  1944. /* The root table entry must not no be busy
  1945. */
  1946. tstl %a0@
  1947. jne L(mmu_map_error)
  1948. /* Do the mapping and advance the pointers
  1949. */
  1950. dputs "early term1"
  1951. dputn %a2
  1952. dputn %a3
  1953. dputn %a1
  1954. dputc '\n'
  1955. movel %a2,%a0@
  1956. movel %a1,%a3
  1957. lea %a2@(PTR_TABLE_SIZE*PAGE_TABLE_SIZE*PAGESIZE),%a2
  1958. jra L(mmu_mapnext_030)
  1959. 1:
  1960. /* Calculate the offset into the pointer table
  1961. */
  1962. movel %a3,%d0
  1963. moveq #PTR_INDEX_SHIFT,%d1
  1964. lsrl %d1,%d0
  1965. andl #PTR_TABLE_SIZE-1,%d0
  1966. mmu_get_ptr_table_entry %a0,%d0
  1967. /* The pointer table entry must not no be busy
  1968. */
  1969. tstl %a0@
  1970. jne L(mmu_map_error)
  1971. /* Do the mapping and advance the pointers
  1972. */
  1973. dputs "early term2"
  1974. dputn %a2
  1975. dputn %a3
  1976. dputc '\n'
  1977. movel %a2,%a0@
  1978. addl #PAGE_TABLE_SIZE*PAGESIZE,%a2
  1979. addl #PAGE_TABLE_SIZE*PAGESIZE,%a3
  1980. L(mmu_mapnext_030):
  1981. /* Ready with mapping?
  1982. */
  1983. lea %a3@(-1),%a0
  1984. cmpl %a0,%a4
  1985. jhi L(mmu_map_030)
  1986. jra L(mmu_map_done)
  1987. L(mmu_map_error):
  1988. dputs "mmu_map error:"
  1989. dputn %a2
  1990. dputn %a3
  1991. dputc '\n'
  1992. L(mmu_map_done):
  1993. func_return mmu_map
  1994. /*
  1995. * mmu_fixup
  1996. *
  1997. * On the 040 class machines, all pages that are used for the
  1998. * mmu have to be fixed up.
  1999. */
  2000. func_start mmu_fixup_page_mmu_cache,%d0/%a0
  2001. dputs "mmu_fixup_page_mmu_cache"
  2002. dputn ARG1
  2003. /* Calculate the offset into the root table
  2004. */
  2005. movel ARG1,%d0
  2006. moveq #ROOT_INDEX_SHIFT,%d1
  2007. lsrl %d1,%d0
  2008. mmu_get_root_table_entry %d0
  2009. /* Calculate the offset into the pointer table
  2010. */
  2011. movel ARG1,%d0
  2012. moveq #PTR_INDEX_SHIFT,%d1
  2013. lsrl %d1,%d0
  2014. andl #PTR_TABLE_SIZE-1,%d0
  2015. mmu_get_ptr_table_entry %a0,%d0
  2016. /* Calculate the offset into the page table
  2017. */
  2018. movel ARG1,%d0
  2019. moveq #PAGE_INDEX_SHIFT,%d1
  2020. lsrl %d1,%d0
  2021. andl #PAGE_TABLE_SIZE-1,%d0
  2022. mmu_get_page_table_entry %a0,%d0
  2023. movel %a0@,%d0
  2024. andil #_CACHEMASK040,%d0
  2025. orl %pc@(m68k_pgtable_cachemode),%d0
  2026. movel %d0,%a0@
  2027. dputc '\n'
  2028. func_return mmu_fixup_page_mmu_cache
  2029. /*
  2030. * mmu_temp_map
  2031. *
  2032. * create a temporary mapping to enable the mmu,
  2033. * this we don't need any transparation translation tricks.
  2034. */
  2035. func_start mmu_temp_map,%d0/%d1/%a0/%a1
  2036. dputs "mmu_temp_map"
  2037. dputn ARG1
  2038. dputn ARG2
  2039. dputc '\n'
  2040. lea %pc@(L(temp_mmap_mem)),%a1
  2041. /* Calculate the offset in the root table
  2042. */
  2043. movel ARG2,%d0
  2044. moveq #ROOT_INDEX_SHIFT,%d1
  2045. lsrl %d1,%d0
  2046. mmu_get_root_table_entry %d0
  2047. /* Check if the table is temporary allocated, so we have to reuse it
  2048. */
  2049. movel %a0@,%d0
  2050. cmpl %pc@(L(memory_start)),%d0
  2051. jcc 1f
  2052. /* Temporary allocate a ptr table and insert it into the root table
  2053. */
  2054. movel %a1@,%d0
  2055. addl #PTR_TABLE_SIZE*4,%a1@
  2056. orw #_PAGE_TABLE+_PAGE_ACCESSED,%d0
  2057. movel %d0,%a0@
  2058. dputs " (new)"
  2059. 1:
  2060. dputn %d0
  2061. /* Mask the root table entry for the ptr table
  2062. */
  2063. andw #-ROOT_TABLE_SIZE,%d0
  2064. movel %d0,%a0
  2065. /* Calculate the offset into the pointer table
  2066. */
  2067. movel ARG2,%d0
  2068. moveq #PTR_INDEX_SHIFT,%d1
  2069. lsrl %d1,%d0
  2070. andl #PTR_TABLE_SIZE-1,%d0
  2071. lea %a0@(%d0*4),%a0
  2072. dputn %a0
  2073. /* Check if a temporary page table is already allocated
  2074. */
  2075. movel %a0@,%d0
  2076. jne 1f
  2077. /* Temporary allocate a page table and insert it into the ptr table
  2078. */
  2079. movel %a1@,%d0
  2080. /* The 512 should be PAGE_TABLE_SIZE*4, but that violates the
  2081. alignment restriction for pointer tables on the '0[46]0. */
  2082. addl #512,%a1@
  2083. orw #_PAGE_TABLE+_PAGE_ACCESSED,%d0
  2084. movel %d0,%a0@
  2085. dputs " (new)"
  2086. 1:
  2087. dputn %d0
  2088. /* Mask the ptr table entry for the page table
  2089. */
  2090. andw #-PTR_TABLE_SIZE,%d0
  2091. movel %d0,%a0
  2092. /* Calculate the offset into the page table
  2093. */
  2094. movel ARG2,%d0
  2095. moveq #PAGE_INDEX_SHIFT,%d1
  2096. lsrl %d1,%d0
  2097. andl #PAGE_TABLE_SIZE-1,%d0
  2098. lea %a0@(%d0*4),%a0
  2099. dputn %a0
  2100. /* Insert the address into the page table
  2101. */
  2102. movel ARG1,%d0
  2103. andw #-PAGESIZE,%d0
  2104. orw #_PAGE_PRESENT+_PAGE_ACCESSED+_PAGE_DIRTY,%d0
  2105. movel %d0,%a0@
  2106. dputn %d0
  2107. dputc '\n'
  2108. func_return mmu_temp_map
  2109. func_start mmu_engage,%d0-%d2/%a0-%a3
  2110. moveq #ROOT_TABLE_SIZE-1,%d0
  2111. /* Temporarily use a different root table. */
  2112. lea %pc@(L(kernel_pgdir_ptr)),%a0
  2113. movel %a0@,%a2
  2114. movel %pc@(L(memory_start)),%a1
  2115. movel %a1,%a0@
  2116. movel %a2,%a0
  2117. 1:
  2118. movel %a0@+,%a1@+
  2119. dbra %d0,1b
  2120. lea %pc@(L(temp_mmap_mem)),%a0
  2121. movel %a1,%a0@
  2122. movew #PAGESIZE-1,%d0
  2123. 1:
  2124. clrl %a1@+
  2125. dbra %d0,1b
  2126. lea %pc@(1b),%a0
  2127. movel #1b,%a1
  2128. /* Skip temp mappings if phys == virt */
  2129. cmpl %a0,%a1
  2130. jeq 1f
  2131. mmu_temp_map %a0,%a0
  2132. mmu_temp_map %a0,%a1
  2133. addw #PAGESIZE,%a0
  2134. addw #PAGESIZE,%a1
  2135. mmu_temp_map %a0,%a0
  2136. mmu_temp_map %a0,%a1
  2137. 1:
  2138. movel %pc@(L(memory_start)),%a3
  2139. movel %pc@(L(phys_kernel_start)),%d2
  2140. is_not_040_or_060(L(mmu_engage_030))
  2141. L(mmu_engage_040):
  2142. .chip 68040
  2143. nop
  2144. cinva %bc
  2145. nop
  2146. pflusha
  2147. nop
  2148. movec %a3,%srp
  2149. movel #TC_ENABLE+TC_PAGE4K,%d0
  2150. movec %d0,%tc /* enable the MMU */
  2151. jmp 1f:l
  2152. 1: nop
  2153. movec %a2,%srp
  2154. nop
  2155. cinva %bc
  2156. nop
  2157. pflusha
  2158. .chip 68k
  2159. jra L(mmu_engage_cleanup)
  2160. L(mmu_engage_030_temp):
  2161. .space 12
  2162. L(mmu_engage_030):
  2163. .chip 68030
  2164. lea %pc@(L(mmu_engage_030_temp)),%a0
  2165. movel #0x80000002,%a0@
  2166. movel %a3,%a0@(4)
  2167. movel #0x0808,%d0
  2168. movec %d0,%cacr
  2169. pmove %a0@,%srp
  2170. pflusha
  2171. /*
  2172. * enable,super root enable,4096 byte pages,7 bit root index,
  2173. * 7 bit pointer index, 6 bit page table index.
  2174. */
  2175. movel #0x82c07760,%a0@(8)
  2176. pmove %a0@(8),%tc /* enable the MMU */
  2177. jmp 1f:l
  2178. 1: movel %a2,%a0@(4)
  2179. movel #0x0808,%d0
  2180. movec %d0,%cacr
  2181. pmove %a0@,%srp
  2182. pflusha
  2183. .chip 68k
  2184. L(mmu_engage_cleanup):
  2185. subl #PAGE_OFFSET,%d2
  2186. subl %d2,%a2
  2187. movel %a2,L(kernel_pgdir_ptr)
  2188. subl %d2,%fp
  2189. subl %d2,%sp
  2190. subl %d2,ARG0
  2191. func_return mmu_engage
  2192. func_start mmu_get_root_table_entry,%d0/%a1
  2193. #if 0
  2194. dputs "mmu_get_root_table_entry:"
  2195. dputn ARG1
  2196. dputs " ="
  2197. #endif
  2198. movel %pc@(L(kernel_pgdir_ptr)),%a0
  2199. tstl %a0
  2200. jne 2f
  2201. dputs "\nmmu_init:"
  2202. /* Find the start of free memory, get_bi_record does this for us,
  2203. * as the bootinfo structure is located directly behind the kernel
  2204. * and and we simply search for the last entry.
  2205. */
  2206. get_bi_record BI_LAST
  2207. addw #PAGESIZE-1,%a0
  2208. movel %a0,%d0
  2209. andw #-PAGESIZE,%d0
  2210. dputn %d0
  2211. lea %pc@(L(memory_start)),%a0
  2212. movel %d0,%a0@
  2213. lea %pc@(L(kernel_end)),%a0
  2214. movel %d0,%a0@
  2215. /* we have to return the first page at _stext since the init code
  2216. * in mm/init.c simply expects kernel_pg_dir there, the rest of
  2217. * page is used for further ptr tables in get_ptr_table.
  2218. */
  2219. lea %pc@(_stext),%a0
  2220. lea %pc@(L(mmu_cached_pointer_tables)),%a1
  2221. movel %a0,%a1@
  2222. addl #ROOT_TABLE_SIZE*4,%a1@
  2223. lea %pc@(L(mmu_num_pointer_tables)),%a1
  2224. addql #1,%a1@
  2225. /* clear the page
  2226. */
  2227. movel %a0,%a1
  2228. movew #PAGESIZE/4-1,%d0
  2229. 1:
  2230. clrl %a1@+
  2231. dbra %d0,1b
  2232. lea %pc@(L(kernel_pgdir_ptr)),%a1
  2233. movel %a0,%a1@
  2234. dputn %a0
  2235. dputc '\n'
  2236. 2:
  2237. movel ARG1,%d0
  2238. lea %a0@(%d0*4),%a0
  2239. #if 0
  2240. dputn %a0
  2241. dputc '\n'
  2242. #endif
  2243. func_return mmu_get_root_table_entry
  2244. func_start mmu_get_ptr_table_entry,%d0/%a1
  2245. #if 0
  2246. dputs "mmu_get_ptr_table_entry:"
  2247. dputn ARG1
  2248. dputn ARG2
  2249. dputs " ="
  2250. #endif
  2251. movel ARG1,%a0
  2252. movel %a0@,%d0
  2253. jne 2f
  2254. /* Keep track of the number of pointer tables we use
  2255. */
  2256. dputs "\nmmu_get_new_ptr_table:"
  2257. lea %pc@(L(mmu_num_pointer_tables)),%a0
  2258. movel %a0@,%d0
  2259. addql #1,%a0@
  2260. /* See if there is a free pointer table in our cache of pointer tables
  2261. */
  2262. lea %pc@(L(mmu_cached_pointer_tables)),%a1
  2263. andw #7,%d0
  2264. jne 1f
  2265. /* Get a new pointer table page from above the kernel memory
  2266. */
  2267. get_new_page
  2268. movel %a0,%a1@
  2269. 1:
  2270. /* There is an unused pointer table in our cache... use it
  2271. */
  2272. movel %a1@,%d0
  2273. addl #PTR_TABLE_SIZE*4,%a1@
  2274. dputn %d0
  2275. dputc '\n'
  2276. /* Insert the new pointer table into the root table
  2277. */
  2278. movel ARG1,%a0
  2279. orw #_PAGE_TABLE+_PAGE_ACCESSED,%d0
  2280. movel %d0,%a0@
  2281. 2:
  2282. /* Extract the pointer table entry
  2283. */
  2284. andw #-PTR_TABLE_SIZE,%d0
  2285. movel %d0,%a0
  2286. movel ARG2,%d0
  2287. lea %a0@(%d0*4),%a0
  2288. #if 0
  2289. dputn %a0
  2290. dputc '\n'
  2291. #endif
  2292. func_return mmu_get_ptr_table_entry
  2293. func_start mmu_get_page_table_entry,%d0/%a1
  2294. #if 0
  2295. dputs "mmu_get_page_table_entry:"
  2296. dputn ARG1
  2297. dputn ARG2
  2298. dputs " ="
  2299. #endif
  2300. movel ARG1,%a0
  2301. movel %a0@,%d0
  2302. jne 2f
  2303. /* If the page table entry doesn't exist, we allocate a complete new
  2304. * page and use it as one continues big page table which can cover
  2305. * 4MB of memory, nearly almost all mappings have that alignment.
  2306. */
  2307. get_new_page
  2308. addw #_PAGE_TABLE+_PAGE_ACCESSED,%a0
  2309. /* align pointer table entry for a page of page tables
  2310. */
  2311. movel ARG1,%d0
  2312. andw #-(PAGESIZE/PAGE_TABLE_SIZE),%d0
  2313. movel %d0,%a1
  2314. /* Insert the page tables into the pointer entries
  2315. */
  2316. moveq #PAGESIZE/PAGE_TABLE_SIZE/4-1,%d0
  2317. 1:
  2318. movel %a0,%a1@+
  2319. lea %a0@(PAGE_TABLE_SIZE*4),%a0
  2320. dbra %d0,1b
  2321. /* Now we can get the initialized pointer table entry
  2322. */
  2323. movel ARG1,%a0
  2324. movel %a0@,%d0
  2325. 2:
  2326. /* Extract the page table entry
  2327. */
  2328. andw #-PAGE_TABLE_SIZE,%d0
  2329. movel %d0,%a0
  2330. movel ARG2,%d0
  2331. lea %a0@(%d0*4),%a0
  2332. #if 0
  2333. dputn %a0
  2334. dputc '\n'
  2335. #endif
  2336. func_return mmu_get_page_table_entry
  2337. /*
  2338. * get_new_page
  2339. *
  2340. * Return a new page from the memory start and clear it.
  2341. */
  2342. func_start get_new_page,%d0/%a1
  2343. dputs "\nget_new_page:"
  2344. /* allocate the page and adjust memory_start
  2345. */
  2346. lea %pc@(L(memory_start)),%a0
  2347. movel %a0@,%a1
  2348. addl #PAGESIZE,%a0@
  2349. /* clear the new page
  2350. */
  2351. movel %a1,%a0
  2352. movew #PAGESIZE/4-1,%d0
  2353. 1:
  2354. clrl %a1@+
  2355. dbra %d0,1b
  2356. dputn %a0
  2357. dputc '\n'
  2358. func_return get_new_page
  2359. /*
  2360. * Debug output support
  2361. * Atarians have a choice between the parallel port, the serial port
  2362. * from the MFP or a serial port of the SCC
  2363. */
  2364. #ifdef CONFIG_MAC
  2365. L(scc_initable_mac):
  2366. .byte 9,12 /* Reset */
  2367. .byte 4,0x44 /* x16, 1 stopbit, no parity */
  2368. .byte 3,0xc0 /* receiver: 8 bpc */
  2369. .byte 5,0xe2 /* transmitter: 8 bpc, assert dtr/rts */
  2370. .byte 9,0 /* no interrupts */
  2371. .byte 10,0 /* NRZ */
  2372. .byte 11,0x50 /* use baud rate generator */
  2373. .byte 12,10,13,0 /* 9600 baud */
  2374. .byte 14,1 /* Baud rate generator enable */
  2375. .byte 3,0xc1 /* enable receiver */
  2376. .byte 5,0xea /* enable transmitter */
  2377. .byte -1
  2378. .even
  2379. #endif
  2380. #ifdef CONFIG_ATARI
  2381. /* #define USE_PRINTER */
  2382. /* #define USE_SCC_B */
  2383. /* #define USE_SCC_A */
  2384. #define USE_MFP
  2385. #if defined(USE_SCC_A) || defined(USE_SCC_B)
  2386. #define USE_SCC
  2387. /* Initialisation table for SCC */
  2388. L(scc_initable):
  2389. .byte 9,12 /* Reset */
  2390. .byte 4,0x44 /* x16, 1 stopbit, no parity */
  2391. .byte 3,0xc0 /* receiver: 8 bpc */
  2392. .byte 5,0xe2 /* transmitter: 8 bpc, assert dtr/rts */
  2393. .byte 9,0 /* no interrupts */
  2394. .byte 10,0 /* NRZ */
  2395. .byte 11,0x50 /* use baud rate generator */
  2396. .byte 12,24,13,0 /* 9600 baud */
  2397. .byte 14,2,14,3 /* use master clock for BRG, enable */
  2398. .byte 3,0xc1 /* enable receiver */
  2399. .byte 5,0xea /* enable transmitter */
  2400. .byte -1
  2401. .even
  2402. #endif
  2403. #ifdef USE_PRINTER
  2404. LPSG_SELECT = 0xff8800
  2405. LPSG_READ = 0xff8800
  2406. LPSG_WRITE = 0xff8802
  2407. LPSG_IO_A = 14
  2408. LPSG_IO_B = 15
  2409. LPSG_CONTROL = 7
  2410. LSTMFP_GPIP = 0xfffa01
  2411. LSTMFP_DDR = 0xfffa05
  2412. LSTMFP_IERB = 0xfffa09
  2413. #elif defined(USE_SCC_B)
  2414. LSCC_CTRL = 0xff8c85
  2415. LSCC_DATA = 0xff8c87
  2416. #elif defined(USE_SCC_A)
  2417. LSCC_CTRL = 0xff8c81
  2418. LSCC_DATA = 0xff8c83
  2419. #elif defined(USE_MFP)
  2420. LMFP_UCR = 0xfffa29
  2421. LMFP_TDCDR = 0xfffa1d
  2422. LMFP_TDDR = 0xfffa25
  2423. LMFP_TSR = 0xfffa2d
  2424. LMFP_UDR = 0xfffa2f
  2425. #endif
  2426. #endif /* CONFIG_ATARI */
  2427. /*
  2428. * Serial port output support.
  2429. */
  2430. /*
  2431. * Initialize serial port hardware for 9600/8/1
  2432. */
  2433. func_start serial_init,%d0/%d1/%a0/%a1
  2434. /*
  2435. * Some of the register usage that follows
  2436. * CONFIG_AMIGA
  2437. * a0 = pointer to boot info record
  2438. * d0 = boot info offset
  2439. * CONFIG_ATARI
  2440. * a0 = address of SCC
  2441. * a1 = Liobase address/address of scc_initable
  2442. * d0 = init data for serial port
  2443. * CONFIG_MAC
  2444. * a0 = address of SCC
  2445. * a1 = address of scc_initable_mac
  2446. * d0 = init data for serial port
  2447. */
  2448. #ifdef CONFIG_AMIGA
  2449. #define SERIAL_DTR 7
  2450. #define SERIAL_CNTRL CIABBASE+C_PRA
  2451. is_not_amiga(1f)
  2452. lea %pc@(L(custom)),%a0
  2453. movel #-ZTWOBASE,%a0@
  2454. bclr #SERIAL_DTR,SERIAL_CNTRL-ZTWOBASE
  2455. get_bi_record BI_AMIGA_SERPER
  2456. movew %a0@,CUSTOMBASE+C_SERPER-ZTWOBASE
  2457. | movew #61,CUSTOMBASE+C_SERPER-ZTWOBASE
  2458. 1:
  2459. #endif
  2460. #ifdef CONFIG_ATARI
  2461. is_not_atari(4f)
  2462. movel %pc@(L(iobase)),%a1
  2463. #if defined(USE_PRINTER)
  2464. bclr #0,%a1@(LSTMFP_IERB)
  2465. bclr #0,%a1@(LSTMFP_DDR)
  2466. moveb #LPSG_CONTROL,%a1@(LPSG_SELECT)
  2467. moveb #0xff,%a1@(LPSG_WRITE)
  2468. moveb #LPSG_IO_B,%a1@(LPSG_SELECT)
  2469. clrb %a1@(LPSG_WRITE)
  2470. moveb #LPSG_IO_A,%a1@(LPSG_SELECT)
  2471. moveb %a1@(LPSG_READ),%d0
  2472. bset #5,%d0
  2473. moveb %d0,%a1@(LPSG_WRITE)
  2474. #elif defined(USE_SCC)
  2475. lea %a1@(LSCC_CTRL),%a0
  2476. lea %pc@(L(scc_initable)),%a1
  2477. 2: moveb %a1@+,%d0
  2478. jmi 3f
  2479. moveb %d0,%a0@
  2480. moveb %a1@+,%a0@
  2481. jra 2b
  2482. 3: clrb %a0@
  2483. #elif defined(USE_MFP)
  2484. bclr #1,%a1@(LMFP_TSR)
  2485. moveb #0x88,%a1@(LMFP_UCR)
  2486. andb #0x70,%a1@(LMFP_TDCDR)
  2487. moveb #2,%a1@(LMFP_TDDR)
  2488. orb #1,%a1@(LMFP_TDCDR)
  2489. bset #1,%a1@(LMFP_TSR)
  2490. #endif
  2491. jra L(serial_init_done)
  2492. 4:
  2493. #endif
  2494. #ifdef CONFIG_MAC
  2495. is_not_mac(L(serial_init_not_mac))
  2496. #ifdef MAC_SERIAL_DEBUG
  2497. #if !defined(MAC_USE_SCC_A) && !defined(MAC_USE_SCC_B)
  2498. #define MAC_USE_SCC_B
  2499. #endif
  2500. #define mac_scc_cha_b_ctrl_offset 0x0
  2501. #define mac_scc_cha_a_ctrl_offset 0x2
  2502. #define mac_scc_cha_b_data_offset 0x4
  2503. #define mac_scc_cha_a_data_offset 0x6
  2504. #ifdef MAC_USE_SCC_A
  2505. /* Initialize channel A */
  2506. movel %pc@(L(mac_sccbase)),%a0
  2507. lea %pc@(L(scc_initable_mac)),%a1
  2508. 5: moveb %a1@+,%d0
  2509. jmi 6f
  2510. moveb %d0,%a0@(mac_scc_cha_a_ctrl_offset)
  2511. moveb %a1@+,%a0@(mac_scc_cha_a_ctrl_offset)
  2512. jra 5b
  2513. 6:
  2514. #endif /* MAC_USE_SCC_A */
  2515. #ifdef MAC_USE_SCC_B
  2516. /* Initialize channel B */
  2517. #ifndef MAC_USE_SCC_A /* Load mac_sccbase only if needed */
  2518. movel %pc@(L(mac_sccbase)),%a0
  2519. #endif /* MAC_USE_SCC_A */
  2520. lea %pc@(L(scc_initable_mac)),%a1
  2521. 7: moveb %a1@+,%d0
  2522. jmi 8f
  2523. moveb %d0,%a0@(mac_scc_cha_b_ctrl_offset)
  2524. moveb %a1@+,%a0@(mac_scc_cha_b_ctrl_offset)
  2525. jra 7b
  2526. 8:
  2527. #endif /* MAC_USE_SCC_B */
  2528. #endif /* MAC_SERIAL_DEBUG */
  2529. jra L(serial_init_done)
  2530. L(serial_init_not_mac):
  2531. #endif /* CONFIG_MAC */
  2532. #ifdef CONFIG_Q40
  2533. is_not_q40(2f)
  2534. /* debug output goes into SRAM, so we don't do it unless requested
  2535. - check for '%LX$' signature in SRAM */
  2536. lea %pc@(q40_mem_cptr),%a1
  2537. move.l #0xff020010,%a1@ /* must be inited - also used by debug=mem */
  2538. move.l #0xff020000,%a1
  2539. cmp.b #'%',%a1@
  2540. bne 2f /*nodbg*/
  2541. addq.w #4,%a1
  2542. cmp.b #'L',%a1@
  2543. bne 2f /*nodbg*/
  2544. addq.w #4,%a1
  2545. cmp.b #'X',%a1@
  2546. bne 2f /*nodbg*/
  2547. addq.w #4,%a1
  2548. cmp.b #'$',%a1@
  2549. bne 2f /*nodbg*/
  2550. /* signature OK */
  2551. lea %pc@(L(q40_do_debug)),%a1
  2552. tas %a1@
  2553. /*nodbg: q40_do_debug is 0 by default*/
  2554. 2:
  2555. #endif
  2556. #ifdef CONFIG_APOLLO
  2557. /* We count on the PROM initializing SIO1 */
  2558. #endif
  2559. #ifdef CONFIG_HP300
  2560. /* We count on the boot loader initialising the UART */
  2561. #endif
  2562. L(serial_init_done):
  2563. func_return serial_init
  2564. /*
  2565. * Output character on serial port.
  2566. */
  2567. func_start serial_putc,%d0/%d1/%a0/%a1
  2568. movel ARG1,%d0
  2569. cmpib #'\n',%d0
  2570. jbne 1f
  2571. /* A little safe recursion is good for the soul */
  2572. serial_putc #'\r'
  2573. 1:
  2574. #ifdef CONFIG_AMIGA
  2575. is_not_amiga(2f)
  2576. andw #0x00ff,%d0
  2577. oriw #0x0100,%d0
  2578. movel %pc@(L(custom)),%a0
  2579. movew %d0,%a0@(CUSTOMBASE+C_SERDAT)
  2580. 1: movew %a0@(CUSTOMBASE+C_SERDATR),%d0
  2581. andw #0x2000,%d0
  2582. jeq 1b
  2583. jra L(serial_putc_done)
  2584. 2:
  2585. #endif
  2586. #ifdef CONFIG_MAC
  2587. is_not_mac(5f)
  2588. #ifdef MAC_SERIAL_DEBUG
  2589. #ifdef MAC_USE_SCC_A
  2590. movel %pc@(L(mac_sccbase)),%a1
  2591. 3: btst #2,%a1@(mac_scc_cha_a_ctrl_offset)
  2592. jeq 3b
  2593. moveb %d0,%a1@(mac_scc_cha_a_data_offset)
  2594. #endif /* MAC_USE_SCC_A */
  2595. #ifdef MAC_USE_SCC_B
  2596. #ifndef MAC_USE_SCC_A /* Load mac_sccbase only if needed */
  2597. movel %pc@(L(mac_sccbase)),%a1
  2598. #endif /* MAC_USE_SCC_A */
  2599. 4: btst #2,%a1@(mac_scc_cha_b_ctrl_offset)
  2600. jeq 4b
  2601. moveb %d0,%a1@(mac_scc_cha_b_data_offset)
  2602. #endif /* MAC_USE_SCC_B */
  2603. #endif /* MAC_SERIAL_DEBUG */
  2604. jra L(serial_putc_done)
  2605. 5:
  2606. #endif /* CONFIG_MAC */
  2607. #ifdef CONFIG_ATARI
  2608. is_not_atari(4f)
  2609. movel %pc@(L(iobase)),%a1
  2610. #if defined(USE_PRINTER)
  2611. 3: btst #0,%a1@(LSTMFP_GPIP)
  2612. jne 3b
  2613. moveb #LPSG_IO_B,%a1@(LPSG_SELECT)
  2614. moveb %d0,%a1@(LPSG_WRITE)
  2615. moveb #LPSG_IO_A,%a1@(LPSG_SELECT)
  2616. moveb %a1@(LPSG_READ),%d0
  2617. bclr #5,%d0
  2618. moveb %d0,%a1@(LPSG_WRITE)
  2619. nop
  2620. nop
  2621. bset #5,%d0
  2622. moveb %d0,%a1@(LPSG_WRITE)
  2623. #elif defined(USE_SCC)
  2624. 3: btst #2,%a1@(LSCC_CTRL)
  2625. jeq 3b
  2626. moveb %d0,%a1@(LSCC_DATA)
  2627. #elif defined(USE_MFP)
  2628. 3: btst #7,%a1@(LMFP_TSR)
  2629. jeq 3b
  2630. moveb %d0,%a1@(LMFP_UDR)
  2631. #endif
  2632. jra L(serial_putc_done)
  2633. 4:
  2634. #endif /* CONFIG_ATARI */
  2635. #ifdef CONFIG_MVME147
  2636. is_not_mvme147(2f)
  2637. 1: btst #2,M147_SCC_CTRL_A
  2638. jeq 1b
  2639. moveb %d0,M147_SCC_DATA_A
  2640. jbra L(serial_putc_done)
  2641. 2:
  2642. #endif
  2643. #ifdef CONFIG_MVME16x
  2644. is_not_mvme16x(2f)
  2645. /*
  2646. * If the loader gave us a board type then we can use that to
  2647. * select an appropriate output routine; otherwise we just use
  2648. * the Bug code. If we haev to use the Bug that means the Bug
  2649. * workspace has to be valid, which means the Bug has to use
  2650. * the SRAM, which is non-standard.
  2651. */
  2652. moveml %d0-%d7/%a2-%a6,%sp@-
  2653. movel vme_brdtype,%d1
  2654. jeq 1f | No tag - use the Bug
  2655. cmpi #VME_TYPE_MVME162,%d1
  2656. jeq 6f
  2657. cmpi #VME_TYPE_MVME172,%d1
  2658. jne 5f
  2659. /* 162/172; it's an SCC */
  2660. 6: btst #2,M162_SCC_CTRL_A
  2661. nop
  2662. nop
  2663. nop
  2664. jeq 6b
  2665. moveb #8,M162_SCC_CTRL_A
  2666. nop
  2667. nop
  2668. nop
  2669. moveb %d0,M162_SCC_CTRL_A
  2670. jra 3f
  2671. 5:
  2672. /* 166/167/177; it's a CD2401 */
  2673. moveb #0,M167_CYCAR
  2674. moveb M167_CYIER,%d2
  2675. moveb #0x02,M167_CYIER
  2676. 7:
  2677. btst #5,M167_PCSCCTICR
  2678. jeq 7b
  2679. moveb M167_PCTPIACKR,%d1
  2680. moveb M167_CYLICR,%d1
  2681. jeq 8f
  2682. moveb #0x08,M167_CYTEOIR
  2683. jra 7b
  2684. 8:
  2685. moveb %d0,M167_CYTDR
  2686. moveb #0,M167_CYTEOIR
  2687. moveb %d2,M167_CYIER
  2688. jra 3f
  2689. 1:
  2690. moveb %d0,%sp@-
  2691. trap #15
  2692. .word 0x0020 /* TRAP 0x020 */
  2693. 3:
  2694. moveml %sp@+,%d0-%d7/%a2-%a6
  2695. jbra L(serial_putc_done)
  2696. 2:
  2697. #endif /* CONFIG_MVME16x */
  2698. #ifdef CONFIG_BVME6000
  2699. is_not_bvme6000(2f)
  2700. /*
  2701. * The BVME6000 machine has a serial port ...
  2702. */
  2703. 1: btst #2,BVME_SCC_CTRL_A
  2704. jeq 1b
  2705. moveb %d0,BVME_SCC_DATA_A
  2706. jbra L(serial_putc_done)
  2707. 2:
  2708. #endif
  2709. #ifdef CONFIG_SUN3X
  2710. is_not_sun3x(2f)
  2711. movel %d0,-(%sp)
  2712. movel 0xFEFE0018,%a1
  2713. jbsr (%a1)
  2714. addq #4,%sp
  2715. jbra L(serial_putc_done)
  2716. 2:
  2717. #endif
  2718. #ifdef CONFIG_Q40
  2719. is_not_q40(2f)
  2720. tst.l %pc@(L(q40_do_debug)) /* only debug if requested */
  2721. beq 2f
  2722. lea %pc@(q40_mem_cptr),%a1
  2723. move.l %a1@,%a0
  2724. move.b %d0,%a0@
  2725. addq.l #4,%a0
  2726. move.l %a0,%a1@
  2727. jbra L(serial_putc_done)
  2728. 2:
  2729. #endif
  2730. #ifdef CONFIG_APOLLO
  2731. is_not_apollo(2f)
  2732. movl %pc@(L(iobase)),%a1
  2733. moveb %d0,%a1@(LTHRB0)
  2734. 1: moveb %a1@(LSRB0),%d0
  2735. andb #0x4,%d0
  2736. beq 1b
  2737. jbra L(serial_putc_done)
  2738. 2:
  2739. #endif
  2740. #ifdef CONFIG_HP300
  2741. is_not_hp300(3f)
  2742. movl %pc@(L(iobase)),%a1
  2743. addl %pc@(L(uartbase)),%a1
  2744. movel %pc@(L(uart_scode)),%d1 /* Check the scode */
  2745. jmi 3f /* Unset? Exit */
  2746. cmpi #256,%d1 /* APCI scode? */
  2747. jeq 2f
  2748. 1: moveb %a1@(DCALSR),%d1 /* Output to DCA */
  2749. andb #0x20,%d1
  2750. beq 1b
  2751. moveb %d0,%a1@(DCADATA)
  2752. jbra L(serial_putc_done)
  2753. 2: moveb %a1@(APCILSR),%d1 /* Output to APCI */
  2754. andb #0x20,%d1
  2755. beq 2b
  2756. moveb %d0,%a1@(APCIDATA)
  2757. jbra L(serial_putc_done)
  2758. 3:
  2759. #endif
  2760. L(serial_putc_done):
  2761. func_return serial_putc
  2762. /*
  2763. * Output a string.
  2764. */
  2765. func_start puts,%d0/%a0
  2766. movel ARG1,%a0
  2767. jra 2f
  2768. 1:
  2769. #ifdef CONSOLE
  2770. console_putc %d0
  2771. #endif
  2772. #ifdef SERIAL_DEBUG
  2773. serial_putc %d0
  2774. #endif
  2775. 2: moveb %a0@+,%d0
  2776. jne 1b
  2777. func_return puts
  2778. /*
  2779. * Output number in hex notation.
  2780. */
  2781. func_start putn,%d0-%d2
  2782. putc ' '
  2783. movel ARG1,%d0
  2784. moveq #7,%d1
  2785. 1: roll #4,%d0
  2786. move %d0,%d2
  2787. andb #0x0f,%d2
  2788. addb #'0',%d2
  2789. cmpb #'9',%d2
  2790. jls 2f
  2791. addb #'A'-('9'+1),%d2
  2792. 2:
  2793. #ifdef CONSOLE
  2794. console_putc %d2
  2795. #endif
  2796. #ifdef SERIAL_DEBUG
  2797. serial_putc %d2
  2798. #endif
  2799. dbra %d1,1b
  2800. func_return putn
  2801. #ifdef CONFIG_MAC
  2802. /*
  2803. * mac_serial_print
  2804. *
  2805. * This routine takes its parameters on the stack. It then
  2806. * turns around and calls the internal routine. This routine
  2807. * is used until the Linux console driver initializes itself.
  2808. *
  2809. * The calling parameters are:
  2810. * void mac_serial_print(const char *str);
  2811. *
  2812. * This routine does NOT understand variable arguments only
  2813. * simple strings!
  2814. */
  2815. ENTRY(mac_serial_print)
  2816. moveml %d0/%a0,%sp@-
  2817. #if 1
  2818. move %sr,%sp@-
  2819. ori #0x0700,%sr
  2820. #endif
  2821. movel %sp@(10),%a0 /* fetch parameter */
  2822. jra 2f
  2823. 1: serial_putc %d0
  2824. 2: moveb %a0@+,%d0
  2825. jne 1b
  2826. #if 1
  2827. move %sp@+,%sr
  2828. #endif
  2829. moveml %sp@+,%d0/%a0
  2830. rts
  2831. #endif /* CONFIG_MAC */
  2832. #if defined(CONFIG_HP300) || defined(CONFIG_APOLLO)
  2833. func_start set_leds,%d0/%a0
  2834. movel ARG1,%d0
  2835. #ifdef CONFIG_HP300
  2836. is_not_hp300(1f)
  2837. movel %pc@(L(iobase)),%a0
  2838. moveb %d0,%a0@(0x1ffff)
  2839. jra 2f
  2840. #endif
  2841. 1:
  2842. #ifdef CONFIG_APOLLO
  2843. movel %pc@(L(iobase)),%a0
  2844. lsll #8,%d0
  2845. eorw #0xff00,%d0
  2846. moveb %d0,%a0@(LCPUCTRL)
  2847. #endif
  2848. 2:
  2849. func_return set_leds
  2850. #endif
  2851. #ifdef CONSOLE
  2852. /*
  2853. * For continuity, see the data alignment
  2854. * to which this structure is tied.
  2855. */
  2856. #define Lconsole_struct_cur_column 0
  2857. #define Lconsole_struct_cur_row 4
  2858. #define Lconsole_struct_num_columns 8
  2859. #define Lconsole_struct_num_rows 12
  2860. #define Lconsole_struct_left_edge 16
  2861. #define Lconsole_struct_penguin_putc 20
  2862. func_start console_init,%a0-%a4/%d0-%d7
  2863. /*
  2864. * Some of the register usage that follows
  2865. * a0 = pointer to boot_info
  2866. * a1 = pointer to screen
  2867. * a2 = pointer to Lconsole_globals
  2868. * d3 = pixel width of screen
  2869. * d4 = pixel height of screen
  2870. * (d3,d4) ~= (x,y) of a point just below
  2871. * and to the right of the screen
  2872. * NOT on the screen!
  2873. * d5 = number of bytes per scan line
  2874. * d6 = number of bytes on the entire screen
  2875. */
  2876. lea %pc@(L(console_globals)),%a2
  2877. movel %pc@(L(mac_videobase)),%a1
  2878. movel %pc@(L(mac_rowbytes)),%d5
  2879. movel %pc@(L(mac_dimensions)),%d3 /* -> low byte */
  2880. movel %d3,%d4
  2881. swap %d4 /* -> high byte */
  2882. andl #0xffff,%d3 /* d3 = screen width in pixels */
  2883. andl #0xffff,%d4 /* d4 = screen height in pixels */
  2884. movel %d5,%d6
  2885. | subl #20,%d6
  2886. mulul %d4,%d6 /* scan line bytes x num scan lines */
  2887. divul #8,%d6 /* we'll clear 8 bytes at a time */
  2888. moveq #-1,%d0 /* Mac_black */
  2889. subq #1,%d6
  2890. L(console_clear_loop):
  2891. movel %d0,%a1@+
  2892. movel %d0,%a1@+
  2893. dbra %d6,L(console_clear_loop)
  2894. /* Calculate font size */
  2895. #if defined(FONT_8x8) && defined(CONFIG_FONT_8x8)
  2896. lea %pc@(font_vga_8x8),%a0
  2897. #elif defined(FONT_8x16) && defined(CONFIG_FONT_8x16)
  2898. lea %pc@(font_vga_8x16),%a0
  2899. #elif defined(FONT_6x11) && defined(CONFIG_FONT_6x11)
  2900. lea %pc@(font_vga_6x11),%a0
  2901. #elif defined(CONFIG_FONT_8x8) /* default */
  2902. lea %pc@(font_vga_8x8),%a0
  2903. #else /* no compiled-in font */
  2904. lea 0,%a0
  2905. #endif
  2906. /*
  2907. * At this point we make a shift in register usage
  2908. * a1 = address of console_font pointer
  2909. */
  2910. lea %pc@(L(console_font)),%a1
  2911. movel %a0,%a1@ /* store pointer to struct fbcon_font_desc in console_font */
  2912. tstl %a0
  2913. jeq 1f
  2914. lea %pc@(L(console_font_data)),%a4
  2915. movel %a0@(FONT_DESC_DATA),%d0
  2916. subl #L(console_font),%a1
  2917. addl %a1,%d0
  2918. movel %d0,%a4@
  2919. /*
  2920. * Calculate global maxs
  2921. * Note - we can use either an
  2922. * 8 x 16 or 8 x 8 character font
  2923. * 6 x 11 also supported
  2924. */
  2925. /* ASSERT: a0 = contents of Lconsole_font */
  2926. movel %d3,%d0 /* screen width in pixels */
  2927. divul %a0@(FONT_DESC_WIDTH),%d0 /* d0 = max num chars per row */
  2928. movel %d4,%d1 /* screen height in pixels */
  2929. divul %a0@(FONT_DESC_HEIGHT),%d1 /* d1 = max num rows */
  2930. movel %d0,%a2@(Lconsole_struct_num_columns)
  2931. movel %d1,%a2@(Lconsole_struct_num_rows)
  2932. /*
  2933. * Clear the current row and column
  2934. */
  2935. clrl %a2@(Lconsole_struct_cur_column)
  2936. clrl %a2@(Lconsole_struct_cur_row)
  2937. clrl %a2@(Lconsole_struct_left_edge)
  2938. /*
  2939. * Initialization is complete
  2940. */
  2941. 1:
  2942. func_return console_init
  2943. func_start console_put_stats,%a0/%d7
  2944. /*
  2945. * Some of the register usage that follows
  2946. * a0 = pointer to boot_info
  2947. * d7 = value of boot_info fields
  2948. */
  2949. puts "\nMacLinux\n\n"
  2950. #ifdef SERIAL_DEBUG
  2951. puts " vidaddr:"
  2952. putn %pc@(L(mac_videobase)) /* video addr. */
  2953. puts "\n _stext:"
  2954. lea %pc@(_stext),%a0
  2955. putn %a0
  2956. puts "\nbootinfo:"
  2957. lea %pc@(_end),%a0
  2958. putn %a0
  2959. puts "\ncpuid:"
  2960. putn %pc@(L(cputype))
  2961. putc '\n'
  2962. #ifdef MAC_SERIAL_DEBUG
  2963. putn %pc@(L(mac_sccbase))
  2964. putc '\n'
  2965. #endif
  2966. # if defined(MMU_PRINT)
  2967. jbsr mmu_print_machine_cpu_types
  2968. # endif /* MMU_PRINT */
  2969. #endif /* SERIAL_DEBUG */
  2970. func_return console_put_stats
  2971. #ifdef CONSOLE_PENGUIN
  2972. func_start console_put_penguin,%a0-%a1/%d0-%d7
  2973. /*
  2974. * Get 'that_penguin' onto the screen in the upper right corner
  2975. * penguin is 64 x 74 pixels, align against right edge of screen
  2976. */
  2977. lea %pc@(L(mac_dimensions)),%a0
  2978. movel %a0@,%d0
  2979. andil #0xffff,%d0
  2980. subil #64,%d0 /* snug up against the right edge */
  2981. clrl %d1 /* start at the top */
  2982. movel #73,%d7
  2983. lea %pc@(L(that_penguin)),%a1
  2984. L(console_penguin_row):
  2985. movel #31,%d6
  2986. L(console_penguin_pixel_pair):
  2987. moveb %a1@,%d2
  2988. lsrb #4,%d2
  2989. console_plot_pixel %d0,%d1,%d2
  2990. addq #1,%d0
  2991. moveb %a1@+,%d2
  2992. console_plot_pixel %d0,%d1,%d2
  2993. addq #1,%d0
  2994. dbra %d6,L(console_penguin_pixel_pair)
  2995. subil #64,%d0
  2996. addq #1,%d1
  2997. dbra %d7,L(console_penguin_row)
  2998. func_return console_put_penguin
  2999. /* include penguin bitmap */
  3000. L(that_penguin):
  3001. #include "../mac/mac_penguin.S"
  3002. #endif
  3003. /*
  3004. * Calculate source and destination addresses
  3005. * output a1 = dest
  3006. * a2 = source
  3007. */
  3008. func_start console_scroll,%a0-%a4/%d0-%d7
  3009. lea %pc@(L(mac_videobase)),%a0
  3010. movel %a0@,%a1
  3011. movel %a1,%a2
  3012. lea %pc@(L(mac_rowbytes)),%a0
  3013. movel %a0@,%d5
  3014. movel %pc@(L(console_font)),%a0
  3015. tstl %a0
  3016. jeq 1f
  3017. mulul %a0@(FONT_DESC_HEIGHT),%d5 /* account for # scan lines per character */
  3018. addal %d5,%a2
  3019. /*
  3020. * Get dimensions
  3021. */
  3022. lea %pc@(L(mac_dimensions)),%a0
  3023. movel %a0@,%d3
  3024. movel %d3,%d4
  3025. swap %d4
  3026. andl #0xffff,%d3 /* d3 = screen width in pixels */
  3027. andl #0xffff,%d4 /* d4 = screen height in pixels */
  3028. /*
  3029. * Calculate number of bytes to move
  3030. */
  3031. lea %pc@(L(mac_rowbytes)),%a0
  3032. movel %a0@,%d6
  3033. movel %pc@(L(console_font)),%a0
  3034. subl %a0@(FONT_DESC_HEIGHT),%d4 /* we're not scrolling the top row! */
  3035. mulul %d4,%d6 /* scan line bytes x num scan lines */
  3036. divul #32,%d6 /* we'll move 8 longs at a time */
  3037. subq #1,%d6
  3038. L(console_scroll_loop):
  3039. movel %a2@+,%a1@+
  3040. movel %a2@+,%a1@+
  3041. movel %a2@+,%a1@+
  3042. movel %a2@+,%a1@+
  3043. movel %a2@+,%a1@+
  3044. movel %a2@+,%a1@+
  3045. movel %a2@+,%a1@+
  3046. movel %a2@+,%a1@+
  3047. dbra %d6,L(console_scroll_loop)
  3048. lea %pc@(L(mac_rowbytes)),%a0
  3049. movel %a0@,%d6
  3050. movel %pc@(L(console_font)),%a0
  3051. mulul %a0@(FONT_DESC_HEIGHT),%d6 /* scan line bytes x font height */
  3052. divul #32,%d6 /* we'll move 8 words at a time */
  3053. subq #1,%d6
  3054. moveq #-1,%d0
  3055. L(console_scroll_clear_loop):
  3056. movel %d0,%a1@+
  3057. movel %d0,%a1@+
  3058. movel %d0,%a1@+
  3059. movel %d0,%a1@+
  3060. movel %d0,%a1@+
  3061. movel %d0,%a1@+
  3062. movel %d0,%a1@+
  3063. movel %d0,%a1@+
  3064. dbra %d6,L(console_scroll_clear_loop)
  3065. 1:
  3066. func_return console_scroll
  3067. func_start console_putc,%a0/%a1/%d0-%d7
  3068. is_not_mac(L(console_exit))
  3069. tstl %pc@(L(console_font))
  3070. jeq L(console_exit)
  3071. /* Output character in d7 on console.
  3072. */
  3073. movel ARG1,%d7
  3074. cmpib #'\n',%d7
  3075. jbne 1f
  3076. /* A little safe recursion is good for the soul */
  3077. console_putc #'\r'
  3078. 1:
  3079. lea %pc@(L(console_globals)),%a0
  3080. cmpib #10,%d7
  3081. jne L(console_not_lf)
  3082. movel %a0@(Lconsole_struct_cur_row),%d0
  3083. addil #1,%d0
  3084. movel %d0,%a0@(Lconsole_struct_cur_row)
  3085. movel %a0@(Lconsole_struct_num_rows),%d1
  3086. cmpl %d1,%d0
  3087. jcs 1f
  3088. subil #1,%d0
  3089. movel %d0,%a0@(Lconsole_struct_cur_row)
  3090. console_scroll
  3091. 1:
  3092. jra L(console_exit)
  3093. L(console_not_lf):
  3094. cmpib #13,%d7
  3095. jne L(console_not_cr)
  3096. clrl %a0@(Lconsole_struct_cur_column)
  3097. jra L(console_exit)
  3098. L(console_not_cr):
  3099. cmpib #1,%d7
  3100. jne L(console_not_home)
  3101. clrl %a0@(Lconsole_struct_cur_row)
  3102. clrl %a0@(Lconsole_struct_cur_column)
  3103. jra L(console_exit)
  3104. /*
  3105. * At this point we know that the %d7 character is going to be
  3106. * rendered on the screen. Register usage is -
  3107. * a0 = pointer to console globals
  3108. * a1 = font data
  3109. * d0 = cursor column
  3110. * d1 = cursor row to draw the character
  3111. * d7 = character number
  3112. */
  3113. L(console_not_home):
  3114. movel %a0@(Lconsole_struct_cur_column),%d0
  3115. addql #1,%a0@(Lconsole_struct_cur_column)
  3116. movel %a0@(Lconsole_struct_num_columns),%d1
  3117. cmpl %d1,%d0
  3118. jcs 1f
  3119. console_putc #'\n' /* recursion is OK! */
  3120. 1:
  3121. movel %a0@(Lconsole_struct_cur_row),%d1
  3122. /*
  3123. * At this point we make a shift in register usage
  3124. * a0 = address of pointer to font data (fbcon_font_desc)
  3125. */
  3126. movel %pc@(L(console_font)),%a0
  3127. movel %pc@(L(console_font_data)),%a1 /* Load fbcon_font_desc.data into a1 */
  3128. andl #0x000000ff,%d7
  3129. /* ASSERT: a0 = contents of Lconsole_font */
  3130. mulul %a0@(FONT_DESC_HEIGHT),%d7 /* d7 = index into font data */
  3131. addl %d7,%a1 /* a1 = points to char image */
  3132. /*
  3133. * At this point we make a shift in register usage
  3134. * d0 = pixel coordinate, x
  3135. * d1 = pixel coordinate, y
  3136. * d2 = (bit 0) 1/0 for white/black (!) pixel on screen
  3137. * d3 = font scan line data (8 pixels)
  3138. * d6 = count down for the font's pixel width (8)
  3139. * d7 = count down for the font's pixel count in height
  3140. */
  3141. /* ASSERT: a0 = contents of Lconsole_font */
  3142. mulul %a0@(FONT_DESC_WIDTH),%d0
  3143. mulul %a0@(FONT_DESC_HEIGHT),%d1
  3144. movel %a0@(FONT_DESC_HEIGHT),%d7 /* Load fbcon_font_desc.height into d7 */
  3145. subq #1,%d7
  3146. L(console_read_char_scanline):
  3147. moveb %a1@+,%d3
  3148. /* ASSERT: a0 = contents of Lconsole_font */
  3149. movel %a0@(FONT_DESC_WIDTH),%d6 /* Load fbcon_font_desc.width into d6 */
  3150. subql #1,%d6
  3151. L(console_do_font_scanline):
  3152. lslb #1,%d3
  3153. scsb %d2 /* convert 1 bit into a byte */
  3154. console_plot_pixel %d0,%d1,%d2
  3155. addq #1,%d0
  3156. dbra %d6,L(console_do_font_scanline)
  3157. /* ASSERT: a0 = contents of Lconsole_font */
  3158. subl %a0@(FONT_DESC_WIDTH),%d0
  3159. addq #1,%d1
  3160. dbra %d7,L(console_read_char_scanline)
  3161. L(console_exit):
  3162. func_return console_putc
  3163. /*
  3164. * Input:
  3165. * d0 = x coordinate
  3166. * d1 = y coordinate
  3167. * d2 = (bit 0) 1/0 for white/black (!)
  3168. * All registers are preserved
  3169. */
  3170. func_start console_plot_pixel,%a0-%a1/%d0-%d4
  3171. movel %pc@(L(mac_videobase)),%a1
  3172. movel %pc@(L(mac_videodepth)),%d3
  3173. movel ARG1,%d0
  3174. movel ARG2,%d1
  3175. mulul %pc@(L(mac_rowbytes)),%d1
  3176. movel ARG3,%d2
  3177. /*
  3178. * Register usage:
  3179. * d0 = x coord becomes byte offset into frame buffer
  3180. * d1 = y coord
  3181. * d2 = black or white (0/1)
  3182. * d3 = video depth
  3183. * d4 = temp of x (d0) for many bit depths
  3184. */
  3185. L(test_1bit):
  3186. cmpb #1,%d3
  3187. jbne L(test_2bit)
  3188. movel %d0,%d4 /* we need the low order 3 bits! */
  3189. divul #8,%d0
  3190. addal %d0,%a1
  3191. addal %d1,%a1
  3192. andb #7,%d4
  3193. eorb #7,%d4 /* reverse the x-coordinate w/ screen-bit # */
  3194. andb #1,%d2
  3195. jbne L(white_1)
  3196. bsetb %d4,%a1@
  3197. jbra L(console_plot_pixel_exit)
  3198. L(white_1):
  3199. bclrb %d4,%a1@
  3200. jbra L(console_plot_pixel_exit)
  3201. L(test_2bit):
  3202. cmpb #2,%d3
  3203. jbne L(test_4bit)
  3204. movel %d0,%d4 /* we need the low order 2 bits! */
  3205. divul #4,%d0
  3206. addal %d0,%a1
  3207. addal %d1,%a1
  3208. andb #3,%d4
  3209. eorb #3,%d4 /* reverse the x-coordinate w/ screen-bit # */
  3210. lsll #1,%d4 /* ! */
  3211. andb #1,%d2
  3212. jbne L(white_2)
  3213. bsetb %d4,%a1@
  3214. addq #1,%d4
  3215. bsetb %d4,%a1@
  3216. jbra L(console_plot_pixel_exit)
  3217. L(white_2):
  3218. bclrb %d4,%a1@
  3219. addq #1,%d4
  3220. bclrb %d4,%a1@
  3221. jbra L(console_plot_pixel_exit)
  3222. L(test_4bit):
  3223. cmpb #4,%d3
  3224. jbne L(test_8bit)
  3225. movel %d0,%d4 /* we need the low order bit! */
  3226. divul #2,%d0
  3227. addal %d0,%a1
  3228. addal %d1,%a1
  3229. andb #1,%d4
  3230. eorb #1,%d4
  3231. lsll #2,%d4 /* ! */
  3232. andb #1,%d2
  3233. jbne L(white_4)
  3234. bsetb %d4,%a1@
  3235. addq #1,%d4
  3236. bsetb %d4,%a1@
  3237. addq #1,%d4
  3238. bsetb %d4,%a1@
  3239. addq #1,%d4
  3240. bsetb %d4,%a1@
  3241. jbra L(console_plot_pixel_exit)
  3242. L(white_4):
  3243. bclrb %d4,%a1@
  3244. addq #1,%d4
  3245. bclrb %d4,%a1@
  3246. addq #1,%d4
  3247. bclrb %d4,%a1@
  3248. addq #1,%d4
  3249. bclrb %d4,%a1@
  3250. jbra L(console_plot_pixel_exit)
  3251. L(test_8bit):
  3252. cmpb #8,%d3
  3253. jbne L(test_16bit)
  3254. addal %d0,%a1
  3255. addal %d1,%a1
  3256. andb #1,%d2
  3257. jbne L(white_8)
  3258. moveb #0xff,%a1@
  3259. jbra L(console_plot_pixel_exit)
  3260. L(white_8):
  3261. clrb %a1@
  3262. jbra L(console_plot_pixel_exit)
  3263. L(test_16bit):
  3264. cmpb #16,%d3
  3265. jbne L(console_plot_pixel_exit)
  3266. addal %d0,%a1
  3267. addal %d0,%a1
  3268. addal %d1,%a1
  3269. andb #1,%d2
  3270. jbne L(white_16)
  3271. clrw %a1@
  3272. jbra L(console_plot_pixel_exit)
  3273. L(white_16):
  3274. movew #0x0fff,%a1@
  3275. jbra L(console_plot_pixel_exit)
  3276. L(console_plot_pixel_exit):
  3277. func_return console_plot_pixel
  3278. #endif /* CONSOLE */
  3279. #if 0
  3280. /*
  3281. * This is some old code lying around. I don't believe
  3282. * it's used or important anymore. My guess is it contributed
  3283. * to getting to this point, but it's done for now.
  3284. * It was still in the 2.1.77 head.S, so it's still here.
  3285. * (And still not used!)
  3286. */
  3287. L(showtest):
  3288. moveml %a0/%d7,%sp@-
  3289. puts "A="
  3290. putn %a1
  3291. .long 0xf0119f15 | ptestr #5,%a1@,#7,%a0
  3292. puts "DA="
  3293. putn %a0
  3294. puts "D="
  3295. putn %a0@
  3296. puts "S="
  3297. lea %pc@(L(mmu)),%a0
  3298. .long 0xf0106200 | pmove %psr,%a0@
  3299. clrl %d7
  3300. movew %a0@,%d7
  3301. putn %d7
  3302. putc '\n'
  3303. moveml %sp@+,%a0/%d7
  3304. rts
  3305. #endif /* 0 */
  3306. __INITDATA
  3307. .align 4
  3308. #if defined(CONFIG_ATARI) || defined(CONFIG_AMIGA) || \
  3309. defined(CONFIG_HP300) || defined(CONFIG_APOLLO)
  3310. L(custom):
  3311. L(iobase):
  3312. .long 0
  3313. #endif
  3314. #if defined(CONSOLE)
  3315. L(console_globals):
  3316. .long 0 /* cursor column */
  3317. .long 0 /* cursor row */
  3318. .long 0 /* max num columns */
  3319. .long 0 /* max num rows */
  3320. .long 0 /* left edge */
  3321. .long 0 /* mac putc */
  3322. L(console_font):
  3323. .long 0 /* pointer to console font (struct font_desc) */
  3324. L(console_font_data):
  3325. .long 0 /* pointer to console font data */
  3326. #endif /* CONSOLE */
  3327. #if defined(MMU_PRINT)
  3328. L(mmu_print_data):
  3329. .long 0 /* valid flag */
  3330. .long 0 /* start logical */
  3331. .long 0 /* next logical */
  3332. .long 0 /* start physical */
  3333. .long 0 /* next physical */
  3334. #endif /* MMU_PRINT */
  3335. L(cputype):
  3336. .long 0
  3337. L(mmu_cached_pointer_tables):
  3338. .long 0
  3339. L(mmu_num_pointer_tables):
  3340. .long 0
  3341. L(phys_kernel_start):
  3342. .long 0
  3343. L(kernel_end):
  3344. .long 0
  3345. L(memory_start):
  3346. .long 0
  3347. L(kernel_pgdir_ptr):
  3348. .long 0
  3349. L(temp_mmap_mem):
  3350. .long 0
  3351. #if defined (CONFIG_MVME147)
  3352. M147_SCC_CTRL_A = 0xfffe3002
  3353. M147_SCC_DATA_A = 0xfffe3003
  3354. #endif
  3355. #if defined (CONFIG_MVME16x)
  3356. M162_SCC_CTRL_A = 0xfff45005
  3357. M167_CYCAR = 0xfff450ee
  3358. M167_CYIER = 0xfff45011
  3359. M167_CYLICR = 0xfff45026
  3360. M167_CYTEOIR = 0xfff45085
  3361. M167_CYTDR = 0xfff450f8
  3362. M167_PCSCCTICR = 0xfff4201e
  3363. M167_PCTPIACKR = 0xfff42025
  3364. #endif
  3365. #if defined (CONFIG_BVME6000)
  3366. BVME_SCC_CTRL_A = 0xffb0000b
  3367. BVME_SCC_DATA_A = 0xffb0000f
  3368. #endif
  3369. #if defined(CONFIG_MAC)
  3370. L(mac_booter_data):
  3371. .long 0
  3372. L(mac_videobase):
  3373. .long 0
  3374. L(mac_videodepth):
  3375. .long 0
  3376. L(mac_dimensions):
  3377. .long 0
  3378. L(mac_rowbytes):
  3379. .long 0
  3380. #ifdef MAC_SERIAL_DEBUG
  3381. L(mac_sccbase):
  3382. .long 0
  3383. #endif /* MAC_SERIAL_DEBUG */
  3384. #endif
  3385. #if defined (CONFIG_APOLLO)
  3386. LSRB0 = 0x10412
  3387. LTHRB0 = 0x10416
  3388. LCPUCTRL = 0x10100
  3389. #endif
  3390. #if defined(CONFIG_HP300)
  3391. DCADATA = 0x11
  3392. DCALSR = 0x1b
  3393. APCIDATA = 0x00
  3394. APCILSR = 0x14
  3395. L(uartbase):
  3396. .long 0
  3397. L(uart_scode):
  3398. .long -1
  3399. #endif
  3400. __FINIT
  3401. .data
  3402. .align 4
  3403. availmem:
  3404. .long 0
  3405. m68k_pgtable_cachemode:
  3406. .long 0
  3407. m68k_supervisor_cachemode:
  3408. .long 0
  3409. #if defined(CONFIG_MVME16x)
  3410. mvme_bdid:
  3411. .long 0,0,0,0,0,0,0,0
  3412. #endif
  3413. #if defined(CONFIG_Q40)
  3414. q40_mem_cptr:
  3415. .long 0
  3416. L(q40_do_debug):
  3417. .long 0
  3418. #endif