head.S 88 KB

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