From: Roman.Hodek@informatik.uni-erlangen.de (Roman Hodek)
Date: Sun, 16 Nov 1997 14:58:35 +0100 (CET)
To: linux-m68k@lists.linux-m68k.org
Subject: L68K: Misc patches for 2.1.61
Sender: owner-linux-m68k@phil.uni-sb.de


Ok, this weekend I finally found some spare time for kernel hacking;
the result is below :-)

 - There's a new bootinfo tag ATARI_MCH_TYPE. The bootstrap passes
   there an indicator whether the machine is some special one
   (currently Medusa, Hades, Afterburner040). Note that you need the
   new ataboot 3.1 for this[1]. If you use an older bootstrap, the
   value will be assumed as 0 (= no special machine), which doesn't
   matter on normal machines, but will crash on a
   Medusa/Hades/Afterburner. I incremented bootstrap version to 2.1
   for Atari for this change (so that the bootstrap will warn you if
   it's too old).

   In the past, I always argued that such tests should be done by the
   kernel itself, to make it more independent from the environment
   that what was before it. But experience showed that the bootstrap
   has to do the same tests anyway for properly determining the memory
   configuration. So there's not much sense in hiding the information
   from the kernel...

 - The is_medusa and is_hades variables have become obsolete due to
   the new atari_mch_type variable. Deleted them and their
   initialization in head.S. The latter has been replaced by fetching
   the info from the bootinfo.

 - Rewritten tests for Falcon, TT, ... (using mch_cookie) and
   is_medusa and is_hades to use new MACH_IS_* macros for clarity.

 - In the Atari reset code, hardcode reset address 0xe00030 for
   Afterburner. The contents of 0x4 phys. seemed to be valid until
   now, but since this is RAM, it's better to be sure...

 - The year offset of the Atari RTC (70 for TOS before 3.06, 68 after)
   has been calculated at more and more locations in the kernel. To
   avoid determining the TOS version and recalculating that value all
   the time, I've introduced a new global variable
   atari_rtc_year_offset.

 - I implemented the missing serial console stuff for Atari. Valid
   devices are ttyS0 (Modem1, ST-MFP) and ttyS1 (Modem2, SCC-B). Baud
   rates can be 1200...115200. On Modem1, rates >= 38400 only work if
   you have RSVE or RSSPEED. On a TT's Modem2, 57600 and 115200 aren't
   possible (you know...) and are replaced by 76800 and 153600 as
   usual.

   Unfortunately, I had to turn off CON_PRINTBUFFER in the sercons
   flags, see comment in serial_console_init().

   (BTW, Geert: What is the amiga_serial_gets() function good for?
   It's never called... Is it a leftover?)

 - m68kserial.c:serial_console_setup(): PARENB flag for enabling odd
   parity was missing

 - The Atari SCC driver was using character size 6 instead of 7 and
   vice versa. (The values for 5..8 bits aren't consecutive, which I
   must have misread in the docs...) Seems that nobody uses char sizes
   != 8 :-)

 - Deleted unused variable in acsi.c.

 - In ataflop.c, added anti-test for Hades, since that machine doesn't
   have an Atari-compatible floppy drive.

 - In ataflop.c (again), obey the fact that the Falcon doesn't support
   a second floppy drive and only probe for one. Also never touch the
   drive select line for B:, it's connected to the printer port.

 - Atari net drivers were modularized ages ago, so they should also be
   selectable as modules in the config.in :-)

 - Clearing %a6 before calling start_kernel in head.S was still
   missing (I did this already in a previous patch).

   Also changed boot message if kgdb isn't enabled at all (i.e., no
   debug= option). "Initialization failed" wasn't quite correct...

 - Another new read/write prototype change in acsi_slm.c

 - I was about to add the Falcon's additional printer lines (SELECT
   OUT, ACK) to lp_intern.c, but then realized that these lines are
   never used by the driver... also not by the PC driver (nearly
   never...). What to do with them now?

Roman

[1]: I'll release ataboot-3.1 as soon as the Afterburner memory
detection stuff is tested. A source preview is already
ftp.uni-erlangen.de, under tmp/.

------------------------------------------------------------------------------
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/arch/m68k/atari/atari_ksyms.c linux-2.1.61/arch/m68k/atari/atari_ksyms.c
--- linux-2.1.61.orig/arch/m68k/atari/atari_ksyms.c	Wed Apr 16 16:56:51 1997
+++ linux-2.1.61/arch/m68k/atari/atari_ksyms.c	Fri Nov 14 14:17:56 1997
@@ -12,9 +12,8 @@
 extern int atari_SCC_reset_done;
 
 EXPORT_SYMBOL(atari_mch_cookie);
+EXPORT_SYMBOL(atari_mch_type);
 EXPORT_SYMBOL(atari_hw_present);
-EXPORT_SYMBOL(is_medusa);
-EXPORT_SYMBOL(is_hades);
 EXPORT_SYMBOL(atari_register_vme_int);
 EXPORT_SYMBOL(atari_unregister_vme_int);
 EXPORT_SYMBOL(stdma_lock);
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/arch/m68k/atari/config.c linux-2.1.61/arch/m68k/atari/config.c
--- linux-2.1.61.orig/arch/m68k/atari/config.c	Fri Nov 14 18:08:12 1997
+++ linux-2.1.61/arch/m68k/atari/config.c	Sun Nov 16 13:38:24 1997
@@ -33,6 +33,7 @@
 #include <linux/console.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 
 #include <asm/bootinfo.h>
 #include <asm/setup.h>
@@ -50,7 +51,9 @@
 #endif
 
 u_long atari_mch_cookie;
+u_long atari_mch_type = 0;
 struct atari_hw_present atari_hw_present;
+int atari_rtc_year_offset;
 
 extern char m68k_debug_device[];
 
@@ -87,6 +90,10 @@
 
 static struct console atari_console_driver;
 
+/* Flag that Modem1 port is already initialized and used */
+int atari_MFP_init_done = 0;
+/* Flag that Modem1 port is already initialized and used */
+int atari_SCC_init_done = 0;
 /* Can be set somewhere, if a SCC master reset has already be done and should
  * not be repeated; used by kgdb */
 int atari_SCC_reset_done = 0;
@@ -244,6 +251,9 @@
 	case BI_ATARI_MCH_COOKIE:
 	    atari_mch_cookie = *data;
 	    break;
+	case BI_ATARI_MCH_TYPE:
+	    atari_mch_type = *data;
+	    break;
 	default:
 	    unknown = 1;
     }
@@ -256,6 +266,8 @@
 
 __initfunc(void config_atari(void))
 {
+    unsigned short tos_version;
+
     memset(&atari_hw_present, 0, sizeof(atari_hw_present));
 
     atari_debug_init();
@@ -292,7 +304,7 @@
      */
 
     printk( "Atari hardware found: " );
-    if (is_medusa || is_hades) {
+    if (MACH_IS_MEDUSA || MACH_IS_HADES) {
         /* There's no Atari video hardware on the Medusa, but all the
          * addresses below generate a DTACK so no bus error occurs! */
     }
@@ -334,12 +346,12 @@
 	ATARIHW_SET(SCSI_DMA);
         printk( "TT_SCSI_DMA " );
     }
-    if (!is_hades && hwreg_present( &st_dma.dma_hi )) {
+    if (!MACH_IS_HADES && hwreg_present( &st_dma.dma_hi )) {
 	ATARIHW_SET(STND_DMA);
         printk( "STND_DMA " );
     }
-    if (is_medusa || /* The ST-DMA address registers aren't readable
-                      * on all Medusas, so the test below may fail */
+    if (MACH_IS_MEDUSA || /* The ST-DMA address registers aren't readable
+			   * on all Medusas, so the test below may fail */
         (hwreg_present( &st_dma.dma_vhi ) &&
          (st_dma.dma_vhi = 0x55) && (st_dma.dma_hi = 0xaa) &&
          st_dma.dma_vhi == 0x55 && st_dma.dma_hi == 0xaa &&
@@ -356,11 +368,12 @@
 	ATARIHW_SET(YM_2149);
         printk( "YM2149 " );
     }
-    if (!is_medusa && !is_hades && hwreg_present( &tt_dmasnd.ctrl )) {
+    if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
+	hwreg_present( &tt_dmasnd.ctrl )) {
 	ATARIHW_SET(PCM_8BIT);
         printk( "PCM " );
     }
-    if (!is_hades && hwreg_present( &codec.unused5 )) {
+    if (!MACH_IS_HADES && hwreg_present( &codec.unused5 )) {
 	ATARIHW_SET(CODEC);
         printk( "CODEC " );
     }
@@ -374,7 +387,7 @@
 	(tt_scc_dma.dma_ctrl = 0x01, (tt_scc_dma.dma_ctrl & 1) == 1) &&
 	(tt_scc_dma.dma_ctrl = 0x00, (tt_scc_dma.dma_ctrl & 1) == 0)
 #else
-	!is_medusa && !is_hades
+	!MACH_IS_MEDUSA && !MACH_IS_HADES
 #endif
 	) {
 	ATARIHW_SET(SCC_DMA);
@@ -388,7 +401,7 @@
 	ATARIHW_SET( ST_ESCC );
 	printk( "ST_ESCC " );
     }
-    if (is_hades)
+    if (MACH_IS_HADES)
     {
         ATARIHW_SET( VME );
         printk( "VME " );
@@ -403,7 +416,7 @@
 	ATARIHW_SET(ANALOG_JOY);
         printk( "ANALOG_JOY " );
     }
-    if (!is_hades && hwreg_present( blitter.halftone )) {
+    if (!MACH_IS_HADES && hwreg_present( blitter.halftone )) {
 	ATARIHW_SET(BLITTER);
         printk( "BLITTER " );
     }
@@ -412,7 +425,7 @@
         printk( "IDE " );
     }
 #if 1 /* This maybe wrong */
-    if (!is_medusa && !is_hades &&
+    if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
 	hwreg_present( &tt_microwire.data ) &&
 	hwreg_present( &tt_microwire.mask ) &&
 	(tt_microwire.mask = 0x7ff,
@@ -430,20 +443,20 @@
         mach_hwclk = atari_hwclk;
         mach_set_clock_mmss = atari_set_clock_mmss;
     }
-    if (!is_hades && hwreg_present( &mste_rtc.sec_ones)) {
+    if (!MACH_IS_HADES && hwreg_present( &mste_rtc.sec_ones)) {
 	ATARIHW_SET(MSTE_CLK);
         printk( "MSTE_CLK ");
         mach_gettod = atari_mste_gettod;
         mach_hwclk = atari_mste_hwclk;
         mach_set_clock_mmss = atari_mste_set_clock_mmss;
     }
-    if (!is_medusa && !is_hades &&
+    if (!MACH_IS_MEDUSA && !MACH_IS_HADES &&
 	hwreg_present( &dma_wd.fdc_speed ) &&
 	hwreg_write( &dma_wd.fdc_speed, 0 )) {
 	    ATARIHW_SET(FDCSPEED);
 	    printk( "FDC_SPEED ");
     }
-    if (!is_hades && !ATARIHW_PRESENT(ST_SCSI)) {
+    if (!MACH_IS_HADES && !ATARIHW_PRESENT(ST_SCSI)) {
 	ATARIHW_SET(ACSI);
         printk( "ACSI " );
     }
@@ -501,6 +514,18 @@
               : "d0" );
 
     }
+
+    /* Fetch tos version at Physical 2 */
+    /* We my not be able to access this address if the kernel is
+       loaded to st ram, since the first page is unmapped.  On the
+       Medusa this is always the case and there is nothing we can do
+       about this, so we just assume the smaller offset.  For the TT
+       we use the fact that in head.S we have set up a mapping
+       0xFFxxxxxx -> 0x00xxxxxx, so that the first 16MB is accessible
+       in the last 16MB of the address space. */
+    tos_version = (MACH_IS_MEDUSA || MACH_IS_HADES) ?
+		  0xfff : *(unsigned short *)0xff000002;
+    atari_rtc_year_offset = (tos_version < 0x306) ? 70 : 68;
 }
 
 __initfunc(static void
@@ -614,7 +639,6 @@
 			  int *hourp, int *minp, int *secp)
 {
     unsigned char	ctrl;
-    unsigned short tos_version;
     int hour, pm;
 
     while (!(RTC_READ(RTC_FREQ_SELECT) & RTC_UIP)) ;
@@ -657,8 +681,7 @@
        we use the fact that in head.S we have set up a mapping
        0xFFxxxxxx -> 0x00xxxxxx, so that the first 16MB is accessible
        in the last 16MB of the address space. */
-    tos_version = (is_medusa || is_hades) ? 0xfff : *(unsigned short *)0xFF000002;
-    *yearp += (tos_version < 0x306) ? 70 : 68;
+    *yearp += atari_rtc_year_offset;
 }
 
 #define HWCLK_POLL_INTERVAL	5
@@ -726,14 +749,9 @@
 {
     int sec=0, min=0, hour=0, day=0, mon=0, year=0, wday=0; 
     unsigned long 	flags;
-    unsigned short	tos_version;
     unsigned char	ctrl;
     int pm = 0;
 
-    /* Tos version at Physical 2.  See above for explanation why we
-       cannot use PTOV(2).  */
-    tos_version = (is_medusa || is_hades) ? 0xfff : *(unsigned short *)0xff000002;
-
     ctrl = RTC_READ(RTC_CONTROL); /* control registers are
                                    * independent from the UIP */
 
@@ -745,7 +763,7 @@
         hour = t->hour;
         day  = t->day;
         mon  = t->mon + 1;
-        year = t->year - ((tos_version < 0x306) ? 70 : 68);
+        year = t->year - atari_rtc_year_offset;
         wday = t->wday + (t->wday >= 0);
         
         if (!(ctrl & RTC_24H)) {
@@ -841,7 +859,7 @@
         t->hour = hour;
         t->day  = day;
         t->mon  = mon - 1;
-        t->year = year + ((tos_version < 0x306) ? 70 : 68);
+        t->year = year + atari_rtc_year_offset;
         t->wday = wday - 1;
     }
 
@@ -911,6 +929,8 @@
     return retval;
 }
 
+
+
 static inline void ata_mfp_out (char c)
 {
     while (!(mfp.trn_stat & 0x80)) /* wait for tx buf empty */
@@ -918,7 +938,7 @@
     mfp.usart_dta = c;
 }
 
-static void atari_mfp_console_write (const char *str, unsigned int count)
+void atari_mfp_console_write (const char *str, unsigned int count)
 {
     while (count--) {
 	if (*str == '\n')
@@ -936,7 +956,7 @@
     scc.cha_b_data = c;
 }
 
-static void atari_scc_console_write (const char *str, unsigned int count)
+void atari_scc_console_write (const char *str, unsigned int count)
 {
     while (count--) {
 	if (*str == '\n')
@@ -947,7 +967,6 @@
 
 static int ata_par_out (char c)
 {
-    extern unsigned long loops_per_sec;
     unsigned char tmp;
     /* This a some-seconds timeout in case no printer is connected */
     unsigned long i = loops_per_sec > 1 ? loops_per_sec : 10000000;
@@ -986,6 +1005,144 @@
     }
 }
 
+#ifdef CONFIG_SERIAL_CONSOLE
+int atari_mfp_console_wait_key(void)
+{
+    while( !(mfp.rcv_stat & 0x80) ) /* wait for rx buf filled */
+	barrier();
+    return( mfp.usart_dta );
+}
+
+int atari_scc_console_wait_key(void)
+{
+    do {
+	MFPDELAY();
+    } while( !(scc.cha_b_ctrl & 0x01) ); /* wait for rx buf filled */
+    MFPDELAY();
+    return( scc.cha_b_data );
+}
+#endif
+
+/* The following two functions do a quick'n'dirty initialization of the MFP or
+ * SCC serial ports. They're used by the debugging interface, kgdb, and the
+ * serial console code. */
+#ifndef CONFIG_SERIAL_CONSOLE
+__initfunc(static
+#endif
+void atari_init_mfp_port( int cflag )
+#ifndef CONFIG_SERIAL_CONSOLE
+)
+#endif
+{
+    /* timer values for 1200...115200 bps; > 38400 select 110, 134, or 150
+     * bps, resp., and work only correct if there's a RSVE or RSSPEED */
+    static int baud_table[9] = { 16, 11, 8, 4, 2, 1, 175, 143, 128 };
+    int baud = cflag & CBAUD;
+    int parity = (cflag & PARENB) ? ((cflag & PARODD) ? 0x04 : 0x06) : 0;
+    int csize = ((cflag & CSIZE) == CS7) ? 0x20 : 0x00;
+
+    if (cflag & CBAUDEX)
+	baud += B38400;
+    if (baud < B1200 || baud > B38400+2)
+	baud = B9600; /* use default 9600bps for non-implemented rates */
+    baud -= B1200; /* baud_table[] starts at 1200bps */
+	
+    mfp.trn_stat &= ~0x01; /* disable TX */
+    mfp.usart_ctr = parity | csize | 0x88; /* 1:16 clk mode, 1 stop bit */
+    mfp.tim_ct_cd &= 0x70;  /* stop timer D */
+    mfp.tim_dt_d = baud_table[baud];
+    mfp.tim_ct_cd |= 0x01;  /* start timer D, 1:4 */
+    mfp.trn_stat |= 0x01;  /* enable TX */
+
+    atari_MFP_init_done = 1;
+}
+
+#define SCC_WRITE(reg,val)				\
+    do {						\
+	scc.cha_b_ctrl = (reg);				\
+	MFPDELAY();					\
+	scc.cha_b_ctrl = (val);				\
+	MFPDELAY();					\
+	printk("WR%02d: %02x\n",(reg),(val));	\
+    } while(0)
+
+/* loops_per_sec isn't initialized yet, so we can't use udelay(). This does a
+ * delay of ~ 60us. */
+#define LONG_DELAY()				\
+    do {					\
+	int i;					\
+	for( i = 100; i > 0; --i )		\
+	    MFPDELAY();				\
+    } while(0)
+    
+#ifndef CONFIG_SERIAL_CONSOLE
+__initfunc(static
+#endif
+void atari_init_scc_port( int cflag )
+#ifndef CONFIG_SERIAL_CONSOLE
+)
+#endif
+{
+    extern int atari_SCC_reset_done;
+    static int clksrc_table[9] =
+	/* reg 11: 0x50 = BRG, 0x00 = RTxC, 0x28 = TRxC */
+    	{ 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00 };
+    static int brgsrc_table[9] =
+	/* reg 14: 0 = RTxC, 2 = PCLK */
+    	{ 2, 2, 2, 2, 2, 2, 0, 2, 2 };
+    static int clkmode_table[9] =
+	/* reg 4: 0x40 = x16, 0x80 = x32, 0xc0 = x64 */
+    	{ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0, 0x80 };
+    static int div_table[9] =
+	/* reg12 (BRG low) */
+    	{ 208, 138, 103, 50, 24, 11, 1, 0, 0 };
+
+    int baud = cflag & CBAUD;
+    int clksrc, clkmode, div, reg3, reg5;
+    
+    if (cflag & CBAUDEX)
+	baud += B38400;
+    if (baud < B1200 || baud > B38400+2)
+	baud = B9600; /* use default 9600bps for non-implemented rates */
+    baud -= B1200; /* tables starts at 1200bps */
+
+    clksrc  = clksrc_table[baud];
+    clkmode = clkmode_table[baud];
+    div     = div_table[baud];
+    if (ATARIHW_PRESENT(TT_MFP) && baud >= 6) {
+	/* special treatment for TT, where rates >= 38400 are done via TRxC */
+	clksrc = 0x28; /* TRxC */
+	clkmode = baud == 6 ? 0xc0 :
+		  baud == 7 ? 0x80 : /* really 76800bps */
+			      0x40;  /* really 153600bps */
+	div = 0;
+    }
+
+    reg3 = (cflag & CSIZE) == CS8 ? 0xc0 : 0x40;
+    reg5 = (cflag & CSIZE) == CS8 ? 0x60 : 0x20 | 0x82 /* assert DTR/RTS */;
+    
+    (void)scc.cha_b_ctrl;	/* reset reg pointer */
+    SCC_WRITE( 9, 0xc0 );	/* reset */
+    LONG_DELAY();		/* extra delay after WR9 access */
+    SCC_WRITE( 4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 |
+		  0x04 /* 1 stopbit */ |
+		  clkmode );
+    SCC_WRITE( 3, reg3 );
+    SCC_WRITE( 5, reg5 );
+    SCC_WRITE( 9, 0 );		/* no interrupts */
+    LONG_DELAY();		/* extra delay after WR9 access */
+    SCC_WRITE( 10, 0 );		/* NRZ mode */
+    SCC_WRITE( 11, clksrc );	/* main clock source */
+    SCC_WRITE( 12, div );	/* BRG value */
+    SCC_WRITE( 13, 0 );		/* BRG high byte */
+    SCC_WRITE( 14, brgsrc_table[baud] );
+    SCC_WRITE( 14, brgsrc_table[baud] | (div ? 1 : 0) );
+    SCC_WRITE( 3, reg3 | 1 );
+    SCC_WRITE( 5, reg5 | 8 );
+    
+    atari_SCC_reset_done = 1;
+    atari_SCC_init_done = 1;
+}
 
 __initfunc(static void atari_debug_init(void))
 {
@@ -997,46 +1154,17 @@
 
     if (!strcmp( m68k_debug_device, "ser" )) {
 	/* defaults to ser2 for a Falcon and ser1 otherwise */
-	strcpy( m68k_debug_device, 
-		((atari_mch_cookie >> 16) == ATARI_MCH_FALCON) ?
-		"ser2" : "ser1" );
-
+	strcpy( m68k_debug_device, MACH_IS_FALCON ? "ser2" : "ser1" );
     }
 
     if (!strcmp( m68k_debug_device, "ser1" )) {
 	/* ST-MFP Modem1 serial port */
-	mfp.trn_stat  &= ~0x01; /* disable TX */
-	mfp.usart_ctr  = 0x88;  /* clk 1:16, 8N1 */
-	mfp.tim_ct_cd &= 0x70;  /* stop timer D */
-	mfp.tim_dt_d   = 2;     /* 9600 bps */
-	mfp.tim_ct_cd |= 0x01;  /* start timer D, 1:4 */
-	mfp.trn_stat  |= 0x01;  /* enable TX */
+	atari_init_mfp_port( B9600|CS8 );
 	atari_console_driver.write = atari_mfp_console_write;
     }
     else if (!strcmp( m68k_debug_device, "ser2" )) {
 	/* SCC Modem2 serial port */
-	static unsigned char *p, scc_table[] = {
-	    9, 12,		/* Reset */
-	    4, 0x44,		/* x16, 1 stopbit, no parity */
-	    3, 0xc0,		/* receiver: 8 bpc */
-	    5, 0xe2,		/* transmitter: 8 bpc, assert dtr/rts */
-	    9, 0,		/* no interrupts */
-	    10, 0,		/* NRZ */
-	    11, 0x50,		/* use baud rate generator */
-	    12, 24, 13, 0,	/* 9600 baud */
-	    14, 2, 14, 3,	/* use master clock for BRG, enable */
-	    3, 0xc1,		/* enable receiver */
-	    5, 0xea,		/* enable transmitter */
-	    0
-	};
-	    
-	(void)scc.cha_b_ctrl; /* reset reg pointer */
-	for( p = scc_table; *p != 0; ) {
-	    scc.cha_b_ctrl = *p++;
-	    MFPDELAY();
-	    scc.cha_b_ctrl = *p++;
-	    MFPDELAY();
-	}
+	atari_init_scc_port( B9600|CS8 );
 	atari_console_driver.write = atari_scc_console_write;
     }
     else if (!strcmp( m68k_debug_device, "par" )) {
@@ -1092,8 +1220,9 @@
 
     /* On the Medusa, phys. 0x4 may contain garbage because it's no
        ROM.  See above for explanation why we cannot use PTOV(4). */
-    reset_addr = is_hades ? 0x7fe00030 :
-                 (is_medusa ? 0xe00030 : *(unsigned long *) 0xff000004);
+    reset_addr = MACH_IS_HADES ? 0x7fe00030 :
+                 MACH_IS_MEDUSA || MACH_IS_AB40 ? 0xe00030 :
+		 *(unsigned long *) 0xff000004;
 
     acia.key_ctrl = ACIA_RESET;             /* reset ACIA for switch off OverScan, if it's active */
 
@@ -1177,22 +1306,24 @@
 		strcat (model, "ST");
 	    break;
 	case ATARI_MCH_STE:
-	    if ((atari_mch_cookie & 0xffff) == 0x10)
+	    if (MACH_IS_MSTE)
 		strcat (model, "Mega STE");
 	    else
 		strcat (model, "STE");
 	    break;
 	case ATARI_MCH_TT:
-	    if (is_medusa)
+	    if (MACH_IS_MEDUSA)
 		/* Medusa has TT _MCH cookie */
 		strcat (model, "Medusa");
-	    else if (is_hades)
+	    else if (MACH_IS_HADES)
 		strcat(model, "Hades");
 	    else
 		strcat (model, "TT");
 	    break;
 	case ATARI_MCH_FALCON:
 	    strcat (model, "Falcon");
+	    if (MACH_IS_AB40)
+		strcat (model, " (with Afterburner040)");
 	    break;
 	default:
 	    sprintf (model + strlen (model), "(unknown mach cookie 0x%lx)",
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/arch/m68k/config.in linux-2.1.61/arch/m68k/config.in
--- linux-2.1.61.orig/arch/m68k/config.in	Fri Nov 14 18:05:57 1997
+++ linux-2.1.61/arch/m68k/config.in	Sun Nov 16 12:06:45 1997
@@ -211,10 +211,10 @@
   tristate 'Apollo 3c505 support' CONFIG_APOLLO_ELPLUS
 fi
 if [ "$CONFIG_ATARI" = "y" ]; then
-  bool 'Atari Lance support' CONFIG_ATARILANCE
-if [ "$CONFIG_ATARI_ACSI" = "y" ]; then
-  bool 'BioNet-100 support' CONFIG_ATARI_BIONET
-  bool 'PAMsNet support' CONFIG_ATARI_PAMSNET
+  tristate 'Atari Lance support' CONFIG_ATARILANCE
+if [ "$CONFIG_ATARI_ACSI" != "n" ]; then
+  tristate 'BioNet-100 support' CONFIG_ATARI_BIONET
+  tristate 'PAMsNet support' CONFIG_ATARI_PAMSNET
 fi
 fi
 fi
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/arch/m68k/kernel/head.S linux-2.1.61/arch/m68k/kernel/head.S
--- linux-2.1.61.orig/arch/m68k/kernel/head.S	Sat Nov  1 19:01:22 1997
+++ linux-2.1.61/arch/m68k/kernel/head.S	Sat Nov 15 20:30:24 1997
@@ -72,8 +72,7 @@
 #include <asm/pgtable.h>
 
 .globl SYMBOL_NAME(kernel_pg_dir), SYMBOL_NAME(kpt)
-.globl SYMBOL_NAME(availmem), SYMBOL_NAME(is_medusa)
-.globl SYMBOL_NAME(is_hades)
+.globl SYMBOL_NAME(availmem)
 .globl SYMBOL_NAME(m68k_pgtable_cachemode)
 .globl SYMBOL_NAME(kernel_pmd_table), SYMBOL_NAME(swapper_pg_dir)
 
@@ -249,33 +248,25 @@
 #ifdef CONFIG_ATARI
 	is_not_atari(Lnotypetest)
 
-	moveq	#0,%d3			/* base addr for others: 0x00000000 */
-	moveq	#0,%d2			/* no Hades */
-	movec	%d3,%vbr
-	lea	%pc@(Ltest_berr),%a0
-	movel	%a0,0x8
-	movel	%sp,%a0
-	moveb	0x0,%d1
-	clrb	0x0
-	nop
-	moveb	%d1,0x0
-	nop
-	tstb	0x00ff82fe
-	nop
-	movel	#0xff000000,%d3		/* Medusa base addr: 0xff000000 */
-	tstb	0xb0000000
-	nop
-	movel	#0xff000000,%d2		/* Computer is a Hades */
-	moveq	#0,%d3
-Ltest_berr:
-	movel	%a0,%sp
-	lea	%pc@(SYMBOL_NAME(is_hades)),%a0
-	movel	%d2,%a0@
-	lea	%pc@(SYMBOL_NAME(is_medusa)),%a0
-	movel	%d3,%a0@
-	lea     %pc@(Liobase),%a0
-	movel   %d2,%a0@		/* On a Hades the iobase must be set
-					   before opening the serial port. */
+	/* get special machine type (Medusa/Hades/AB40) */
+	moveq	#0,%d3 /* default if tag doesn't exist */
+	movew	#BI_ATARI_MCH_TYPE,%d0
+	jbsr	Lget_bi_record
+	tstl	%d0
+	jbne	1f
+	movel	%a0@,%d3
+1:	
+	/* %d3 is not clobbered until Atari page tables are set up,
+	 * where it is used again. */
+
+	/* On the Hades, the iobase must be set up before opening the
+	 * serial port. There are no I/O regs at 0x00ffxxxx at all. */
+	moveq	#0,%d0
+	cmpl	#ATARI_MACH_HADES,%d3
+	jbne	1f
+	movel	#0xff000000,%d0		/* Hades I/O base addr: 0xff000000 */
+1:	lea     %pc@(Liobase),%a0
+	movel   %d0,%a0@
 Lnotypetest:
 #endif
 
@@ -543,10 +534,15 @@
    area.
 */
 
-	movel   %pc@(is_medusa),%d3
-	bne     1f
-	movel   %pc@(is_hades),%d3
-1:
+	/* I/O base addr for non-Medusa, non-Hades: 0x00000000 */
+	moveq	#0,%d0
+	cmpl	#ATARI_MACH_MEDUSA,%d3
+	jbeq	2f
+	cmpl	#ATARI_MACH_HADES,%d3
+	jbne	1f
+2:	movel	#0xff000000,%d0 /* Medusa/Hades base addr: 0xff000000 */
+1:	movel	%d0,%d3
+	
 	/* Let the root table point to the new pointer table */
 	lea	%a4@(PTR_TABLE_SIZE<<2),%a4
 	movel	%a4,%a0
@@ -874,7 +870,7 @@
 
 /* jump to the kernel start */
 	putr()
-
+	subl	%a6,%a6 /* clear a6 for gdb */
 	jbsr	SYMBOL_NAME(start_kernel)
 
 /*
@@ -1145,10 +1141,6 @@
 SYMBOL_NAME_LABEL(kpt)
 	.long 0
 SYMBOL_NAME_LABEL(availmem)
-	.long 0
-SYMBOL_NAME_LABEL(is_medusa)
-	.long 0
-SYMBOL_NAME_LABEL(is_hades)
 	.long 0
 SYMBOL_NAME_LABEL(m68k_pgtable_cachemode)
 	.long 0
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/arch/m68k/kernel/kgdb.c linux-2.1.61/arch/m68k/kernel/kgdb.c
--- linux-2.1.61.orig/arch/m68k/kernel/kgdb.c	Fri Nov 14 18:08:01 1997
+++ linux-2.1.61/arch/m68k/kernel/kgdb.c	Sun Nov 16 11:49:48 1997
@@ -587,9 +587,7 @@
 	if (MACH_IS_ATARI) {
 		if (!strcmp( m68k_debug_device, "ser" )) {
 			/* defaults to ser2 for a Falcon and ser1 otherwise */
-			strcpy( m68k_debug_device, 
-					((atari_mch_cookie>>16) == ATARI_MCH_FALCON) ?
-					"ser2" : "ser1" );
+			strcpy( m68k_debug_device, MACH_IS_FALCON ? "ser2" : "ser1" );
 		}
 
 		if (!strcmp( m68k_debug_device, "ser1" )) {
@@ -670,7 +668,10 @@
 
 #ifdef CONFIG_ATARI
 	if (!serial_in || !serial_out) {
-		printk( "kgdb_init failed: no valid serial device!\n" );
+		if (*m68k_debug_device)
+			printk( "kgdb_init failed: no valid serial device!\n" );
+		else
+			printk( "kgdb not enabled\n" );
 		return;
 	}
 #endif
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/drivers/block/acsi.c linux-2.1.61/drivers/block/acsi.c
--- linux-2.1.61.orig/drivers/block/acsi.c	Fri Oct 31 18:49:10 1997
+++ linux-2.1.61/drivers/block/acsi.c	Fri Nov 14 18:23:26 1997
@@ -1874,7 +1874,7 @@
 
 static int revalidate_acsidisk( int dev, int maxusage )
 {
-	int device, major;
+	int device;
 	struct gendisk * gdev;
 	int max_p, start, i;
 	struct acsi_info_struct *aip;
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/drivers/block/acsi_slm.c linux-2.1.61/drivers/block/acsi_slm.c
--- linux-2.1.61.orig/drivers/block/acsi_slm.c	Mon Sep 29 15:44:26 1997
+++ linux-2.1.61/drivers/block/acsi_slm.c	Sat Nov 15 20:50:04 1997
@@ -252,15 +252,15 @@
 
 static char *slm_errstr( int stat );
 static int slm_getstats( char *buffer, int device );
-static long slm_read( struct inode *node, struct file* file, char *buf,
-                      unsigned long count );
+static ssize_t slm_read( struct file* file, char *buf, size_t count, loff_t
+                         *ppos );
 static void start_print( int device );
-static void slm_interrupt(int irc, void *data, struct pt_regs *fp);
+static void slm_interrupt( int irc, void *data, struct pt_regs *fp);
 static void slm_test_ready( unsigned long dummy );
 static void set_dma_addr( unsigned long paddr );
 static unsigned long get_dma_addr( void );
-static long slm_write( struct inode *node, struct file *file, const char *buf,
-                       unsigned long count );
+static ssize_t slm_write( struct file *file, const char *buf, size_t count,
+                          loff_t *ppos );
 static int slm_ioctl( struct inode *inode, struct file *file, unsigned int
                       cmd, unsigned long arg );
 static int slm_open( struct inode *inode, struct file *file );
@@ -372,10 +372,12 @@
 }
 
 
-static long slm_read( struct inode *node, struct file* file,
-					  char *buf, unsigned long count )
+static ssize_t slm_read( struct file *file, char *buf, size_t count,
+						 loff_t *ppos )
 
-{	unsigned long page;
+{
+	struct inode *node = file->f_dentry->d_inode;
+	unsigned long page;
 	int length;
 	int end;
 
@@ -625,10 +627,12 @@
 }
 
 
-static long slm_write( struct inode *node, struct file *file,
-					   const char *buf, unsigned long count )
+static ssize_t slm_write( struct file *file, const char *buf, size_t count,
+						  loff_t *ppos )
 
-{	int		device = MINOR( node->i_rdev );
+{
+	struct inode *node = file->f_dentry->d_inode;
+	int		device = MINOR( node->i_rdev );
 	int		n, filled, w, h;
 
 	while( SLMState == PRINTING ||
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/drivers/block/ataflop.c linux-2.1.61/drivers/block/ataflop.c
--- linux-2.1.61.orig/drivers/block/ataflop.c	Mon Sep 29 15:44:26 1997
+++ linux-2.1.61/drivers/block/ataflop.c	Fri Nov 14 18:25:53 1997
@@ -483,7 +483,10 @@
 	save_flags(flags);
 	cli(); /* protect against various other ints mucking around with the PSG */
 	sound_ym.rd_data_reg_sel=14;	/* Select PSG Port A */
-	sound_ym.wd_data = sound_ym.rd_data_reg_sel | 7; /* no drives selected */
+	sound_ym.wd_data = sound_ym.rd_data_reg_sel |
+					   MACH_IS_FALCON ? 3 : 7; /* no drives selected */
+	/* On Falcon, the drive B select line is used on the printer port, so
+	 * leave it alone... */
 	SelectedDrive = -1;
 	restore_flags(flags);
 }
@@ -1802,7 +1805,7 @@
 		UD.steprate = FDCSTEP_12;
 		break;
 	default: /* should be -1 for "not set by user" */
-		if (ATARIHW_PRESENT( FDCSPEED ) || is_medusa)
+		if (ATARIHW_PRESENT( FDCSPEED ) || MACH_IS_MEDUSA)
 			UD.steprate = FDCSTEP_3;
 		else
 			UD.steprate = FDCSTEP_6;
@@ -1826,8 +1829,9 @@
 	unsigned long timeout;
 	unsigned char status;
 	int ok;
-	
-	if (drive > 1) return( 0 );
+
+	/* Falcon supports only one Floppy */
+	if (drive >= MACH_IS_FALCON ? 1 : 2) return( 0 );
 	fd_select_drive( drive );
 
 	/* disable interrupt temporarily */
@@ -2019,6 +2023,10 @@
 {
 	int i;
 
+	if (MACH_IS_HADES)
+		/* Hades doesn't have Atari-compatible floppy */
+		return -ENXIO;
+
 	if (register_blkdev(MAJOR_NR,"fd",&floppy_fops)) {
 		printk(KERN_ERR "Unable to get major %d for floppy\n",MAJOR_NR);
 		return -EBUSY;
@@ -2029,7 +2037,7 @@
 		   track buffering off for all Medusas, though it
 		   could be used with ones that have a counter
 		   card. But the test is too hard :-( */
-		UseTrackbuffer = !is_medusa;
+		UseTrackbuffer = !MACH_IS_MEDUSA;
 
 	/* initialize variables */
 	SelectedDrive = -1;
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/drivers/char/atari_MFPser.c linux-2.1.61/drivers/char/atari_MFPser.c
--- linux-2.1.61.orig/drivers/char/atari_MFPser.c	Fri Oct 31 19:13:39 1997
+++ linux-2.1.61/drivers/char/atari_MFPser.c	Sun Nov 16 12:37:23 1997
@@ -119,7 +119,7 @@
   /* RSVE or RSSPEED will only recognize the 3 frequencies for 
    * 110, 134, 150 Baud, if the prescaler is 4 and the counter value does 
    * the rest. The divisors 350 and 256 can be built in multiple ways. 
-   * This driver tryes to use the largest presscaler factor possible and 
+   * This driver tries to use the largest presscaler factor possible and 
    * uses small counter values. TOS uses a presscaler factor of 4
    * ==> MFP_timer_mode = 2 ==> Index 0. Then RSVE replaces the clock 
    * correctly. Since the absolute frequencies don't have to be so accurate 
@@ -160,6 +160,8 @@
 
 static int stmfp_line = -1, ttmfp_line = -1;
 
+extern int atari_MFP_init_done;
+
 
 int atari_MFPser_init( void )
 
@@ -232,8 +234,9 @@
 		            "ST-MFP CTS", info);
 		request_irq(IRQ_MFP_RI, MFPctrl_ri_int, IRQ_TYPE_SLOW,
 		            "ST-MFP RI", info);
-		/* clear RTS and DTR */
-		GIACCESS( GI_RTS | GI_DTR );
+		if (!atari_MFP_init_done)
+			/* clear RTS and DTR */
+			GIACCESS( GI_RTS | GI_DTR );
 	}
 
 	info->sw = (type == SER_MFP_CTRL ? &MFPctrl_switch : &MFPbare_switch);
@@ -241,8 +244,10 @@
   	info->custom_divisor = 4;          /* 9600 Baud */
   	info->baud_base = MFP_BAUD_BASE;
 
-	currMFP(info)->rcv_stat  = 0;	/* disable Rx */
-	currMFP(info)->trn_stat  = 0;	/* disable Tx */
+	if (tt_flag || !atari_MFP_init_done) {
+		currMFP(info)->rcv_stat  = 0;	/* disable Rx */
+		currMFP(info)->trn_stat  = 0;	/* disable Tx */
+	}
 }
 
 
@@ -355,8 +360,9 @@
 static void MFPser_init( struct async_struct *info )
 {
 	/* base value for UCR */
-	currMFP(info)->usart_ctr = (UCR_PARITY_OFF | UCR_ASYNC_1 |
-				    UCR_CHSIZE_8 | UCR_PREDIV);
+	if (info->type != SER_MFP_CTRL || !atari_MFP_init_done)
+		currMFP(info)->usart_ctr = (UCR_PARITY_OFF | UCR_ASYNC_1 |
+									UCR_CHSIZE_8 | UCR_PREDIV);
 
 	/* enable Rx and clear any error conditions */
 	currMFP(info)->rcv_stat = RSR_RX_ENAB;
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/drivers/char/atari_SCC.c linux-2.1.61/drivers/char/atari_SCC.c
--- linux-2.1.61.orig/drivers/char/atari_SCC.c	Wed May 21 13:55:10 1997
+++ linux-2.1.61/drivers/char/atari_SCC.c	Sun Nov 16 12:40:30 1997
@@ -375,6 +375,9 @@
 	SCC_check_open
 };
 
+extern int atari_SCC_init_done;
+extern int atari_SCC_reset_done;
+
 
 int atari_SCC_init( void )
 {
@@ -399,11 +402,9 @@
 	 * channel A is fixed to a RS-232 Serial2, add code to set to
 	 * SCCA_SWITCH_SERIAL2_ONLY.
 	 */
-	if ((atari_mch_cookie >> 16) == ATARI_MCH_FALCON)
+	if (MACH_IS_FALCON)
 		SCC_chan_a_switchable = SCCA_SWITCH_LAN_ONLY;
-	else if (ATARIHW_PRESENT(TT_MFP) ||
-		 ((atari_mch_cookie >> 16) == ATARI_MCH_STE &&
-		  (atari_mch_cookie & 0xffff)))
+	else if (ATARIHW_PRESENT(TT_MFP) || MACH_IS_MSTE)
 		SCC_chan_a_switchable = SCCA_SWITCH_BOTH;
 	else
 		SCC_chan_a_switchable = SCCA_SWITCH_SERIAL2_ONLY;
@@ -553,8 +554,6 @@
 	/* Hardware initialization */
 
 	if (!called) {
-		extern int atari_SCC_reset_done;
-
 		/* Before accessing the SCC the first time, do a read to the
 		 * control register to reset the internal pointers
 		 */
@@ -1516,10 +1515,12 @@
 
 static void SCC_change_speed( struct async_struct *info )
 {
-	unsigned		cflag, baud, chsize, aflags;
-	unsigned		channel, div = 0, clkmode, brgmode, brgval;
+	/* the SCC has char sizes 5,7,6,8 in that order! */
+	static int chsize_map[4] = { 0, 2, 1, 3 };
+	unsigned cflag, baud, chsize, aflags;
+	unsigned channel, div = 0, clkmode, brgmode, brgval;
 	int clksrc = 0;
-	unsigned long	flags;
+	unsigned long flags;
 
 	if (!info->tty || !info->tty->termios) return;
 
@@ -1622,7 +1623,7 @@
 #endif
 
 	/* receiver's character size */
-	SCCmod( RX_CTRL_REG, ~RCR_CHSIZE_MASK, chsize << 6 );
+	SCCmod( RX_CTRL_REG, ~RCR_CHSIZE_MASK, chsize_map[chsize] << 6 );
 #if DEBUG & DEBUG_SPEED
 	printk( "  RX_CTRL_REG <- %02x\n", SCCread( RX_CTRL_REG ) );
 #endif
@@ -1641,7 +1642,7 @@
 
 	/* sender's character size */
 	/* Set DTR for valid baud rates! Tnx to jds@kom.auc.dk */
-	SCCmod( TX_CTRL_REG, ~TCR_CHSIZE_MASK, chsize << 5 | TCR_DTR );
+	SCCmod( TX_CTRL_REG, ~TCR_CHSIZE_MASK, chsize_map[chsize] << 5 | TCR_DTR );
 #if DEBUG & DEBUG_SPEED
 	printk( "  TX_CTRL_REG <- %02x\n", SCCread( TX_CTRL_REG ) );
 #endif
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/drivers/char/m68kserial.c linux-2.1.61/drivers/char/m68kserial.c
--- linux-2.1.61.orig/drivers/char/m68kserial.c	Fri Nov 14 18:05:57 1997
+++ linux-2.1.61/drivers/char/m68kserial.c	Sun Nov 16 14:29:46 1997
@@ -1711,7 +1711,7 @@
 	}
 	switch(parity) {
 		case 'o': case 'O':
-			cflag |= PARODD;
+			cflag |= PARENB|PARODD;
 			break;
 		case 'e': case 'E':
 			cflag |= PARENB;
@@ -1729,7 +1729,7 @@
 	NULL,			/* filled in by serial_console_init */
 	NULL,
 	serial_console_setup,
-	CON_PRINTBUFFER,
+	0 /*CON_PRINTBUFFER*/,
 	0,
 	NULL
 };
@@ -1737,6 +1737,12 @@
 extern void amiga_serial_console_write(const char *s, unsigned int count);
 extern int amiga_serial_console_wait_key(void);
 extern void amiga_init_serial_console(struct async_struct *info, int cflag);
+extern void atari_mfp_console_write (const char *str, unsigned int count);
+extern int atari_mfp_console_wait_key(void);
+extern void atari_init_mfp_port( int cflag );
+extern void atari_scc_console_write (const char *str, unsigned int count);
+extern int atari_scc_console_wait_key(void);
+extern void atari_init_scc_port( int cflag );
 
 /*
  * This is here to set the speed etc. for a non-initialized
@@ -1744,14 +1750,36 @@
  */
 long serial_console_init(long kmem_start, long kmem_end)
 {
+	/*
+	 * This sets sercons.index and serial_console_cflag
+	 * Unfortunately, register_console() also calls sercons.write for printing
+	 * the buffer. But we can't set up the write method before we know the
+	 * index... sounds like chicken and egg, doesn't it? :-) Bad design...
+	 */
+	register_console(&sercons);
+	
 	/* Currently this supports the Amiga builtin port only */
 	if (MACH_IS_AMIGA && sercons.index == 0) {
 		sercons.write = amiga_serial_console_write;
 		sercons.wait_key = amiga_serial_console_wait_key;
-		register_console(&sercons);
 		/* no initialization yet */
 		/* amiga_init_serial_console(rs_table+sercons.index, */
 		/*			     serial_console_cflag); */
+	}
+	/* On Atari, Modem1 (ttyS0) and Modem2 (ttyS1) are supported
+	 * Note: On a TT, 57.6 and 115.2 kbps are not possible and are replaced by
+	 * 76.8 and 153.6 kbps. */
+	else if (MACH_IS_ATARI && sercons.index == 0) {
+		sercons.write = atari_mfp_console_write;
+		sercons.wait_key = atari_mfp_console_wait_key;
+		atari_init_mfp_port( serial_console_cflag );
+	}
+	else if (MACH_IS_ATARI && sercons.index == 1) {
+		sercons.write = atari_scc_console_write;
+		sercons.wait_key = atari_scc_console_wait_key;
+		sercons.flags &= ~CON_ENABLED;
+		atari_init_scc_port( serial_console_cflag );
+		sercons.flags |= CON_ENABLED;
 	}
 	return kmem_start;
 }
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/drivers/char/nvram.c linux-2.1.61/drivers/char/nvram.c
--- linux-2.1.61.orig/drivers/char/nvram.c	Fri Nov 14 18:07:42 1997
+++ linux-2.1.61/drivers/char/nvram.c	Fri Nov 14 17:14:47 1997
@@ -645,7 +645,7 @@
 		PRINT_PROC( "n/a\n" );
 
 	/* the following entries are defined only for the Falcon */
-	if ((atari_mch_cookie >> 16) != ATARI_MCH_FALCON)
+	if (!MACH_IS_FALCON)
 		return 1;
 
 	PRINT_PROC( "OS language      : " );
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/drivers/scsi/atari_scsi.c linux-2.1.61/drivers/scsi/atari_scsi.c
--- linux-2.1.61.orig/drivers/scsi/atari_scsi.c	Thu Jul 17 17:45:45 1997
+++ linux-2.1.61/drivers/scsi/atari_scsi.c	Fri Nov 14 14:24:54 1997
@@ -682,7 +682,7 @@
 		atari_dma_residual = 0;
 #endif /* REAL_DMA */
 #ifdef REAL_DMA
-		if (is_medusa || is_hades) {
+		if (MACH_IS_MEDUSA || MACH_IS_HADES) {
 			/* While the read overruns (described by Drew Eckhardt in
 			 * NCR5380.c) never happened on TTs, they do in fact on the Medusa
 			 * (This was the cause why SCSI didn't work right for so long
@@ -1004,7 +1004,7 @@
 {
 	unsigned long	possible_len, limit;
 
-	if (is_hades)
+	if (MACH_IS_HADES)
 		/* Hades has no SCSI DMA at all :-( Always force use of PIO */
 		return( 0 );
 	
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/drivers/sound/dmasound.c linux-2.1.61/drivers/sound/dmasound.c
--- linux-2.1.61.orig/drivers/sound/dmasound.c	Fri Nov 14 18:05:32 1997
+++ linux-2.1.61/drivers/sound/dmasound.c	Fri Nov 14 17:09:04 1997
@@ -2614,8 +2614,7 @@
 		case SOUND_MIXER_READ_DEVMASK:
 		    return(IOCTL_OUT(arg,
 			SOUND_MASK_VOLUME | SOUND_MASK_TREBLE | SOUND_MASK_BASS |
-			((atari_mch_cookie >> 16) == ATARI_MCH_TT ?
-			    SOUND_MASK_SPEAKER : 0)));
+			(MACH_IS_TT ? SOUND_MASK_SPEAKER : 0)));
 		case SOUND_MIXER_READ_RECMASK:
 		    return(IOCTL_OUT(arg, 0));
 		case SOUND_MIXER_READ_STEREODEVS:
@@ -2631,7 +2630,7 @@
 		case SOUND_MIXER_READ_SPEAKER:
 		    {
 			int porta;
-			if ((atari_mch_cookie >> 16) == ATARI_MCH_TT) {
+			if (MACH_IS_TT) {
 			    cli();
 			    sound_ym.rd_data_reg_sel = 14;
 			    porta = sound_ym.rd_data_reg_sel;
@@ -2650,7 +2649,7 @@
 		    IOCTL_IN(arg, data);
 		    return(IOCTL_OUT(arg, sound_set_treble(data)));
 		case SOUND_MIXER_WRITE_SPEAKER:
-		    if ((atari_mch_cookie >> 16) == ATARI_MCH_TT) {
+		    if (MACH_IS_TT) {
 			int porta;
 			IOCTL_IN(arg, data);
 			cli();
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/include/asm-m68k/atarihw.h linux-2.1.61/include/asm-m68k/atarihw.h
--- linux-2.1.61.orig/include/asm-m68k/atarihw.h	Sun Nov  9 13:12:57 1997
+++ linux-2.1.61/include/asm-m68k/atarihw.h	Sun Nov 16 12:10:06 1997
@@ -21,14 +21,23 @@
 #define _LINUX_ATARIHW_H_
 
 #include <linux/types.h>
+#include <asm/bootinfo.h>
 
 extern u_long atari_mch_cookie;
+extern u_long atari_mch_type;
+extern int atari_rtc_year_offset;
 
-/* mch_cookie values (upper word) */
-#define ATARI_MCH_ST		0
-#define ATARI_MCH_STE		1
-#define ATARI_MCH_TT		2
-#define ATARI_MCH_FALCON	3
+/* convenience macros for testing machine type */
+#define MACH_IS_ST	((atari_mch_cookie >> 16) == ATARI_MCH_ST)
+#define MACH_IS_STE	((atari_mch_cookie >> 16) == ATARI_MCH_STE && \
+			 (atari_mch_cookie & 0xffff) == 0)
+#define MACH_IS_MSTE	((atari_mch_cookie >> 16) == ATARI_MCH_STE && \
+			 (atari_mch_cookie & 0xffff) == 0x10)
+#define MACH_IS_TT	((atari_mch_cookie >> 16) == ATARI_MCH_TT)
+#define MACH_IS_FALCON	((atari_mch_cookie >> 16) == ATARI_MCH_FALCON)
+#define MACH_IS_MEDUSA	(atari_mch_type == ATARI_MACH_MEDUSA)
+#define MACH_IS_HADES	(atari_mch_type == ATARI_MACH_HADES)
+#define MACH_IS_AB40	(atari_mch_type == ATARI_MACH_AB40)
 
 /*
  * Define several Hardware-Chips for indication so that for the ATARI we do
@@ -97,9 +106,6 @@
 void *atari_stram_alloc (long size, unsigned long *start_mem );
 void atari_stram_free (void *);
 
-extern int is_medusa;
-extern int is_hades;
-
 /* Do cache push/invalidate for DMA read/write. This function obeys the
  * snooping on some machines (Medusa) and processors: The Medusa itself can
  * snoop, but only the '040 can source data from its cache to DMA writes i.e.,
@@ -116,11 +122,11 @@
 
 {
 	if (writeflag) {
-		if (!is_medusa || CPU_IS_060)
+		if (!MACH_IS_MEDUSA || CPU_IS_060)
 			cache_push( paddr, len );
 	}
 	else {
-		if (!is_medusa)
+		if (!MACH_IS_MEDUSA)
 			cache_clear( paddr, len );
 	}
 }
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/include/asm-m68k/bootinfo.h linux-2.1.61/include/asm-m68k/bootinfo.h
--- linux-2.1.61.orig/include/asm-m68k/bootinfo.h	Sun Nov  9 13:21:56 1997
+++ linux-2.1.61/include/asm-m68k/bootinfo.h	Fri Nov 14 18:44:45 1997
@@ -93,7 +93,20 @@
      */
 
 #define BI_ATARI_MCH_COOKIE	0x8000	/* _MCH cookie from TOS (u_long) */
+#define BI_ATARI_MCH_TYPE	0x8001	/* special machine type (u_long) */
+					/* (values are ATARI_MACH_* defines */
 
+/* mch_cookie values (upper word) */
+#define ATARI_MCH_ST		0
+#define ATARI_MCH_STE		1
+#define ATARI_MCH_TT		2
+#define ATARI_MCH_FALCON	3
+
+/* mch_type values */
+#define ATARI_MACH_NORMAL	0	/* no special machine type */
+#define ATARI_MACH_MEDUSA	1	/* Medusa 040 */
+#define ATARI_MACH_HADES	2	/* Hades 040 or 060 */
+#define ATARI_MACH_AB40		3	/* Afterburner040 on Falcon */
 
     /*
      * Stuff for bootinfo interface versioning
@@ -129,7 +142,7 @@
 #endif /* __ASSEMBLY__ */
 
 #define AMIGA_BOOTI_VERSION    MK_BI_VERSION( 2, 0 )
-#define ATARI_BOOTI_VERSION    MK_BI_VERSION( 2, 0 )
+#define ATARI_BOOTI_VERSION    MK_BI_VERSION( 2, 1 )
 
 
 #ifdef BOOTINFO_COMPAT_1_0
diff -u --recursive --exclude-from=diff-excludes --new-file linux-2.1.61.orig/include/linux/mc146818rtc.h linux-2.1.61/include/linux/mc146818rtc.h
--- linux-2.1.61.orig/include/linux/mc146818rtc.h	Fri Nov 14 18:08:17 1997
+++ linux-2.1.61/include/linux/mc146818rtc.h	Sun Nov 16 12:11:20 1997
@@ -26,21 +26,18 @@
 				 * to deal with both modes */
 
 #define RTC_CHECK_DRIVER_INIT() (MACH_IS_ATARI && ATARIHW_PRESENT(TT_CLK))
-#define RTC_MACH_VARIABLES \
-    static int leap_year_fix;
+#define RTC_MACH_VARIABLES
 #define RTC_MACH_INIT()							\
     do {								\
 	if (RTC_HAS_IRQ)						\
 	    /* select RTC int on H->L edge */				\
 	    tt_mfp.active_edge &= ~0x40;				\
-	leap_year_fix = (is_medusa || is_hades ||			\
-			 *(short *)0xff000002 >= 0x306);		\
     } while(0)
 
 /* On Atari, the year was stored with base 1970 in old TOS versions (before
  * 3.06). Later, Atari recognized that this broke leap year recognition, and
  * changed the base to 1968. Medusa and Hades always use the new version. */
-#define RTC_YEAR_BASE 		(leap_year_fix ? 68 : 70)
+#define RTC_YEAR_BASE 		atari_rtc_year_offset
 #define RTC_CENTURY_SWITCH	-1	/* no century switch */
 #define RTC_MINYEAR		(RTC_YEAR_BASE + 1900)
 

