1 /* $NetBSD: m68k_machdep.c,v 1.29 2026/11/15 15:16:24 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 1997, 2026 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /* 30 * Copyright (c) 1988 University of Utah. 31 * Copyright (c) 1982, 1986, 1990, 1993 32 * The Regents of the University of California. All rights reserved. 33 * 34 * This code is derived from software contributed to Berkeley by 35 * the Systems Programming Group of the University of Utah Computer 36 * Science Department. 37 * 38 * Redistribution and use in source and binary forms, with or without 39 * modification, are permitted provided that the following conditions 40 * are met: 41 * 1. Redistributions of source code must retain the above copyright 42 * notice, this list of conditions and the following disclaimer. 43 * 2. Redistributions in binary form must reproduce the above copyright 44 * notice, this list of conditions and the following disclaimer in the 45 * documentation and/or other materials provided with the distribution. 46 * 3. Neither the name of the University nor the names of its contributors 47 * may be used to endorse or promote products derived from this software 48 * without specific prior written permission. 49 * 50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60 * SUCH DAMAGE. 61 * 62 * from: Utah $Hdr: machdep.c 1.74 92/12/20$ 63 * 64 * @(#)machdep.c 8.10 (Berkeley) 4/20/94 65 */ 66 67 #include <sys/cdefs.h> 68 __KERNEL_RCSID(0, "$NetBSD: m68k_machdep.c,v 1.29 2026/11/15 15:16:24 thorpej Exp $"); 69 70 #include "opt_compat_netbsd.h" 71 #include "opt_compat_sunos.h" 72 #include "opt_execfmt.h" 73 #include "opt_m68k_arch.h" 74 #include "opt_fpu_emulate.h" 75 76 #include <sys/param.h> 77 #include <sys/cpu.h> 78 #include <sys/exec.h> 79 #include <sys/lwp.h> 80 #include <sys/proc.h> 81 #include <sys/msgbuf.h> 82 #include <sys/reboot.h> 83 #include <sys/device.h> 84 #include <sys/vnode.h> 85 #include <sys/kernel.h> 86 #include <sys/kcore.h> 87 88 #include <dev/cons.h> 89 90 #ifdef EXEC_AOUT 91 #include <sys/exec_aout.h> /* for cpu_exec_aout_makecmds() prototype */ 92 #endif 93 94 #include <uvm/uvm_extern.h> 95 96 #include <m68k/m68k.h> 97 #include <m68k/kcore.h> 98 #include <m68k/frame.h> 99 #include <m68k/pcb.h> 100 #include <m68k/reg.h> 101 #ifdef M68060 102 #include <m68k/pcr.h> 103 #endif 104 #include <m68k/seglist.h> 105 106 /* the following is used externally (sysctl_hw) */ 107 char machine[] = MACHINE; /* from <machine/param.h> */ 108 char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */ 109 110 /* cpu speed in kHz */ 111 int cpuspeed_khz; 112 113 #if defined(M68020) || defined(M68030) 114 /* fpu speed in kHz */ 115 int fpuspeed_khz; 116 #endif 117 118 #ifdef M68K_EC 119 /* external cache size in bytes */ 120 int ecsize; 121 #endif 122 123 /* 124 * Physical memory segments. These segments are included in kernel 125 * crash dumps, and the available ranges of the segments are loaded 126 * into the VM system as managed pages. 127 */ 128 phys_seg_list_t phys_seg_list[VM_PHYSSEG_MAX]; 129 130 /* 131 * __HAVE_M68K_PRIVATE_MSGSBUF is a hook for the Sun platforms that 132 * are re-using PROM mappings of memory for the messsage buffer that 133 * are not guaranteed to be physically contiguous. 134 * 135 * How we act on this: We don't care about the PA of the message buffer 136 * at all, and we assume that the message buffer has already been mapped 137 * as part of the VM bootstrap. 138 */ 139 #ifndef __HAVE_M68K_PRIVATE_MSGSBUF 140 paddr_t msgbufpa = (paddr_t)-1; /* PA of message buffer */ 141 #endif 142 void *msgbufaddr; 143 144 vaddr_t m68k_usrstack; 145 146 /* 147 * Common tasks for machine_init(). 148 */ 149 void 150 machine_init_common(paddr_t nextpa) 151 { 152 extern paddr_t avail_start, avail_end; 153 int i; 154 #ifndef __HAVE_M68K_PRIVATE_MSGSBUF 155 int end_seg = 0; 156 #endif 157 158 /* 159 * Compute the boundaries of available memory. 160 */ 161 avail_start = UINT_MAX; 162 avail_end = 0; 163 for (i = 0; i < VM_PHYSSEG_MAX; i++) { 164 /* 165 * Make sure the memory segment begins/ends on 166 * page boundaries. 167 * 168 * If ps_avail_start and ps_avail_end have not already 169 * been initialized, go ahead and validate those. 170 */ 171 phys_seg_list[i].ps_start = 172 m68k_round_page(phys_seg_list[i].ps_start); 173 phys_seg_list[i].ps_end = 174 m68k_trunc_page(phys_seg_list[i].ps_end); 175 176 if (phys_seg_list[i].ps_avail_start == 0 && 177 phys_seg_list[i].ps_avail_end == 0) { 178 phys_seg_list[i].ps_avail_start = 179 phys_seg_list[i].ps_start; 180 phys_seg_list[i].ps_avail_end = 181 phys_seg_list[i].ps_end; 182 } 183 184 if (phys_seg_list[i].ps_start == phys_seg_list[i].ps_end) { 185 /* Empty segment. */ 186 continue; 187 } 188 189 /* 190 * nextpa represents the next available page after 191 * the pages already consumed by the bootstrap 192 * process. If it falls within this physical segment, 193 * just the available range as necessary. 194 */ 195 if (nextpa >= phys_seg_list[i].ps_start && 196 /* this <= is intentional */ 197 nextpa <= phys_seg_list[i].ps_end && 198 nextpa > phys_seg_list[i].ps_avail_start) { 199 phys_seg_list[i].ps_avail_start = nextpa; 200 } 201 202 if (phys_seg_list[i].ps_avail_start == 203 phys_seg_list[i].ps_avail_end) { 204 /* Segment has been completely gobbled up. */ 205 continue; 206 } 207 208 if (phys_seg_list[i].ps_avail_start < avail_start) { 209 avail_start = phys_seg_list[i].ps_avail_start; 210 } 211 if (phys_seg_list[i].ps_avail_end > avail_end) { 212 avail_end = phys_seg_list[i].ps_avail_end; 213 #ifndef __HAVE_M68K_PRIVATE_MSGSBUF 214 end_seg = i; 215 #endif 216 } 217 } 218 219 #ifndef __HAVE_M68K_PRIVATE_MSGSBUF 220 /* 221 * If the message buffer has not already been allocated, 222 * allocate it from the end of physical memory. 223 */ 224 if (msgbufpa == (paddr_t)-1) { 225 KASSERT((phys_seg_list[end_seg].ps_avail_end 226 - phys_seg_list[end_seg].ps_avail_start) 227 >= round_page(MSGBUFSIZE)); 228 phys_seg_list[end_seg].ps_avail_end -= round_page(MSGBUFSIZE); 229 msgbufpa = phys_seg_list[end_seg].ps_avail_end; 230 } 231 #endif 232 233 #ifndef VM_PHYS_SEG_TO_FREELIST 234 #define VM_PHYS_SEG_TO_FREELIST(s) VM_FREELIST_DEFAULT 235 #endif 236 237 /* 238 * Now load the pages into the VM system. 239 */ 240 for (i = 0; i < VM_PHYSSEG_MAX; i++) { 241 if (phys_seg_list[i].ps_avail_start == 242 phys_seg_list[i].ps_avail_end) { 243 /* Segment has been completely gobbled up. */ 244 continue; 245 } 246 uvm_page_physload(atop(phys_seg_list[i].ps_avail_start), 247 atop(phys_seg_list[i].ps_avail_end), 248 atop(phys_seg_list[i].ps_avail_start), 249 atop(phys_seg_list[i].ps_avail_end), 250 VM_PHYS_SEG_TO_FREELIST(i)); 251 } 252 253 /* 254 * Initialize the kernel message buffer. 255 */ 256 #ifndef __HAVE_M68K_PRIVATE_MSGSBUF 257 for (i = 0; i < btoc(round_page(MSGBUFSIZE)); i++) { 258 pmap_kenter_pa((vaddr_t)msgbufaddr + i * PAGE_SIZE, 259 msgbufpa + i * PAGE_SIZE, 260 VM_PROT_READ|VM_PROT_WRITE, 0); 261 } 262 pmap_update(pmap_kernel()); 263 #endif 264 initmsgbuf(msgbufaddr, round_page(MSGBUFSIZE)); 265 } 266 267 /* 268 * Common tasks for cpu_startup(). 269 */ 270 void 271 cpu_startup_common(void) 272 { 273 vaddr_t minaddr, maxaddr; 274 char pbuf[9]; 275 276 /* 277 * For the benefit of modules that need USRSTACK (such 278 * as compat exec modules). Initialized here because 279 * USRSTACK may not be a compile-time constant. 280 */ 281 m68k_usrstack = USRSTACK; 282 283 /* Initialize the FPU, if present. */ 284 fpu_init(); 285 286 /* Set the model info. */ 287 machine_set_model(); 288 289 /* 290 * Good {morning,afternoon,evening,night}. 291 * XXX Should augment banner() and then switch to using it. 292 */ 293 printf("%s%s", copyright, version); 294 #ifdef __HAVE_CPU_STARTUP_PRINT_MACHINE_MODEL 295 cpu_startup_print_machine_model(printf); 296 #endif 297 #ifdef __HAVE_CPU_STARTUP_PRINT_TOTAL_MEMORY 298 cpu_startup_print_total_memory(printf); 299 #else 300 format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); 301 printf("total memory = %s\n", pbuf); 302 #endif 303 format_bytes(pbuf, sizeof(pbuf), ptoa(uvm_availmem(false))); 304 printf("avail memory = %s\n", pbuf); 305 306 /* 307 * Allocate a submap for physio 308 */ 309 minaddr = 0; 310 phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, 311 VM_PHYS_SIZE, 0, false, NULL); 312 } 313 __weak_alias(cpu_startup, cpu_startup_common); 314 315 static const char * 316 mhz_string_from_khz(int speed_khz, char *buf, size_t bufsize) 317 { 318 int whole_mhz = speed_khz / 1000; 319 int frac_mhz = (speed_khz % 1000) / 10; 320 if ((frac_mhz % 10) == 0) { 321 frac_mhz /= 10; 322 } 323 if (frac_mhz == 0) { 324 snprintf(buf, bufsize, " @ %dMHz", whole_mhz); 325 } else { 326 snprintf(buf, bufsize, " @ %d.%dMHz", whole_mhz, frac_mhz); 327 } 328 return buf; 329 } 330 331 void 332 cpu_startup_print_machine_model(void (*pr)(const char *, ...) 333 __printflike(1, 2)) 334 { 335 char speed_str[sizeof("@ xxx.xxxMHz")] = { 0 }; 336 337 /* 338 * Caller should have set the system model already. We 339 * will print the CPU information after, like so: 340 * 341 * MODEL 342 * CPU MMU FPU CACHE 343 * 344 * Examples: 345 346 Qemu 10.1.2 Virt platform 347 MC68040+MMU+FPU, 4k+4k on-chip I/D caches 348 349 Motorola MVME-147 350 MC68030 CPU+MMU @ 25MHz, MC68882 FPU 351 352 HP 9000/433s 353 MC68040 CPU+MMU+FPU @ 33MHz, 4K+4K on-chip I/D caches 354 355 HP 9000/320 356 MC68020 CPU @ 16.67MHz, HP MMU, MC68881 FPU 357 External 16K virtual-address cache 358 359 HP 9000/350 360 MC68020 CPU @ 25MHz, HP MMU, MC68881 FPU @ 20MHz 361 External 32K virtual-address cache 362 363 * ^^^ Yes, there's at least one HP system where the FPU 364 * has a different clock than the CPU. 365 * 366 * There is a hook that allows machine-specific code to print 367 * a more informative model banner, such as: 368 369 Model: sun3x 80 370 MC68030 CPU+MMU @ 20MHz, MC68882 FPU 371 372 Model: sun3 160 373 MC68020 CPU @ 16.67MHz, Sun MMU, MC68881 FPU 374 375 Model: sun2 {120,170} 376 MC68010 CPU @ 10MHz, Sun MMU 377 378 SONY NET WORK STATION, Model NWS-1710, Machine ID #123456 379 MC68030 CPU+MMU @ 25MHz, MC68882 FPU 380 381 * (In this last example, cpu_model() returns "NWS-1710".) 382 * In the Sun examples, for historical reasons, the model 383 * string is formatted a certain way for use by the installer 384 * miniroot. 385 * 386 * This is a departure from how it has been on some NetBSD 387 * systems historically, but this is intended to bring some 388 * consistency to the platforms while maintaining a reasonable 389 * aesthetic. 390 */ 391 #ifdef __HAVE_M68K_MACHINE_PRINT_MODEL 392 machine_print_model(pr); 393 #else 394 (*pr)("%s\n", cpu_getmodel()); 395 #endif 396 397 switch (cputype) { 398 #ifdef M68010 399 case CPU_68010: 400 (*pr)("MC68010 CPU"); 401 break; 402 #endif 403 #ifdef M68020 404 case CPU_68020: 405 (*pr)("MC68020 CPU"); 406 break; 407 #endif 408 #ifdef M68030 409 case CPU_68030: 410 (*pr)("MC68030 CPU+MMU"); 411 break; 412 #endif 413 #ifdef M68040 414 case CPU_68040: 415 (*pr)("MC68040 CPU+MMU"); 416 break; 417 #endif 418 #ifdef M68060 419 case CPU_68060: { 420 u_int pcr = get_pcr(); 421 (*pr)("MC68%s060 rev.%d CPU+MMU", 422 (PCR_ID(pcr) & 1) ? "LC" : "", 423 (int)PCR_REVISION(pcr)); 424 if (pcr & PCR_DFP) { 425 (*pr)("+FPU(disabled)"); 426 } 427 break; 428 } 429 #endif 430 default: 431 (*pr)("unknown CPU type\n"); 432 panic("startup"); 433 } 434 435 #if defined(M68040) || defined(M68060) 436 switch (fputype) { 437 case FPU_68040: 438 case FPU_68060: 439 (*pr)("+FPU"); 440 break; 441 default: 442 break; 443 } 444 #endif 445 446 if (cpuspeed_khz) { 447 (*pr)("%s", 448 mhz_string_from_khz(cpuspeed_khz, 449 speed_str, sizeof(speed_str))); 450 } 451 452 switch (mmutype) { 453 #ifdef M68K_MMU_68851 454 case MMU_68851: 455 (*pr)(", MC68851 MMU"); 456 break; 457 #endif 458 #ifdef M68K_MMU_HP 459 case MMU_HP: 460 (*pr)(", HP MMU"); 461 break; 462 #endif 463 #ifdef M68K_MMU_SUN 464 case MMU_SUN: 465 (*pr)(", Sun MMU"); 466 break; 467 #endif 468 #ifdef M68K_MMU_CUSTOM 469 case MMU_CUSTOM: 470 (*pr)(", custom MMU"); 471 break; 472 #endif 473 default: 474 break; 475 } 476 477 switch (fputype) { 478 #ifdef FPU_EMULATE 479 case FPU_NONE: 480 (*pr)(", emulated FPU"); 481 break; 482 #endif 483 #if defined(M68020) || defined(M68030) 484 case FPU_68881: 485 (*pr)(", MC68881 FPU"); 486 break; 487 488 case FPU_68882: 489 (*pr)(", MC68882 FPU"); 490 break; 491 #endif 492 default: 493 break; 494 } 495 496 #if defined(M68020) || defined(M68030) 497 if (fpuspeed_khz != 0 && fpuspeed_khz != cpuspeed_khz) { 498 (*pr)("%s", 499 mhz_string_from_khz(fpuspeed_khz, 500 speed_str, sizeof(speed_str))); 501 } 502 #endif 503 504 switch (cputype) { 505 #if defined(M68040) || defined(M68060) 506 case CPU_68040: 507 case CPU_68060: 508 (*pr)(", %dK+%dK on-chip I/D caches", 509 cputype == CPU_68040 ? 4 : 8, 510 cputype == CPU_68040 ? 4 : 8); 511 break; 512 #endif 513 default: 514 #ifdef M68K_EC 515 if (ectype != EC_NONE) { 516 (*pr)("\nExternal "); 517 if (ecsize >= 1024) { 518 (*pr)("%dK ", ecsize / 1024); 519 } 520 (*pr)("%s-address cache", 521 ectype == EC_PHYS ? "physical" : "virtual"); 522 } 523 #endif 524 break; 525 } 526 (*pr)("\n"); 527 } 528 529 int 530 mm_md_physacc_regular(paddr_t pa, vm_prot_t prot) 531 { 532 int i; 533 534 for (i = 0; i < VM_PHYSSEG_MAX; i++) { 535 if (phys_seg_list[i].ps_start == phys_seg_list[i].ps_end) { 536 continue; 537 } 538 if (pa < phys_seg_list[i].ps_start) { 539 continue; 540 } 541 if (pa >= phys_seg_list[i].ps_end) { 542 continue; 543 } 544 return 0; 545 } 546 return EFAULT; 547 } 548 549 int 550 cpu_reboot_poll_console(bool wait) 551 { 552 int rv; 553 554 cnpollc(true); 555 /* If there is no console input device, cngetc() returns 0. */ 556 while ((rv = cngetc()) == 0 && wait) { 557 delay(100000); 558 } 559 cnpollc(false); 560 561 return rv; 562 } 563 564 void 565 machine_powerdown_default(void) 566 { 567 /* zip, nada, nothing */ 568 } 569 __weak_alias(machine_powerdown,machine_powerdown_default); 570 571 void 572 machine_halt_default(void) 573 { 574 printf("Please press any key to reboot.\n"); 575 576 cpu_reboot_poll_console(true); 577 } 578 __weak_alias(machine_halt,machine_halt_default); 579 580 int waittime = -1; 581 582 void 583 bootsync(void) 584 { 585 if (waittime < 0) { 586 waittime = 0; 587 vfs_shutdown(); 588 } 589 } 590 591 void 592 cpu_reboot_common(int howto, char *bootstr) 593 { 594 struct pcb *pcb = lwp_getpcb(curlwp); 595 596 /* take a snap shot before clobbering any registers */ 597 if (pcb != NULL) { 598 savectx(pcb); 599 } 600 601 /* If system is hold, just halt. */ 602 if (cold) { 603 howto |= RB_HALT; 604 goto haltsys; 605 } 606 607 /* Un-blank the screen if appropriate. */ 608 cnpollc(true); 609 610 boothowto = howto; 611 if ((howto & RB_NOSYNC) == 0) { 612 bootsync(); 613 } 614 615 /* Disable interrupts. */ 616 splhigh(); 617 618 /* If rebooting and a dump is requested, do it. */ 619 if (howto & RB_DUMP) { 620 dumpsys(); 621 } 622 623 haltsys: 624 /* Run any shutdown hooks. */ 625 doshutdownhooks(); 626 627 pmf_system_shutdown(boothowto); 628 629 #if defined(PANICWAIT) && !defined(DDB) 630 if ((howto & RB_HALT) == 0 && panicstr) { 631 printf("hit any key to reboot...\n"); 632 cpu_reboot_poll_console(false); 633 printf("\n"); 634 } 635 #endif 636 637 /* Finally, halt/reboot the system. */ 638 if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { 639 machine_powerdown(); 640 } 641 if (howto & RB_HALT) { 642 printf("The operating system has halted.\n"); 643 machine_halt(); 644 } 645 646 printf("rebooting...\n"); 647 delay(1000000); 648 machine_reboot(howto, bootstr); 649 printf("WARNING: system reboot failed, holding here.\n\n"); 650 for (;;) { 651 /* spin forever. */ 652 } 653 } 654 __weak_alias(cpu_reboot,cpu_reboot_common); 655 656 /* 657 * mm_md_physacc_common is the standard implementation for all 658 * m68k platforms, and covers regular physical memory. If a 659 * platform wants to include other ranges, it can simply 660 * define its own mm_md_physacc(), call mm_md_physacc_common() 661 * first, and then check its own ranges if mm_md_physacc_common() 662 * does not return 0. 663 */ 664 __weak_alias(mm_md_physacc, mm_md_physacc_regular); 665 666 /* 667 * Set registers on exec. 668 */ 669 void 670 setregs(struct lwp *l, struct exec_package *pack, vaddr_t stack) 671 { 672 struct trapframe *tf = (struct trapframe *)l->l_md.md_regs; 673 struct pcb *pcb = lwp_getpcb(l); 674 675 memset(tf, 0, sizeof(*tf)); 676 677 tf->tf_sr = PSL_USERSET; 678 tf->tf_pc = pack->ep_entry & ~1; 679 tf->tf_regs[D0] = 0; 680 tf->tf_regs[D1] = 0; 681 tf->tf_regs[D2] = 0; 682 tf->tf_regs[D3] = 0; 683 tf->tf_regs[D4] = 0; 684 tf->tf_regs[D5] = 0; 685 tf->tf_regs[D6] = 0; 686 tf->tf_regs[D7] = 0; 687 tf->tf_regs[A0] = 0; 688 tf->tf_regs[A1] = 0; 689 tf->tf_regs[A2] = l->l_proc->p_psstrp; 690 tf->tf_regs[A3] = 0; 691 tf->tf_regs[A4] = 0; 692 tf->tf_regs[A5] = 0; 693 tf->tf_regs[A6] = 0; 694 tf->tf_regs[SP] = stack; 695 696 /* restore a null state frame */ 697 pcb->pcb_fpregs.fpf_null = 0; 698 #if !defined(__mc68010__) 699 if (fputype) 700 fpu_restore(&pcb->pcb_fpregs); 701 #endif 702 703 #ifdef COMPAT_SUNOS 704 /* see m68k/sunos_syscall.c */ 705 l->l_md.md_flags = 0; 706 #endif 707 } 708 709 #ifdef EXEC_AOUT 710 /* 711 * cpu_exec_aout_makecmds(): 712 * cpu-dependent a.out format hook for execve(). 713 * 714 * Determine of the given exec package refers to something which we 715 * understand and, if so, set up the vmcmds for it. 716 * 717 * XXX what are the special cases for the hp300? 718 * XXX why is this COMPAT_NOMID? was something generating 719 * hp300 binaries with an a_mid of 0? i thought that was only 720 * done on little-endian machines... -- cgd 721 * XXX perhaps this whole thing should be relegated to a smoking crater? 722 */ 723 int 724 cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp) 725 { 726 #ifdef __mc68010__ 727 /* There were never native a.out binaries for NetBSD on 68010. */ 728 return ENOEXEC; 729 #elif defined(COMPAT_NOMID) || defined(COMPAT_44) 730 struct exec *execp = epp->ep_hdr; 731 u_long midmag, magic; 732 u_short mid; 733 int error; 734 735 midmag = ntohl(execp->a_midmag); 736 mid = (midmag >> 16) & 0xffff; 737 magic = midmag & 0xffff; 738 739 midmag = mid << 16 | magic; 740 741 switch (midmag) { 742 #ifdef COMPAT_NOMID 743 case (MID_ZERO << 16) | ZMAGIC: 744 error = exec_aout_prep_oldzmagic(l, epp); 745 break; 746 #endif 747 #ifdef COMPAT_44 748 case (MID_HP300 << 16) | ZMAGIC: 749 error = exec_aout_prep_oldzmagic(l, epp); 750 break; 751 #endif 752 default: 753 error = ENOEXEC; 754 } 755 return error; 756 #else /* COMPAT_NOMID || COMPAT_44 */ 757 return ENOEXEC; 758 #endif 759 } 760 #endif /* EXEC_AOUT */ 761 762 /* 763 * On multi-processor systems, the cpu_info shares a page with the 764 * page tables that map it. Those page tables occupy the last 1280 765 * bytes (512+512+256) of that page. For good measure, assert that 766 * cpu_info fits in 2048 bytes. 767 */ 768 __CTASSERT(sizeof(struct cpu_info) <= 2048); 769 770 /* List of all CPUs present on the system. */ 771 struct cpu_info *cpu_info_list = &cpu_info_primary; 772