head.S 89 KB

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