Resent-Date: Thu, 31 Dec 1998 00:33:46 +0100 (MET) Sender: schmitz@lbl.gov Date: Wed, 30 Dec 1998 15:33:37 -0800 From: Michael Schmitz Organization: Tinoco Lab, UC Berkekely / Lawrence Berkeley Laboratory To: linux-m68k@lists.linux-m68k.org CC: linux-mac68k@baltimore.wwaves.com, ddkilzer@earthlink.net Subject: Mac68k patch for 2.1.131 Resent-From: linux-m68k@phil.uni-sb.de This is a multi-part message in MIME format. --------------4512410F37455D20F52AFE7B Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, it's getting smaller with each time, but there's still some Mac stuff missing in Jes' 2.1.131 (I know, I'm lame to post a 2.1.131 patch while 2.2 is out but what the heck :-P). I take it as the ideal opportunity to sync my changes with Dave Kilzer before he takes over the Mac operations again (have fun with 2.2, Dave). In particular: - head.S, the Mac version again (and I'm not taking "there's Roman's experimental patch" for an answer; it didn't even compile). It's mainly for the benefit of Mac hackers, and for those of the m68k crowd who want to test this version on other machines. It works on my Falcon, but broke on Jes' Amiga. - arch/m68k/mac/config.c: Changes to the Mac model config table: Color Classic ADB is CUDA, Centris 610/650 have Sonic ethernet. - arch/m68k/mac/debug.c: avoid undefined *console_wait_key if building without serial console support. - arch/m68k/mac/macboing.c: Juergen Mellinger's patches for Quadra sound chips. Needs someone to write a nice algorithm to interpolate a 800 point sine wave instead of the triangle function. - arch/m68k/mac/macints.c: cleanup Nubus interrupt handling and add IDE IRQ pending check to run IDE interrupts just like other Nubus interrupts in the inner loop. Fix mis-counting of spurious interrupts, fix Nubus interrupt logging in /proc/ and disable Nubus interrupt until the first handler is registered. - arch/m68k/config.in: comment out MACE ethernet option (driver not included). - drivers/block/macide.c: implement Mac IDE interrupt check function for Nubus code (should probably be registered in the Mac IDE driver struct?). Geert: If that solution is a major no-no, I'll change the interrupt handler for Quadra IDE so can always be called and will only call ide_intr if there's a pending IRQ. - drivers/net/macsonic.c: Mac specific Sonic driver - drivers/net/jazzsonic.c: Mips specific Sonic driver - drivers/net/sonic.[ch]: core code included by the above. - drivers/net/Makefile, drivers/net/Space.c: include macsonic and jazzsonic. The Sonic driver is basically functional on Mac, so I see no reason not to include it. The split into Jazz and Mac and generic parts was Alan's work, I just got the Mac part to work. Left out, pending: 5380 SCSI patches - the current status is most probably broken when using disconnects and multiple disks, but I'm leaving it that way until someone bothers to tell me what exactly is OK to do about the race conditions in the driver without stepping on the Intel people's toes. BTW, I'm still waiting for a reply from Lenoard Zubkoff. 5380 pseudo DMA has been started to evolve but I haven't seen any patches yet. Mac Quadra color mapping code from Juergen Mellinger (no time to separate that code from the other macfb.c changes, sorry). Machine specfic reset, halt and poweroff code: needs more work on non-CUDA Macs (map in ROM and pass ROM base address from booter), Dave has the original code. The mystical Powerbook ADB: wishlist item, nice to have to complete the Mac support, no time for it. Same goes for other nifty ADB features. FPU emulator - basics are working in 2.1, badly broken in 2.0, waitng for David Huggins-Daines to add one missing addressing mode and it should work for most things in 2.1. Not quite there yet, but definitely coming soon. Credits for the FOU emulator are due Roman Zippel (for the gory work of the trap handling, instruction decoding and addressing stuff) and David Huggins-Daines (for addimg some more gory stuff, filling in the basic math and bringing it to life on a LC040). (For the very adventurous: FPE patches are on the Mac FTP site. I'd be glad if someone familiar with the entry.S and signal code could carefully check the 2.0 patch; I've done something very silly there so it works fine when testing it with nonstandard FPU IDs on my Falcon, but crashes horribly on a 030 without FPU). I'll keep helping with the FPU support, 5380 SCSI unless someone else volunteers to push that one (and some of the pending items, but that'll be merged via Dave again in future). Michael --------------4512410F37455D20F52AFE7B Content-Type: application/octet-stream; name="mac-2.1.131-981229" Content-Transfer-Encoding: x-uuencode Content-Disposition: attachment; filename="mac-2.1.131-981229" --- linux-2.1.131/arch/m68k/kernel/head.S.org Wed Dec 30 10:08:59 1998 +++ linux-2.1.131/arch/m68k/kernel/head.S Wed Dec 30 10:09:06 1998 @@ -7,9 +7,11 @@ ** ** 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 +** VME Support by Richard Hirst ** ** 94/11/14 Andreas Schwab: put kernel at PAGESIZE ** 94/11/18 Andreas Schwab: remove identity mapping of STRAM for Atari @@ -18,13 +20,15 @@ ** 96/04/26 Guenther Kelleter: fixed identity mapping for Falcon with ** Magnum- and FX-alternate ram ** 98/04/25 Phil Blundell: added HP300 support +** 1998/08/30 David Kilzer: Added support for fbcon_font_desc structures +** for linux-2.1.115 ** ** This file is subject to the terms and conditions of the GNU General Public ** License. See the file README.legal in the main directory of this archive ** for more details. ** */ - + /* * Linux startup code. * @@ -34,37 +38,225 @@ * Put us in supervisor state. * * The kernel setup code takes the following steps: - * Raise interrupt level - * Set up initial kernel memory mapping. - * This sets up a mapping of the 4M of memory the kernel - * is located in. It also does a mapping of any initial - * machine specific areas. - * Note that the kernel is located at virtual address 0x1000 == _start - * Enable cache memories - * Jump to kernel startup - * - * Register d6 contains the CPU flags and d4 the machine type - * from the boot_info information for most of this file. - * The upper word of d6 contains a bit for '040 or '060, since these two - * are quite similar for initial mm setup. Another bit in d6 allows - * distinction of the '060. The lower word of d6 contains the cache mode - * that should be applied to pages containing descriptors. This mode is - * non-cached/non-serialized for the '040 and cacheable/write-through for - * the '060. - * - * General register usage: - * a6 - start of unused memory - * new pages can be allocated from here - * a5 - mmu root table - * a4 - mmu pointer table - * a3 - mmu page tables - * a2 - points to the page table entry for a6 - * cache status can be changed (used for '0[46]0) - * you must increase a2 if alloc a new page - * d7 - used for debug output and some macros - * d6 - cpu type and cache mode - * d5 - physical start address of kernel - * d4 - machine type + * . Raise interrupt level + * . Set up initial kernel memory mapping. + * . This sets up a mapping of the 4M of memory the kernel is located in. + * . It also does a mapping of any initial machine specific areas. + * . Enable the MMU + * . Enable cache memories + * . Jump to kernel startup + * + * Much of the file restructuring was to accomplish: + * 1) Reduce register dependency through-out the file. + * 2) Increase use of subroutines to perform functions + * 3) Increase readability of the code + * + * Of course, readability is a subjective issue, so it will never be + * argued that that goal was accomplished. It was merely a goal. + * A key way to help make code more readable is to give good + * documentation. So, the first thing you will find is exaustive + * write-ups on the structure of the file, and the features of the + * functional subroutines. + * + * General Structure: + * ------------------ + * Without a doubt the single largest chunk of head.S is spent + * mapping the kernel and I/O physical space into the logical range + * for the kernel. + * There are new subroutines and data structures to make MMU + * support cleaner and easier to understand. + * First, you will find a routine call "mmu_map" which maps + * a logical to a physical region for some length given a cache + * type on behalf of the caller. This routine makes writing the + * actual per-machine specific code very simple. + * A central part of the code, but not a subroutine in itself, + * is the mmu_init code which is broken down into mapping the kernel + * (the same for all machines) and mapping machine-specific I/O + * regions. + * Also, there will be a description of engaging the MMU and + * caches. + * You will notice that there is a chunk of code which + * can emit the entire MMU mapping of the machine. This is present + * only in debug modes and can be very helpful. + * Further, there is a new console driver in head.S that is + * also only engaged in debug mode. Currently, it's only supported + * on the Macintosh class of machines. However, it is hoped that + * others will plug-in support for specific machines. + * + * ###################################################################### + * + * mmu_map + * ------- + * mmu_map was written for two key reasons. First, it was clear + * that it was very difficult to read the previous code for mapping + * regions of memory. Second, the Macintosh required such extensive + * memory allocations that it didn't make sense to propogate the + * existing code any further. + * mmu_map requires some parameters: + * + * mmu_map (logical, physical, length, cache_type) + * + * While this essentially describes the function in the abstract, you'll + * find more indepth description of other parameters at the implementation site. + * + * mmu_get_page_table + * ------------------ + * mmu_get_pointer_table + * --------------------- + * These routines are used by mmu_map to get fresh tables. They + * will allocate a new page of memory and consume page tables from that page + * until the page has been exausted. Unfortunately, the kernel code uses + * a wacky and not very efficient mechanism for re-using pages of memory + * allocated for page tables. Therefore, while this code does set the kpt + * global to a correct value upon initial usage, it doesn't help. + * + * mmu_clear_root_table + * -------------------- + * mmu_clear_pointer_table + * ----------------------- + * mmu_clear_page_table + * -------------------- + * Given a pointer to a table, these routines will clear it. + * Sometimes writing well factored code can be a source of pride. + * + * ###################################################################### + * + * mmu_init + * -------- + * Here is where the MMU is initialized for the various platforms. + * First, the kernel is mapped for all platforms at the address computed + * as the current address (which is known to be physical) and mapped down + * to logical 0x01000. Then there is logic on a per-machine basis. + * + * ###################################################################### + * + * mmu_engage + * ---------- + * The MMU engagement code is quite extensive and there is ample + * description of the algorithm in all it's gory detail at the site of the + * evil deed. However, allow me to state that magic takes place there. + * + * ###################################################################### + * + * mmu_print + * --------- + * This algorithm will print out the page tables of the system as + * appropriate for an 030 or an 040. This is useful for debugging purposes + * and as such is enclosed in #ifdef MMU_PRINT/#endif clauses. + * + * ###################################################################### + * + * Lconsole_init + * ------------- + * The console is also able to be turned off. The console in head.S + * is specifically for debugging and can be very useful. It is surrounded by + * #ifdef CONSOLE/#endif clauses so it doesn't have to ship in known-good + * kernels. It's basic algorithm is to determine the size of the screen + * (in height/width and bit depth) and then use that information for + * displaying an 8x8 font or an 8x16 (widthxheight). I prefer the 8x8 for + * debugging so I can see more good data. But it was trivial to add support + * for both fonts, so I included it. + * Also, the algorithm for plotting pixels is abstracted so that in + * theory other platforms could add support for different kinds of frame + * buffers. This could be very useful. + * + * Lconsole_put_penguin + * -------------------- + * An important part of any Linux bring up is the penguin and there's + * nothing like getting the Penguin on the screen! This algorithm will work + * on any machine for which there is a console_plot_pixel. + * + * console_scroll + * -------------- + * My hope is that the scroll algorithm does the right thing on the + * various platforms, but it wouldn't be hard to add the test conditions + * and new code if it doesn't. + * + * console_putc + * ------------- + * + * ###################################################################### + * + * The only register that is passed through out the system are: + * . A7 -- Stack Pointer (duh) + * . A6 -- Top of Kernel, available pages are taken from here + * . A5 -- Ptr to Root Table + * . D5 -- Ptr to __start (physical) + * Many other registers are used as passed parameters into + * functions or used within functions. + * + * Reducing the register usage from a dozen to a few greatly simplified + * head.S. + * + * ###################################################################### + * + * options + * ------- + * There are many options availble in a build of this file. I've + * taken the time to describe them here to save you the time of searching + * for them and trying to understand what they mean. + * + * CONFIG_xxx: These are the obvious machine configuration defines created + * during configuration. These are defined in include/linux/autoconf.h. + * + * CONSOLE: There is support for head.S console in this file. This + * console can talk to a Mac frame buffer, but could easily be extrapolated + * to extend it to support other platforms. + * + * TEST_MMU: This is a test harness for running on any given machine but + * getting an MMU dump for another class of machine. The classes of machines + * that can be tested are any of the makes (Atari, Amiga, Mac, VME, etc.) + * and any of the models (030, 040, 060, etc.). + * + * NOTE: TEST_MMU is NOT permanent! It is scheduled to be removed + * When head.S boots on Atari, Amiga, Macintosh, and VME + * machines. At that point the underlying logic will be + * believed to be solid enough to be trusted, and TEST_MMU + * can be dropped. Do note that that will clean up the + * head.S code significantly as large blocks of #if/#else + * clauses can be removed. + * + * MMU_NOCACHE_KERNEL: On the Macintosh platform there was an inquiry into + * determing why devices don't appear to work. A test case was to remove + * the cacheability of the kernel bits. + * + * MMU_PRINT: There is a routine built into head.S that can display the + * MMU data structures. It outputs its result through the Lserial_putc + * interface. So where ever that winds up driving data, that's where the + * mmu struct will appear. On the Macintosh that's typically the console. + * + * SERIAL_DEBUG: There are a series of putc() macro statements + * scattered through out the code to give progress of status to the + * person sitting at the console. This constant determines whether those + * are used. + * + * DEBUG: This is the standard DEBUG flag that can be set for building + * the kernel. It has the effect adding additional tests into + * the code. + * + * MMU_PRINT_PAGE_USAGE: + * Print the number of pages used by the MMU tables. + * + * FONT_6x11: + * FONT_8x8: + * FONT_8x16: + * In theory these could be determined at run time or handed + * over by the booter. But, let's be real, it's a fine hard + * coded value. (But, you will notice the code is run-time + * flexible!) A pointer to the font's struct fbcon_font_desc + * is kept locally in Lconsole_font. It is used to determine + * font size information dynamically. + * + * Atari constants: + * USE_PRINTER: Use the printer port for serial debug. + * USE_SCC_B: Use the SCC port A (Serial2) for serial debug. + * USE_SCC_A: Use the SCC port B (Modem2) for serial debug. + * USE_MFP: Use the ST-MFP port (Modem1) for serial debug. + * + * Macintosh constants: + * MAC_SERIAL_DEBUG: Turns on serial debug output for the Macintosh. + * MAC_USE_SCC_A: Use the SCC port A (modem) for serial debug. + * MAC_USE_SCC_B: Use the SCC port B (printer) for serial debug (default). */ #include @@ -72,11 +264,67 @@ #include #include #include +#if defined(CONFIG_MAC) +#include