Date: Mon, 11 May 1998 21:46:43 +0200 (CEST)
From: Wout Klaren <W.Klaren@inter.NL.net>
To: linux-m68k@lists.linux-m68k.org
Subject: L68K: Hades PCI fixes
Sender: owner-linux-m68k@phil.uni-sb.de

Hello,

This patch makes the Hades PCI BIOS emulation work with Linux 2.1.99. It
also fixes the problem that Linux 2.1.99 won't boot on a Medusa/Hades.

Wout



diff -ruN -x *.o -x *.a -x .*depend -x .config* -x .menuconfig* -x System.map -x .version -x autoconf.h -x compile.h -x vmlinux -x *_MODULES -x *.ver -x *.flags /atari/h/linux-2.1.99.orig/arch/m68k/atari/time.c linux-2.1.99/arch/m68k/atari/time.c
--- /atari/h/linux-2.1.99.orig/arch/m68k/atari/time.c	Tue Apr  7 14:16:44 1998
+++ linux-2.1.99/arch/m68k/atari/time.c	Sun May 10 19:19:30 1998
@@ -83,7 +83,7 @@
 
 #define	RTC_READ(reg)				\
     ({	unsigned char	__val;			\
-		writeb(reg,&tt_rtc.regsel);	\
+		(void) writeb(reg,&tt_rtc.regsel);	\
 		__val = tt_rtc.data;		\
 		__val;				\
 	})
diff -ruN -x *.o -x *.a -x .*depend -x .config* -x .menuconfig* -x System.map -x .version -x autoconf.h -x compile.h -x vmlinux -x *_MODULES -x *.ver -x *.flags /atari/h/linux-2.1.99.orig/arch/m68k/kernel/bios32.c linux-2.1.99/arch/m68k/kernel/bios32..c
--- /atari/h/linux-2.1.99.orig/arch/m68k/kernel/bios32.c	Sat Jan 31 14:01:30 1998
+++ linux-2.1.99/arch/m68k/kernel/bios32.c	Mon May 11 19:23:23 1998
@@ -33,7 +33,6 @@
  *    been removed in this version.
  */
 
-#include <linux/bios32.h>
 #include <linux/pci.h>
 #include <linux/malloc.h>
 #include <linux/mm.h>
@@ -49,7 +48,7 @@
 #define GB		(1024*MB)
 
 #define MAJOR_REV	0
-#define MINOR_REV	0
+#define MINOR_REV	1
 
 /*
  * Base addresses of the PCI memory and I/O areas on the Hades.
@@ -264,12 +263,14 @@
 
 #define MAX(val1, val2) ( ((val1) > (val2)) ? val1 : val2)
 
-__initfunc(static void layout_dev(struct pci_dev *dev))
+__initfunc(static void layout_dev(struct pci_dev *dev, unsigned long pci_mem_base,
+								  unsigned long pci_io_base))
 {
 	struct pci_bus *bus;
 	unsigned short cmd;
 	unsigned int base, mask, size, reg;
 	unsigned int alignto;
+	int i;
 
 	/*
 	 * Skip video cards for the time being.
@@ -283,7 +284,7 @@
 	bus = dev->bus;
 	pcibios_read_config_word(bus->number, dev->devfn, PCI_COMMAND, &cmd);
 
-	for (reg = PCI_BASE_ADDRESS_0; reg <= PCI_BASE_ADDRESS_5; reg += 4)
+	for (reg = PCI_BASE_ADDRESS_0, i = 0; reg <= PCI_BASE_ADDRESS_5; reg += 4, i++)
 	{
 		/*
 		 * Figure out how much space and of what type this
@@ -297,6 +298,7 @@
 		if (!base)
 		{
 			/* this base-address register is unused */
+			dev->base_address[i] = 0;
 			continue;
 		}
 
@@ -322,6 +324,7 @@
 			io_base = base + size;
 			pcibios_write_config_dword(bus->number, dev->devfn,
 						   reg, base | 0x1);
+			dev->base_address[i] = (pci_io_base + base) | 1;
 			DBG_DEVS(("layout_dev: IO address: %lX\n", base));
 		}
 		else
@@ -369,6 +372,7 @@
 			mem_base = base + size;
 			pcibios_write_config_dword(bus->number, dev->devfn,
 						   reg, base);
+			dev->base_address[i] = pci_mem_base + base;
 		}
 	}
 
@@ -396,7 +400,8 @@
 		  bus->number, PCI_SLOT(dev->devfn), dev->vendor, dev->device, dev->class));
 }
 
-__initfunc(static void layout_bus(struct pci_bus *bus))
+__initfunc(static void layout_bus(struct pci_bus *bus, unsigned long pci_mem_base,
+								  unsigned long pci_io_base))
 {
 	struct pci_dev *dev;
 
@@ -438,7 +443,7 @@
 	for (dev = bus->devices; dev; dev = dev->sibling)
 	{
 		if (dev->class >> 16 != PCI_BASE_CLASS_BRIDGE)
-			layout_dev(dev);
+			layout_dev(dev, pci_mem_base, pci_io_base);
 	}
 }
 
@@ -507,8 +512,7 @@
 		return 0;
 }
 
-__initfunc(unsigned long pcibios_init(unsigned long mem_start,
-				      unsigned long mem_end))
+__initfunc(void pcibios_init(void))
 {
 	printk("Linux/m68k PCI BIOS32 revision %x.%02x\n", MAJOR_REV, MINOR_REV);
 
@@ -516,7 +520,8 @@
 	printk("...NOT modifying existing PCI configuration\n");
 #endif
 
-	return mem_start;
+	pci_mem_base = 0x80000000;
+	pci_io_base = 0xB0000000;
 }
 
 /*
@@ -555,26 +560,35 @@
 	}
 }
 
-__initfunc(unsigned long pcibios_fixup(unsigned long mem_start,
-				       unsigned long mem_end))
+__initfunc(void pcibios_fixup(void))
 {
 #if PCI_MODIFY
+	unsigned long orig_mem_base, orig_io_base;
+
+	orig_mem_base = pci_mem_base;
+	orig_io_base = pci_io_base;
+	pci_mem_base = 0;
+	pci_io_base = 0;
+
 	/*
 	 * Scan the tree, allocating PCI memory and I/O space.
 	 */
 
-	layout_bus(&pci_root);
-#endif
+	layout_bus(&pci_root, orig_mem_base, orig_io_base);
 
-	pci_mem_base = 0x80000000;
-	pci_io_base = 0xB0000000;
+	pci_mem_base = orig_mem_base;
+	pci_io_base = orig_io_base;
+#endif
 
 	/*
 	 * Now is the time to do all those dirty little deeds...
 	 */
 
 	hades_fixup();
+}
 
-	return mem_start;
+__initfunc(char *pcibios_setup(char *str))
+{
+	return str;
 }
 #endif /* CONFIG_PCI */
diff -ruN -x *.o -x *.a -x .*depend -x .config* -x .menuconfig* -x System.map -x .version -x autoconf.h -x compile.h -x vmlinux -x *_MODULES -x *.ver -x *.flags /atari/h/linux-2.1.99.orig/arch/m68k/kernel/m68k_ksyms.c linux-2.1.99/arch/m68k/kernel/m68k_ks
yms.c
--- /atari/h/linux-2.1.99.orig/arch/m68k/kernel/m68k_ksyms.c	Wed May  6 19:43:39 1998
+++ linux-2.1.99/arch/m68k/kernel/m68k_ksyms.c	Thu May  7 21:19:15 1998
@@ -60,7 +60,3 @@
 EXPORT_SYMBOL_NOVERS(__down_failed);
 EXPORT_SYMBOL_NOVERS(__down_failed_interruptible);
 EXPORT_SYMBOL_NOVERS(__up_wakeup);
-
-#ifdef CONFIG_PCI
-EXPORT_SYMBOL(pci_devices);
-#endif

