From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Date: Mon, 28 Apr 97 10:26:12 +0200
To: linux-m68k@phil.uni-sb.de
Subject: L68K: Linux 2.1.35
X-Yow: The FALAFEL SANDWICH lands on my HEAD and I become a VEGETARIAN...
Sender: owner-linux-m68k@phil.uni-sb.de
Reply-To: linux-m68k@phil.uni-sb.de

Hi!

Here is my patch for 2.1.35.  Most of it is for exploiting the new init
section feature (saves about 4 pages in my kernel, after applying the
2.1.36 patch).  About the other changes:

- arch/m68k/kernel/process.c: Block out hblank interrupt on the falcon,
  otherwise the stop is pretty useless.  Tell gcc that the condition codes
  are clobbered, just in case.
- arch/m68k/kernel/signal.c: From 2.1.36, sys_waitpid is just a wrapper
  for sys_wait4.
- arch/m68k/kernel/time.c, fs/proc/array.c: Reenable kernel profiling.
- include/asm-m68k/hardirq.h: Include <linux/tasks.h> for NR_CPUS.
- include/asm-m68k/semaphore.h: Use cas if possible.
- include/asm-m68k/softirq.h: Include <linux/atomic.h> for
  atomic_clear_mask.
- include/linux/linkage.h: Remove support for non-elf.

Andreas.

----------------------------------------------------------------------
table
`!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
--- arch/m68k/Makefile.~1~	Mon Apr 14 17:59:51 1997
+++ arch/m68k/Makefile	Sat Apr 26 01:21:40 1997
@@ -24,18 +24,8 @@
 	CROSS_COMPILE = m68k-linux-
 endif
 
-#
-# Set these to indicate how to link it..
-#
-# -zmagic:   
-#
-# LINKFLAGS    = -Ttext 0x100000
-#
-# -qmagic (we need to remove the 32 byte header for bootup purposes)
-#
+LINKFLAGS = -T $(TOPDIR)/arch/m68k/vmlinux.lds
 
-LINKFLAGS = -Ttext 0x1000
-
 CFLAGS := $(CFLAGS) -pipe -fno-strength-reduce
 
 ifdef CONFIG_OPTIMIZE_040
--- arch/m68k/atari/atafb.c.~1~	Sat Apr 26 00:10:34 1997
+++ arch/m68k/atari/atafb.c	Fri Apr 18 21:13:47 1997
@@ -46,6 +46,7 @@
 #include <linux/tty.h>
 #include <linux/malloc.h>
 #include <linux/delay.h>
+#include <linux/init.h>
 
 #include <asm/setup.h>
 #include <asm/uaccess.h>
@@ -2911,7 +2912,7 @@
 	return(atari_fb_set_cmap(cmap, 1, con));
 }
 
-struct fb_info *
+struct fb_info * __init
 atari_fb_init(long *mem_start)
 {
 	int err;
--- arch/m68k/atari/ataints.c.~1~	Sat Apr 26 00:10:35 1997
+++ arch/m68k/atari/ataints.c	Sat Apr 19 05:06:05 1997
@@ -39,6 +39,7 @@
 #include <linux/kernel.h>
 #include <linux/ptrace.h>
 #include <linux/kernel_stat.h>
+#include <linux/init.h>
 
 #include <asm/system.h>
 #include <asm/traps.h>
@@ -331,7 +332,7 @@
  * the atari IRQ handling routines.
  */
 
-void atari_init_IRQ(void)
+void __init atari_init_IRQ(void)
 {
 	int i;
 
--- arch/m68k/atari/atakeyb.c.~1~	Sat Apr 26 00:10:35 1997
+++ arch/m68k/atari/atakeyb.c	Fri Apr 18 21:12:54 1997
@@ -22,6 +22,7 @@
 #include <linux/timer.h>
 #include <linux/kd.h>
 #include <linux/random.h>
+#include <linux/init.h>
 
 #include <asm/atariints.h>
 #include <asm/atarihw.h>
@@ -804,7 +805,7 @@
  * Martin Rogge, 20 Aug 1995
  */
  
-int atari_keyb_init(void)
+int __init atari_keyb_init(void)
 {
     /* setup key map */
     key_maps[0]  = ataplain_map;
--- arch/m68k/atari/config.c.~1~	Sat Apr 26 00:10:36 1997
+++ arch/m68k/atari/config.c	Fri Apr 18 21:15:08 1997
@@ -32,6 +32,7 @@
 #include <linux/tty.h>
 #include <linux/console.h>
 #include <linux/interrupt.h>
+#include <linux/init.h>
 
 #include <asm/bootinfo.h>
 #include <asm/setup.h>
@@ -106,7 +107,7 @@
  * a temporary VBR and a vector table for the duration of the test.
  */
 
-static int hwreg_present( volatile void *regp )
+static int __init hwreg_present( volatile void *regp )
 {
     int	ret = 0;
     long	save_sp, save_vbr;
@@ -132,9 +133,8 @@
 }
   
 #if 0
-static int hwreg_present_bywrite( volatile void *regp,
-				 unsigned char val )
-
+static int __init
+hwreg_present_bywrite(volatile void *regp, unsigned char val)
 {
     int		ret;
     long	save_sp, save_vbr;
@@ -166,7 +166,7 @@
 /* Basically the same, but writes a value into a word register, protected
  * by a bus error handler */
 
-static int hwreg_write( volatile void *regp, unsigned short val )
+static int __init hwreg_write( volatile void *regp, unsigned short val )
 {
 	int		ret;
 	long	save_sp, save_vbr;
@@ -201,7 +201,7 @@
  * should be readable without trouble (from channel A!).
  */
 
-static int scc_test( volatile char *ctla )
+static int __init scc_test( volatile char *ctla )
 {
 	if (!hwreg_present( ctla ))
 		return( 0 );
@@ -228,7 +228,7 @@
      *  Parse an Atari-specific record in the bootinfo
      */
 
-int atari_parse_bootinfo(const struct bi_record *record)
+int __init atari_parse_bootinfo(const struct bi_record *record)
 {
     int unknown = 0;
     const u_long *data = record->data;
@@ -247,7 +247,7 @@
      *  Setup the Atari configuration info
      */
 
-void config_atari(void)
+void __init config_atari(void)
 {
     memset(&atari_hw_present, 0, sizeof(atari_hw_present));
 
@@ -493,7 +493,8 @@
     }
 }
 
-static void atari_sched_init(void (*timer_routine)(int, void *, struct pt_regs *))
+static void __init
+atari_sched_init(void (*timer_routine)(int, void *, struct pt_regs *))
 {
     /* set Timer C data Register */
     mfp.tim_dt_c = INT_TICKS;
@@ -976,7 +977,7 @@
 }
 
 
-static void atari_debug_init(void)
+static void __init atari_debug_init(void)
 {
 #ifdef CONFIG_KGDB
 	/* if the m68k_debug_device is used by the GDB stub, do nothing here */
--- arch/m68k/atari/joystick.c.~1~	Wed Apr  9 19:58:22 1997
+++ arch/m68k/atari/joystick.c	Fri Apr 18 21:12:15 1997
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/major.h>
 #include <linux/poll.h>
+#include <linux/init.h>
 
 #include <asm/atarikb.h>
 #include <asm/atari_joystick.h>
@@ -128,7 +129,7 @@
 	release_joystick
 };
 
-int atari_joystick_init(void)
+int __init atari_joystick_init(void)
 {
     joystick[0].active = joystick[1].active = 0;
     joystick[0].ready = joystick[1].ready = 0;
--- arch/m68k/atari/stdma.c.~1~	Mon Nov 18 20:29:25 1996
+++ arch/m68k/atari/stdma.c	Fri Apr 18 21:12:07 1997
@@ -32,6 +32,8 @@
 #include <linux/types.h>
 #include <linux/genhd.h>
 #include <linux/sched.h>
+#include <linux/init.h>
+
 #include <asm/atari_stdma.h>
 #include <asm/atariints.h>
 #include <asm/atarihw.h>
@@ -171,7 +173,7 @@
  *
  */
 
-void stdma_init(void)
+void __init stdma_init(void)
 {
 	stdma_isr = NULL;
 	request_irq(IRQ_MFP_FDC, stdma_int, IRQ_TYPE_SLOW,
--- arch/m68k/atari/stram.c.~1~	Mon Nov 11 22:37:17 1996
+++ arch/m68k/atari/stram.c	Fri Apr 18 21:13:39 1997
@@ -149,6 +149,7 @@
 #else
 
 #include <linux/mm.h>
+#include <linux/init.h>
 
 /* ++roman:
  * 
@@ -190,7 +191,7 @@
     /* Overall end of ST-Ram */
 
 
-void atari_stram_init( void )
+void __init atari_stram_init( void )
 
 {	int		i;
 
--- arch/m68k/kernel/ints.c.~1~	Sat Apr 26 00:10:40 1997
+++ arch/m68k/kernel/ints.c	Sat Apr 26 00:32:12 1997
@@ -29,6 +29,7 @@
 #include <linux/sched.h>
 #include <linux/kernel_stat.h>
 #include <linux/errno.h>
+#include <linux/init.h>
 
 #include <asm/system.h>
 #include <asm/irq.h>
@@ -79,7 +80,7 @@
  * the IRQ handling routines.
  */
 
-void init_IRQ(void)
+void __init init_IRQ(void)
 {
 	int i;
 
--- arch/m68k/kernel/m68k_ksyms.c.~1~	Sat Apr 26 00:10:41 1997
+++ arch/m68k/kernel/m68k_ksyms.c	Sat Apr 26 00:32:35 1997
@@ -7,6 +7,7 @@
 #include <linux/user.h>
 #include <linux/elfcore.h>
 #include <linux/in6.h>
+#include <linux/interrupt.h>
 
 #include <asm/setup.h>
 #include <asm/machdep.h>
@@ -15,6 +16,7 @@
 #include <asm/semaphore.h>
 #include <asm/checksum.h>
 #include <asm/hardirq.h>
+#include <asm/softirq.h>
 
 asmlinkage long long __ashrdi3 (long long, int);
 extern char m68k_debug_device[];
@@ -41,6 +43,7 @@
 EXPORT_SYMBOL(strrchr);
 EXPORT_SYMBOL(strstr);
 EXPORT_SYMBOL(local_irq_count);
+EXPORT_SYMBOL(__m68k_bh_counter);
 
 /* Networking helper routines. */
 EXPORT_SYMBOL(csum_partial_copy);
--- arch/m68k/kernel/process.c.~1~	Sat Apr 26 00:10:41 1997
+++ arch/m68k/kernel/process.c	Sat Apr 26 00:38:19 1997
@@ -10,6 +10,7 @@
  * This file handles the architecture-dependent parts of process handling..
  */
 
+#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
@@ -48,13 +49,12 @@
 	current->counter = -100;
 	for (;;){
 		if (!need_resched)
-			/*
-			 * As long as the following code does not
-			 * depend on the condition codes there is no
-			 * reason to save_flags() etc.
-			 */
-
-			__asm__("stop #0x2000");
+#if defined(CONFIG_ATARI) && !defined(CONFIG_AMIGA) && !defined(CONFIG_MAC)
+			/* block out HSYNC on the atari (falcon) */
+			__asm__("stop #0x2200" : : : "cc");
+#else /* portable version */
+			__asm__("stop #0x2000" : : : "cc");
+#endif /* machine compilation types */ 
 		schedule();
 	}
 	ret = 0;
--- arch/m68k/kernel/setup.c.~1~	Sat Apr 26 00:10:42 1997
+++ arch/m68k/kernel/setup.c	Fri Apr 18 22:34:21 1997
@@ -18,6 +18,7 @@
 #include <linux/genhd.h>
 #include <linux/errno.h>
 #include <linux/string.h>
+#include <linux/init.h>
 
 #include <asm/bootinfo.h>
 #include <asm/setup.h>
@@ -55,13 +56,13 @@
 static char m68k_command_line[CL_SIZE];
 char saved_command_line[CL_SIZE];
 
-void (*mach_sched_init) (void (*handler)(int, void *, struct pt_regs *));
+void (*mach_sched_init) (void (*handler)(int, void *, struct pt_regs *)) __initdata;
 /* machine dependent keyboard functions */
-int (*mach_keyb_init) (void);
+int (*mach_keyb_init) (void) __initdata;
 int (*mach_kbdrate) (struct kbd_repeat *) = NULL;
 void (*mach_kbd_leds) (unsigned int) = NULL;
 /* machine dependent irq functions */
-void (*mach_init_IRQ) (void);
+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;
@@ -73,12 +74,12 @@
 int (*mach_hwclk) (int, struct hwclk_time*) = NULL;
 int (*mach_set_clock_mmss) (unsigned long) = NULL;
 void (*mach_reset)( void );
-struct fb_info *(*mach_fb_init)(long *);
+struct fb_info *(*mach_fb_init)(long *) __initdata;
 long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
-void (*mach_video_setup) (char *, int *);
+void (*mach_video_setup) (char *, int *) __initdata;
 #ifdef CONFIG_BLK_DEV_FD
-int (*mach_floppy_init) (void) = NULL;
-void (*mach_floppy_setup) (char *, int *) = NULL;
+int (*mach_floppy_init) (void) __initdata = NULL;
+void (*mach_floppy_setup) (char *, int *) __initdata = NULL;
 void (*mach_floppy_eject) (void) = NULL;
 #endif
 
@@ -94,7 +95,7 @@
 #define MASK_256K 0xfffc0000
 
 
-static void m68k_parse_bootinfo(const struct bi_record *record)
+static void __init m68k_parse_bootinfo(const struct bi_record *record)
 {
     while (record->tag != BI_LAST) {
 	int unknown = 0;
@@ -141,7 +142,7 @@
     }
 }
 
-void setup_arch(char **cmdline_p, unsigned long * memory_start_p,
+void __init setup_arch(char **cmdline_p, unsigned long * memory_start_p,
 		unsigned long * memory_end_p)
 {
 	unsigned long memory_start, memory_end;
@@ -337,7 +338,7 @@
 }
 
 #ifdef CONFIG_BLK_DEV_FD
-int floppy_init(void)
+int __init floppy_init(void)
 {
 	if (mach_floppy_init)
 		return mach_floppy_init();
@@ -345,7 +346,7 @@
 		return 0;
 }
 
-void floppy_setup(char *str, int *ints)
+void __init floppy_setup(char *str, int *ints)
 {
 	if (mach_floppy_setup)
 		mach_floppy_setup (str, ints);
@@ -358,7 +359,7 @@
 }
 #endif
 
-unsigned long arch_kbd_init(void)
+unsigned long __init arch_kbd_init(void)
 {
 	return mach_keyb_init();
 }
@@ -372,7 +373,7 @@
 		*year = *mon = *day = *hour = *min = *sec = 0;
 }
 
-void video_setup (char *options, int *ints)
+void __init video_setup (char *options, int *ints)
 {
 	if (mach_video_setup)
 		mach_video_setup (options, ints);
--- arch/m68k/kernel/signal.c.~1~	Wed Jan 15 17:39:49 1997
+++ arch/m68k/kernel/signal.c	Sat Apr 26 01:26:22 1997
@@ -42,7 +42,9 @@
 
 #define _BLOCKABLE (~(_S(SIGKILL) | _S(SIGSTOP)))
 
-asmlinkage int sys_waitpid(pid_t pid,unsigned long * stat_addr, int options);
+asmlinkage int sys_wait4(pid_t pid, unsigned long *stat_addr,
+			 int options, unsigned long *ru);
+
 asmlinkage int do_signal(unsigned long oldmask, struct pt_regs *regs);
 
 const int frame_extra_sizes[16] = {
@@ -466,7 +468,7 @@
 			if (signr != SIGCHLD)
 				continue;
 			/* check for SIGCHLD: it's special */
-			while (sys_waitpid(-1,NULL,WNOHANG) > 0)
+			while (sys_wait4(-1,NULL,WNOHANG, NULL) > 0)
 				/* nothing */;
 			continue;
 		}
--- arch/m68k/kernel/time.c.~1~	Tue Nov 19 19:52:48 1996
+++ arch/m68k/kernel/time.c	Wed Apr 16 21:54:38 1997
@@ -27,6 +27,24 @@
   return -1;
 }
 
+static inline void do_profile (unsigned long pc)
+{
+	if (prof_buffer && current->pid) {
+		extern int _stext;
+		pc -= (unsigned long) &_stext;
+		pc >>= prof_shift;
+		if (pc < prof_len)
+			++prof_buffer[pc];
+		else
+		/*
+		 * Dont ignore out-of-bounds PC values silently,
+		 * put them into the last histogram slot, so if
+		 * present, they will show up as a sharp peak.
+		 */
+			++prof_buffer[prof_len-1];
+	}
+}
+
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "do_timer()" routine every clocktick
@@ -37,6 +55,9 @@
 	static long last_rtc_update=0;
 
 	do_timer(regs);
+
+	if (!user_mode(regs))
+		do_profile(regs->pc);
 
 	/*
 	 * If we have an externally synchronized Linux clock, then update
--- arch/m68k/kernel/traps.c.~1~	Sat Apr 26 00:10:42 1997
+++ arch/m68k/kernel/traps.c	Fri Apr 18 22:30:44 1997
@@ -27,6 +27,7 @@
 #include <linux/user.h>
 #include <linux/string.h>
 #include <linux/linkage.h>
+#include <linux/init.h>
 
 #include <asm/setup.h>
 #include <asm/fpu.h>
@@ -63,7 +64,7 @@
     __ALIGN_STR "\n"
     SYMBOL_NAME_STR(nmihandler) ": rte");
 
-void trap_init (void)
+void __init trap_init (void)
 {
 	int i;
 
--- arch/m68k/mm/init.c.~1~	Sat Apr 26 00:10:43 1997
+++ arch/m68k/mm/init.c	Fri Apr 18 21:16:47 1997
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/types.h>
+#include <linux/init.h>
 #ifdef CONFIG_BLK_DEV_RAM
 #include <linux/blk.h>
 #endif
@@ -116,9 +117,8 @@
 	return ptablep;
 }
 
-static unsigned long map_chunk (unsigned long addr,
-				unsigned long size,
-				unsigned long *memavailp)
+static unsigned long __init
+map_chunk (unsigned long addr, unsigned long size, unsigned long *memavailp)
 {
 #define ONEMEG	(1024*1024)
 #define L3TREESIZE (256*1024)
@@ -283,6 +283,11 @@
 
 extern unsigned long free_area_init(unsigned long, unsigned long);
 
+/* References to section boundaries */
+
+extern char _text, _etext, _edata, __bss_start, _end;
+extern char __init_begin, __init_end;
+
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 
 /*
@@ -291,7 +296,7 @@
  * The parameters are pointers to where to stick the starting and ending
  * addresses  of available kernel virtual memory.
  */
-unsigned long paging_init(unsigned long start_mem, unsigned long end_mem)
+unsigned long __init paging_init(unsigned long start_mem, unsigned long end_mem)
 {
 	int chunk;
 	unsigned long mem_avail = 0;
@@ -395,12 +400,12 @@
 	return PAGE_ALIGN(free_area_init (start_mem, end_mem));
 }
 
-void mem_init(unsigned long start_mem, unsigned long end_mem)
+void __init mem_init(unsigned long start_mem, unsigned long end_mem)
 {
 	int codepages = 0;
 	int datapages = 0;
+	int initpages = 0;
 	unsigned long tmp;
-	extern int _etext;
 
 	end_mem &= PAGE_MASK;
 	high_memory = (void *) end_mem;
@@ -448,8 +453,15 @@
 		if (VTOP (tmp) >= mach_max_dma_address)
 			clear_bit(PG_DMA, &mem_map[MAP_NR(tmp)].flags);
 		if (PageReserved(mem_map+MAP_NR(tmp))) {
-			if (tmp < (unsigned long)&_etext)
-				codepages++;
+			if (tmp >= (unsigned long)&_text
+			    && tmp < (unsigned long)&_edata) {
+				if (tmp < (unsigned long) &_etext)
+					codepages++;
+				else
+					datapages++;
+			} else if (tmp >= (unsigned long) &__init_begin
+				   && tmp < (unsigned long) &__init_end)
+				initpages++;
 			else
 				datapages++;
 			continue;
@@ -461,16 +473,24 @@
 #endif
 			free_page(tmp);
 	}
-	printk("Memory: %luk/%luk available (%dk kernel code, %dk data)\n",
+	printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n",
 	       (unsigned long) nr_free_pages << (PAGE_SHIFT-10),
 	       max_mapnr << (PAGE_SHIFT-10),
 	       codepages << (PAGE_SHIFT-10),
-	       datapages << (PAGE_SHIFT-10));
+	       datapages << (PAGE_SHIFT-10),
+	       initpages << (PAGE_SHIFT-10));
 }
 
 void free_initmem(void)
 {
-	/* To be written */
+	unsigned long addr;
+	
+	addr = (unsigned long)&__init_begin;
+	for (; addr < (unsigned long)&__init_end; addr += PAGE_SIZE) {
+		mem_map[MAP_NR(addr)].flags &= ~(1 << PG_reserved);
+		atomic_set(&mem_map[MAP_NR(addr)].count, 1);
+		free_page(addr);
+	}
 }
 
 void si_meminfo(struct sysinfo *val)
--- /dev/null	Fri Apr 29 15:43:48 1994
+++ arch/m68k/vmlinux.lds	Fri Apr 18 20:25:48 1997
@@ -0,0 +1,56 @@
+/* ld script to make m68k Linux kernel */
+OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
+OUTPUT_ARCH(m68k)
+ENTRY(_start)
+SECTIONS
+{
+  . = 0x1000;
+  _text = .;			/* Text and read-only data */
+  .text : {
+	*(.text)
+	*(.fixup)
+	*(.gnu.warning)
+	} = 0x4e75
+  .rodata : { *(.rodata) }
+  .kstrtab : { *(.kstrtab) }
+
+  . = ALIGN(16);		/* Exception table */
+  __start___ex_table = .;
+  __ex_table : { *(__ex_table) }
+  __stop___ex_table = .;
+
+  __start___ksymtab = .;	/* Kernel symbol table */
+  __ksymtab : { *(__ksymtab) }
+  __stop___ksymtab = .;
+
+  _etext = .;			/* End of text section */
+
+  .data : {			/* Data */
+	*(.data)
+	CONSTRUCTORS
+	}
+
+  _edata = .;			/* End of data section */
+
+  . = ALIGN(4096);		/* Init code and data */
+  __init_begin = .;
+  .text.init : { *(.text.init) }
+  .data.init : { *(.data.init) }
+  . = ALIGN(4096);
+  __init_end = .;
+
+  __bss_start = .;		/* BSS */
+  .bss : {
+	*(.bss)
+	}
+  _end = . ;
+
+  /* Stabs debugging sections.  */
+  .stab 0 : { *(.stab) }
+  .stabstr 0 : { *(.stabstr) }
+  .stab.excl 0 : { *(.stab.excl) }
+  .stab.exclstr 0 : { *(.stab.exclstr) }
+  .stab.index 0 : { *(.stab.index) }
+  .stab.indexstr 0 : { *(.stab.indexstr) }
+  .comment 0 : { *(.comment) }
+}
--- drivers/block/ataflop.c.~1~	Sat Apr 26 00:11:23 1997
+++ drivers/block/ataflop.c	Sat Apr 19 09:13:21 1997
@@ -75,6 +75,7 @@
 #include <linux/delay.h>
 #include <linux/mm.h>
 #include <linux/malloc.h>
+#include <linux/init.h>
 
 #include <asm/setup.h>
 #include <asm/system.h>
@@ -1777,7 +1778,7 @@
 
 /* Initialize the 'unit' variable for drive 'drive' */
 
-static void fd_probe( int drive )
+static void __init fd_probe( int drive )
 {
 	UD.connected = 0;
 	UDT  = NULL;
@@ -1820,7 +1821,7 @@
  * declared absent.
  */
 
-static int fd_test_drive_present( int drive )
+static int __init fd_test_drive_present( int drive )
 {
 	unsigned long timeout;
 	unsigned char status;
@@ -1867,7 +1868,7 @@
  * floppies, additionally start the disk-change and motor-off timers.
  */
 
-static void config_types( void )
+static void __init config_types( void )
 {
 	int drive, cnt = 0;
 
@@ -2010,7 +2011,7 @@
 	floppy_revalidate,	/* revalidate */
 };
 
-int atari_floppy_init (void)
+int __init atari_floppy_init (void)
 {
 	int i;
 
@@ -2070,7 +2071,7 @@
 }
 
 
-void atari_floppy_setup( char *str, int *ints )
+void __init atari_floppy_setup( char *str, int *ints )
 {
 	int i;
 	
--- drivers/char/atarimouse.c.~1~	Wed Apr  9 20:09:02 1997
+++ drivers/char/atarimouse.c	Sat Apr 19 09:13:06 1997
@@ -20,6 +20,7 @@
 #include <linux/mm.h>
 #include <linux/random.h>
 #include <linux/poll.h>
+#include <linux/init.h>
 
 #include <asm/setup.h>
 #include <asm/atarikb.h>
@@ -158,7 +159,7 @@
     ATARIMOUSE_MINOR, "atarimouse", &atari_mouse_fops
 };
 
-int atari_mouse_init(void)
+int __init atari_mouse_init(void)
 {
     mouse.active = 0;
     mouse.ready = 0;
@@ -175,7 +176,7 @@
 #define	MIN_THRESHOLD 1
 #define	MAX_THRESHOLD 20	/* more seems not reasonable... */
 
-void atari_mouse_setup( char *str, int *ints )
+void __init atari_mouse_setup( char *str, int *ints )
 {
     if (ints[0] < 1) {
 	printk( "atari_mouse_setup: no arguments!\n" );
--- drivers/char/m68kserial.c.~1~	Mon Mar 10 18:20:10 1997
+++ drivers/char/m68kserial.c	Sat Apr 26 01:41:54 1997
@@ -70,6 +70,7 @@
 #include <linux/fcntl.h>
 #include <linux/ptrace.h>
 #include <linux/mm.h>
+#include <linux/init.h>
 #ifdef CONFIG_PROC_FS
 #include <linux/proc_fs.h>
 #endif
@@ -1345,7 +1346,7 @@
  * number, and identifies which options were configured into this
  * driver.
  */
-static void show_serial_version(void)
+static inline void show_serial_version(void)
 {
 	printk(KERN_INFO "M68K Serial driver version 1.01\n");
 }
@@ -1360,7 +1361,7 @@
 /*
  * The serial driver boot-time initialization code!
  */
-int rs_init(void)
+int __init rs_init(void)
 {
 	int i, rs_count;
 	struct async_struct * info;
--- drivers/scsi/atari_NCR5380.c.~1~	Sat Apr 26 00:12:01 1997
+++ drivers/scsi/atari_NCR5380.c	Sat Apr 26 18:19:52 1997
@@ -323,7 +323,7 @@
 static TAG_ALLOC TagAlloc[8][8]; /* 8 targets and 8 LUNs */
 
 
-static void init_tags( void )
+static void __init init_tags( void )
 {
     int target, lun;
     TAG_ALLOC *ta;
@@ -665,7 +665,7 @@
 }
 
 
-static void NCR5380_all_init (void)
+static inline void NCR5380_all_init (void)
 {
     static int done = 0;
     if (!done) {
@@ -684,7 +684,7 @@
  * Inputs : instance, pointer to this instance.  Unused.
  */
 
-static void NCR5380_print_options (struct Scsi_Host *instance)
+static void __init NCR5380_print_options (struct Scsi_Host *instance)
 {
     printk(" generic options"
 #ifdef AUTOSENSE 
@@ -848,7 +848,7 @@
  * 
  */
 
-static void NCR5380_init (struct Scsi_Host *instance, int flags)
+static void __init NCR5380_init (struct Scsi_Host *instance, int flags)
 {
     int i;
     SETUP_HOSTDATA(instance);
--- drivers/scsi/atari_scsi.c.~1~	Sat Apr 26 00:12:02 1997
+++ drivers/scsi/atari_scsi.c	Sat Apr 26 00:42:47 1997
@@ -89,6 +89,7 @@
 #include <linux/blk.h>
 #include <linux/sched.h>
 #include <linux/interrupt.h>
+#include <linux/init.h>
 
 #include <asm/setup.h>
 #include <asm/atarihw.h>
@@ -765,7 +766,7 @@
 }
 #endif
 
-void atari_scsi_setup( char *str, int *ints )
+void __init atari_scsi_setup( char *str, int *ints )
 {
 	/* Format of atascsi parameter is:
 	 *   atascsi=<can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>
@@ -869,7 +870,7 @@
 }
 
 	
-static void atari_scsi_reset_boot( void )
+static void __init atari_scsi_reset_boot( void )
 {
 	unsigned long end;
 	
--- fs/proc/array.c.~1~	Sat Apr 26 00:12:19 1997
+++ fs/proc/array.c	Wed Apr 16 21:57:26 1997
@@ -155,10 +155,6 @@
 	return read;
 }
 
-#ifdef __SMP__
-
-extern int setup_profiling_timer (unsigned int multiplier);
-
 /*
  * Writing to /proc/profile resets the counters
  *
@@ -170,6 +166,9 @@
 {
 	int i=prof_len;
 
+#ifdef __SMP__
+	extern int setup_profiling_timer (unsigned int multiplier);
+
 	if (count==sizeof(int)) {
 		unsigned int multiplier;
 
@@ -179,14 +178,12 @@
 		if (setup_profiling_timer(multiplier))
 			return -EINVAL;
 	}
+#endif
   
 	while (i--)
 		prof_buffer[i]=0UL;
 	return count;
 }
-#else
-#define write_profile NULL
-#endif
 
 static struct file_operations proc_profile_operations = {
 	NULL,           /* lseek */
--- include/asm-m68k/hardirq.h.~1~	Mon Apr 14 19:30:54 1997
+++ include/asm-m68k/hardirq.h	Wed Apr 16 18:33:43 1997
@@ -1,11 +1,13 @@
 #ifndef __M68K_HARDIRQ_H
 #define __M68K_HARDIRQ_H
 
+#include <linux/tasks.h>
+
 extern unsigned int local_irq_count[NR_CPUS];
 #define in_interrupt()	(local_irq_count[smp_processor_id()] != 0)
 
-#define hardirq_trylock(cpu)	((cpu)==0)	/* always true */
-#define hardirq_endlock(cpu)	do { } while (0)
+#define hardirq_trylock(cpu)	(++local_irq_count[cpu], (cpu) == 0)
+#define hardirq_endlock(cpu)	(--local_irq_count[cpu])
 
 #define hardirq_enter(cpu)	(local_irq_count[cpu]++)
 #define hardirq_exit(cpu)	(local_irq_count[cpu]--)
--- include/asm-m68k/init.h.~1~	Sat Apr 26 00:12:28 1997
+++ include/asm-m68k/init.h	Sat Apr 26 02:01:55 1997
@@ -1,14 +1,14 @@
 #ifndef _M68K_INIT_H
 #define _M68K_INIT_H
 
-/* Throwing the initialization code and data out is not supported yet... */
-
-#define	__init
-#define __initdata
-#define __initfunc(__arginit) __arginit
+#define __init __attribute__ ((__section__ (".text.init")))
+#define __initdata __attribute__ ((__section__ (".data.init")))
+#define __initfunc(__arginit) \
+	__arginit __init; \
+	__arginit
 /* For assembly routines */
-#define __INIT
-#define __FINIT
-#define __INITDATA
+#define __INIT		.section	".text.init",#alloc,#execinstr
+#define __FINIT		.previous
+#define __INITDATA	.section	".data.init",#alloc,#write
 
 #endif
--- include/asm-m68k/semaphore.h.~1~	Sat Apr 26 00:12:28 1997
+++ include/asm-m68k/semaphore.h	Sat Apr 26 01:59:35 1997
@@ -1,6 +1,7 @@
 #ifndef _M68K_SEMAPHORE_H
 #define _M68K_SEMAPHORE_H
 
+#include <linux/config.h>
 #include <linux/linkage.h>
 #include <asm/system.h>
 #include <asm/atomic.h>
@@ -38,6 +39,7 @@
 
 static inline int waking_non_zero(struct semaphore *sem)
 {
+#ifndef CONFIG_RMW_INSNS
 	unsigned long flags;
 	int ret = 0;
 
@@ -48,6 +50,21 @@
 		ret = 1;
 	}
 	restore_flags(flags);
+#else
+	int ret, tmp;
+
+	__asm__ __volatile__
+	  ("1:	movel	%2,%0\n"
+	   "	jeq	3f\n"
+	   "2:	movel	%0,%1\n"
+	   "	subql	#1,%1\n"
+	   "	casl	%0,%1,%2\n"
+	   "	jeq	3f\n"
+	   "	tstl	%0\n"
+	   "	jne	2b\n"
+	   "3:"
+	   : "=d" (ret), "=d" (tmp), "=m" (sem->waking));
+#endif
 	return ret;
 }
 
--- include/asm-m68k/softirq.h.~1~	Sat Apr 26 00:12:29 1997
+++ include/asm-m68k/softirq.h	Sat Apr 26 00:53:21 1997
@@ -4,6 +4,9 @@
 /*
  * Software interrupts.. no SMP here either.
  */
+
+#include <asm/atomic.h>
+
 #define get_active_bhs()	(bh_mask & bh_active)
 #define clear_active_bhs(x)	atomic_clear_mask((x),&bh_active)
 
--- include/linux/linkage.h.~1~	Sat Apr 26 00:12:59 1997
+++ include/linux/linkage.h	Fri Apr 18 20:53:12 1997
@@ -16,13 +16,8 @@
 #endif
 
 #ifdef __mc68000__
-#ifdef __ELF__
 #define __ALIGN .align 4
 #define __ALIGN_STR ".align 4"
-#else
-#define __ALIGN .align 2
-#define __ALIGN_STR ".align 2"
-#endif
 #else /* !m68k */
 #if !defined(__i486__) && !defined(__i586__)
 #define __ALIGN .align 4,0x90
