machdep.c (105569) | machdep.c (105733) |
---|---|
1/*- 2 * Copyright (c) 2001 Jake Burkholder. 3 * Copyright (c) 1992 Terrence R. Lambert. 4 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * William Jolitz. --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 39 * from: FreeBSD: src/sys/i386/i386/machdep.c,v 1.477 2001/08/27 | 1/*- 2 * Copyright (c) 2001 Jake Burkholder. 3 * Copyright (c) 1992 Terrence R. Lambert. 4 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * William Jolitz. --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 39 * from: FreeBSD: src/sys/i386/i386/machdep.c,v 1.477 2001/08/27 |
40 * $FreeBSD: head/sys/sparc64/sparc64/machdep.c 105569 2002-10-20 21:55:35Z mux $ | 40 * $FreeBSD: head/sys/sparc64/sparc64/machdep.c 105733 2002-10-22 18:03:15Z jake $ |
41 */ 42 43#include "opt_ddb.h" 44#include "opt_msgbuf.h" 45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/cons.h> --- 86 unchanged lines hidden (view full) --- 135void sparc64_shutdown_final(void *dummy, int howto); 136 137static void cpu_startup(void *); 138SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); 139 140CTASSERT((1 << INT_SHIFT) == sizeof(int)); 141CTASSERT((1 << PTR_SHIFT) == sizeof(char *)); 142 | 41 */ 42 43#include "opt_ddb.h" 44#include "opt_msgbuf.h" 45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/cons.h> --- 86 unchanged lines hidden (view full) --- 135void sparc64_shutdown_final(void *dummy, int howto); 136 137static void cpu_startup(void *); 138SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); 139 140CTASSERT((1 << INT_SHIFT) == sizeof(int)); 141CTASSERT((1 << PTR_SHIFT) == sizeof(char *)); 142 |
143CTASSERT(sizeof(struct reg) == 256); 144CTASSERT(sizeof(struct fpreg) == 272); 145CTASSERT(sizeof(struct __mcontext) == 512); 146 |
|
143CTASSERT(sizeof(struct pcpu) <= ((PCPU_PAGES * PAGE_SIZE) / 2)); 144 145static void 146cpu_startup(void *arg) 147{ 148 u_int clock; 149 150 OF_getprop(PCPU_GET(node), "clock-frequency", &clock, sizeof(clock)); --- 7 unchanged lines hidden (view full) --- 158 159 cpu_identify(rdpr(ver), clock, PCPU_GET(cpuid)); 160 161 vm_ksubmap_init(&kmi); 162 163 bufinit(); 164 vm_pager_bufferinit(); 165 | 147CTASSERT(sizeof(struct pcpu) <= ((PCPU_PAGES * PAGE_SIZE) / 2)); 148 149static void 150cpu_startup(void *arg) 151{ 152 u_int clock; 153 154 OF_getprop(PCPU_GET(node), "clock-frequency", &clock, sizeof(clock)); --- 7 unchanged lines hidden (view full) --- 162 163 cpu_identify(rdpr(ver), clock, PCPU_GET(cpuid)); 164 165 vm_ksubmap_init(&kmi); 166 167 bufinit(); 168 vm_pager_bufferinit(); 169 |
166 tick_start(clock, tick_hardclock); 167 | |
168 EVENTHANDLER_REGISTER(shutdown_final, sparc64_shutdown_final, NULL, 169 SHUTDOWN_PRI_LAST); 170} 171 172void 173cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) 174{ 175 struct intr_request *ir; --- 213 unchanged lines hidden (view full) --- 389 } 390 391 /* Save user context. */ 392 bzero(&sf, sizeof(sf)); 393 sf.sf_uc.uc_sigmask = *mask; 394 sf.sf_uc.uc_stack = p->p_sigstk; 395 sf.sf_uc.uc_stack.ss_flags = (p->p_flag & P_ALTSTACK) 396 ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE; | 170 EVENTHANDLER_REGISTER(shutdown_final, sparc64_shutdown_final, NULL, 171 SHUTDOWN_PRI_LAST); 172} 173 174void 175cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) 176{ 177 struct intr_request *ir; --- 213 unchanged lines hidden (view full) --- 391 } 392 393 /* Save user context. */ 394 bzero(&sf, sizeof(sf)); 395 sf.sf_uc.uc_sigmask = *mask; 396 sf.sf_uc.uc_stack = p->p_sigstk; 397 sf.sf_uc.uc_stack.ss_flags = (p->p_flag & P_ALTSTACK) 398 ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE; |
397 sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0; 398 bcopy(tf->tf_global, sf.sf_uc.uc_mcontext.mc_global, 399 sizeof (tf->tf_global)); 400 bcopy(tf->tf_out, sf.sf_uc.uc_mcontext.mc_out, sizeof (tf->tf_out)); 401 sf.sf_uc.uc_mcontext.mc_tpc = tf->tf_tpc; 402 sf.sf_uc.uc_mcontext.mc_tnpc = tf->tf_tnpc; 403 sf.sf_uc.uc_mcontext.mc_tstate = tf->tf_tstate; | 399 bcopy(tf, &sf.sf_uc.uc_mcontext, sizeof(*tf)); |
404 405 /* Allocate and validate space for the signal handler context. */ 406 if ((p->p_flag & P_ALTSTACK) != 0 && !oonstack && 407 SIGISMEMBER(psp->ps_sigonstack, sig)) { 408 sfp = (struct sigframe *)(p->p_sigstk.ss_sp + 409 p->p_sigstk.ss_size - sizeof(struct sigframe)); | 400 401 /* Allocate and validate space for the signal handler context. */ 402 if ((p->p_flag & P_ALTSTACK) != 0 && !oonstack && 403 SIGISMEMBER(psp->ps_sigonstack, sig)) { 404 sfp = (struct sigframe *)(p->p_sigstk.ss_sp + 405 p->p_sigstk.ss_size - sizeof(struct sigframe)); |
410#if defined(COMPAT_43) || defined(COMPAT_SUNOS) 411 p->p_sigstk.ss_flags |= SS_ONSTACK; 412#endif | |
413 } else 414 sfp = (struct sigframe *)sp - 1; 415 PROC_UNLOCK(p); 416 417 fp = (struct frame *)sfp - 1; 418 419 /* Translate the signal if appropriate. */ 420 if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) 421 sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; 422 423 /* Build the argument list for the signal handler. */ 424 tf->tf_out[0] = sig; | 406 } else 407 sfp = (struct sigframe *)sp - 1; 408 PROC_UNLOCK(p); 409 410 fp = (struct frame *)sfp - 1; 411 412 /* Translate the signal if appropriate. */ 413 if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) 414 sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; 415 416 /* Build the argument list for the signal handler. */ 417 tf->tf_out[0] = sig; |
418 tf->tf_out[1] = (register_t)&sfp->sf_si; |
|
425 tf->tf_out[2] = (register_t)&sfp->sf_uc; | 419 tf->tf_out[2] = (register_t)&sfp->sf_uc; |
426 tf->tf_out[3] = tf->tf_type; | |
427 tf->tf_out[4] = (register_t)catcher; | 420 tf->tf_out[4] = (register_t)catcher; |
428 PROC_LOCK(p); 429 if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) { 430 /* Signal handler installed with SA_SIGINFO. */ 431 tf->tf_out[1] = (register_t)&sfp->sf_si; 432 433 /* Fill siginfo structure. */ 434 sf.sf_si.si_signo = sig; 435 sf.sf_si.si_code = code; 436 sf.sf_si.si_addr = (void *)tf->tf_sfar; 437 sf.sf_si.si_pid = p->p_pid; 438 sf.sf_si.si_uid = p->p_ucred->cr_uid; 439 } else { 440 /* Old FreeBSD-style arguments. */ 441 tf->tf_out[1] = code; 442 } 443 PROC_UNLOCK(p); | 421 /* Fill siginfo structure. */ 422 sf.sf_si.si_signo = sig; 423 sf.sf_si.si_code = code; 424 sf.sf_si.si_addr = (void *)tf->tf_sfar; 425 sf.sf_si.si_pid = p->p_pid; 426 sf.sf_si.si_uid = td->td_ucred->cr_uid; |
444 445 /* Copy the sigframe out to the user's stack. */ 446 if (rwindow_save(td) != 0 || copyout(&sf, sfp, sizeof(*sfp)) != 0 || 447 suword(&fp->fr_in[6], tf->tf_out[6]) != 0) { 448 /* 449 * Something is wrong with the stack pointer. 450 * ...Kill the process. 451 */ --- 34 unchanged lines hidden (view full) --- 486#endif 487 488/* 489 * MPSAFE 490 */ 491int 492sigreturn(struct thread *td, struct sigreturn_args *uap) 493{ | 427 428 /* Copy the sigframe out to the user's stack. */ 429 if (rwindow_save(td) != 0 || copyout(&sf, sfp, sizeof(*sfp)) != 0 || 430 suword(&fp->fr_in[6], tf->tf_out[6]) != 0) { 431 /* 432 * Something is wrong with the stack pointer. 433 * ...Kill the process. 434 */ --- 34 unchanged lines hidden (view full) --- 469#endif 470 471/* 472 * MPSAFE 473 */ 474int 475sigreturn(struct thread *td, struct sigreturn_args *uap) 476{ |
494 struct trapframe *tf; | |
495 struct proc *p; 496 ucontext_t uc; 497 498 p = td->td_proc; 499 if (rwindow_save(td)) { 500 PROC_LOCK(p); 501 sigexit(td, SIGILL); 502 } 503 504 CTR2(KTR_SIG, "sigreturn: td=%p ucp=%p", td, uap->sigcntxp); 505 if (copyin(uap->sigcntxp, &uc, sizeof(uc)) != 0) { 506 CTR1(KTR_SIG, "sigreturn: efault td=%p", td); 507 return (EFAULT); 508 } 509 | 477 struct proc *p; 478 ucontext_t uc; 479 480 p = td->td_proc; 481 if (rwindow_save(td)) { 482 PROC_LOCK(p); 483 sigexit(td, SIGILL); 484 } 485 486 CTR2(KTR_SIG, "sigreturn: td=%p ucp=%p", td, uap->sigcntxp); 487 if (copyin(uap->sigcntxp, &uc, sizeof(uc)) != 0) { 488 CTR1(KTR_SIG, "sigreturn: efault td=%p", td); 489 return (EFAULT); 490 } 491 |
510 if (((uc.uc_mcontext.mc_tpc | uc.uc_mcontext.mc_tnpc) & 3) != 0) 511 return (EINVAL); | |
512 if (!TSTATE_SECURE(uc.uc_mcontext.mc_tstate)) 513 return (EINVAL); | 492 if (!TSTATE_SECURE(uc.uc_mcontext.mc_tstate)) 493 return (EINVAL); |
494 bcopy(&uc.uc_mcontext, td->td_frame, sizeof(*td->td_frame)); |
|
514 | 495 |
515 tf = td->td_frame; 516 bcopy(uc.uc_mcontext.mc_global, tf->tf_global, 517 sizeof(tf->tf_global)); 518 bcopy(uc.uc_mcontext.mc_out, tf->tf_out, sizeof(tf->tf_out)); 519 tf->tf_tpc = uc.uc_mcontext.mc_tpc; 520 tf->tf_tnpc = uc.uc_mcontext.mc_tnpc; 521 tf->tf_tstate = uc.uc_mcontext.mc_tstate; | |
522 PROC_LOCK(p); | 496 PROC_LOCK(p); |
523#if defined(COMPAT_43) || defined(COMPAT_SUNOS) 524 if (uc.uc_mcontext.mc_onstack & 1) 525 p->p_sigstk.ss_flags |= SS_ONSTACK; 526 else 527 p->p_sigstk.ss_flags &= ~SS_ONSTACK; 528#endif 529 | |
530 p->p_sigmask = uc.uc_sigmask; 531 SIG_CANTMASK(p->p_sigmask); 532 signotify(p); 533 PROC_UNLOCK(p); | 497 p->p_sigmask = uc.uc_sigmask; 498 SIG_CANTMASK(p->p_sigmask); 499 signotify(p); 500 PROC_UNLOCK(p); |
501 |
|
534 CTR4(KTR_SIG, "sigreturn: return td=%p pc=%#lx sp=%#lx tstate=%#lx", | 502 CTR4(KTR_SIG, "sigreturn: return td=%p pc=%#lx sp=%#lx tstate=%#lx", |
535 td, tf->tf_tpc, tf->tf_sp, tf->tf_tstate); | 503 td, td->td_frame->tf_tpc, td->td_frame->tf_sp, 504 td->td_frame->tf_tstate); |
536 return (EJUSTRETURN); 537} 538 539/* 540 * Exit the kernel and execute a firmware call that will not return, as 541 * specified by the arguments. 542 */ 543void --- 107 unchanged lines hidden (view full) --- 651 critical_enter(); 652 breakpoint(); 653 critical_exit(); 654} 655 656int 657fill_regs(struct thread *td, struct reg *regs) 658{ | 505 return (EJUSTRETURN); 506} 507 508/* 509 * Exit the kernel and execute a firmware call that will not return, as 510 * specified by the arguments. 511 */ 512void --- 107 unchanged lines hidden (view full) --- 620 critical_enter(); 621 breakpoint(); 622 critical_exit(); 623} 624 625int 626fill_regs(struct thread *td, struct reg *regs) 627{ |
659 struct trapframe *tf; | |
660 | 628 |
661 tf = td->td_frame; 662 regs->r_tstate = tf->tf_tstate; 663 regs->r_pc = tf->tf_tpc; 664 regs->r_npc = tf->tf_tnpc; 665 regs->r_y = tf->tf_y; 666 bcopy(tf->tf_global, regs->r_global, sizeof(tf->tf_global)); 667 bcopy(tf->tf_out, regs->r_out, sizeof(tf->tf_out)); 668 /* XXX - these are a pain to get at */ 669 bzero(regs->r_in, sizeof(regs->r_in)); 670 bzero(regs->r_local, sizeof(regs->r_local)); | 629 bcopy(td->td_frame, regs, sizeof(*regs)); |
671 return (0); 672} 673 674int 675set_regs(struct thread *td, struct reg *regs) 676{ | 630 return (0); 631} 632 633int 634set_regs(struct thread *td, struct reg *regs) 635{ |
677 struct trapframe *tf; | |
678 | 636 |
679 tf = td->td_frame; 680 if (((regs->r_pc | regs->r_npc) & 3) != 0) 681 return (EINVAL); | |
682 if (!TSTATE_SECURE(regs->r_tstate)) 683 return (EINVAL); | 637 if (!TSTATE_SECURE(regs->r_tstate)) 638 return (EINVAL); |
684 tf->tf_tstate = regs->r_tstate; 685 tf->tf_tpc = regs->r_pc; 686 tf->tf_tnpc = regs->r_npc; 687 tf->tf_y = regs->r_y; 688 bcopy(regs->r_global, tf->tf_global, sizeof(regs->r_global)); 689 bcopy(regs->r_out, tf->tf_out, sizeof(regs->r_out)); | 639 bcopy(regs, td->td_frame, sizeof(*regs)); |
690 return (0); 691} 692 693int 694fill_dbregs(struct thread *td, struct dbreg *dbregs) 695{ 696 697 return (ENOSYS); --- 11 unchanged lines hidden (view full) --- 709{ 710 struct trapframe *tf; 711 struct pcb *pcb; 712 713 pcb = td->td_pcb; 714 tf = td->td_frame; 715 bcopy(pcb->pcb_fpstate.fp_fb, fpregs->fr_regs, 716 sizeof(pcb->pcb_fpstate.fp_fb)); | 640 return (0); 641} 642 643int 644fill_dbregs(struct thread *td, struct dbreg *dbregs) 645{ 646 647 return (ENOSYS); --- 11 unchanged lines hidden (view full) --- 659{ 660 struct trapframe *tf; 661 struct pcb *pcb; 662 663 pcb = td->td_pcb; 664 tf = td->td_frame; 665 bcopy(pcb->pcb_fpstate.fp_fb, fpregs->fr_regs, 666 sizeof(pcb->pcb_fpstate.fp_fb)); |
717 fpregs->fr_fprs = tf->tf_fprs; | |
718 fpregs->fr_fsr = tf->tf_fsr; | 667 fpregs->fr_fsr = tf->tf_fsr; |
668 fpregs->fr_gsr = tf->tf_gsr; |
|
719 return (0); 720} 721 722int 723set_fpregs(struct thread *td, struct fpreg *fpregs) 724{ 725 struct trapframe *tf; 726 struct pcb *pcb; 727 728 pcb = td->td_pcb; 729 tf = td->td_frame; 730 bcopy(fpregs->fr_regs, pcb->pcb_fpstate.fp_fb, 731 sizeof(fpregs->fr_regs)); | 669 return (0); 670} 671 672int 673set_fpregs(struct thread *td, struct fpreg *fpregs) 674{ 675 struct trapframe *tf; 676 struct pcb *pcb; 677 678 pcb = td->td_pcb; 679 tf = td->td_frame; 680 bcopy(fpregs->fr_regs, pcb->pcb_fpstate.fp_fb, 681 sizeof(fpregs->fr_regs)); |
732 tf->tf_fprs = fpregs->fr_fprs; | |
733 tf->tf_fsr = fpregs->fr_fsr; | 682 tf->tf_fsr = fpregs->fr_fsr; |
683 tf->tf_gsr = fpregs->fr_gsr; |
|
734 return (0); 735} | 684 return (0); 685} |