[BACK]Return to process_machdep.c CVS log [TXT][DIR] Up to [local] / sys / arch / powerpc / powerpc

Annotation of sys/arch/powerpc/powerpc/process_machdep.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: process_machdep.c,v 1.12 2007/03/20 20:59:53 kettenis Exp $   */
        !             2: /*     $NetBSD: process_machdep.c,v 1.1 1996/09/30 16:34:53 ws Exp $   */
        !             3:
        !             4: /*
        !             5:  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
        !             6:  * Copyright (C) 1995, 1996 TooLs GmbH.
        !             7:  * All rights reserved.
        !             8:  *
        !             9:  * Redistribution and use in source and binary forms, with or without
        !            10:  * modification, are permitted provided that the following conditions
        !            11:  * are met:
        !            12:  * 1. Redistributions of source code must retain the above copyright
        !            13:  *    notice, this list of conditions and the following disclaimer.
        !            14:  * 2. Redistributions in binary form must reproduce the above copyright
        !            15:  *    notice, this list of conditions and the following disclaimer in the
        !            16:  *    documentation and/or other materials provided with the distribution.
        !            17:  * 3. All advertising materials mentioning features or use of this software
        !            18:  *    must display the following acknowledgement:
        !            19:  *     This product includes software developed by TooLs GmbH.
        !            20:  * 4. The name of TooLs GmbH may not be used to endorse or promote products
        !            21:  *    derived from this software without specific prior written permission.
        !            22:  *
        !            23:  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
        !            24:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            25:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            26:  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
        !            27:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
        !            28:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
        !            29:  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
        !            30:  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
        !            31:  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
        !            32:  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            33:  */
        !            34: #include <sys/param.h>
        !            35: #include <sys/systm.h>
        !            36: #include <sys/proc.h>
        !            37: #include <sys/ptrace.h>
        !            38: #include <sys/user.h>
        !            39:
        !            40: #include <machine/fpu.h>
        !            41: #include <machine/pcb.h>
        !            42: #include <machine/psl.h>
        !            43: #include <machine/reg.h>
        !            44:
        !            45: int
        !            46: process_read_regs(struct proc *p, struct reg *regs)
        !            47: {
        !            48:        struct cpu_info *ci = curcpu();
        !            49:        struct trapframe *tf = trapframe(p);
        !            50:        struct pcb *pcb = &p->p_addr->u_pcb;
        !            51:
        !            52:        bcopy(tf->fixreg, regs->gpr, sizeof(regs->gpr));
        !            53:
        !            54:        if (!(pcb->pcb_flags & PCB_FPU)) {
        !            55:                bzero(regs->fpr, sizeof(regs->fpr));
        !            56:        } else {
        !            57:                /* XXX What if the state is on the other cpu? */
        !            58:                if (p == ci->ci_fpuproc)
        !            59:                        save_fpu();
        !            60:                bcopy(pcb->pcb_fpu.fpr, regs->fpr, sizeof(regs->fpr));
        !            61:        }
        !            62:
        !            63:        regs->pc  = tf->srr0;
        !            64:        regs->ps  = tf->srr1; /* is this the correct value for this ? */
        !            65:        regs->cnd = tf->cr;
        !            66:        regs->lr  = tf->lr;
        !            67:        regs->cnt = tf->ctr;
        !            68:        regs->xer = tf->xer;
        !            69:        regs->mq  = 0; /*  what should this really be? */
        !            70:
        !            71:        return (0);
        !            72: }
        !            73:
        !            74: int
        !            75: process_read_fpregs(struct proc *p, struct fpreg *regs)
        !            76: {
        !            77:        struct cpu_info *ci = curcpu();
        !            78:        struct pcb *pcb = &p->p_addr->u_pcb;
        !            79:
        !            80:        if (!(pcb->pcb_flags & PCB_FPU)) {
        !            81:                bzero(regs->fpr, sizeof(regs->fpr));
        !            82:                regs->fpscr = 0;
        !            83:        } else {
        !            84:                /* XXX What if the state is on the other cpu? */
        !            85:                if (p == ci->ci_fpuproc)
        !            86:                        save_fpu();
        !            87:                bcopy(pcb->pcb_fpu.fpr, regs->fpr, sizeof(regs->fpr));
        !            88:                regs->fpscr = *(u_int64_t *)&pcb->pcb_fpu.fpcsr;
        !            89:        }
        !            90:
        !            91:        return (0);
        !            92: }
        !            93:
        !            94: #ifdef PTRACE
        !            95:
        !            96: /*
        !            97:  * Set the process's program counter.
        !            98:  */
        !            99: int
        !           100: process_set_pc(struct proc *p, caddr_t addr)
        !           101: {
        !           102:        struct trapframe *tf = trapframe(p);
        !           103:
        !           104:        tf->srr0 = (u_int32_t)addr;
        !           105:        return 0;
        !           106: }
        !           107:
        !           108: int
        !           109: process_sstep(struct proc *p, int sstep)
        !           110: {
        !           111:        struct trapframe *tf = trapframe(p);
        !           112:
        !           113:        if (sstep)
        !           114:                tf->srr1 |= PSL_SE;
        !           115:        else
        !           116:                tf->srr1 &= ~PSL_SE;
        !           117:        return 0;
        !           118: }
        !           119:
        !           120: int
        !           121: process_write_regs(struct proc *p, struct reg *regs)
        !           122: {
        !           123:        struct cpu_info *ci = curcpu();
        !           124:        struct trapframe *tf = trapframe(p);
        !           125:        struct pcb *pcb = &p->p_addr->u_pcb;
        !           126:
        !           127:        bcopy(regs->gpr, tf->fixreg, sizeof(regs->gpr));
        !           128:
        !           129:        /* XXX What if the state is on the other cpu? */
        !           130:        if (p == ci->ci_fpuproc) {      /* release the fpu */
        !           131:                save_fpu();
        !           132:                ci->ci_fpuproc = NULL;
        !           133:        }
        !           134:
        !           135:        bcopy(regs->fpr, pcb->pcb_fpu.fpr, sizeof(regs->fpr));
        !           136:        if (!(pcb->pcb_flags & PCB_FPU)) {
        !           137:                pcb->pcb_fpu.fpcsr = 0;
        !           138:                pcb->pcb_flags |= PCB_FPU;
        !           139:        }
        !           140:
        !           141:        tf->srr0 = regs->pc;
        !           142:        tf->srr1 = regs->ps;  /* is this the correct value for this ? */
        !           143:        tf->cr   = regs->cnd;
        !           144:        tf->lr   = regs->lr;
        !           145:        tf->ctr  = regs->cnt;
        !           146:        tf->xer  = regs->xer;
        !           147:        /*  regs->mq = 0; what should this really be? */
        !           148:
        !           149:        return (0);
        !           150: }
        !           151:
        !           152: int
        !           153: process_write_fpregs(struct proc *p, struct fpreg *regs)
        !           154: {
        !           155:        struct cpu_info *ci = curcpu();
        !           156:        struct pcb *pcb = &p->p_addr->u_pcb;
        !           157:        u_int64_t fpscr = regs->fpscr;
        !           158:
        !           159:        /* XXX What if the state is on the other cpu? */
        !           160:        if (p == ci->ci_fpuproc) {      /* release the fpu */
        !           161:                save_fpu();
        !           162:                ci->ci_fpuproc = NULL;
        !           163:        }
        !           164:
        !           165:        bcopy(regs->fpr, pcb->pcb_fpu.fpr, sizeof(regs->fpr));
        !           166:        pcb->pcb_fpu.fpcsr = *(double *)&fpscr;
        !           167:        pcb->pcb_flags |= PCB_FPU;
        !           168:
        !           169:        return (0);
        !           170: }
        !           171:
        !           172: #endif /* PTRACE */

CVSweb