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

Annotation of sys/arch/hppa/hppa/hpux_machdep.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: hpux_machdep.c,v 1.2 2005/03/26 20:37:24 mickey Exp $ */
                      2:
                      3: /*
                      4:  * Copyright (c) 2005 Michael Shalayeff
                      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 AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     17:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     18:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     19:  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
                     20:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     21:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     22:  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     23:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
                     24:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
                     25:  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
                     26:  * THE POSSIBILITY OF SUCH DAMAGE.
                     27:  */
                     28:
                     29: #include <sys/param.h>
                     30: #include <sys/proc.h>
                     31: #include <sys/user.h>
                     32: #include <sys/exec.h>
                     33: #include <sys/signalvar.h>
                     34:
                     35: #include <compat/hpux/hpux.h>
                     36: #include <compat/hpux/hpux_sig.h>
                     37: #include <compat/hpux/hpux_util.h>
                     38: #include <compat/hpux/hpux_syscallargs.h>
                     39:
                     40: #include <machine/cpufunc.h>
                     41: #include <machine/frame.h>
                     42:
                     43: int
                     44: hpux_cpu_sysconf_arch(void)
                     45: {
                     46:        extern int cpu_model_hpux;      /* machdep.c */
                     47:
                     48:        return cpu_model_hpux;
                     49: }
                     50:
                     51: int
                     52: hpux_sys_getcontext(struct proc *p, void *v, register_t *retval)
                     53: {
                     54:        struct hpux_sys_getcontext_args *uap = v;
                     55:        int len = SCARG(uap, len);
                     56:
                     57:        if (len <= 0)
                     58:                return (EINVAL);
                     59:
                     60:        if (len > 4)
                     61:                len = 4;
                     62:
                     63:        if (!copyout("FPU", SCARG(uap, buf), len))
                     64:                *retval = len;
                     65:
                     66:        return (0);
                     67: }
                     68:
                     69: void
                     70: hpux_setregs(struct proc *p, struct exec_package *pack, u_long stack,
                     71:     register_t *retval)
                     72: {
                     73:        extern int cpu_model_hpux;      /* machdep.c */
                     74:        extern paddr_t fpu_curpcb;      /* from locore.S */
                     75:        extern u_int fpu_version;       /* from machdep.c */
                     76:        struct ps_strings arginfo;      /* XXX copy back in from the stack */
                     77:        struct hpux_keybits {
                     78:                int     kb_cpuver;
                     79:                int     kb_fpustat;
                     80:                int     kb_nbits;
                     81:                int     kb_bits[2];
                     82:        } hpux_keybits;
                     83:        struct trapframe *tf = p->p_md.md_regs;
                     84:        struct pcb *pcb = &p->p_addr->u_pcb;
                     85:        register_t zero;
                     86:
                     87:        if (copyin((char *)PS_STRINGS, &arginfo, sizeof(arginfo)))
                     88:                sigexit(p, SIGILL);
                     89:
                     90:        stack = (stack + 0x1f) & ~0x1f;
                     91:        hpux_keybits.kb_cpuver = cpu_model_hpux;
                     92:        hpux_keybits.kb_fpustat = fpu_version;
                     93:        hpux_keybits.kb_nbits = 1;
                     94:        hpux_keybits.kb_bits[0] = 0;    /* TODO report half-word insns */
                     95:        hpux_keybits.kb_bits[1] = -1;
                     96:        if (copyout(&hpux_keybits, (void *)stack, sizeof(hpux_keybits)))
                     97:                sigexit(p, SIGILL);
                     98:
                     99:        tf->tf_flags = TFF_SYS|TFF_LAST;
                    100:        tf->tf_iioq_tail = 4 +
                    101:            (tf->tf_iioq_head = pack->ep_entry | HPPA_PC_PRIV_USER);
                    102:        tf->tf_rp = 0;
                    103:        tf->tf_arg0 = (register_t)arginfo.ps_nargvstr;
                    104:        tf->tf_arg1 = (register_t)arginfo.ps_argvstr;
                    105:        tf->tf_arg2 = (register_t)arginfo.ps_envstr;
                    106:        tf->tf_arg3 = stack;    /* keybits */
                    107:        stack += sizeof(hpux_keybits);
                    108:
                    109:        /* setup terminal stack frame */
                    110:        stack = (stack + 0x1f) & ~0x1f;
                    111:        tf->tf_r3 = stack;
                    112:        tf->tf_sp = stack += HPPA_FRAME_SIZE;
                    113:        zero = 0;
                    114:        copyout(&zero, (caddr_t)(stack - HPPA_FRAME_SIZE), sizeof(register_t));
                    115:        copyout(&zero, (caddr_t)(stack + HPPA_FRAME_CRP), sizeof(register_t));
                    116:
                    117:        /* reset any of the pending FPU exceptions */
                    118:        pcb->pcb_fpregs[0] = ((u_int64_t)HPPA_FPU_INIT) << 32;
                    119:        pcb->pcb_fpregs[1] = 0;
                    120:        pcb->pcb_fpregs[2] = 0;
                    121:        pcb->pcb_fpregs[3] = 0;
                    122:        fdcache(HPPA_SID_KERNEL, (vaddr_t)pcb->pcb_fpregs, 8 * 4);
                    123:        if (tf->tf_cr30 == fpu_curpcb) {
                    124:                fpu_curpcb = 0;
                    125:                /* force an fpu ctxsw, we won't be hugged by the cpu_switch */
                    126:                mtctl(0, CR_CCR);
                    127:        }
                    128:        retval[1] = 0;
                    129: }
                    130:
                    131: int
                    132: hpux_sigsetreturn(struct proc *p, void *v, register_t *retval)
                    133: {
                    134:        struct hpux_sigsetreturn_args /* {
                    135:                syscallarg(caddr_t) addr;
                    136:                syscallarg(int) cookie;
                    137:                syscallarg(int) len;
                    138:        } */ *uap = v;
                    139:        struct pcb *pcb = &p->p_addr->u_pcb;
                    140:
                    141:        /* XXX should fail on second call? */
                    142:
                    143:        pcb->pcb_sigreturn = SCARG(uap, addr);
                    144:        pcb->pcb_srcookie = SCARG(uap, cookie);
                    145:        pcb->pcb_sclen = SCARG(uap, len);
                    146:
                    147: printf("hpux_sigsetreturn(%p, %x, %d)\n", SCARG(uap, addr), SCARG(uap, cookie), SCARG(uap, len));
                    148:
                    149:        retval[0] = 0;
                    150:        return (0);
                    151: }

CVSweb