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