diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/MAINTAINERS ./MAINTAINERS
--- /home/jskov/kernel/dist/linux-2.2.8/MAINTAINERS	Tue May 11 11:25:22 1999
+++ ./MAINTAINERS	Sun May 16 11:35:29 1999
@@ -442,6 +442,13 @@
 L:	linux-pmac@samba.anu.edu.au
 S:	Maintained
 
+LINUX FOR POWERUP AMIGA (POWERPC/APUS)
+P:	Jesper Skov
+M:	jskov@cygnus.co.uk
+W:	http://sunsite.auc.dk/ftp/pub/os/linux/apus/docs/faq.html
+L:	linux-apus@sunsite.auc.dk
+S:	Maintained
+
 M68K
 P:	Jes Sorensen
 M:	Jes.Sorensen@cern.ch
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/Makefile ./Makefile
--- /home/jskov/kernel/dist/linux-2.2.8/Makefile	Tue May 11 11:25:22 1999
+++ ./Makefile	Sat May 15 11:36:59 1999
@@ -3,7 +3,7 @@
 SUBLEVEL = 8
 EXTRAVERSION =
 
-ARCH := m68k
+ARCH := ppc
 
 .EXPORT_ALL_VARIABLES:
 
@@ -18,7 +18,11 @@
 HOSTCC  	=gcc
 HOSTCFLAGS	=-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
 
+ifeq (ppc,$(shell uname -m))
 CROSS_COMPILE 	=
+else
+CROSS_COMPILE 	= powerpc-unknown-linux-
+endif
 
 AS	=$(CROSS_COMPILE)as
 LD	=$(CROSS_COMPILE)ld
@@ -87,6 +91,13 @@
 #
 
 CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
+
+# No -fomit-frame-pointer if compiling a kernel with KGDB support.
+ifeq ($(CONFIG_KGDB),y)
+HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -g
+CFLAGS = -Wall -Wstrict-prototypes -O2 -g
+endif
+
 
 ifdef CONFIG_SMP
 CFLAGS += -D__SMP__
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/Makefile ./arch/ppc/amiga/Makefile
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/Makefile	Fri Aug  7 15:53:32 1998
+++ ./arch/ppc/amiga/Makefile	Sat Apr  3 10:27:01 1999
@@ -12,4 +12,8 @@
             bootinfo.o amisound.o chipram.o ints.o
 OX_OBJS  := amiga_ksyms.o
 
+ifdef CONFIG_AMIGA_PCMCIA
+O_OBJS := $(O_OBJS) pcmcia.o
+endif
+
 include $(TOPDIR)/Rules.make
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/amiints.c ./arch/ppc/amiga/amiints.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/amiints.c	Sat Jan  9 18:30:34 1999
+++ ./arch/ppc/amiga/amiints.c	Sun May 16 20:07:50 1999
@@ -1,7 +1,3 @@
-/* Rename a few functions. */
-#define amiga_request_irq request_irq
-#define amiga_free_irq free_irq
-
 /*
  * linux/arch/m68k/amiga/amiints.c -- Amiga Linux interrupt handling code
  *
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/bootinfo.c ./arch/ppc/amiga/bootinfo.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/bootinfo.c	Mon Jan  4 11:30:09 1999
+++ ./arch/ppc/amiga/bootinfo.c	Mon Jan 11 21:44:38 1999
@@ -16,9 +16,11 @@
 
 extern char cmd_line[CL_SIZE];
 
-int num_memory = 0;
-struct mem_info memory[NUM_MEMINFO];
-struct mem_info ramdisk;
+extern int num_memory;
+extern int m68k_realnum_memory;
+extern struct mem_info memory[NUM_MEMINFO];
+extern struct mem_info m68k_memory[NUM_MEMINFO];
+extern struct mem_info ramdisk;
 
 extern int amiga_parse_bootinfo(const struct bi_record *);
 extern int atari_parse_bootinfo(const struct bi_record *);
@@ -42,6 +44,11 @@
 		    memory[num_memory].addr = data[0];
 		    memory[num_memory].size = data[1];
 		    num_memory++;
+
+		    /* FIXME: duplicate for m68k drivers. */
+		    m68k_memory[m68k_realnum_memory].addr = data[0];
+		    m68k_memory[m68k_realnum_memory].size = data[1];
+		    m68k_realnum_memory++;
 		} else
 		    printk("parse_bootinfo: too many memory chunks\n");
 		break;
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/chipram.c ./arch/ppc/amiga/chipram.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/chipram.c	Fri Aug  7 15:53:33 1998
+++ ./arch/ppc/amiga/chipram.c	Sun Nov 22 13:30:45 1998
@@ -1 +1,174 @@
-#include "../../m68k/amiga/chipram.c"
+/*
+**  linux/amiga/chipram.c
+**
+**      Modified 03-May-94 by Geert Uytterhoeven
+**                           (Geert.Uytterhoeven@cs.kuleuven.ac.be)
+**          - 64-bit aligned allocations for full AGA compatibility
+*/
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <asm/amigahw.h>
+
+struct chip_desc {
+	unsigned first   :  1;
+	unsigned last    :  1;
+	unsigned alloced :  1;
+	unsigned length  : 24;
+	long pad;					/* We suppose this makes this struct 64 bits long!! */
+};
+
+#define DP(ptr) ((struct chip_desc *)(ptr))
+
+u_long amiga_chip_size;
+static unsigned long chipavail;
+
+unsigned long amiga_chip_avail( void )
+{
+#ifdef DEBUG
+	printk("chip_avail : %ld bytes\n",chipavail);
+#endif
+	return chipavail;
+}
+
+
+__initfunc(void amiga_chip_init (void))
+{
+  struct chip_desc *dp;
+
+  if (!AMIGAHW_PRESENT(CHIP_RAM))
+    return;
+
+#ifndef CONFIG_APUS_FAST_EXCEPT
+  /*
+   * Remove the first 4 pages where PPC exception handlers will
+   * be located.
+   */
+  amiga_chip_size -= 0x4000;
+#endif
+
+  /* initialize start boundary */
+
+  dp = DP(chipaddr);
+  dp->first = 1;
+
+  dp->alloced = 0;
+  dp->length = amiga_chip_size - 2*sizeof(*dp);
+
+  /* initialize end boundary */
+  dp = DP(chipaddr + amiga_chip_size) - 1;
+  dp->last = 1;
+  
+  dp->alloced = 0;
+  dp->length = amiga_chip_size - 2*sizeof(*dp);
+  chipavail = dp->length;  /*MILAN*/
+
+#ifdef DEBUG
+  printk ("chipram end boundary is %p, length is %d\n", dp,
+	  dp->length);
+#endif
+}
+
+void *amiga_chip_alloc (long size)
+{
+	/* last chunk */
+	struct chip_desc *dp;
+	void *ptr;
+
+	/* round off */
+	size = (size + 7) & ~7;
+
+#ifdef DEBUG
+   printk("chip_alloc: allocate %ld bytes\n", size);
+#endif
+
+	/*
+	 * get pointer to descriptor for last chunk by 
+	 * going backwards from end chunk
+	 */
+	dp = DP(chipaddr + amiga_chip_size) - 1;
+	dp = DP((unsigned long)dp - dp->length) - 1;
+	
+	while ((dp->alloced || dp->length < size)
+	       && !dp->first)
+		dp = DP ((unsigned long)dp - dp[-1].length) - 2;
+
+	if (dp->alloced || dp->length < size) {
+		printk ("no chipmem available for %ld allocation\n", size);
+		return NULL;
+	}
+
+	if (dp->length < (size + 2*sizeof(*dp))) {
+		/* length too small to split; allocate the whole thing */
+		dp->alloced = 1;
+		ptr = (void *)(dp+1);
+		dp = DP((unsigned long)ptr + dp->length);
+		dp->alloced = 1;
+#ifdef DEBUG
+		printk ("chip_alloc: no split\n");
+#endif
+	} else {
+		/* split the extent; use the end part */
+		long newsize = dp->length - (2*sizeof(*dp) + size);
+
+#ifdef DEBUG
+		printk ("chip_alloc: splitting %d to %ld\n", dp->length,
+			newsize);
+#endif
+		dp->length = newsize;
+		dp = DP((unsigned long)(dp+1) + newsize);
+		dp->first = dp->last = 0;
+		dp->alloced = 0;
+		dp->length = newsize;
+		dp++;
+		dp->first = dp->last = 0;
+		dp->alloced = 1;
+		dp->length = size;
+		ptr = (void *)(dp+1);
+		dp = DP((unsigned long)ptr + size);
+		dp->alloced = 1;
+		dp->length = size;
+	}
+
+#ifdef DEBUG
+	printk ("chip_alloc: returning %p\n", ptr);
+#endif
+
+	if ((unsigned long)ptr & 7)
+		panic("chip_alloc: alignment violation\n");
+
+    chipavail -= size + (2*sizeof(*dp)); /*MILAN*/
+
+    return ptr;
+}
+
+void amiga_chip_free (void *ptr)
+{
+	struct chip_desc *sdp = DP(ptr) - 1, *dp2;
+	struct chip_desc *edp = DP((unsigned long)ptr + sdp->length);
+
+    chipavail += sdp->length + (2* sizeof(sdp)); /*MILAN*/
+#ifdef DEBUG
+   printk("chip_free: free %ld bytes at %p\n",sdp->length,ptr);
+#endif
+	/* deallocate the chunk */
+	sdp->alloced = edp->alloced = 0;
+
+	/* check if we should merge with the previous chunk */
+	if (!sdp->first && !sdp[-1].alloced) {
+		dp2 = DP((unsigned long)sdp - sdp[-1].length) - 2;
+		dp2->length += sdp->length + 2*sizeof(*sdp);
+		edp->length = dp2->length;
+		sdp = dp2;
+	}
+
+	/* check if we should merge with the following chunk */
+	if (!edp->last && !edp[1].alloced) {
+		dp2 = DP((unsigned long)edp + edp[1].length) + 2;
+		dp2->length += edp->length + 2*sizeof(*sdp);
+		sdp->length = dp2->length;
+		edp = dp2;
+	}
+}
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/config.c ./arch/ppc/amiga/config.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/config.c	Mon Jan  4 11:30:10 1999
+++ ./arch/ppc/amiga/config.c	Sun Jan 31 11:57:25 1999
@@ -1,13 +1,12 @@
 #define m68k_debug_device debug_device
-#define m68k_num_memory num_memory
-#define m68k_memory memory
 
 #include <linux/init.h>
 
 /* machine dependent "kbd-reset" setup function */
-void (*kbd_reset_setup) (char *, int) __initdata = 0;
+void (*mach_kbd_reset_setup) (char *, int) __initdata = 0;
 
 #include <asm/io.h>
+#include <asm/system.h>
 
 /*
  *  linux/arch/m68k/amiga/config.c
@@ -42,6 +41,7 @@
 #include <asm/machdep.h>
 #include <linux/zorro.h>
 
+unsigned long powerup_PCI_present;
 unsigned long amiga_model;
 unsigned long amiga_eclock;
 unsigned long amiga_masterclock;
@@ -62,7 +62,6 @@
 /* amiga specific keyboard functions */
 extern int amiga_keyb_init(void);
 extern int amiga_kbdrate (struct kbd_repeat *);
-extern void amiga_kbd_reset_setup(char*, int);
 /* amiga specific irq functions */
 extern void amiga_init_IRQ (void);
 extern void (*amiga_default_handler[]) (int, void *, struct pt_regs *);
@@ -138,8 +137,13 @@
 
     switch (record->tag) {
 	case BI_AMIGA_MODEL:
-	    amiga_model = *data;
-	    break;
+	{
+		unsigned long d = *data;
+
+		powerup_PCI_present = d & 0x100;
+		amiga_model = d & 0xff;
+	}
+	break;
 
 	case BI_AMIGA_ECLOCK:
 	    amiga_eclock = *data;
@@ -353,7 +357,6 @@
   mach_sched_init      = amiga_sched_init;
   mach_keyb_init       = amiga_keyb_init;
   mach_kbdrate         = amiga_kbdrate;
-  kbd_reset_setup      = amiga_kbd_reset_setup;
   mach_init_IRQ        = amiga_init_IRQ;
   mach_default_handler = &amiga_default_handler;
 #ifndef CONFIG_APUS
@@ -742,7 +745,7 @@
 static void amiga_serial_putc(char c)
 {
     custom.serdat = (unsigned char)c | 0x100;
-    iobarrier_rw ();
+    mb();
     while (!(custom.serdatr & 0x2000))
        ;
 }
@@ -922,3 +925,30 @@
 
     return(len);
 }
+
+#ifdef CONFIG_APUS
+int get_hardware_list(char *buffer)
+{
+	extern int get_cpuinfo(char *buffer);
+	int len = 0;
+	char model[80];
+	u_long mem;
+	int i;
+
+	if (mach_get_model)
+		mach_get_model(model);
+	else
+		strcpy(model, "Unknown PowerPC");
+	
+	len += sprintf(buffer+len, "Model:\t\t%s\n", model);
+	len += get_cpuinfo(buffer+len);
+	for (mem = 0, i = 0; i < m68k_realnum_memory; i++)
+		mem += m68k_memory[i].size;
+	len += sprintf(buffer+len, "System Memory:\t%ldK\n", mem>>10);
+
+	if (mach_get_hardware_list)
+		len += mach_get_hardware_list(buffer+len);
+
+	return(len);
+}
+#endif
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/ints.c ./arch/ppc/amiga/ints.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/ints.c	Fri Aug  7 15:53:34 1998
+++ ./arch/ppc/amiga/ints.c	Sat Nov 21 20:38:10 1998
@@ -42,7 +42,7 @@
  * the IRQ handling routines.
  */
 
-__initfunc(void apus_init_IRQ(void))
+__initfunc(void m68k_init_IRQ(void))
 {
 	int i;
 
@@ -134,7 +134,7 @@
 	}
 }
 
-int get_irq_list(char *buf)
+int m68k_get_irq_list(char *buf)
 {
 	int i, len = 0;
 
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/pcmcia.c ./arch/ppc/amiga/pcmcia.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/pcmcia.c	Thu Jan  1 01:00:00 1970
+++ ./arch/ppc/amiga/pcmcia.c	Sun May 16 11:54:04 1999
@@ -0,0 +1 @@
+#include "../../m68k/amiga/pcmcia.c"
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/time.c ./arch/ppc/amiga/time.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/amiga/time.c	Thu Nov 19 19:16:53 1998
+++ ./arch/ppc/amiga/time.c	Sun Nov 22 21:02:04 1998
@@ -15,7 +15,7 @@
 	unsigned int day, unsigned int hour,
 	unsigned int min, unsigned int sec);
 
-unsigned long apus_get_rtc_time(void)
+unsigned long m68k_get_rtc_time(void)
 {
 	unsigned int year, mon, day, hour, min, sec;
 
@@ -30,7 +30,7 @@
 	return mktime(year, mon, day, hour, min, sec);
 }
 
-int apus_set_rtc_time(unsigned long nowtime)
+int m68k_set_rtc_time(unsigned long nowtime)
 {
   if (mach_set_clock_mmss)
     return mach_set_clock_mmss (nowtime);
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/apus_defconfig ./arch/ppc/apus_defconfig
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/apus_defconfig	Wed Mar 10 19:14:12 1999
+++ ./arch/ppc/apus_defconfig	Sun May 16 20:42:46 1999
@@ -8,11 +8,11 @@
 CONFIG_PPC=y
 CONFIG_6xx=y
 # CONFIG_8xx is not set
-CONFIG_PMAC=y
+# CONFIG_PMAC is not set
 # CONFIG_PREP is not set
 # CONFIG_CHRP is not set
 # CONFIG_ALL_PPC is not set
-# CONFIG_APUS is not set
+CONFIG_APUS=y
 # CONFIG_MBX is not set
 # CONFIG_SMP is not set
 CONFIG_MACH_SPECIFIC=y
@@ -21,33 +21,45 @@
 # General setup
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-CONFIG_PCI=y
-# CONFIG_PCI_QUIRKS is not set
-CONFIG_PCI_OLD_PROC=y
+# CONFIG_MODULES is not set
+CONFIG_APUS_FAST_EXCEPT=y
 CONFIG_NET=y
 CONFIG_SYSCTL=y
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 CONFIG_BINFMT_ELF=y
 CONFIG_KERNEL_ELF=y
-CONFIG_BINFMT_MISC=m
+# CONFIG_BINFMT_MISC is not set
 # CONFIG_BINFMT_JAVA is not set
 # CONFIG_PARPORT is not set
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_FB=y
-CONFIG_FB_COMPAT_XPMAC=y
-CONFIG_PMAC_PBOOK=y
-CONFIG_MAC_KEYBOARD=y
-CONFIG_MAC_FLOPPY=y
-CONFIG_MAC_SERIAL=y
-CONFIG_ADBMOUSE=y
-CONFIG_PROC_DEVICETREE=y
-# CONFIG_KGDB is not set
-# CONFIG_XMON is not set
+# CONFIG_FB_COMPAT_XPMAC is not set
+# CONFIG_PMAC_PBOOK is not set
+# CONFIG_MAC_KEYBOARD is not set
+# CONFIG_MAC_FLOPPY is not set
+# CONFIG_MAC_SERIAL is not set
+# CONFIG_ADBMOUSE is not set
+# CONFIG_PROC_DEVICETREE is not set
 # CONFIG_TOTALMP is not set
+# CONFIG_BOOTX_TEXT is not set
+# CONFIG_MOTOROLA_HOTSWAP is not set
+CONFIG_AMIGA=y
+CONFIG_ZORRO=y
+CONFIG_AMIGAMOUSE=y
+CONFIG_AMIGA_PCMCIA=y
+CONFIG_AMIGA_BUILTIN_SERIAL=y
+CONFIG_GVPIOEXT=y
+# CONFIG_GVPIOEXT_LP is not set
+CONFIG_GVPIOEXT_PLIP=y
+CONFIG_MULTIFACE_III_TTY=y
+# CONFIG_SERIAL_CONSOLE is not set
+CONFIG_WHIPPET_SERIAL=y
+# CONFIG_PARPORT is not set
+# CONFIG_M68K_PRINTER is not set
+# CONFIG_MULTIFACE_III_LP is not set
+CONFIG_HEARTBEAT=y
+CONFIG_PROC_HARDWARE=y
 
 #
 # Plug and Play support
@@ -58,6 +70,7 @@
 # Block devices
 #
 # CONFIG_BLK_DEV_FD is not set
+CONFIG_AMIGA_FLOPPY=y
 CONFIG_BLK_DEV_IDE=y
 
 #
@@ -67,22 +80,20 @@
 CONFIG_BLK_DEV_IDEDISK=y
 CONFIG_BLK_DEV_IDECD=y
 # CONFIG_BLK_DEV_IDETAPE is not set
-CONFIG_BLK_DEV_IDEFLOPPY=y
+# CONFIG_BLK_DEV_IDEFLOPPY is not set
 # CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_BLK_DEV_PCIDE is not set
+CONFIG_BLK_DEV_GAYLE=y
+CONFIG_BLK_DEV_IDEDOUBLER=y
+CONFIG_BLK_DEV_BUDDHA=y
 # CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_RZ1000 is not set
-# CONFIG_BLK_DEV_IDEPCI is not set
-# CONFIG_BLK_DEV_SL82C105 is not set
-CONFIG_BLK_DEV_IDE_PMAC=y
-CONFIG_BLK_DEV_IDEDMA_PMAC=y
-CONFIG_BLK_DEV_IDEDMA=y
-CONFIG_PMAC_IDEDMA_AUTO=y
 # CONFIG_IDE_CHIPSETS is not set
+CONFIG_AMIGA_Z2RAM=y
 
 #
 # Additional Block Devices
 #
-# CONFIG_BLK_DEV_LOOP is not set
+CONFIG_BLK_DEV_LOOP=y
 # CONFIG_BLK_DEV_NBD is not set
 # CONFIG_BLK_DEV_MD is not set
 CONFIG_BLK_DEV_RAM=y
@@ -95,37 +106,33 @@
 #
 # Networking options
 #
-CONFIG_PACKET=y
-CONFIG_NETLINK=y
-# CONFIG_RTNETLINK is not set
-# CONFIG_NETLINK_DEV is not set
+# CONFIG_PACKET is not set
+# CONFIG_NETLINK is not set
 # CONFIG_FIREWALL is not set
 # CONFIG_FILTER is not set
 CONFIG_UNIX=y
 CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
+# CONFIG_IP_MULTICAST is not set
 # CONFIG_IP_ADVANCED_ROUTER is not set
 # CONFIG_IP_PNP is not set
 # CONFIG_IP_ROUTER is not set
 # CONFIG_NET_IPIP is not set
 # CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-CONFIG_IP_ALIAS=y
+# CONFIG_IP_ALIAS is not set
 # CONFIG_SYN_COOKIES is not set
 
 #
 # (it is safe to leave these untouched)
 #
-CONFIG_INET_RARP=y
-CONFIG_IP_NOSR=y
-CONFIG_SKB_LARGE=y
+# CONFIG_INET_RARP is not set
+# CONFIG_SKB_LARGE is not set
 # CONFIG_IPV6 is not set
 
 #
 #  
 #
 # CONFIG_IPX is not set
-CONFIG_ATALK=m
+# CONFIG_ATALK is not set
 # CONFIG_X25 is not set
 # CONFIG_LAPB is not set
 # CONFIG_BRIDGE is not set
@@ -135,6 +142,10 @@
 # CONFIG_NET_FASTROUTE is not set
 # CONFIG_NET_HW_FLOWCONTROL is not set
 # CONFIG_CPU_IS_SLOW is not set
+
+#
+# QoS and/or fair queueing
+#
 # CONFIG_NET_SCHED is not set
 
 #
@@ -146,7 +157,7 @@
 # SCSI support type (disk, tape, CD-ROM)
 #
 CONFIG_BLK_DEV_SD=y
-CONFIG_CHR_DEV_ST=y
+# CONFIG_CHR_DEV_ST is not set
 CONFIG_BLK_DEV_SR=y
 CONFIG_BLK_DEV_SR_VENDOR=y
 # CONFIG_CHR_DEV_SG is not set
@@ -155,49 +166,29 @@
 # Some SCSI devices (e.g. CD jukebox) support multiple LUNs
 #
 # CONFIG_SCSI_MULTI_LUN is not set
-CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_CONSTANTS is not set
 # CONFIG_SCSI_LOGGING is not set
 
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_7000FASST is not set
-# CONFIG_SCSI_AHA152X is not set
-# CONFIG_SCSI_AHA1542 is not set
-# CONFIG_SCSI_AHA1740 is not set
-CONFIG_SCSI_AIC7XXX=y
-# CONFIG_OVERRIDE_CMDS is not set
-CONFIG_AIC7XXX_PROC_STATS=y
-CONFIG_AIC7XXX_RESET_DELAY=15
-# CONFIG_SCSI_ADVANSYS is not set
-# CONFIG_SCSI_IN2000 is not set
-# CONFIG_SCSI_AM53C974 is not set
-# CONFIG_SCSI_BUSLOGIC is not set
-# CONFIG_SCSI_DTC3280 is not set
-# CONFIG_SCSI_EATA_DMA is not set
-# CONFIG_SCSI_EATA_PIO is not set
-# CONFIG_SCSI_EATA is not set
-# CONFIG_SCSI_FUTURE_DOMAIN is not set
-# CONFIG_SCSI_GDTH is not set
-# CONFIG_SCSI_GENERIC_NCR5380 is not set
-# CONFIG_SCSI_NCR53C406A is not set
-# CONFIG_SCSI_NCR53C7xx is not set
-# CONFIG_SCSI_NCR53C8XX is not set
-# CONFIG_SCSI_PAS16 is not set
-# CONFIG_SCSI_PCI2000 is not set
-# CONFIG_SCSI_PCI2220I is not set
-# CONFIG_SCSI_PSI240I is not set
-# CONFIG_SCSI_QLOGIC_FAS is not set
-# CONFIG_SCSI_QLOGIC_ISP is not set
-# CONFIG_SCSI_SEAGATE is not set
-# CONFIG_SCSI_DC390T is not set
-# CONFIG_SCSI_T128 is not set
-# CONFIG_SCSI_U14_34F is not set
-# CONFIG_SCSI_ULTRASTOR is not set
+CONFIG_SCSI_ALL=y
+# CONFIG_SCSI_ALL is not set
+CONFIG_A3000_SCSI=y
+CONFIG_A4000T_SCSI=y
+# CONFIG_SCSI_ALL is not set
+CONFIG_A2091_SCSI=y
+CONFIG_GVP11_SCSI=y
+# CONFIG_CYBERSTORM_SCSI is not set
+# CONFIG_CYBERSTORMII_SCSI is not set
+# CONFIG_BLZ2060_SCSI is not set
+# CONFIG_BLZ1230_SCSI is not set
+# CONFIG_FASTLANE_SCSI is not set
+CONFIG_A4091_SCSI=y
+# CONFIG_WARPENGINE_SCSI is not set
+CONFIG_BLZ603EPLUS_SCSI=y
+CONFIG_OKTAGON_SCSI=y
 # CONFIG_SCSI_DEBUG is not set
-CONFIG_SCSI_MESH=y
-CONFIG_SCSI_MESH_SYNC_RATE=5
-CONFIG_SCSI_MAC53C94=y
 
 #
 # Network device support
@@ -206,51 +197,40 @@
 # CONFIG_ARCNET is not set
 # CONFIG_DUMMY is not set
 # CONFIG_EQUALIZER is not set
-# CONFIG_ETHERTAP is not set
 CONFIG_NET_ETHERNET=y
-CONFIG_MACE=y
-CONFIG_BMAC=y
+# CONFIG_MACE is not set
+# CONFIG_BMAC is not set
+CONFIG_ARIADNE=y
+CONFIG_ARIADNE2=y
+CONFIG_A2065=y
+CONFIG_HYDRA=y
+CONFIG_APNE=y
 # CONFIG_NET_VENDOR_3COM is not set
 # CONFIG_LANCE is not set
 # CONFIG_NET_VENDOR_SMC is not set
 # CONFIG_NET_VENDOR_RACAL is not set
 # CONFIG_RTL8139 is not set
 # CONFIG_YELLOWFIN is not set
+# CONFIG_ACENIC is not set
 # CONFIG_NET_ISA is not set
-CONFIG_NET_EISA=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AC3200 is not set
-# CONFIG_APRICOT is not set
-# CONFIG_CS89x0 is not set
-CONFIG_DE4X5=y
-CONFIG_DEC_ELCP=m
-# CONFIG_DGRS is not set
-# CONFIG_EEXPRESS_PRO100 is not set
-# CONFIG_LNE390 is not set
-# CONFIG_NE3210 is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-# CONFIG_ES3210 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_ZNET is not set
+# CONFIG_NET_EISA is not set
 # CONFIG_NET_POCKET is not set
 # CONFIG_FDDI is not set
 # CONFIG_HIPPI is not set
 # CONFIG_DLCI is not set
-# CONFIG_LTPC is not set
-# CONFIG_COPS is not set
-# CONFIG_IPDDP is not set
 CONFIG_PPP=y
 
 #
 # CCP compressors for PPP are only built as modules.
 #
-# CONFIG_SLIP is not set
+CONFIG_SLIP=y
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+# CONFIG_SLIP_MODE_SLIP6 is not set
 # CONFIG_NET_RADIO is not set
 # CONFIG_TR is not set
 # CONFIG_SHAPER is not set
-# CONFIG_HOSTESS_SV11 is not set
+# CONFIG_RCPCI is not set
 
 #
 # Amateur Radio support
@@ -263,7 +243,7 @@
 # CONFIG_ISDN is not set
 
 #
-# CD-ROM drivers (not for SCSI or IDE/ATAPI drives)
+# Old CD-ROM drivers (not SCSI, not IDE)
 #
 # CONFIG_CD_NO_IDESCSI is not set
 
@@ -271,47 +251,61 @@
 # Console drivers
 #
 CONFIG_DUMMY_CONSOLE=y
-CONFIG_FB_OF=y
-CONFIG_FB_CONTROL=y
-CONFIG_FB_PLATINUM=y
-CONFIG_FB_VALKYRIE=y
-CONFIG_FB_ATY=y
-CONFIG_FB_IMSTT=y
-CONFIG_FB_CT65550=y
-# CONFIG_FB_S3TRIO is not set
+CONFIG_FB_PM2=y
+CONFIG_FB_PM2_CVPPC=y
+CONFIG_FB_AMIGA=y
+CONFIG_FB_AMIGA_OCS=y
+CONFIG_FB_AMIGA_ECS=y
+CONFIG_FB_AMIGA_AGA=y
+CONFIG_FB_CYBER=y
+CONFIG_FB_VIRGE=y
+CONFIG_FB_RETINAZ3=y
+CONFIG_FB_CLGEN=y
+# CONFIG_FB_FM2 is not set
+# CONFIG_FB_OF is not set
+# CONFIG_FB_MATROX is not set
+# CONFIG_FB_ATY is not set
 # CONFIG_FB_VIRTUAL is not set
 # CONFIG_FBCON_ADVANCED is not set
+CONFIG_FBCON_MFB=y
 CONFIG_FBCON_CFB8=y
 CONFIG_FBCON_CFB16=y
 CONFIG_FBCON_CFB24=y
 CONFIG_FBCON_CFB32=y
-# CONFIG_FBCON_FONTWIDTH8_ONLY is not set
-CONFIG_FBCON_FONTS=y
-# CONFIG_FONT_8x8 is not set
+CONFIG_FBCON_AFB=y
+CONFIG_FBCON_ILBM=y
+CONFIG_FBCON_FONTWIDTH8_ONLY=y
+# CONFIG_FBCON_FONTS is not set
+CONFIG_FONT_8x8=y
 CONFIG_FONT_8x16=y
-CONFIG_FONT_SUN8x16=y
-CONFIG_FONT_SUN12x22=y
-# CONFIG_FONT_6x11 is not set
-# CONFIG_FONT_PEARL_8x8 is not set
-# CONFIG_FONT_ACORN_8x8 is not set
+CONFIG_FONT_PEARL_8x8=y
 
 #
 # Character devices
 #
 CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
-CONFIG_SERIAL=m
+CONFIG_SERIAL=y
+# CONFIG_SERIAL_CONSOLE is not set
 # CONFIG_SERIAL_EXTENDED is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
+# CONFIG_UNIX98_PTYS is not set
 # CONFIG_MOUSE is not set
 # CONFIG_QIC02_TAPE is not set
 # CONFIG_WATCHDOG is not set
+# CONFIG_NVRAM is not set
 # CONFIG_RTC is not set
+
+#
+# Video For Linux
+#
 # CONFIG_VIDEO_DEV is not set
-CONFIG_NVRAM=y
+
+#
+# Joystick support
+#
 # CONFIG_JOYSTICK is not set
+# CONFIG_DTLK is not set
 
 #
 # Ftape, the floppy tape device driver
@@ -322,42 +316,57 @@
 # Filesystems
 #
 # CONFIG_QUOTA is not set
-# CONFIG_MINIX_FS is not set
-CONFIG_EXT2_FS=y
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=y
+CONFIG_HFS_FS=y
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+# CONFIG_UMSDOS_FS is not set
+CONFIG_VFAT_FS=y
 CONFIG_ISO9660_FS=y
 # CONFIG_JOLIET is not set
-CONFIG_FAT_FS=m
-CONFIG_MSDOS_FS=m
-# CONFIG_UMSDOS_FS is not set
-CONFIG_VFAT_FS=m
+CONFIG_MINIX_FS=y
+# CONFIG_NTFS_FS is not set
+# CONFIG_HPFS_FS is not set
 CONFIG_PROC_FS=y
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_EXT2_FS=y
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+# CONFIG_CODA_FS is not set
 CONFIG_NFS_FS=y
-CONFIG_NFSD=y
+# CONFIG_NFSD is not set
 CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
-# CONFIG_CODA_FS is not set
 # CONFIG_SMB_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_AFFS_FS is not set
-CONFIG_HFS_FS=y
-# CONFIG_ROMFS_FS is not set
-CONFIG_AUTOFS_FS=y
-# CONFIG_UFS_FS is not set
+# CONFIG_NCP_FS is not set
+
+#
+# Partition Types
+#
+CONFIG_AMIGA_PARTITION=y
+CONFIG_FOREIGN_PARTITIONS=y
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_OSF_PARTITION is not set
+# CONFIG_SUN_PARTITION is not set
+# CONFIG_ATARI_PARTITION is not set
+CONFIG_MAC_PARTITION=y
 # CONFIG_BSD_DISKLABEL is not set
 # CONFIG_SMD_DISKLABEL is not set
 # CONFIG_SOLARIS_X86_PARTITION is not set
-CONFIG_DEVPTS_FS=y
-# CONFIG_ADFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-CONFIG_MAC_PARTITION=y
+# CONFIG_UNIXWARE_DISKLABEL is not set
 CONFIG_NLS=y
 
 #
 # Native Language Support
 #
-CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_437 is not set
 # CONFIG_NLS_CODEPAGE_737 is not set
 # CONFIG_NLS_CODEPAGE_775 is not set
 # CONFIG_NLS_CODEPAGE_850 is not set
@@ -382,16 +391,17 @@
 # CONFIG_NLS_ISO8859_7 is not set
 # CONFIG_NLS_ISO8859_8 is not set
 # CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_15 is not set
 # CONFIG_NLS_KOI8_R is not set
 
 #
 # Sound
 #
-CONFIG_SOUND=y
-CONFIG_DMASOUND=y
-# CONFIG_SOUND_ES1370 is not set
-# CONFIG_SOUND_ES1371 is not set
-# CONFIG_SOUND_SONICVIBES is not set
-# CONFIG_SOUND_MSNDCLAS is not set
-# CONFIG_SOUND_MSNDPIN is not set
-# CONFIG_SOUND_OSS is not set
+# CONFIG_SOUND is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_KGDB is not set
+# CONFIG_XMON is not set
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/config.in ./arch/ppc/config.in
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/config.in	Wed May 12 10:02:44 1999
+++ ./arch/ppc/config.in	Sat May 15 11:38:26 1999
@@ -22,7 +22,10 @@
 bool 'Symmetric multi-processing support' CONFIG_SMP
 if [ "$CONFIG_ALL_PPC" != "y" ];then
   define_bool CONFIG_MACH_SPECIFIC y
+else
+  bool 'Include APUS support' CONFIG_APUS
 fi
+
 endmenu
 
 if [ "$CONFIG_MBX" = "y" ];then
@@ -40,7 +43,11 @@
 fi
 
 if [ "$CONFIG_APUS" = "y" ]; then
-  define_bool CONFIG_PCI n
+  if [ "$CONFIG_MACH_SPECIFIC" = "y" ];then
+    define_bool CONFIG_APUS_FAST_EXCEPT y
+  else
+    define_bool CONFIG_PCI y
+  fi
 else
   define_bool CONFIG_PCI y
 fi
@@ -99,14 +106,15 @@
 fi
 
 if [ "$CONFIG_APUS" = "y" ]; then
-  define_bool CONFIG_FB_CONSOLE y
   define_bool CONFIG_AMIGA y
   define_bool CONFIG_ZORRO y
   define_bool CONFIG_AMIGAMOUSE y
-  define_bool CONFIG_ABSTRACT_CONSOLE y
-  define_bool CONFIG_FB y
+  if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
+    bool 'Amiga 1200/600 PCMCIA support' CONFIG_AMIGA_PCMCIA
+  fi
+
+  # Serial
   tristate 'Amiga builtin serial support' CONFIG_AMIGA_BUILTIN_SERIAL
-  tristate 'Parallel printer support' CONFIG_M68K_PRINTER
   tristate 'GVP IO-Extender support' CONFIG_GVPIOEXT
   dep_tristate 'GVP IO-Extender parallel printer support' CONFIG_GVPIOEXT_LP $CONFIG_GVPIOEXT
   dep_tristate 'GVP IO-Extender PLIP support' CONFIG_GVPIOEXT_PLIP $CONFIG_GVPIOEXT
@@ -115,6 +123,35 @@
        "$CONFIG_MULTIFACE_III_TTY" = "y" ]; then
     bool 'Support for serial port console' CONFIG_SERIAL_CONSOLE
   fi
+  if [ "$CONFIG_AMIGA_PCMCIA" = "y" ]; then
+    tristate 'Hisoft Whippet PCMCIA serial support' CONFIG_WHIPPET_SERIAL
+  fi
+
+  # Parallel
+  if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
+    tristate 'Parallel port support (EXPERIMENTAL, disables old lp driver!)' CONFIG_PARPORT
+    if [ "$CONFIG_PARPORT" != "n" ]; then
+      if [ "$CONFIG_AMIGA" != "n" ]; then
+        dep_tristate '   Amiga builtin port' CONFIG_PARPORT_AMIGA $CONFIG_PARPORT
+        if [ "$CONFIG_ZORRO" != "n" ]; then
+          dep_tristate '    Multiface III parallel port' CONFIG_PARPORT_MFC3 $CONFIG_PARPORT
+        fi
+      fi
+    fi
+  fi
+  if [ "$CONFIG_PARPORT" = "n" ]; then
+    tristate 'Parallel printer support' CONFIG_M68K_PRINTER
+    if [ "$CONFIG_ZORRO" = "y" ]; then
+      dep_tristate 'Multiface Card III parallel support' CONFIG_MULTIFACE_III_LP $CONFIG_M68K_PRINTER
+    fi
+  else
+    dep_tristate 'Parallel printer support' CONFIG_PRINTER $CONFIG_PARPORT
+    if [ "$CONFIG_PRINTER" != "n" ]; then
+      bool '  Support IEEE1284 status readback' CONFIG_PRINTER_READBACK
+    fi
+  fi   
+
+  # Misc
   bool 'Use power LED as a heartbeat' CONFIG_HEARTBEAT
   bool '/proc/hardware support' CONFIG_PROC_HARDWARE
 fi
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/Makefile ./arch/ppc/kernel/Makefile
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/Makefile	Tue May 11 11:26:14 1999
+++ ./arch/ppc/kernel/Makefile	Sat May 15 11:39:25 1999
@@ -15,10 +15,8 @@
 
 
 O_OBJS := traps.o irq.o idle.o time.o process.o signal.o syscalls.o misc.o \
-	  bitops.o ptrace.o align.o ppc_htab.o
-ifdef CONFIG_PCI
-O_OBJS += pci.o
-endif
+	  bitops.o ptrace.o align.o ppc_htab.o pci.o
+
 ifdef CONFIG_KGDB
 O_OBJS += ppc-stub.o
 endif
@@ -29,18 +27,12 @@
 ifeq ($(CONFIG_MBX),y)
 O_OBJS += mbx_setup.o mbx_pci.o softemu8xx.o i8259.o ppc8xx_pic.o
 else
-ifeq ($(CONFIG_APUS),y)
-O_OBJS += apus_setup.o prom.o openpic.o
-else
-ifneq ($(CONFIG_MBX),y)
 O_OBJS += prep_time.o pmac_time.o chrp_time.o \
 	  pmac_setup.o pmac_support.o \
 	  prep_pci.o pmac_pci.o chrp_pci.o \
-	  residual.o prom.o openpic.o feature.o \
+	  residual.o prom.o openpic.o feature.o apus_setup.o \
 	  prep_nvram.o open_pic.o i8259.o pmac_pic.o indirect_pci.o
 OX_OBJS += chrp_setup.o prep_setup.o
-endif
-endif
 endif
 
 ifdef CONFIG_SMP
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/apus_setup.c ./arch/ppc/kernel/apus_setup.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/apus_setup.c	Tue May 11 11:26:15 1999
+++ ./arch/ppc/kernel/apus_setup.c	Sun May 16 20:13:49 1999
@@ -1,11 +1,16 @@
 /*
  *  linux/arch/ppc/kernel/apus_setup.c
  *
- *  Copyright (C) 1998  Jesper Skov
+ *  Copyright (C) 1998, 1999  Jesper Skov
  *
  *  Basically what is needed to replace functionality found in
  *  arch/m68k allowing Amiga drivers to work under APUS.
  *  Bits of code and/or ideas from arch/m68k and arch/ppc files.
+ *
+ * TODO:
+ *  This file needs a *really* good cleanup. Restructure and optimize.
+ *  Make sure it can be compiled for non-APUS configs. Begine to move
+ *  Amiga specific stuff into linux/machine/amiga.
  */
 
 #include <linux/config.h>
@@ -14,7 +19,10 @@
 #include <linux/sched.h>
 #include <linux/kd.h>
 #include <linux/init.h>
+#include <linux/serial.h>
 #include <linux/hdreg.h>
+#include <linux/blk.h>
+#include <linux/pci.h>
 
 /* Get the IDE stuff from the 68k file */
 #define ide_init_hwif_ports m68k_ide_init_hwif_ports
@@ -26,67 +34,74 @@
 #define ide_fix_driveid m68k_ide_fix_driveid
 #include <asm-m68k/ide.h>
 #undef ide_init_hwif_ports
-#define ide_default_irq
-#define ide_default_io_base
-#define ide_check_region
-#define ide_request_region
-#define ide_release_region
-#define ide_fix_driveid
+#undef ide_default_irq
+#undef ide_default_io_base
+#undef ide_check_region
+#undef ide_request_region
+#undef ide_release_region
+#undef ide_fix_driveid
+/* But do define the magic ppc ide structure */
+struct ide_machdep_calls {
+        void        (*insw)(ide_ioreg_t port, void *buf, int ns);
+        void        (*outsw)(ide_ioreg_t port, void *buf, int ns);
+        int         (*default_irq)(ide_ioreg_t base);
+        ide_ioreg_t (*default_io_base)(int index);
+        int         (*check_region)(ide_ioreg_t from, unsigned int extent);
+        void        (*request_region)(ide_ioreg_t from,
+                                      unsigned int extent,
+                                      const char *name);
+        void        (*release_region)(ide_ioreg_t from,
+                                      unsigned int extent);
+        void        (*fix_driveid)(struct hd_driveid *id);
+        void        (*ide_init_hwif)(ide_ioreg_t *p,
+                                     ide_ioreg_t base,
+                                     int *irq); 
+
+        int io_base;
+};
 
+extern struct ide_machdep_calls ppc_ide_md;
+/*-------------------------------------------*/
 
+#include <asm/bootinfo.h>
 #include <asm/setup.h>
 #include <asm/amigahw.h>
 #include <asm/amigappc.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
+#include <asm/dma.h>
 #include <asm/machdep.h>
-#include <asm/ide.h>
 
-#include "time.h"
 #include "local_irq.h"
 
-unsigned long apus_get_rtc_time(void);
-int apus_set_rtc_time(unsigned long nowtime);
-
-/* APUS defs */
-extern int parse_bootinfo(const struct bi_record *);
-extern char _end[];
-#ifdef CONFIG_APUS
-struct mem_info ramdisk;
-unsigned long isa_io_base;
-unsigned long isa_mem_base;
-unsigned long pci_dram_offset;
-#endif
-/* END APUS defs */
-
-unsigned long m68k_machtype;
-char debug_device[6] = "";
+unsigned long m68k_machtype __apusdata;
+char debug_device[6] __apusdata = "";
 
 void (*mach_sched_init) (void (*handler)(int, void *, struct pt_regs *)) __initdata;
 /* machine dependent keyboard functions */
 int (*mach_keyb_init) (void) __initdata;
-int (*mach_kbdrate) (struct kbd_repeat *) = NULL;
-void (*mach_kbd_leds) (unsigned int) = NULL;
+int (*mach_kbdrate) (struct kbd_repeat *) __apusdata = NULL;
+void (*mach_kbd_leds) (unsigned int) __apusdata = NULL;
 /* machine dependent irq functions */
 void (*mach_init_IRQ) (void) __initdata;
-void (*(*mach_default_handler)[]) (int, void *, struct pt_regs *) = NULL;
-void (*mach_get_model) (char *model) = NULL;
-int (*mach_get_hardware_list) (char *buffer) = NULL;
-int (*mach_get_irq_list) (char *) = NULL;
-void (*mach_process_int) (int, struct pt_regs *) = NULL;
+void (*(*mach_default_handler)[]) (int, void *, struct pt_regs *) __apusdata = NULL;
+void (*mach_get_model) (char *model) __apusdata = NULL;
+int (*mach_get_hardware_list) (char *buffer) __apusdata = NULL;
+int (*mach_get_irq_list) (char *) __apusdata = NULL;
+void (*mach_process_int) (int, struct pt_regs *) __apusdata = NULL;
 /* machine dependent timer functions */
-unsigned long (*mach_gettimeoffset) (void);
-void (*mach_gettod) (int*, int*, int*, int*, int*, int*);
-int (*mach_hwclk) (int, struct hwclk_time*) = NULL;
-int (*mach_set_clock_mmss) (unsigned long) = NULL;
-void (*mach_reset)( void );
-long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
-#if defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
+unsigned long (*mach_gettimeoffset) (void) __apusdata;
+void (*mach_gettod) (int*, int*, int*, int*, int*, int*) __apusdata;
+int (*mach_hwclk) (int, struct hwclk_time*) __apusdata = NULL;
+int (*mach_set_clock_mmss) (unsigned long) __apusdata = NULL;
+void (*mach_reset)( void ) __apusdata;
+long mach_max_dma_address __apusdata = 0x00ffffff; /* default set to the lower 16MB */
+#if defined(CONFIG_AMIGA_FLOPPY)
 void (*mach_floppy_setup) (char *, int *) __initdata = NULL;
-void (*mach_floppy_eject) (void) = NULL;
+void (*mach_floppy_eject) (void) __apusdata = NULL;
 #endif
 #ifdef CONFIG_HEARTBEAT
-void (*mach_heartbeat) (int) = NULL;
+void (*mach_heartbeat) (int) __apusdata = NULL;
 #endif
 
 extern unsigned long amiga_model;
@@ -94,22 +109,155 @@
 extern unsigned count_period_num; /* 1 decrementer count equals */
 extern unsigned count_period_den; /* count_period_num / count_period_den us */
 
-extern struct mem_info memory[NUM_MEMINFO];/* memory description */
+int num_memory __apusdata = 0;
+struct mem_info memory[NUM_MEMINFO] __apusdata;/* memory description */
+/* FIXME: Duplicate memory data to avoid conflicts with m68k shared code. */
+int m68k_realnum_memory __apusdata = 0;
+struct mem_info m68k_memory[NUM_MEMINFO] __apusdata;/* memory description */
+
+struct mem_info ramdisk __apusdata;
 
 extern void amiga_floppy_setup(char *, int *);
 extern void config_amiga(void);
 
-static int __60nsram = 0;
+static int __60nsram __apusdata = 0;
+
+/* for cpuinfo */
+static int __bus_speed __apusdata = 0;
+static int __speed_test_failed __apusdata = 0;
+
+/********************************************** COMPILE PROTECTION */
+/* Provide some stubs that links to Amiga specific functions. 
+ * This allows CONFIG_APUS to be removed from generic PPC files while
+ * preventing link errors for other PPC targets.
+ */
+__apus
+unsigned long apus_get_rtc_time(void)
+{
+#ifdef CONFIG_APUS
+	extern unsigned long m68k_get_rtc_time(void);
+	
+	return m68k_get_rtc_time ();
+#else
+	return 0;
+#endif
+}
+
+__apus
+int apus_set_rtc_time(unsigned long nowtime)
+{
+#ifdef CONFIG_APUS
+	extern int m68k_set_rtc_time(unsigned long nowtime);
+
+	return m68k_set_rtc_time (nowtime);
+#else
+	return 0;
+#endif
+}
+
+__apus
+int  apus_request_irq(unsigned int irq, 
+		      void (*handler)(int, void *, struct pt_regs *),
+		      unsigned long flags, const char *devname, 
+		      void *dev_id)
+{
+#ifdef CONFIG_APUS
+	extern int  amiga_request_irq(unsigned int irq, 
+				      void (*handler)(int, void *, 
+						      struct pt_regs *),
+				      unsigned long flags, 
+				      const char *devname, 
+				      void *dev_id);
+
+	return amiga_request_irq (irq, handler, flags, devname, dev_id);
+#else
+	return 0;
+#endif
+}
+
+__apus
+void apus_free_irq(unsigned int irq, void *dev_id)
+{
+#ifdef CONFIG_APUS
+	extern void amiga_free_irq(unsigned int irq, void *dev_id);
+
+	amiga_free_irq (irq, dev_id);
+#endif
+}
+
+__apus
+void apus_process_int(unsigned long vec, void *fp)
+{
+#ifdef CONFIG_APUS
+	extern void process_int(unsigned long vec, struct pt_regs *fp);
+
+	process_int (vec, (struct pt_regs*)fp);
+#endif
+}
+
+__apus
+int apus_get_irq_list(char *buf)
+{
+#ifdef CONFIG_APUS
+	extern int m68k_get_irq_list (char*);
+	
+	return m68k_get_irq_list (buf);
+#else
+	return 0;
+#endif
+}
+
+
+/* Here some functions we don't support, but which the other ports reference */
+int pckbd_setkeycode(unsigned int scancode, unsigned int keycode)
+{
+	printk("Bogus call to " __FILE__ ":" __FUNCTION__ "\n");
+	return 0; 
+}
+int pckbd_getkeycode(unsigned int scancode) 
+{ 
+	printk("Bogus call to " __FILE__ ":" __FUNCTION__ "\n");
+	return 0; 
+}
+int pckbd_translate(unsigned char scancode, unsigned char *keycode,
+		    char raw_mode) 
+{
+	printk("Bogus call to " __FILE__ ":" __FUNCTION__ "\n");
+	return 0; 
+}
+char pckbd_unexpected_up(unsigned char keycode)
+{
+	printk("Bogus call to " __FILE__ ":" __FUNCTION__ "\n");
+	return 0;
+}
+void pckbd_leds(unsigned char leds)
+{
+	printk("Bogus call to " __FILE__ ":" __FUNCTION__ "\n");
+}
+void pckbd_init_hw(void)
+{
+	printk("Bogus call to " __FILE__ ":" __FUNCTION__ "\n");
+}
+unsigned char pckbd_sysrq_xlate[128];
+
+struct pci_dev *pci_devices = NULL;
+struct pci_bus * __init pci_scan_peer_bridge(int bus)
+{
+	printk("Bogus call to " __FILE__ ":" __FUNCTION__ "\n");
+	return NULL;
+}
 
 /*********************************************************** SETUP */
 /* From arch/m68k/kernel/setup.c. */
 __initfunc(void apus_setup_arch(unsigned long * memory_start_p,
 				unsigned long * memory_end_p))
 {
+#ifdef CONFIG_APUS
 	extern char cmd_line[];
 	int i;
 	char *p, *q;
 
+	/* Let m68k-shared code know it should do the Amiga thing. */
 	m68k_machtype = MACH_AMIGA;
 
 	/* Parse the command line for arch-specific options.
@@ -141,12 +289,34 @@
 		if ((p = strchr( p, ' ' ))) ++p;
 	    }
 	}
-
 	config_amiga();
+#endif
 }
 
+__apus
+int
+apus_get_cpuinfo(char *buffer)
+{
+#ifdef CONFIG_APUS
+	extern int __map_without_bats;
+	extern unsigned long powerup_PCI_present;
+	int len;
+
+	len = sprintf(buffer, "machine\t\t: Amiga\n");
+	len += sprintf(buffer+len, "bus speed\t: %d%s", __bus_speed,
+		       (__speed_test_failed) ? " [failed]\n" : "\n");
+	len += sprintf(buffer+len, "using BATs\t: %s\n",
+		       (__map_without_bats) ? "No" : "Yes");
+	len += sprintf(buffer+len, "ram speed\t: %dns\n", 
+		       (__60nsram) ? 60 : 70);
+	len += sprintf(buffer+len, "PCI bridge\t: %s\n",
+		       (powerup_PCI_present) ? "Yes" : "No");
+	return len;
+#endif
+}
 
-void get_current_tb(unsigned long long *time)
+__apus
+static void get_current_tb(unsigned long long *time)
 {
 	__asm __volatile ("1:mftbu 4      \n\t"
 			  "  mftb  5      \n\t"
@@ -161,14 +331,17 @@
 }
 
 
+__apus
 void apus_calibrate_decr(void)
 {
+#ifdef CONFIG_APUS
 	int freq, divisor;
 
 	/* This algorithm for determining the bus speed was
            contributed by Ralph Schmidt. */
 	unsigned long long start, stop;
 	int bus_speed;
+	int speed_test_failed = 0;
 
 	{
 		unsigned long loop = amiga_eclock / 10;
@@ -200,16 +373,23 @@
 			"Defaulting to 50MHz", bus_speed);
 		bus_speed = 50;
 		freq = 12500000;
+		speed_test_failed = 1;
 	}
 
 	/* Ease diagnostics... */
 	{
 		extern int __map_without_bats;
+		extern unsigned long powerup_PCI_present;
 
-		printk ("APUS: BATs=%d, BUS=%dMHz, RAM=%dns\n",
+		printk ("APUS: BATs=%d, BUS=%dMHz",
 			(__map_without_bats) ? 0 : 1,
-			bus_speed,
-			(__60nsram) ? 60 : 70);
+			bus_speed);
+		if (speed_test_failed)
+			printk ("[FAILED - please report]");
+
+		printk (", RAM=%dns, PCI bridge=%d\n",
+			(__60nsram) ? 60 : 70,
+			(powerup_PCI_present) ? 1 : 0);
 
 		/* print a bit more if asked politely... */
 		if (!(ciaa.pra & 0x40)){
@@ -232,25 +412,65 @@
         decrementer_count = freq / HZ / divisor;
         count_period_num = divisor;
         count_period_den = freq / 1000000;
+
+	__bus_speed = bus_speed;
+	__speed_test_failed = speed_test_failed;
+#endif
 }
 
+__apus
 void arch_gettod(int *year, int *mon, int *day, int *hour,
 		 int *min, int *sec)
 {
+#ifdef CONFIG_APUS
 	if (mach_gettod)
 		mach_gettod(year, mon, day, hour, min, sec);
 	else
 		*year = *mon = *day = *hour = *min = *sec = 0;
+#endif
+}
+
+/* for "kbd-reset" cmdline param */
+__initfunc(void kbd_reset_setup(char *str, int *ints))
+{
 }
 
+#if defined(CONFIG_WHIPPET_SERIAL)||defined(CONFIG_MULTIFACE_III_TTY)||defined(CONFIG_GVPIOEXT)||defined(CONFIG_AMIGA_BUILTIN_SERIAL)
+
+long m68k_rs_init(void);
+int m68k_register_serial(struct serial_struct *);
+void m68k_unregister_serial(int);
+long m68k_serial_console_init(long, long );
+
+int rs_init(void)
+{
+	return m68k_rs_init();
+}
+int register_serial(struct serial_struct *p)
+{
+	return m68k_register_serial(p);
+}
+void unregister_serial(int i)
+{
+	m68k_unregister_serial(i);
+}
+#ifdef CONFIG_SERIAL_CONSOLE
+long serial_console_init(long kmem_start, long kmem_end)
+{
+	return m68k_serial_console_init(kmem_start, kmem_end);
+}
+#endif
+#endif
+
 /*********************************************************** FLOPPY */
-#if defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
+#if defined(CONFIG_AMIGA_FLOPPY)
 __initfunc(void floppy_setup(char *str, int *ints))
 {
 	if (mach_floppy_setup)
 		mach_floppy_setup (str, ints);
 }
 
+__apus
 void floppy_eject(void)
 {
 	if (mach_floppy_eject)
@@ -259,44 +479,13 @@
 #endif
 
 /*********************************************************** MEMORY */
-extern void
-map_page(struct task_struct *tsk, unsigned long va,
-	 unsigned long pa, int flags);
-
-#define KMAP_MAX 8
-static unsigned long kmap_chunks[KMAP_MAX*3];
-static int kmap_chunk_count = 0;
-
-/* Based on arch/ppc/mm/init.c:ioremap() which maps the address range
-   to the same virtual address as the physical address - which may
-   cause problems since Z3 IO space is not the same as PCI/ISA.
-   This should be rewritten to something more like the m68k version. */
-unsigned long kernel_map (unsigned long phys_addr, unsigned long size,
-			  int cacheflag, unsigned long *memavailp)
-{
-	unsigned long v_ret, end;
-	/* Remap to 0x90000000. Related comment in ppc/mm/init.c. */
-	static unsigned long virt = 0x90000000;
-	v_ret = virt;
-
-	if (kmap_chunk_count == KMAP_MAX*3)
-		panic ("kernel_map: Can only map %d chunks.\n",
-		       KMAP_MAX);
-
-	kmap_chunks[kmap_chunk_count++] = phys_addr;
-	kmap_chunks[kmap_chunk_count++] = size;
-	kmap_chunks[kmap_chunk_count++] = v_ret;
-
-	for (end = phys_addr + size ; phys_addr < end; 
-	     phys_addr += PAGE_SIZE, virt += PAGE_SIZE) {
-		map_page(&init_task, virt, phys_addr,
-			 pgprot_val(PAGE_KERNEL_CI) | _PAGE_GUARDED);
-	}
-	return v_ret;
-}
+#define KMAP_MAX 32
+unsigned long kmap_chunks[KMAP_MAX*3] __apusdata;
+int kmap_chunk_count __apusdata = 0;
 
 /* From pgtable.h */
-extern __inline__ pte_t *my_find_pte(struct mm_struct *mm,unsigned long va)
+__apus
+static __inline__ pte_t *my_find_pte(struct mm_struct *mm,unsigned long va)
 {
 	pgd_t *dir = 0;
 	pmd_t *pmd = 0;
@@ -318,10 +507,11 @@
 
 
 /* Again simulating an m68k/mm/kmap.c function. */
+__apus
 void kernel_set_cachemode( unsigned long address, unsigned long size,
 			   unsigned int cmode )
 {
-	int mask, flags;
+	unsigned long mask, flags;
 
 	switch (cmode)
 	{
@@ -360,6 +550,7 @@
 	}
 }
 
+__apus
 unsigned long mm_ptov (unsigned long paddr)
 {
 	unsigned long ret;
@@ -388,6 +579,7 @@
 	return ret;
 }
 
+__apus
 int mm_end_of_chunk (unsigned long addr, int len)
 {
 	if (memory[0].addr + memory[0].size == addr + len)
@@ -399,6 +591,7 @@
 
 #define L1_CACHE_BYTES 32
 #define MAX_CACHE_SIZE 8192
+__apus
 void cache_push(__u32 addr, int length)
 {
 	addr = mm_ptov(addr);
@@ -417,6 +610,8 @@
 	       "sync \n\t"
 	       : : "r" (addr));
 }
+
+__apus
 void cache_clear(__u32 addr, int length)
 {
 	if (MAX_CACHE_SIZE < length)
@@ -450,6 +645,7 @@
 	       : : "r" (addr));
 }
 
+/****************************************************** from setup.c */
 void
 apus_restart(char *cmd)
 {
@@ -478,37 +674,13 @@
    apus_restart(NULL);
 }
 
-void
-apus_do_IRQ(struct pt_regs *regs,
-	    int            cpu,
-            int            isfake)
-{
-        int old_level, new_level;
-
-	/* I don't think we need SMP code here - Corey */
-
-        old_level = ~(regs->mq) & IPLEMU_IPLMASK;
-        new_level = (~(regs->mq) >> 3) & IPLEMU_IPLMASK;
-        if (new_level != 0)
-        {
-                APUS_WRITE(APUS_IPL_EMU, IPLEMU_IPLMASK);
-                APUS_WRITE(APUS_IPL_EMU, (IPLEMU_SETRESET
-                                          | (~(new_level) & IPLEMU_IPLMASK)));
-                APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT);
-
-                process_int (VEC_SPUR+new_level, regs);
-                APUS_WRITE(APUS_IPL_EMU, IPLEMU_SETRESET | IPLEMU_DISABLEINT);
-                APUS_WRITE(APUS_IPL_EMU, IPLEMU_IPLMASK);
-                APUS_WRITE(APUS_IPL_EMU, (IPLEMU_SETRESET
-                                          | (~(old_level) & IPLEMU_IPLMASK)));
-        }
-        APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT);
-}
-
+/****************************************************** from setup.c/IDE */
 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
 /*
  * IDE stuff.
  */
+void ide_insw(ide_ioreg_t port, void *buf, int ns);
+void ide_outsw(ide_ioreg_t port, void *buf, int ns);
 void
 apus_ide_insw(ide_ioreg_t port, void *buf, int ns)
 {
@@ -524,13 +696,13 @@
 int
 apus_ide_default_irq(ide_ioreg_t base)
 {
-        m68k_ide_default_irq(base);
+        return m68k_ide_default_irq(base);
 }
 
 ide_ioreg_t
 apus_ide_default_io_base(int index)
 {
-        m68k_ide_default_io_base(index);
+        return 0;
 }
 
 int
@@ -565,20 +737,113 @@
 {
         m68k_ide_init_hwif_ports(p, base, irq);
 }
+
+
+
 #endif
 
+/****************************************************** from irq.c */
+#define VEC_SPUR    (24)
+
+void
+apus_do_IRQ(struct pt_regs *regs,
+	    int            cpu,
+            int            isfake)
+{
+	int old_level, new_level;
+
+	new_level = (~(regs->mq) >> 3) & IPLEMU_IPLMASK;
+		
+	if (0 != new_level && 7 != new_level) {
+		old_level = ~(regs->mq) & IPLEMU_IPLMASK;
+
+		apus_process_int (VEC_SPUR+new_level, regs);
+		
+		APUS_WRITE(APUS_IPL_EMU, IPLEMU_SETRESET | IPLEMU_DISABLEINT);
+		APUS_WRITE(APUS_IPL_EMU, IPLEMU_IPLMASK);
+		APUS_WRITE(APUS_IPL_EMU, (IPLEMU_SETRESET
+					  | (~(old_level) & IPLEMU_IPLMASK)));
+		APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT);
+	}
+}
+
+/****************************************************** keyboard */
+__apus
+static int apus_kbd_setkeycode(unsigned int scancode, unsigned int keycode)
+{
+	return -EOPNOTSUPP;
+}
+
+__apus
+static int apus_kbd_getkeycode(unsigned int scancode)
+{
+	return scancode > 127 ? -EINVAL : scancode;
+}
+
+__apus
+static int apus_kbd_translate(unsigned char keycode, unsigned char *keycodep,
+			      char raw_mode)
+{
+	*keycodep = keycode;
+	return 1;
+}
+
+__apus
+static char apus_kbd_unexpected_up(unsigned char keycode)
+{
+	return 0200;
+}
+
+__apus  
+static void apus_kbd_leds(unsigned char leds)
+{
+}
+
+__apus  
+static void apus_kbd_init_hw(void)
+{
+#ifdef CONFIG_APUS
+	extern int amiga_keyb_init(void);
+
+printk("**** " __FUNCTION__ "\n");
+	amiga_keyb_init();
+#endif
+}
+
+
+/****************************************************** init */
+extern void amiga_disable_irq(unsigned int irq);
+extern void amiga_enable_irq(unsigned int irq);
+extern void m68k_init_IRQ (void);
+
+struct hw_interrupt_type amiga_irq_ctl = {
+	" Amiga    ",
+        NULL,
+        NULL,
+        NULL,
+        amiga_enable_irq,
+        amiga_disable_irq,
+        NULL,
+        0
+};
+
 __initfunc(void
-apus_local_init_IRQ(void))
+apus_init_IRQ(void))
 {
-	ppc_md.mask_irq = amiga_disable_irq;
-	ppc_md.unmask_irq = amiga_enable_irq;
-	apus_init_IRQ();
+	int i;
+
+	for (i = 0; i < NR_IRQS; i++)
+		irq_desc[i].ctl = &amiga_irq_ctl;
+	m68k_init_IRQ ();
 }
 
 __initfunc(void
 apus_init(unsigned long r3, unsigned long r4, unsigned long r5,
 	  unsigned long r6, unsigned long r7))
 {
+	extern int parse_bootinfo(const struct bi_record *);
+	extern char _end[];
+	
 	/* Parse bootinfo. The bootinfo is located right after
            the kernel bss */
 	parse_bootinfo((const struct bi_record *)&_end);
@@ -591,9 +856,6 @@
 		initrd_end = (unsigned long) 
 			__va(ramdisk.size + ramdisk.addr);
 	}
-	/* Make sure code below is not executed. */
-	r4 = 0;
-	r6 = 0;
 #endif /* CONFIG_BLK_DEV_INITRD */
 
 	ISA_DMA_THRESHOLD = 0x00ffffff;
@@ -604,7 +866,7 @@
 	ppc_md.irq_cannonicalize = NULL;
 	ppc_md.init_IRQ       = apus_init_IRQ;
 	ppc_md.do_IRQ         = apus_do_IRQ;
-	ppc_md.get_irq_source = NULL;
+
 	ppc_md.init           = NULL;
 
 	ppc_md.restart        = apus_restart;
@@ -616,15 +878,20 @@
 	ppc_md.get_rtc_time   = apus_get_rtc_time;
 	ppc_md.calibrate_decr = apus_calibrate_decr;
 
+	ppc_md.nvram_read_val = NULL;
+	ppc_md.nvram_write_val = NULL;
+
 	/* These should not be used for the APUS yet, since it uses
 	   the M68K keyboard now. */
-	ppc_md.kbd_setkeycode    = NULL;
-	ppc_md.kbd_getkeycode    = NULL;
-	ppc_md.kbd_translate     = NULL;
-	ppc_md.kbd_unexpected_up = NULL;
-	ppc_md.kbd_leds          = NULL;
-	ppc_md.kbd_init_hw       = NULL;
+	ppc_md.kbd_setkeycode    = apus_kbd_setkeycode;
+	ppc_md.kbd_getkeycode    = apus_kbd_getkeycode;
+	ppc_md.kbd_translate     = apus_kbd_translate;
+	ppc_md.kbd_unexpected_up = apus_kbd_unexpected_up;
+	ppc_md.kbd_leds          = apus_kbd_leds;
+	ppc_md.kbd_init_hw       = apus_kbd_init_hw;
+#ifdef CONFIG_MAGIC_SYSRQ
 	ppc_md.kbd_sysrq_xlate	 = NULL;
+#endif
 
 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
         ppc_ide_md.insw = apus_ide_insw;
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/debug.h ./arch/ppc/kernel/debug.h
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/debug.h	Thu Jan  1 01:00:00 1970
+++ ./arch/ppc/kernel/debug.h	Tue Sep  1 21:59:02 1998
@@ -0,0 +1,111 @@
+/* Roman Zippel's debug functions */
+
+#include <asm/amigappc.h>
+
+#define INITSERIAL()           \
+       lis     r4,0x00bf;      \
+       ori     r4,r4,0xd000;   \
+       lis     r5,0x00df;      \
+       ori     r5,r5,0xf032;   \
+       lbz     r0,0(r4);       \
+       clrlwi  r0,r0,25;       \
+       stb     r0,0(r4);       \
+       li      r0,368;         \
+       sth     r0,0(r5)
+
+#define SENDCHAR()             \
+       lis     r4,0x00df;      \
+       ori     r4,r4,0xf000;   \
+       clrlwi  r3,r3,24;       \
+       ori     r3,r3,0x100;    \
+       sth     r3,0x30(r4);    \
+       eieio;                  \
+50:    lhz     r0,0x18(r4);    \
+       andi.   r0,r0,8192;     \
+       beq     50b
+
+#define SENDNL()               \
+       li      r3,'\n';        \
+       SENDCHAR();             \
+       li      r3,'\r';        \
+       SENDCHAR()
+
+#define        SENDLONG()              \
+       mr      r5,r3;          \
+       li      r3,' ';         \
+       SENDCHAR();             \
+       li      r6,0;           \
+51:    addi    r6,r6,4;        \
+       rlwnm   r3,r5,r6,28,31; \
+       addi    r3,r3,'0';      \
+       cmpwi   r3,'9';         \
+       ble     52f;            \
+       addi    r3,r3,'A'-'9'-1;\
+52:    SENDCHAR();             \
+       cmpwi   r6,32;          \
+       bne     51b
+
+#define SENDCHAR2()            \
+       lis     r4,0x80df;      \
+       ori     r4,r4,0xf000;   \
+       clrlwi  r3,r3,24;       \
+       ori     r3,r3,0x100;    \
+       sth     r3,0x30(r4);    \
+       eieio;                  \
+50:    lhz     r0,0x18(r4);    \
+       andi.   r0,r0,8192;     \
+       beq     50b
+
+#define SENDNL2()              \
+       li      r3,'\n';        \
+       SENDCHAR2();            \
+       li      r3,'\r';        \
+       SENDCHAR2()
+
+#define        SENDLONG2()             \
+       mr      r5,r3;          \
+       li      r3,' ';         \
+       SENDCHAR2();            \
+       li      r6,0;           \
+51:    addi    r6,r6,4;        \
+       rlwnm   r3,r5,r6,28,31; \
+       addi    r3,r3,'0';      \
+       cmpwi   r3,'9';         \
+       ble     52f;            \
+       addi    r3,r3,'A'-'9'-1;\
+52:    SENDCHAR2();            \
+       cmpwi   r6,32;          \
+       bne     51b
+
+#ifdef __ASSEMBLY__
+
+initserial:
+       INITSERIAL()
+       blr
+
+       .global sendchar
+sendchar:
+       SENDCHAR()
+       blr
+sendnl:
+       SENDNL()
+       blr
+
+       .global sendlong
+sendlong:
+       SENDLONG()
+       blr
+
+sendchar2:
+       SENDCHAR2()
+       blr
+
+sendnl2:
+       SENDNL2()
+       blr
+
+sendlong2:
+       SENDLONG2()
+       blr
+
+#endif
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/head.S ./arch/ppc/kernel/head.S
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/head.S	Wed May 12 09:56:44 1999
+++ ./arch/ppc/kernel/head.S	Sun May 16 12:01:08 1999
@@ -41,6 +41,19 @@
 #include <asm/amigappc.h>
 #endif
 
+#if 1
+#define APUS_PROGRESS(_a)
+#else
+#define APUS_PROGRESS(_a)			\
+	lis	r3,0xfff0;			\
+	ori	r3,r3,0xeff0;			\
+	lis	r4,0x1234;			\
+	ori	r4,r4,(_a);			\
+	stw	r4,0x0(r3);			\
+	dcbf	0,r3;				\
+	sync;					\
+	isync
+#endif
 /* optimization for 603 to load the tlb directly from the linux table */
 #define NO_RELOAD_HTAB 1
 	
@@ -103,27 +116,27 @@
 	lwz	RB,offset+4(reg);	\
 	mtspr	IBAT##n##U,RA;	\
 	mtspr	IBAT##n##L,RB;	\
-	beq	1f;		\
+	beq	0f;		\
 	lwz	RA,offset+8(reg);	\
 	lwz	RB,offset+12(reg);	\
 	mtspr	DBAT##n##U,RA;	\
 	mtspr	DBAT##n##L,RB;	\
-1:	 
+0:	 
+
+#define tophys(rd,rs)				\
+0:	addis	rd,rs,-KERNELBASE@h;		\
+	.section ".vtop_fixup","aw";		\
+	.align  1;				\
+	.long   0b;				\
+	.previous
+
+#define tovirt(rd,rs)				\
+0:	addis	rd,rs,KERNELBASE@h;		\
+	.section ".ptov_fixup","aw";		\
+	.align  1;				\
+	.long   0b;				\
+	.previous
 
-#ifndef CONFIG_APUS
-#define tophys(rd,rs,rt)	addis	rd,rs,-KERNELBASE@h
-#define tovirt(rd,rs,rt)	addis	rd,rs,KERNELBASE@h
-#else
-#define tophys(rd,rs,rt)	 \
-	lis	rt,CYBERBASEp@h; \
-	lwz	rt,0(rt);	 \
-	add	rd,rs,rt
-#define tovirt(rd,rs,rt)	 \
-	lis	rt,CYBERBASEp@h; \
-	lwz	rt,0(rt);	 \
-	sub	rd,rs,rt
-#endif
-	
 	.text
 	.globl	_stext
 _stext:
@@ -154,6 +167,7 @@
  *
  * APUS
  *   r3: 'APUS'
+ *   r4: physical address of memory base
  *   Linux/m68k style BootInfo structure at &_end.
  *
  * PREP
@@ -221,6 +235,16 @@
 	bl	prom_init
 	.globl	__secondary_start
 __secondary_start:
+/* On APUS the __va/__pa constants need to be set to the correct 
+ * values before continuing. 
+ */
+	lis	r3,0x6170
+	ori	r3,r3,0x7573
+	cmpw	4,r3,r31		/* cr4.eq is true if this is APUS */
+	bne	4,1f
+	mr	r4,r30
+	bl	fix_mem_constants
+1:
 /*
  * Use the first pair of BAT registers to map the 1st 16MB
  * of RAM to KERNELBASE.  From this point on we can't safely
@@ -241,16 +265,17 @@
 	mtspr	IBAT1L,r10
 	b	5f
 4:
-#ifdef CONFIG_APUS
-	ori	r11,r11,BL_8M<<2|0x2	/* set up an 8MB mapping */
-	ori	r11,r11,0xfe		/* set up an 8MB mapping */
-	lis	r8,CYBERBASEp@h
-	lwz	r8,0(r8)
-	addis	r8,r8,KERNELBASE@h
-	addi	r8,r8,2
-#else
+	tophys(r8,r11)                  /* phys memory base */
+	ori	r8,r8,2			/* R/W access */
+	beq	4,1f                    /* only set up 8MB on APUS */
 	ori	r11,r11,BL_256M<<2|0x2	/* set up BAT registers for 604 */
-	li	r8,2			/* R/W access */
+1:	ori	r11,r11,BL_8M<<2|0x2	/* set up 8MB BAT registers for 604 */
+	mtspr	DBAT0L,r8		/* N.B. 6xx (not 601) have valid */
+	mtspr	DBAT0U,r11		/* bit in upper BAT register */
+	mtspr	IBAT0L,r8
+	mtspr	IBAT0U,r11
+
+#ifndef CONFIG_APUS		        /* out of space! :( */
 	/* 
 	 * allow secondary cpus to get at all of ram in early bootup
 	 * since their init_task may be up there -- Cort
@@ -269,33 +294,8 @@
 	mtspr	IBAT2L,r28
 	mtspr	IBAT2U,r21
 #endif
-	mtspr	DBAT0L,r8		/* N.B. 6xx (not 601) have valid */
-	mtspr	DBAT0U,r11		/* bit in upper BAT register */
-	mtspr	IBAT0L,r8
-	mtspr	IBAT0U,r11
 5:	isync
 
-#ifdef CONFIG_APUS
-	/* Unfortunately the APUS specific instructions bloat the
-	 * code so it cannot fit in the 0x100 bytes available. We have
-	 * to do it the crude way. */
-
-	/* Map 0xfff00000 so we can access VTOP/PTOV constant when
-	   MMU is enabled. */
-	lis	r8,0xfff0
-	ori	r11,r8,0x2		/* r/w */
-	ori	r8,r8,0x2		/* 128KB, supervisor */
-	mtspr	DBAT3U,r8
-	mtspr	DBAT3L,r11
-	
-	/* Copy exception code to exception vector base. */
-	lis	r3,KERNELBASE@h
-	tophys(r4,r3,r5)
-	lis	r3,0xfff0		/* Copy to 0xfff00000 on APUS */
-	li	r5,0x4000		/* # bytes of memory to copy */
-	li	r6,0
-	bl	copy_and_flush		/* copy the first 0x4000 bytes */
-#else /* CONFIG_APUS */
 /*
  * We need to run with _start at physical address 0.
  * On CHRP, we are loaded at 0x10000 since OF on CHRP uses
@@ -304,6 +304,7 @@
  * If the MMU is already turned on, we copy stuff to KERNELBASE,
  * otherwise we copy it to 0.
  */
+	beq	4,2f                    /* skip this on APUS */
 	bl	reloc_offset
 	mr	r26,r3
 	addis	r4,r3,KERNELBASE@h	/* current address of _start */
@@ -317,7 +318,7 @@
 	cmpw	0,r4,r3			/* already running at KERNELBASE? */
 	bne	relocate_kernel
 2:
-#endif /* CONFIG_APUS */
+
 /*
  * we now have the 1st 16M of ram mapped with the bats.
  * prep needs the mmu to be turned on here, but pmac already has it on.
@@ -430,7 +431,7 @@
 	mfspr	r21,SPRG2;		/* exception stack to use from */ \
 	cmpwi	0,r21,0;		/* user mode or RTAS */ \
 	bne	1f;		\
-	tophys(r21,r1,r21);		/* use tophys(kernel sp) otherwise */ \
+	tophys(r21,r1);			/* use tophys(kernel sp) otherwise */ \
 	subi	r21,r21,INT_FRAME_SIZE+STACK_UNDERHEAD;	/* alloc exc. frame */\
 1:	stw	r20,_CCR(r21);		/* save registers */ \
 	stw	r22,GPR22(r21);	\
@@ -451,7 +452,7 @@
 	stw	r1,GPR1(r21);	\
 	stw	r2,GPR2(r21);	\
 	stw	r1,0(r21);	\
-	tovirt(r1,r21,r1);		/* set new kernel sp */	\
+	tovirt(r1,r21);			/* set new kernel sp */	\
 	SAVE_4GPRS(3, r21);
 /*
  * Note: code which follows this uses cr0.eq (set if from kernel),
@@ -535,44 +536,18 @@
 	.long	int_return
 
 /* External interrupt */
-	. = 0x500;
+	. = 0x500
 HardwareInterrupt:
 	EXCEPTION_PROLOG;
-#ifdef CONFIG_APUS
-	/* This is horrible, but there's no way around it. Enable the
-	data cache so the IRQ hardware register can be accessed
-	without cache intervention. Then disable interrupts and get
-	the current emulated m68k IPL value. */
-	
-	mfmsr	20
-	xori	r20,r20,MSR_DR
-	sync
-	mtmsr	r20
-	sync
 
-	lis	r3,APUS_IPL_EMU@h
-
-	li	r20,(IPLEMU_SETRESET|IPLEMU_DISABLEINT)
-	stb	r20,APUS_IPL_EMU@l(r3)
-	eieio
-
-	lbz	r3,APUS_IPL_EMU@l(r3)
-
-	mfmsr	r20
-	xori	r20,r20,MSR_DR
-	sync
-	mtmsr	r20
-	sync
-
-	stw	r3,(_CCR+4)(r21);
-#endif
 	addi	r3,r1,STACK_FRAME_OVERHEAD
 	li	r20,MSR_KERNEL
-	li	r4,0
-	bl	transfer_to_handler
-	.long	do_IRQ;
+apusIRQ:	
+	bl	transfer_to_handler         /* On APUS these three words */
+	.long	do_IRQ                      /* will be replaced with NOPs */
 	.long	int_return
-	
+
+	bl	apus_interrupt_entry
 
 /* Alignment exception */
 	. = 0x600
@@ -655,13 +630,13 @@
 	/* Get PTE (linux-style) and check access */
 	mfspr	r2,SPRG3
 	lwz	r2,PG_TABLES(r2)
-	tophys(r2,r2,r3)
+	tophys(r2,r2)
 	mfspr	r3,IMISS
 	rlwimi	r2,r3,12,20,29		/* insert top 10 bits of address */
 	lwz	r2,0(r2)		/* get pmd entry */
 	rlwinm.	r2,r2,0,0,19		/* extract address of pte page */
 	beq-	InstructionAddressInvalid	/* return if no mapping */
-	tophys(r2,r2,r1)
+	tophys(r2,r2)
 	rlwimi	r2,r3,22,20,29		/* insert next 10 bits of address */
 	lwz	r1,0(r2)		/* get linux-style pte */
 	/* setup access flags in r3 */
@@ -758,13 +733,13 @@
 	/* Get PTE (linux-style) and check access */
 	mfspr	r2,SPRG3
 	lwz	r2,PG_TABLES(r2)		
-	tophys(r2,r2,r3)
+	tophys(r2,r2)
 	mfspr	r3,DMISS
 	rlwimi	r2,r3,12,20,29		/* insert top 10 bits of address */
 	lwz	r2,0(r2)		/* get pmd entry */
 	rlwinm.	r2,r2,0,0,19		/* extract address of pte page */
 	beq-	DataAddressInvalid	/* return if no mapping */
-	tophys(r2,r2,r1)
+	tophys(r2,r2)
 	rlwimi	r2,r3,22,20,29		/* insert next 10 bits of address */
 	lwz	r1,0(r2)		/* get linux-style pte */
 	/* setup access flags in r3 */
@@ -865,7 +840,7 @@
 	/* We have a pte table, so load the MI_TWC with the attributes
 	 * for this page, which has only bit 31 set.
 	 */
-	tophys(r21,r21,0)
+	tophys(r21,r21)
 	ori	r21,r21,1		/* Set valid bit */
 	mtspr	MI_TWC, r21	/* Set page attributes */
 	mtspr	MD_TWC, r21	/* Load pte table base address */
@@ -920,13 +895,13 @@
 	/* Get PTE (linux-style) and check access */
 	mfspr	r2,SPRG3
 	lwz	r2,PG_TABLES(r2)		
-	tophys(r2,r2,r3)
+	tophys(r2,r2)
 	mfspr	r3,DMISS
 	rlwimi	r2,r3,12,20,29		/* insert top 10 bits of address */
 	lwz	r2,0(r2)		/* get pmd entry */
 	rlwinm.	r2,r2,0,0,19		/* extract address of pte page */
 	beq-	DataAddressInvalid	/* return if no mapping */
-	tophys(r2,r2,r1)
+	tophys(r2,r2)
 	rlwimi	r2,r3,22,20,29		/* insert next 10 bits of address */
 	lwz	r1,0(r2)		/* get linux-style pte */
 	/* setup access flags in r3 */
@@ -988,7 +963,7 @@
 
 	/* We have a pte table, so load fetch the pte from the table.
 	 */
-	tophys(r21, r21, 0)
+	tophys(r21, r21)
 	ori	r21, r21, 1	/* Set valid bit in physical L2 page */
 	mtspr	MD_TWC, r21	/* Load pte table base address */
 	mfspr	r21, MD_TWC	/* ....and get the pte address */
@@ -1072,7 +1047,7 @@
 
 	/* We have a pte table, so fetch the pte from the table.
 	 */
-	tophys(r21, r21, 0)
+	tophys(r21, r21)
 	ori	r21, r21, 1		/* Set valid bit in physical L2 page */
 	mtspr	MD_TWC, r21		/* Load pte table base address */
 	mfspr	r21, MD_TWC		/* ....and get the pte address */
@@ -1178,7 +1153,7 @@
 	addi	r24,r1,STACK_FRAME_OVERHEAD
 	stw	r24,PT_REGS(r23)
 2:	addi	r2,r23,-TSS		/* set r2 to current */
-	tovirt(r2,r2,r23)
+	tovirt(r2,r2)
 	mflr	r23
 	andi.	r24,r23,0x3f00		/* get vector offset */
 	stw	r24,TRAP(r21)
@@ -1246,7 +1221,7 @@
 	eieio
 	lis	r2,hash_table_lock@h
 	ori	r2,r2,hash_table_lock@l
-	tophys(r2,r2,r6)
+	tophys(r2,r2)
 	lis	r6,100000000@h
 	mtctr	r6
 	lwz	r0,PROCESSOR-TSS(r5)
@@ -1263,7 +1238,7 @@
 #endif
 	/* Get PTE (linux-style) and check access */
 	lwz	r5,PG_TABLES(r5)		
-	tophys(r5,r5,r2)		/* convert to phys addr */
+	tophys(r5,r5)			/* convert to phys addr */
 	rlwimi	r5,r3,12,20,29		/* insert top 10 bits of address */
 	lwz	r5,0(r5)		/* get pmd entry */
 	rlwinm.	r5,r5,0,0,19		/* extract address of pte page */
@@ -1276,7 +1251,7 @@
 	   to the address following the rfi. */
 	beqlr-
 #endif
-	tophys(r2,r5,r2)
+	tophys(r2,r5)
 	rlwimi	r2,r3,22,20,29		/* insert next 10 bits of address */
 	lwz	r6,0(r2)		/* get linux-style pte */
 	ori	r4,r4,1			/* set _PAGE_PRESENT bit in access */
@@ -1384,7 +1359,7 @@
 	/* update counter of evicted pages */
 	lis	r2,htab_evicts@h
 	ori	r2,r2,htab_evicts@l
-	tophys(r2,r2,r4)
+	tophys(r2,r2)
 	lwz	r4,0(r2)
 	addi	r4,r4,1
 	stw	r4,0(r2)
@@ -1439,14 +1414,14 @@
  */
 	lis	r2,htab_reloads@h
 	ori	r2,r2,htab_reloads@l
-	tophys(r2,r2,r3)
+	tophys(r2,r2)
 	lwz	r3,0(r2)
 	addi	r3,r3,1
 	stw	r3,0(r2)
 
 #ifdef __SMP__
 	lis	r2,hash_table_lock@ha
-	tophys(r2,r2,r6)
+	tophys(r2,r2)
 	li	r0,0
 	stw	r0,hash_table_lock@l(r2)
 	eieio
@@ -1473,7 +1448,7 @@
 #ifdef __SMP__
 hash_page_out:
 	lis	r2,hash_table_lock@ha
-	tophys(r2,r2,r6)
+	tophys(r2,r2)
 	li	r0,0
 	stw	r0,hash_table_lock@l(r2)
 	eieio
@@ -1506,12 +1481,8 @@
  * to another.  Instead we call giveup_fpu in switch_to.
  */
 #ifndef __SMP__
-#ifndef CONFIG_APUS
-	lis	r6,-KERNELBASE@h
-#else
-	lis	r6,CYBERBASEp@h
-	lwz	r6,0(r6)
-#endif
+	lis	r6,0                    /* get __pa constant */
+	tophys(r6,r6)
 	addis	r3,r6,last_task_used_math@ha
 	lwz	r4,last_task_used_math@l(r3)
 	cmpi	0,r4,0
@@ -1662,14 +1633,164 @@
 	addi	r6,r6,4
 	blr
 
-#ifdef CONFIG_APUS
-	/* On APUS the first 0x4000 bytes of the kernel	will be mapped
-	 * at a different physical address than the rest. For this
-	 * reason, the exception code cannot use relative branches to
-	 * access the code below.
+/*
+ * On APUS the physical base address of the kernel is not known at compile
+ * time, which means the __pa/__va constants used are incorect. In the
+ * __init section is recorded the virtual addresses of instructions using
+ * these constants, so all that has to be done is fix these before
+ * continuing the kernel boot.
+ *
+ * r4 = The physical address of the kernel base.
+ */
+fix_mem_constants:
+	mr	r10,r4
+	addis	r10,r10,-KERNELBASE@h    /* virt_to_phys constant */
+	neg	r11,r10	                 /* phys_to_virt constant */
+
+ 	APUS_PROGRESS(2)
+
+	lis	r12,__vtop_table_begin@h
+	ori	r12,r12,__vtop_table_begin@l
+	add	r12,r12,r10	         /* table begin phys address */
+	lis	r13,__vtop_table_end@h
+	ori	r13,r13,__vtop_table_end@l
+	add	r13,r13,r10	         /* table end phys address */
+	subi	r12,r12,4
+	subi	r13,r13,4
+1:	lwzu	r14,4(r12)               /* virt address of instruction */
+	add     r14,r14,r10              /* phys address of instruction */
+	lwz     r15,0(r14)               /* instruction, now insert top */
+	rlwimi  r15,r10,16,16,31         /* half of vp const in low half */
+	stw	r15,0(r14)               /* of instruction and restore. */
+	dcbst	r0,r14			 /* write it to memory */
+	sync
+	icbi	r0,r14			 /* flush the icache line */
+	cmpw	r12,r13
+	bne     1b
+
+ 	APUS_PROGRESS(3)
+
+	lis	r12,__ptov_table_begin@h
+	ori	r12,r12,__ptov_table_begin@l
+	add	r12,r12,r10	         /* table begin phys address */
+	lis	r13,__ptov_table_end@h
+	ori	r13,r13,__ptov_table_end@l
+	add	r13,r13,r10	         /* table end phys address */
+	subi	r12,r12,4
+	subi	r13,r13,4
+1:	lwzu	r14,4(r12)               /* virt address of instruction */
+	add     r14,r14,r10              /* phys address of instruction */
+	lwz     r15,0(r14)               /* instruction, now insert top */
+	rlwimi  r15,r11,16,16,31         /* half of pv const in low half*/
+	stw	r15,0(r14)               /* of instruction and restore. */
+	dcbst	r0,r14			 /* write it to memory */
+	sync
+	icbi	r0,r14			 /* flush the icache line */
+	cmpw	r12,r13
+	bne     1b
+
+ 	APUS_PROGRESS(4)
+	/*
+	 * Let Hardware Interrupts fall through to APUS specific 
+	 * handling.
 	 */
-	. = 0x4000
+	lis	r12,apusIRQ@h
+	ori	r12,r12,apusIRQ@l
+	add	r12,r12,r10              /* phys address of instructions */
+	lis     r8,0x38600000@h
+	ori     r8,r8,0x38600000@l
+	stw	r8,0(r12)
+	stwu	r8,4(r12)
+	stwu	r8,4(r12)
+	dcbst	r0,r12			 /* write it to memory */
+	sync
+	icbi	r0,r12			 /* flush the icache line */
+	subi	r12,r12,8
+	dcbst	r0,r12			 /* write it to memory */
+	sync
+	icbi	r0,r12			 /* flush the icache line */
+
+ 	APUS_PROGRESS(5)
+	
+	/*
+	 * Map the memory where the exception handlers will
+  	 * be copied to when hash constants have been patched.  
+	 */
+#ifdef CONFIG_APUS_FAST_EXCEPT
+	lis	r8,0xfff0
+#else
+	lis	r8,0
 #endif
+	ori	r8,r8,0x2		/* 128KB, supervisor */
+	mtspr	DBAT3U,r8
+	mtspr	DBAT3L,r8
+
+
+ 	APUS_PROGRESS(6)
+	isync				/* No speculative loading until now */
+	blr
+	
+apus_interrupt_entry:
+	/* This is horrible, but there's no way around it. Enable the
+	 * data cache so the IRQ hardware register can be accessed
+	 * without cache intervention. Then disable interrupts and get
+	 * the current emulated m68k IPL value. 
+	 */
+	
+	mfmsr	20
+	xori	r20,r20,MSR_DR
+	sync
+	mtmsr	r20
+	sync
+
+	lis	r4,APUS_IPL_EMU@h
+
+	li	r20,(IPLEMU_SETRESET|IPLEMU_DISABLEINT)
+	stb	r20,APUS_IPL_EMU@l(r4)
+	eieio
+
+	lbz	r3,APUS_IPL_EMU@l(r4)
+
+	li	r2,IPLEMU_IPLMASK
+	rlwinm. r20,r3,32-3,29,31
+	bne	2f
+	mr	r20,r2		/* lvl7! Need to reset state machine. */
+	b	3f
+2:	cmp	0,r20,r2
+	beq	1f
+3:	eieio
+	stb     r2,APUS_IPL_EMU@l(r4)
+	ori	r20,r20,IPLEMU_SETRESET
+	eieio
+	stb     r20,APUS_IPL_EMU@l(r4)
+1:	eieio
+	li	r20,IPLEMU_DISABLEINT
+	stb	r20,APUS_IPL_EMU@l(r4)
+
+	/* At this point we could do some magic to avoid the overhead
+	 * of calling the C interrupt handler. Could not get a simple
+	 * hack to work though.
+	 */
+	
+	mfmsr	r20
+	xori	r20,r20,MSR_DR
+	sync
+	mtmsr	r20
+	sync
+
+	stw	r3,(_CCR+4)(r21);
+
+	addi	r3,r1,STACK_FRAME_OVERHEAD;
+	li	r20,MSR_KERNEL;
+	bl	transfer_to_handler;
+	.long	do_IRQ;
+	.long	int_return
+	
+/***********************************************************************
+ *  Please note that on APUS the exception handlers are located at the
+ *  physical address 0xfff0000. For this reason, the exception handlers
+ *  cannot use relative branches to access the code below.
+ ***********************************************************************/
 
 #ifdef CONFIG_SMP
 	.globl	__secondary_start_psurge
@@ -1694,7 +1815,7 @@
 	/* our cpu # was at addr 0 - go */
 	lis	r5,__secondary_start@h
 	ori	r5,r5,__secondary_start@l
-	tophys(r5,r5,r4)
+	tophys(r5,r5)
 	mtlr	r5
 	mr	r24,r3			/* cpu # */
 	blr
@@ -1705,6 +1826,7 @@
  */
 start_here:
 #ifndef CONFIG_8xx
+ 	APUS_PROGRESS(7)
 	/*
 	 * Enable caches and 604-specific features if necessary.
 	 */
@@ -1783,6 +1905,7 @@
 /*
  * Decide what sort of machine this is and initialize the MMU.
  */
+ 	APUS_PROGRESS(8)
 	mr	r3,r31
 	mr	r4,r30
 	mr	r5,r29
@@ -1790,6 +1913,23 @@
 	mr	r7,r27
 	bl	identify_machine
 	bl	MMU_init
+ 	APUS_PROGRESS(9)
+
+	/* Copy exception code to exception vector base on APUS. */
+	bne	4,1f
+	lis	r4,KERNELBASE@h
+#ifdef CONFIG_APUS_FAST_EXCEPT
+	lis	r3,0xfff0		/* Copy to 0xfff00000 */
+#else
+	lis	r3,0			/* Copy to 0x00000000 */
+#endif
+	li	r5,0x4000		/* # bytes of memory to copy */
+	li	r6,0
+	bl	copy_and_flush		/* copy the first 0x4000 bytes */
+1:
+
+ 	APUS_PROGRESS(10)
+
 /*
  * Go back to running unmapped so we can load up new values
  * for SDR1 (hash table pointer) and the segment registers
@@ -1806,13 +1946,13 @@
 	 * easier......until someone changes init's static structures.
 	 */
 	lis	r6, swapper_pg_dir@h
-	tophys(r6,r6,0)
+	tophys(r6,r6)
 	ori	r6, r6, swapper_pg_dir@l
 	mtspr	M_TWB, r6
 #endif
 	lis	r4,2f@h
 	ori	r4,r4,2f@l
-	tophys(r4,r4,r3)
+	tophys(r4,r4)
 	li	r3,MSR_KERNEL & ~(MSR_IR|MSR_DR)
 	mtspr	SRR0,r4
 	mtspr	SRR1,r3
@@ -1843,7 +1983,7 @@
 	cmpwi	r3,1
 	lis	r3,BATS@ha
 	addi	r3,r3,BATS@l
-	tophys(r3,r3,r4)
+	tophys(r3,r3)
 	LOAD_BAT(0,0,r3,r4,r5)
 	LOAD_BAT(1,16,r3,r4,r5)
 	LOAD_BAT(2,32,r3,r4,r5)
@@ -1851,12 +1991,13 @@
 #endif /* CONFIG_8xx */
 /* Set up for using our exception vectors */
 	/* ptr to phys current tss */
-	tophys(r4,r2,r4)
+	tophys(r4,r2)
 	addi	r4,r4,TSS	/* init task's TSS */
 	mtspr	SPRG3,r4
 	li	r3,0
 	mtspr	SPRG2,r3	/* 0 => r1 has kernel sp */
 /* Now turn on the MMU for real! */
+ 	APUS_PROGRESS(12)
 	li	r4,MSR_KERNEL
 	lis	r3,start_kernel@h
 	ori	r3,r3,start_kernel@l
@@ -1866,7 +2007,7 @@
 	 */
 	lis	r5,first_cpu_booted@h
 	ori	r5,r5,first_cpu_booted@l
-	tophys(r5,r5,r3)
+	tophys(r5,r5)
 	lwz	r5,0(r5)
 	cmpi	0,r5,0
 	beq	10f
@@ -2066,7 +2207,7 @@
 	stw	r0,TRAP(r1)
 	stw	r1,KSP(r3)	/* Set old stack pointer */
 	sync
-	tophys(r0,r4,r3)
+	tophys(r0,r4)
 	mtspr	SPRG3,r0	/* Update current TSS phys addr */
 	SYNC
 	lwz	r1,KSP(r4)	/* Load new stack pointer */
@@ -2102,7 +2243,7 @@
 	beq+	10f		/* if not, don't adjust kernel stack */
 8:	addi	r4,r1,INT_FRAME_SIZE+STACK_UNDERHEAD	/* size of frame */
 	stw	r4,TSS+KSP(r2)	/* save kernel stack pointer */
-	tophys(r9,r1,r9)
+	tophys(r9,r1)
 	mtspr	SPRG2,r9	/* phys exception stack pointer */
 10:	lwz	r2,_CTR(r1)
 	lwz	r0,_LINK(r1)
@@ -2139,7 +2280,7 @@
 ret_from_syscall:	
 	.globl	int_return
 int_return:
-0:	mfmsr	r30		/* Disable interrupts */
+00:	mfmsr	r30		/* Disable interrupts */
 	li	r4,0
 	ori	r4,r4,MSR_EE
 	andc	r30,r30,r4
@@ -2177,7 +2318,7 @@
 	cmpi	0,r3,0		/* check need_resched flag */
 	beq+	7f
 	bl	schedule
-	b	0b
+	b	00b
 7:	lwz	r5,SIGPENDING(r2) /* Check for pending unblocked signals */
 	cmpwi	0,r5,0
 	beq+	8f
@@ -2186,10 +2327,10 @@
 	bl	do_signal
 	.globl	do_signal_ret
 do_signal_ret:
-	b	0b
+	b	00b
 8:	addi	r4,r1,INT_FRAME_SIZE+STACK_UNDERHEAD	/* size of frame */
 	stw	r4,TSS+KSP(r2)	/* save kernel stack pointer */
-	tophys(r3,r1,r3)
+	tophys(r3,r1)
 	mtspr	SPRG2,r3	/* phys exception stack pointer */
 10:	lwz	r2,_CTR(r1)
 	lwz	r0,_LINK(r1)
@@ -2339,14 +2480,14 @@
 	li	r4,4096/CACHE_LINE_SIZE	/* Number of lines in a page */
 	mtctr	r4
 	mr	r6,r3
-0:	dcbst	0,r3			/* Write line to ram */
+00:	dcbst	0,r3			/* Write line to ram */
 	addi	r3,r3,CACHE_LINE_SIZE
-	bdnz	0b
+	bdnz	00b
 	sync
 	mtctr	r4
-1:	icbi	0,r6
+10:	icbi	0,r6
 	addi	r6,r6,CACHE_LINE_SIZE
-	bdnz	1b
+	bdnz	10b
 	sync
 	isync
 	blr
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/irq.c ./arch/ppc/kernel/irq.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/irq.c	Tue May 11 11:26:17 1999
+++ ./arch/ppc/kernel/irq.c	Sun May 16 20:05:36 1999
@@ -61,6 +61,13 @@
 
 #include "local_irq.h"
 
+extern int  apus_request_irq(unsigned int irq, 
+                            void (*handler)(int, void *, struct pt_regs *),
+                            unsigned long flags, const char *devname, 
+                            void *dev_id);
+extern void apus_free_irq(unsigned int irq, void *dev_id);
+extern void apus_process_int(unsigned long, void *);
+
 extern volatile unsigned long ipi_count;
 void enable_irq(unsigned int irq_nr);
 void disable_irq(unsigned int irq_nr);
@@ -68,14 +75,6 @@
 /* Fixme - Need to figure out a way to get rid of this - Corey */
 volatile unsigned char *chrp_int_ack_special;
 
-#ifdef CONFIG_APUS
-/* Rename a few functions. Requires the CONFIG_APUS protection. */
-#define request_irq nop_ppc_request_irq
-#define free_irq nop_ppc_free_irq
-#define get_irq_list nop_get_irq_list
-#define VEC_SPUR    (24)
-#endif
-
 #define MAXCOUNT 10000000
 
 #define NR_MASK_WORDS	((NR_IRQS + 31) / 32)
@@ -133,6 +132,10 @@
 	struct irqaction *old, **p, *action;
 	unsigned long flags;
 
+	if (is_apus)
+		return apus_request_irq (irq, handler, irqflags, 
+					 devname, dev_id);
+
 	if (irq >= NR_IRQS)
 		return -EINVAL;
 	if (!handler)
@@ -187,7 +190,10 @@
 
 void free_irq(unsigned int irq, void *dev_id)
 {
-	request_irq(irq, NULL, 0, NULL, dev_id);
+	if (is_apus)
+		apus_free_irq (irq, dev_id);
+	else
+		request_irq(irq, NULL, 0, NULL, dev_id);
 }
 
 void disable_irq(unsigned int irq_nr)
@@ -205,6 +211,9 @@
 {
 	int i, len = 0, j;
 	struct irqaction * action;
+
+	if (_MACH_apus == _machine)
+		return apus_get_irq_list (buf);
 
 	len += sprintf(buf+len, "           ");
 	for (j=0; j<smp_num_cpus; j++)
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/misc.S ./arch/ppc/kernel/misc.S
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/misc.S	Tue May 11 11:26:19 1999
+++ ./arch/ppc/kernel/misc.S	Sat May 15 11:35:12 1999
@@ -243,10 +242,8 @@
 	subi	r5,r5,1		/* Perform 'add' operation */
 	stwcx.	r5,0,r3		/* Update with new value */
 	bne-	10b		/* Retry if "reservation" (i.e. lock) lost */
-	cmpi	0,r5,0		/* Return 'true' IFF 0 */
-	li	r3,1
-	beqlr
-	li	r3,0
+	cntlzw	r3,r5		/* Return 'true' IFF 0 */
+	srwi	r3,r3,5		/* But do it the clever way */
 	blr
 _GLOBAL(atomic_clear_mask)
 10:	lwarx	r5,0,r4
@@ -370,38 +367,59 @@
 	blr	
 
 /*
- * Extended precision shifts
+ * Extended precision shifts.
+ * 
+ * Updated to be valid for shift counts from 0 to 63 inclusive.
+ * -- Gabriel 
  *
  * R3/R4 has 64 bit value
  * R5    has shift count
  * result in R3/R4
  *
- *  ashrdi3:     XXXYYY/ZZZAAA -> SSSXXX/YYYZZZ
- *  ashldi3:     XXXYYY/ZZZAAA -> YYYZZZ/AAA000
+ *  ashrdi3: arithmetic right shift (sign propagation)     
+ *  lslhdi3: logical right shift	
+ *  ashldi3: left shift
  */
 _GLOBAL(__ashrdi3)
-	li	r6,32
-	sub	r6,r6,r5
-	slw	r7,r3,r6	/* isolate YYY */
-	srw	r4,r4,r5	/* isolate ZZZ */
-	or	r4,r4,r7	/* YYYZZZ */
-	sraw	r3,r3,r5	/* SSSXXX */
+	subfic	r6,r5,32	
+	srw	r4,r4,r5	# LSW = count > 31 ? 0 : LSW >> count
+	addi	r7,r5,32	# could be xori, or addi with -32
+	slw	r6,r3,r6	# t1 = count > 31 ? 0 :	MSW << (32-count)
+	rlwinm	r8,r7,0,32	# t3 = (count < 32) ? 32 : 0
+	sraw	r7,r3,r7	# t2 = MSW >> (count-32)
+	or	r4,r4,r6	# LSW |= t1
+	slw	r7,r7,r8	# t2 = (count < 32) ? 0 : t2
+	sraw	r3,r3,r5	# MSW = MSW >> count
+	or	r4,r4,r7	# LSW |= t2
 	blr
-	
+
 _GLOBAL(__ashldi3)
-	li	r6,32
-	sub	r6,r6,r5
-	srw	r7,r4,r6	/* isolate ZZZ */
-	slw	r4,r4,r5	/* AAA000 */
-	slw	r3,r3,r5	/* YYY--- */
-	or	r3,r3,r7	/* YYYZZZ */
+	subfic	r6,r5,32	
+	slw	r3,r3,r5	# MSW = count > 31 ? 0 : MSW << count
+	addi	r7,r5,32	# could be xori, or addi with -32
+	srw	r6,r4,r6	# t1 = count > 31 ? 0 :	LSW >> (32-count)
+	slw	r7,r4,r7	# t2 = count < 32 ? 0 :	LSW << (count-32)
+	or	r3,r3,r6	# MSW |= t1
+	slw	r4,r4,r5	# LSW = LSW << count
+	or	r3,r3,r7	# MSW |= t2
+	blr
+
+_GLOBAL(__lshrdi3)
+	subfic	r6,r5,32	
+	srw	r4,r4,r5	# LSW = count > 31 ? 0 : LSW >> count
+	addi	r7,r5,32	# could be xori, or addi with -32
+	slw	r6,r3,r6	# t1 = count > 31 ? 0 :	MSW << (32-count)
+	srw	r7,r3,r7	# t2 = count < 32 ? 0 :	MSW >> (count-32)
+	or	r4,r4,r6	# LSW |= t1
+	srw	r3,r3,r5	# MSW = MSW >> count
+	or	r4,r4,r7	# LSW |= t2 
 	blr
 
 _GLOBAL(abs)
-	cmpi	0,r3,0
-	bge	10f
-	neg	r3,r3
-10:	blr
+	srawi	r4,r3,31
+	xor	r3,r3,r4
+	sub	r3,r3,r4
+	blr
 
 _GLOBAL(_get_SP)
 	mr	r3,r1		/* Close enough */
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/pci.c ./arch/ppc/kernel/pci.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/pci.c	Tue May 11 11:26:20 1999
+++ ./arch/ppc/kernel/pci.c	Sat May 15 11:35:12 1999
@@ -60,6 +60,8 @@
 
 int pcibios_present(void)
 {
+	if (is_apus)
+		return 0;
 	return 1;
 }
 
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/pmac_setup.c ./arch/ppc/kernel/pmac_setup.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/pmac_setup.c	Wed May 12 09:56:47 1999
+++ ./arch/ppc/kernel/pmac_setup.c	Sun May 16 11:13:10 1999
@@ -54,6 +54,7 @@
 #include <asm/mediabay.h>
 #include <asm/feature.h>
 #include <asm/ide.h>
+#include <asm/dma.h>
 #include <asm/machdep.h>
 
 #include "time.h"
@@ -277,7 +278,7 @@
 
 	feature_init();
 
-#ifdef CONFIG_KGDB
+#if defined(CONFIG_KGDB) && defined(CONFIG_MAC_SERIAL)
 	zs_kgdb_hook(0);
 #endif
 
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/ppc-stub.c ./arch/ppc/kernel/ppc-stub.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/ppc-stub.c	Fri Aug  7 15:53:43 1998
+++ ./arch/ppc/kernel/ppc-stub.c	Sat Feb 20 16:32:45 1999
@@ -112,6 +112,32 @@
 #include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
+#include <asm/io.h>
+#include <asm/amigahw.h>
+#include <asm/amigaints.h>
+
+extern int amiga_ser_out( unsigned char c );
+extern unsigned char amiga_ser_in( void );
+
+#define getDebugChar amiga_ser_in
+#define putDebugChar amiga_ser_out
+
+void kgdb_interruptible (int stat)
+{
+	if (stat) {
+		custom.intreq = IF_RBF;
+		mb();
+		custom.intena = IF_SETCLR | IF_RBF;
+	} else
+		custom.intena = IF_RBF;
+}
+
+void kgdb_abort (void)
+{
+	breakpoint ();
+}
+
+
 void breakinst(void);
 
 /*
@@ -181,7 +207,7 @@
  * return 0.
  */
 static unsigned char *
-mem2hex(char *mem, char *buf, int count)
+mem2hex(const char *mem, char *buf, int count)
 {
 	unsigned char ch;
 
@@ -343,7 +369,7 @@
 	flush_instruction_cache();
 }
 
-static inline int get_msr()
+static inline int get_msr(void)
 {
 	int msr;
 	asm volatile("mfmsr %0" : "=r" (msr):);
@@ -358,12 +384,23 @@
 /* Set up exception handlers for tracing and breakpoints
  * [could be called kgdb_init()]
  */
+
+void kgdb_init(void)
+{
+
+  set_debug_traps();
+}
+
+extern void amiga_serinit(void);
+
 void set_debug_traps(void)
 {
-#if 0
+
+#if 1
 	unsigned char c;
+	amiga_serinit();
 
-	save_and_cli(flags);
+/*	save_and_cli(flags);*/
 
 	/* In case GDB is started before us, ack any packets (presumably
 	 * "$?#xx") sitting there.
@@ -373,10 +410,12 @@
 	 * now starting either before or after the kernel   -bwb
 	 */
 
+#if 0
 	while((c = getDebugChar()) != '$');
 	while((c = getDebugChar()) != '#');
 	c = getDebugChar(); /* eat first csum byte */
 	c = getDebugChar(); /* eat second csum byte */
+#endif
 	putDebugChar('+'); /* ack it */
 #endif
 	debugger = kgdb;
@@ -701,4 +740,17 @@
 	asm("	.globl breakinst
 	     breakinst: trap
             ");
+}
+
+void
+__gdb_output_string (const char* s, unsigned int count)
+{
+	char buffer[512];
+
+	count = (count <= (sizeof(buffer) / 2 - 2)) 
+		? count : (sizeof(buffer) / 2 - 2);
+
+	buffer[0] = 'O';
+	mem2hex (s, &buffer[1], count);
+	putpacket(buffer);
 }
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/ppc_ksyms.c ./arch/ppc/kernel/ppc_ksyms.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/ppc_ksyms.c	Tue May 11 11:26:23 1999
+++ ./arch/ppc/kernel/ppc_ksyms.c	Sat May 15 12:29:33 1999
@@ -47,6 +47,7 @@
 extern int do_signal(sigset_t *, struct pt_regs *);
 
 asmlinkage long long __ashrdi3(long long, int);
+asmlinkage long long __lshrdi3(long long, int);
 asmlinkage int abs(int);
 
 EXPORT_SYMBOL(clear_page);
@@ -149,6 +150,7 @@
 EXPORT_SYMBOL(ioremap);
 EXPORT_SYMBOL(__ioremap);
 EXPORT_SYMBOL(iounmap);
+EXPORT_SYMBOL(iopa);
 
 EXPORT_SYMBOL(ide_insw);
 EXPORT_SYMBOL(ide_outsw);
@@ -200,19 +202,28 @@
 EXPORT_SYMBOL(find_path_device);
 EXPORT_SYMBOL(find_phandle);
 EXPORT_SYMBOL(get_property);
+EXPORT_SYMBOL(device_is_compatible);
+#ifdef CONFIG_PCI
 EXPORT_SYMBOL(pci_io_base);
 EXPORT_SYMBOL(pci_device_loc);
+#endif
 EXPORT_SYMBOL(feature_set);
 EXPORT_SYMBOL(feature_clear);
 EXPORT_SYMBOL(feature_test);
-#ifdef CONFIG_SCSI
+#if defined(CONFIG_SCSI) && defined(CONFIG_PMAC)
 EXPORT_SYMBOL(note_scsi_host);
-#endif
+#endif 
 EXPORT_SYMBOL(kd_mksound);
 #ifdef CONFIG_PMAC
 EXPORT_SYMBOL(nvram_read_byte);
 EXPORT_SYMBOL(nvram_write_byte);
 #endif /* CONFIG_PMAC */
+#ifdef CONFIG_APUS
+extern char debug_device[];
+EXPORT_SYMBOL(debug_device);
+extern unsigned long m68k_machtype;
+EXPORT_SYMBOL(m68k_machtype);
+#endif /* CONFIG_APUS */
 
 EXPORT_SYMBOL(abs);
 EXPORT_SYMBOL(device_is_compatible);
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/setup.c ./arch/ppc/kernel/setup.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/setup.c	Tue May 11 11:26:26 1999
+++ ./arch/ppc/kernel/setup.c	Sat May 15 18:35:05 1999
@@ -79,6 +79,7 @@
 int have_of = 0;
 int is_prep = 0;
 int is_chrp = 0;
+int is_apus = 0;
 /* For MTX/MVME boards.. with Raven/Falcon Chipset
       Real close to CHRP, but boot like PReP (via PPCbug)
       There's probably a nicer way to do this.. --Troy */
@@ -342,8 +343,8 @@
 	/* boot loader will tell us if we're APUS */
 	if ( r3 == 0x61707573 )
 	{
+		is_apus = 1;
 		_machine = _MACH_apus;
-		r3 = 0;
 	}
 	/* prep boot loader tells us if we're prep or not */
 	else if ( *(unsigned long *)(KERNELBASE) == (0xdeadc0de) ) {
@@ -397,6 +398,7 @@
 #elif defined(CONFIG_FADS)
 	_machine = _MACH_fads;
 #elif defined(CONFIG_APUS)
+	is_apus  = 1;
 	_machine = _MACH_apus;
 #else
 #error "Machine not defined correctly"
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/syscalls.c ./arch/ppc/kernel/syscalls.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/kernel/syscalls.c	Tue May 11 11:26:27 1999
+++ ./arch/ppc/kernel/syscalls.c	Sun May 16 10:19:38 1999
@@ -205,15 +205,12 @@
 
 	lock_kernel();
 	if (!(flags & MAP_ANONYMOUS)) {
-		file = fget(fd);
-		if (!file)
+		if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
 			goto out;
 	}
 	
 	flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
 	ret = do_mmap(file, addr, len, prot, flags, offset);
-	if (file)
-		fput(file);
 out:
 	unlock_kernel();
 	return ret;
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/mm/init.c ./arch/ppc/mm/init.c
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/mm/init.c	Wed May 12 09:56:50 1999
+++ ./arch/ppc/mm/init.c	Sun May 16 14:22:32 1999
@@ -50,10 +50,8 @@
 #include <asm/mbx.h>
 #include <asm/smp.h>
 #include <asm/bootx.h>
-/* APUS includes */
-#include <asm/setup.h>
-#include <asm/amigahw.h>
-/* END APUS includes */
+#include <asm/setup.h>		/* struct mem_info */
+#include <asm/amigahw.h>	/* zTwoBase */
 
 int prom_trashed;
 atomic_t next_mmu_context;
@@ -65,18 +63,19 @@
 extern char __init_begin, __init_end;
 extern char __prep_begin, __prep_end;
 extern char __pmac_begin, __pmac_end;
+extern char __apus_begin, __apus_end;
 extern char __openfirmware_begin, __openfirmware_end;
 char *klimit = _end;
 struct device_node *memory_node;
 unsigned long ioremap_base;
 unsigned long ioremap_bot;
 unsigned long avail_start;
-extern int num_memory;
-extern struct mem_info memory[NUM_MEMINFO];
-extern boot_infos_t *boot_infos;
 #ifndef __SMP__
 struct pgtable_cache_struct quicklists;
 #endif
+extern int num_memory;
+extern struct mem_info memory[];
+extern boot_infos_t *boot_infos;
 
 void MMU_init(void);
 static void *MMU_get_page(void);
@@ -388,6 +387,23 @@
 			v = (ioremap_bot -= size);
 	}
 
+#if 1
+	/* FIXME: Temporary hack to allow ptov conversions. */
+	{
+		extern unsigned long kmap_chunks[];
+		extern int kmap_chunk_count;
+
+		kmap_chunks[kmap_chunk_count++] = p;
+		kmap_chunks[kmap_chunk_count++] = size;
+		kmap_chunks[kmap_chunk_count++] = v;
+
+#if 0
+		printk ("ioremap: %08lx (%08lx) -> %08lx\n",
+			p, size, v);
+#endif
+	}
+#endif
+
 	if ((flags & _PAGE_PRESENT) == 0)
 		flags |= pgprot_val(PAGE_KERNEL);
 	if (flags & (_PAGE_NO_CACHE | _PAGE_WRITETHRU))
@@ -425,13 +441,7 @@
 	/* Check the BATs */
 	for (b = 0; b < 4; ++b)
 		if (addr >= bat_addrs[b].start && addr <= bat_addrs[b].limit)
-#ifndef CONFIG_APUS
-			return bat_addrs[b].phys | idx;
-#else
-			/* Do a more precise remapping of virtual address */
-			/* --Carsten */
 			return (bat_addrs[b].phys - bat_addrs[b].start + addr) | idx;
-#endif /* CONFIG_APUS */
 #endif /* CONFIG_8xx */
 	/* Do we have a page table? */
 	if (init_task.mm->pgd == NULL)
@@ -961,7 +971,8 @@
 {
 	unsigned long a;
 	unsigned long num_freed_pages = 0, num_prep_pages = 0,
-		num_pmac_pages = 0, num_openfirmware_pages = 0;
+		num_pmac_pages = 0, num_openfirmware_pages = 0,
+		num_apus_pages = 0;
 #define FREESEC(START,END,CNT) do { \
 	a = (unsigned long)(&START); \
 	for (; a < (unsigned long)(&END); a += PAGE_SIZE) { \
@@ -976,25 +987,33 @@
 	switch (_machine)
 	{
 	case _MACH_Pmac:
+		FREESEC(__apus_begin,__apus_end,num_apus_pages);
 		FREESEC(__prep_begin,__prep_end,num_prep_pages);
 		break;
 	case _MACH_chrp:
+		FREESEC(__apus_begin,__apus_end,num_apus_pages);
 		FREESEC(__pmac_begin,__pmac_end,num_pmac_pages);
 		FREESEC(__prep_begin,__prep_end,num_prep_pages);
 		break;
 	case _MACH_prep:
+		FREESEC(__apus_begin,__apus_end,num_apus_pages);
 		FREESEC(__pmac_begin,__pmac_end,num_pmac_pages);
 		break;
 	case _MACH_mbx:
+		FREESEC(__apus_begin,__apus_end,num_apus_pages);
+		FREESEC(__pmac_begin,__pmac_end,num_pmac_pages);
+		FREESEC(__prep_begin,__prep_end,num_prep_pages);
+		break;
+	case _MACH_apus:
 		FREESEC(__pmac_begin,__pmac_end,num_pmac_pages);
 		FREESEC(__prep_begin,__prep_end,num_prep_pages);
 		break;
 	}
-
+	
 	if ( !have_of )
 		FREESEC( __openfirmware_begin, __openfirmware_end,
 			 num_openfirmware_pages );
-	
+
 	printk ("Freeing unused kernel memory: %ldk init",
 		(num_freed_pages * PAGE_SIZE) >> 10);
 	if ( num_prep_pages )
@@ -1003,6 +1022,8 @@
 		printk(" %ldk pmac",(num_pmac_pages*PAGE_SIZE)>>10);
 	if ( num_openfirmware_pages )
 		printk(" %ldk open firmware",(num_openfirmware_pages*PAGE_SIZE)>>10);
+	if ( num_apus_pages )
+		printk(" %ldk apus",(num_apus_pages*PAGE_SIZE)>>10);
 	printk("\n");
 }
 
@@ -1067,9 +1089,6 @@
 		setbat(0, 0xfff00000, 0xfff00000, 0x00020000, RAM_PAGE);
 		/* Map chip and ZorroII memory */
 		setbat(1, zTwoBase,   0x00000000, 0x01000000, IO_PAGE);
-		/* Note: a temporary hack in arch/ppc/amiga/setup.c
-		   (kernel_map) remaps individual IO regions to
-		   0x90000000. */
 		break;
 	}
 	ioremap_bot = ioremap_base;
@@ -1412,7 +1431,6 @@
 	return (__va(total));
 }
 
-#ifdef CONFIG_APUS
 #define HARDWARE_MAPPED_SIZE (512*1024)
 __initfunc(unsigned long *apus_find_end_of_memory(void))
 {
@@ -1487,7 +1505,6 @@
 	   using the z2ram device. */
 	return __va(memory[0].addr + memory[0].size);
 }
-#endif /* CONFIG_APUS */
 
 /*
  * Initialize the hash table and patch the instructions in head.S.
@@ -1543,11 +1560,6 @@
 	       ramsize >> 20, Hash_size >> 10, Hash);
 	if ( Hash_size )
 	{
-#ifdef CONFIG_APUS
-#define b(x) ((unsigned int*)(((unsigned long)(x)) - KERNELBASE + 0xfff00000))
-#else
-#define b(x) (x)
-#endif
 		/*memset(Hash, 0, Hash_size);*/
 		__clear_user(Hash, Hash_size);
 		
@@ -1557,20 +1569,20 @@
 		 * Patch up the instructions in head.S:hash_page
 		 */
 		Hash_bits = ffz(~Hash_size) - 6;
-		*b(hash_page_patch_A) = (*b(hash_page_patch_A) & ~0xffff)
+		hash_page_patch_A[0] = (hash_page_patch_A[0] & ~0xffff)
 			| (__pa(Hash) >> 16);
-		*b(hash_page_patch_A + 1) = (*b(hash_page_patch_A + 1)& ~0x7c0)
+		hash_page_patch_A[1] = (hash_page_patch_A[1] & ~0x7c0)
 			| ((26 - Hash_bits) << 6);
 		if (Hash_bits > 16)
 			Hash_bits = 16;
-		*b(hash_page_patch_A + 2) = (*b(hash_page_patch_A + 2)& ~0x7c0)
+		hash_page_patch_A[2] = (hash_page_patch_A[2] & ~0x7c0)
 			| ((26 - Hash_bits) << 6);
-		*b(hash_page_patch_B) = (*b(hash_page_patch_B) & ~0xffff)
+		hash_page_patch_B[0] = (hash_page_patch_B[0] & ~0xffff)
 			| (Hash_mask >> 10);
-		*b(hash_page_patch_C) = (*b(hash_page_patch_C) & ~0xffff)
+		hash_page_patch_C[0] = (hash_page_patch_C[0] & ~0xffff)
 			| (Hash_mask >> 10);
 #if 0	/* see hash_page in head.S, note also patch_C ref below */
-		*b(hash_page_patch_D) = (*b(hash_page_patch_D) & ~0xffff)
+		hash_page_patch_D[0] = (hash_page_patch_D[0] & ~0xffff)
 			| (Hash_mask >> 10);
 #endif
 		/*
@@ -1578,8 +1590,8 @@
 		 * out from the data cache and invalidated in the instruction
 		 * cache, on those machines with split caches.
 		 */
-		flush_icache_range((unsigned long) b(hash_page_patch_A),
-				   (unsigned long) b(hash_page_patch_C + 1));
+		flush_icache_range((unsigned long) &hash_page_patch_A[0],
+				   (unsigned long) &hash_page_patch_C[1]);
 	}
 	else {
 		Hash_end = 0;
@@ -1588,9 +1600,9 @@
 		 * start of hash_page, since we can still get DSI
 		 * exceptions on a 603.
 		 */
-		*b(hash_page) = 0x4e800020;
-		flush_icache_range((unsigned long) b(hash_page),
-				   (unsigned long) b(hash_page + 1));
+		hash_page[0] = 0x4e800020;
+		flush_icache_range((unsigned long) &hash_page[0],
+				   (unsigned long) &hash_page[1]);
 	}
 }
 #endif /* ndef CONFIG_8xx */
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/vmlinux.lds ./arch/ppc/vmlinux.lds
--- /home/jskov/kernel/dist/linux-2.2.8/arch/ppc/vmlinux.lds	Mon Jan  4 15:15:08 1999
+++ ./arch/ppc/vmlinux.lds	Mon Jan 11 22:56:56 1999
@@ -70,7 +70,15 @@
   . = ALIGN(4096);
   __init_begin = .;
   .text.init : { *(.text.init) }
-  .data.init : { *(.data.init) }
+  .data.init : { 
+    *(.data.init);
+    __vtop_table_begin = .;
+    *(.vtop_fixup);
+    __vtop_table_end = .;
+    __ptov_table_begin = .;
+    *(.ptov_fixup);
+    __ptov_table_end = .;
+  }
   . = ALIGN(4096);
   __init_end = .;
 
@@ -87,6 +95,13 @@
   .data.prep : { *(.data.prep) }
   . = ALIGN(4096);
   __prep_end = .;
+
+  . = ALIGN(4096);
+  __apus_begin = .;
+  .text.apus : { *(.text.apus) }
+  .data.apus : { *(.data.apus) }
+  . = ALIGN(4096);
+  __apus_end = .;
 
   . = ALIGN(4096);
   __openfirmware_begin = .;
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/char/Makefile ./drivers/char/Makefile
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/char/Makefile	Tue May 11 11:26:42 1999
+++ ./drivers/char/Makefile	Sat May 15 18:55:43 1999
@@ -196,9 +196,11 @@
 L_OBJS += defkeymap.o
 endif
 
+ifndef CONFIG_APUS
 ifneq ($(ARCH),m68k)
 L_OBJS += pc_keyb.o
 endif
+endif
 
 ifdef CONFIG_Q40
 L_OBJS += q40_keyb.o
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/char/lp_m68k.c ./drivers/char/lp_m68k.c
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/char/lp_m68k.c	Tue Jan 19 11:56:05 1999
+++ ./drivers/char/lp_m68k.c	Fri Feb  5 20:42:53 1999
@@ -45,6 +45,10 @@
 #include <linux/init.h>
 #include <linux/kmod.h>
 
+#ifdef CONFIG_APUS
+#define m68k_debug_device debug_device
+#endif
+
 #ifdef CONFIG_AMIGA
 #ifdef CONFIG_MULTIFACE_III_LP
 #include <linux/lp_mfc.h>
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/char/ser_ioext.c ./drivers/char/ser_ioext.c
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/char/ser_ioext.c	Fri Apr 23 17:27:53 1999
+++ ./drivers/char/ser_ioext.c	Sat May 15 11:35:25 1999
@@ -776,6 +776,7 @@
 {
     /* Wait for the uart to get empty */
     while (!(uart->LSR & TEMT)) {
+	    mb();
 #if IOEXT_DEBUG
 	printk("Waiting for transmitter to finish\n");
 #endif
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/net/8390.c ./drivers/net/8390.c
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/net/8390.c	Tue May 11 11:26:58 1999
+++ ./drivers/net/8390.c	Sun May 16 10:39:37 1999
@@ -256,8 +256,12 @@
 		spin_unlock_irqrestore(&ei_local->page_lock, flags);
 
 		/* Ugly but a reset can be slow, yet must be protected */
-		
+#if	0 /* FIXME:APUS: */
 		disable_irq_nosync(dev->irq);
+#else
+		disable_irq(dev->irq);
+		synchronize_irq();
+#endif
 		spin_lock(&ei_local->page_lock);
 		
 		/* Try to restart the card.  Perhaps the user has fixed something. */
@@ -285,7 +289,12 @@
 	 *	Slow phase with lock held.
 	 */
 	 
-	disable_irq_nosync(dev->irq);
+#if	0 /* FIXME:APUS: */
+		disable_irq_nosync(dev->irq);
+#else
+		disable_irq(dev->irq);
+		synchronize_irq();
+#endif
 	
 	spin_lock(&ei_local->page_lock);
 	
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/net/Config.in ./drivers/net/Config.in
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/net/Config.in	Wed Mar 24 11:31:05 1999
+++ ./drivers/net/Config.in	Sat May 15 11:35:29 1999
@@ -41,6 +41,9 @@
     tristate 'A2065 support' CONFIG_A2065
     tristate 'Hydra support' CONFIG_HYDRA
   fi
+  if [ "$CONFIG_AMIGA_PCMCIA" = "y" ]; then
+    tristate 'PCMCIA NE2000 support' CONFIG_APNE
+  fi
   if [ "$CONFIG_MIPS_JAZZ" = "y" ]; then
     bool 'MIPS JAZZ onboard SONIC Ethernet support' CONFIG_MIPS_JAZZ_SONIC
   fi
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/net/slhc.c ./drivers/net/slhc.c
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/net/slhc.c	Mon Jan  4 11:30:51 1999
+++ ./drivers/net/slhc.c	Sun May 16 20:55:44 1999
@@ -518,7 +518,7 @@
 		x = *cp++;	/* Read conn index */
 		if(x < 0 || x > comp->rslot_limit)
 			goto bad;
-
+		if (comp->rstate[x].cs_hsize==0) goto bad;    /* header lost */
 		comp->flags &=~ SLF_TOSS;
 		comp->recv_current = x;
 	} else {
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/scsi/Config.in ./drivers/scsi/Config.in
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/scsi/Config.in	Tue May 11 11:27:19 1999
+++ ./drivers/scsi/Config.in	Sat May 15 11:35:36 1999
@@ -18,6 +18,73 @@
 mainmenu_option next_comment
 comment 'SCSI low-level drivers'
 
+# Default is to ask for all drivers. This may be disabled in the below
+# code handling specific platforms.
+define_bool CONFIG_SCSI_ALL y
+
+if [ "$CONFIG_AMIGA" = "y" ]; then
+  define_bool CONFIG_SCSI_ALL n
+
+  dep_tristate 'A3000 WD33C93A support' CONFIG_A3000_SCSI $CONFIG_SCSI
+  if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
+    bool 'A4000T SCSI support' CONFIG_A4000T_SCSI
+  fi
+fi
+if [ "$CONFIG_ZORRO" = "y" ]; then
+  define_bool CONFIG_SCSI_ALL n
+
+  dep_tristate 'A2091 WD33C93A support' CONFIG_A2091_SCSI $CONFIG_SCSI
+  dep_tristate 'GVP Series II WD33C93A support' CONFIG_GVP11_SCSI $CONFIG_SCSI
+  dep_tristate 'CyberStorm SCSI support' CONFIG_CYBERSTORM_SCSI $CONFIG_SCSI
+  dep_tristate 'CyberStorm Mk II SCSI support' CONFIG_CYBERSTORMII_SCSI $CONFIG_SCSI
+  dep_tristate 'Blizzard 2060 SCSI support' CONFIG_BLZ2060_SCSI $CONFIG_SCSI
+  dep_tristate 'Blizzard 1230IV/1260 SCSI support' CONFIG_BLZ1230_SCSI $CONFIG_SCSI
+  dep_tristate 'Fastlane SCSI support' CONFIG_FASTLANE_SCSI $CONFIG_SCSI
+  if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
+    bool 'A4091 SCSI support' CONFIG_A4091_SCSI
+    bool 'WarpEngine SCSI support' CONFIG_WARPENGINE_SCSI
+    bool 'Blizzard PowerUP 603e+ SCSI' CONFIG_BLZ603EPLUS_SCSI
+    dep_tristate 'BSC Oktagon SCSI support' CONFIG_OKTAGON_SCSI $CONFIG_SCSI
+#    bool 'Cyberstorm Mk III SCSI support' CONFIG_CYBERSTORMIII_SCSI
+#    bool 'GVP Turbo 040/060 SCSI support' CONFIG_GVP_TURBO_SCSI
+  fi
+fi
+
+if [ "$CONFIG_ATARI" = "y" ]; then
+  define_bool CONFIG_SCSI_ALL n
+
+  dep_tristate 'Atari native SCSI support' CONFIG_ATARI_SCSI $CONFIG_SCSI
+  if [ "$CONFIG_ATARI_SCSI" != "n" ]; then
+    bool '  Long delays for Toshiba CD-ROMs' CONFIG_ATARI_SCSI_TOSHIBA_DELAY
+    bool '  Reset SCSI-devices at boottime' CONFIG_ATARI_SCSI_RESET_BOOT
+    if [ "$CONFIG_EXPERIMENTAL" = "y" -a "$CONFIG_HADES" = "y" ]; then
+      bool '  Hades SCSI DMA emulator (EXPERIMENTAL)' CONFIG_TT_DMA_EMUL
+    fi
+  fi
+fi
+
+if [ "$CONFIG_MAC" = "y" ]; then
+  define_bool CONFIG_SCSI_ALL n
+
+  bool 'MAC NCR5380 SCSI' CONFIG_MAC_SCSI
+  dep_tristate 'MAC NCR53c9[46] SCSI' CONFIG_SCSI_MAC_ESP $CONFIG_SCSI
+fi
+
+if [ "$CONFIG_VME" = "y" -a "$CONFIG_MVME16x" = "y" ]; then
+  define_bool CONFIG_SCSI_ALL n
+
+  bool 'NCR53C710 SCSI driver for MVME16x' CONFIG_MVME16x_SCSI
+fi
+
+if [ "$CONFIG_VME" = "y" -a "$CONFIG_BVME6000" = "y" ]; then
+  define_bool CONFIG_SCSI_ALL n
+
+  bool 'NCR53C710 SCSI driver for BVME6000' CONFIG_BVME6000_SCSI
+fi
+
+# Generic SCSI
+if [ "CONFIG_SCSI_ALL" = "y" ];then
+
 dep_tristate '7000FASST SCSI support' CONFIG_SCSI_7000FASST $CONFIG_SCSI
 dep_tristate 'ACARD SCSI support' CONFIG_SCSI_ACARD $CONFIG_SCSI
 dep_tristate 'Adaptec AHA152X/2825 support' CONFIG_SCSI_AHA152X $CONFIG_SCSI
@@ -140,6 +207,7 @@
     int  '  maximum number of queued commands' CONFIG_SCSI_U14_34F_MAX_TAGS 8
   fi
 dep_tristate 'UltraStor SCSI support' CONFIG_SCSI_ULTRASTOR $CONFIG_SCSI
+fi # CONFIG_SCSI_ALL
 #
 # Note - this is a very special 'host' adapter that simulates the presence of some disks.
 # It can come in very handy for troubleshooting.  Anyone else is welcome to use it - all
@@ -151,7 +219,7 @@
 if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
   dep_tristate 'SCSI debugging host adapter' CONFIG_SCSI_DEBUG $CONFIG_SCSI
 fi
-if [ "$CONFIG_PPC" = "y" ]; then
+if [ "$CONFIG_PMAC" = "y" ]; then
   dep_tristate 'MESH (Power Mac internal SCSI) support' CONFIG_SCSI_MESH $CONFIG_SCSI
   if [ "$CONFIG_SCSI_MESH" != "n" ]; then
     int '  maximum synchronous transfer rate (MB/s) (0 = async)' CONFIG_SCSI_MESH_SYNC_RATE 5
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/scsi/a2091.c ./drivers/scsi/a2091.c
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/scsi/a2091.c	Tue May 11 11:02:46 1999
+++ ./drivers/scsi/a2091.c	Sun May 16 20:49:27 1999
@@ -53,6 +53,7 @@
     unsigned short cntr = CNTR_PDMD | CNTR_INTEN;
     unsigned long addr = virt_to_bus(cmd->SCp.ptr);
     struct Scsi_Host *instance = cmd->host;
+    static int scsi_alloc_out_of_range = 0;
 
     /* don't allow DMA if the physical address is bad */
     if (addr & A2091_XFER_MASK ||
@@ -60,41 +61,55 @@
     {
 	HDATA(instance)->dma_bounce_len = (cmd->SCp.this_residual + 511)
 	    & ~0x1ff;
-	HDATA(instance)->dma_bounce_buffer =
-	    scsi_malloc (HDATA(instance)->dma_bounce_len);
-	
-	/* can't allocate memory; use PIO */
-	if (!HDATA(instance)->dma_bounce_buffer) {
-	    HDATA(instance)->dma_bounce_len = 0;
-	    return 1;
+ 	if( !scsi_alloc_out_of_range ) {
+	    HDATA(cmd->host)->dma_bounce_buffer =
+		scsi_malloc (HDATA(cmd->host)->dma_bounce_len);
+	    HDATA(cmd->host)->dma_buffer_pool = BUF_SCSI_ALLOCED;
 	}
 
-	/* get the physical address of the bounce buffer */
-	addr = virt_to_bus(HDATA(instance)->dma_bounce_buffer);
+	if ( scsi_alloc_out_of_range || !HDATA(cmd->host)->dma_bounce_buffer) {
+	    HDATA(cmd->host)->dma_bounce_buffer =
+		amiga_chip_alloc(HDATA(cmd->host)->dma_bounce_len);
+
+	    if(!HDATA(cmd->host)->dma_bounce_buffer)
+	    {
+		HDATA(cmd->host)->dma_bounce_len = 0;
+		return 1;
+	    }
 
-	/* the bounce buffer may not be in the first 16M of physmem */
-	if (addr & A2091_XFER_MASK) {
-	    /* we could use chipmem... maybe later */
-	    scsi_free (HDATA(instance)->dma_bounce_buffer,
-		       HDATA(instance)->dma_bounce_len);
-	    HDATA(instance)->dma_bounce_buffer = NULL;
-	    HDATA(instance)->dma_bounce_len = 0;
-	    return 1;
+	    HDATA(cmd->host)->dma_buffer_pool = BUF_CHIP_ALLOCED;
 	}
 
+	/* check if the address of the bounce buffer is OK */
+	addr = virt_to_bus(HDATA(cmd->host)->dma_bounce_buffer);
+
+	if (addr & A2091_XFER_MASK) {
+	    /* fall back to Chip RAM if address out of range */
+	    if( HDATA(cmd->host)->dma_buffer_pool == BUF_SCSI_ALLOCED) {
+		scsi_free (HDATA(cmd->host)->dma_bounce_buffer,
+			   HDATA(cmd->host)->dma_bounce_len);
+		scsi_alloc_out_of_range = 1;
+	    } else {
+		amiga_chip_free (HDATA(cmd->host)->dma_bounce_buffer);
+            }
+		
+	    HDATA(cmd->host)->dma_bounce_buffer =
+		amiga_chip_alloc(HDATA(cmd->host)->dma_bounce_len);
+
+	    if(!HDATA(cmd->host)->dma_bounce_buffer)
+	    {
+		HDATA(cmd->host)->dma_bounce_len = 0;
+		return 1;
+	    }
+
+	    addr = virt_to_bus(HDATA(cmd->host)->dma_bounce_buffer);
+	    HDATA(cmd->host)->dma_buffer_pool = BUF_CHIP_ALLOCED;
+	}
+	    
 	if (!dir_in) {
 	    /* copy to bounce buffer for a write */
-	    if (cmd->use_sg)
-#if 0
-		panic ("scsi%ddma: incomplete s/g support",
-		       instance->host_no);
-#else
-		memcpy (HDATA(instance)->dma_bounce_buffer,
-			cmd->SCp.ptr, cmd->SCp.this_residual);
-#endif
-	    else
-		memcpy (HDATA(instance)->dma_bounce_buffer,
-			cmd->request_buffer, cmd->request_bufflen);
+	    memcpy (HDATA(cmd->host)->dma_bounce_buffer,
+		    cmd->SCp.ptr, cmd->SCp.this_residual);
 	}
     }
 
@@ -118,7 +133,9 @@
 	cache_push (addr, cmd->SCp.this_residual);
       }
     /* start DMA */
+    mb();			/* make sure setup is completed */
     DMA(cmd->host)->ST_DMA = 1;
+    mb();			/* make sure DMA has started before next IO */
 
     /* return success */
     return 0;
@@ -135,12 +152,15 @@
 
     /* disable SCSI interrupts */
     DMA(instance)->CNTR = cntr;
+    mb();			/* make sure CNTR is updated before next IO */
 
     /* flush if we were reading */
     if (HDATA(instance)->dma_dir) {
 	DMA(instance)->FLUSH = 1;
+	mb();			/* don't allow prefetch */
 	while (!(DMA(instance)->ISTR & ISTR_FE_FLG))
-	    ;
+	    barrier();
+	mb();			/* no IO until FLUSH is done */
     }
 
     /* clear a possible interrupt */
@@ -148,38 +168,27 @@
 
     /* stop DMA */
     DMA(instance)->SP_DMA = 1;
+    mb();			/* make sure DMA is stopped before next IO */
 
     /* restore the CONTROL bits (minus the direction flag) */
     DMA(instance)->CNTR = CNTR_PDMD | CNTR_INTEN;
+    mb();			/* make sure CNTR is updated before next IO */
 
     /* copy from a bounce buffer, if necessary */
     if (status && HDATA(instance)->dma_bounce_buffer) {
-	if (SCpnt && SCpnt->use_sg) {
-#if 0
-	    panic ("scsi%d: incomplete s/g support",
-		   instance->host_no);
-#else
-	    if( HDATA(instance)->dma_dir )
-		memcpy (SCpnt->SCp.ptr, 
-			HDATA(instance)->dma_bounce_buffer,
-			SCpnt->SCp.this_residual);
-	    scsi_free (HDATA(instance)->dma_bounce_buffer,
-		       HDATA(instance)->dma_bounce_len);
-	    HDATA(instance)->dma_bounce_buffer = NULL;
-	    HDATA(instance)->dma_bounce_len = 0;
-	    
-#endif
-	} else {
-	    if (HDATA(instance)->dma_dir && SCpnt)
-		memcpy (SCpnt->request_buffer,
-			HDATA(instance)->dma_bounce_buffer,
-			SCpnt->request_bufflen);
-
+	if (HDATA(instance)->dma_dir && SCpnt)
+	    memcpy (SCpnt->SCp.ptr, 
+		    HDATA(instance)->dma_bounce_buffer,
+		    SCpnt->SCp.this_residual);
+	
+	if (HDATA(instance)->dma_buffer_pool == BUF_SCSI_ALLOCED)
 	    scsi_free (HDATA(instance)->dma_bounce_buffer,
 		       HDATA(instance)->dma_bounce_len);
-	    HDATA(instance)->dma_bounce_buffer = NULL;
-	    HDATA(instance)->dma_bounce_len = 0;
-	}
+	else
+	    amiga_chip_free(HDATA(instance)->dma_bounce_buffer);
+	
+	HDATA(instance)->dma_bounce_buffer = NULL;
+	HDATA(instance)->dma_bounce_len = 0;
     }
 }
 
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/scsi/a3000.c ./drivers/scsi/a3000.c
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/scsi/a3000.c	Tue Sep  1 18:56:07 1998
+++ ./drivers/scsi/a3000.c	Tue Mar 23 21:32:27 1999
@@ -32,7 +32,7 @@
 
 static void a3000_intr (int irq, void *dummy, struct pt_regs *fp)
 {
-    unsigned int status = DMA(a3000_host)->ISTR;
+    unsigned short status = DMA(a3000_host)->ISTR;
 
     if (!(status & ISTR_INT_P))
 	return;
@@ -102,7 +102,9 @@
 	cache_push (addr, cmd->SCp.this_residual);
 
     /* start DMA */
+    mb();			/* make sure setup is completed */
     DMA(a3000_host)->ST_DMA = 1;
+    mb();			/* make sure DMA has started before next IO */
 
     /* return success */
     return 0;
@@ -118,12 +120,15 @@
 	cntr |= CNTR_DDIR;
 
     DMA(instance)->CNTR = cntr;
+    mb();			/* make sure CNTR is updated before next IO */
 
     /* flush if we were reading */
     if (HDATA(instance)->dma_dir) {
 	DMA(instance)->FLUSH = 1;
+	mb();			/* don't allow prefetch */
 	while (!(DMA(instance)->ISTR & ISTR_FE_FLG))
-	    ;
+	    barrier();
+	mb();			/* no IO until FLUSH is done */
     }
 
     /* clear a possible interrupt */
@@ -134,9 +139,11 @@
 
     /* stop DMA */
     DMA(instance)->SP_DMA = 1;
+    mb();			/* make sure DMA is stopped before next IO */
 
     /* restore the CONTROL bits (minus the direction flag) */
     DMA(instance)->CNTR = CNTR_PDMD | CNTR_INTEN;
+    mb();			/* make sure CNTR is updated before next IO */
 
     /* copy from a bounce buffer, if necessary */
     if (status && HDATA(instance)->dma_bounce_buffer) {
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/scsi/gvp11.c ./drivers/scsi/gvp11.c
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/scsi/gvp11.c	Wed May 12 10:03:07 1999
+++ ./drivers/scsi/gvp11.c	Sat May 15 11:35:36 1999
@@ -127,6 +127,7 @@
 
     HDATA(cmd->host)->dma_dir = dir_in;
     DMA(cmd->host)->CNTR = cntr;
+    mb();			/* make sure CNTR is updated before next IO */
 
     /* setup DMA *physical* address */
     DMA(cmd->host)->ACR = addr;
@@ -142,7 +143,9 @@
 	    DMA(cmd->host)->BANK = bank_mask & (addr >> 18);
 
     /* start DMA */
+    mb();			/* make sure setup is completed */
     DMA(cmd->host)->ST_DMA = 1;
+    mb();			/* make sure DMA has started before next IO */
 
     /* return success */
     return 0;
@@ -155,6 +158,7 @@
     DMA(instance)->SP_DMA = 1;
     /* remove write bit from CONTROL bits */
     DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE;
+    mb();			/* make sure CNTR is updated before next IO */
 
     /* copy from a bounce buffer, if necessary */
     if (status && HDATA(instance)->dma_bounce_buffer) {
@@ -316,9 +320,14 @@
 
 
 	DMA(instance)->secret2 = 1;
+	mb();			/* ensure IO order */
 	DMA(instance)->secret1 = 0;
+	mb();			/* ensure IO order */
 	DMA(instance)->secret3 = 15;
-	while (DMA(instance)->CNTR & GVP11_DMAC_BUSY) ;
+	mb();			/* ensure IO order */
+	while (DMA(instance)->CNTR & GVP11_DMAC_BUSY)
+		barrier();
+	mb();			/* ensure IO order */
 	DMA(instance)->CNTR = 0;
 
 	DMA(instance)->BANK = 0;
@@ -341,6 +350,7 @@
 		request_irq(IRQ_AMIGA_PORTS, gvp11_intr, 0,
 			    "GVP11 SCSI", gvp11_intr);
 	}
+	mb();			/* ensure IO order */
 	DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE;
 	zorro_config_board(key, 0);
     }
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/scsi/sd.c ./drivers/scsi/sd.c
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/scsi/sd.c	Tue May 11 11:27:33 1999
+++ ./drivers/scsi/sd.c	Sat May 15 11:35:38 1999
@@ -68,13 +68,13 @@
 #define N_USED_SCSI_DISKS  (sd_template.dev_max + SCSI_DISKS_PER_MAJOR - 1)
 #define N_USED_SD_MAJORS   (N_USED_SCSI_DISKS / SCSI_DISKS_PER_MAJOR)
 
-#define MAX_RETRIES 5
+#define MAX_RETRIES 100
 
 /*
  *  Time out in seconds for disks and Magneto-opticals (which are slower).
  */
 
-#define SD_TIMEOUT (15 * HZ)
+#define SD_TIMEOUT (50 * HZ)
 #define SD_MOD_TIMEOUT (75 * HZ)
 
 #define CLUSTERABLE_DEVICE(SC) (SC->host->use_clustering && \
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/sound/dmasound.c ./drivers/sound/dmasound.c
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/sound/dmasound.c	Fri Mar 26 11:54:46 1999
+++ ./drivers/sound/dmasound.c	Sat May 15 11:35:41 1999
@@ -107,7 +107,7 @@
 #include <asm/amigahw.h>
 #include <asm/amigaints.h>
 #endif /* CONFIG_AMIGA */
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 #include <asm/prom.h>
 #include <asm/io.h>
 #include <asm/dbdma.h>
@@ -117,7 +117,7 @@
 #include "awacs_defs.h"
 #include <linux/nvram.h>
 #include <linux/vt_kern.h>
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 
 #include "dmasound.h"
 #include <linux/soundcard.h>
@@ -164,7 +164,7 @@
 
 #endif /* CONFIG_AMIGA */
 
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 /*
  * Interrupt numbers and addresses, obtained from the device tree.
  */
@@ -261,7 +261,7 @@
 };
 #endif /* CONFIG_PMAC_PBOOK */
 
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 
 /*** Some declarations *******************************************************/
 
@@ -599,7 +599,7 @@
 			    ssize_t frameLeft);
 #endif /* CONFIG_AMIGA */
 
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 static ssize_t pmac_ct_law(const u_char *userPtr, size_t userCount,
 			   u_char frame[], ssize_t *frameUsed,
 			   ssize_t frameLeft);
@@ -630,7 +630,7 @@
 static ssize_t pmac_ctx_u16(const u_char *userPtr, size_t userCount,
 			    u_char frame[], ssize_t *frameUsed,
 			    ssize_t frameLeft);
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 
 /*** Machine definitions *****************************************************/
 
@@ -687,7 +687,7 @@
 	int treble;
 	int gain;
 	int minDev;		/* minor device number currently open */
-#if defined(CONFIG_ATARI) || defined(CONFIG_PPC)
+#if defined(CONFIG_ATARI) || defined(CONFIG_PMAC)
 	int bal;		/* balance factor for expanding (not volume!) */
 	u_long data;		/* data for expanding */
 #endif /* CONFIG_ATARI */
@@ -736,7 +736,7 @@
 static void ami_sq_interrupt(int irq, void *dummy, struct pt_regs *fp);
 #endif /* CONFIG_AMIGA */
 
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 static void *PMacAlloc(unsigned int size, int flags);
 static void PMacFree(void *ptr, unsigned int size);
 static int PMacIrqInit(void);
@@ -755,7 +755,7 @@
 static int awacs_volume_setter(int volume, int n, int mute, int lshift);
 static void awacs_mksound(unsigned int hz, unsigned int ticks);
 static void awacs_nosound(unsigned long xx);
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 
 /*** Mid level stuff *********************************************************/
 
@@ -1789,7 +1789,7 @@
 }
 #endif /* CONFIG_AMIGA */
 
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 static ssize_t pmac_ct_law(const u_char *userPtr, size_t userCount,
 			   u_char frame[], ssize_t *frameUsed,
 			   ssize_t frameLeft)
@@ -2171,7 +2171,7 @@
 	return stereo? utotal * 4: utotal * 2;
 }
 
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 
 
 #ifdef CONFIG_ATARI
@@ -2201,7 +2201,7 @@
 };
 #endif /* CONFIG_AMIGA */
 
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 static TRANS transAwacsNormal = {
 	pmac_ct_law, pmac_ct_law, pmac_ct_s8, pmac_ct_u8,
 	pmac_ct_s16, pmac_ct_u16, pmac_ct_s16, pmac_ct_u16
@@ -2211,7 +2211,7 @@
 	pmac_ctx_law, pmac_ctx_law, pmac_ctx_s8, pmac_ctx_u8,
 	pmac_ctx_s16, pmac_ctx_u16, pmac_ctx_s16, pmac_ctx_u16
 };
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 
 /*** Low level stuff *********************************************************/
 
@@ -2981,7 +2981,7 @@
 }
 #endif /* CONFIG_AMIGA */
 
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 
 /*
  * PCI PowerMac, with AWACS and DBDMA.
@@ -3609,7 +3609,7 @@
 	while (!req.complete) cuda_poll();
 }
 
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 
 /*** Machine definitions *****************************************************/
 
@@ -3648,7 +3648,7 @@
 };
 #endif /* CONFIG_AMIGA */
 
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 static MACHINE machPMac = {
 	DMASND_AWACS, PMacAlloc, PMacFree, PMacIrqInit,
 #ifdef MODULE
@@ -3949,7 +3949,7 @@
 		break;
 #endif /* CONFIG_AMIGA */
 
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 	case DMASND_AWACS:
 		if (awacs_revision<AWACS_BURGUNDY) { /* Different IOCTLS for burgundy*/
 			switch (cmd) {
@@ -4297,10 +4297,10 @@
 
 static void sq_setup(int numBufs, int bufSize, char **buffers)
 {
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 	int i;
 	volatile struct dbdma_cmd *cp;
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 
 	sq.max_count = numBufs;
 	sq.max_active = numBufs;
@@ -4319,7 +4319,7 @@
 	sq.block_size_half = sq.block_size>>1;
 	sq.block_size_quarter = sq.block_size_half>>1;
 #endif /* CONFIG_AMIGA */
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 	cp = awacs_tx_cmds;
 	memset((void *) cp, 0, (numBufs + 1) * sizeof(struct dbdma_cmd));
 	for (i = 0; i < numBufs; ++i, ++cp) {
@@ -4329,7 +4329,7 @@
 	st_le32(&cp->cmd_dep, virt_to_bus(awacs_tx_cmds));
 	out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16);
 	out_le32(&awacs_txdma->cmdptr, virt_to_bus(awacs_tx_cmds));
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 }
 
 static void sq_play(void)
@@ -4649,11 +4649,11 @@
 		sound.dsp.speed = 8000;
 		break;
 #endif /* CONFIG_AMIGA */
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 	case DMASND_AWACS:
 		sound.dsp.speed = 8000;
 		break;
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 	}
 
 	/* before the first open to /dev/dsp this wouldn't be set */
@@ -4694,11 +4694,11 @@
 		mach = "Amiga ";
 		break;
 #endif /* CONFIG_AMIGA */
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 	case DMASND_AWACS:
 		sprintf(mach, "PowerMac (AWACS rev %d) ", awacs_revision);
 		break;
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 	}
 	len += sprintf(buffer+len, "%sDMA sound driver:\n", mach);
 
@@ -4838,7 +4838,7 @@
 void __init dmasound_init(void)
 {
 	int has_sound = 0;
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 	struct device_node *np;
 #endif
 
@@ -4872,7 +4872,7 @@
 	}
 #endif /* __mc68000__||CONFIG_APUS */
 
-#ifdef CONFIG_PPC
+#ifdef CONFIG_PMAC
 	awacs_subframe = 0;
 	awacs_revision = 0;
 	np = find_devices("awacs");
@@ -4951,7 +4951,7 @@
 					&awacs_sleep_notifier);
 #endif /* CONFIG_PMAC_PBOOK */
 	}
-#endif /* CONFIG_PPC */
+#endif /* CONFIG_PMAC */
 
 	if (!has_sound)
 		return;
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/drivers/video/cyberfb.c ./drivers/video/cyberfb.c
--- /home/jskov/kernel/dist/linux-2.2.8/drivers/video/cyberfb.c	Sun Mar 28 17:54:33 1999
+++ ./drivers/video/cyberfb.c	Sat May 15 11:35:43 1999
@@ -905,7 +905,7 @@
 	cyberfb_get_fix(&fix, con, info);
 	if (con == -1)
 		con = 0;
-	display->screen_base = (unsigned char *)CyberMem;
+	display->screen_base = (char*) CyberMem;
 	display->visual = fix.visual;
 	display->type = fix.type;
 	display->type_aux = fix.type_aux;
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/fs/Config.in ./fs/Config.in
--- /home/jskov/kernel/dist/linux-2.2.8/fs/Config.in	Thu Jan 21 12:10:37 1999
+++ ./fs/Config.in	Fri Feb  5 21:36:32 1999
@@ -135,9 +135,13 @@
     if [ "$CONFIG_PREP" = "y" -o "$CONFIG_CHRP" = "y" ]; then
       define_bool CONFIG_MSDOS_PARTITION y
     fi
+    if [ "$CONFIG_APUS" = "y" ]; then
+      define_bool CONFIG_AMIGA_PARTITION y
+    fi
   else
     define_bool CONFIG_MAC_PARTITION y
     define_bool CONFIG_MSDOS_PARTITION y
+    define_bool CONFIG_AMIGA_PARTITION y
   fi
 fi
 bool 'Support for foreign partition tables' CONFIG_FOREIGN_PARTITIONS
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-m68k/ide.h ./include/asm-m68k/ide.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-m68k/ide.h	Fri Apr 23 17:28:02 1999
+++ ./include/asm-m68k/ide.h	Sat May 15 20:34:06 1999
@@ -177,7 +177,7 @@
 #endif
 #endif
 
-
+#ifndef CONFIG_APUS
 #define insl(data_reg, buffer, wcount) insw(data_reg, buffer, (wcount)<<1)
 #define outsl(data_reg, buffer, wcount) outsw(data_reg, buffer, (wcount)<<1)
 
@@ -377,6 +377,7 @@
 		: "d0", "a0", "a1", "d6")
 
 #endif /* CONFIG_ATARI */
+#endif /* CONFIG_APUS */
 
 #define T_CHAR          (0x0000)        /* char:  don't touch  */
 #define T_SHORT         (0x4000)        /* short: 12 -> 21     */
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-m68k/traps.h ./include/asm-m68k/traps.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-m68k/traps.h	Mon Jan 11 14:20:40 1999
+++ ./include/asm-m68k/traps.h	Sun May 16 10:14:46 1999
@@ -13,6 +13,8 @@
 
 #ifndef __ASSEMBLY__
 
+#include <asm/ptrace.h>
+
 typedef void (*e_vector)(void);
 
 extern e_vector vectors[];
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/amigahw.h ./include/asm-ppc/amigahw.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/amigahw.h	Fri Aug  7 15:56:15 1998
+++ ./include/asm-ppc/amigahw.h	Sun Nov 22 12:57:55 1998
@@ -1 +1,339 @@
-#include <asm-m68k/amigahw.h>
+/*
+** asm-m68k/amigahw.h -- This header defines some macros and pointers for
+**                    the various Amiga custom hardware registers.
+**                    The naming conventions used here conform to those
+**                    used in the Amiga Hardware Reference Manual, 3rd Edition
+**
+** Copyright 1992 by Greg Harp
+**
+** This file is subject to the terms and conditions of the GNU General Public
+** License.  See the file COPYING in the main directory of this archive
+** for more details.
+**
+** Created: 9/24/92 by Greg Harp
+*/
+
+#ifndef _M68K_AMIGAHW_H
+#define _M68K_AMIGAHW_H
+
+    /*
+     *  Different Amiga models
+     */
+
+extern unsigned long amiga_model;
+
+#define AMI_UNKNOWN	(0)
+#define AMI_500		(1)
+#define AMI_500PLUS	(2)
+#define AMI_600		(3)
+#define AMI_1000	(4)
+#define AMI_1200	(5)
+#define AMI_2000	(6)
+#define AMI_2500	(7)
+#define AMI_3000	(8)
+#define AMI_3000T	(9)
+#define AMI_3000PLUS	(10)
+#define AMI_4000	(11)
+#define AMI_4000T	(12)
+#define AMI_CDTV	(13)
+#define AMI_CD32	(14)
+#define AMI_DRACO	(15)
+
+
+    /*
+     *  Chipsets
+     */
+
+extern unsigned long amiga_chipset;
+
+#define CS_STONEAGE	(0)
+#define CS_OCS		(1)
+#define CS_ECS		(2)
+#define CS_AGA		(3)
+
+
+    /*
+     *  Miscellaneous
+     */
+
+extern unsigned long amiga_eclock;	/* 700 kHz E Peripheral Clock */
+extern unsigned long amiga_masterclock;	/* 28 MHz Master Clock */
+extern unsigned long amiga_colorclock;	/* 3.5 MHz Color Clock */
+extern unsigned long amiga_chip_size;	/* Chip RAM Size (bytes) */
+extern unsigned char amiga_vblank;	/* VBLANK Frequency */
+extern unsigned char amiga_psfreq;	/* Power Supply Frequency */
+
+
+#define AMIGAHW_DECLARE(name)	unsigned name : 1
+#define AMIGAHW_SET(name)	(amiga_hw_present.name = 1)
+#define AMIGAHW_PRESENT(name)	(amiga_hw_present.name)
+
+struct amiga_hw_present {
+    /* video hardware */
+    AMIGAHW_DECLARE(AMI_VIDEO);		/* Amiga Video */
+    AMIGAHW_DECLARE(AMI_BLITTER);	/* Amiga Blitter */
+    AMIGAHW_DECLARE(AMBER_FF);		/* Amber Flicker Fixer */
+    /* sound hardware */
+    AMIGAHW_DECLARE(AMI_AUDIO);		/* Amiga Audio */
+    /* disk storage interfaces */
+    AMIGAHW_DECLARE(AMI_FLOPPY);	/* Amiga Floppy */
+    AMIGAHW_DECLARE(A3000_SCSI);	/* SCSI (wd33c93, A3000 alike) */
+    AMIGAHW_DECLARE(A4000_SCSI);	/* SCSI (ncr53c710, A4000T alike) */
+    AMIGAHW_DECLARE(A1200_IDE);		/* IDE (A1200 alike) */
+    AMIGAHW_DECLARE(A4000_IDE);		/* IDE (A4000 alike) */
+    AMIGAHW_DECLARE(CD_ROM);		/* CD ROM drive */
+    /* other I/O hardware */
+    AMIGAHW_DECLARE(AMI_KEYBOARD);	/* Amiga Keyboard */
+    AMIGAHW_DECLARE(AMI_MOUSE);		/* Amiga Mouse */
+    AMIGAHW_DECLARE(AMI_SERIAL);	/* Amiga Serial */
+    AMIGAHW_DECLARE(AMI_PARALLEL);	/* Amiga Parallel */
+    /* real time clocks */
+    AMIGAHW_DECLARE(A2000_CLK);		/* Hardware Clock (A2000 alike) */
+    AMIGAHW_DECLARE(A3000_CLK);		/* Hardware Clock (A3000 alike) */
+    /* supporting hardware */
+    AMIGAHW_DECLARE(CHIP_RAM);		/* Chip RAM */
+    AMIGAHW_DECLARE(PAULA);		/* Paula (8364) */
+    AMIGAHW_DECLARE(DENISE);		/* Denise (8362) */
+    AMIGAHW_DECLARE(DENISE_HR);		/* Denise (8373) */
+    AMIGAHW_DECLARE(LISA);		/* Lisa (8375) */
+    AMIGAHW_DECLARE(AGNUS_PAL);		/* Normal/Fat PAL Agnus (8367/8371) */
+    AMIGAHW_DECLARE(AGNUS_NTSC);	/* Normal/Fat NTSC Agnus (8361/8370) */
+    AMIGAHW_DECLARE(AGNUS_HR_PAL);	/* Fat Hires PAL Agnus (8372) */
+    AMIGAHW_DECLARE(AGNUS_HR_NTSC);	/* Fat Hires NTSC Agnus (8372) */
+    AMIGAHW_DECLARE(ALICE_PAL);		/* PAL Alice (8374) */
+    AMIGAHW_DECLARE(ALICE_NTSC);	/* NTSC Alice (8374) */
+    AMIGAHW_DECLARE(MAGIC_REKICK);	/* A3000 Magic Hard Rekick */
+    AMIGAHW_DECLARE(PCMCIA);		/* PCMCIA Slot */
+    AMIGAHW_DECLARE(ZORRO);		/* Zorro AutoConfig */
+    AMIGAHW_DECLARE(ZORRO3);		/* Zorro III */
+};
+
+extern struct amiga_hw_present amiga_hw_present;
+
+struct CUSTOM {
+    unsigned short bltddat;
+    unsigned short dmaconr;
+    unsigned short vposr;
+    unsigned short vhposr;
+    unsigned short dskdatr;
+    unsigned short joy0dat;
+    unsigned short joy1dat;
+    unsigned short clxdat;
+    unsigned short adkconr;
+    unsigned short pot0dat;
+    unsigned short pot1dat;
+    unsigned short potgor;
+    unsigned short serdatr;
+    unsigned short dskbytr;
+    unsigned short intenar;
+    unsigned short intreqr;
+    unsigned char  *dskptr;
+    unsigned short dsklen;
+    unsigned short dskdat;
+    unsigned short refptr;
+    unsigned short vposw;
+    unsigned short vhposw;
+    unsigned short copcon;
+    unsigned short serdat;
+    unsigned short serper;
+    unsigned short potgo;
+    unsigned short joytest;
+    unsigned short strequ;
+    unsigned short strvbl;
+    unsigned short strhor;
+    unsigned short strlong;
+    unsigned short bltcon0;
+    unsigned short bltcon1;
+    unsigned short bltafwm;
+    unsigned short bltalwm;
+    unsigned char  *bltcpt;
+    unsigned char  *bltbpt;
+    unsigned char  *bltapt;
+    unsigned char  *bltdpt;
+    unsigned short bltsize;
+    unsigned char  pad2d;
+    unsigned char  bltcon0l;
+    unsigned short bltsizv;
+    unsigned short bltsizh;
+    unsigned short bltcmod;
+    unsigned short bltbmod;
+    unsigned short bltamod;
+    unsigned short bltdmod;
+    unsigned short spare2[4];
+    unsigned short bltcdat;
+    unsigned short bltbdat;
+    unsigned short bltadat;
+    unsigned short spare3[3];
+    unsigned short deniseid;
+    unsigned short dsksync;
+    unsigned short *cop1lc;
+    unsigned short *cop2lc;
+    unsigned short copjmp1;
+    unsigned short copjmp2;
+    unsigned short copins;
+    unsigned short diwstrt;
+    unsigned short diwstop;
+    unsigned short ddfstrt;
+    unsigned short ddfstop;
+    unsigned short dmacon;
+    unsigned short clxcon;
+    unsigned short intena;
+    unsigned short intreq;
+    unsigned short adkcon;
+    struct {
+	unsigned short	*audlc;
+	unsigned short audlen;
+	unsigned short audper;
+	unsigned short audvol;
+	unsigned short auddat;
+	unsigned short audspare[2];
+    } aud[4];
+    unsigned char  *bplpt[8];
+    unsigned short bplcon0;
+    unsigned short bplcon1;
+    unsigned short bplcon2;
+    unsigned short bplcon3;
+    unsigned short bpl1mod;
+    unsigned short bpl2mod;
+    unsigned short bplcon4;
+    unsigned short clxcon2;
+    unsigned short bpldat[8];
+    unsigned char  *sprpt[8];
+    struct {
+	unsigned short pos;
+	unsigned short ctl;
+	unsigned short dataa;
+	unsigned short datab;
+    } spr[8];
+    unsigned short color[32];
+    unsigned short htotal;
+    unsigned short hsstop;
+    unsigned short hbstrt;
+    unsigned short hbstop;
+    unsigned short vtotal;
+    unsigned short vsstop;
+    unsigned short vbstrt;
+    unsigned short vbstop;
+    unsigned short sprhstrt;
+    unsigned short sprhstop;
+    unsigned short bplhstrt;
+    unsigned short bplhstop;
+    unsigned short hhposw;
+    unsigned short hhposr;
+    unsigned short beamcon0;
+    unsigned short hsstrt;
+    unsigned short vsstrt;
+    unsigned short hcenter;
+    unsigned short diwhigh;
+    unsigned short spare4[11];
+    unsigned short fmode;
+};
+
+/*
+ * DMA register bits
+ */
+#define DMAF_SETCLR		(0x8000)
+#define DMAF_AUD0		(0x0001)
+#define DMAF_AUD1		(0x0002)
+#define DMAF_AUD2		(0x0004)
+#define DMAF_AUD3		(0x0008)
+#define DMAF_DISK		(0x0010)
+#define DMAF_SPRITE		(0x0020)
+#define DMAF_BLITTER		(0x0040)
+#define DMAF_COPPER		(0x0080)
+#define DMAF_RASTER		(0x0100)
+#define DMAF_MASTER		(0x0200)
+#define DMAF_BLITHOG		(0x0400)
+#define DMAF_BLTNZERO		(0x2000)
+#define DMAF_BLTDONE		(0x4000)
+#define DMAF_ALL		(0x01FF)
+
+struct CIA {
+    unsigned char pra; 		char pad0[0xff];
+    unsigned char prb; 		char pad1[0xff];
+    unsigned char ddra;		char pad2[0xff];
+    unsigned char ddrb;		char pad3[0xff];
+    unsigned char talo;		char pad4[0xff];
+    unsigned char tahi;		char pad5[0xff];
+    unsigned char tblo;		char pad6[0xff];
+    unsigned char tbhi;		char pad7[0xff];
+    unsigned char todlo;	char pad8[0xff];
+    unsigned char todmid;	char pad9[0xff];
+    unsigned char todhi;	char pada[0x1ff];
+    unsigned char sdr; 		char padb[0xff];
+    unsigned char icr; 		char padc[0xff];
+    unsigned char cra; 		char padd[0xff];
+    unsigned char crb; 		char pade[0xff];
+};
+
+#define zTwoBase (0x80000000)
+#define ZTWO_PADDR(x) (((unsigned long)(x))-zTwoBase)
+#define ZTWO_VADDR(x) (((unsigned long)(x))+zTwoBase)
+
+#define CUSTOM_PHYSADDR     (0xdff000)
+#define custom ((*(volatile struct CUSTOM *)(zTwoBase+CUSTOM_PHYSADDR)))
+
+#define CIAA_PHYSADDR	  (0xbfe001)
+#define CIAB_PHYSADDR	  (0xbfd000)
+#define ciaa   ((*(volatile struct CIA *)(zTwoBase + CIAA_PHYSADDR)))
+#define ciab   ((*(volatile struct CIA *)(zTwoBase + CIAB_PHYSADDR)))
+
+#ifdef CONFIG_APUS_CHIP_EXCEPT
+#define CHIP_PHYSADDR	    (0x004000)
+#else
+#define CHIP_PHYSADDR	    (0x000000)
+#endif
+#define chipaddr ((unsigned long)(zTwoBase + CHIP_PHYSADDR))
+void amiga_chip_init (void);
+void *amiga_chip_alloc (long size);
+void amiga_chip_free (void *);
+unsigned long amiga_chip_avail( void ); /*MILAN*/
+
+struct tod3000 {
+  unsigned int  :28, second2:4;	/* lower digit */
+  unsigned int  :28, second1:4;	/* upper digit */
+  unsigned int  :28, minute2:4;	/* lower digit */
+  unsigned int  :28, minute1:4;	/* upper digit */
+  unsigned int  :28, hour2:4;	/* lower digit */
+  unsigned int  :28, hour1:4;	/* upper digit */
+  unsigned int  :28, weekday:4;
+  unsigned int  :28, day2:4;	/* lower digit */
+  unsigned int  :28, day1:4;	/* upper digit */
+  unsigned int  :28, month2:4;	/* lower digit */
+  unsigned int  :28, month1:4;	/* upper digit */
+  unsigned int  :28, year2:4;	/* lower digit */
+  unsigned int  :28, year1:4;	/* upper digit */
+  unsigned int  :28, cntrl1:4;	/* control-byte 1 */
+  unsigned int  :28, cntrl2:4;	/* control-byte 2 */  
+  unsigned int  :28, cntrl3:4;	/* control-byte 3 */
+};
+#define TOD3000_CNTRL1_HOLD	0
+#define TOD3000_CNTRL1_FREE	9
+#define TOD_3000 ((struct tod3000 *)(zTwoBase+0xDC0000))
+
+struct tod2000 {
+  unsigned int  :28, second2:4;	/* lower digit */
+  unsigned int  :28, second1:4;	/* upper digit */
+  unsigned int  :28, minute2:4;	/* lower digit */
+  unsigned int  :28, minute1:4;	/* upper digit */
+  unsigned int  :28, hour2:4;	/* lower digit */
+  unsigned int  :28, hour1:4;	/* upper digit */
+  unsigned int  :28, day2:4;	/* lower digit */
+  unsigned int  :28, day1:4;	/* upper digit */
+  unsigned int  :28, month2:4;	/* lower digit */
+  unsigned int  :28, month1:4;	/* upper digit */
+  unsigned int  :28, year2:4;	/* lower digit */
+  unsigned int  :28, year1:4;	/* upper digit */
+  unsigned int  :28, weekday:4;
+  unsigned int  :28, cntrl1:4;	/* control-byte 1 */
+  unsigned int  :28, cntrl2:4;	/* control-byte 2 */  
+  unsigned int  :28, cntrl3:4;	/* control-byte 3 */
+};
+
+#define TOD2000_CNTRL1_HOLD	(1<<0)
+#define TOD2000_CNTRL1_BUSY	(1<<1)
+#define TOD2000_CNTRL3_24HMODE	(1<<2)
+#define TOD2000_HOUR1_PM	(1<<2)
+#define TOD_2000 ((struct tod2000 *)(zTwoBase+0xDC0000))
+
+#endif /* _M68K_AMIGAHW_H */
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/amigappc.h ./include/asm-ppc/amigappc.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/amigappc.h	Mon Jan  4 11:32:04 1999
+++ ./include/asm-ppc/amigappc.h	Sat May 15 19:30:27 1999
@@ -16,30 +16,23 @@
 
 #ifndef __ASSEMBLY__
 
-#ifndef iobarrier_rw /* Don't include io.h - avoid circular dependency */
-#define iobarrier_rw() eieio()
-#endif
+#include <asm/system.h>
 
 #define APUS_WRITE(_a_, _v_)				\
 do {							\
 	(*((volatile unsigned char *)(_a_)) = (_v_));	\
-	iobarrier_rw ();				\
+	mb();						\
 } while (0)
 
-#define APUS_READ(_a_, _v_) 				\
+#define APUS_READ(_a_, _v_)				\
 do {							\
 	(_v_) = (*((volatile unsigned char *)(_a_)));	\
-	iobarrier_rw ();				\
+	mb();						\
 } while (0)
 #endif /* ndef __ASSEMBLY__ */
 
 /* Maybe add a [#ifdef WANT_ZTWOBASE] condition to amigahw.h? */
 #define zTwoBase (0x80000000)
-
-/* At CYBERBASEp we find the following sum:
- * -KERNELBASE+CyberStormMemoryBase
- */
-#define CYBERBASEp (0xfff00000)
 
 #define APUS_IPL_BASE   	(zTwoBase + 0x00f60000)
 #define APUS_REG_RESET    	(APUS_IPL_BASE + 0x00)
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/amigayle.h ./include/asm-ppc/amigayle.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/amigayle.h	Mon Oct  5 22:09:06 1998
+++ ./include/asm-ppc/amigayle.h	Sat May 15 18:53:25 1999
@@ -1 +1 @@
-#include "../asm-m68k/amigayle.h"
+#include <asm-m68k/amigayle.h>
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/amipcmcia.h ./include/asm-ppc/amipcmcia.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/amipcmcia.h	Mon Oct  5 22:09:06 1998
+++ ./include/asm-ppc/amipcmcia.h	Sat May 15 18:53:32 1999
@@ -1 +1 @@
-#include "../asm-m68k/amipcmcia.h"
+#include <asm-m68k/amipcmcia.h>
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/ide.h ./include/asm-ppc/ide.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/ide.h	Tue May 11 11:29:01 1999
+++ ./include/asm-ppc/ide.h	Sun May 16 14:22:59 1999
@@ -145,7 +145,7 @@
 /*
  * The following are not needed for the non-m68k ports
  */
-#define ide_ack_intr(base, irq)		(1)
+#define ide_ack_intr(hwif)	((hwif)->ack_intr ? (hwif)->ack_intr(hwif) : 1)
 #define ide_release_lock(lock)		do {} while (0)
 #define ide_get_lock(lock, hdlr, data)	do {} while (0)
 
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/init.h ./include/asm-ppc/init.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/init.h	Mon Jan  4 15:16:13 1999
+++ ./include/asm-ppc/init.h	Tue Jan  5 20:12:11 1999
@@ -20,6 +20,12 @@
 	__argprep __prep; \
 	__argprep
 
+#define __apus __attribute__ ((__section__ (".text.apus")))
+#define __apusdata __attribute__ ((__section__ (".data.apus")))
+#define __apusfunc(__argapus) \
+	__argapus __apus; \
+	__argapus
+
 /* this is actually just common chrp/pmac code, not OF code -- Cort */
 #define __openfirmware __attribute__ ((__section__ (".text.openfirmware")))
 #define __openfirmwaredata __attribute__ ((__section__ (".data.openfirmware")))
@@ -51,6 +57,10 @@
 #define __prep
 #define __prepdata
 #define __prepfunc(x) x
+
+#define __apus
+#define __apusdata
+#define __apusfunc(x) x
 
 #define __openfirmware
 #define __openfirmwaredata
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/io.h ./include/asm-ppc/io.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/io.h	Tue May 11 11:29:01 1999
+++ ./include/asm-ppc/io.h	Sun May 16 13:37:55 1999
@@ -3,7 +3,9 @@
 
 #include <linux/config.h>
 #include <asm/page.h>
+#include <asm/pgtable.h>
 #include <asm/byteorder.h>
+#include <asm/processor.h>
 
 #define SIO_CONFIG_RA	0x398
 #define SIO_CONFIG_RD	0x399
@@ -24,33 +26,26 @@
 #define _ISA_MEM_BASE   0
 #define PCI_DRAM_OFFSET 0x80000000
 #else /* CONFIG_MBX8xx */
-#ifdef CONFIG_APUS
-#define _IO_BASE 0
-#define _ISA_MEM_BASE 0
-#define PCI_DRAM_OFFSET 0
-#else
 extern unsigned long isa_io_base;
 extern unsigned long isa_mem_base;
 extern unsigned long pci_dram_offset;
 #define _IO_BASE	isa_io_base
 #define _ISA_MEM_BASE	isa_mem_base
 #define PCI_DRAM_OFFSET	pci_dram_offset
-#endif /* CONFIG_APUS */
 #endif /* CONFIG_MBX8xx */
 
 #define readb(addr) in_8((volatile unsigned char *)(addr))
 #define writeb(b,addr) out_8((volatile unsigned char *)(addr), (b))
-#if defined(CONFIG_APUS)
-#define readw(addr) (*(volatile unsigned short *) (addr))
-#define readl(addr) (*(volatile unsigned int *) (addr))
-#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b))
-#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b))
-#else
-#define readw(addr) in_le16((volatile unsigned short *)(addr))
-#define readl(addr) in_le32((volatile unsigned *)(addr))
-#define writew(b,addr) out_le16((volatile unsigned short *)(addr),(b))
-#define writel(b,addr) out_le32((volatile unsigned *)(addr),(b))
-#endif
+#define readw(addr) ((is_apus) ? (*(volatile unsigned short *) (addr)) : \
+		     in_le16((volatile unsigned short *)(addr)))
+#define readl(addr) ((is_apus) ? (*(volatile unsigned int *) (addr)) :	\
+		     in_le32((volatile unsigned *)addr)) 
+#define writew(b,addr) ((is_apus) ? 					 \
+			((*(volatile unsigned short *) (addr)) = (b)) :	 \
+			out_le16((volatile unsigned short *)(addr),(b)))
+#define writel(b,addr) ((is_apus) ?					\
+			((*(volatile unsigned int *) (addr)) = (b)) :	\
+			out_le32((volatile unsigned *)(addr),(b)))
 
 #define insb(port, buf, ns)	_insb((unsigned char *)((port)+_IO_BASE), (buf), (ns))
 #define outsb(port, buf, ns)	_outsb((unsigned char *)((port)+_IO_BASE), (buf), (ns))
@@ -61,17 +56,18 @@
 
 #define inb(port)		in_8((unsigned char *)((port)+_IO_BASE))
 #define outb(val, port)		out_8((unsigned char *)((port)+_IO_BASE), (val))
-#if defined(CONFIG_APUS)
-#define inw(port)		in_be16((unsigned short *)((port)+_IO_BASE))
-#define outw(val, port)		out_be16((unsigned short *)((port)+_IO_BASE), (val))
-#define inl(port)		in_be32((unsigned *)((port)+_IO_BASE))
-#define outl(val, port)		out_be32((unsigned *)((port)+_IO_BASE), (val))
-#else
-#define inw(port)		in_le16((unsigned short *)((port)+_IO_BASE))
-#define outw(val, port)		out_le16((unsigned short *)((port)+_IO_BASE), (val))
-#define inl(port)		in_le32((unsigned *)((port)+_IO_BASE))
-#define outl(val, port)		out_le32((unsigned *)((port)+_IO_BASE), (val))
-#endif
+#define inw(port) ((is_apus) ?						\
+		   in_be16((unsigned short *)(port)) :			\
+		   in_le16((unsigned short *)((port)+_IO_BASE)))
+#define outw(val, port) ((is_apus) ?					    \
+			 out_be16((unsigned short *)(port), (val)) :	    \
+			 out_le16((unsigned short *)((port)+_IO_BASE), (val)))
+#define inl(port) ((is_apus) ?					\
+		   in_be32((unsigned *)(port)) :		\
+		   in_le32((unsigned *)((port)+_IO_BASE)))
+#define outl(val, port) ((is_apus) ?					 \
+			 out_be32((unsigned *)(port), (val)) :		 \
+			 out_le32((unsigned *)((port)+_IO_BASE), (val)))
 
 #define inb_p(port)		in_8((unsigned char *)((port)+_IO_BASE))
 #define outb_p(val, port)	out_8((unsigned char *)((port)+_IO_BASE), (val))
@@ -105,6 +101,14 @@
 #define memcpy_toio(a,b,c)	memcpy((a),(b),(c))
 
 #ifdef __KERNEL__
+/* These are not used by the PPC ioremap, but prevents
+   compilation errors. */
+/* Values for nocacheflag and cmode */
+#define	IOMAP_FULL_CACHING		0
+#define	IOMAP_NOCACHE_SER		1
+#define	IOMAP_NOCACHE_NONSER		2
+#define	IOMAP_WRITETHROUGH		3
+
 /*
  * Map in an area of physical address space, for accessing
  * I/O devices etc.
@@ -113,20 +117,11 @@
 		       unsigned long flags);
 extern void *ioremap(unsigned long address, unsigned long size);
 #define ioremap_nocache(addr, size)	ioremap((addr), (size))
+#define ioremap_writethrough(addr, size) \
+        __ioremap((addr), (size), _PAGE_WRITETHRU)
 extern void iounmap(void *addr);
 extern unsigned long iopa(unsigned long addr);
-#ifdef CONFIG_APUS
 extern unsigned long mm_ptov(unsigned long addr) __attribute__ ((const));
-#endif
-
-/* Values for nocacheflag and cmode */
-/* These are not used by the APUS kernel_map, but prevents
-   compilation errors. */
-#define	IOMAP_FULL_CACHING		0
-#define	IOMAP_NOCACHE_SER		1
-#define	IOMAP_NOCACHE_NONSER		2
-#define	IOMAP_WRITETHROUGH		3
-
 
 /*
  * The PCI bus is inherently Little-Endian.  The PowerPC is being
@@ -137,24 +132,22 @@
  */
 extern inline unsigned long virt_to_bus(volatile void * address)
 {
-#ifndef CONFIG_APUS
+	if (is_apus)
+		return iopa ((unsigned long) address);
+
         if (address == (void *)0)
 		return 0;
         return (unsigned long)address - KERNELBASE + PCI_DRAM_OFFSET;
-#else
-	return iopa ((unsigned long) address);
-#endif
 }
 
 extern inline void * bus_to_virt(unsigned long address)
 {
-#ifndef CONFIG_APUS
+	if (is_apus)
+		return (void*) mm_ptov (address);
+
         if (address == 0)
 		return 0;
         return (void *)(address - PCI_DRAM_OFFSET + KERNELBASE);
-#else
-	return (void*) mm_ptov (address);
-#endif
 }
 
 /*
@@ -163,20 +156,18 @@
  */
 extern inline unsigned long virt_to_phys(volatile void * address)
 {
-#ifndef CONFIG_APUS
+	if (is_apus)
+		return iopa ((unsigned long) address);
+
 	return (unsigned long) address - KERNELBASE;
-#else
-	return iopa ((unsigned long) address);
-#endif
 }
 
 extern inline void * phys_to_virt(unsigned long address)
 {
-#ifndef CONFIG_APUS
+	if (is_apus)
+		return (void*) mm_ptov (address);
+
 	return (void *) (address + KERNELBASE);
-#else
-	return (void*) mm_ptov (address);
-#endif
 }
 
 #endif /* __KERNEL__ */
@@ -190,13 +181,6 @@
 {
 	__asm__ __volatile__ ("eieio" : : : "memory");
 }
-
-/* Enforce in-order execution of data I/O. 
- * No distinction between read/write on PPC; use eieio for all three.
- */
-#define iobarrier_rw() eieio()
-#define iobarrier_r()  eieio()
-#define iobarrier_w()  eieio()
 
 /*
  * 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/keyboard.h ./include/asm-ppc/keyboard.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/keyboard.h	Tue May 11 11:29:02 1999
+++ ./include/asm-ppc/keyboard.h	Sun May 16 11:31:09 1999
@@ -18,9 +18,6 @@
 #include <linux/config.h>
 #include <asm/adb.h>
 #include <asm/machdep.h>
-#ifdef CONFIG_APUS
-#include <asm-m68k/keyboard.h>
-#else
 
 #define KEYBOARD_IRQ			1
 #define DISABLE_KBD_DURING_INTERRUPTS	0
@@ -30,28 +27,28 @@
 {
 	return ppc_md.kbd_setkeycode(scancode, keycode);
 }
-
-static inline int kbd_getkeycode(unsigned int x)
+  
+static inline int kbd_getkeycode(unsigned int scancode)
 {
 	return ppc_md.kbd_getkeycode(scancode);
 }
-
+  
 static inline int kbd_translate(unsigned char keycode, unsigned char *keycodep,
-		     char raw_mode)
+				char raw_mode)
 {
 	return ppc_md.kbd_translate(keycode, keycodep, raw_mode);
 }
-
+  
 static inline int kbd_unexpected_up(unsigned char keycode)
 {
 	return ppc_md.kbd_unexpected_up(keycode);
 }
-
+  
 static inline void kbd_leds(unsigned char leds)
 {
 	ppc_md.kbd_leds(leds);
 }
-
+  
 static inline void kbd_init_hw(void)
 {
 	ppc_md.kbd_init_hw();
@@ -64,8 +61,6 @@
 #else
 # define SYSRQ_KEY 0x54
 #endif
-
-#endif /* CONFIG_APUS */
 
 #endif /* __KERNEL__ */
 
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/linux_logo.h ./include/asm-ppc/linux_logo.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/linux_logo.h	Mon Oct  5 22:09:10 1998
+++ ./include/asm-ppc/linux_logo.h	Tue Jan  5 21:53:17 1999
@@ -12,14 +12,6 @@
  */
  
 #include <linux/config.h>
-#ifdef CONFIG_APUS
-#include <asm-m68k/linux_logo.h>
-
-#undef linux_logo_banner
-#define linux_logo_banner "Linux/PPC version " UTS_RELEASE
-
-#else
-
 #include <linux/init.h>
 
 #define linux_logo_banner "Linux/PPC version " UTS_RELEASE
@@ -48,4 +40,3 @@
 extern unsigned char linux_logo16[];
 
 #endif
-#endif /* CONFIG_APUS */
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/m68kserial.h ./include/asm-ppc/m68kserial.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/m68kserial.h	Thu Jan  1 01:00:00 1970
+++ ./include/asm-ppc/m68kserial.h	Sun May 16 11:55:59 1999
@@ -0,0 +1 @@
+#include <asm-m68k/m68kserial.h>
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/page.h ./include/asm-ppc/page.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/page.h	Tue May 11 11:29:03 1999
+++ ./include/asm-ppc/page.h	Sat May 15 11:35:57 1999
@@ -67,15 +67,34 @@
 #define copy_page(to,from)	memcpy((void *)(to), (void *)(from), PAGE_SIZE)
 
 /* map phys->virtual and virtual->phys for RAM pages */
-#ifdef CONFIG_APUS
-#include <asm/amigappc.h>
-/* Word at CYBERBASEp has the value (-KERNELBASE+CYBERBASE). */
-#define __pa(x)			((unsigned long)(x)+(*(unsigned long*)CYBERBASEp))
-#define __va(x)			((void *)((unsigned long)(x)-(*(unsigned long*)CYBERBASEp)))
-#else
-#define __pa(x)			((unsigned long)(x)-PAGE_OFFSET)
-#define __va(x)			((void *)((unsigned long)(x)+PAGE_OFFSET))
-#endif
+static inline unsigned long ___pa(unsigned long v)
+{ 
+	unsigned long p;
+	asm volatile ("1: addis %0, %1, %2;" 
+		      ".section \".vtop_fixup\",\"aw\";"
+		      ".align  1;"
+		      ".long   1b;"
+		      ".previous;"
+		      : "=r" (p) 
+		      : "b" (v), "K" (((-PAGE_OFFSET) >> 16) & 0xffff));
+
+	return p;
+}
+static inline void* ___va(unsigned long p)
+{ 
+	unsigned long v;
+	asm volatile ("1: addis %0, %1, %2;" 
+		      ".section \".ptov_fixup\",\"aw\";"
+		      ".align  1;"
+		      ".long   1b;"
+		      ".previous;"
+		      : "=r" (v) 
+		      : "b" (p), "K" (((PAGE_OFFSET) >> 16) & 0xffff));
+
+	return (void*) v;
+}
+#define __pa(x) ___pa ((unsigned long)(x))
+#define __va(x) ___va ((unsigned long)(x))
 
 #define MAP_NR(addr)		(((unsigned long)addr-PAGE_OFFSET) >> PAGE_SHIFT)
 #define MAP_PAGE_RESERVED	(1<<15)
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/pgtable.h ./include/asm-ppc/pgtable.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/pgtable.h	Tue May 11 11:29:03 1999
+++ ./include/asm-ppc/pgtable.h	Sun May 16 13:37:55 1999
@@ -610,7 +611,6 @@
 #define module_map      vmalloc
 #define module_unmap    vfree
 
-/* CONFIG_APUS */
 /* For virtual address to physical address conversion */
 extern void cache_clear(__u32 addr, int length);
 extern void cache_push(__u32 addr, int length);
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/processor.h ./include/asm-ppc/processor.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/processor.h	Wed May 12 09:57:47 1999
+++ ./include/asm-ppc/processor.h	Sat May 15 18:33:35 1999
@@ -24,7 +24,7 @@
 #define MSR_RI		(1<<1)		/* Recoverable Exception */
 #define MSR_LE		(1<<0)		/* Little-Endian enable */
 
-#ifdef CONFIG_APUS
+#ifdef CONFIG_APUS_FAST_EXCEPT
 #define MSR_		MSR_ME|MSR_IP|MSR_RI
 #else
 #define MSR_		MSR_ME|MSR_RI
@@ -181,6 +181,7 @@
 extern int have_of;
 extern int is_prep;
 extern int is_chrp;
+extern int is_apus;
 extern int is_powerplus;
 
 /* what kind of prep workstation we are */
@@ -288,5 +289,4 @@
 
 #endif /* ndef ASSEMBLY*/
 
-  
 #endif /* __ASM_PPC_PROCESSOR_H */
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/serial.h ./include/asm-ppc/serial.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/serial.h	Fri Aug  7 15:56:22 1998
+++ ./include/asm-ppc/serial.h	Sat May 15 18:52:39 1999
@@ -4,10 +4,6 @@
 
 #include <linux/config.h>
 
-#ifdef CONFIG_APUS
-#include <asm-m68k/serial.h>
-#else
-
 /*
  * This assumes you have a 1.8432 MHz clock for your UART.
  *
@@ -119,5 +115,3 @@
 	EXTRA_SERIAL_PORT_DEFNS		\
 	HUB6_SERIAL_PORT_DFNS		\
 	MCA_SERIAL_PORT_DFNS
-
-#endif /* CONFIG_APUS */
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/system.h ./include/asm-ppc/system.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/asm-ppc/system.h	Wed May 12 09:57:49 1999
+++ ./include/asm-ppc/system.h	Sat May 15 18:35:15 1999
@@ -39,6 +39,14 @@
 	asm("dcbf %0,%1; sync" : : "r" (line), "r" (0));
 }
 
+extern __inline__ void dcbi(void *line)
+{
+	asm("dcbi %0,%1\n\t"
+	    "sync \n\t"
+	    "isync \n\t"
+	    :: "r" (line), "r" (0));
+}
+
 extern __inline__ void __restore_flags(unsigned long flags)
 {
         extern atomic_t ppc_n_lost_interrupts;
diff -u --recursive -B --exclude-from=/home/jskov/lib/diff-excludes -P /home/jskov/kernel/dist/linux-2.2.8/include/linux/socket.h ./include/linux/socket.h
--- /home/jskov/kernel/dist/linux-2.2.8/include/linux/socket.h	Thu Apr 22 15:01:41 1999
+++ ./include/linux/socket.h	Sat May 15 18:27:25 1999
@@ -1,7 +1,7 @@
 #ifndef _LINUX_SOCKET_H
 #define _LINUX_SOCKET_H
 
-#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
+#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) || (defined(__powerpc__) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 0)
 
 #include <asm/socket.h>			/* arch-dependent defines	*/
 #include <linux/sockios.h>		/* the SIOCxxx I/O controls	*/
