Module Name:    src
Committed By:   isaki
Date:           Tue Jan 22 11:58:40 UTC 2013

Modified Files:
        src/sys/arch/x68k/dev: intiovar.h
        src/sys/arch/x68k/x68k: machdep.c

Log Message:
Detect emulators (and display it on dmesg).


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x68k/dev/intiovar.h
cvs rdiff -u -r1.185 -r1.186 src/sys/arch/x68k/x68k/machdep.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/x68k/dev/intiovar.h
diff -u src/sys/arch/x68k/dev/intiovar.h:1.13 src/sys/arch/x68k/dev/intiovar.h:1.14
--- src/sys/arch/x68k/dev/intiovar.h:1.13	Thu Dec 18 05:56:42 2008
+++ src/sys/arch/x68k/dev/intiovar.h	Tue Jan 22 11:58:39 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: intiovar.h,v 1.13 2008/12/18 05:56:42 isaki Exp $	*/
+/*	$NetBSD: intiovar.h,v 1.14 2013/01/22 11:58:39 isaki Exp $	*/
 
 /*
  *
@@ -126,6 +126,8 @@ int intio_intr(struct frame *);
 #define INTIO_SYSPORT_KBEXIST	0x08
 #define intio_get_sysport_waitctrl() \
 	(intio_sysport[sysport_waitctrl])
+#define intio_get_sysport_sramwp() \
+	(intio_sysport[sysport_sramwp])
 #define intio_get_sysport_mpustat() \
 	(intio_sysport[sysport_mpustat])
 

Index: src/sys/arch/x68k/x68k/machdep.c
diff -u src/sys/arch/x68k/x68k/machdep.c:1.185 src/sys/arch/x68k/x68k/machdep.c:1.186
--- src/sys/arch/x68k/x68k/machdep.c:1.185	Mon Jul 30 17:19:59 2012
+++ src/sys/arch/x68k/x68k/machdep.c	Tue Jan 22 11:58:39 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.185 2012/07/30 17:19:59 christos Exp $	*/
+/*	$NetBSD: machdep.c,v 1.186 2013/01/22 11:58:39 isaki Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.185 2012/07/30 17:19:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.186 2013/01/22 11:58:39 isaki Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -125,6 +125,7 @@ int	maxmem;			/* max memory per process 
 
 /* prototypes for local functions */
 void	identifycpu(void);
+static int check_emulator(char *, int);
 void	initcpu(void);
 int	cpu_dumpsize(void);
 int	cpu_dump(int (*)(dev_t, daddr_t, void *, size_t), daddr_t *);
@@ -304,6 +305,7 @@ identifycpu(void)
 	/* there's alot of XXX in here... */
 	const char *cpu_type, *mach, *mmu, *fpu;
 	char clock[16];
+	char emubuf[20];
 
 	/*
 	 * check machine type constant
@@ -335,6 +337,9 @@ identifycpu(void)
 		break;
 	}
 
+	emubuf[0] = '\0';
+	check_emulator(emubuf, sizeof(emubuf));
+
 	cpuspeed = 2048 / delay_divisor;
 	sprintf(clock, "%dMHz", cpuspeed);
 	switch (cputype) {
@@ -367,12 +372,60 @@ identifycpu(void)
 		fpu = fpu_descr[fputype];
 	else
 		fpu = ", unknown FPU";
-	sprintf(cpu_model, "X68%s (%s CPU%s%s, %s clock)",
-	    mach, cpu_type, mmu, fpu, clock);
+	sprintf(cpu_model, "X68%s (%s CPU%s%s, %s clock)%s%s",
+	    mach, cpu_type, mmu, fpu, clock,
+		emubuf[0] ? " on " : "", emubuf);
 	printf("%s\n", cpu_model);
 }
 
 /*
+ * If it is an emulator, store the name in buf and return 1.
+ * Otherwise return 0.
+ */
+static int
+check_emulator(char *buf, int bufsize)
+{
+	int xm6major;
+	int xm6minor;
+	int xm6imark;
+	int xm6imajor;
+	int xm6iminor;
+
+	/* XM6 and its family */
+	intio_set_sysport_sramwp('X');
+	if (intio_get_sysport_sramwp() == '6') {
+		xm6major = intio_get_sysport_sramwp();
+		xm6minor = intio_get_sysport_sramwp();
+		xm6imark = intio_get_sysport_sramwp();
+		switch (xm6imark) {
+		case 0xff:	/* Original XM6 or unknown compatibles */
+			snprintf(buf, bufsize, "XM6 v%d.%02d",
+				xm6major, xm6minor);
+			break;
+
+		case 'i':	/* XM6i */
+			xm6imajor = intio_get_sysport_sramwp();
+			xm6iminor = intio_get_sysport_sramwp();
+			snprintf(buf, bufsize, "XM6i v%d.%02d",
+				xm6imajor, xm6iminor);
+			break;
+
+		case 'g':	/* XM6 TypeG */
+			snprintf(buf, bufsize, "XM6 TypeG v%d.%02d",
+				xm6major, xm6minor);
+			break;
+
+		default:	/* Other XM6 compatibles? */
+			/* XXX what should I do? */
+			return 0;
+		}
+		return 1;
+	}
+
+	return 0;
+}
+
+/*
  * machine dependent system variables.
  */
 SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")

Reply via email to