1 /* 2 * Copyright (C) 1995, 1996 Wolfgang Solfrank. 3 * Copyright (C) 1995, 1996 TooLs GmbH. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by TooLs GmbH. 17 * 4. The name of TooLs GmbH may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 /* 32 * Copyright (C) 2001 Benno Rice 33 * All rights reserved. 34 * 35 * Redistribution and use in source and binary forms, with or without 36 * modification, are permitted provided that the following conditions 37 * are met: 38 * 1. Redistributions of source code must retain the above copyright 39 * notice, this list of conditions and the following disclaimer. 40 * 2. Redistributions in binary form must reproduce the above copyright 41 * notice, this list of conditions and the following disclaimer in the 42 * documentation and/or other materials provided with the distribution. 43 * 44 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR 45 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 46 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 47 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 49 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 50 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 51 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 52 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 53 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 54 * $NetBSD: machdep.c,v 1.74.2.1 2000/11/01 16:13:48 tv Exp $ 55 */ 56 57 #include <sys/cdefs.h> 58 __FBSDID("$FreeBSD$"); 59 60 #include "opt_ddb.h" 61 #include "opt_compat.h" 62 #include "opt_msgbuf.h" 63 64 #include <sys/param.h> 65 #include <sys/systm.h> 66 #include <sys/eventhandler.h> 67 #include <sys/imgact.h> 68 #include <sys/sysproto.h> 69 #include <sys/lock.h> 70 #include <sys/mutex.h> 71 #include <sys/ktr.h> 72 #include <sys/signalvar.h> 73 #include <sys/kernel.h> 74 #include <sys/proc.h> 75 #include <sys/malloc.h> 76 #include <sys/reboot.h> 77 #include <sys/bio.h> 78 #include <sys/buf.h> 79 #include <sys/bus.h> 80 #include <sys/mbuf.h> 81 #include <sys/vmmeter.h> 82 #include <sys/msgbuf.h> 83 #include <sys/exec.h> 84 #include <sys/sysctl.h> 85 #include <sys/uio.h> 86 #include <sys/linker.h> 87 #include <sys/cons.h> 88 #include <sys/ucontext.h> 89 #include <sys/sysent.h> 90 #include <net/netisr.h> 91 #include <vm/vm.h> 92 #include <vm/vm_kern.h> 93 #include <vm/vm_page.h> 94 #include <vm/vm_map.h> 95 #include <vm/vm_extern.h> 96 #include <vm/vm_object.h> 97 #include <vm/vm_pager.h> 98 #include <sys/user.h> 99 #include <sys/ptrace.h> 100 #include <machine/bat.h> 101 #include <machine/clock.h> 102 #include <machine/md_var.h> 103 #include <machine/metadata.h> 104 #include <machine/reg.h> 105 #include <machine/fpu.h> 106 #include <machine/vmparam.h> 107 #include <machine/elf.h> 108 #include <machine/trap.h> 109 #include <machine/powerpc.h> 110 #include <dev/ofw/openfirm.h> 111 #include <ddb/ddb.h> 112 #include <sys/vnode.h> 113 #include <machine/sigframe.h> 114 115 int cold = 1; 116 117 char pcpu0[PAGE_SIZE]; 118 char uarea0[UAREA_PAGES * PAGE_SIZE]; 119 struct trapframe frame0; 120 121 vm_offset_t kstack0; 122 vm_offset_t kstack0_phys; 123 124 char machine[] = "powerpc"; 125 SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, ""); 126 127 static char model[128]; 128 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, model, 0, ""); 129 130 static int cacheline_size = CACHELINESIZE; 131 SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size, 132 CTLFLAG_RD, &cacheline_size, 0, ""); 133 134 #ifdef DDB 135 /* start and end of kernel symbol table */ 136 void *ksym_start, *ksym_end; 137 #endif /* DDB */ 138 139 static void cpu_startup(void *); 140 SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL) 141 142 void powerpc_init(u_int, u_int, u_int, void *); 143 144 int save_ofw_mapping(void); 145 int restore_ofw_mapping(void); 146 147 void install_extint(void (*)(void)); 148 149 int setfault(faultbuf); /* defined in locore.S */ 150 151 long Maxmem = 0; 152 153 struct pmap ofw_pmap; 154 extern int ofmsr; 155 156 struct bat battable[16]; 157 158 struct kva_md_info kmi; 159 160 static void 161 powerpc_ofw_shutdown(void *junk, int howto) 162 { 163 if (howto & RB_HALT) { 164 OF_exit(); 165 } 166 } 167 168 static void 169 cpu_startup(void *dummy) 170 { 171 172 /* 173 * Initialise the decrementer-based clock. 174 */ 175 decr_init(); 176 177 /* 178 * Good {morning,afternoon,evening,night}. 179 */ 180 cpu_setup(PCPU_GET(cpuid)); 181 182 /* startrtclock(); */ 183 #ifdef PERFMON 184 perfmon_init(); 185 #endif 186 printf("real memory = %ld (%ld MB)\n", ptoa(Maxmem), 187 ptoa(Maxmem) / 1048576); 188 189 /* 190 * Display any holes after the first chunk of extended memory. 191 */ 192 if (bootverbose) { 193 int indx; 194 195 printf("Physical memory chunk(s):\n"); 196 for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) { 197 int size1 = phys_avail[indx + 1] - phys_avail[indx]; 198 199 printf("0x%08x - 0x%08x, %d bytes (%d pages)\n", 200 phys_avail[indx], phys_avail[indx + 1] - 1, size1, 201 size1 / PAGE_SIZE); 202 } 203 } 204 205 vm_ksubmap_init(&kmi); 206 207 printf("avail memory = %ld (%ld MB)\n", ptoa(cnt.v_free_count), 208 ptoa(cnt.v_free_count) / 1048576); 209 210 /* 211 * Set up buffers, so they can be used to read disk labels. 212 */ 213 bufinit(); 214 vm_pager_bufferinit(); 215 216 EVENTHANDLER_REGISTER(shutdown_final, powerpc_ofw_shutdown, 0, 217 SHUTDOWN_PRI_LAST); 218 219 #ifdef SMP 220 /* 221 * OK, enough kmem_alloc/malloc state should be up, lets get on with it! 222 */ 223 mp_start(); /* fire up the secondaries */ 224 mp_announce(); 225 #endif /* SMP */ 226 } 227 228 extern char kernel_text[], _end[]; 229 230 extern void *trapcode, *trapsize; 231 extern void *alitrap, *alisize; 232 extern void *dsitrap, *dsisize; 233 extern void *isitrap, *isisize; 234 extern void *decrint, *decrsize; 235 extern void *tlbimiss, *tlbimsize; 236 extern void *tlbdlmiss, *tlbdlmsize; 237 extern void *tlbdsmiss, *tlbdsmsize; 238 extern void *extint, *extsize; 239 240 #if 0 /* XXX: interrupt handler. We'll get to this later */ 241 extern void ext_intr(void); 242 #endif 243 244 #ifdef DDB 245 extern ddblow, ddbsize; 246 #endif 247 #ifdef IPKDB 248 extern ipkdblow, ipkdbsize; 249 #endif 250 251 void 252 powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp) 253 { 254 struct pcpu *pc; 255 vm_offset_t end, off; 256 void *kmdp; 257 258 end = 0; 259 kmdp = NULL; 260 261 /* 262 * Parse metadata if present and fetch parameters. Must be done 263 * before console is inited so cninit gets the right value of 264 * boothowto. 265 */ 266 if (mdp != NULL) { 267 preload_metadata = mdp; 268 kmdp = preload_search_by_type("elf kernel"); 269 if (kmdp != NULL) { 270 boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); 271 kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); 272 end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); 273 } 274 } 275 276 /* 277 * Initialize the console before printing anything. 278 */ 279 cninit(); 280 281 /* 282 * Complain if there is no metadata. 283 */ 284 if (mdp == NULL || kmdp == NULL) { 285 printf("powerpc_init: no loader metadata.\n"); 286 } 287 288 #ifdef DDB 289 kdb_init(); 290 #endif 291 /* 292 * XXX: Initialize the interrupt tables. 293 */ 294 bcopy(&trapcode, (void *)EXC_MCHK, (size_t)&trapsize); 295 bcopy(&dsitrap, (void *)EXC_DSI, (size_t)&dsisize); 296 bcopy(&isitrap, (void *)EXC_ISI, (size_t)&isisize); 297 bcopy(&trapcode, (void *)EXC_EXI, (size_t)&trapsize); 298 bcopy(&trapcode, (void *)EXC_ALI, (size_t)&trapsize); 299 bcopy(&trapcode, (void *)EXC_PGM, (size_t)&trapsize); 300 bcopy(&trapcode, (void *)EXC_FPU, (size_t)&trapsize); 301 bcopy(&trapcode, (void *)EXC_DECR, (size_t)&trapsize); 302 bcopy(&trapcode, (void *)EXC_SC, (size_t)&trapsize); 303 bcopy(&trapcode, (void *)EXC_TRC, (size_t)&trapsize); 304 __syncicache(EXC_RSVD, EXC_LAST - EXC_RSVD); 305 306 /* 307 * Start initializing proc0 and thread0. 308 */ 309 proc_linkup(&proc0, &ksegrp0, &kse0, &thread0); 310 proc0.p_uarea = (struct user *)uarea0; 311 proc0.p_stats = &proc0.p_uarea->u_stats; 312 thread0.td_frame = &frame0; 313 314 /* 315 * Set up per-cpu data. 316 */ 317 pc = (struct pcpu *)(pcpu0 + PAGE_SIZE) - 1; 318 pcpu_init(pc, 0, sizeof(struct pcpu)); 319 pc->pc_curthread = &thread0; 320 pc->pc_curpcb = thread0.td_pcb; 321 pc->pc_cpuid = 0; 322 /* pc->pc_mid = mid; */ 323 324 __asm __volatile("mtsprg 0, %0" :: "r"(pc)); 325 326 mutex_init(); 327 328 /* 329 * Make sure translation has been enabled 330 */ 331 mtmsr(mfmsr() | PSL_IR|PSL_DR|PSL_ME|PSL_RI); 332 333 /* 334 * Initialise virtual memory. 335 */ 336 pmap_bootstrap(startkernel, endkernel); 337 338 /* 339 * Initialize tunables. 340 */ 341 init_param1(); 342 init_param2(physmem); 343 344 /* 345 * Finish setting up thread0. 346 */ 347 thread0.td_kstack = kstack0; 348 thread0.td_pcb = (struct pcb *) 349 (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; 350 351 /* 352 * Map and initialise the message buffer. 353 */ 354 for (off = 0; off < round_page(MSGBUF_SIZE); off += PAGE_SIZE) 355 pmap_kenter((vm_offset_t)msgbufp + off, msgbuf_phys + off); 356 msgbufinit(msgbufp, MSGBUF_SIZE); 357 } 358 359 void 360 bzero(void *buf, size_t len) 361 { 362 caddr_t p; 363 364 p = buf; 365 366 while (((vm_offset_t) p & (sizeof(u_long) - 1)) && len) { 367 *p++ = 0; 368 len--; 369 } 370 371 while (len >= sizeof(u_long) * 8) { 372 *(u_long*) p = 0; 373 *((u_long*) p + 1) = 0; 374 *((u_long*) p + 2) = 0; 375 *((u_long*) p + 3) = 0; 376 len -= sizeof(u_long) * 8; 377 *((u_long*) p + 4) = 0; 378 *((u_long*) p + 5) = 0; 379 *((u_long*) p + 6) = 0; 380 *((u_long*) p + 7) = 0; 381 p += sizeof(u_long) * 8; 382 } 383 384 while (len >= sizeof(u_long)) { 385 *(u_long*) p = 0; 386 len -= sizeof(u_long); 387 p += sizeof(u_long); 388 } 389 390 while (len) { 391 *p++ = 0; 392 len--; 393 } 394 } 395 396 void 397 sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) 398 { 399 struct trapframe *tf; 400 struct sigframe *sfp; 401 struct sigacts *psp; 402 struct sigframe sf; 403 struct thread *td; 404 struct proc *p; 405 int oonstack, rndfsize; 406 407 td = curthread; 408 p = td->td_proc; 409 PROC_LOCK_ASSERT(p, MA_OWNED); 410 psp = p->p_sigacts; 411 mtx_assert(&psp->ps_mtx, MA_OWNED); 412 tf = td->td_frame; 413 oonstack = sigonstack(tf->fixreg[1]); 414 415 rndfsize = ((sizeof(sf) + 15) / 16) * 16; 416 417 CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, 418 catcher, sig); 419 420 /* 421 * Save user context 422 */ 423 memset(&sf, 0, sizeof(sf)); 424 sf.sf_uc.uc_sigmask = *mask; 425 sf.sf_uc.uc_stack = p->p_sigstk; 426 sf.sf_uc.uc_stack.ss_flags = (p->p_flag & P_ALTSTACK) 427 ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE; 428 429 sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0; 430 memcpy(&sf.sf_uc.uc_mcontext.mc_frame, tf, sizeof(struct trapframe)); 431 432 /* 433 * Allocate and validate space for the signal handler context. 434 */ 435 if ((p->p_flag & P_ALTSTACK) != 0 && !oonstack && 436 SIGISMEMBER(psp->ps_sigonstack, sig)) { 437 sfp = (struct sigframe *)((caddr_t)p->p_sigstk.ss_sp + 438 p->p_sigstk.ss_size - rndfsize); 439 } else { 440 sfp = (struct sigframe *)(tf->fixreg[1] - rndfsize); 441 } 442 443 /* 444 * Translate the signal if appropriate (Linux emu ?) 445 */ 446 if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) 447 sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; 448 449 /* 450 * Save the floating-point state, if necessary, then copy it. 451 */ 452 /* XXX */ 453 454 /* 455 * Set up the registers to return to sigcode. 456 * 457 * r1/sp - sigframe ptr 458 * lr - sig function, dispatched to by blrl in trampoline 459 * r3 - sig number 460 * r4 - SIGINFO ? &siginfo : exception code 461 * r5 - user context 462 * srr0 - trampoline function addr 463 */ 464 tf->lr = (register_t)catcher; 465 tf->fixreg[1] = (register_t)sfp; 466 tf->fixreg[FIRSTARG] = sig; 467 tf->fixreg[FIRSTARG+2] = (register_t)&sfp->sf_uc; 468 if (SIGISMEMBER(psp->ps_siginfo, sig)) { 469 /* 470 * Signal handler installed with SA_SIGINFO. 471 */ 472 tf->fixreg[FIRSTARG+1] = (register_t)&sfp->sf_si; 473 474 /* 475 * Fill siginfo structure. 476 */ 477 sf.sf_si.si_signo = sig; 478 sf.sf_si.si_code = code; 479 sf.sf_si.si_addr = (void *)tf->srr0; 480 } else { 481 /* Old FreeBSD-style arguments. */ 482 tf->fixreg[FIRSTARG+1] = code; 483 } 484 mtx_unlock(&psp->ps_mtx); 485 PROC_UNLOCK(p); 486 487 tf->srr0 = (register_t)(PS_STRINGS - *(p->p_sysent->sv_szsigcode)); 488 489 /* 490 * copy the frame out to userland. 491 */ 492 if (copyout((caddr_t)&sf, (caddr_t)sfp, sizeof(sf)) != 0) { 493 /* 494 * Process has trashed its stack. Kill it. 495 */ 496 CTR2(KTR_SIG, "sendsig: sigexit td=%p sfp=%p", td, sfp); 497 PROC_LOCK(p); 498 sigexit(td, SIGILL); 499 } 500 501 CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, 502 tf->srr0, tf->fixreg[1]); 503 504 PROC_LOCK(p); 505 mtx_lock(&psp->ps_mtx); 506 } 507 508 /* 509 * Build siginfo_t for SA thread 510 */ 511 void 512 cpu_thread_siginfo(int sig, u_long code, siginfo_t *si) 513 { 514 struct proc *p; 515 struct thread *td; 516 517 td = curthread; 518 p = td->td_proc; 519 PROC_LOCK_ASSERT(p, MA_OWNED); 520 521 bzero(si, sizeof(*si)); 522 si->si_signo = sig; 523 si->si_code = code; 524 /* XXXKSE fill other fields */ 525 } 526 527 int 528 sigreturn(struct thread *td, struct sigreturn_args *uap) 529 { 530 struct trapframe *tf; 531 struct proc *p; 532 ucontext_t uc; 533 534 CTR2(KTR_SIG, "sigreturn: td=%p ucp=%p", td, uap->sigcntxp); 535 536 if (copyin(uap->sigcntxp, &uc, sizeof(uc)) != 0) { 537 CTR1(KTR_SIG, "sigreturn: efault td=%p", td); 538 return (EFAULT); 539 } 540 541 /* 542 * Don't let the user set privileged MSR bits 543 */ 544 tf = td->td_frame; 545 if ((uc.uc_mcontext.mc_frame.srr1 & PSL_USERSTATIC) != 546 (tf->srr1 & PSL_USERSTATIC)) { 547 return (EINVAL); 548 } 549 550 /* 551 * Restore the user-supplied context 552 */ 553 memcpy(tf, &uc.uc_mcontext.mc_frame, sizeof(struct trapframe)); 554 555 p = td->td_proc; 556 PROC_LOCK(p); 557 td->td_sigmask = uc.uc_sigmask; 558 SIG_CANTMASK(td->td_sigmask); 559 signotify(td); 560 PROC_UNLOCK(p); 561 562 /* 563 * Restore FP state 564 */ 565 /* XXX */ 566 567 CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x", 568 td, tf->srr0, tf->fixreg[1]); 569 570 return (EJUSTRETURN); 571 } 572 573 #ifdef COMPAT_FREEBSD4 574 int 575 freebsd4_sigreturn(struct thread *td, struct freebsd4_sigreturn_args *uap) 576 { 577 578 return sigreturn(td, (struct sigreturn_args *)uap); 579 } 580 #endif 581 582 int 583 get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret) 584 { 585 586 return (ENOSYS); 587 } 588 589 int 590 set_mcontext(struct thread *td, const mcontext_t *mcp) 591 { 592 593 return (ENOSYS); 594 } 595 596 void 597 cpu_boot(int howto) 598 { 599 } 600 601 /* 602 * Shutdown the CPU as much as possible. 603 */ 604 void 605 cpu_halt(void) 606 { 607 608 OF_exit(); 609 } 610 611 /* 612 * Set set up registers on exec. 613 */ 614 void 615 exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) 616 { 617 struct trapframe *tf; 618 struct ps_strings arginfo; 619 620 tf = trapframe(td); 621 bzero(tf, sizeof *tf); 622 tf->fixreg[1] = -roundup(-stack + 8, 16); 623 624 /* 625 * XXX Machine-independent code has already copied arguments and 626 * XXX environment to userland. Get them back here. 627 */ 628 (void)copyin((char *)PS_STRINGS, &arginfo, sizeof(arginfo)); 629 630 /* 631 * Set up arguments for _start(): 632 * _start(argc, argv, envp, obj, cleanup, ps_strings); 633 * 634 * Notes: 635 * - obj and cleanup are the auxilliary and termination 636 * vectors. They are fixed up by ld.elf_so. 637 * - ps_strings is a NetBSD extention, and will be 638 * ignored by executables which are strictly 639 * compliant with the SVR4 ABI. 640 * 641 * XXX We have to set both regs and retval here due to different 642 * XXX calling convention in trap.c and init_main.c. 643 */ 644 /* 645 * XXX PG: these get overwritten in the syscall return code. 646 * execve() should return EJUSTRETURN, like it does on NetBSD. 647 * Emulate by setting the syscall return value cells. The 648 * registers still have to be set for init's fork trampoline. 649 */ 650 td->td_retval[0] = arginfo.ps_nargvstr; 651 td->td_retval[1] = (register_t)arginfo.ps_argvstr; 652 tf->fixreg[3] = arginfo.ps_nargvstr; 653 tf->fixreg[4] = (register_t)arginfo.ps_argvstr; 654 tf->fixreg[5] = (register_t)arginfo.ps_envstr; 655 tf->fixreg[6] = 0; /* auxillary vector */ 656 tf->fixreg[7] = 0; /* termination vector */ 657 tf->fixreg[8] = (register_t)PS_STRINGS; /* NetBSD extension */ 658 659 tf->srr0 = entry; 660 tf->srr1 = PSL_MBO | PSL_USERSET | PSL_FE_DFLT; 661 td->td_pcb->pcb_flags = 0; 662 } 663 664 #if !defined(DDB) 665 void 666 Debugger(const char *msg) 667 { 668 669 printf("Debugger(\"%s\") called.\n", msg); 670 } 671 #endif /* !defined(DDB) */ 672 673 /* XXX: dummy {fill,set}_[fp]regs */ 674 int 675 fill_regs(struct thread *td, struct reg *regs) 676 { 677 678 return (ENOSYS); 679 } 680 681 int 682 fill_dbregs(struct thread *td, struct dbreg *dbregs) 683 { 684 685 return (ENOSYS); 686 } 687 688 int 689 fill_fpregs(struct thread *td, struct fpreg *fpregs) 690 { 691 692 return (ENOSYS); 693 } 694 695 int 696 set_regs(struct thread *td, struct reg *regs) 697 { 698 699 return (ENOSYS); 700 } 701 702 int 703 set_dbregs(struct thread *td, struct dbreg *dbregs) 704 { 705 706 return (ENOSYS); 707 } 708 709 int 710 set_fpregs(struct thread *td, struct fpreg *fpregs) 711 { 712 713 return (ENOSYS); 714 } 715 716 int 717 ptrace_set_pc(struct thread *td, unsigned long addr) 718 { 719 720 /* XXX: coming soon... */ 721 return (ENOSYS); 722 } 723 724 int 725 ptrace_single_step(struct thread *td) 726 { 727 728 /* XXX: coming soon... */ 729 return (ENOSYS); 730 } 731 732 /* 733 * Initialise a struct pcpu. 734 */ 735 void 736 cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz) 737 { 738 739 pcpu->pc_current_asngen = 1; 740 } 741 742 /* 743 * kcopy(const void *src, void *dst, size_t len); 744 * 745 * Copy len bytes from src to dst, aborting if we encounter a fatal 746 * page fault. 747 * 748 * kcopy() _must_ save and restore the old fault handler since it is 749 * called by uiomove(), which may be in the path of servicing a non-fatal 750 * page fault. 751 */ 752 int 753 kcopy(const void *src, void *dst, size_t len) 754 { 755 struct thread *td; 756 faultbuf env, *oldfault; 757 int rv; 758 759 td = PCPU_GET(curthread); 760 oldfault = td->td_pcb->pcb_onfault; 761 if ((rv = setfault(env)) != 0) { 762 td->td_pcb->pcb_onfault = oldfault; 763 return rv; 764 } 765 766 memcpy(dst, src, len); 767 768 td->td_pcb->pcb_onfault = oldfault; 769 return (0); 770 } 771 772 773 intptr_t 774 casuptr(intptr_t *p, intptr_t old, intptr_t new) 775 { 776 return (-1); 777 } 778 779