diff -rubBwN linux-270897-1/.config linux-2.0.29/.config --- linux-270897-1/.config Wed Dec 31 16:00:00 1969 +++ linux-2.0.29/.config Sun Sep 21 23:37:45 1997 @@ -0,0 +1,90 @@ +# +# Automatically generated by make menuconfig: don't edit +# + +# +# Code maturity level options +# +CONFIG_EXPERIMENTAL=y + +# +# Loadable module support +# +# CONFIG_MODULES is not set + +# +# Platform dependant setup +# +# CONFIG_AMIGA is not set +# CONFIG_ATARI is not set +CONFIG_MAC=y +CONFIG_M68020=y +CONFIG_M68030=y +CONFIG_M68040=y +CONFIG_ADVANCED_CPU=y +# CONFIG_RMW_INSNS is not set + +# +# General setup +# +# CONFIG_NET is not set +# CONFIG_SYSVIPC is not set +# CONFIG_BINFMT_AOUT is not set +CONFIG_BINFMT_ELF=y +CONFIG_KERNEL_ELF=y + +# +# Floppy, IDE, and other block devices +# +# CONFIG_BLK_DEV_FD is not set +# CONFIG_BLK_DEV_IDE is not set +# CONFIG_BLK_DEV_LOOP is not set +# CONFIG_BLK_DEV_MD is not set +# CONFIG_BLK_DEV_RAM is not set + +# +# SCSI support +# +# CONFIG_SCSI is not set + +# +# Filesystems +# +# CONFIG_QUOTA is not set +# CONFIG_LOCK_MANDATORY is not set +# CONFIG_MINIX_FS is not set +# CONFIG_EXT_FS is not set +CONFIG_EXT2_FS=y +# CONFIG_XIA_FS is not set +# CONFIG_FAT_FS is not set +# CONFIG_MSDOS_FS is not set +# CONFIG_VFAT_FS is not set +# CONFIG_UMSDOS_FS is not set +# CONFIG_MSDOS_PARTITION is not set +# CONFIG_PROC_FS is not set +# CONFIG_NCP_FS is not set +# CONFIG_ISO9660_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_AFFS_FS is not set +# CONFIG_HFS_FS is not set +# CONFIG_UFS_FS is not set + +# +# Character devices +# +# CONFIG_PRINTER is not set +CONFIG_MAC_SCC=y +# CONFIG_USERIAL is not set +# CONFIG_WATCHDOG is not set +# CONFIG_UMISC is not set + +# +# Sound support +# +# CONFIG_SOUND is not set + +# +# Kernel hacking +# +# CONFIG_PROFILE is not set diff -rubBwN linux-270897-1/Makefile linux-2.0.29/Makefile --- linux-270897-1/Makefile Mon Sep 22 00:31:43 1997 +++ linux-2.0.29/Makefile Sun Sep 21 01:32:04 1997 @@ -33,7 +33,7 @@ AS =$(CROSS_COMPILE)as LD =$(CROSS_COMPILE)ld -CC =$(CROSS_COMPILE)gcc -D__KERNEL__ -I$(HPATH) +CC =$(CROSS_COMPILE)gcc -DDEBUG -D__KERNEL__ -I$(HPATH) CPP =$(CC) -E AR =$(CROSS_COMPILE)ar NM =$(CROSS_COMPILE)nm diff -rubBwN linux-270897-1/arch/m68k/kernel/console.c linux-2.0.29/arch/m68k/kernel/console.c --- linux-270897-1/arch/m68k/kernel/console.c Mon Sep 22 00:31:40 1997 +++ linux-2.0.29/arch/m68k/kernel/console.c Sun Sep 21 20:43:56 1997 @@ -2188,6 +2188,7 @@ */ unsigned long con_init(unsigned long kmem_start) { +#if 0 char *display_desc = "????"; unsigned int currcons = 0; extern int serial_debug; @@ -2272,6 +2273,8 @@ MIN_NR_CONSOLES, (MIN_NR_CONSOLES == 1) ? "" : "s", MAX_NR_CONSOLES); init_bh(CONSOLE_BH, console_bh); +#endif + return kmem_start; } diff -rubBwN linux-270897-1/arch/m68k/kernel/head.S linux-2.0.29/arch/m68k/kernel/head.S --- linux-270897-1/arch/m68k/kernel/head.S Mon Sep 22 00:35:46 1997 +++ linux-2.0.29/arch/m68k/kernel/head.S Mon Sep 22 00:15:11 1997 @@ -7,6 +7,7 @@ ** ** 68040 fixes by Michael Rausch ** 68060 fixes by Roman Hodek +** MMU cleanup by Randy Thelen ** ** Atari support by Andreas Schwab, using ideas of Robert de Vries ** and Bjoern Brauel @@ -90,6 +91,10 @@ D6F_040 = 1< skip */ - -Ltest_maybe_mac: - is_not_amiga(Ltest_is_mac) - jra Ltest_notmac /* is Amiga -> skip */ - -Ltest_is_mac: /* not Amiga, not Atari: must be Mac! */ - - /* restore d0 */ - movel SYMBOL_NAME(peng_booter_data),%d0 - movel SYMBOL_NAME(mac_booter_data),%d4 - - /* test for Penguin booter */ - movel %d0,%d1 - andl #0xffffff00,%d1 - cmpl #0x50656e00,%d1 - jeq Ltest_penguin - - - /* okay, so it's the MacBSD booter, not Penguin */ - - /* - * zero bootinfo - who knows what we copied above ... - */ - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %pc@(SYMBOL_NAME(bisize)),%d0 - subql #1,%d0 -1: moveb #0,%a0@+ - dbra %d0,1b - -/* - * Save the boot info - */ - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel #MACH_MAC,%a0@(BI_machtype) - movel %sp@+, %d0 - movel %d0, %a0@(BI_args) - movel %d4, %a0@(BI_cpuid) - /* - * See if it is an 030 - just for now - */ - movel #0x200, %d6 - movec %d6, %cacr - movec %cacr, %d6 - tstl %d6 - jeq cpu_nocacr - /* - * An 030 - */ -#ifdef FPU - movel #34,%d0 /* 68030+68881 - guessing FPU */ -#else - movel #2, %d0 /* 68030 alone */ -#endif - bra cpu_typed - - /* - * 020,040 or 060 that is the question ? - */ -cpu_nocacr: - bset #31, %d6 /* Set DCache Enable */ - movec %d6, %cacr - movec %cacr, %d6 - btst #31, %d6 /* Did it set ? */ - jeq cpu_nodce - - /* - * Ok we have DCE but not CACR that makes us an 040 - * or 060. My manual doesn't go up to the 060 and I've - * yet to meet a Macintrash with one ! - * Note: 040 mode doesnt work yet on the Mac as I use early - * termination descriptors. - */ - movel #132, %d0 /* 68040 - built in FPU */ - bra cpu_typed - - /* - * no dce no cacr, 68010 or 68020. We don't support 010 - * anyway.. - */ -cpu_nodce: -#ifdef FPU - movel #33, %d0 /* 68020+68881 */ -#else - movel #1, %d0 -#endif -cpu_typed: - movel %d0, %a0@(BI_cputype) - movel %a4, %a0@(BI_dimensions) - movel %d5, %a0@(BI_videoaddr) - movel %a3, %a0@(BI_videorow) - movel %a2, %a0@(BI_videodepth) - lea %pc@(SYMBOL_NAME(_stext):w),%sp - movel #0, %a0@(BI_memory+MI_addr) - lsrl #7, %d4 - andl #31, %d4 - movel #20, %d0 - lsll %d0, %d4 - movel %d4, %a0@(BI_memory+MI_size) - - /* - * end of MacBSD hackery - * d0 clobbered - * d4, d6 clobbered - */ -Ltest_penguin: - - /* - * Yes this isnt the clean way to do it. I need to revise - * my 68k asm. - * MS: No sweat, Alan. I learned a lot from it :-) - */ - - /* - * clear screen (first write to screen!) .... - */ - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videoaddr), %a1 - movel %a0@(BI_dimensions), %d1 - andl #0xFFFF,%d1 /* rows */ -loopy: - movel %a0@(BI_videorow), %d0 -loopx: - moveb #0x55, %a1@+ - dbra %d0,loopx - dbra %d1,loopy - - /* - * 5 rows white at the top ... - * - plus a few more bytes, which get partially overwritten as - * the boot proceeds, black and white in turn. - * Crude hack, but I need some kind of process indicator ... - */ - movel %a0@(BI_videoaddr),%a1 - movel %a0@(BI_videorow),%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* that's 5 rows + 1 byte! dbra weirdness :-) */ - addl #8,%d0 -loopw: - moveb #0x00, %a1@+ - dbra %d0,loopw /* white + 9 bytes */ - - /* - * write what we determined to be the videoaddr to the screen - * Note: if we got this wrong enough, we won't see it anyway. + /* Record the machinetype and cputype where they can be used by macros! */ - movel %a0@(BI_videoaddr), %a1@+ /* video addr. */ - - moveb #0xFF, %a1@+ - moveb #0x00, %a1@+ /* b/w: spacer */ + lea %pc@(Lmachinetype),%a0 + movel %d4,%a0@ - /* - * write kernel start address to the screen + /* Test the BootInfo cputype for 060 */ - lea %pc@(SYMBOL_NAME(_stext):w),%a0 - movel %a0,%d0 /* get start addr. */ - movel %d0, %a1@+ /* write start addr. */ + clrl %d6 + btst #CPUB_68060,%d0 + jeq 1f - moveb #0xFF, %a1@+ - moveb #0x00, %a1@+ /* b/w: spacer */ + bset &CPUTYPE_060,%d6 + bset &CPUTYPE_0460,%d6 + jra 2f - /* - * restore register a0 (used for accessing bootinfo below) +1: /* Test the BootInfo cputype for 040 */ - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - -Ltest_notmac: - + btst #CPUB_68040,%d0 + jeq 1f -/* - * Re-record the CPU and machine type (we just clobbered d0 and d4 :=( if - * booting with NetBSD ...). + bset &CPUTYPE_040,%d6 + bset &CPUTYPE_0460,%d6 + jra 2f +1: /* Assume it's an 020 & 030 + * 020/030 no difference in Lcputype */ - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_machtype),%d4 - movel %a0@(BI_cputype),%d0 - +2: /* - * end of Mac-specific hacks + * Determine the cache bits for 040 & 060 CPU's */ -#endif - - jbsr Lserial_init + lea %pc@(Lcputype),%a0 + movel %d6,%a0@ -#ifdef SERIAL_DEBUG - putr() - putc('L') - putc('i') - putc('n') - putc('u') - putc('x') - putc('.') - putr() -#endif + is_not_040_or_060(1f) + /* '040 or '060: d6 := cacheable write-through */ + movel #_PAGE_CACHE040W,%d6 + jbra 2f - btst #CPUB_68060,%d0 - jeq 1f - /* '060: d6 := BIT0460|BIT060, cache mode 0x60 (no-cache/non-ser) */ - movel #D6F_060+_PAGE_CACHE040W,%d6 - jra 2f -1: btst #CPUB_68040,%d0 - jeq 1f - /* '040: d6 := BIT0460, cache mode 0x00 (write-through) */ - movel #D6F_040+_PAGE_CACHE040W,%d6 - jra 2f -1: /* '020 or '030: d6 := no CPU bit, cache mode unused */ +1: /* '020 or '030: d6 := cache bits unused */ moveq #0,%d6 -2: lea %pc@(SYMBOL_NAME(m68k_pgtable_cachemode)),%a0 - moveq #0,%d0 - movew %d6,%d0 - movel %d0,%a0@ /* save cache mode for page tables */ -#ifdef DEBUG_MAC - is_not_mac(2f) - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - addl #7,%d0 -1: - moveb #0xFF,%a0@+ /* black + 8 bytes */ - dbra %d0,1b 2: -#endif + lea %pc@(SYMBOL_NAME(m68k_pgtable_cachemode)),%a0 + movel %d6,%a0@ /* save cache mode for page tables */ /* + * I don't see reference to FROM_PL9 anywhere else in + * source tree. Is this used? + */ +/* * raise interrupt level with MASTER bit set, copy isp to msp (if not 68060) */ #ifdef FROM_PL9 @@ -514,56 +322,16 @@ movew #0x2700,%sr #endif -#ifdef DEBUG_MAC - is_not_mac(2f) - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - addl #6,%d0 -1: - moveb #0x00,%a0@+ /* white + 7 bytes */ - dbra %d0,1b -2: -#endif - -#ifndef CONFIG_MAC /* * Initialize serial port */ jbsr Lserial_init -#endif #ifdef SERIAL_DEBUG putr() putc('A') #endif -#ifdef DEBUG_MAC - is_not_mac(2f) - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - addl #5,%d0 -1: - moveb #0xFF,%a0@+ /* black + 6 bytes */ - dbra %d0,1b -2: - /* at this point, the bar should be black, - * with a white-black-white pattern appended - * -> SE/30 gets that far :-) - */ -#endif - /* * Get address at end of kernel code/data/bss and * mask off at a page boundary. @@ -573,23 +341,10 @@ movel %a0,%d0 andl #-PAGESIZE,%d0 movel %d0,%a6 - -#ifdef DEBUG_MAC - is_not_mac(2f) - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - addl #4,%d0 -1: - moveb #0x00,%a0@+ /* white + 5 bytes */ - dbra %d0,1b -2: -#endif +/* + * %a6 now contains the address to the + * next free block beyond the kernel + */ #ifdef SERIAL_DEBUG putc('B') @@ -602,57 +357,6 @@ lea %pc@(SYMBOL_NAME(_stext)-PAGESIZE:w),%a0 movel %a0,%d5 -#ifdef DEBUG_MAC - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 7 rows */ - - movel %d5,%a0@(%d0) -#endif - -#ifdef MAC_HARDCODE_START - /* - * XXX: This is a bummer - without DEBUG_MAC defined never seen before! - */ - movel #0,%d5 -#endif - -#ifdef DEBUG_MAC - /* just testing if we arrived here ... pattern interrupted if not! */ - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - addl #3,%d0 -1: - moveb #0xFF,%a0@+ /* black + 4 bytes */ - dbra %d0,1b - - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - addl #2,%d0 -1: - moveb #0x00,%a0@+ /* white + 3 bytes */ - dbra %d0,1b -#endif - jra Lsave_start_done Lsave_start_notmac: @@ -666,1054 +370,967 @@ movel %d5,%a0@ #endif + jbsr mmu_init + + lea 3f,%a1 + lea %pc@(SYMBOL_NAME(_stext)-PAGESIZE:w),%a0 + movel %a0,%d0 + jbra 1f +1: nop + .word 0xf518 /* pflusha */ + .long 0x4e7bd807 /* movec %a5,%srp */ + .long 0x4e7bd806 /* movec %a5,%urp */ + movel #TC_ENABLE+TC_PAGE4K,%d0 /* - * initialize the kernel root table. + * this value is also ok for the 68060, we don`t use the cache + * mode/protection defaults */ - lea %pc@(SYMBOL_NAME(kernel_pg_dir):w),%a5 - movel %a5,%a0 - moveq #ROOT_TABLE_SIZE-1,%d1 -1: clrl %a0@+ - dbra %d1,1b - + .long 0x4e7b0003 /* movec %d0,%tc (enable the MMU) */ + jmp %a1@ +3: /* - * Initialize root table descriptor pointing to the kernel pointer - * table. + * Fixup the addresses for the kernel pointer table and availmem. + * Convert them from physical addresses to virtual addresses. */ - lea %pc@(Lavail_pmd_table:w),%a4 - moveq #_PAGE_TABLE,%d0 - addl %a4,%d0 - movel %d0,%a5@ - -#ifdef DEBUG_MAC - is_not_mac(2f) - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - addl #1,%d0 -1: - moveb #0xFF,%a0@+ /* black + 2 bytes */ - dbra %d0,1b -2: -#endif #ifdef SERIAL_DEBUG - putc('C') + putc('M') #endif -/* - * Initialize the pointer tables referred to above. They either point - * to page tables in the case of the 680[46]0 or contain early - * termination page descriptors in the case of the 68851 or 68030. - * - * Each pointer table entry points to a 64 entry page table. 16 of these - * page tables are grouped to form a single 1024 entry page table which - * fits in a single 4096 byte page. - * - * Some register usages: - * a0 -> pointer table descriptor address - * a1 -> pointer table descriptor - * d1 -> counter - * d2 -> pointer table descriptor increment (varies according to CPU) - */ - - /* clear the kernel pointer table */ - movel %a4,%a0 - moveq #PTR_TABLE_SIZE-1,%d1 -1: clrl %a0@+ - dbra %d1,1b - - movel %a4,%a0 - moveq #15,%d1 - - /* - * base value of pointer table descriptor is either - * the address of the first page table (680[46]0) - * or the base address of physical memory (68030). + /* d5 contains physaddr of kernel start */ - is_040_or_060(1f) + subl %d5,SYMBOL_NAME(kpt) - /* 680[23]0 */ - movel %d5,%a1 /* base address */ - addql #_PAGE_PRESENT,%a1 /* descriptor type */ - movel #PAGE_TABLE_SIZE*PAGESIZE,%d2 /* increment */ - jra 2f + /* do the same conversion on the first available memory + * address (in a6). + */ + subl %d5,%a6 + movel %a6,SYMBOL_NAME(availmem) /* first available memory address */ -1: /* 680[46]0 */ - movel %a6,%a3 /* base address */ - addw #PAGESIZE,%a6 /* allocate page for 16 page tables */ - lea %pc@(SYMBOL_NAME(kpt)),%a1 - movel %a3,%a1@ /* save address of page table */ - movel %a3,%a1 - addql #_PAGE_TABLE,%a1 /* descriptor type */ - movel #PAGE_TABLE_SIZE<<2,%d2 /* increment */ +#ifdef SERIAL_DEBUG + putc('N') +#endif -2: movel %a1,%a0@+ - addl %d2,%a1 +#if 0 + putr() + lea SYMBOL_NAME(kernel_pmd_table),%a0 + moveq #63,%d0 +1: moveq #7,%d1 + putn(%a0) + putc(':') + putc(' ') +2: putn(%a0@+) dbra %d1,2b - -#ifdef DEBUG_MAC - is_not_mac(2f) - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ -1: - moveb #0x00,%a0@+ /* white + 1 byte */ + putr() + dbra %d0,1b + putr() + movel SYMBOL_NAME(kpt),%a0 + moveq #63,%d0 +1: moveq #7,%d1 + putn(%a0) + putc(':') + putc(' ') +2: putn(%a0@+) + dbra %d1,2b + putr() dbra %d0,1b -2: -#endif - -#ifdef SERIAL_DEBUG - putc('D') #endif +/* + * Enable caches + */ /* - * If we are running on a 680[46]0, we have a kernel page table and - * must initialize it. Make the entries point to the first - * 4M of physical memory (the memory we are residing in). - * Set the cache mode bits to Cacheable, Copyback. Set the Global bits - * in the descriptors also. + ** Will work only if virtual == physical */ - is_not_040_or_060(Lnot040) + is_040_or_060(Lcache680460) -#ifdef SERIAL_DEBUG - putc('F') -#endif + movel #CC3_ENABLE_DB+CC3_CLR_D+CC3_ENABLE_D+CC3_ENABLE_IB+CC3_CLR_I+CC3_ENABLE_I,%d0 + movec %d0,%cacr - movel %a3,%a0 - movel %d5,%a1 - addw #_PAGE_GLOBAL040+_PAGE_CACHE040+_PAGE_PRESENT,%a1 - movew #(PAGE_TABLE_SIZE*TABLENR_4MB)-1,%d1 - movel #PAGESIZE,%d2 -1: movel %a1,%a0@+ - addl %d2,%a1 - dbra %d1,1b + jra 1f - /* - * on the 68040, pages used to hold mmu tables should - * be initialized as noncachable; the '060 allows write-through. - * Do this for the root table page (which also contains - * all pointer tables utilized thus far) and the - * kernel page table. - */ - movel %a5,%d0 - subl %d5,%d0 - moveq #PAGE_INDEX_SHIFT,%d2 - lsrl %d2,%d0 - lea %a3@(%d0:l:4),%a2 - movel %a2@,%d1 - andw #_CACHEMASK040,%d1 - orw %d6,%d1 - movel %d1,%a2@ - - movel %a3,%d0 - subl %d5,%d0 - lsrl %d2,%d0 - lea %a3@(%d0:l:4),%a2 - movel %a2@,%d1 - andw #_CACHEMASK040,%d1 - orw %d6,%d1 - movel %d1,%a2@+ - /* - * %a2 points now to the page table entry for available pages at %a6, - * hence caching modes for new pages can easily set unless increasing - * of %a2 are forgotten. - */ +Lcache680460: + .word 0xf4f8 /* cpusha %bc */ - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ -1: - moveb #0xF0,%a0@+ /* b/w+1 : this is missing on SE/30 */ - dbra %d0,1b + is_060(Lcache68060) -Lnot040: -/* - * Do any machine specific page table initializations. - */ -#ifdef CONFIG_AMIGA - is_not_amiga(Lnotami) + movel #CC6_ENABLE_D+CC6_ENABLE_I,%d0 + /* MMU stuff works in copyback mode now, so enable the cache */ + movec %d0,%cacr + jra 1f + +Lcache68060: + movel #CC6_ENABLE_D+CC6_ENABLE_I+CC6_ENABLE_SB+CC6_PUSH_DPI+CC6_ENABLE_B+CC6_CLRA_B,%d0 + /* MMU stuff works in copyback mode now, so enable the cache */ + movec %d0,%cacr + /* enable superscalar dispatch in PCR */ + moveq #1,%d0 + .long 0x4e7b0808 /* movec d0,pcr */ +1: /* - * Setup a mapping of the first 16M of physical address space at virtual - * address 0x80000000, using early termination page descriptors for the - * 68030, and proper page tables for the 680[46]0. Set this area as - * non-cacheable. + * Setup initial stack pointer */ + lea SYMBOL_NAME(init_user_stack)+PAGESIZE,%sp +/* jump to the kernel start */ #ifdef SERIAL_DEBUG - putc('H') + putr() #endif - is_040_or_060(Lspami68040) + jbsr SYMBOL_NAME(start_kernel) /* - * for the 68030, just setup a translation to map in the first - * 32M of physical address space at virtual address 0x80000000 - * using an early termination page descriptor. + * switch off mmu and exit */ -#ifdef SERIAL_DEBUG - putc('I') -#endif - - moveq #_PAGE_NOCACHE030+_PAGE_PRESENT,%d0 - orl #0x80000000, %d0 - movel %d0,%a5@(0x40<<2) - - jra Lmapphys +#ifdef HACKER_KERNEL +ENTRY(kernel_exit) + lea 2f:w,%a0 + movel %pc@(Lkernel_start),%a0 + lea %a0@(2f:w),%a1 + movel %a1,%d0 + andl #0xff000000,%d0 + jne 1f + jmp %a0@(1f+0x80000000) +1: orw #TTR_ENABLE+TTR_KERNELMODE+_PAGE_NOCACHE_S,%d0 + .long 0x4e7b0004 /* movec %d0,%itt0 */ + jmp %a1@ +2: moveq #0,%d0 + .long 0x4e7b0003 /* movec %d0,%tc (disable the MMU) */ + .word 0xf518 /* pflusha */ + .long 0x4e7b0004 /* movec %d0,%itt0 */ + movec %d0,%cacr + .word 0xf4f8 /* cpusha %bc */ -Lspami68040: + lea %pc@(SYMBOL_NAME(boot_info)),%a0 + jmp %a0@(BI_amiga_exit_func:w)@(0:w) +#endif /* - * for the 680[46]0, use another pointer table, and allocate 4 more - * page tables. Initialize the pointer table to point to the - * page tables. Then initialize the page tables to point to - * the first 16M of memory, with no caching (noncachable/serialized). - */ + * MMU Initialization Begins Here + * + * The structure of the MMU tables on the 68k machines + * is thus: + * Root Table + * Logical addresses are translated through + * a hierarchical translation mechanism where the high-order + * seven bits of the logical address (LA) are used as an + * index into the "root table." Each entry in the root + * table is either 0x0000.0000 or a valid pointer to a + * pointer table. Each entry defines a 32Meg range of memory. + * If an entry is 0x00 then that logical range of 32M is + * invalid and references to that range of memory (when the MMU + * is enabled) will fault. + * + * Pointer Tables + * Per the Root Table, there will be one or more + * pointer tables. Each pointer table defines a 32M range. + * Not all of the 32M range need be defined. Again, the next + * seven bits of the logical address are used an index into + * the pointer table to point to page tables (if the pointer + * is not 0x0). There will undoubtedly be more than one + * pointer table for the kernel because each pointer table + * defines a range of only 256K. + * + * Page Tables + * Per the Pointer Tables, each page table entry points + * to the physical page in memory that supports the logical + * address that translates to the particular index. + * + * In short, the Logical Address gets translated as follows: + * bits 31..26 - index into the Root Table + * bits 25..18 - index into the Pointer Table + * bits 17..12 - index into the Page Table + * bits 11..0 - offset into a particular 4K page + */ +#define MMU_CACHE_KERNEL_CODE 0 +#define MMU_CACHE_MMU_DATA 1 +#define MMU_CACHE_IO_DATA 2 + +mmu_init_map_kernel_low: + lea %pc@(SYMBOL_NAME(Lavail_pmd_table)),%a4 + jbsr mmu_clear_pointer_table - /* clear the amiga pointer table */ - lea %a4@(PTR_TABLE_SIZE<<2),%a4 - moveq #PTR_TABLE_SIZE-1,%d1 -1: clrl %a0@+ - dbra %d1,1b + /* Map the 4Meg range beginning at the kernel's phys start + */ + movel %d5,%a1 + movel %d5,%a0 + movel #4*1024*1024,%d0 + movel #MMU_CACHE_MMU_DATA,%d1 + jbsr mmu_map + jbra 2f - /* allocate 4 pages for 64 page tables */ - movel %a6,%a3 - addw #4*PAGESIZE,%a6 +1: + movel %d5,%a1 + movel %d5,%a0 + movel #PAGESIZE,%d0 + movel #MMU_CACHE_KERNEL_CODE,%d1 - /* initialize the pointer table */ - movel %a4,%a0 - movel %a3,%a1 - addql #_PAGE_TABLE,%a1 /* base descriptor */ - movel #PAGE_TABLE_SIZE<<2,%d2 /* increment */ - moveq #TABLENR_16MB-1,%d1 -1: movel %a1,%a0@+ - addl %d2,%a1 - dbra %d1,1b + moveq #0,%d0 + movel %d0,%a4 + movel %d0,%a3 +2: + rts - /* ensure that the root table points to the pointer table */ - movel %a4,%a0 - addql #_PAGE_TABLE,%a0 - movel %a0,%a5@(0x40<<2) - - /* - * initialize the page tables - * descriptor bits include noncachable/serialized and global bits. - */ - movel %a3,%a0 - movew #_PAGE_GLOBAL040+_PAGE_NOCACHE_S+_PAGE_PRESENT,%a1 - movel #PAGESIZE,%d2 - movew #(PAGE_TABLE_SIZE*TABLENR_16MB)-1,%d1 +mmu_init: + moveml %d0-%d7/%a0-%a4,%sp@- -1: movel %a1,%a0@+ - addl %d2,%a1 - dbra %d1,1b +/* + * initialize the kernel root table. + */ + lea %pc@(SYMBOL_NAME(kernel_pg_dir)),%a5 + jbsr mmu_clear_root_table + jbsr mmu_init_map_kernel_low /* - * Finally, since we just allocated 4 page tables, make sure that - * the virtual mapping of the 4 page tables indicates - * noncachable/serialized. - */ - moveq #3,%d0 -1: movel %a2@,%d1 /* a2 already points to root table offset */ - andw #_CACHEMASK040,%d1 - orw %d6,%d1 - movel %d1,%a2@+ - dbra %d0,1b + * jbsr mmu_init_map_kerenl_high + */ - jra Lmapphys +#if defined(CONFIG_AMIGA) +mmu_init_amiga: + is_not_amiga(mmu_init_not_amiga) -Lnotami: + /* There is nothing else to do on this platform! + * Yet! + */ +mmu_init_not_amiga: #endif -#ifdef CONFIG_MAC - is_not_mac(Lnotmac) +#if defined(CONFIG_ATARI) +mmu_init_atari: + is_not_atari(mmu_init_not_atari) -/* - * Setup a mapping of the 0xFC range for 32M of physical address space - * at virtual address 0xFC000000, using early termination page descriptors - * for the 68030, and proper page tables for the 680[46]0. Set this area - * as non-cacheable. (040/060 one still wrong XXX) + /* There is nothing else to do on this platform! + * Yet! */ - -#ifdef SERIAL_DEBUG - putc('H') +mmu_init_not_atari: #endif - is_040_or_060(Lspmac68040) +#if defined(CONFIG_MAC) +mmu_init_mac: + is_not_mac(mmu_init_not_mac) -#ifdef DEBUG_MAC - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - subl #1, %d0 -1: - moveb #0xFF,%a0@+ /* black - 0 bytes : ok */ - dbra %d0,1b -#endif + moveq #0,%d0 + movel %d0,%a4 + movel %d0,%a3 - /* - * for the 68030, just setup a translation to map in the - * 32M of physical address space at virtual address 0x80000000 - * using an early termination page descriptor. - */ + movel #0x50000000,%a1 + movel #0x02000000,%d0 + movel #MMU_CACHE_IO_DATA,%d1 + movel %a1,%a0 + jbsr mmu_map + + movel #0x60000000,%a1 + movel %a1,%a0 + movel #0x00400000,%d0 + movel #MMU_CACHE_IO_DATA,%d1 + jbsr mmu_map + + movel #0xF8000000,%a1 +1: + movel %a1,%a0 + movel #0x00400000,%d0 + movel #MMU_CACHE_IO_DATA,%d1 + jbsr mmu_map + addl #0x01000000,%a1 + cmpl #0,%a1 + jbne 1b -#ifdef SERIAL_DEBUG - putc('I') +mmu_init_not_mac: #endif - /* - * Nubus space - */ - - moveq #_PAGE_NOCACHE030+_PAGE_PRESENT,%d0 - orl #0xF8000000,%d0 - movel %d0,%a5@(0x7C<<2) - moveq #_PAGE_NOCACHE030+_PAGE_PRESENT,%d0 - orl #0xFA000000,%d0 - movel %d0,%a5@(0x7D<<2) - moveq #_PAGE_NOCACHE030+_PAGE_PRESENT,%d0 - orl #0xFC000000,%d0 - movel %d0,%a5@(0x7E<<2) - moveq #_PAGE_NOCACHE030+_PAGE_PRESENT,%d0 - orl #0xFE000000,%d0 - movel %d0,%a5@(0x7F<<2) - - /* - * IO space identity at 0x50-> for now - */ - - moveq #_PAGE_NOCACHE030+_PAGE_PRESENT,%d0 - orl #0x50000000,%d0 - movel %d0,%a5@(0x28<<2) + moveml %sp@+,%d0-%d7/%a0-%a4 + rts - /* - * MAC onboard video - */ +#define mmu_next_valid 0 +#define mmu_start_logical 4 +#define mmu_next_logical 8 +#define mmu_start_physical 12 +#define mmu_next_physical 16 - moveq #_PAGE_NOCACHE030+_PAGE_PRESENT,%d0 - orl #0x60000000,%d0 - movel %d0,%a5@(0x30<<2) +#define MMU_PRINT_INVALID -1 +#define MMU_PRINT_VALID 1 +#define MMU_PRINT_UNINITED 0 - /* - * Classic Video (9Fxxxxxx) (0x9E000000-0x9FFFFFFF -> 0x60000000?) - */ +#define putZc(z,n) jbne 1f; putc(z); jbra 2f ; 1: putc(n); 2: - moveq #_PAGE_NOCACHE030+_PAGE_PRESENT,%d0 - orl #0x60000000,%d0 - movel %d0,%a5@(0x4F<<2) +mmu_print: + moveml %a0-%a6/%d0-%d7,%sp@- -#if 1 - /* - * MAC RAM identity at 0x00000000 - required for SE/30 and IIcx - * syntax: physbase | _PAGE_NOCACHE030 | _PAGE_PRESENT - * -> tbl[virtual >> 18] - */ + is_040_or_060(mmu_040_print) + jbra mmu_030_print - moveq #_PAGE_NOCACHE030+_PAGE_PRESENT,%d0 - orl #0x00000000,%d0 - movel %d0,%a5@(0x00<<2) -#endif +mmu_040_print: + putr() + put3c('r','p',':') + movel %a5,%d7 + jbsr Lserial_putnum + putr() + put3c('t','c',':') + movel %d5,%d7 + jbsr Lserial_putnum + putr() + putr() + put3c('M','M','U') + put3c('0','4','0') + putr() + movel %a5,%d0 + andil #0xfffffe00,%d0 + movel %d0,%a0 + movel #0x00000000,%a4 /* logical address */ + movel #0,%d0 +40: + movel %a4,%d5 + addil #PAGESIZE<<13,%d5 + movel %a0@+,%d6 + btst #1,%d6 + jbne 41f + jbsr mmu_print_tuple_invalidate + jbra 48f +41: + movel #0,%d1 + andil #0xfffffe00,%d6 + movel %d6,%a1 +42: + movel %a4,%d5 + addil #PAGESIZE<<6,%d5 + movel %a1@+,%d6 + btst #1,%d6 + jbne 43f + jbsr mmu_print_tuple_invalidate + jbra 47f +43: + movel #0,%d2 + andil #0xffffff00,%d6 + movel %d6,%a2 +44: + movel %a4,%d5 + addil #PAGESIZE,%d5 + movel %a2@+,%d6 + btst #0,%d6 + jbne 45f + jbsr mmu_print_tuple_invalidate + jbra 46f +45: + moveml %d0-%d1,%sp@- + movel %a4,%d0 + movel %d6,%d1 + andil #0xfffff4e0,%d1 + lea %pc@(mmu_040_print_flags),%a6 + jbsr mmu_print_tuple + moveml %sp@+,%d0-%d1 +46: + movel %d5,%a4 + addq #1,%d2 + cmpib #64,%d2 + jbne 44b +47: + movel %d5,%a4 + addq #1,%d1 + cmpib #128,%d1 + jbne 42b +48: + movel %d5,%a4 /* move to the next logical address */ + addq #1,%d0 + cmpib #128,%d0 + jbne 40b + + jbra mmu_print_done + +mmu_040_print_flags: + btstl #10,%d6 + putZc(' ','G') /* global bit */ + btstl #7,%d6 + putZc(' ','S') /* supervisor bit */ + btstl #6,%d6 + jbne 3f + putc('C') + btstl #5,%d6 + putZc('w','c') /* write through or copy-back */ + jbra 4f +3: + putc('N') + btstl #5,%d6 + putZc('s',' ') /* serialized non-cacheable, or non-cacheable */ +4: + rts -#if 0 - /* - * MAC RAM 0x80000000 -> 0x00000000 - doesn't help :-( - */ +mmu_030_print_flags: + btstl #6,%d6 + putZc('C','I') /* write through or copy-back */ + rts - moveq #_PAGE_NOCACHE030+_PAGE_PRESENT,%d0 - orl #0x00000000,%d0 - movel %d0,%a5@(0x40<<2) -#endif +mmu_030_print: + putr() + put3c('r','p',':') + movel %a5,%d7 + jbsr Lserial_putnum + putr() + put3c('t','c',':') + movel %d5,%d7 + jbsr Lserial_putnum + putr() + putr() + put3c('M','M','U') + put3c('0','3','0') + putr() + movel %a5,%d0 + andil #0xfffffff0,%d0 + movel %d0,%a0 + movel #0x00000000,%a4 /* logical address */ + movel #0,%d0 +30: + movel %a4,%d5 + addil #PAGESIZE<<13,%d5 + movel %a0@+,%d6 + btst #1,%d6 /* is it a ptr? */ + jbne 31f /* yes */ + btst #0,%d6 /* is it early terminating? */ + jbeq 1f /* no */ + jbsr mmu_030_print_helper + jbra 38f +1: + jbsr mmu_print_tuple_invalidate + jbra 38f +31: + movel #0,%d1 + andil #0xfffffff0,%d6 + movel %d6,%a1 +32: + movel %a4,%d5 + addil #PAGESIZE<<6,%d5 + movel %a1@+,%d6 + btst #1,%d6 + jbne 33f + btst #0,%d6 + jbeq 1f /* no */ + jbsr mmu_030_print_helper + jbra 37f +1: + jbsr mmu_print_tuple_invalidate + jbra 37f +33: + movel #0,%d2 + andil #0xfffffff0,%d6 + movel %d6,%a2 +34: + movel %a4,%d5 + addil #PAGESIZE,%d5 + movel %a2@+,%d6 + btst #0,%d6 + jbne 35f + jbsr mmu_print_tuple_invalidate + jbra 36f +35: + jbsr mmu_030_print_helper +36: + movel %d5,%a4 + addq #1,%d2 + cmpib #64,%d2 + jbne 34b +37: + movel %d5,%a4 + addq #1,%d1 + cmpib #128,%d1 + jbne 32b +38: + movel %d5,%a4 /* move to the next logical address */ + addq #1,%d0 + cmpib #128,%d0 + jbne 30b + +mmu_print_done: + lea %pc@(Lmmu_print_data),%a0 + movel #MMU_PRINT_UNINITED,%a0@(mmu_next_valid) + + cmpil #0,%d5 + beq 3f + put6c('a','4','!','=','0','!') + movel %d5,%d7 + jsr Lserial_putnum + putr() +3: + putr() + putr() -#ifdef DEBUG_MAC - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - subl #2, %d0 -1: - moveb #0x00,%a0@+ /* white - 1 bytes : ok! */ - dbra %d0,1b -#endif + moveml %sp@+,%a0-%a6/%d0-%d7 + rts - jra Lmapphys +mmu_030_print_helper: + moveml %d0-%d1,%sp@- + movel %a4,%d0 + movel %d6,%d1 + lea %pc@(mmu_030_print_flags),%a6 + jbsr mmu_print_tuple + moveml %sp@+,%d0-%d1 + rts -Lspmac68040: +mmu_print_tuple_invalidate: + moveml %a0/%d7,%sp@- -#ifdef DEBUG_MAC - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - subl #2, %d0 -1: - moveb #0xF0,%a0@+ /* black/white - 1 bytes ?? weird */ - dbra %d0,1b -#endif - /* - * for the 680[46]0, use another pointer table, and allocate 4 more - * page tables. Initialize the pointer table to point to the - * page tables. Then initialize the page tables to point to - * the first 16M of memory, with no caching (noncachable/serialized). - */ + lea %pc@(Lmmu_print_data),%a0 + tstl %a0@(mmu_next_valid) + jbmi mmu_print_tuple_invalidate_exit - /* clear the mac pointer table */ - lea %a4@(PTR_TABLE_SIZE<<2),%a4 - moveq #PTR_TABLE_SIZE-1,%d1 -1: clrl %a0@+ - dbra %d1,1b + movel #MMU_PRINT_INVALID,%a0@(mmu_next_valid) - /* allocate 4 pages for 64 page tables */ - movel %a6,%a3 - addw #4*PAGESIZE,%a6 + movel %a4,%d7 + jbsr Lserial_putnum - /* initialize the pointer table */ - movel %a4,%a0 - movel %a3,%a1 - addql #_PAGE_TABLE,%a1 /* base descriptor */ - movel #PAGE_TABLE_SIZE<<2,%d2 /* increment */ - moveq #TABLENR_16MB-1,%d1 + put2c('#','#') + putr() -1: movel %a1,%a0@+ - addl %d2,%a1 - dbra %d1,1b +mmu_print_tuple_invalidate_exit: + moveml %sp@+,%a0/%d7 + rts - /* ensure that the root table points to the pointer table */ - movel %a4,%a0 - addql #_PAGE_TABLE,%a0 - movel %a0,%a5@(0x40<<2) - - /* - * initialize the page tables - * descriptor bits include noncachable/serialized and global bits. - */ - movel %a3,%a0 - movew #_PAGE_GLOBAL040+_PAGE_NOCACHE_S+_PAGE_PRESENT,%a1 - movel #PAGESIZE,%d2 - movew #(PAGE_TABLE_SIZE*TABLENR_16MB)-1,%d1 -1: movel %a1,%a0@+ - addl %d2,%a1 - dbra %d1,1b +mmu_print_tuple: + moveml %d0-%d7/%a0,%sp@- - /* - * Finally, since we just allocated 4 page tables, make sure that - * the virtual mapping of the 4 page tables indicates - * noncachable/serialized. - */ - moveq #3,%d0 -1: movel %a2@,%d1 /* a2 already points to root table offset */ - andw #_CACHEMASK040,%d1 - orw %d6,%d1 - movel %d1,%a2@+ - dbra %d0,1b + lea %pc@(Lmmu_print_data),%a0 - jra Lmapphys + tstl %a0@(mmu_next_valid) + jbmi mmu_print_tuple_print + jbeq mmu_print_tuple_print + jbpl mmu_print_tuple_test + +mmu_print_tuple_test: + cmpl %a0@(mmu_next_physical),%d1 + jbeq mmu_print_tuple_increment -Lnotmac: -#endif +mmu_print_tuple_print: + movel %d0,%d7 + jbsr Lserial_putnum -#ifdef CONFIG_ATARI - is_not_atari(Lnotatari) + put2c('-','>') - move.w #PAGESIZE,%sp + movel %d1,%d7 + jbsr Lserial_putnum -/* On the Atari, we map the I/O region (phys. 0x00ffxxxx) by mapping - the last 16 MB of virtual address space to the first 16 MB (i.e. - 0xffxxxxxx -> 0x00xxxxxx). For this, an additional pointer table is - needed. I/O ranges are marked non-cachable. - - For the Medusa it is better to map the I/O region transparently - (i.e. 0xffxxxxxx -> 0xffxxxxxx), because some I/O registers are - accessible only in the high area. The test whether it is a Medusa - is done by writing to the byte at phys. 0x0. This should result - in a bus error on all other machines. - - ...should, but doesn't. The Afterburner040 for the Falcon has the - same behaviour (0x0..0x7 are no ROM shadow). So we have to do - another test to distinguish Medusa and AB040. This is a - read attempt for 0x00ff82fe phys. that should bus error on a Falcon - (+AB040), but is in the range where the Medusa always asserts DTACK. -*/ - - moveq #0,%d3 /* base addr for others: 0x00000000 */ - movec %d3,%vbr - lea %pc@(Ltest_berr),%a0 - movel %a0,0x8 - movel %sp,%a0 - moveb 0x0,%d1 - clrb 0x0 - nop - moveb %d1,0x0 - nop - tstb 0x00ff82fe - nop - movel #0xff000000,%d3 /* Medusa base addr: 0xff000000 */ -Ltest_berr: - movel %a0,%sp - lea %pc@(SYMBOL_NAME(is_medusa)),%a0 - movel %d3,%a0@ - - /* Let the root table point to the new pointer table */ - lea %a4@(PTR_TABLE_SIZE<<2),%a4 - movel %a4,%a0 - addl #_PAGE_TABLE,%a0 - movel %a0,%a5@(0x7f<<2) /* 0xFE000000 - 0xFFFFFFFF */ - - /* clear lower half of the pointer table (0xfexxxxxx) */ - movel %a4,%a0 - movel #(PTR_TABLE_SIZE/2)-1,%d2 -1: clrl %a0@+ - dbra %d2,1b - - is_040_or_060(Lspata68040) - -/* Mapping of the last 16M of virtual address space to the first 16M - for efficient addressing of hardware registers */ - movel #PAGE_TABLE_SIZE*PAGESIZE,%d1 - movel #(PTR_TABLE_SIZE/2)-1,%d2 - movel %d3,%d0 - addl #_PAGE_PRESENT,%d0 -1: movel %d0,%a0@+ - addl %d1,%d0 - dbra %d2,1b - moveq #_PAGE_NOCACHE030,%d0 /* make non-cachable */ - addl %d0,%a4@(0x7f<<2) /* 0xFFFC0000-0xFFFFFFFF (I/O space) */ -/* GK: 0xFFF00000-0xFFF3FFFF (IDE-bus) has to be non-cachable too */ - addl %d0,%a4@(0x7c<<2) + movel %d1,%d6 + jbsr %a6@ + putr() - jra Lmapphys +mmu_print_tuple_record: + movel #MMU_PRINT_VALID,%a0@(mmu_next_valid) -Lspata68040: - /* allocate 4 page tables */ - movel %a6,%a3 - addw #4*PAGESIZE,%a6 + movel %d1,%a0@(mmu_next_physical) - /* Initialize the upper half of the pointer table (a0 is still valid) */ - movel %a3,%a1 - addql #_PAGE_TABLE,%a1 - movel #PAGE_TABLE_SIZE<<2,%d2 - moveq #TABLENR_16MB-1,%d1 -1: movel %a1,%a0@+ - addl %d2,%a1 - dbra %d1,1b +mmu_print_tuple_increment: + movel %d5,%d7 + subl %a4,%d7 + addl %d7,%a0@(mmu_next_physical) - /* Initialize the page tables as noncacheable/serialized! */ - movel %a3,%a0 - movel %d3,%a1 - addw #_PAGE_GLOBAL040+_PAGE_NOCACHE_S+_PAGE_PRESENT,%a1 - movel #PAGESIZE,%d2 - movew #(PAGE_TABLE_SIZE*TABLENR_16MB)-1,%d1 -1: movel %a1,%a0@+ - addl %d2,%a1 - dbra %d1,1b +mmu_print_tuple_exit: + moveml %sp@+,%d0-%d7/%a0 + rts - /* - * Finally, since we just allocated 4 page tables, make sure that - * the virtual mapping of the 4 page tables indicates - * noncachable or write-through. - */ - moveq #3,%d0 -1: movel %a2@,%d1 /* a2 already points to root table offset */ - andw #_CACHEMASK040,%d1 - orw %d6,%d1 - movel %d1,%a2@+ - dbra %d0,1b +mmu_print_machine_cpu_types: + put4c('m','a','c','h') + put5c('i','n','e',':',' ') + is_not_amiga(1f) + put5c('a','m','i','g','a') + jbra 9f +1: is_not_atari(2f) + put5c('a','t','a','r','i') + jbra 9f +2: is_not_mac(3f) + put5c('m','a','c','i','n') + put5c('t','r','a','s','h') + jbra 9f +3: put5c('u','n','k','n','o') + put2c('w','n') +9: putr() + + put4c('c','p','u','t') + put5c('y','p','e',':',' ') + putc('0') + is_not_060(1f) + putc('6') + jbra 9f +1: is_not_040_or_060(2f) + putc('4') + jbra 9f +2: putc('3') +9: putc('0') + putr() -Lnotatari: -#endif + rts /* - * Setup a transparent mapping of the physical memory we are executing in. + * mmu_clear_root_table + * + * %a5 = pointer to the root table + * + * This routine will clear out the kernel root table + * + * The root table points to 128 pointer tables. Because the + * root table describes 32 bits of logical memory, (and there + * are 7 bits of indexing in the root table) there is 25 bits + * of logical address space described by each entry in the + * root table. 2^25 is 32Meg, another way to look at that is + * 4Gig / 128 = 32Meg. Any entry which does not have bit 1 set + * is not a valid entry. In that case, a reference into that + * memory range will cause a memory exception (bus error). + * + * The pointer tables each have 128 entries. Each entry + * describes 1/128th of 32Meg, or 256K. Again, any entry + * with bit 1 cleared is not a valid entry. * - * Only do this if the physical memory is not in the first 16M Meg, or not on - * an Amiga since the first 16M is already identity mapped on the Amiga. */ -Lmapphys: - -#ifdef SERIAL_DEBUG - putc('J') -#endif +mmu_clear_root_table: + movel %d0,%sp@- -#ifdef CONFIG_AMIGA - is_not_amiga(Lmapphysnotamiga) + moveq #ROOT_TABLE_SIZE-1,%d0 +1: clrl %a5@(%d0*4) + dbra %d0,1b -/* - * The virtual address of the start of the kernel is 0x1000. We transparently - * translate the memory where we running in and can enable then the MMU. Hence - * we have now two locations of the kernel in memory and can jump to the final - * place. Except if the physical location is in the first 16MB, translation - * will overlap later virtual location, but as we already mapped the first - * 16MB to 0x80000000, we can jump there after translation and MMU is enabled - * and then we can switch off translation and go to the final place. - * On 020/030 we must emulate transparant translation, since 020 doesn't know - * it, but due to early termination pointer this is easy to do. - * When MMU is enabled, stack pointer and Lcustom will become again valid and - * stack points to the unused first page. - */ + movel %sp@+,%d0 + rts /* - * Setup Supervisor Root Pointer register to point to page directory, - * setup translation register contents and enable translation. + * mmu_clear_pointer_table + * + * %a4 = pointer to a pointer table + * + * This routine will clear out a pointer table. + * It does NOT link the pointer table into the root table + * (that linkage is done by mapping memory!) */ +mmu_clear_pointer_table: + movel %d0,%sp@- -#ifdef SERIAL_DEBUG - putc('K') -#endif - - movew #PAGESIZE,%sp - - /* fixup the Amiga custom register location before printing */ - lea %pc@(Lcustom),%a0 - movel #0x80000000,%a0@ - - is_040_or_060(Lamimmu68040) - - moveq #ROOT_INDEX_SHIFT,%d2 - movel %d5,%d0 - lsrl %d2,%d0 - movel %d0,%d1 - lsll %d2,%d1 - addql #_PAGE_PRESENT,%d1 - lsll #2,%d0 - movel %a5@(%d0:w),%d2 - movel %d1,%a5@(%d0:w) - lea %pc@(Lmmu),%a3 - /* no limit, 4byte descriptors */ - movel #0x80000002,%a3@ - movel %a5,%a3@(4) - .long 0xf0134800 /* pmove %a3@,%srp */ - .long 0xf0134c00 /* pmove %a3@,%crp */ - .long 0xf0002400 /* pflusha */ - /* - * enable,super root enable,4096 byte pages,7 bit root index, - * 7 bit pointer index, 6 bit page table index. - */ - movel #0x82c07760,%a3@ - .long 0xf0134000 /* pmove %a3@,%tc (enable the MMU) */ - tstl %d0 - jne 1f - jmp %pc@(2f+0x80000000) -1: jmp 2f:w -2: movel %d2,%a5@(%d0:w) - .long 0xf0002400 /* pflusha */ - jmp LdoneMMUenable:w + moveq #PTR_TABLE_SIZE-1,%d0 +1: clrl %a4@(%d0*4) + dbra %d0,1b -Lamimmu68040: + movel %sp@+,%d0 + rts - lea 2f:w,%a0 - movel %d5,%d0 - andl #0xff000000,%d0 - jne 1f - lea %pc@(2f+0x80000000),%a0 -1: orw #TTR_ENABLE+TTR_KERNELMODE+_PAGE_NOCACHE_S,%d0 - .long 0x4e7b0004 /* movec %d0,%itt0 */ - .long 0x4e7bd806 /* movec %a5,%urp */ - .long 0x4e7bd807 /* movec %a5,%srp */ - .word 0xf518 /* pflusha */ - movel #TC_ENABLE+TC_PAGE4K,%d0 /* - * this value is also ok for the 68060, we don`t use the cache - * mode/protection defaults + * mmu_clear_page_table + * + * %a3 = pointer to a page table + * + * This routine will clear out a pointer table. + * It does NOT link the page table into the pointer table + * (that linkage is done by mapping memory!) */ - .long 0x4e7b0003 /* movec %d0,%tc (enable the MMU) */ - jmp %a0@ -2: moveq #0,%d0 - .long 0x4e7b0004 /* movec %d0,%itt0 */ - jmp LdoneMMUenable:w +mmu_clear_page_table: + movel %d0,%sp@- -Lmapphysnotamiga: -#endif + moveq #PAGE_TABLE_SIZE-1,%d0 +1: clrl %a3@(%d0*4) + dbra %d0,1b -#ifdef CONFIG_ATARI - is_not_atari(Lmapphysnotatari) + movel %sp@+,%d0 + rts /* - * If the kernel physical address is different from its virtual address, we - * will temporarily set up an identity mapping of the 16MB chunk with - * transparent translation where the kernel is executing. + * mmu_map + * + * %a6 = address of free memory above kernel (page aligned) + * %a5 = pointer to the root table + * %a4 = pointer to a pointer table + * %a1 = physical address of mapping + * %a0 = logical address to map + * %d1 = memory type + * %d0 = length of the mapping + * + * This routine will map a range of memory using a pointer + * table and allocating the pages on the fly from the kernel. + * The pointer table does not have to be already linked into + * the root table, this routine will do that if necessary. + * + * NOTE + * This routine will assert failure and use the Lserial_putc + * routines in the case of a run-time error. For example, + * if the address to be mapped requires two pointer tables + * this routine will fail and the boot process will terminate. + * A higher level routine would have to be written to call + * this routine multiple times (with different parameters + * if a single mapping might straddle multiple pointer tables. + * + * NOTE-2 + * This routine will use early terminating descriptors + * where possible for the 68020+68851 and 68030 type + * processors. + * + * Memory Type + * 0 = Cacheable (common) + * 1 = Non-cacheable (serialized) + * 2 = Global, cacheable + * 3 = Global, non-cacheable */ +mmu_map: + moveml %d0-%d7/%a0-%a5,%sp@- -#ifdef SERIAL_DEBUG - putc('L') -#endif + /* Calculate the offset in the root table + */ + movel %a0,%d5 + andil #0xFE000000,%d5 + roll #7,%d5 - /* fixup the Atari iobase register location before printing */ - lea %pc@(Liobase),%a0 - movel #0xff000000,%a0@ + /* Calculate the offset in the pointer table + */ + movel %a0,%d4 + andil #0x01fC0000,%d4 + lsrl #2,%d4 + swap %d4 - is_040_or_060(Latarimmu68040) + /* Calculate the offset in the page table (used on 040's + 060's) + */ + movel %a0,%d3 + andil #0x0002F000,%d3 + lsll #4,%d3 + swap %d3 - lea %pc@(Lmmu),%a3 - movel %d5,%d0 - jne 1f - lea LdoneMMUenable:w,%a0 - jra 3f -1: lea 4f:w,%a0 - andl #0xff000000,%d0 /* logical address base */ - jeq 2f - orw #TTR_ENABLE+TTR_CI+TTR_RWM+TTR_FCB2+TTR_FCM1+TTR_FCM0,%d0 - movel %d0,%a3@ - .long 0xf0130800 /* pmove %a3@,%tt0 */ - jra 3f - /* tt0 doesn't work if physical and virtual address of kernel is in - * the same 16M area (Falcon with Magnum/FX, kernel in alternate ram) - * Transparent translation through kernel pointer table - * Requires that this code until after MMU enabling lies in - * the 256K page around %d5 - */ -2: movel %a5@,%d1 - andw #0xfff0,%d1 - movel %d1,%a1 - movel %d5,%d1 - moveq #PTR_INDEX_SHIFT,%d0 - lsrl %d0,%d1 - lea %a1@(%d1:l:4),%a1 - movel %d5,%d1 - addql #_PAGE_PRESENT,%d1 - movel %a1@,%d2 - movel %d1,%a1@ - lea 5f:w,%a0 - /* no limit, 4byte descriptors */ -3: movel #0x80000002,%a3@ - movel %a5,%a3@(4) - .long 0xf0134800 /* pmove %a3@,%srp */ - .long 0xf0134c00 /* pmove %a3@,%crp */ - .long 0xf0002400 /* pflusha */ - /* - * enable,super root enable,4096 byte pages,7 bit root index, - * 7 bit pointer index, 6 bit page table index. - */ - movel #0x82c07760,%a3@ - .long 0xf0134000 /* pmove %a3@,%tc (enable the MMU) */ - jmp %a0@ -4: clrl %a3@ - .long 0xf0130800 /* pmove %a3@,%tt0 */ - jra LdoneMMUenable -5: movel %d2,%a1@ - jra LdoneMMUenable + /* Convert address range length into # of pages + */ + divul #PAGESIZE,%d0 -Latarimmu68040: - movel %d5,%d0 - jne 1f - lea LdoneMMUenable:w,%a0 - jra 2f -1: lea 3f:w,%a0 - andl #0xff000000,%d0 /* logical address base */ - orw #TTR_ENABLE+TTR_KERNELMODE+_PAGE_NOCACHE_S,%d0 - .long 0x4e7b0004 /* movec %d0,%itt0 */ -2: nop - .word 0xf518 /* pflusha */ - .long 0x4e7bd807 /* movec %a5,%srp */ - .long 0x4e7bd806 /* movec %a5,%urp */ - movel #TC_ENABLE+TC_PAGE4K,%d0 /* - * this value is also ok for the 68060, we don`t use the cache - * mode/protection defaults + * The code that follows implements the following rules + * with respect to the pointer table for this memory mapping + * 1) If the memory to be mapped lies within an already + * mapped region, there will be a pointer table listed + * in the root table. This pointer table must be used. + * 2) If the caller does not supply a pointer table, a table + * will be allocated from above the kernel. + * 3) Else, the caller must have passed the address to memory + * that will be used as the pointer table for this mapping. */ - .long 0x4e7b0003 /* movec %d0,%tc (enable the MMU) */ - jmp %a0@ -3: moveq #0,%d0 - .long 0x4e7b0004 /* movec %d0,%itt0 */ - tstl %a1 - jra LdoneMMUenable - -Lmapphysnotatari: -#endif +mmu_map_check_root_entry: + /* Is another pointer table already mapped into this root entry? + */ + movel %a5@(%d5*4),%d2 + jbeq mmu_map_check_make_new_pointer_table -#ifdef CONFIG_MAC - is_not_mac(Lmapphysnotmac) + /* If there is an entry already, we must use it + * to preserve existing MMU mapping data! + */ + andil #0xFFFFFE00,%d2 /* 040 MMU Ptr mask */ + movel %d2,%a4 + jbra 2f -#ifdef DEBUG_MAC - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - subl #3, %d0 +mmu_map_check_make_new_pointer_table: 1: - moveb #0xFF,%a0@+ /* black - 2 bytes : present */ - dbra %d0,1b -#endif - -#ifdef SERIAL_DEBUG - putc('L') -#endif + /* Should we get a pointer table from memory on behalf of the caller? + */ + cmpl #0x00000000,%a4 + jbne 2f - is_040_or_060(Lmacmmu68040) + jbsr mmu_get_pointer_table - lea %pc@(Lmmu),%a3 - movel %d5,%d0 - /* We always follow this path as the kernel is at 0x0000 after - the MacBoot has finished */ - /* no transparent translation ?? */ - - lea LdoneMMUenable:w,%a0 - movel #0x80000002,%a3@ - movel %a5,%a3@(4) - .long 0xf0134800 /* pmove %a3@,%srp */ - .long 0xf0134c00 /* pmove %a3@,%crp */ - .long 0xf0002400 /* pflusha */ - /* - * enable,super root enable,4096 byte pages,7 bit root index, - * 7 bit pointer index, 6 bit page table index. - */ - movel #0x82c07760,%a3@ - .long 0xf0134000 /* pmove %a3@,%tc (enable the MMU) */ - jmp %a0@ - -Lmacmmu68040: - movel %d5,%d0 - lea LdoneMMUenable:w,%a0 - jra 2f -2: nop - .word 0xf518 /* pflusha */ - .long 0x4e7bd807 /* movec %a5,%srp */ - .long 0x4e7bd806 /* movec %a5,%urp */ - movel #TC_ENABLE+TC_PAGE4K,%d0 - /* - * this value is also ok for the 68060, we don`t use the cache - * mode/protection defaults + /* Put the pointer table into the root table */ - .long 0x4e7b0003 /* movec %d0,%tc (enable the MMU) */ - jmp %a0@ -3: moveq #0,%d0 - .long 0x4e7b0004 /* movec %d0,%itt0 */ - tstl %a1 - jra LdoneMMUenable +2: + movel %a4,%d2 + oril #_PAGE_TABLE,%d2 + movel %d2,%a5@(%d5*4) - /* NOT reached (and if we would try to write to screenmem after MMU - * enable - what happens??) + /* Split up here, 030's have different logic than 040's + */ +3: +/* is_not_040_or_060(mmu_map_030) */ -#if 0 -#ifdef DEBUG_MAC - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - subl #4, %d0 -1: - moveb #0xF0,%a0@+ /* white/black - 3 bytes */ - dbra %d0,1b -#endif -#endif - -Lmapphysnotmac: -#endif - -LdoneMMUenable: +/* + * MMU 040 & 060 Support + * + * The MMU usage for the 040 and 060 is different enough from + * the 030 and 68851 that there is separate code. This comment + * block describes the data structures and algorithms built by + * this code. + * + * The 040 does not support early terminating descriptors, as + * the 030 does. Therefore, a third level of table is needed + * for the 040, and that would be the page table. In Linux, + * page tables are allocated directly from the memory above the + * kernel. Register A6 points to the memory above kernel and + * it is from that pool that page tables are allocated. + * + * For each page table that is allocated from above the kernel, + * that page table's address has to be put into the pointer table. + * Then, each page table has to be fully prepared. Page tables, + * by the way describe a full 256K of memory. That coincides with + * the fact that a single entry in the pointer table describes + * a 256K of memory because a pointer table entry points to a + * complete page table. There are 64 entries in the page table, + * and each entry in the page table points to a physical page of + * memory. Each page is 4K. + * + * Also, there is a label "kpt" which holds the pointer to the + * page table that describes the kernel. This is only true on + * the 040 and 060 cpu's. This algorithm, because it's general + * and allows the mapping of arbitrary regions of memory, assumes + * that the first memory mapping is the one which maps the kernel. + * So it's that page table that gets stored at kpt. + * + * Also, it is an error to attempt to map two regions that + * fall within the same 256K range. For that to work, this routine + * would need to be modified. + * + * + * + */ +mmu_map_040: + /* Turn abstract cache type into 040 cache bits + */ + andil #3,%d1 + movel %pc@(Lmmu_040_cache_flags,%d1*4),%d1 + addw %d1,%a1 -/* - * Fixup the addresses for the kernel pointer table and availmem. - * Convert them from physical addresses to virtual addresses. +mmu_040_loop: + /* See if there is an existing page table pointer to use */ + movel %a4@(%d4*4),%a3 + tstl %a3 + jbne 1f -#ifdef DEBUG_MAC - is_not_mac(2f) - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 /* videoaddr */ - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 - addl %d0,%d0 /* 5 rows */ - subl #4, %d0 -1: - moveb #0x00,%a0@+ /* white - 3 bytes : present */ - dbra %d0,1b -2: -#endif + jbsr mmu_get_page_table -#ifdef SERIAL_DEBUG - putc('M') -#endif - /* - * d5 contains physaddr of kernel start +1: + /* Now, begin assigning physical pages into the page table */ - subl %d5,SYMBOL_NAME(kpt) +mmu_fill_040_pagetable: + movel %a1,%a3@(%d3*4) - /* - * do the same conversion on the first available memory - * address (in a6). + /* Decrement page count */ - subl %d5,%a6 - movel %a6,SYMBOL_NAME(availmem) /* first available memory address */ + subq #1,%d0 + jbeq mmu_map_done -#ifdef SERIAL_DEBUG - putc('N') -#endif + /* Increase mapping addresses + */ + addl #PAGESIZE,%a1 + addl #PAGESIZE,%a0 -#if 0 - putr() - lea SYMBOL_NAME(kernel_pmd_table),%a0 - moveq #63,%d0 -1: moveq #7,%d1 - putn(%a0) - putc(':') - putc(' ') -2: putn(%a0@+) - dbra %d1,2b - putr() - dbra %d0,1b - putr() - movel SYMBOL_NAME(kpt),%a0 - moveq #639,%d0 -1: moveq #7,%d1 - putn(%a0) - putc(':') - putc(' ') -2: putn(%a0@+) - dbra %d1,2b - putr() - dbra %d0,1b -#endif + /* Have we exhausted this page table? + */ + addq #1,%d3 + cmpil #PAGE_TABLE_SIZE,%d3 + jbne mmu_fill_040_pagetable -/* - * Enable caches + /* Have we exhausted this pointer table? */ + clrl %d3 + addq #1,%d4 + cmpil #PTR_TABLE_SIZE,%d4 + jbne mmu_040_loop - /* - ** Will work only if virtual == physical + /* It's an error to exhaust the pointer table + * + * FIXME -- but it's trivial to fix this now */ -#ifdef DEBUG_MAC - is_not_mac(Lcache_notmac) - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 - addl %d0,%d0 - addl %d0,%d0 -1: - moveb #0x33,%a0@+ - dbra %d0,1b -Lcache_notmac: -#endif + movel #4,%d0 + jbra mmu_err - is_040_or_060(Lcache680460) +mmu_map_done: + moveml %sp@+,%d0-%d7/%a0-%a5 + rts - movel #CC3_ENABLE_DB+CC3_CLR_D+CC3_ENABLE_D+CC3_ENABLE_IB+CC3_CLR_I+CC3_ENABLE_I,%d0 - movec %d0,%cacr -#ifdef DEBUG_MAC - is_not_mac(Lcache_notmac030) - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 - addl %d0,%d0 -1: - moveb #0xFF,%a0@+ - dbra %d0,1b -Lcache_notmac030: -#endif +mmu_err: + put3c('E','r','r') - jra 1f + movel %d0,%d7 + jbsr Lserial_putnum -Lcache680460: - .word 0xf4f8 /* cpusha %bc */ + jbsr mmu_print - is_060(Lcache68060) +mmu_fail: + jbra mmu_fail - movel #CC6_ENABLE_D+CC6_ENABLE_I,%d0 - /* MMU stuff works in copyback mode now, so enable the cache */ - movec %d0,%cacr - jra 1f -Lcache68060: - movel #CC6_ENABLE_D+CC6_ENABLE_I+CC6_ENABLE_SB+CC6_PUSH_DPI+CC6_ENABLE_B+CC6_CLRA_B,%d0 - /* MMU stuff works in copyback mode now, so enable the cache */ - movec %d0,%cacr - /* enable superscalar dispatch in PCR */ - moveq #1,%d0 - .long 0x4e7b0808 /* movec d0,pcr */ -1: +mmu_get_page_table: + moveml %a0-%a2/%d0-%d2,%sp@- + + /* See if there is a page table in our cache of page tables + */ + lea %pc@(Lmmu_cached_page_tables),%a2 + movel %a2@,%d2 + jbeq 1f + + andil #0x00000F00,%d2 + jbeq 1f + + /* There is an unused page table in our cache... use it + */ + movel %a2@,%d2 + movel %d2,%a3 + addil #PAGE_TABLE_SIZE*4,%d2 + movel %d2,%a2@ + jbra 2f + +1: /* Get the page table from above the kernel memory + */ + movel %a6,%a3 + addw #PAGESIZE,%a6 /* allocate page for 16 page tables */ + movel %a3,%a2@ +2: + jbsr mmu_clear_page_table + + /* Is this the first page table allocated? + */ + lea %pc@(SYMBOL_NAME(kpt)),%a2 + tst %a2@ + jbne 1f + + /* Store the page table address at kpt. + */ + movel %a3,%a2@ /* save adddress of first page table */ -#ifdef DEBUG_MAC - is_not_mac(Lstart_notmac) - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - movel %a0@(BI_videorow),%d0 /* rowbytes */ - andl #0xFFFF,%d0 /* bytes per rows */ - movel %a0@(BI_videoaddr),%a0 1: - moveb #0x00,%a0@+ - dbra %d0,1b -Lstart_notmac: -#endif + /* Log this page table (%a3) in the pointer table (%a4) + */ + movel %a3,%d2 + orib #2,%d2 /* enable this pointer table entry */ + movel %d2,%a4@(%d4*4) -/* - * Setup initial stack pointer + moveml %sp@+,%a0-%a2/%d0-%d2 + rts + +mmu_get_pointer_table: + moveml %a0-%a2/%d0-%d2,%sp@- + + /* See if there is a pointer table in our cache of pointer tables */ - lea SYMBOL_NAME(init_user_stack)+PAGESIZE,%sp + lea %pc@(Lmmu_cached_pointer_tables),%a2 + movel %a2@,%d2 + jbeq 1f -/* jump to the kernel start */ -/* putr()*/ + andil #0x00000E00,%d2 + jbeq 1f - jbsr SYMBOL_NAME(start_kernel) + /* There is an unused pointer table in our cache... use it + */ + movel %a2@,%d2 + movel %d2,%a4 + addil #PTR_TABLE_SIZE*4,%d2 + movel %d2,%a2@ + jbra 2f -/* - * switch off mmu and exit +1: /* Get the page table from above the kernel memory */ + movel %a6,%a4 + addw #PAGESIZE,%a6 /* allocate page for 8 ptr tables */ + movel %a4,%a2@ +2: + jbsr mmu_clear_pointer_table -#ifdef HACKER_KERNEL -ENTRY(kernel_exit) - lea 2f:w,%a0 - movel %pc@(Lkernel_start),%a0 - lea %a0@(2f:w),%a1 - movel %a1,%d0 - andl #0xff000000,%d0 - jne 1f - jmp %a0@(1f+0x80000000) -1: orw #TTR_ENABLE+TTR_KERNELMODE+_PAGE_NOCACHE_S,%d0 - .long 0x4e7b0004 /* movec %d0,%itt0 */ - jmp %a1@ -2: moveq #0,%d0 - .long 0x4e7b0003 /* movec %d0,%tc (disable the MMU) */ - .word 0xf518 /* pflusha */ - .long 0x4e7b0004 /* movec %d0,%itt0 */ - movec %d0,%cacr - .word 0xf4f8 /* cpusha %bc */ + /* Log this pointer table (%a4) in the root table (%a5) + */ + movel %a4,%d2 + orib #2,%d2 /* enable this pointer table entry */ + movel %d2,%a5@(%d5*4) + + moveml %sp@+,%a0-%a2/%d0-%d2 + rts - lea %pc@(SYMBOL_NAME(boot_info)),%a0 - jmp %a0@(BI_amiga_exit_func:w)@(0:w) -#endif /* * Serial port output support. @@ -1809,8 +1426,7 @@ .even Lserial_init: #ifdef CONFIG_AMIGA - cmpil #MACH_AMIGA,%d4 - jne 1f + is_not_amiga(1f) lea %pc@(SYMBOL_NAME(boot_info)),%a0 bclr #LSERIAL_DTR,LSERIAL_CNTRL movew #LNTSC_PERIOD,LSERPER @@ -1821,8 +1437,7 @@ 1: #endif #ifdef CONFIG_ATARI - cmpil #MACH_ATARI,%d4 - jne 4f + is_not_atari(4f) #ifdef USE_PRINTER bclr #0,LSTMFP_IERB bclr #0,LSTMFP_DDR @@ -1851,22 +1466,13 @@ orb #1,LMFP_TDCDR bset #1,LMFP_TSR #endif -#endif 4: -#ifdef defined(CONFIG_MAC) -#ifdef MACSERIAL - cmpil #MACH_MAC,%d4 - jne 3f - lea #50F04000,%a0 - lea %pc@(scc_initable_mac:w),%a1 -2: moveb %a1@+,%d0 - jmi 3f - moveb %d0,%a0@ - moveb %a1@+,%a0@ - jra 2b -3: clrb %a0@ -#endif /* MACSERIAL */ - +#endif +#if defined(CONFIG_MAC) + is_not_mac(5f) + jbsr Lconsole_init + jbra 9f +5: #endif 9: rts @@ -1876,10 +1482,16 @@ * d7 thrashed. */ Lserial_putc: + cmpib #'\n',%d7 + jbne 1f + + putc(13) /* A little safe recursion is good for the soul */ + moveb #'\n',%d7 +1: moveml %a0/%a1,%sp@- + #ifdef CONFIG_AMIGA - cmpil #MACH_AMIGA,%d4 - jne 2f + is_not_amiga(2f) andw #0x00ff,%d7 oriw #0x0100,%d7 movel %pc@(Lcustom),%a1 @@ -1890,23 +1502,16 @@ jra 9f 2: #endif + #ifdef CONFIG_MAC -#ifdef MACSERIAL - /* check if mac ... */ - cmpil #MACH_MAC,%d4 - jne 4f - /* should check if MAC .. - note this base is for a MacII and later ! */ - lea 0x50F04000,%a1 -3: btst #2,%a1@(0) - jeq 3b - moveb %d7,%a1@(4) + is_not_mac(4f) + jbsr Lconsole_putc jra 9f 4: -#endif /* MACSERIAL */ #endif + #ifdef CONFIG_ATARI - cmpil #MACH_ATARI,%d4 - jne 4f + is_not_atari(4f) movel %pc@(Liobase),%a1 #ifdef USE_PRINTER 3: btst #0,%a1@(LSTMFP_GPIP) @@ -1951,8 +1556,6 @@ /* * Output number in d7 in hex notation on serial port. - * d0-d2 trashed. - * d7 trashed. */ Lserial_putnum: @@ -1975,25 +1578,479 @@ moveml %sp@+,%d0-%d2/%d7 rts +#if defined(CONFIG_MAC) +/* + * For continuity, see the data alignment + * to which this structure is strong tied. + */ +#define Lconsole_struct_cur_column 0 +#define Lconsole_struct_cur_row 4 +#define Lconsole_struct_num_columns 8 +#define Lconsole_struct_num_rows 12 +#define Lconsole_struct_left_edge 16 +#define Lconsole_struct_penguin_putc 20 + +#define MAC_CONSOLE_SCROLL + +Lconsole_init: + /* + * Some of the register usage that follows + * a0 = pointer to boot_info + * a1 = pointer to screen + * a2 = pointer to Lconsole_globals + * d3 = pixel width of screen + * d4 = pixel height of screen + * (d3,d4) ~= (x,y) of a point just below + * and to the right of the screen + * NOT on the screen! + * d5 = number of bytes per scan line + * d6 = number of bytes on the entire screen + */ + moveml %a0-%a4/%d0-%d7,%sp@- + + lea %pc@(SYMBOL_NAME(boot_info)),%a0 + lea %pc@(SYMBOL_NAME(Lconsole_globals)),%a2 + movel %a0@(BI_videoaddr), %a1 + movel %a0@(BI_videorow),%d5 + movel %a0@(BI_dimensions), %d3 + movel %d3,%d4 + swap %d4 + andl #0xffff,%d3 /* d3 = screen width in pixels */ + andl #0xffff,%d4 /* d4 = screen height in pixels */ + + movel %d5,%d6 + mulul %d4,%d6 /* scan line bytes x num scan lines */ + divul #8,%d6 /* we'll clear 8 bytes at a time */ + subq #1,%d6 + +console_clear_loop: + movel #0xffffffff,%a1@+ /* Mac_black */ + movel #0xffffffff,%a1@+ /* Mac_black */ + dbra %d6,console_clear_loop + + /* + * Calculate global maxs + * Note - we can use either an + * 8 x 16 or 8 x 8 character font + */ + movel %d3,%d0 /* screen width in pixels */ + divul #8,%d0 /* d0 = max num chars per row */ + + movel %d4,%d1 /* screen height in pixels */ + divul #FONT_HEIGHT,%d1 /* d1 = max num rows */ + + movel %d0,%a2@(Lconsole_struct_num_columns) + movel %d1,%a2@(Lconsole_struct_num_rows) + + /* + * Clear the current row and column + */ + clrl %a2@(Lconsole_struct_cur_column) + clrl %a2@(Lconsole_struct_cur_row) + clrl %a2@(Lconsole_struct_left_edge) + + /* + * Initialization is complete ... now output some + * debugging information + */ + + jbsr console_put_penguin + +Lconsole_put_stats: + putr() + put3c('M','a','c') + put5c('L','i','n','u','x') + putr() + putr() + +#ifdef SERIAL_DEBUG + put4c(' ','v','i','d') + put5c('a','d','d','r',':'); + movel %a0@(BI_videoaddr), %d7 /* video addr. */ + jbsr Lserial_putnum /* This redirects to console */ + putr() + + put4c(' ',' ','_','s') + put5c('t','e','x','t',':') + lea %pc@(SYMBOL_NAME(_stext)),%a0 + movel %a0,%d7 /* get start addr. */ + jbsr Lserial_putnum + putr() + + put4c('b','o','o','t') + put5c('i','n','f','o',':') + lea %pc@(SYMBOL_NAME(boot_info)),%a0 + movel %a0, %d7 /* write start addr. */ + jbsr Lserial_putnum + putr() + + put5c('c','p','u','i','d') + putc(':') + lea %pc@(SYMBOL_NAME(boot_info)),%a0 + movel %a0@(BI_cputype),%d7 + jbsr Lserial_putnum + putr() + + jbsr mmu_print_machine_cpu_types +#endif + + moveml %sp@+,%a0-%a4/%d0-%d7 + rts + +console_put_penguin: + /* + * Get 'that_penguin' onto the screen in the upper right corner + * penguin is 64 x 74 pixels, align against right edge of screen + */ + moveml %a0-%a1/%d0-%d7,%sp@- + + lea %pc@(SYMBOL_NAME(boot_info)),%a0 + movel %a0@(SYMBOL_NAME(BI_dimensions)),%d0 + andil #0xffff,%d0 + subil #64,%d0 /* snug up against the right edge */ + clrl %d1 /* start at the top */ + movel #73,%d7 + lea %pc@(SYMBOL_NAME(that_penguin)),%a1 +console_penguin_row: + movel #31,%d6 +console_penguin_pixel_pair: + moveb %a1@,%d2 + lsrb #4,%d2 + jbsr console_plot_pixel + addq #1,%d0 + moveb %a1@+,%d2 + jbsr console_plot_pixel + addq #1,%d0 + dbra %d6,console_penguin_pixel_pair + + subil #64,%d0 + addq #1,%d1 + dbra %d7,console_penguin_row + + moveml %sp@+,%a0-%a1/%d0-%d7 + rts + +console_scroll: + moveml %a0-%a4/%d0-%d7,%sp@- + + lea %pc@(SYMBOL_NAME(boot_info)),%a0 + + /* + * Calculate source and destination addresses + * output a1 = dest + * a2 = source + */ + movel %a0@(BI_videoaddr),%a1 + movel %a1,%a2 + movel %a0@(BI_videorow),%d5 + mulul #FONT_HEIGHT,%d5 /* account for # scan lines per character */ + addal %d5,%a2 + + /* + * Get dimensions + */ + movel %a0@(BI_dimensions), %d3 + movel %d3,%d4 + swap %d4 + andl #0xffff,%d3 /* d3 = screen width in pixels */ + andl #0xffff,%d4 /* d4 = screen height in pixels */ + + /* + * Calculate number of bytes to move + */ + movel %a0@(BI_videorow),%d6 + subil #FONT_HEIGHT,%d4 /* we're not scrolling the top row! */ + mulul %d4,%d6 /* scan line bytes x num scan lines */ + divul #32,%d6 /* we'll move 8 bytes at a time */ + subq #1,%d6 + +console_scroll_loop: + movel %a2@+,%a1@+ + movel %a2@+,%a1@+ + movel %a2@+,%a1@+ + movel %a2@+,%a1@+ + movel %a2@+,%a1@+ + movel %a2@+,%a1@+ + movel %a2@+,%a1@+ + movel %a2@+,%a1@+ + dbra %d6,console_scroll_loop + + movel %a0@(BI_videorow),%d6 + mulul #FONT_HEIGHT,%d6 /* scan line bytes x font height */ + divul #32,%d6 /* we'll move 8 bytes at a time */ + subq #1,%d6 + + moveq #-1,%d0 +console_scroll_clear_loop: + movel %d0,%a1@+ + movel %d0,%a1@+ + movel %d0,%a1@+ + movel %d0,%a1@+ + movel %d0,%a1@+ + movel %d0,%a1@+ + movel %d0,%a1@+ + movel %d0,%a1@+ + dbra %d6,console_scroll_clear_loop + + moveml %sp@+,%a0-%a4/%d0-%d7 + rts + +/* + * mac_serial_print + * + * This routine takes its parameters on the stack. It then + * turns around and calls the internal routine. This routine + * is used until the Linux console driver initializes itself. + * + * The calling parameters are: + * void mac_serial_print(const char *str); + * + * This routine does NOT understand variable arguments only + * simple strings! + */ +ENTRY(mac_serial_print) + movel %a0,%sp@- + movel %sp@(8),%a0 /* fetch parameter */ + jbsr Lserial_puts + movel %sp@+,%a0 + rts + + +Lconsole_putc: +/* + * Output character in d7 on console. + */ + moveml %a0/%a1/%d0-%d7,%sp@- + + lea %pc@(Lconsole_globals),%a0 + + cmpib #10,%d7 + jne console_not_lf + movel %a0@(Lconsole_struct_cur_row),%d0 + addil #1,%d0 + movel %d0,%a0@(Lconsole_struct_cur_row) + movel %a0@(Lconsole_struct_num_rows),%d1 + cmpl %d1,%d0 + jcs 1f +#if defined(MAC_CONSOLE_SCROLL) /* regular scrolling code */ + subil #1,%d0 + movel %d0,%a0@(Lconsole_struct_cur_row) + jbsr console_scroll +#else /* make-shift scroller, use dual columns on screen */ + moveq #10,%d0 + movel %d0,%a0@(Lconsole_struct_cur_row) + moveq #52,%d0 + addl %d0,%a0@(Lconsole_struct_left_edge) +#endif +1: + jra console_exit + +console_not_lf: + cmpib #13,%d7 + jne console_not_cr +#if defined(MAC_CONSOLE_SCROLL) + clrl %a0@(Lconsole_struct_cur_column) +#else + movel %a0@(Lconsole_struct_left_edge),%a0@(Lconsole_struct_cur_column) +#endif + jra console_exit + +/* + * At this point we know that the %d7 character is going to be + * rendered on the screen. Register usage is - + * a0 = pointer to console globals + * a1 = font data + * d0 = cursor column + * d1 = cursor row to draw the character + * d7 = character number + */ +console_not_cr: + movel %a0@(Lconsole_struct_cur_column),%d0 + addil #1,%a0@(Lconsole_struct_cur_column) + movel %a0@(Lconsole_struct_num_columns),%d1 + cmpl %d1,%d0 + jcs 1f + movel %d7,%sp@- + putr() /* recursion is OK! */ + movel %sp@+,%d7 +1: + movel %a0@(Lconsole_struct_cur_row),%d1 + + movel #FONT_HEIGHT,%d2 + cmpil #16,%d2 + beq console_8x16 +console_8x8: + lea %pc@(SYMBOL_NAME(fontdata_8x8)),%a1 + jbra console_got_fontaddr + +console_8x16: + lea %pc@(SYMBOL_NAME(fontdata_8x16)),%a1 + +console_got_fontaddr: + andl #0x000000ff,%d7 + mulul #FONT_HEIGHT,%d7 /* d7 = index into font data */ + addl %d7,%a1 /* a1 = points to char image */ + + /* + * At this point we make a shift in register usage + * d0 = pixel coordinate, x + * d1 = pixel coordinate, y + * d2 = (bit 0) 1/0 for white/black (!) pixel on screen + * d3 = font scan line data (8 pixels) + * d6 = count down for the font's pixel width (8) + * d7 = count down for the font's pixel count in height + */ + mulul #8,%d0 + mulul #FONT_HEIGHT,%d1 + moveq #FONT_HEIGHT,%d7 + subq #1,%d7 +console_read_char_scanline: + moveb %a1@+,%d3 + + movel #7,%d6 + +console_do_font_scanline: + lslb #1,%d3 + scsb %d2 /* convert 1 bit into a byte */ + jbsr console_plot_pixel + addq #1,%d0 + dbra %d6,console_do_font_scanline + + subq #8,%d0 + addq #1,%d1 + dbra %d7,console_read_char_scanline + +console_exit: + moveml %sp@+,%a0/%a1/%d0-%d7 + rts + +console_plot_pixel: + /* + * Input: + * d0 = x coordinate + * d1 = y coordinate + * d2 = (bit 0) 1/0 for white/black (!) + * All registers are preserved + */ + moveml %a0-%a1/%d0-%d4,%sp@- + + lea %pc@(SYMBOL_NAME(boot_info)),%a0 + movel %a0@(BI_videoaddr),%a1 + movel %a0@(BI_videodepth),%d3 + mulul %a0@(BI_videorow),%d1 + + /* + * Register usage: + * d0 = x coord becomes byte offset into frame buffer + * d1 = y coord + * d2 = black or white (0/1) + * d3 = video depth + * d4 = temp of x (d0) for many bit depths + * d5 = unused + * d6 = unused + * d7 = unused + */ +test_1bit: + cmpb #1,%d3 + jbne test_2bit + movel %d0,%d4 /* we need the low order 3 bits! */ + divul #8,%d0 + addal %d0,%a1 + addal %d1,%a1 + andb #7,%d4 + eorb #7,%d4 /* reverse the x-coordinate w/ screen-bit # */ + andb #1,%d2 + jbne white_1 + bsetb %d4,%a1@ + jbra console_plot_pixel_exit +white_1: + bclrb %d4,%a1@ + jbra console_plot_pixel_exit + +test_2bit: + cmpb #2,%d3 + jbne test_4bit + movel %d0,%d4 /* we need the low order 2 bits! */ + divul #4,%d0 + addal %d0,%a1 + addal %d1,%a1 + andb #3,%d4 + eorb #3,%d4 /* reverse the x-coordinate w/ screen-bit # */ + lsll #1,%d4 /* ! */ + andb #1,%d2 + jbne white_2 + bsetb %d4,%a1@ + addq #1,%d4 + bsetb %d4,%a1@ + jbra console_plot_pixel_exit +white_2: + bclrb %d4,%a1@ + addq #1,%d4 + bclrb %d4,%a1@ + jbra console_plot_pixel_exit + +test_4bit: + cmpb #4,%d3 + jbne test_8bit + movel %d0,%d4 /* we need the low order bit! */ + divul #2,%d0 + addal %d0,%a1 + addal %d1,%a1 + andb #1,%d4 + eorb #1,%d4 + lsll #2,%d4 /* ! */ + andb #1,%d2 + jbne white_4 + bsetb %d4,%a1@ + addq #1,%d4 + bsetb %d4,%a1@ + addq #1,%d4 + bsetb %d4,%a1@ + addq #1,%d4 + bsetb %d4,%a1@ + jbra console_plot_pixel_exit +white_4: + bclrb %d4,%a1@ + addq #1,%d4 + bclrb %d4,%a1@ + addq #1,%d4 + bclrb %d4,%a1@ + addq #1,%d4 + bclrb %d4,%a1@ + jbra console_plot_pixel_exit + +test_8bit: + cmpb #8,%d3 + jbne console_plot_pixel_exit + addal %d0,%a1 + addal %d1,%a1 + andb #1,%d2 + jbne white_8 + moveb #0xff,%a1@ + jbra console_plot_pixel_exit +white_8: + clrb %a1@ + jbra console_plot_pixel_exit + +console_plot_pixel_exit: + moveml %sp@+,%a0-%a1/%d0-%d4 + rts +#endif + Lshowtest: moveml %a0/%d7,%sp@- - putc('A') - putc('=') + put2c('A','=') putn(%a1) .long 0xf0119f15 | ptestr #5,%a1@,#7,%a0 - putc('D') - putc('A') - putc('=') + put3c('D','A','=') putn(%a0) - putc('D') - putc('=') + put2c('D','=') putn(%a0@) - putc('S') - putc('=') + put2c('S','=') lea %pc@(Lmmu),%a0 .long 0xf0106200 | pmove %psr,%a0@ clrl %d7 @@ -2014,6 +2071,38 @@ Liobase: .long 0 Lmmu: .quad 0 + +Lmachinetype: + .long 0 +Lcputype: + .long 0 +Lconsole_globals: + .long 0 /* cursor column */ + .long 0 /* cursor row */ + .long 0 /* max num columns */ + .long 0 /* max num rows */ + .long 0 /* left edge */ + .long 0 /* mac putc */ + +Lmmu_print_data: + .long 0 /* valid flag */ + .long 0 /* start logical */ + .long 0 /* next logical */ + .long 0 /* start physical */ + .long 0 /* next physical */ + +Lmmu_040_cache_flags: + .long _PAGE_PRESENT+_PAGE_CACHE040 + .long _PAGE_PRESENT+_PAGE_CACHE040W + .long _PAGE_PRESENT+_PAGE_GLOBAL040+_PAGE_NOCACHE_S + .long 0 + +Lmmu_cached_page_tables: + .long 0 + +Lmmu_cached_pointer_tables: + .long 0 + SYMBOL_NAME_LABEL(mac_booter_data) .long 0 SYMBOL_NAME_LABEL(peng_booter_data) diff -rubBwN linux-270897-1/arch/m68k/kernel/setup.c linux-2.0.29/arch/m68k/kernel/setup.c --- linux-270897-1/arch/m68k/kernel/setup.c Mon Sep 22 00:31:40 1997 +++ linux-2.0.29/arch/m68k/kernel/setup.c Sun Sep 21 23:31:41 1997 @@ -91,6 +91,7 @@ extern void register_console(void (*proc)(const char *)); extern void ami_serial_print (const char *str); extern void ata_serial_print (const char *str); +extern void mac_serial_print (const char *str); extern void (*kd_mksound)(unsigned int, unsigned int); @@ -116,6 +117,9 @@ if (MACH_IS_ATARI) register_console(ata_serial_print); + + if (MACH_IS_MAC) + register_console(mac_serial_print); if (CPU_IS_040) m68k_is040or060 = 4; diff -rubBwN linux-270897-1/arch/m68k/mac/config.c linux-2.0.29/arch/m68k/mac/config.c --- linux-270897-1/arch/m68k/mac/config.c Mon Sep 22 00:35:46 1997 +++ linux-2.0.29/arch/m68k/mac/config.c Mon Sep 22 00:24:42 1997 @@ -116,7 +116,8 @@ printk("ERROR: no Mac, but config_mac() called!! \n"); } - mac_debugging_penguin(5); + printk("Welcome to MacLinux!\n"); + printk("Please visit www.maclinux.org\n"); mach_sched_init = mac_sched_init; mach_keyb_init = mac_keyb_init; @@ -259,8 +260,9 @@ if(m->ident==-1) { printk("\nUnknown macintosh model %d.\n", model); - mac_debugging_long(1, (long) 0x55555555); - mac_debugging_long(1, (long) model); +#if 0 + mac_boom(5); +#else model = MAC_MODEL_Q800; printk("Hardcoding: Quadra800, model id %d\n", model); m=&mac_data_table[0]; @@ -272,15 +274,17 @@ } if(m->ident==-1) mac_boom(5); +#endif } + printk (" (%s) \n", m->name); printk (" Booter data:\n"); printk (" Video: addr %lx row %lx depth %lx dimensions %lx\n", boot_info.bi_mac.videoaddr, boot_info.bi_mac.videorow, boot_info.bi_mac.videodepth, boot_info.bi_mac.dimensions); - printk (" Args: %ld boottime %lx GMTBias %ld \n", - boot_info.bi_mac.args, boot_info.bi_mac.boottime, - boot_info.bi_mac.gmtbias); + printk (" Args: %ld CPU type: %lx boottime %lx GMTBias %ld \n", + boot_info.bi_mac.args, boot_info.cputype, + boot_info.bi_mac.boottime, boot_info.bi_mac.gmtbias); printk (" Booter version: %lx video log.: %lx SCC at %lx \n", boot_info.bi_mac.bootver, boot_info.bi_mac.videological, boot_info.bi_mac.scc); @@ -292,9 +296,21 @@ printk (" Printer: %lx handshake: %lx GPI: %lx \n", boot_info.bi_mac.printmf, boot_info.bi_mac.printhsk, boot_info.bi_mac.printgpi); - printk (" CPUid: %lx ROMbase: %ld ADBDelay: %lx timebra: %lx \n", + printk (" CPUid: %lx ROMbase: %lx ADBDelay: %lx timebra: %lx \n", boot_info.bi_mac.cpuid, boot_info.bi_mac.rombase, boot_info.bi_mac.adbdelay, boot_info.bi_mac.timedbra); + + if (CPU_IS_020) + printk("Processor type 020\n"); + + if (CPU_IS_030) + printk("Processor type 030\n"); + + if (CPU_IS_040) + printk("Processor type 040\n"); + + if (CPU_IS_060) + printk("Processor type 060\n"); /* * Save the pointer diff -rubBwN linux-270897-1/arch/m68k/mac/macfb.c linux-2.0.29/arch/m68k/mac/macfb.c --- linux-270897-1/arch/m68k/mac/macfb.c Mon Sep 22 00:35:46 1997 +++ linux-2.0.29/arch/m68k/mac/macfb.c Sun Sep 21 02:04:55 1997 @@ -306,179 +306,42 @@ /* * These two auxiliary debug functions should go away ASAP. Only usage: * before the console output is up (after head.S come some other crucial - * setup routines :-) it permits writing 'data' to the screen as bit patterns - * (good luck reading those). Helped to figure that the bootinfo contained + * setup routines :-) it permits writing data to the screen. + * Helped to figure that the bootinfo contained * garbage data on the amount and size of memory chunks ... - * - * The 'pos' argument now simply means 'linefeed after print' ... */ -static int peng=0, line=0; - void mac_debugging_short(int pos, short num) { - unsigned char *pengoffset; - unsigned char *pptr; - int i; - - if (MACH_IS_ATARI || MACH_IS_AMIGA) { - /* printk("debug: %d !\n", num); */ - return; - } - - /* calculate current offset */ - pengoffset=(unsigned char *)(boot_info.bi_mac.videoaddr+ - (20+line*2)*boot_info.bi_mac.videorow)+80*peng; - - pptr=pengoffset; - - for(i=0;i<8*sizeof(short);i++) /* # of bits */ - { - /* value mask for bit i, reverse order */ - *pptr++ = (num & ( 1 << (8*sizeof(short)-i-1) ) ? 0xFF : 0x00); - } - - peng++; - - if (pos) { - line++; - peng = 0; - } + printk("debug- (%d, %d)\n", pos, num); } void mac_debugging_long(int pos, long addr) { - unsigned char *pengoffset; - unsigned char *pptr; - int i; - - if (MACH_IS_ATARI || MACH_IS_AMIGA) { - /* printk("debug: #%ld !\n", addr); */ - return; - } - - pengoffset=(unsigned char *)(boot_info.bi_mac.videoaddr+ - (20+line*2)*boot_info.bi_mac.videorow)+80*peng; - - pptr=pengoffset; - - for(i=0;i<8*sizeof(long);i++) /* # of bits */ - { - *pptr++ = (addr & ( 1 << (8*sizeof(long)-i-1) ) ? 0xFF : 0x00); + printk("debug- (%d, %lX)\n", pos, addr); } - peng++; - - if (pos) { - line++; - peng = 0; - } -} - -static char that_penguin[]={ +char that_penguin[]={ #include "that_penguin.h" }; -/* - * B/W version of penguin, unfinished - any takers?? - */ -static char bw_penguin[]={ -#include "bw_penguin.h" -}; - void mac_debugging_penguin(int peng) { - unsigned char *pengoffset; - unsigned char *pptr; - unsigned char *pdptr=that_penguin; - unsigned char *bwpdptr=bw_penguin; - int i; - - if (MACH_IS_ATARI || MACH_IS_AMIGA) { - printk("Penguin #%d !\n", peng); - return; + printk("Pengiun #%d\n",peng); } - if (boot_info.bi_mac.videodepth ==1) - pengoffset=(unsigned char *)(boot_info.bi_mac.videoaddr+ - 64*boot_info.bi_mac.videorow)+10*peng; - else - pengoffset=(unsigned char *)(boot_info.bi_mac.videoaddr+ - 64*boot_info.bi_mac.videorow)+40*peng; - - pptr=pengoffset; - - for(i=0;i<74;i++) - { - if (boot_info.bi_mac.videodepth ==1) { - memcpy(pptr,bwpdptr,8); - bwpdptr+=8; - } else { - memcpy(pptr,pdptr,32); - pdptr+=32; - } - pptr+=boot_info.bi_mac.videorow; - } -} - -static char kaboom_map[]={ -#include "mac.h" -}; - -/* - * B/W version of flaming Mac, unfinished (see above). - */ -static char bw_kaboom_map[]={ -#include "bw_mac.h" -}; - static void mac_boom_boom(void) { - static unsigned char *boomoffset=NULL; - unsigned char *pptr; - unsigned char *pdptr=kaboom_map; - unsigned char *bwpdptr=bw_kaboom_map; - int i; - - if(!boomoffset) - if (boot_info.bi_mac.videodepth == 1) { - boomoffset=(unsigned char *)(boot_info.bi_mac.videoaddr+ - 160*boot_info.bi_mac.videorow); - } else { - boomoffset=(unsigned char *)(boot_info.bi_mac.videoaddr+ - 256*boot_info.bi_mac.videorow); - } - else - if (boot_info.bi_mac.videodepth == 1) - boomoffset+=10; - else - boomoffset+=32; - - pptr=boomoffset; - - for(i=0;i<74;i++) - { - if (boot_info.bi_mac.videodepth ==1) { - memcpy(pptr,bwpdptr,8); - bwpdptr+=8; - } else { - memcpy(pptr,pdptr,32); - pdptr+=32; - } - pptr+=boot_info.bi_mac.videorow; - } + printk("Boom!! Kapoow!\n"); } void mac_boom(int booms) { int i; - if (MACH_IS_ATARI || MACH_IS_AMIGA) { printk("Boom #%d !\n", booms); - return; - } - for(i=0;i> 18) & 0x7f; - mac_debugging_long(0, (long) kpointerp); - mac_debugging_long(1, (long) pindex); #ifdef DEBUG printk ("mm=%ld, kernel_pg_dir=%p, kpointerp=%p, pindex=%d\n", @@ -168,16 +164,14 @@ for (physaddr = addr; physaddr < addr + size; mem_mapped += L3TREESIZE, virtaddr += L3TREESIZE) { - mac_debugging_long(1, (long) physaddr); - #ifdef DEBUG - printk ("pa=%#lx va=%#lx ", physaddr, virtaddr); +// printk ("pa=%#lx va=%#lx ", physaddr, virtaddr); #endif if (pindex > 127 && mem_mapped >= 32*ONEMEG) { /* we need a new pointer table every 32M */ #ifdef DEBUG - printk ("[new pointer]"); +// printk ("[new pointer]"); #endif kpointerp = (unsigned long *)get_kpointer_table (); @@ -189,7 +183,6 @@ int i; unsigned long ktable; - mac_debugging_short(1, 3); /* Don't map the first 4 MB again. The pagetables * for this range have already been initialized * in boot/head.S. Otherwise the pages used for @@ -199,14 +192,14 @@ if (mem_mapped < 4 * ONEMEG) { #ifdef DEBUG - printk ("Already initialized\n"); +// printk ("Already initialized\n"); #endif physaddr += L3TREESIZE; pindex++; continue; } #ifdef DEBUG - printk ("[setup table]"); +// printk ("[setup table]"); #endif /* @@ -217,7 +210,7 @@ if ((pindex & 15) == 0) { /* Need new page table every 4M on the '040 */ #ifdef DEBUG - printk ("[new table]"); +// printk ("[new table]"); #endif ktablep = kernel_page_table (memavailp); } @@ -244,7 +237,6 @@ kpointerp[pindex++] = ktable | _PAGE_TABLE | _PAGE_ACCESSED; } else { - mac_debugging_short(0, 4); /* * 68030, use early termination page descriptors. * Each one points to 64 pages (256K). @@ -261,7 +253,6 @@ int i; unsigned long *tbl; - mac_debugging_short(1, 5); tbl = (unsigned long *)get_kpointer_table(); kpointerp[pindex++] = VTOP(tbl) | _PAGE_TABLE |_PAGE_ACCESSED; @@ -272,7 +263,6 @@ /* unmap the zero page */ tbl[0] = 0; } else { - mac_debugging_short(1, 6); /* not the first 256K */ kpointerp[pindex++] = physaddr | _PAGE_PRESENT | _PAGE_ACCESSED; #ifdef DEBUG @@ -283,11 +273,10 @@ } } #ifdef DEBUG - printk ("\n"); +// printk ("\n"); #endif } - mac_debugging_long(0, (long) mem_mapped); return mem_mapped; } @@ -316,14 +305,6 @@ } #endif - mac_debugging_long(1, 0x55555555); -#ifdef MAC_DEBUG_PGINIT - mac_debugging_long(1, kernel_pg_dir); - mac_debugging_long(0, availmem); - mac_debugging_long(0, start_mem); - mac_debugging_long(1, end_mem); -#endif - init_kpointer_table(); /* Fix the cache mode in the page descriptors for the 680[46]0. */ @@ -341,10 +322,15 @@ * address space. It may allocate some memory for page * tables and thus modify availmem. */ +#ifdef DEBUG + printk("Printing out boot_info mappings\n"); +#endif for (chunk = 0; chunk < boot_info.num_memory; chunk++) { - mac_debugging_long(0, boot_info.memory[chunk].addr); - mac_debugging_long(1, boot_info.memory[chunk].size); +#ifdef DEBUG + printk("Memory range begins :%lX\n",boot_info.memory[chunk].addr); + printk("Memory range size :%lX\n",boot_info.memory[chunk].size); +#endif mem_avail = map_chunk (boot_info.memory[chunk].addr, boot_info.memory[chunk].size, &availmem); @@ -348,11 +334,9 @@ mem_avail = map_chunk (boot_info.memory[chunk].addr, boot_info.memory[chunk].size, &availmem); - } - flush_tlb_all(); - mac_debugging_long(1, 0x55555555); + flush_tlb_all(); #ifdef DEBUG printk ("memory available is %ldKB\n", mem_avail >> 10); @@ -364,12 +348,6 @@ */ start_mem = availmem; - mac_debugging_long(1, 0x55555555); -#ifdef MAC_DEBUG_PGINIT - mac_debugging_long(0, start_mem); - mac_debugging_long(1, end_mem); -#endif - #ifdef DEBUG printk ("start_mem is %#lx\nvirtual_end is %#lx\n", start_mem, end_mem); diff -rubBwN linux-270897-1/init/main.c linux-2.0.29/init/main.c --- linux-270897-1/init/main.c Mon Sep 22 00:32:06 1997 +++ linux-2.0.29/init/main.c Sun Sep 21 23:32:53 1997 @@ -798,11 +798,6 @@ extern struct consw fb_con; extern u_long fbcon_startup(u_long, char **); - if(fb_con.con_startup!=fbcon_startup) - mac_boom(1); - - mac_debugging_penguin(0); - /* * This little check will move. */ @@ -820,14 +815,26 @@ * enable them */ setup_arch(&command_line, &memory_start, &memory_end); - mac_debugging_penguin(1); + printk("Setup_arch complete\n"); + memory_start = paging_init(memory_start,memory_end); - mac_debugging_penguin(2); + printk("Memory_start complete\n"); + trap_init(); + printk("Trap_init complete\n"); + init_IRQ(); + printk("Init_IRQ complete\n"); + sched_init(); + printk("Sched_init complete\n"); + time_init(); + printk("Time_init complete\n"); + parse_options(command_line); + printk("Parse_options complete\n"); + #ifdef CONFIG_MODULES init_modules(); #endif .