| @@ -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. */ |
116 | struct cpu_info cpu_info_store; | | 116 | struct cpu_info cpu_info_store; |
117 | | | 117 | |
118 | struct vm_map *phys_map = NULL; | | 118 | struct vm_map *phys_map = NULL; |
119 | | | 119 | |
120 | extern paddr_t avail_start, avail_end; | | 120 | extern paddr_t avail_start, avail_end; |
121 | extern u_int lowram; | | 121 | extern u_int lowram; |
122 | extern int end, *esym; | | 122 | extern int end, *esym; |
123 | | | 123 | |
124 | int maxmem; /* max memory per process */ | | 124 | int maxmem; /* max memory per process */ |
125 | | | 125 | |
126 | /* prototypes for local functions */ | | 126 | /* prototypes for local functions */ |
127 | void identifycpu(void); | | 127 | void identifycpu(void); |
| | | 128 | static int check_emulator(char *, int); |
128 | void initcpu(void); | | 129 | void initcpu(void); |
129 | int cpu_dumpsize(void); | | 130 | int cpu_dumpsize(void); |
130 | int cpu_dump(int (*)(dev_t, daddr_t, void *, size_t), daddr_t *); | | 131 | int cpu_dump(int (*)(dev_t, daddr_t, void *, size_t), daddr_t *); |
131 | void cpu_init_kcore_hdr(void); | | 132 | void cpu_init_kcore_hdr(void); |
132 | #ifdef EXTENDED_MEMORY | | 133 | #ifdef EXTENDED_MEMORY |
133 | static int mem_exists(void *, u_long); | | 134 | static int mem_exists(void *, u_long); |
134 | static void setmemrange(void); | | 135 | static void setmemrange(void); |
135 | #endif | | 136 | #endif |
136 | | | 137 | |
137 | /* functions called from locore.s */ | | 138 | /* functions called from locore.s */ |
138 | void x68k_init(void); | | 139 | void x68k_init(void); |
139 | void dumpsys(void); | | 140 | void dumpsys(void); |
140 | void straytrap(int, u_short); | | 141 | void 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 | |
301 | void | | 302 | void |
302 | identifycpu(void) | | 303 | identifycpu(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 | */ |
| | | 385 | static int |
| | | 386 | check_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 | */ |
378 | SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup") | | 431 | SYSCTL_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, |