3 ** head.S -- This file contains the initial boot code for the
6 ** Copyright 1993 by Hamish Macdonald
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
13 ** Atari support by Andreas Schwab, using ideas of Robert de Vries
15 ** VME Support by Richard Hirst
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 fbcon_font_desc structures
27 ** This file is subject to the terms and conditions of the GNU General Public
28 ** License. See the file README.legal in the main directory of this archive
36 * At this point, the boot loader has:
39 * Put us in supervisor state.
41 * The kernel setup code takes the following steps:
42 * . Raise interrupt level
43 * . Set up initial kernel memory mapping.
44 * . This sets up a mapping of the 4M of memory the kernel is located in.
45 * . It also does a mapping of any initial machine specific areas.
47 * . Enable cache memories
48 * . Jump to kernel startup
50 * Much of the file restructuring was to accomplish:
51 * 1) Remove register dependency through-out the file.
52 * 2) Increase use of subroutines to perform functions
53 * 3) Increase readability of the code
55 * Of course, readability is a subjective issue, so it will never be
56 * argued that that goal was accomplished. It was merely a goal.
57 * A key way to help make code more readable is to give good
58 * documentation. So, the first thing you will find is exaustive
59 * write-ups on the structure of the file, and the features of the
60 * functional subroutines.
64 * Without a doubt the single largest chunk of head.S is spent
65 * mapping the kernel and I/O physical space into the logical range
67 * There are new subroutines and data structures to make MMU
68 * support cleaner and easier to understand.
69 * First, you will find a routine call "mmu_map" which maps
70 * a logical to a physical region for some length given a cache
71 * type on behalf of the caller. This routine makes writing the
72 * actual per-machine specific code very simple.
73 * A central part of the code, but not a subroutine in itself,
74 * is the mmu_init code which is broken down into mapping the kernel
75 * (the same for all machines) and mapping machine-specific I/O
77 * Also, there will be a description of engaging the MMU and
79 * You will notice that there is a chunk of code which
80 * can emit the entire MMU mapping of the machine. This is present
81 * only in debug modes and can be very helpful.
82 * Further, there is a new console driver in head.S that is
83 * also only engaged in debug mode. Currently, it's only supported
84 * on the Macintosh class of machines. However, it is hoped that
85 * others will plug-in support for specific machines.
87 * ######################################################################
91 * mmu_map was written for two key reasons. First, it was clear
92 * that it was very difficult to read the previous code for mapping
93 * regions of memory. Second, the Macintosh required such extensive
94 * memory allocations that it didn't make sense to propogate the
95 * existing code any further.
96 * mmu_map requires some parameters:
98 * mmu_map (logical, physical, length, cache_type)
100 * While this essentially describes the function in the abstract, you'll
101 * find more indepth description of other parameters at the implementation site.
103 * mmu_get_root_table_entry
104 * ------------------------
105 * mmu_get_ptr_table_entry
106 * -----------------------
107 * mmu_get_page_table_entry
108 * ------------------------
110 * These routines are used by other mmu routines to get a pointer into
111 * a table, if necessary a new table is allocated. These routines are working
112 * basically like pmd_alloc() and pte_alloc() in <asm/pgtable.h>. The root
113 * table needs of course only to be allocated once in mmu_get_root_table_entry,
114 * so that here also some mmu specific initialization is done. The second page
115 * at the start of the kernel (the first page is unmapped later) is used for
116 * the kernel_pg_dir. It must be at a position known at link time (as it's used
117 * to initialize the init task struct) and since it needs special cache
118 * settings, it's the easiest to use this page, the rest of the page is used
119 * for further pointer tables.
120 * mmu_get_page_table_entry allocates always a whole page for page tables, this
121 * means 1024 pages and so 4MB of memory can be mapped. It doesn't make sense
122 * to manage page tables in smaller pieces as nearly all mappings have that
125 * ######################################################################
128 * ######################################################################
132 * Thanks to a small helping routine enabling the mmu got quiet simple
133 * and there is only one way left. mmu_engage makes a complete a new mapping
134 * that only includes the absolute necessary to be able to jump to the final
135 * postion and to restore the original mapping.
136 * As this code doesn't need a transparent translation register anymore this
137 * means all registers are free to be used by machines that needs them for
140 * ######################################################################
144 * This algorithm will print out the page tables of the system as
145 * appropriate for an 030 or an 040. This is useful for debugging purposes
146 * and as such is enclosed in #ifdef MMU_PRINT/#endif clauses.
148 * ######################################################################
152 * The console is also able to be turned off. The console in head.S
153 * is specifically for debugging and can be very useful. It is surrounded by
154 * #ifdef CONSOLE/#endif clauses so it doesn't have to ship in known-good
155 * kernels. It's basic algorithm is to determine the size of the screen
156 * (in height/width and bit depth) and then use that information for
157 * displaying an 8x8 font or an 8x16 (widthxheight). I prefer the 8x8 for
158 * debugging so I can see more good data. But it was trivial to add support
159 * for both fonts, so I included it.
160 * Also, the algorithm for plotting pixels is abstracted so that in
161 * theory other platforms could add support for different kinds of frame
162 * buffers. This could be very useful.
164 * console_put_penguin
165 * -------------------
166 * An important part of any Linux bring up is the penguin and there's
167 * nothing like getting the Penguin on the screen! This algorithm will work
168 * on any machine for which there is a console_plot_pixel.
172 * My hope is that the scroll algorithm does the right thing on the
173 * various platforms, but it wouldn't be hard to add the test conditions
174 * and new code if it doesn't.
179 * ######################################################################
181 * Register usage has greatly simplified within head.S. Every subroutine
182 * saves and restores all registers that it modifies (except it returns a
183 * value in there of course). So the only register that needs to be initialized
184 * is the stack pointer.
185 * All other init code and data is now placed in the init section, so it will
186 * be automatically freed at the end of the kernel initialization.
188 * ######################################################################
192 * There are many options availble in a build of this file. I've
193 * taken the time to describe them here to save you the time of searching
194 * for them and trying to understand what they mean.
196 * CONFIG_xxx: These are the obvious machine configuration defines created
197 * during configuration. These are defined in include/linux/autoconf.h.
199 * CONSOLE: There is support for head.S console in this file. This
200 * console can talk to a Mac frame buffer, but could easily be extrapolated
201 * to extend it to support other platforms.
203 * TEST_MMU: This is a test harness for running on any given machine but
204 * getting an MMU dump for another class of machine. The classes of machines
205 * that can be tested are any of the makes (Atari, Amiga, Mac, VME, etc.)
206 * and any of the models (030, 040, 060, etc.).
208 * NOTE: TEST_MMU is NOT permanent! It is scheduled to be removed
209 * When head.S boots on Atari, Amiga, Macintosh, and VME
210 * machines. At that point the underlying logic will be
211 * believed to be solid enough to be trusted, and TEST_MMU
212 * can be dropped. Do note that that will clean up the
213 * head.S code significantly as large blocks of #if/#else
214 * clauses can be removed.
216 * MMU_NOCACHE_KERNEL: On the Macintosh platform there was an inquiry into
217 * determing why devices don't appear to work. A test case was to remove
218 * the cacheability of the kernel bits.
220 * MMU_PRINT: There is a routine built into head.S that can display the
221 * MMU data structures. It outputs its result through the serial_putc
222 * interface. So where ever that winds up driving data, that's where the
223 * mmu struct will appear. On the Macintosh that's typically the console.
225 * SERIAL_DEBUG: There are a series of putc() macro statements
226 * scattered through out the code to give progress of status to the
227 * person sitting at the console. This constant determines whether those
230 * DEBUG: This is the standard DEBUG flag that can be set for building
231 * the kernel. It has the effect adding additional tests into
237 * In theory these could be determined at run time or handed
238 * over by the booter. But, let's be real, it's a fine hard
239 * coded value. (But, you will notice the code is run-time
240 * flexible!) A pointer to the font's struct fbcon_font_desc
241 * is kept locally in Lconsole_font. It is used to determine
242 * font size information dynamically.
245 * USE_PRINTER: Use the printer port for serial debug.
246 * USE_SCC_B: Use the SCC port A (Serial2) for serial debug.
247 * USE_SCC_A: Use the SCC port B (Modem2) for serial debug.
248 * USE_MFP: Use the ST-MFP port (Modem1) for serial debug.
250 * Macintosh constants:
251 * MAC_SERIAL_DEBUG: Turns on serial debug output for the Macintosh.
252 * MAC_USE_SCC_A: Use the SCC port A (modem) for serial debug.
253 * MAC_USE_SCC_B: Use the SCC port B (printer) for serial debug (default).
256 #include <linux/config.h>
257 #include <linux/linkage.h>
258 #include <linux/init.h>
259 #include <asm/bootinfo.h>
260 #include <asm/setup.h>
261 #include <asm/pgtable.h>
262 #include "m68k_defs.h"
266 #include <asm/machw.h>
269 * Macintosh console support
275 * Macintosh serial debug support; outputs boot info to the printer
276 * and/or modem serial ports
278 #undef MAC_SERIAL_DEBUG
281 * Macintosh serial debug port selection; define one or both;
282 * requires MAC_SERIAL_DEBUG to be defined
284 #define MAC_USE_SCC_A /* Macintosh modem serial port */
285 #define MAC_USE_SCC_B /* Macintosh printer serial port */
287 #endif /* CONFIG_MAC */
290 #undef MMU_NOCACHE_KERNEL
295 * For the head.S console, there are three supported fonts, 6x11, 8x16 and 8x8.
296 * The 8x8 font is harder to read but fits more on the screen.
298 #define FONT_8x8 /* default */
299 /* #define FONT_8x16 */ /* 2nd choice */
300 /* #define FONT_6x11 */ /* 3rd choice */
302 .globl SYMBOL_NAME(kernel_pg_dir)
303 .globl SYMBOL_NAME(availmem)
304 .globl SYMBOL_NAME(m68k_pgtable_cachemode)
305 .globl SYMBOL_NAME(m68k_supervisor_cachemode)
307 CPUTYPE_040 = 1 /* indicates an 040 */
308 CPUTYPE_060 = 2 /* indicates an 060 */
309 CPUTYPE_0460 = 3 /* if either above are set, this is set */
310 CPUTYPE_020 = 4 /* indicates an 020 */
312 /* Translation control register */
317 /* Transparent translation registers */
318 TTR_ENABLE = 0x8000 /* enable transparent translation */
319 TTR_ANYMODE = 0x4000 /* user and kernel mode access */
320 TTR_KERNELMODE = 0x2000 /* only kernel mode access */
321 TTR_USERMODE = 0x0000 /* only user mode access */
322 TTR_CI = 0x0400 /* inhibit cache */
323 TTR_RW = 0x0200 /* read/write mode */
324 TTR_RWM = 0x0100 /* read/write mask */
325 TTR_FCB2 = 0x0040 /* function code base bit 2 */
326 TTR_FCB1 = 0x0020 /* function code base bit 1 */
327 TTR_FCB0 = 0x0010 /* function code base bit 0 */
328 TTR_FCM2 = 0x0004 /* function code mask bit 2 */
329 TTR_FCM1 = 0x0002 /* function code mask bit 1 */
330 TTR_FCM0 = 0x0001 /* function code mask bit 0 */
332 /* Cache Control registers */
333 CC6_ENABLE_D = 0x80000000 /* enable data cache (680[46]0) */
334 CC6_FREEZE_D = 0x40000000 /* freeze data cache (68060) */
335 CC6_ENABLE_SB = 0x20000000 /* enable store buffer (68060) */
336 CC6_PUSH_DPI = 0x10000000 /* disable CPUSH invalidation (68060) */
337 CC6_HALF_D = 0x08000000 /* half-cache mode for data cache (68060) */
338 CC6_ENABLE_B = 0x00800000 /* enable branch cache (68060) */
339 CC6_CLRA_B = 0x00400000 /* clear all entries in branch cache (68060) */
340 CC6_CLRU_B = 0x00200000 /* clear user entries in branch cache (68060) */
341 CC6_ENABLE_I = 0x00008000 /* enable instruction cache (680[46]0) */
342 CC6_FREEZE_I = 0x00004000 /* freeze instruction cache (68060) */
343 CC6_HALF_I = 0x00002000 /* half-cache mode for instruction cache (68060) */
344 CC3_ALLOC_WRITE = 0x00002000 /* write allocate mode(68030) */
345 CC3_ENABLE_DB = 0x00001000 /* enable data burst (68030) */
346 CC3_CLR_D = 0x00000800 /* clear data cache (68030) */
347 CC3_CLRE_D = 0x00000400 /* clear entry in data cache (68030) */
348 CC3_FREEZE_D = 0x00000200 /* freeze data cache (68030) */
349 CC3_ENABLE_D = 0x00000100 /* enable data cache (68030) */
350 CC3_ENABLE_IB = 0x00000010 /* enable instruction burst (68030) */
351 CC3_CLR_I = 0x00000008 /* clear instruction cache (68030) */
352 CC3_CLRE_I = 0x00000004 /* clear entry in instruction cache (68030) */
353 CC3_FREEZE_I = 0x00000002 /* freeze instruction cache (68030) */
354 CC3_ENABLE_I = 0x00000001 /* enable instruction cache (68030) */
356 /* Miscellaneous definitions */
360 ROOT_TABLE_SIZE = 128
363 ROOT_INDEX_SHIFT = 25
365 PAGE_INDEX_SHIFT = 12
368 /* When debugging use readable names for labels */
370 #define L(name) .head.S.##name
372 #define L(name) .head.S./**/name
376 #define L(name) .L##name
378 #define L(name) .L/**/name
382 /* Several macros to make the writing of subroutines easier:
383 * - func_start marks the beginning of the routine which setups the frame
384 * register and saves the registers, it also defines another macro
385 * to automatically restore the registers again.
386 * - func_return marks the end of the routine and simply calls the prepared
387 * macro to restore registers and jump back to the caller.
388 * - func_define generates another macro to automatically put arguments
389 * onto the stack call the subroutine and cleanup the stack again.
392 /* Within subroutines these macros can be used to access the arguments
393 * on the stack. With STACK some allocated memory on the stack can be
394 * accessed and ARG0 points to the return address (used by mmu_engage).
396 #define STACK %a6@(stackstart)
399 #define ARG2 %a6@(12)
400 #define ARG3 %a6@(16)
401 #define ARG4 %a6@(20)
403 .macro func_start name,saveregs,stack=0
406 moveml \saveregs,%sp@-
407 .set stackstart,-\stack
409 .macro func_return_\name
410 moveml %sp@+,\saveregs
416 .macro func_return name
420 .macro func_call name
424 .macro move_stack nr,arg1,arg2,arg3,arg4
426 move_stack "(\nr-1)",\arg2,\arg3,\arg4
431 .macro func_define name,nr=0
432 .macro \name arg1,arg2,arg3,arg4
433 move_stack \nr,\arg1,\arg2,\arg3,\arg4
441 func_define mmu_map,4
442 func_define mmu_map_tt,4
443 func_define mmu_fixup_page_mmu_cache,1
444 func_define mmu_temp_map,2
445 func_define mmu_engage
446 func_define mmu_get_root_table_entry,1
447 func_define mmu_get_ptr_table_entry,2
448 func_define mmu_get_page_table_entry,2
449 func_define mmu_print
450 func_define get_new_page
455 .macro mmu_map_eq arg1,arg2,arg3
456 mmu_map \arg1,\arg1,\arg2,\arg3
459 .macro get_bi_record record
461 func_call get_bi_record
465 func_define serial_putc,1
466 func_define console_putc,1
469 #if defined(CONSOLE) || defined(SERIAL_DEBUG)
473 func_call console_putc
476 func_call serial_putc
478 #if defined(CONSOLE) || defined(SERIAL_DEBUG)
498 #if defined(CONSOLE) || defined(SERIAL_DEBUG)
516 #define is_not_amiga(lab) cmpl &MACH_AMIGA,%pc@(m68k_machtype); jne lab
517 #define is_not_atari(lab) cmpl &MACH_ATARI,%pc@(m68k_machtype); jne lab
518 #define is_not_mac(lab) cmpl &MACH_MAC,%pc@(m68k_machtype); jne lab
519 #define is_not_mvme16x(lab) cmpl &MACH_MVME16x,%pc@(m68k_machtype); jne lab
520 #define is_not_bvme6000(lab) cmpl &MACH_BVME6000,%pc@(m68k_machtype); jne lab
521 #define is_not_hp300(lab) cmpl &MACH_HP300,%pc@(m68k_machtype); jne lab
523 #define is_040_or_060(lab) btst &CPUTYPE_0460,%pc@(L(cputype)+3); jne lab
524 #define is_not_040_or_060(lab) btst &CPUTYPE_0460,%pc@(L(cputype)+3); jeq lab
525 #define is_040(lab) btst &CPUTYPE_040,%pc@(L(cputype)+3); jne lab
526 #define is_060(lab) btst &CPUTYPE_060,%pc@(L(cputype)+3); jne lab
527 #define is_not_060(lab) btst &CPUTYPE_060,%pc@(L(cputype)+3); jeq lab
528 #define is_020(lab) btst &CPUTYPE_020,%pc@(L(cputype)+3); jne lab
529 #define is_not_020(lab) btst &CPUTYPE_020,%pc@(L(cputype)+3); jeq lab
531 /* On the HP300 we use the on-board LEDs for debug output before
532 the console is running. Writing a 1 bit turns the corresponding LED
533 _off_ - on the 340 bit 7 is towards the back panel of the machine. */
536 is_not_hp300(.Lled\@)
547 * Version numbers of the bootinfo interface
548 * The area from _stext to _start will later be used as kernel pointer table
550 bras 1f /* Jump over bootinfo version numbers */
552 .long BOOTINFOV_MAGIC
553 .long MACH_AMIGA, AMIGA_BOOTI_VERSION
554 .long MACH_ATARI, ATARI_BOOTI_VERSION
555 .long MACH_MVME16x, MVME16x_BOOTI_VERSION
556 .long MACH_BVME6000, BVME6000_BOOTI_VERSION
557 .long MACH_MAC, MAC_BOOTI_VERSION
559 1: jra SYMBOL_NAME(__start)
561 .equ SYMBOL_NAME(kernel_pg_dir),SYMBOL_NAME(_stext)
563 .equ .,SYMBOL_NAME(_stext)+PAGESIZE
566 jra SYMBOL_NAME(__start)
571 * Setup initial stack pointer
573 lea %pc@(SYMBOL_NAME(_stext)),%sp
576 * Record the CPU and machine type.
579 get_bi_record BI_MACHTYPE
580 lea %pc@(SYMBOL_NAME(m68k_machtype)),%a1
583 get_bi_record BI_FPUTYPE
584 lea %pc@(SYMBOL_NAME(m68k_fputype)),%a1
587 get_bi_record BI_MMUTYPE
588 lea %pc@(SYMBOL_NAME(m68k_mmutype)),%a1
591 get_bi_record BI_CPUTYPE
592 lea %pc@(SYMBOL_NAME(m68k_cputype)),%a1
597 * For Macintosh, we need to determine the display parameters early (at least
598 * while debugging it).
601 is_not_mac(L(test_notmac))
603 get_bi_record BI_MAC_VADDR
604 lea %pc@(L(mac_videobase)),%a1
607 get_bi_record BI_MAC_VDEPTH
608 lea %pc@(L(mac_videodepth)),%a1
611 get_bi_record BI_MAC_VDIM
612 lea %pc@(L(mac_dimensions)),%a1
615 get_bi_record BI_MAC_VROW
616 lea %pc@(L(mac_rowbytes)),%a1
619 #ifdef MAC_SERIAL_DEBUG
620 get_bi_record BI_MAC_SCCBASE
621 lea %pc@(L(mac_sccbase)),%a1
623 #endif /* MAC_SERIAL_DEBUG */
629 lea %pc@(L(mac_videobase)),%a0
631 lea %pc@(L(mac_dimensions)),%a0
633 swap %d1 /* #rows is high bytes */
634 andl #0xFFFF,%d1 /* rows */
636 lea %pc@(L(mac_rowbytes)),%a0
647 #endif /* CONFIG_MAC */
651 * There are ultimately two pieces of information we want for all kinds of
652 * processors CpuType and CacheBits. The CPUTYPE was passed in from booter
653 * and is converted here from a booter type definition to a separate bit
654 * number which allows for the standard is_0x0 macro tests.
656 movel %pc@(SYMBOL_NAME(m68k_cputype)),%d0
663 * Test the BootInfo cputype for 060
667 bset #CPUTYPE_060,%d1
668 bset #CPUTYPE_0460,%d1
672 * Test the BootInfo cputype for 040
676 bset #CPUTYPE_040,%d1
677 bset #CPUTYPE_0460,%d1
681 * Test the BootInfo cputype for 020
685 bset #CPUTYPE_020,%d1
689 * Record the cpu type
691 lea %pc@(L(cputype)),%a0
697 * Now the macros are valid:
706 * Determine the cache mode for pages holding MMU tables
707 * and for supervisor mode, unused for '020 and '030
712 is_not_040_or_060(L(save_cachetype))
716 * d1 := cacheable write-through
717 * NOTE: The 68040 manual strongly recommends non-cached for MMU tables,
718 * but we have been using write-through since at least 2.0.29 so I
721 #ifdef CONFIG_060_WRITETHROUGH
723 * If this is a 68060 board using drivers with cache coherency
724 * problems, then supervisor memory accesses need to be write-through
725 * also; otherwise, we want copyback.
729 movel #_PAGE_CACHE040W,%d0
730 jra L(save_cachetype)
731 #endif /* CONFIG_060_WRITETHROUGH */
733 movew #_PAGE_CACHE040,%d0
735 movel #_PAGE_CACHE040W,%d1
738 /* Save cache mode for supervisor mode and page tables
740 lea %pc@(SYMBOL_NAME(m68k_supervisor_cachemode)),%a0
742 lea %pc@(SYMBOL_NAME(m68k_pgtable_cachemode)),%a0
746 * raise interrupt level
751 If running on an Atari, determine the I/O base of the
752 serial port and test if we are running on a Medusa or Hades.
753 This test is necessary here, because on the Hades the serial
754 port is only accessible in the high I/O memory area.
756 The test whether it is a Medusa is done by writing to the byte at
757 phys. 0x0. This should result in a bus error on all other machines.
759 ...should, but doesn't. The Afterburner040 for the Falcon has the
760 same behaviour (0x0..0x7 are no ROM shadow). So we have to do
761 another test to distinguish Medusa and AB040. This is a
762 read attempt for 0x00ff82fe phys. that should bus error on a Falcon
763 (+AB040), but is in the range where the Medusa always asserts DTACK.
765 The test for the Hades is done by reading address 0xb0000000. This
766 should give a bus error on the Medusa.
770 is_not_atari(L(notypetest))
772 /* get special machine type (Medusa/Hades/AB40) */
773 moveq #0,%d3 /* default if tag doesn't exist */
774 get_bi_record BI_ATARI_MCH_TYPE
778 lea %pc@(SYMBOL_NAME(atari_mch_type)),%a0
781 /* On the Hades, the iobase must be set up before opening the
782 * serial port. There are no I/O regs at 0x00ffxxxx at all. */
784 cmpl #ATARI_MACH_HADES,%d3
786 movel #0xff000000,%d0 /* Hades I/O base addr: 0xff000000 */
787 1: lea %pc@(L(iobase)),%a0
794 * Initialize serial port
805 #ifdef CONSOLE_PENGUIN
806 jbsr L(console_put_penguin)
807 #endif /* CONSOLE_PENGUIN */
808 jbsr L(console_put_stats)
811 #endif /* CONFIG_MAC */
816 dputn %pc@(L(cputype))
817 dputn %pc@(SYMBOL_NAME(m68k_supervisor_cachemode))
818 dputn %pc@(SYMBOL_NAME(m68k_pgtable_cachemode))
822 * Save physical start address of kernel
824 lea %pc@(L(phys_kernel_start)),%a0
825 lea %pc@(SYMBOL_NAME(_stext)),%a1
826 subl #SYMBOL_NAME(_stext),%a1
836 * This block of code does what's necessary to map in the various kinds
837 * of machines for execution of Linux.
838 * First map the first 4 MB of kernel code & data
841 mmu_map #0,%pc@(L(phys_kernel_start)),#4*1024*1024,\
842 %pc@(SYMBOL_NAME(m68k_supervisor_cachemode))
850 is_not_amiga(L(mmu_init_not_amiga))
857 is_not_040_or_060(1f)
860 * 040: Map the 16Meg range physical 0x0 upto logical 0x8000.0000
862 mmu_map #0x80000000,#0,#0x01000000,#_PAGE_NOCACHE_S
864 jbra L(mmu_init_done)
868 * 030: Map the 32Meg range physical 0x0 upto logical 0x8000.0000
870 mmu_map #0x80000000,#0,#0x02000000,#_PAGE_NOCACHE030
872 jbra L(mmu_init_done)
874 L(mmu_init_not_amiga):
881 is_not_atari(L(mmu_init_not_atari))
885 /* On the Atari, we map the I/O region (phys. 0x00ffxxxx) by mapping
886 the last 16 MB of virtual address space to the first 16 MB (i.e.
887 0xffxxxxxx -> 0x00xxxxxx). For this, an additional pointer table is
888 needed. I/O ranges are marked non-cachable.
890 For the Medusa it is better to map the I/O region transparently
891 (i.e. 0xffxxxxxx -> 0xffxxxxxx), because some I/O registers are
892 accessible only in the high area.
894 On the Hades all I/O registers are only accessible in the high
898 /* I/O base addr for non-Medusa, non-Hades: 0x00000000 */
900 movel %pc@(SYMBOL_NAME(atari_mch_type)),%d3
901 cmpl #ATARI_MACH_MEDUSA,%d3
903 cmpl #ATARI_MACH_HADES,%d3
905 2: movel #0xff000000,%d0 /* Medusa/Hades base addr: 0xff000000 */
908 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
916 mmu_map #0xff000000,%d3,#0x01000000,#_PAGE_NOCACHE030
918 jbra L(mmu_init_done)
922 mmu_map #0xff000000,%d3,#0x01000000,#_PAGE_NOCACHE_S
924 jbra L(mmu_init_done)
926 L(mmu_init_not_atari):
930 is_not_hp300(L(nothp300))
932 /* On the HP300, we map the ROM, INTIO and DIO regions (phys. 0x00xxxxxx)
933 by mapping 32MB from 0xf0xxxxxx -> 0x00xxxxxx) using an 030 early
934 termination page descriptor. The ROM mapping is needed because the LEDs
935 are mapped there too. */
937 mmu_map #0xf0000000,#0,#0x02000000,#_PAGE_NOCACHE030
943 #ifdef CONFIG_MVME16x
945 is_not_mvme16x(L(not16x))
947 /* Get pointer to board ID data */
950 .word 0x70 /* trap 0x70 - .BRD_ID */
952 lea %pc@(SYMBOL_NAME(mvme_bdid_ptr)),%a0
956 * On MVME16x we have already created kernel page tables for
957 * 4MB of RAM at address 0, so now need to do a transparent
958 * mapping of the top of memory space. Make it 0.5GByte for now.
959 * Supervisor only access, so transparent mapping doesn't
960 * clash with User code virtual address space.
961 * this covers IO devices, PROM and SRAM. The PROM and SRAM
962 * mapping is needed to allow 167Bug to run.
963 * IO is in the range 0xfff00000 to 0xfffeffff.
964 * PROM is 0xff800000->0xffbfffff and SRAM is
965 * 0xffe00000->0xffe1ffff.
968 mmu_map_tt 1,#0xe0000000,#0x20000000,#_PAGE_NOCACHE_S
970 jbra L(mmu_init_done)
973 #endif /* CONFIG_MVME162 | CONFIG_MVME167 */
975 #ifdef CONFIG_BVME6000
977 is_not_bvme6000(L(not6000))
980 * On BVME6000 we have already created kernel page tables for
981 * 4MB of RAM at address 0, so now need to do a transparent
982 * mapping of the top of memory space. Make it 0.5GByte for now,
983 * so we can access on-board i/o areas.
984 * Supervisor only access, so transparent mapping doesn't
985 * clash with User code virtual address space.
988 mmu_map_tt 1,#0xe0000000,#0x20000000,#_PAGE_NOCACHE_S
990 jbra L(mmu_init_done)
993 #endif /* CONFIG_BVME6000 */
998 * The Macintosh mappings are less clear.
1000 * Even as of this writing, it is unclear how the
1001 * Macintosh mappings will be done. However, as
1002 * the first author of this code I'm proposing the
1005 * Map the kernel (that's already done),
1006 * Map the I/O (on most machines that's the
1007 * 0x5000.0000 ... 0x5200.0000 range,
1008 * Map the video frame buffer using as few pages
1009 * as absolutely (this requirement mostly stems from
1010 * the fact that when the frame buffer is at
1011 * 0x0000.0000 then we know there is valid RAM just
1012 * above the screen that we don't want to waste!).
1014 * By the way, if the frame buffer is at 0x0000.0000
1015 * then the Macintosh is known as an RBV based Mac.
1017 * By the way 2, the code currently maps in a bunch of
1018 * regions. But I'd like to cut that out. (And move most
1019 * of the mappings up into the kernel proper ... or only
1020 * map what's necessary.)
1027 is_not_mac(L(mmu_init_not_mac))
1031 lea %pc@(L(mac_videobase)),%a0
1032 lea %pc@(L(console_video_virtual)),%a1
1035 is_not_040_or_060(1f)
1037 moveq #_PAGE_NOCACHE_S,%d3
1040 moveq #_PAGE_NOCACHE030,%d3
1043 * Mac Note: screen address of logical 0xF000.0000 -> <screen physical>
1044 * we simply map the 4MB that contains the videomem
1047 movel #VIDEOMEMMASK,%d0
1048 andl L(mac_videobase),%d0
1050 mmu_map #VIDEOMEMBASE,%d0,#VIDEOMEMSIZE,%d3
1051 mmu_map_eq #0x40800000,#0x02000000,%d3 /* rom ? */
1052 mmu_map_eq #0x50000000,#0x02000000,%d3
1053 mmu_map_eq #0x60000000,#0x00400000,%d3
1054 mmu_map_eq #0x9c000000,#0x00400000,%d3
1055 mmu_map_tt 1,#0xf8000000,#0x08000000,%d3
1057 jbra L(mmu_init_done)
1059 L(mmu_init_not_mac):
1070 * On the 040 class machines, all pages that are used for the
1071 * mmu have to be fixed up. According to Motorola, pages holding mmu
1072 * tables should be non-cacheable on a '040 and write-through on a
1073 * '060. But analysis of the reasons for this, and practical
1074 * experience, showed that write-through also works on a '040.
1076 * Allocated memory so far goes from kernel_end to memory_start that
1077 * is used for all kind of tables, for that the cache attributes
1082 is_not_040_or_060(L(mmu_fixup_done))
1084 #ifdef MMU_NOCACHE_KERNEL
1085 jbra L(mmu_fixup_done)
1088 /* first fix the page at the start of the kernel, that
1089 * contains also kernel_pg_dir.
1091 movel %pc@(L(phys_kernel_start)),%d0
1092 lea %pc@(SYMBOL_NAME(_stext)),%a0
1094 mmu_fixup_page_mmu_cache %a0
1096 movel %pc@(L(kernel_end)),%a0
1098 movel %pc@(L(memory_start)),%a1
1102 mmu_fixup_page_mmu_cache %a0
1117 * This chunk of code performs the gruesome task of engaging the MMU.
1118 * The reason its gruesome is because when the MMU becomes engaged it
1119 * maps logical addresses to physical addresses. The Program Counter
1120 * register is then passed through the MMU before the next instruction
1121 * is fetched (the instruction following the engage MMU instruction).
1122 * This may mean one of two things:
1123 * 1. The Program Counter falls within the logical address space of
1124 * the kernel of which there are two sub-possibilities:
1125 * A. The PC maps to the correct instruction (logical PC == physical
1126 * code location), or
1127 * B. The PC does not map through and the processor will read some
1128 * data (or instruction) which is not the logically next instr.
1129 * As you can imagine, A is good and B is bad.
1131 * 2. The Program Counter does not map through the MMU. The processor
1132 * will take a Bus Error.
1133 * Clearly, 2 is bad.
1134 * It doesn't take a wiz kid to figure you want 1.A.
1135 * This code creates that possibility.
1136 * There are two possible 1.A. states (we now ignore the other above states):
1137 * A. The kernel is located at physical memory addressed the same as
1138 * the logical memory for the kernel, i.e., 0x01000.
1139 * B. The kernel is located some where else. e.g., 0x0400.0000
1141 * Under some conditions the Macintosh can look like A or B.
1142 * [A friend and I once noted that Apple hardware engineers should be
1143 * wacked twice each day: once when they show up at work (as in, Whack!,
1144 * "This is for the screwy hardware we know you're going to design today."),
1145 * and also at the end of the day (as in, Whack! "I don't know what
1146 * you designed today, but I'm sure it wasn't good."). -- rst]
1148 * This code works on the following premise:
1149 * If the kernel start (%d5) is within the first 16 Meg of RAM,
1150 * then create a mapping for the kernel at logical 0x8000.0000 to
1151 * the physical location of the pc. And, create a transparent
1152 * translation register for the first 16 Meg. Then, after the MMU
1153 * is engaged, the PC can be moved up into the 0x8000.0000 range
1154 * and then the transparent translation can be turned off and then
1155 * the PC can jump to the correct logical location and it will be
1156 * home (finally). This is essentially the code that the Amiga used
1157 * to use. Now, it's generalized for all processors. Which means
1158 * that a fresh (but temporary) mapping has to be created. The mapping
1159 * is made in page 0 (an as of yet unused location -- except for the
1160 * stack!). This temporary mapping will only require 1 pointer table
1161 * and a single page table (it can map 256K).
1163 * OK, alternatively, imagine that the Program Counter is not within
1164 * the first 16 Meg. Then, just use Transparent Translation registers
1165 * to do the right thing.
1167 * Last, if _start is already at 0x01000, then there's nothing special
1168 * to do (in other words, in a degenerate case of the first case above,
1182 /* fixup the Amiga custom register location before printing */
1189 /* fixup the Atari iobase register location before printing */
1190 movel #0xff000000,L(iobase)
1196 movel #~VIDEOMEMMASK,%d0
1197 andl L(mac_videobase),%d0
1198 addl #VIDEOMEMBASE,%d0
1199 movel %d0,L(mac_videobase)
1206 * Fix up the custom register to point to the new location of the LEDs.
1208 movel #0xf0000000,L(custom)
1211 * Energise the FPU and caches.
1213 movel #0x60,0xf05f400c
1218 * Fixup the addresses for the kernel pointer table and availmem.
1219 * Convert them from physical addresses to virtual addresses.
1225 /* do the same conversion on the first available memory
1228 movel L(memory_start),%d0
1229 movel %d0,SYMBOL_NAME(availmem)
1235 is_not_040_or_060(L(cache_not_680460))
1243 is_060(L(cache68060))
1245 movel #CC6_ENABLE_D+CC6_ENABLE_I,%d0
1246 /* MMU stuff works in copyback mode now, so enable the cache */
1251 movel #CC6_ENABLE_D+CC6_ENABLE_I+CC6_ENABLE_SB+CC6_PUSH_DPI+CC6_ENABLE_B+CC6_CLRA_B,%d0
1252 /* MMU stuff works in copyback mode now, so enable the cache */
1254 /* enable superscalar dispatch in PCR */
1260 L(cache_not_680460):
1263 movel #CC3_ENABLE_DB+CC3_CLR_D+CC3_ENABLE_D+CC3_ENABLE_IB+CC3_CLR_I+CC3_ENABLE_I,%d0
1273 * Setup initial stack pointer
1275 lea SYMBOL_NAME(init_task_union),%a2
1278 /* jump to the kernel start */
1282 subl %a6,%a6 /* clear a6 for gdb */
1283 jbsr SYMBOL_NAME(start_kernel)
1286 * Find a tag record in the bootinfo structure
1287 * The bootinfo structure is located right after the kernel bss
1288 * Returns: d0: size (-1 if not found)
1289 * a0: data pointer (end-of-records if not found)
1291 func_start get_bi_record,%d1
1294 lea %pc@(SYMBOL_NAME(_end)),%a0
1295 1: tstw %a0@(BIR_TAG)
1297 cmpw %a0@(BIR_TAG),%d0
1299 addw %a0@(BIR_SIZE),%a0
1302 movew %a0@(BIR_SIZE),%d0
1303 lea %a0@(BIR_DATA),%a0
1306 lea %a0@(BIR_SIZE),%a0
1308 func_return get_bi_record
1312 * MMU Initialization Begins Here
1314 * The structure of the MMU tables on the 68k machines
1317 * Logical addresses are translated through
1318 * a hierarchical translation mechanism where the high-order
1319 * seven bits of the logical address (LA) are used as an
1320 * index into the "root table." Each entry in the root
1321 * table has a bit which specifies if it's a valid pointer to a
1322 * pointer table. Each entry defines a 32KMeg range of memory.
1323 * If an entry is invalid then that logical range of 32M is
1324 * invalid and references to that range of memory (when the MMU
1325 * is enabled) will fault. If the entry is valid, then it does
1326 * one of two things. On 040/060 class machines, it points to
1327 * a pointer table which then describes more finely the memory
1328 * within that 32M range. On 020/030 class machines, a technique
1329 * called "early terminating descriptors" are used. This technique
1330 * allows an entire 32Meg to be described by a single entry in the
1331 * root table. Thus, this entry in the root table, contains the
1332 * physical address of the memory or I/O at the logical address
1333 * which the entry represents and it also contains the necessary
1334 * cache bits for this region.
1337 * Per the Root Table, there will be one or more
1338 * pointer tables. Each pointer table defines a 32M range.
1339 * Not all of the 32M range need be defined. Again, the next
1340 * seven bits of the logical address are used an index into
1341 * the pointer table to point to page tables (if the pointer
1342 * is valid). There will undoubtedly be more than one
1343 * pointer table for the kernel because each pointer table
1344 * defines a range of only 32M. Valid pointer table entries
1345 * point to page tables, or are early terminating entries
1349 * Per the Pointer Tables, each page table entry points
1350 * to the physical page in memory that supports the logical
1351 * address that translates to the particular index.
1353 * In short, the Logical Address gets translated as follows:
1354 * bits 31..26 - index into the Root Table
1355 * bits 25..18 - index into the Pointer Table
1356 * bits 17..12 - index into the Page Table
1357 * bits 11..0 - offset into a particular 4K page
1359 * The algorithms which follows do one thing: they abstract
1360 * the MMU hardware. For example, there are three kinds of
1361 * cache settings that are relevant. Either, memory is
1362 * being mapped in which case it is either Kernel Code (or
1363 * the RamDisk) or it is MMU data. On the 030, the MMU data
1364 * option also describes the kernel. Or, I/O is being mapped
1365 * in which case it has its own kind of cache bits. There
1366 * are constants which abstract these notions from the code that
1367 * actually makes the call to map some range of memory.
1377 * This algorithm will print out the current MMU mappings.
1380 * %a5 points to the root table. Everything else is calculated
1384 #define mmu_next_valid 0
1385 #define mmu_start_logical 4
1386 #define mmu_next_logical 8
1387 #define mmu_start_physical 12
1388 #define mmu_next_physical 16
1390 #define MMU_PRINT_INVALID -1
1391 #define MMU_PRINT_VALID 1
1392 #define MMU_PRINT_UNINITED 0
1394 #define putZc(z,n) jbne 1f; putc z; jbra 2f; 1: putc n; 2:
1396 func_start mmu_print,%a0-%a6/%d0-%d7
1398 movel %pc@(L(kernel_pgdir_ptr)),%a5
1399 lea %pc@(L(mmu_print_data)),%a0
1400 movel #MMU_PRINT_UNINITED,%a0@(mmu_next_valid)
1402 is_not_040_or_060(mmu_030_print)
1411 * The following #if/#endif block is a tight algorithm for dumping the 040
1412 * MMU Map in gory detail. It really isn't that practical unless the
1413 * MMU Map algorithm appears to go awry and you need to debug it at the
1414 * entry per entry level.
1416 movel #ROOT_TABLE_SIZE,%d5
1418 movel %a5@+,%d7 | Burn an entry to skip the kernel mappings,
1419 subql #1,%d5 | they (might) work
1429 andil #0xFFFFFE00,%d7
1431 movel #PTR_TABLE_SIZE,%d4
1441 andil #0xFFFFFF00,%d7
1443 movel #PAGE_TABLE_SIZE,%d3
1457 movel #8+1+8+1+1,%d2
1472 #endif /* MMU 040 Dumping code that's gory and detailed */
1474 lea %pc@(SYMBOL_NAME(kernel_pg_dir)),%a5
1475 movel %a5,%a0 /* a0 has the address of the root table ptr */
1476 movel #0x00000000,%a4 /* logical address */
1479 /* Increment the logical address and preserve in d5 */
1481 addil #PAGESIZE<<13,%d5
1485 jbsr mmu_print_tuple_invalidate
1489 andil #0xfffffe00,%d6
1493 addil #PAGESIZE<<6,%d5
1497 jbsr mmu_print_tuple_invalidate
1501 andil #0xffffff00,%d6
1509 jbsr mmu_print_tuple_invalidate
1512 moveml %d0-%d1,%sp@-
1515 andil #0xfffff4e0,%d1
1516 lea %pc@(mmu_040_print_flags),%a6
1517 jbsr mmu_print_tuple
1518 moveml %sp@+,%d0-%d1
1530 movel %d5,%a4 /* move to the next logical address */
1538 andiw #0x8000,%d1 /* is it valid ? */
1539 jbeq 1f /* No, bail out */
1542 andil #0xff000000,%d1 /* Get the address */
1548 jbsr mmu_040_print_flags_tt
1552 andiw #0x8000,%d1 /* is it valid ? */
1553 jbeq 1f /* No, bail out */
1556 andil #0xff000000,%d1 /* Get the address */
1562 jbsr mmu_040_print_flags_tt
1568 mmu_040_print_flags:
1570 putZc(' ','G') /* global bit */
1572 putZc(' ','S') /* supervisor bit */
1573 mmu_040_print_flags_tt:
1578 putZc('w','c') /* write through or copy-back */
1583 putZc('s',' ') /* serialized non-cacheable, or non-cacheable */
1587 mmu_030_print_flags:
1589 putZc('C','I') /* write through or copy-back */
1598 andil #0xfffffff0,%d0
1600 movel #0x00000000,%a4 /* logical address */
1604 addil #PAGESIZE<<13,%d5
1606 btst #1,%d6 /* is it a ptr? */
1608 btst #0,%d6 /* is it early terminating? */
1610 jbsr mmu_030_print_helper
1613 jbsr mmu_print_tuple_invalidate
1617 andil #0xfffffff0,%d6
1621 addil #PAGESIZE<<6,%d5
1627 jbsr mmu_030_print_helper
1630 jbsr mmu_print_tuple_invalidate
1634 andil #0xfffffff0,%d6
1642 jbsr mmu_print_tuple_invalidate
1645 jbsr mmu_030_print_helper
1657 movel %d5,%a4 /* move to the next logical address */
1665 func_return mmu_print
1668 mmu_030_print_helper:
1669 moveml %d0-%d1,%sp@-
1672 lea %pc@(mmu_030_print_flags),%a6
1673 jbsr mmu_print_tuple
1674 moveml %sp@+,%d0-%d1
1677 mmu_print_tuple_invalidate:
1678 moveml %a0/%d7,%sp@-
1680 lea %pc@(L(mmu_print_data)),%a0
1681 tstl %a0@(mmu_next_valid)
1682 jbmi mmu_print_tuple_invalidate_exit
1684 movel #MMU_PRINT_INVALID,%a0@(mmu_next_valid)
1690 mmu_print_tuple_invalidate_exit:
1691 moveml %sp@+,%a0/%d7
1696 moveml %d0-%d7/%a0,%sp@-
1698 lea %pc@(L(mmu_print_data)),%a0
1700 tstl %a0@(mmu_next_valid)
1701 jble mmu_print_tuple_print
1703 cmpl %a0@(mmu_next_physical),%d1
1704 jbeq mmu_print_tuple_increment
1706 mmu_print_tuple_print:
1714 mmu_print_tuple_record:
1715 movel #MMU_PRINT_VALID,%a0@(mmu_next_valid)
1717 movel %d1,%a0@(mmu_next_physical)
1719 mmu_print_tuple_increment:
1722 addl %d7,%a0@(mmu_next_physical)
1724 mmu_print_tuple_exit:
1725 moveml %sp@+,%d0-%d7/%a0
1728 mmu_print_machine_cpu_types:
1750 is_not_040_or_060(2f)
1758 #endif /* MMU_PRINT */
1763 * This is a specific function which works on all 680x0 machines.
1764 * On 030, 040 & 060 it will attempt to use Transparent Translation
1766 * On 020 it will call the standard mmu_map which will use early
1767 * terminating descriptors.
1769 func_start mmu_map_tt,%d0/%d1/%a0,4
1780 /* Extract the highest bit set
1782 bfffo ARG3{#0,#32},%d1
1798 /* Generate the upper 16bit of the tt register
1804 is_040_or_060(L(mmu_map_tt_040))
1806 /* set 030 specific bits (read/write access for supervisor mode
1807 * (highest function code set, lower two bits masked))
1809 orw #TTR_ENABLE+TTR_RWM+TTR_FCB2+TTR_FCM1+TTR_FCM0,%d1
1825 jra L(mmu_map_tt_done)
1827 /* set 040 specific bits
1830 orw #TTR_ENABLE+TTR_KERNELMODE,%d1
1844 jra L(mmu_map_tt_done)
1847 mmu_map_eq ARG2,ARG3,ARG4
1851 func_return mmu_map_tt
1856 * This routine will map a range of memory using a pointer
1857 * table and allocating the pages on the fly from the kernel.
1858 * The pointer table does not have to be already linked into
1859 * the root table, this routine will do that if necessary.
1862 * This routine will assert failure and use the serial_putc
1863 * routines in the case of a run-time error. For example,
1864 * if the address is already mapped.
1867 * This routine will use early terminating descriptors
1868 * where possible for the 68020+68851 and 68030 type
1871 func_start mmu_map,%d0-%d4/%a0-%a4
1880 /* Get logical address and round it down to 256KB
1883 andl #-(PAGESIZE*PAGE_TABLE_SIZE),%d0
1886 /* Get the end address
1892 /* Get physical address and round it down to 256KB
1895 andl #-(PAGESIZE*PAGE_TABLE_SIZE),%d0
1898 /* Add page attributes to the physical address
1901 orw #_PAGE_PRESENT+_PAGE_ACCESSED+_PAGE_DIRTY,%d0
1908 is_not_040_or_060(L(mmu_map_030))
1910 addw #_PAGE_GLOBAL040,%a2
1912 * MMU 040 & 060 Support
1914 * The MMU usage for the 040 and 060 is different enough from
1915 * the 030 and 68851 that there is separate code. This comment
1916 * block describes the data structures and algorithms built by
1919 * The 040 does not support early terminating descriptors, as
1920 * the 030 does. Therefore, a third level of table is needed
1921 * for the 040, and that would be the page table. In Linux,
1922 * page tables are allocated directly from the memory above the
1928 /* Calculate the offset into the root table
1931 moveq #ROOT_INDEX_SHIFT,%d1
1933 mmu_get_root_table_entry %d0
1935 /* Calculate the offset into the pointer table
1938 moveq #PTR_INDEX_SHIFT,%d1
1940 andl #PTR_TABLE_SIZE-1,%d0
1941 mmu_get_ptr_table_entry %a0,%d0
1943 /* Calculate the offset into the page table
1946 moveq #PAGE_INDEX_SHIFT,%d1
1948 andl #PAGE_TABLE_SIZE-1,%d0
1949 mmu_get_page_table_entry %a0,%d0
1951 /* The page table entry must not no be busy
1954 jne L(mmu_map_error)
1956 /* Do the mapping and advance the pointers
1963 /* Ready with mapping?
1971 /* Calculate the offset into the root table
1974 moveq #ROOT_INDEX_SHIFT,%d1
1976 mmu_get_root_table_entry %d0
1978 /* Check if logical address 32MB aligned,
1979 * so we can try to map it once
1982 andl #(PTR_TABLE_SIZE*PAGE_TABLE_SIZE*PAGESIZE-1)&(-ROOT_TABLE_SIZE),%d0
1985 /* Is there enough to map for 32MB at once
1987 lea %a3@(PTR_TABLE_SIZE*PAGE_TABLE_SIZE*PAGESIZE-1),%a1
1993 /* The root table entry must not no be busy
1996 jne L(mmu_map_error)
1998 /* Do the mapping and advance the pointers
2008 lea %a2@(PTR_TABLE_SIZE*PAGE_TABLE_SIZE*PAGESIZE),%a2
2009 jra L(mmu_mapnext_030)
2011 /* Calculate the offset into the pointer table
2014 moveq #PTR_INDEX_SHIFT,%d1
2016 andl #PTR_TABLE_SIZE-1,%d0
2017 mmu_get_ptr_table_entry %a0,%d0
2019 /* The pointer table entry must not no be busy
2022 jne L(mmu_map_error)
2024 /* Do the mapping and advance the pointers
2032 addl #PAGE_TABLE_SIZE*PAGESIZE,%a2
2033 addl #PAGE_TABLE_SIZE*PAGESIZE,%a3
2036 /* Ready with mapping?
2045 dputs "mmu_map error:"
2057 * On the 040 class machines, all pages that are used for the
2058 * mmu have to be fixed up.
2061 func_start mmu_fixup_page_mmu_cache,%d0/%a0
2063 dputs "mmu_fixup_page_mmu_cache"
2066 /* Calculate the offset into the root table
2069 moveq #ROOT_INDEX_SHIFT,%d1
2071 mmu_get_root_table_entry %d0
2073 /* Calculate the offset into the pointer table
2076 moveq #PTR_INDEX_SHIFT,%d1
2078 andl #PTR_TABLE_SIZE-1,%d0
2079 mmu_get_ptr_table_entry %a0,%d0
2081 /* Calculate the offset into the page table
2084 moveq #PAGE_INDEX_SHIFT,%d1
2086 andl #PAGE_TABLE_SIZE-1,%d0
2087 mmu_get_page_table_entry %a0,%d0
2090 andil #_CACHEMASK040,%d0
2091 orl %pc@(SYMBOL_NAME(m68k_pgtable_cachemode)),%d0
2096 func_return mmu_fixup_page_mmu_cache
2101 * create a temporary mapping to enable the mmu,
2102 * this we don't need any transparation translation tricks.
2105 func_start mmu_temp_map,%d0/%d1/%a0/%a1
2107 dputs "mmu_temp_map"
2112 lea %pc@(L(temp_mmap_mem)),%a1
2114 /* Calculate the offset in the root table
2117 moveq #ROOT_INDEX_SHIFT,%d1
2119 mmu_get_root_table_entry %d0
2121 /* Check if the table is temporary allocated, so we have to reuse it
2124 cmpl %pc@(L(memory_start)),%d0
2127 /* Temporary allocate a ptr table and insert it into the root table
2130 addl #PTR_TABLE_SIZE*4,%a1@
2131 orw #_PAGE_TABLE+_PAGE_ACCESSED,%d0
2136 /* Mask the root table entry for the ptr table
2138 andw #-ROOT_TABLE_SIZE,%d0
2141 /* Calculate the offset into the pointer table
2144 moveq #PTR_INDEX_SHIFT,%d1
2146 andl #PTR_TABLE_SIZE-1,%d0
2150 /* Check if a temporary page table is already allocated
2155 /* Temporary allocate a page table and insert it into the ptr table
2158 addl #PTR_TABLE_SIZE*4,%a1@
2159 orw #_PAGE_TABLE+_PAGE_ACCESSED,%d0
2164 /* Mask the ptr table entry for the page table
2166 andw #-PTR_TABLE_SIZE,%d0
2169 /* Calculate the offset into the page table
2172 moveq #PAGE_INDEX_SHIFT,%d1
2174 andl #PAGE_TABLE_SIZE-1,%d0
2178 /* Insert the address into the page table
2182 orw #_PAGE_PRESENT+_PAGE_ACCESSED+_PAGE_DIRTY,%d0
2188 func_return mmu_temp_map
2190 func_start mmu_engage,%d0-%d2/%a0-%a3
2192 moveq #ROOT_TABLE_SIZE-1,%d0
2193 /* Temporarily use a different root table. */
2194 lea %pc@(L(kernel_pgdir_ptr)),%a0
2196 movel %pc@(L(memory_start)),%a1
2203 lea %pc@(L(temp_mmap_mem)),%a0
2206 movew #PAGESIZE-1,%d0
2213 /* Skip temp mappings if phys == virt */
2217 mmu_temp_map %a0,%a0
2218 mmu_temp_map %a0,%a1
2222 mmu_temp_map %a0,%a0
2223 mmu_temp_map %a0,%a1
2225 movel %pc@(L(memory_start)),%a3
2226 movel %pc@(L(phys_kernel_start)),%d2
2228 is_not_040_or_060(L(mmu_engage_030))
2238 movel #TC_ENABLE+TC_PAGE4K,%d0
2239 movec %d0,%tc /* enable the MMU */
2248 jra L(mmu_engage_cleanup)
2250 L(mmu_engage_030_temp):
2254 lea %pc@(L(mmu_engage_030_temp)),%a0
2255 movel #0x80000002,%a0@
2262 * enable,super root enable,4096 byte pages,7 bit root index,
2263 * 7 bit pointer index, 6 bit page table index.
2265 movel #0x82c07760,%a0@(8)
2266 pmove %a0@(8),%tc /* enable the MMU */
2268 1: movel %a2,%a0@(4)
2275 L(mmu_engage_cleanup):
2277 movel %a2,L(kernel_pgdir_ptr)
2281 subl %d2,L(memory_start)
2283 func_return mmu_engage
2285 func_start mmu_get_root_table_entry,%d0/%a1
2288 dputs "mmu_get_root_table_entry:"
2293 movel %pc@(L(kernel_pgdir_ptr)),%a0
2299 /* Find the start of free memory, get_bi_record does this for us,
2300 * as the bootinfo structure is located directly behind the kernel
2301 * and and we simply search for the last entry.
2303 get_bi_record BI_LAST
2304 addw #PAGESIZE-1,%a0
2310 lea %pc@(L(memory_start)),%a0
2312 lea %pc@(L(kernel_end)),%a0
2315 /* we have to return the first page at _stext since the init code
2316 * in mm/init.c simply expects kernel_pg_dir there, the rest of
2317 * page is used for further ptr tables in get_ptr_table.
2319 lea %pc@(SYMBOL_NAME(_stext)),%a0
2320 lea %pc@(L(mmu_cached_pointer_tables)),%a1
2322 addl #ROOT_TABLE_SIZE*4,%a1@
2324 lea %pc@(L(mmu_num_pointer_tables)),%a1
2330 movew #PAGESIZE/4-1,%d0
2335 lea %pc@(L(kernel_pgdir_ptr)),%a1
2349 func_return mmu_get_root_table_entry
2353 func_start mmu_get_ptr_table_entry,%d0/%a1
2356 dputs "mmu_get_ptr_table_entry:"
2366 /* Keep track of the number of pointer tables we use
2368 dputs "\nmmu_get_new_ptr_table:"
2369 lea %pc@(L(mmu_num_pointer_tables)),%a0
2373 /* See if there is a free pointer table in our cache of pointer tables
2375 lea %pc@(L(mmu_cached_pointer_tables)),%a1
2379 /* Get a new pointer table page from above the kernel memory
2384 /* There is an unused pointer table in our cache... use it
2387 addl #PTR_TABLE_SIZE*4,%a1@
2392 /* Insert the new pointer table into the root table
2395 orw #_PAGE_TABLE+_PAGE_ACCESSED,%d0
2398 /* Extract the pointer table entry
2400 andw #-PTR_TABLE_SIZE,%d0
2410 func_return mmu_get_ptr_table_entry
2413 func_start mmu_get_page_table_entry,%d0/%a1
2416 dputs "mmu_get_page_table_entry:"
2426 /* If the page table entry doesn't exist, we allocate a complete new
2427 * page and use it as one continues big page table which can cover
2428 * 4MB of memory, nearly almost all mappings have that alignment.
2431 addw #_PAGE_TABLE+_PAGE_ACCESSED,%a0
2433 /* align pointer table entry for a page of page tables
2436 andw #-(PAGESIZE/PAGE_TABLE_SIZE),%d0
2439 /* Insert the page tables into the pointer entries
2441 moveq #PAGESIZE/PAGE_TABLE_SIZE/4-1,%d0
2444 lea %a0@(PAGE_TABLE_SIZE*4),%a0
2447 /* Now we can get the initialized pointer table entry
2452 /* Extract the page table entry
2454 andw #-PAGE_TABLE_SIZE,%d0
2464 func_return mmu_get_page_table_entry
2469 * Return a new page from the memory start and clear it.
2471 func_start get_new_page,%d0/%a1
2473 dputs "\nget_new_page:"
2475 /* allocate the page and adjust memory_start
2477 lea %pc@(L(memory_start)),%a0
2481 /* clear the new page
2484 movew #PAGESIZE/4-1,%d0
2492 func_return get_new_page
2497 * Debug output support
2498 * Atarians have a choice between the parallel port, the serial port
2499 * from the MFP or a serial port of the SCC
2504 L(scc_initable_mac):
2505 .byte 9,12 /* Reset */
2506 .byte 4,0x44 /* x16, 1 stopbit, no parity */
2507 .byte 3,0xc0 /* receiver: 8 bpc */
2508 .byte 5,0xe2 /* transmitter: 8 bpc, assert dtr/rts */
2509 .byte 9,0 /* no interrupts */
2510 .byte 10,0 /* NRZ */
2511 .byte 11,0x50 /* use baud rate generator */
2512 .byte 12,10,13,0 /* 9600 baud */
2513 .byte 14,1 /* Baud rate generator enable */
2514 .byte 3,0xc1 /* enable receiver */
2515 .byte 5,0xea /* enable transmitter */
2521 /* #define USE_PRINTER */
2522 /* #define USE_SCC_B */
2523 /* #define USE_SCC_A */
2526 #if defined(USE_SCC_A) || defined(USE_SCC_B)
2528 /* Initialisation table for SCC */
2530 .byte 9,12 /* Reset */
2531 .byte 4,0x44 /* x16, 1 stopbit, no parity */
2532 .byte 3,0xc0 /* receiver: 8 bpc */
2533 .byte 5,0xe2 /* transmitter: 8 bpc, assert dtr/rts */
2534 .byte 9,0 /* no interrupts */
2535 .byte 10,0 /* NRZ */
2536 .byte 11,0x50 /* use baud rate generator */
2537 .byte 12,24,13,0 /* 9600 baud */
2538 .byte 14,2,14,3 /* use master clock for BRG, enable */
2539 .byte 3,0xc1 /* enable receiver */
2540 .byte 5,0xea /* enable transmitter */
2547 LPSG_SELECT = 0xff8800
2548 LPSG_READ = 0xff8800
2549 LPSG_WRITE = 0xff8802
2553 LSTMFP_GPIP = 0xfffa01
2554 LSTMFP_DDR = 0xfffa05
2555 LSTMFP_IERB = 0xfffa09
2557 #elif defined(USE_SCC_B)
2559 LSCC_CTRL = 0xff8c85
2560 LSCC_DATA = 0xff8c87
2562 #elif defined(USE_SCC_A)
2564 LSCC_CTRL = 0xff8c81
2565 LSCC_DATA = 0xff8c83
2567 /* Initialisation table for SCC */
2569 .byte 9,12 /* Reset */
2570 .byte 4,0x44 /* x16, 1 stopbit, no parity */
2571 .byte 3,0xc0 /* receiver: 8 bpc */
2572 .byte 5,0xe2 /* transmitter: 8 bpc, assert dtr/rts */
2573 .byte 9,0 /* no interrupts */
2574 .byte 10,0 /* NRZ */
2575 .byte 11,0x50 /* use baud rate generator */
2576 .byte 12,24,13,0 /* 9600 baud */
2577 .byte 14,2,14,3 /* use master clock for BRG, enable */
2578 .byte 3,0xc1 /* enable receiver */
2579 .byte 5,0xea /* enable transmitter */
2583 #elif defined(USE_MFP)
2586 LMFP_TDCDR = 0xfffa1d
2587 LMFP_TDDR = 0xfffa25
2592 #endif /* CONFIG_ATARI */
2595 * Serial port output support.
2599 * Initialize serial port hardware for 9600/8/1
2601 func_start serial_init,%d0/%d1/%a0/%a1
2603 * Some of the register usage that follows
2605 * a0 = pointer to boot info record
2606 * d0 = boot info offset
2608 * a0 = address of SCC
2609 * a1 = Liobase address/address of scc_initable
2610 * d0 = init data for serial port
2612 * a0 = address of SCC
2613 * a1 = address of scc_initable_mac
2614 * d0 = init data for serial port
2618 #define SERIAL_DTR 7
2619 #define SERIAL_CNTRL CIABBASE+C_PRA
2622 lea %pc@(L(custom)),%a0
2623 movel #-ZTWOBASE,%a0@
2624 bclr #SERIAL_DTR,SERIAL_CNTRL-ZTWOBASE
2625 get_bi_record BI_AMIGA_SERPER
2626 movew %a0@,CUSTOMBASE+C_SERPER-ZTWOBASE
2627 | movew #61,CUSTOMBASE+C_SERPER-ZTWOBASE
2632 movel %pc@(L(iobase)),%a1
2633 #if defined(USE_PRINTER)
2634 bclr #0,%a1@(LSTMFP_IERB)
2635 bclr #0,%a1@(LSTMFP_DDR)
2636 moveb #LPSG_CONTROL,%a1@(LPSG_SELECT)
2637 moveb #0xff,%a1@(LPSG_WRITE)
2638 moveb #LPSG_IO_B,%a1@(LPSG_SELECT)
2639 clrb %a1@(LPSG_WRITE)
2640 moveb #LPSG_IO_A,%a1@(LPSG_SELECT)
2641 moveb %a1@(LPSG_READ),%d0
2643 moveb %d0,%a1@(LPSG_WRITE)
2644 #elif defined(USE_SCC)
2645 lea %a1@(LSCC_CTRL),%a0
2646 lea %pc@(L(scc_initable)),%a1
2653 #elif defined(USE_MFP)
2654 bclr #1,%a1@(LMFP_TSR)
2655 moveb #0x88,%a1@(LMFP_UCR)
2656 andb #0x70,%a1@(LMFP_TDCDR)
2657 moveb #2,%a1@(LMFP_TDDR)
2658 orb #1,%a1@(LMFP_TDCDR)
2659 bset #1,%a1@(LMFP_TSR)
2661 jra L(serial_init_done)
2665 is_not_mac(L(serial_init_not_mac))
2666 #ifdef MAC_SERIAL_DEBUG
2667 #if !defined(MAC_USE_SCC_A) && !defined(MAC_USE_SCC_B)
2668 #define MAC_USE_SCC_B
2670 #define mac_scc_cha_b_ctrl_offset 0x0
2671 #define mac_scc_cha_a_ctrl_offset 0x2
2672 #define mac_scc_cha_b_data_offset 0x4
2673 #define mac_scc_cha_a_data_offset 0x6
2675 #ifdef MAC_USE_SCC_A
2676 /* Initialize channel A */
2677 movel %pc@(L(mac_sccbase)),%a0
2678 lea %pc@(L(scc_initable_mac)),%a1
2681 moveb %d0,%a0@(mac_scc_cha_a_ctrl_offset)
2682 moveb %a1@+,%a0@(mac_scc_cha_a_ctrl_offset)
2685 #endif /* MAC_USE_SCC_A */
2687 #ifdef MAC_USE_SCC_B
2688 /* Initialize channel B */
2689 #ifndef MAC_USE_SCC_A /* Load mac_sccbase only if needed */
2690 movel %pc@(L(mac_sccbase)),%a0
2691 #endif /* MAC_USE_SCC_A */
2692 lea %pc@(L(scc_initable_mac)),%a1
2695 moveb %d0,%a0@(mac_scc_cha_b_ctrl_offset)
2696 moveb %a1@+,%a0@(mac_scc_cha_b_ctrl_offset)
2699 #endif /* MAC_USE_SCC_B */
2700 #endif /* MAC_SERIAL_DEBUG */
2702 jra L(serial_init_done)
2703 L(serial_init_not_mac):
2704 #endif /* CONFIG_MAC */
2706 L(serial_init_done):
2707 func_return serial_init
2710 * Output character on serial port.
2712 func_start serial_putc,%d0/%d1/%a0/%a1
2718 /* A little safe recursion is good for the soul */
2726 movel %pc@(L(custom)),%a0
2727 movew %d0,%a0@(CUSTOMBASE+C_SERDAT)
2728 1: movew %a0@(CUSTOMBASE+C_SERDATR),%d0
2731 jra L(serial_putc_done)
2740 #endif /* CONSOLE */
2742 #ifdef MAC_SERIAL_DEBUG
2744 #ifdef MAC_USE_SCC_A
2745 movel %pc@(L(mac_sccbase)),%a1
2746 3: btst #2,%a1@(mac_scc_cha_a_ctrl_offset)
2748 moveb %d0,%a1@(mac_scc_cha_a_data_offset)
2749 #endif /* MAC_USE_SCC_A */
2751 #ifdef MAC_USE_SCC_B
2752 #ifndef MAC_USE_SCC_A /* Load mac_sccbase only if needed */
2753 movel %pc@(L(mac_sccbase)),%a1
2754 #endif /* MAC_USE_SCC_A */
2755 4: btst #2,%a1@(mac_scc_cha_b_ctrl_offset)
2757 moveb %d0,%a1@(mac_scc_cha_b_data_offset)
2758 #endif /* MAC_USE_SCC_B */
2760 #endif /* MAC_SERIAL_DEBUG */
2762 jra L(serial_putc_done)
2764 #endif /* CONFIG_MAC */
2768 movel %pc@(L(iobase)),%a1
2769 #if defined(USE_PRINTER)
2770 3: btst #0,%a1@(LSTMFP_GPIP)
2772 moveb #LPSG_IO_B,%a1@(LPSG_SELECT)
2773 moveb %d0,%a1@(LPSG_WRITE)
2774 moveb #LPSG_IO_A,%a1@(LPSG_SELECT)
2775 moveb %a1@(LPSG_READ),%d0
2777 moveb %d0,%a1@(LPSG_WRITE)
2781 moveb %d0,%a1@(LPSG_WRITE)
2782 #elif defined(USE_SCC)
2783 3: btst #2,%a1@(LSCC_CTRL)
2785 moveb %d0,%a1@(LSCC_DATA)
2786 #elif defined(USE_MFP)
2787 3: btst #7,%a1@(LMFP_TSR)
2789 moveb %d0,%a1@(LMFP_UDR)
2791 jra L(serial_putc_done)
2793 #endif /* CONFIG_ATARI */
2795 #ifdef CONFIG_MVME16x
2798 * The VME 16x class has PROM support for serial output
2799 * of some kind; the TRAP table is still valid.
2801 moveml %d0-%d7/%a2-%a6,%sp@-
2804 .word 0x0020 /* TRAP 0x020 */
2805 moveml %sp@+,%d0-%d7/%a2-%a6
2806 jbra L(serial_putc_done)
2808 #endif CONFIG_MVME162 | CONFIG_MVME167
2810 #ifdef CONFIG_BVME6000
2813 * The BVME6000 machine has a serial port ...
2815 1: btst #2,BVME_SCC_CTRL_A
2817 moveb %d0,BVME_SCC_DATA_A
2818 jbra L(serial_putc_done)
2822 L(serial_putc_done):
2823 func_return serial_putc
2828 func_start puts,%d0/%a0
2845 * Output number in hex notation.
2848 func_start putn,%d0-%d2
2860 addb #'A'-('9'+1),%d2
2876 * This routine takes its parameters on the stack. It then
2877 * turns around and calls the internal routine. This routine
2878 * is used until the Linux console driver initializes itself.
2880 * The calling parameters are:
2881 * void mac_serial_print(const char *str);
2883 * This routine does NOT understand variable arguments only
2886 ENTRY(mac_serial_print)
2887 moveml %d0/%a0,%sp@-
2892 movel %sp@(10),%a0 /* fetch parameter */
2900 moveml %sp@+,%d0/%a0
2902 #endif /* CONFIG_MAC */
2905 func_start set_leds,%d0/%a0
2907 movel %pc@(Lcustom),%a0
2908 moveb %d0,%a0@(0x1ffff)
2909 func_return set_leds
2914 * For continuity, see the data alignment
2915 * to which this structure is tied.
2917 #define Lconsole_struct_cur_column 0
2918 #define Lconsole_struct_cur_row 4
2919 #define Lconsole_struct_num_columns 8
2920 #define Lconsole_struct_num_rows 12
2921 #define Lconsole_struct_left_edge 16
2922 #define Lconsole_struct_penguin_putc 20
2926 * Some of the register usage that follows
2927 * a0 = pointer to boot_info
2928 * a1 = pointer to screen
2929 * a2 = pointer to Lconsole_globals
2930 * d3 = pixel width of screen
2931 * d4 = pixel height of screen
2932 * (d3,d4) ~= (x,y) of a point just below
2933 * and to the right of the screen
2934 * NOT on the screen!
2935 * d5 = number of bytes per scan line
2936 * d6 = number of bytes on the entire screen
2938 moveml %a0-%a4/%d0-%d7,%sp@-
2940 lea %pc@(L(console_globals)),%a2
2941 lea %pc@(L(mac_videobase)),%a0
2943 lea %pc@(L(mac_rowbytes)),%a0
2945 lea %pc@(L(mac_dimensions)),%a0
2946 movel %a0@,%d3 /* -> low byte */
2948 swap %d4 /* -> high byte */
2949 andl #0xffff,%d3 /* d3 = screen width in pixels */
2950 andl #0xffff,%d4 /* d4 = screen height in pixels */
2954 mulul %d4,%d6 /* scan line bytes x num scan lines */
2955 divul #8,%d6 /* we'll clear 8 bytes at a time */
2959 movel #0xffffffff,%a1@+ /* Mac_black */
2960 movel #0xffffffff,%a1@+ /* Mac_black */
2961 dbra %d6,console_clear_loop
2963 /* Calculate font size */
2965 #if defined(FONT_8x8)
2966 lea %pc@(SYMBOL_NAME(font_vga_8x8)), %a0
2967 #elif defined(FONT_8x16)
2968 lea %pc@(SYMBOL_NAME(font_vga_8x16)),%a0
2969 #elif defined(FONT_6x11)
2970 lea %pc@(SYMBOL_NAME(font_vga_6x11)),%a0
2971 #else /* (FONT_8x8) default */
2972 lea %pc@(SYMBOL_NAME(font_vga_8x8)), %a0
2976 * At this point we make a shift in register usage
2977 * a1 = address of Lconsole_font pointer
2979 lea %pc@(L(console_font)),%a1
2980 movel %a0,%a1@ /* store pointer to struct fbcon_font_desc in Lconsole_font */
2983 * Calculate global maxs
2984 * Note - we can use either an
2985 * 8 x 16 or 8 x 8 character font
2986 * 6 x 11 also supported
2988 /* ASSERT: a0 = contents of Lconsole_font */
2989 movel %d3,%d0 /* screen width in pixels */
2990 divul %a0@(FBCON_FONT_DESC_WIDTH),%d0 /* d0 = max num chars per row */
2992 movel %d4,%d1 /* screen height in pixels */
2993 divul %a0@(FBCON_FONT_DESC_HEIGHT),%d1 /* d1 = max num rows */
2995 movel %d0,%a2@(Lconsole_struct_num_columns)
2996 movel %d1,%a2@(Lconsole_struct_num_rows)
2999 * Clear the current row and column
3001 clrl %a2@(Lconsole_struct_cur_column)
3002 clrl %a2@(Lconsole_struct_cur_row)
3003 clrl %a2@(Lconsole_struct_left_edge)
3006 * Initialization is complete
3008 moveml %sp@+,%a0-%a4/%d0-%d7
3011 L(console_put_stats):
3013 * Some of the register usage that follows
3014 * a0 = pointer to boot_info
3015 * d7 = value of boot_info fields
3017 moveml %a0/%d7,%sp@-
3019 puts "\nMacLinux\n\n"
3023 putn %pc@(L(mac_videobase)) /* video addr. */
3026 lea %pc@(SYMBOL_NAME(_stext)),%a0
3030 lea %pc@(SYMBOL_NAME(_end)),%a0
3034 putn %pc@(L(cputype))
3037 # if defined(MMU_PRINT)
3038 jbsr mmu_print_machine_cpu_types
3039 # endif /* MMU_PRINT */
3040 #endif /* SERIAL_DEBUG */
3042 moveml %sp@+,%a0/%d7
3045 #ifdef CONSOLE_PENGUIN
3046 L(console_put_penguin):
3048 * Get 'that_penguin' onto the screen in the upper right corner
3049 * penguin is 64 x 74 pixels, align against right edge of screen
3051 moveml %a0-%a1/%d0-%d7,%sp@-
3053 lea %pc@(L(mac_dimensions)),%a0
3056 subil #64,%d0 /* snug up against the right edge */
3057 clrl %d1 /* start at the top */
3059 lea %pc@(SYMBOL_NAME(that_penguin)),%a1
3060 console_penguin_row:
3062 console_penguin_pixel_pair:
3065 jbsr console_plot_pixel
3068 jbsr console_plot_pixel
3070 dbra %d6,console_penguin_pixel_pair
3074 dbra %d7,console_penguin_row
3076 moveml %sp@+,%a0-%a1/%d0-%d7
3081 moveml %a0-%a4/%d0-%d7,%sp@-
3084 * Calculate source and destination addresses
3088 lea %pc@(L(mac_videobase)),%a0
3091 lea %pc@(L(mac_rowbytes)),%a0
3093 movel %pc@(L(console_font)),%a0
3094 mulul %a0@(FBCON_FONT_DESC_HEIGHT),%d5 /* account for # scan lines per character */
3100 lea %pc@(L(mac_dimensions)),%a0
3104 andl #0xffff,%d3 /* d3 = screen width in pixels */
3105 andl #0xffff,%d4 /* d4 = screen height in pixels */
3108 * Calculate number of bytes to move
3110 lea %pc@(L(mac_rowbytes)),%a0
3112 movel %pc@(L(console_font)),%a0
3113 subl %a0@(FBCON_FONT_DESC_HEIGHT),%d4 /* we're not scrolling the top row! */
3114 mulul %d4,%d6 /* scan line bytes x num scan lines */
3115 divul #32,%d6 /* we'll move 8 longs at a time */
3118 console_scroll_loop:
3127 dbra %d6,console_scroll_loop
3129 lea %pc@(L(mac_rowbytes)),%a0
3131 movel %pc@(L(console_font)),%a0
3132 mulul %a0@(FBCON_FONT_DESC_HEIGHT),%d6 /* scan line bytes x font height */
3133 divul #32,%d6 /* we'll move 8 words at a time */
3137 console_scroll_clear_loop:
3146 dbra %d6,console_scroll_clear_loop
3148 moveml %sp@+,%a0-%a4/%d0-%d7
3152 func_start console_putc,%a0/%a1/%d0-%d7
3154 is_not_mac(console_exit)
3156 /* Output character in d7 on console.
3162 /* A little safe recursion is good for the soul */
3165 lea %pc@(L(console_globals)),%a0
3169 movel %a0@(Lconsole_struct_cur_row),%d0
3171 movel %d0,%a0@(Lconsole_struct_cur_row)
3172 movel %a0@(Lconsole_struct_num_rows),%d1
3176 movel %d0,%a0@(Lconsole_struct_cur_row)
3184 clrl %a0@(Lconsole_struct_cur_column)
3189 jne console_not_home
3190 clrl %a0@(Lconsole_struct_cur_row)
3191 clrl %a0@(Lconsole_struct_cur_column)
3195 * At this point we know that the %d7 character is going to be
3196 * rendered on the screen. Register usage is -
3197 * a0 = pointer to console globals
3199 * d0 = cursor column
3200 * d1 = cursor row to draw the character
3201 * d7 = character number
3204 movel %a0@(Lconsole_struct_cur_column),%d0
3205 addil #1,%a0@(Lconsole_struct_cur_column)
3206 movel %a0@(Lconsole_struct_num_columns),%d1
3209 putc '\n' /* recursion is OK! */
3211 movel %a0@(Lconsole_struct_cur_row),%d1
3214 * At this point we make a shift in register usage
3215 * a0 = address of pointer to font data (fbcon_font_desc)
3217 movel %pc@(L(console_font)),%a0
3218 movel %a0@(FBCON_FONT_DESC_DATA),%a1 /* Load fbcon_font_desc.data into a1 */
3219 andl #0x000000ff,%d7
3220 /* ASSERT: a0 = contents of Lconsole_font */
3221 mulul %a0@(FBCON_FONT_DESC_HEIGHT),%d7 /* d7 = index into font data */
3222 addl %d7,%a1 /* a1 = points to char image */
3225 * At this point we make a shift in register usage
3226 * d0 = pixel coordinate, x
3227 * d1 = pixel coordinate, y
3228 * d2 = (bit 0) 1/0 for white/black (!) pixel on screen
3229 * d3 = font scan line data (8 pixels)
3230 * d6 = count down for the font's pixel width (8)
3231 * d7 = count down for the font's pixel count in height
3233 /* ASSERT: a0 = contents of Lconsole_font */
3234 mulul %a0@(FBCON_FONT_DESC_WIDTH),%d0
3235 mulul %a0@(FBCON_FONT_DESC_HEIGHT),%d1
3236 movel %a0@(FBCON_FONT_DESC_HEIGHT),%d7 /* Load fbcon_font_desc.height into d7 */
3238 console_read_char_scanline:
3241 /* ASSERT: a0 = contents of Lconsole_font */
3242 movel %a0@(FBCON_FONT_DESC_WIDTH),%d6 /* Load fbcon_font_desc.width into d6 */
3245 console_do_font_scanline:
3247 scsb %d2 /* convert 1 bit into a byte */
3248 jbsr console_plot_pixel
3250 dbra %d6,console_do_font_scanline
3252 /* ASSERT: a0 = contents of Lconsole_font */
3253 subl %a0@(FBCON_FONT_DESC_WIDTH),%d0
3255 dbra %d7,console_read_char_scanline
3259 func_return console_putc
3266 * d2 = (bit 0) 1/0 for white/black (!)
3267 * All registers are preserved
3269 moveml %a0-%a1/%d0-%d4,%sp@-
3271 lea %pc@(L(mac_videobase)),%a0
3273 lea %pc@(L(mac_videodepth)),%a0
3275 lea %pc@(L(mac_rowbytes)),%a0
3280 * d0 = x coord becomes byte offset into frame buffer
3282 * d2 = black or white (0/1)
3284 * d4 = temp of x (d0) for many bit depths
3292 movel %d0,%d4 /* we need the low order 3 bits! */
3297 eorb #7,%d4 /* reverse the x-coordinate w/ screen-bit # */
3301 jbra console_plot_pixel_exit
3304 jbra console_plot_pixel_exit
3309 movel %d0,%d4 /* we need the low order 2 bits! */
3314 eorb #3,%d4 /* reverse the x-coordinate w/ screen-bit # */
3321 jbra console_plot_pixel_exit
3326 jbra console_plot_pixel_exit
3331 movel %d0,%d4 /* we need the low order bit! */
3347 jbra console_plot_pixel_exit
3356 jbra console_plot_pixel_exit
3366 jbra console_plot_pixel_exit
3369 jbra console_plot_pixel_exit
3373 jbne console_plot_pixel_exit
3380 jbra console_plot_pixel_exit
3383 jbra console_plot_pixel_exit
3385 console_plot_pixel_exit:
3386 moveml %sp@+,%a0-%a1/%d0-%d4
3388 #endif /* CONSOLE */
3392 * This is some old code lying around. I don't believe
3393 * it's used or important anymore. My guess is it contributed
3394 * to getting to this point, but it's done for now.
3395 * It was still in the 2.1.77 head.S, so it's still here.
3396 * (And still not used!)
3399 moveml %a0/%d7,%sp@-
3403 .long 0xf0119f15 | ptestr #5,%a1@,#7,%a0
3412 lea %pc@(L(mmu)),%a0
3413 .long 0xf0106200 | pmove %psr,%a0@
3419 moveml %sp@+,%a0/%d7
3426 #if defined(CONFIG_ATARI) || defined(CONFIG_AMIGA) || defined(CONFIG_HP300)
3433 L(console_video_virtual):
3435 #endif /* CONFIG_MAC */
3437 #if defined(CONSOLE)
3439 .long 0 /* cursor column */
3440 .long 0 /* cursor row */
3441 .long 0 /* max num columns */
3442 .long 0 /* max num rows */
3443 .long 0 /* left edge */
3444 .long 0 /* mac putc */
3446 .long 0 /* pointer to console font (struct fbcon_font_desc) */
3447 #endif /* CONSOLE */
3449 #if defined(MMU_PRINT)
3451 .long 0 /* valid flag */
3452 .long 0 /* start logical */
3453 .long 0 /* next logical */
3454 .long 0 /* start physical */
3455 .long 0 /* next physical */
3456 #endif /* MMU_PRINT */
3460 L(mmu_cached_pointer_tables):
3462 L(mmu_num_pointer_tables):
3464 L(phys_kernel_start):
3470 L(kernel_pgdir_ptr):
3476 #if defined (CONFIG_BVME6000)
3477 BVME_SCC_CTRL_A = 0xffb0000b
3478 BVME_SCC_DATA_A = 0xffb0000f
3481 #if defined(CONFIG_MAC)
3492 #ifdef MAC_SERIAL_DEBUG
3495 #endif /* MAC_SERIAL_DEBUG */
3502 SYMBOL_NAME_LABEL(availmem)
3504 SYMBOL_NAME_LABEL(m68k_pgtable_cachemode)
3506 SYMBOL_NAME_LABEL(m68k_supervisor_cachemode)
3508 #if defined(CONFIG_MVME16x)
3509 SYMBOL_NAME_LABEL(mvme_bdid_ptr)