head.S 88 KB

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