Tue Jan 22 11:58:40 2013 UTC ()
Detect emulators (and display it on dmesg).


(isaki)
diff -r1.13 -r1.14 src/sys/arch/x68k/dev/intiovar.h
diff -r1.185 -r1.186 src/sys/arch/x68k/x68k/machdep.c

cvs diff -r1.13 -r1.14 src/sys/arch/x68k/dev/intiovar.h (expand / switch to unified diff)

--- src/sys/arch/x68k/dev/intiovar.h 2008/12/18 05:56:42 1.13
+++ src/sys/arch/x68k/dev/intiovar.h 2013/01/22 11:58:39 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: intiovar.h,v 1.13 2008/12/18 05:56:42 isaki Exp $ */ 1/* $NetBSD: intiovar.h,v 1.14 2013/01/22 11:58:39 isaki Exp $ */
2 2
3/* 3/*
4 * 4 *
5 * Copyright (c) 1998 NetBSD Foundation, Inc. 5 * Copyright (c) 1998 NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -116,26 +116,28 @@ int intio_intr(struct frame *); @@ -116,26 +116,28 @@ int intio_intr(struct frame *);
116#define intio_set_sysport_powoff(a) \ 116#define intio_set_sysport_powoff(a) \
117 intio_sysport[sysport_powoff] = (a) 117 intio_sysport[sysport_powoff] = (a)
118 118
119#define intio_get_sysport_contrast() \ 119#define intio_get_sysport_contrast() \
120 (intio_sysport[sysport_contrast]) 120 (intio_sysport[sysport_contrast])
121#define intio_get_sysport_tvctrl() \ 121#define intio_get_sysport_tvctrl() \
122 (intio_sysport[sysport_tvctrl]) 122 (intio_sysport[sysport_tvctrl])
123#define INTIO_SYSPORT_TVSTAT 0x08 123#define INTIO_SYSPORT_TVSTAT 0x08
124#define intio_get_sysport_keyctrl() \ 124#define intio_get_sysport_keyctrl() \
125 (intio_sysport[sysport_keyctrl]) 125 (intio_sysport[sysport_keyctrl])
126#define INTIO_SYSPORT_KBEXIST 0x08 126#define INTIO_SYSPORT_KBEXIST 0x08
127#define intio_get_sysport_waitctrl() \ 127#define intio_get_sysport_waitctrl() \
128 (intio_sysport[sysport_waitctrl]) 128 (intio_sysport[sysport_waitctrl])
 129#define intio_get_sysport_sramwp() \
 130 (intio_sysport[sysport_sramwp])
129#define intio_get_sysport_mpustat() \ 131#define intio_get_sysport_mpustat() \
130 (intio_sysport[sysport_mpustat]) 132 (intio_sysport[sysport_mpustat])
131 133
132/* I/O controller (sicilian/pluto) */ 134/* I/O controller (sicilian/pluto) */
133#define INTIO_SICILIAN (0x00e9c000) 135#define INTIO_SICILIAN (0x00e9c000)
134#define intio_sicilian ((volatile uint8_t *)IIOV(INTIO_SICILIAN)) 136#define intio_sicilian ((volatile uint8_t *)IIOV(INTIO_SICILIAN))
135#define sicilian_intr 1 137#define sicilian_intr 1
136#define sicilian_ivec 3 138#define sicilian_ivec 3
137 139
138#define intio_get_sicilian_intr() \ 140#define intio_get_sicilian_intr() \
139 (intio_sicilian[sicilian_intr]) 141 (intio_sicilian[sicilian_intr])
140#define intio_set_sicilian_intr(a) \ 142#define intio_set_sicilian_intr(a) \
141 intio_sicilian[sicilian_intr] = (a) 143 intio_sicilian[sicilian_intr] = (a)

cvs diff -r1.185 -r1.186 src/sys/arch/x68k/x68k/machdep.c (expand / switch to unified diff)

--- src/sys/arch/x68k/x68k/machdep.c 2012/07/30 17:19:59 1.185
+++ src/sys/arch/x68k/x68k/machdep.c 2013/01/22 11:58:39 1.186
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: machdep.c,v 1.185 2012/07/30 17:19:59 christos Exp $ */ 1/* $NetBSD: machdep.c,v 1.186 2013/01/22 11:58:39 isaki Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988 University of Utah. 4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1982, 1986, 1990, 1993 5 * Copyright (c) 1982, 1986, 1990, 1993
6 * The Regents of the University of California. All rights reserved. 6 * The Regents of the University of California. All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to Berkeley by 8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer 9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department. 10 * Science Department.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * from: Utah $Hdr: machdep.c 1.74 92/12/20$ 36 * from: Utah $Hdr: machdep.c 1.74 92/12/20$
37 * 37 *
38 * @(#)machdep.c 8.10 (Berkeley) 4/20/94 38 * @(#)machdep.c 8.10 (Berkeley) 4/20/94
39 */ 39 */
40 40
41#include <sys/cdefs.h> 41#include <sys/cdefs.h>
42__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.185 2012/07/30 17:19:59 christos Exp $"); 42__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.186 2013/01/22 11:58:39 isaki Exp $");
43 43
44#include "opt_ddb.h" 44#include "opt_ddb.h"
45#include "opt_kgdb.h" 45#include "opt_kgdb.h"
46#include "opt_compat_netbsd.h" 46#include "opt_compat_netbsd.h"
47#include "opt_fpu_emulate.h" 47#include "opt_fpu_emulate.h"
48#include "opt_m060sp.h" 48#include "opt_m060sp.h"
49#include "opt_modular.h" 49#include "opt_modular.h"
50#include "opt_panicbutton.h" 50#include "opt_panicbutton.h"
51#include "opt_extmem.h" 51#include "opt_extmem.h"
52#include "opt_m68k_arch.h" 52#include "opt_m68k_arch.h"
53 53
54#include <sys/param.h> 54#include <sys/param.h>
55#include <sys/systm.h> 55#include <sys/systm.h>
@@ -115,26 +115,27 @@ char machine[] = MACHINE; /* from  @@ -115,26 +115,27 @@ char machine[] = MACHINE; /* from
115/* Our exported CPU info; we can have only one. */ 115/* Our exported CPU info; we can have only one. */
116struct cpu_info cpu_info_store; 116struct cpu_info cpu_info_store;
117 117
118struct vm_map *phys_map = NULL; 118struct vm_map *phys_map = NULL;
119 119
120extern paddr_t avail_start, avail_end; 120extern paddr_t avail_start, avail_end;
121extern u_int lowram; 121extern u_int lowram;
122extern int end, *esym; 122extern int end, *esym;
123 123
124int maxmem; /* max memory per process */ 124int maxmem; /* max memory per process */
125 125
126/* prototypes for local functions */ 126/* prototypes for local functions */
127void identifycpu(void); 127void identifycpu(void);
 128static int check_emulator(char *, int);
128void initcpu(void); 129void initcpu(void);
129int cpu_dumpsize(void); 130int cpu_dumpsize(void);
130int cpu_dump(int (*)(dev_t, daddr_t, void *, size_t), daddr_t *); 131int cpu_dump(int (*)(dev_t, daddr_t, void *, size_t), daddr_t *);
131void cpu_init_kcore_hdr(void); 132void cpu_init_kcore_hdr(void);
132#ifdef EXTENDED_MEMORY 133#ifdef EXTENDED_MEMORY
133static int mem_exists(void *, u_long); 134static int mem_exists(void *, u_long);
134static void setmemrange(void); 135static void setmemrange(void);
135#endif 136#endif
136 137
137/* functions called from locore.s */ 138/* functions called from locore.s */
138void x68k_init(void); 139void x68k_init(void);
139void dumpsys(void); 140void dumpsys(void);
140void straytrap(int, u_short); 141void straytrap(int, u_short);
@@ -294,26 +295,27 @@ static const char *fpu_descr[] = { @@ -294,26 +295,27 @@ static const char *fpu_descr[] = {
294#endif 295#endif
295 ", m68881 FPU", /* 1 */ 296 ", m68881 FPU", /* 1 */
296 ", m68882 FPU", /* 2 */ 297 ", m68882 FPU", /* 2 */
297 "/FPU", /* 3 */ 298 "/FPU", /* 3 */
298 "/FPU", /* 4 */ 299 "/FPU", /* 4 */
299 }; 300 };
300 301
301void 302void
302identifycpu(void) 303identifycpu(void)
303{ 304{
304 /* there's alot of XXX in here... */ 305 /* there's alot of XXX in here... */
305 const char *cpu_type, *mach, *mmu, *fpu; 306 const char *cpu_type, *mach, *mmu, *fpu;
306 char clock[16]; 307 char clock[16];
 308 char emubuf[20];
307 309
308 /* 310 /*
309 * check machine type constant 311 * check machine type constant
310 */ 312 */
311 switch (intio_get_sysport_mpustat()) { 313 switch (intio_get_sysport_mpustat()) {
312 case 0xdc: 314 case 0xdc:
313 /* 315 /*
314 * CPU Type == 68030, Clock == 25MHz 316 * CPU Type == 68030, Clock == 25MHz
315 */ 317 */
316 mach = "030"; 318 mach = "030";
317 break; 319 break;
318 case 0xfe: 320 case 0xfe:
319 /* 321 /*
@@ -325,26 +327,29 @@ identifycpu(void) @@ -325,26 +327,29 @@ identifycpu(void)
325 /* 327 /*
326 * CPU Type == 68000, Clock == 10MHz 328 * CPU Type == 68000, Clock == 10MHz
327 */ 329 */
328 mach = "000/ACE/PRO/EXPERT/SUPER"; 330 mach = "000/ACE/PRO/EXPERT/SUPER";
329 break; 331 break;
330 default: 332 default:
331 /* 333 /*
332 * unknown type 334 * unknown type
333 */ 335 */
334 mach = "000?(unknown model)"; 336 mach = "000?(unknown model)";
335 break; 337 break;
336 } 338 }
337 339
 340 emubuf[0] = '\0';
 341 check_emulator(emubuf, sizeof(emubuf));
 342
338 cpuspeed = 2048 / delay_divisor; 343 cpuspeed = 2048 / delay_divisor;
339 sprintf(clock, "%dMHz", cpuspeed); 344 sprintf(clock, "%dMHz", cpuspeed);
340 switch (cputype) { 345 switch (cputype) {
341 case CPU_68060: 346 case CPU_68060:
342 cpu_type = "m68060"; 347 cpu_type = "m68060";
343 mmu = "/MMU"; 348 mmu = "/MMU";
344 cpuspeed = 128 / delay_divisor; 349 cpuspeed = 128 / delay_divisor;
345 sprintf(clock, "%d/%dMHz", cpuspeed*2, cpuspeed); 350 sprintf(clock, "%d/%dMHz", cpuspeed*2, cpuspeed);
346 break; 351 break;
347 case CPU_68040: 352 case CPU_68040:
348 cpu_type = "m68040"; 353 cpu_type = "m68040";
349 mmu = "/MMU"; 354 mmu = "/MMU";
350 cpuspeed = 759 / delay_divisor; 355 cpuspeed = 759 / delay_divisor;
@@ -357,32 +362,80 @@ identifycpu(void) @@ -357,32 +362,80 @@ identifycpu(void)
357 case CPU_68020: 362 case CPU_68020:
358 cpu_type = "m68020"; 363 cpu_type = "m68020";
359 mmu = ", m68851 MMU"; 364 mmu = ", m68851 MMU";
360 break; 365 break;
361 default: 366 default:
362 cpu_type = "unknown"; 367 cpu_type = "unknown";
363 mmu = ", unknown MMU"; 368 mmu = ", unknown MMU";
364 break; 369 break;
365 } 370 }
366 if (fputype >= 0 && fputype < sizeof(fpu_descr)/sizeof(fpu_descr[0])) 371 if (fputype >= 0 && fputype < sizeof(fpu_descr)/sizeof(fpu_descr[0]))
367 fpu = fpu_descr[fputype]; 372 fpu = fpu_descr[fputype];
368 else 373 else
369 fpu = ", unknown FPU"; 374 fpu = ", unknown FPU";
370 sprintf(cpu_model, "X68%s (%s CPU%s%s, %s clock)", 375 sprintf(cpu_model, "X68%s (%s CPU%s%s, %s clock)%s%s",
371 mach, cpu_type, mmu, fpu, clock); 376 mach, cpu_type, mmu, fpu, clock,
 377 emubuf[0] ? " on " : "", emubuf);
372 printf("%s\n", cpu_model); 378 printf("%s\n", cpu_model);
373} 379}
374 380
375/* 381/*
 382 * If it is an emulator, store the name in buf and return 1.
 383 * Otherwise return 0.
 384 */
 385static int
 386check_emulator(char *buf, int bufsize)
 387{
 388 int xm6major;
 389 int xm6minor;
 390 int xm6imark;
 391 int xm6imajor;
 392 int xm6iminor;
 393
 394 /* XM6 and its family */
 395 intio_set_sysport_sramwp('X');
 396 if (intio_get_sysport_sramwp() == '6') {
 397 xm6major = intio_get_sysport_sramwp();
 398 xm6minor = intio_get_sysport_sramwp();
 399 xm6imark = intio_get_sysport_sramwp();
 400 switch (xm6imark) {
 401 case 0xff: /* Original XM6 or unknown compatibles */
 402 snprintf(buf, bufsize, "XM6 v%d.%02d",
 403 xm6major, xm6minor);
 404 break;
 405
 406 case 'i': /* XM6i */
 407 xm6imajor = intio_get_sysport_sramwp();
 408 xm6iminor = intio_get_sysport_sramwp();
 409 snprintf(buf, bufsize, "XM6i v%d.%02d",
 410 xm6imajor, xm6iminor);
 411 break;
 412
 413 case 'g': /* XM6 TypeG */
 414 snprintf(buf, bufsize, "XM6 TypeG v%d.%02d",
 415 xm6major, xm6minor);
 416 break;
 417
 418 default: /* Other XM6 compatibles? */
 419 /* XXX what should I do? */
 420 return 0;
 421 }
 422 return 1;
 423 }
 424
 425 return 0;
 426}
 427
 428/*
376 * machine dependent system variables. 429 * machine dependent system variables.
377 */ 430 */
378SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup") 431SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
379{ 432{
380 433
381 sysctl_createv(clog, 0, NULL, NULL, 434 sysctl_createv(clog, 0, NULL, NULL,
382 CTLFLAG_PERMANENT, 435 CTLFLAG_PERMANENT,
383 CTLTYPE_NODE, "machdep", NULL, 436 CTLTYPE_NODE, "machdep", NULL,
384 NULL, 0, NULL, 0, 437 NULL, 0, NULL, 0,
385 CTL_MACHDEP, CTL_EOL); 438 CTL_MACHDEP, CTL_EOL);
386 439
387 sysctl_createv(clog, 0, NULL, NULL, 440 sysctl_createv(clog, 0, NULL, NULL,
388 CTLFLAG_PERMANENT, 441 CTLFLAG_PERMANENT,