Home | History | Annotate | Line # | Download | only in include
frame.h revision 1.25
      1  1.25  matt /*	$NetBSD: frame.h,v 1.25 2012/08/01 16:19:42 matt Exp $	*/
      2   1.1    ws 
      3   1.1    ws /*
      4   1.1    ws  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
      5   1.1    ws  * Copyright (C) 1995, 1996 TooLs GmbH.
      6   1.1    ws  * All rights reserved.
      7   1.1    ws  *
      8   1.1    ws  * Redistribution and use in source and binary forms, with or without
      9   1.1    ws  * modification, are permitted provided that the following conditions
     10   1.1    ws  * are met:
     11   1.1    ws  * 1. Redistributions of source code must retain the above copyright
     12   1.1    ws  *    notice, this list of conditions and the following disclaimer.
     13   1.1    ws  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1    ws  *    notice, this list of conditions and the following disclaimer in the
     15   1.1    ws  *    documentation and/or other materials provided with the distribution.
     16   1.1    ws  * 3. All advertising materials mentioning features or use of this software
     17   1.1    ws  *    must display the following acknowledgement:
     18   1.1    ws  *	This product includes software developed by TooLs GmbH.
     19   1.1    ws  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     20   1.1    ws  *    derived from this software without specific prior written permission.
     21   1.1    ws  *
     22   1.1    ws  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     23   1.1    ws  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24   1.1    ws  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25   1.1    ws  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26   1.1    ws  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     27   1.1    ws  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     28   1.1    ws  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     29   1.1    ws  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     30   1.1    ws  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     31   1.1    ws  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32   1.1    ws  */
     33   1.8  matt #ifndef	_POWERPC_FRAME_H_
     34   1.8  matt #define	_POWERPC_FRAME_H_
     35   1.1    ws 
     36   1.1    ws #include <machine/types.h>
     37   1.1    ws 
     38  1.22  matt #ifdef _KERNEL
     39  1.22  matt #ifdef _KERNEL_OPT
     40  1.22  matt #include "opt_ppcarch.h"
     41  1.22  matt #endif
     42  1.22  matt #endif
     43  1.22  matt 
     44   1.1    ws /*
     45   1.1    ws  * We have to save all registers on every trap, because
     46   1.1    ws  *	1. user could attach this process every time
     47   1.1    ws  *	2. we must be able to restore all user registers in case of fork
     48   1.1    ws  * Actually, we do not save the fp registers on trap, since
     49   1.1    ws  * these are not used by the kernel. They are saved only when switching
     50   1.1    ws  * between processes using the FPU.
     51   1.1    ws  *
     52   1.1    ws  * Change ordering to cluster together these register_t's.		XXX
     53   1.1    ws  */
     54  1.22  matt struct reg_sans_pc {
     55  1.22  matt 	register_t r_fixreg[32];
     56  1.22  matt 	register_t r_lr;
     57  1.22  matt 	uint32_t r_cr;
     58  1.22  matt 	uint32_t r_xer;
     59  1.22  matt 	register_t r_ctr;
     60  1.22  matt };
     61  1.22  matt 
     62  1.14  matt struct utrapframe {
     63  1.14  matt 	register_t fixreg[32];
     64  1.14  matt 	register_t lr;
     65  1.14  matt 	int cr;
     66  1.14  matt 	int xer;
     67  1.14  matt 	register_t ctr;
     68  1.14  matt 	register_t srr0;
     69  1.14  matt 	register_t srr1;
     70  1.14  matt 	int vrsave;
     71  1.14  matt 	int mq;
     72  1.14  matt 	int spare;
     73  1.14  matt };
     74  1.14  matt 
     75  1.22  matt struct clockframe {
     76  1.22  matt 	register_t cf_srr0;
     77  1.22  matt 	register_t cf_srr1;
     78  1.22  matt 	int cf_idepth;
     79  1.22  matt };
     80  1.22  matt 
     81   1.1    ws struct trapframe {
     82  1.22  matt 	struct reg_sans_pc tf_ureg;
     83  1.22  matt 	struct clockframe tf_cf;
     84  1.22  matt 	uint32_t tf_exc;
     85  1.22  matt #if defined(PPC_OEA) || defined(PPC_OEA64) || defined(PPC_OEA64_BRIDGE)
     86  1.22  matt 	register_t tf_dar;
     87  1.23  matt 	register_t tf_pad0[2];
     88  1.22  matt 	uint32_t tf_dsisr;
     89  1.22  matt 	uint32_t tf_vrsave;
     90  1.22  matt 	uint32_t tf_mq;
     91  1.23  matt 	uint32_t tf_pad1[1];
     92  1.22  matt #endif
     93  1.22  matt #if defined(PPC_BOOKE) || defined(PPC_IBM4XX)
     94  1.22  matt 	register_t tf_dear;
     95  1.22  matt 	register_t tf_mcar;
     96  1.22  matt 	register_t tf_sprg1;
     97  1.22  matt 	uint32_t tf_esr;
     98  1.22  matt 	uint32_t tf_mcsr;
     99  1.22  matt 	uint32_t tf_pid;
    100  1.22  matt 	uint32_t tf_spefscr;
    101  1.22  matt #endif
    102  1.22  matt };
    103  1.22  matt #define tf_fixreg	tf_ureg.r_fixreg
    104  1.22  matt #define tf_lr		tf_ureg.r_lr
    105  1.22  matt #define tf_cr		tf_ureg.r_cr
    106  1.22  matt #define tf_xer		tf_ureg.r_xer
    107  1.22  matt #define tf_ctr		tf_ureg.r_ctr
    108  1.22  matt #define tf_srr0		tf_cf.cf_srr0
    109  1.22  matt #define tf_srr1		tf_cf.cf_srr1
    110  1.22  matt #define tf_idepth	tf_cf.cf_idepth
    111  1.22  matt 
    112  1.22  matt struct ktrapframe {
    113  1.22  matt 	register_t ktf_sp;
    114  1.22  matt 	register_t ktf_lr;
    115  1.22  matt 	struct trapframe ktf_tf;
    116  1.25  matt 	register_t ktf_cframe_lr;	/* for DDB */
    117  1.22  matt };
    118  1.10  matt 
    119  1.10  matt #if defined(_KERNEL) || defined(_LKM)
    120  1.10  matt #ifdef _LP64
    121  1.15  matt struct utrapframe32 {
    122  1.10  matt 	register32_t fixreg[32];
    123  1.10  matt 	register32_t lr;
    124  1.10  matt 	int cr;
    125  1.10  matt 	int xer;
    126  1.10  matt 	register32_t ctr;
    127  1.10  matt 	register32_t srr0;
    128  1.10  matt 	register32_t srr1;
    129  1.14  matt 	int vrsave;
    130  1.14  matt 	int mq;
    131  1.14  matt 	int spare;
    132  1.10  matt };
    133  1.10  matt #endif
    134  1.10  matt #endif /* _KERNEL || _LKM */
    135  1.10  matt 
    136   1.1    ws /*
    137   1.1    ws  * This is to ensure alignment of the stackpointer
    138   1.1    ws  */
    139  1.22  matt #define	FRAMELEN	roundup(sizeof(struct ktrapframe), CALLFRAMELEN)
    140  1.22  matt #define	ktrapframe(l)	((struct ktrapframe *)(uvm_lwp_getuarea(l) + USPACE - CALLFRAMELEN - FRAMELEN))
    141  1.22  matt #define	trapframe(l)	(&(ktrapframe(l)->ktf_tf))
    142   1.1    ws 
    143  1.17  matt #define	SFRAMELEN	roundup(sizeof(struct switchframe), CALLFRAMELEN)
    144   1.1    ws struct switchframe {
    145  1.22  matt 	register_t sf_sp;
    146  1.22  matt 	register_t sf_lr;
    147  1.22  matt 	register_t sf_user_sr;		/* VSID on IBM4XX */
    148  1.22  matt 	register_t sf_cr;		/* why?  CR is volatile. */
    149  1.22  matt 	register_t sf_fixreg2;
    150  1.22  matt 	register_t sf_fixreg[19];	/* R13-R31 */
    151   1.1    ws };
    152   1.1    ws 
    153   1.1    ws /*
    154   1.1    ws  * Call frame for PowerPC used during fork.
    155   1.1    ws  */
    156  1.10  matt #define	CALLFRAMELEN	sizeof(struct callframe)
    157   1.1    ws struct callframe {
    158  1.22  matt 	register_t cf_sp;
    159  1.22  matt 	register_t cf_lr;
    160  1.22  matt 	register_t cf_r30;
    161  1.22  matt 	register_t cf_r31;
    162   1.3  matt };
    163   1.3  matt 
    164   1.8  matt #endif	/* _POWERPC_FRAME_H_ */
    165