head.S 88 KB

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