From f7bbb6b37b44db64270ddbe3c46d2507b71921f6 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Mon, 14 Nov 2016 21:04:26 +0100
Subject: [PATCH] WIP old platform removal.

---
 lib/libc/gmon/gmon.c        | 19 +++----------------
 libexec/rtld-elf/rtld.c     |  4 ----
 sys/boot/common/load_elf.c  |  9 ---------
 sys/bus/u4b/usb_dragonfly.h |  4 ----
 sys/dev/disk/isp/isp_pci.c  |  4 ----
 sys/dev/disk/sbp/sbp.c      |  5 +----
 sys/dev/disk/sym/sym_hipd.c | 14 --------------
 sys/dev/raid/amr/amrio.h    |  2 +-
 sys/dev/sound/pci/t4dwave.c | 32 +-------------------------------
 sys/net/bpf_filter.c        | 30 ++----------------------------
 sys/sys/link_elf.h          |  3 ---
 usr.sbin/pppd/main.c        |  5 -----
 12 files changed, 8 insertions(+), 123 deletions(-)

diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c
index 47b9215..4a7293c 100644
--- a/lib/libc/gmon/gmon.c
+++ b/lib/libc/gmon/gmon.c
@@ -46,7 +46,7 @@
 
 #include "libc_private.h"
 
-#if defined(__i386__) || defined(__sparc64__) || defined(__x86_64__) || defined(__powerpc__)
+#if defined(__i386__) || defined(__x86_64__)
 extern char *minbrk __asm (".minbrk");
 #else
 extern char *minbrk __asm ("minbrk");
@@ -105,22 +105,9 @@ monstartup(u_long lowpc, u_long highpc)
 	p->tos[0].link = 0;
 
 	o = p->highpc - p->lowpc;
-	if (p->kcountsize < o) {
-#ifndef hp300
+	if (p->kcountsize < o)
 		s_scale = ((float)p->kcountsize / o ) * SCALE_1_TO_1;
-#else /* avoid floating point */
-		int quot = o / p->kcountsize;
-
-		if (quot >= 0x10000)
-			s_scale = 1;
-		else if (quot >= 0x100)
-			s_scale = 0x10000 / quot;
-		else if (o >= 0x800000)
-			s_scale = 0x1000000 / (o / (p->kcountsize >> 8));
-		else
-			s_scale = 0x1000000 / ((o << 8) / p->kcountsize);
-#endif
-	} else
+	else
 		s_scale = SCALE_1_TO_1;
 
 	moncontrol(1);
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index a8fe623..a892f3e 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -3593,10 +3593,6 @@ linkmap_add(Obj_Entry *obj)
     obj->linkmap.l_name = obj->path;
     obj->linkmap.l_addr = obj->mapbase;
     obj->linkmap.l_ld = obj->dynamic;
-#ifdef __mips__
-    /* GDB needs load offset on MIPS to use the symbols */
-    obj->linkmap.l_offs = obj->relocbase;
-#endif
 
     if (r_debug.r_map == NULL) {
 	r_debug.r_map = l;
diff --git a/sys/boot/common/load_elf.c b/sys/boot/common/load_elf.c
index 829daf8..89bb54c 100644
--- a/sys/boot/common/load_elf.c
+++ b/sys/boot/common/load_elf.c
@@ -300,15 +300,6 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_t ef, u_int64_t off)
 #else
 	off = - (off & 0xff000000u);	/* i386 relocates after locore */
 #endif
-#elif defined(__arm__)
-	if (off & 0xf0000000u) {
-	    off = -(off & 0xf0000000u);
-	    ehdr->e_entry += off;
-#ifdef ELF_VERBOSE
-	    printf("Converted entry 0x%08x\n", ehdr->e_entry);
-#endif
-	} else
-	    off = 0;
 #else
 	off = 0;		/* other archs use direct mapped kernels */
 #endif
diff --git a/sys/bus/u4b/usb_dragonfly.h b/sys/bus/u4b/usb_dragonfly.h
index b955f76..65084fa 100644
--- a/sys/bus/u4b/usb_dragonfly.h
+++ b/sys/bus/u4b/usb_dragonfly.h
@@ -60,12 +60,8 @@
 #if (!defined(USB_HOST_ALIGN)) || (USB_HOST_ALIGN <= 0)
 /* Use default value. */
 #undef USB_HOST_ALIGN
-#if defined(__arm__) || defined(__mips__) || defined(__powerpc__)
-#define USB_HOST_ALIGN	32		/* Arm and MIPS need at least this much, if not more */
-#else
 #define	USB_HOST_ALIGN    8		/* bytes, must be power of two */
 #endif
-#endif
 /* Sanity check for USB_HOST_ALIGN: Verify power of two. */
 #if ((-USB_HOST_ALIGN) & USB_HOST_ALIGN) != USB_HOST_ALIGN
 #error "USB_HOST_ALIGN is not power of two."
diff --git a/sys/dev/disk/isp/isp_pci.c b/sys/dev/disk/isp/isp_pci.c
index 576e2d7..7795bb2 100644
--- a/sys/dev/disk/isp/isp_pci.c
+++ b/sys/dev/disk/isp/isp_pci.c
@@ -530,11 +530,7 @@ isp_get_specific_options(device_t dev, int chan, ispsoftc_t *isp)
 		if (IS_FC(isp)) {
 			ISP_FC_PC(isp, chan)->default_id = 109 - chan;
 		} else {
-#ifdef __sparc64__
-			ISP_SPI_PC(isp, chan)->iid = OF_getscsinitid(dev);
-#else
 			ISP_SPI_PC(isp, chan)->iid = 7;
-#endif
 		}
 	} else {
 		if (IS_FC(isp)) {
diff --git a/sys/dev/disk/sbp/sbp.c b/sys/dev/disk/sbp/sbp.c
index 9220f39..c0394ee 100644
--- a/sys/dev/disk/sbp/sbp.c
+++ b/sys/dev/disk/sbp/sbp.c
@@ -136,11 +136,8 @@ TUNABLE_INT("hw.firewire.sbp.tags", &sbp_tags);
 #define NEED_RESPONSE 0
 
 #define SBP_SEG_MAX rounddown(0xffff, PAGE_SIZE)
-#ifdef __sparc64__ /* iommu */
-#define SBP_IND_MAX howmany(SBP_MAXPHYS, SBP_SEG_MAX)
-#else
 #define SBP_IND_MAX howmany(SBP_MAXPHYS, PAGE_SIZE)
-#endif
+
 struct sbp_ocb {
 	STAILQ_ENTRY(sbp_ocb)	ocb;
 	union ccb	*ccb;
diff --git a/sys/dev/disk/sym/sym_hipd.c b/sys/dev/disk/sym/sym_hipd.c
index dc05033..d36a562 100644
--- a/sys/dev/disk/sym/sym_hipd.c
+++ b/sys/dev/disk/sym/sym_hipd.c
@@ -84,11 +84,6 @@
 #include <bus/pci/pcireg.h>
 #include <bus/pci/pcivar.h>
 
-#ifdef __sparc64__
-#include <dev/ofw/openfirm.h>
-#include <machine/ofw_machdep.h>
-#endif
-
 #include <sys/rman.h>
 
 #include <bus/cam/cam.h>
@@ -127,12 +122,6 @@ typedef	u_int32_t u32;
 
 #if	defined __x86_64__
 #define MEMORY_BARRIER()	do { ; } while(0)
-#elif	defined	__powerpc__
-#define MEMORY_BARRIER()	__asm__ volatile("eieio; sync" : : : "memory")
-#elif	defined	__ia64__
-#define MEMORY_BARRIER()	__asm__ volatile("mf.a; mf" : : : "memory")
-#elif	defined	__sparc64__
-#define MEMORY_BARRIER()	__asm__ volatile("membar #Sync" : : : "memory")
 #else
 #error	"Not supported platform"
 #endif
@@ -2678,9 +2667,6 @@ static int sym_prepare_setting(hcb_p np, struct sym_nvram *nvram)
 	 */
 	np->myaddr = 255;
 	sym_nvram_setup_host (np, nvram);
-#ifdef __sparc64__
-	np->myaddr = OF_getscsinitid(np->device);
-#endif
 
 	/*
 	 *  Get SCSI addr of host adapter (set by bios?).
diff --git a/sys/dev/raid/amr/amrio.h b/sys/dev/raid/amr/amrio.h
index 2a00ea2..df338b3 100644
--- a/sys/dev/raid/amr/amrio.h
+++ b/sys/dev/raid/amr/amrio.h
@@ -108,7 +108,7 @@ struct amr_user_ioctl {
 
 #define AMR_IO_COMMAND	_IOWR('A', 0x201, struct amr_user_ioctl)
 
-#if defined(__x86_64__) || defined(__ia64__)
+#if defined(__x86_64__)
 
 struct amr_user_ioctl32 {
     unsigned char	au_cmd[32];	/* command text from userspace */
diff --git a/sys/dev/sound/pci/t4dwave.c b/sys/dev/sound/pci/t4dwave.c
index d4a3276..30b1214 100644
--- a/sys/dev/sound/pci/t4dwave.c
+++ b/sys/dev/sound/pci/t4dwave.c
@@ -832,11 +832,6 @@ tr_pci_attach(device_t dev)
 	bus_addr_t	lowaddr;
 	int		i, dacn;
 	char 		status[SND_STATUSLEN];
-#ifdef __sparc64__
-	device_t	*children;
-	int		nchildren;
-	u_int32_t	data;
-#endif
 
 	tr = kmalloc(sizeof(*tr), M_DEVBUF, M_WAITOK | M_ZERO);
 	tr->type = pci_get_devid(dev);
@@ -903,34 +898,9 @@ tr_pci_attach(device_t dev)
 		 * using a low address of BUS_SPACE_MAXADDR_32BIT for both
 		 * we might end up with the play buffer being in the 32-bit
 		 * range while the record buffer isn't or vice versa. So we
-		 * limit enabling the 31st bit to sparc64, where the IOMMU
-		 * guarantees that we're using a 32-bit address (and in turn
-		 * requires it).
+		 * do not enable the 31st bit.
 		 */
 		lowaddr = ALI_MAXADDR;
-#ifdef __sparc64__
-		if (device_get_children(device_get_parent(dev), &children,
-		    &nchildren) == 0) {
-			for (i = 0; i < nchildren; i++) {
-				if (pci_get_devid(children[i]) == 0x153310b9) {
-					lowaddr = BUS_SPACE_MAXADDR_32BIT;
-					data = pci_read_config(children[i],
-					    0x7e, 1);
-					if (bootverbose)
-						device_printf(dev,
-						    "M1533 0x7e: 0x%x -> ",
-						    data);
-					data |= 0x1;
-					if (bootverbose)
-						kprintf("0x%x\n", data);
-					pci_write_config(children[i], 0x7e,
-					    data, 1);
-					break;
-				}
-			}
-		}
-		kfree(children, M_TEMP);
-#endif
 		tr->hwchns = ALI_MAXHWCH;
 		tr->bufsz = ALI_BUFSZ;
 	} else {
diff --git a/sys/net/bpf_filter.c b/sys/net/bpf_filter.c
index c059535..4095a7f 100644
--- a/sys/net/bpf_filter.c
+++ b/sys/net/bpf_filter.c
@@ -39,24 +39,8 @@
 #include <sys/systm.h>
 #include <sys/param.h>
 
-#if defined(sparc) || defined(mips) || defined(ibm032)
-#define BPF_ALIGN
-#endif
-
-#ifndef BPF_ALIGN
 #define EXTRACT_SHORT(p)	((u_int16_t)ntohs(*(u_int16_t *)p))
 #define EXTRACT_LONG(p)		(ntohl(*(u_int32_t *)p))
-#else
-#define EXTRACT_SHORT(p)\
-	((u_int16_t)\
-		((u_int16_t)*((u_char *)p+0)<<8|\
-		 (u_int16_t)*((u_char *)p+1)<<0))
-#define EXTRACT_LONG(p)\
-		((u_int32_t)*((u_char *)p+0)<<24|\
-		 (u_int32_t)*((u_char *)p+1)<<16|\
-		 (u_int32_t)*((u_char *)p+2)<<8|\
-		 (u_int32_t)*((u_char *)p+3)<<0)
-#endif
 
 #ifdef _KERNEL
 #include <sys/mbuf.h>
@@ -219,12 +203,7 @@ bpf_filter(const struct bpf_insn *pc, u_char *p, u_int wirelen, u_int buflen)
 				return 0;
 #endif
 			}
-#ifdef BPF_ALIGN
-			if (((intptr_t)(p + k) & 3) != 0)
-				A = EXTRACT_LONG(&p[k]);
-			else
-#endif
-				A = ntohl(*(int32_t *)(p + k));
+			A = ntohl(*(int32_t *)(p + k));
 			continue;
 
 		case BPF_LD|BPF_H|BPF_ABS:
@@ -288,12 +267,7 @@ bpf_filter(const struct bpf_insn *pc, u_char *p, u_int wirelen, u_int buflen)
 				return 0;
 #endif
 			}
-#ifdef BPF_ALIGN
-			if (((intptr_t)(p + k) & 3) != 0)
-				A = EXTRACT_LONG(&p[k]);
-			else
-#endif
-				A = ntohl(*(int32_t *)(p + k));
+			A = ntohl(*(int32_t *)(p + k));
 			continue;
 
 		case BPF_LD|BPF_H|BPF_IND:
diff --git a/sys/sys/link_elf.h b/sys/sys/link_elf.h
index 86a1425..d8c7c44 100644
--- a/sys/sys/link_elf.h
+++ b/sys/sys/link_elf.h
@@ -56,9 +56,6 @@
 
 typedef struct link_map {
 	caddr_t		l_addr;			/* Base Address of library */
-#ifdef __mips__
-	caddr_t		l_offs;			/* Load Offset of library */
-#endif
 	const char	*l_name;		/* Absolute Path to Library */
 	const void	*l_ld;			/* Pointer to .dynamic in memory */
 	struct link_map	*l_next, *l_prev;	/* linked list of of mapped libs */
diff --git a/usr.sbin/pppd/main.c b/usr.sbin/pppd/main.c
index fe32290..2446bcc 100644
--- a/usr.sbin/pppd/main.c
+++ b/usr.sbin/pppd/main.c
@@ -1490,12 +1490,7 @@ vfmtmsg(char *buf, int buflen, char *fmt, va_list args)
 	    break;
 	case 'r':
 	    f = va_arg(args, char *);
-#if !defined(__powerpc__) && !defined(__x86_64__)
-	    n = vfmtmsg(buf, buflen + 1, f, va_arg(args, va_list));
-#else
-	    /* On the powerpc, a va_list is an array of 1 structure */
 	    n = vfmtmsg(buf, buflen + 1, f, va_arg(args, void *));
-#endif
 	    buf += n;
 	    buflen -= n;
 	    continue;
-- 
2.9.2

