head.S 88 KB

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