Module Name:    src
Committed By:   phx
Date:           Fri May 21 12:52:14 UTC 2010

Modified Files:
        src/sys/arch/amigappc/amigappc: autoconf.c machdep.c mainbus.c

Log Message:
Some code cleanup and style guide compliance.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amigappc/amigappc/autoconf.c
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/amigappc/amigappc/machdep.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amigappc/amigappc/mainbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amigappc/amigappc/autoconf.c
diff -u src/sys/arch/amigappc/amigappc/autoconf.c:1.2 src/sys/arch/amigappc/amigappc/autoconf.c:1.3
--- src/sys/arch/amigappc/amigappc/autoconf.c:1.2	Tue Feb  2 19:15:33 2010
+++ src/sys/arch/amigappc/amigappc/autoconf.c	Fri May 21 12:52:14 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.2 2010/02/02 19:15:33 phx Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.3 2010/05/21 12:52:14 phx Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.2 2010/02/02 19:15:33 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.3 2010/05/21 12:52:14 phx Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -42,15 +42,16 @@
 #include <sys/disklabel.h>
 #include <sys/disk.h>
 #include <sys/proc.h>
+#include <sys/kernel.h>
+
 #include <machine/cpu.h>
+
 #include <amiga/amiga/cfdev.h>
 #include <amiga/amiga/device.h>
 #include <amiga/amiga/custom.h>
 
 static void findroot(void);
 
-#include <sys/kernel.h>
-
 u_long boot_partition;
 
 int amiga_realconfig;
@@ -61,6 +62,7 @@
 void
 cpu_configure(void)
 {
+
 	/*
 	 * this is the real thing baby (i.e. not console init)
 	 */
@@ -101,7 +103,7 @@
 simple_devprint(void *auxp, const char *pnp)
 {
 
-	return(QUIET);
+	return QUIET;
 }
 
 int
@@ -111,10 +113,10 @@
 
 	len = strlen(fp);
 	if (strlen(sp) != len)
-		return(0);
+		return 0;
 	if (bcmp(fp, sp, len) == 0)
-		return(1);
-	return(0);
+		return 1;
+	return 0;
 }
 
 /*
@@ -132,7 +134,7 @@
 	const struct cfattach *ca;
 
 	if (amiga_realconfig)
-		return(config_found(pdp, auxp, pfn) != NULL);
+		return config_found(pdp, auxp, pfn) != NULL;
 
 	if (pdp == NULL) {
 		memset(&temp, 0, sizeof temp);
@@ -148,11 +150,11 @@
 		if (ca != NULL) {
 			(*ca->ca_attach)(pdp, NULL, auxp);
 			pdp->dv_cfdata = NULL;
-			return(1);
+			return 1;
 		}
 	}
 	pdp->dv_cfdata = NULL;
-	return(0);
+	return 0;
 }
 
 /*
@@ -171,15 +173,8 @@
 	 * we need mainbus' cfdata.
 	 */
 	cf = config_rootsearch(NULL, "mainbus", NULL);
-	if (cf == NULL) {
+	if (cf == NULL)
 		panic("no mainbus");
-	}
-#if 0 /* XXX doesn't exist on amigappc */
-	/*
-	 * delay clock calibration.
-	 */
-	amiga_config_found(cf, NULL, __UNCONST("clock"), NULL);
-#endif
 
 	/*
 	 * internal grf.
@@ -373,7 +368,6 @@
  * realtime clock and scsi controller, so that this hardware is only
  * included as "configured" if this IS an A3000
  */
-
 int a3000_flag = 1;		/* patchable */
 #ifdef A4000
 int a4000_flag = 1;		/* patchable - default to A4000 */
@@ -389,14 +383,14 @@
 	short sc;
 
 	if ((machineid >> 16) == 3000)
-		return (1);			/* It's an A3000 */
+		return 1;			/* It's an A3000 */
 	if (machineid >> 16)
-		return (0);			/* It's not an A3000 */
+		return 0;			/* It's not an A3000 */
 	/* Machine type is unknown, so try to guess it */
 	/* where is fastram on the A4000 ?? */
 	/* if fastram is below 0x07000000, assume it's not an A3000 */
 	if (boot_fphystart < 0x07000000)
-		return(0);
+		return 0;
 	/*
 	 * OK, fastram starts at or above 0x07000000, check specific
 	 * machines
@@ -407,23 +401,23 @@
 			switch (cfdev[sc].rom.prodid) {
 			case 0:		/* PPI Mercury - A3000 */
 			case 1:		/* PP&S A3000 '040 */
-				return(1);
+				return 1;
 			case 150:	/* PPI Zeus - it's an A2000 */
 			case 105:	/* PP&S A2000 '040 */
 			case 187:	/* PP&S A500 '040 */
-				return(0);
+				return 0;
 			}
 			break;
 
 		case 2112:			/* IVS */
 			switch (cfdev[sc].rom.prodid) {
 			case 242:
-				return(0);	/* A2000 accelerator? */
+				return 0;	/* A2000 accelerator? */
 			}
 			break;
 		}
 	}
-	return (a3000_flag);		/* XXX let flag tell now */
+	return a3000_flag;		/* XXX let flag tell now */
 }
 
 int
@@ -431,19 +425,19 @@
 {
 
 	if ((machineid >> 16) == 4000)
-		return (1);		/* It's an A4000 */
+		return 1;		/* It's an A4000 */
 	if ((machineid >> 16) == 1200)
-		return (0);		/* It's an A1200, so not A4000 */
+		return 0;		/* It's an A1200, so not A4000 */
 	/* Do I need this any more? */
 	if ((custom.deniseid & 0xff) == 0xf8)
-		return (1);
+		return 1;
 #ifdef DEBUG
 	if (a4000_flag)
 		printf("Denise ID = %04x\n", (unsigned short)custom.deniseid);
 #endif
 	if (machineid >> 16)
-		return (0);		/* It's not an A4000 */
-	return (a4000_flag);		/* Machine type not set */
+		return 0;		/* It's not an A4000 */
+	return a4000_flag;		/* Machine type not set */
 }
 
 int
@@ -451,6 +445,6 @@
 {
 
 	if ((machineid >> 16) == 1200)
-		return (1);		/* It's an A1200 */
-	return (0);			/* Machine type not set */
+		return 1;		/* It's an A1200 */
+	return 0;			/* Machine type not set */
 }

Index: src/sys/arch/amigappc/amigappc/machdep.c
diff -u src/sys/arch/amigappc/amigappc/machdep.c:1.42 src/sys/arch/amigappc/amigappc/machdep.c:1.43
--- src/sys/arch/amigappc/amigappc/machdep.c:1.42	Fri Mar  5 17:56:46 2010
+++ src/sys/arch/amigappc/amigappc/machdep.c	Fri May 21 12:52:14 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.42 2010/03/05 17:56:46 phx Exp $ */
+/* $NetBSD: machdep.c,v 1.43 2010/05/21 12:52:14 phx Exp $ */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,10 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.42 2010/03/05 17:56:46 phx Exp $");
-
-#include "opt_ddb.h"
-#include "opt_ipkdb.h"
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.43 2010/05/21 12:52:14 phx Exp $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -46,6 +43,8 @@
 
 #include <uvm/uvm_extern.h>
 
+#include <dev/cons.h>
+
 #include <machine/autoconf.h>
 #include <machine/powerpc.h>
 #include <machine/stdarg.h>
@@ -53,8 +52,6 @@
 #include <powerpc/oea/bat.h>
 #include <powerpc/pic/picvar.h>
 
-#include <dev/cons.h>
-
 #include <amiga/amiga/cc.h>
 #include <amiga/amiga/cia.h>
 #include <amiga/amiga/custom.h>
@@ -62,6 +59,9 @@
 #include <amiga/amiga/memlist.h>
 #include <amigappc/amigappc/p5reg.h>
 
+#include "opt_ddb.h"
+#include "opt_ipkdb.h"
+
 #include "fd.h"
 #include "ser.h"
 
@@ -74,6 +74,10 @@
 extern void fdintr(int);
 #endif
 
+#define AMIGAMEMREGIONS 8
+static struct mem_region physmemr[AMIGAMEMREGIONS], availmemr[AMIGAMEMREGIONS];
+static char model[80];
+
 /*
  * patched by some devices at attach time (currently, only the coms)
  */
@@ -85,10 +89,6 @@
  */
 int ser_open_speed;
 
-#define AMIGAMEMREGIONS 8
-static struct mem_region physmemr[AMIGAMEMREGIONS], availmemr[AMIGAMEMREGIONS];
-char cpu_model[80];
-
 /* interrupt handler chains for level2 and level6 interrupt */
 struct isr *isr_ports;
 struct isr *isr_exter;
@@ -258,16 +258,21 @@
 static void
 amigappc_identify(void)
 {
-	extern u_long ticks_per_sec, ns_per_tick;
-	static const char pll603[] = {10, 10, 10, 10, 20, 20, 25, 0,
-			30, 0, 40, 0, 15,0, 35, 0};
-	static const char pll604[] = {10, 10, 70, 10, 20, 65, 25, 45,
-			30, 55, 40, 50, 15, 60, 35, 0};
-	const char *mach, *pup, *cpuname;
-	const char *p5type_p = (const char *)0xf00010;
+	extern u_long ns_per_tick, ticks_per_sec;
+	static const char pll603[] = {
+		10, 10, 10, 10, 20, 20, 25, 00,
+		30, 00, 40, 00, 15, 00, 35, 00
+	};
+	static const char pll604[] = {
+		10, 10, 70, 10, 20, 65, 25, 45,
+		30, 55, 40, 50, 15, 60, 35, 00
+	};
+	const char *cpuname, *mach, *p5type_p, *pup;
+	int busclock, cpu, cpuclock;
 	register int pvr, hid1;
-	int cpu = 604;
-	int cpuclock, busclock;
+
+	/* PowerUp ROM id location */
+	p5type_p = (const char *)0xf00010;
 
 	/*
 	 * PVR holds the CPU-type and version while
@@ -276,15 +281,12 @@
 	__asm ("mfpvr %0; mfspr %1,1009" : "=r"(pvr), "=r"(hid1));
 
 	/* Amiga types which can run a PPC board */
-	if (is_a4000()) {
+	if (is_a4000())
 		mach = "Amiga 4000";
-	}
-	else if (is_a3000()) {
+	else if (is_a3000())
 		mach = "Amiga 3000";
-	}
-	else {
+	else
 		mach = "Amiga 1200";
-	}
 
 	/* find CPU type - BlizzardPPC has 603e, CyberstormPPC has 604e */
 	switch (pvr >> 16) {
@@ -311,6 +313,7 @@
 		break;
 	default:
 		cpuname = "unknown";
+		cpu = 604;
 		break;
 	}
 
@@ -343,21 +346,17 @@
 		break;
 	}
 
-	/*
-	 * compute cpuclock based on PLL configuration
-	 */
+	/* compute cpuclock based on PLL configuration */
 	if (cpu == 603)
 		cpuclock = busclock * pll603[hid1>>28 & 0xf] / 10;
 	else /* 604 */
 		cpuclock = busclock * pll604[hid1>>28 & 0xf] / 10;
 
-	snprintf(cpu_model, sizeof(cpu_model),
+	snprintf(model, sizeof(model),
 	    "%s %s (%s v%d.%d %d MHz, busclk %d MHz)", mach, pup, cpuname,
 	    pvr>>8 & 0xff, pvr & 0xff, cpuclock/1000000, busclock/1000000);
 
-	/*
-	 * set timebase
-	 */
+	/* set timebase */
 	ticks_per_sec = busclock / 4;
 	ns_per_tick = 1000000000 / ticks_per_sec;
 }
@@ -366,17 +365,14 @@
 amigappc_reboot(void)
 {
 
-	/*
-	 * reboot CSPPC/BPPC
-	 */
+	/* reboot CSPPC/BPPC */
 	if (!is_a1200()) {
 		P5write(P5_REG_LOCK,0x60);
 		P5write(P5_REG_LOCK,0x50);
 		P5write(P5_REG_LOCK,0x30);
 		P5write(P5_REG_SHADOW,P5_SET_CLEAR|P5_SHADOW);
 		P5write(P5_REG_LOCK,0x00);
-	}
-	else
+	} else
 		P5write(P5_BPPC_MAGIC,0x00);
 
 	P5write(P5_REG_LOCK,0x60);
@@ -389,8 +385,8 @@
 static void
 amigappc_bat_add(paddr_t pa, register_t len, register_t prot)
 {
-	static int ni = 0, nd = 0;
-	const u_int i = pa >> 28;
+	static int nd = 0, ni = 0;
+	const uint32_t i = pa >> 28;
 
 	battable[i].batl = BATL(pa, prot, BAT_PP_RW);
 	battable[i].batu = BATU(pa, len, BAT_Vs);
@@ -398,7 +394,7 @@
 	/*
 	 * Let's start loading the BAT registers.
 	 */
-	if (!(prot & (BAT_I|BAT_G))) {
+	if (!(prot & (BAT_I | BAT_G))) {
 		switch (ni) {
 		case 0:
 			__asm volatile ("isync");
@@ -478,7 +474,9 @@
 amigappc_batinit(paddr_t pa, ...)
 {
 	va_list ap;
-	register_t msr = mfmsr();
+	register_t msr;
+
+	msr = mfmsr();
 
 	/*
 	 * Set BAT registers to unmapped to avoid overlapping mappings below.
@@ -501,9 +499,10 @@
 	 */
 	va_start(ap, pa);
 	while (pa != ~0) {
-		register_t len = va_arg(ap, register_t);
-		register_t prot = va_arg(ap, register_t);
+		register_t len, prot;
 
+		len = va_arg(ap, register_t);
+		prot = va_arg(ap, register_t);
 		amigappc_bat_add(pa, len, prot);
 		pa = va_arg(ap, paddr_t);
 	}
@@ -520,7 +519,7 @@
 	 * amigappc memory region set
 	 */
 	ms = &memlist->m_seg[0];
-	for (i=0, r=0; i<memlist->m_nseg; i++, ms++) {
+	for (i = 0, r = 0; i < memlist->m_nseg; i++, ms++) {
 		if (ms->ms_attrib & MEMF_FAST) {
 			/*
 			 * XXX Only recognize the memory segment in which
@@ -630,7 +629,7 @@
 	/*
 	 * hello world
 	 */
-	oea_startup(cpu_model);
+	oea_startup(model);
 
 	/* Setup interrupts */
 	pic_init();

Index: src/sys/arch/amigappc/amigappc/mainbus.c
diff -u src/sys/arch/amigappc/amigappc/mainbus.c:1.1 src/sys/arch/amigappc/amigappc/mainbus.c:1.2
--- src/sys/arch/amigappc/amigappc/mainbus.c:1.1	Tue Jul 21 09:49:15 2009
+++ src/sys/arch/amigappc/amigappc/mainbus.c	Fri May 21 12:52:14 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.1 2009/07/21 09:49:15 phx Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.2 2010/05/21 12:52:14 phx Exp $	*/
 
 /*-
  * Copyright (c) 2008,2009 Frank Wille.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.1 2009/07/21 09:49:15 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.2 2010/05/21 12:52:14 phx Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -86,14 +86,11 @@
 CFATTACH_DECL(mainbus, sizeof(struct device),
     mbmatch, mbattach, NULL, NULL);
 
-static int mainbus_print (void *, const char *);
-
-
 int
 mbmatch(struct device *parent, struct cfdata *cfp, void *aux)
 {
 
-	return (1);
+	return 1;
 }
 
 void
@@ -105,7 +102,7 @@
 	/*
 	 * Always find the CPU
 	 */
-	config_found_ia(self, "mainbus", __UNCONST("cpu"), mainbus_print);
+	config_found_ia(self, "mainbus", __UNCONST("cpu"), mbprint);
 
 	/*
 	 * "find" all the things that should be there.
@@ -121,10 +118,8 @@
 	config_found(self, __UNCONST("grfcc"), simple_devprint);
 	config_found(self, __UNCONST("amidisplaycc"), simple_devprint);
 	config_found(self, __UNCONST("fdc"), simple_devprint);
-	if (is_a4000() || is_a1200()) {
+	if (is_a4000() || is_a1200())
 		config_found(self, __UNCONST("wdc"), simple_devprint);
-		config_found(self, __UNCONST("idesc"), simple_devprint);
-	}
 	if (is_a4000())			/* Try to configure A4000T SCSI */
 		config_found(self, __UNCONST("afsc"), simple_devprint);
 	if (is_a3000())
@@ -142,14 +137,5 @@
 
 	if (pnp)
 		aprint_normal("%s at %s", (char *)aux, pnp);
-	return (UNCONF);
-}
-
-static int
-mainbus_print(void *aux, const char *pnp)
-{
-
-	if (pnp)
-		aprint_normal("cpu0 at %s", pnp);
-	return (UNCONF);
+	return UNCONF;
 }

Reply via email to