Home | History | Annotate | Line # | Download | only in include
frame.h revision 1.28
      1  1.28       rin /*	$NetBSD: frame.h,v 1.28 2020/07/06 08:18:57 rin 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.27  christos 	__register_t r_fixreg[32];
     56  1.27  christos 	__register_t r_lr;
     57  1.22      matt 	uint32_t r_cr;
     58  1.22      matt 	uint32_t r_xer;
     59  1.27  christos 	__register_t r_ctr;
     60  1.22      matt };
     61  1.22      matt 
     62  1.26      matt #ifdef _LP64
     63  1.26      matt struct reg_sans_pc32 {
     64  1.27  christos 	__register32_t r_fixreg[32];
     65  1.27  christos 	__register32_t r_lr;
     66  1.26      matt 	uint32_t r_cr;
     67  1.26      matt 	uint32_t r_xer;
     68  1.27  christos 	__register32_t r_ctr;
     69  1.26      matt };
     70  1.26      matt #endif
     71  1.26      matt 
     72  1.14      matt struct utrapframe {
     73  1.27  christos 	__register_t fixreg[32];
     74  1.27  christos 	__register_t lr;
     75  1.14      matt 	int cr;
     76  1.14      matt 	int xer;
     77  1.27  christos 	__register_t ctr;
     78  1.27  christos 	__register_t srr0;
     79  1.27  christos 	__register_t srr1;
     80  1.14      matt 	int vrsave;
     81  1.14      matt 	int mq;
     82  1.14      matt 	int spare;
     83  1.14      matt };
     84  1.14      matt 
     85  1.22      matt struct clockframe {
     86  1.27  christos 	__register_t cf_srr0;
     87  1.27  christos 	__register_t cf_srr1;
     88  1.22      matt 	int cf_idepth;
     89  1.22      matt };
     90  1.22      matt 
     91  1.26      matt #ifdef _LP64
     92  1.26      matt struct clockframe32 {
     93  1.27  christos 	__register32_t cf_srr0;
     94  1.27  christos 	__register32_t cf_srr1;
     95  1.26      matt 	int cf_idepth;
     96  1.26      matt };
     97  1.26      matt #endif
     98  1.26      matt 
     99   1.1        ws struct trapframe {
    100  1.22      matt 	struct reg_sans_pc tf_ureg;
    101  1.22      matt 	struct clockframe tf_cf;
    102  1.22      matt 	uint32_t tf_exc;
    103  1.22      matt #if defined(PPC_OEA) || defined(PPC_OEA64) || defined(PPC_OEA64_BRIDGE)
    104  1.27  christos 	__register_t tf_dar;
    105  1.27  christos 	__register_t tf_pad0[2];
    106  1.22      matt 	uint32_t tf_dsisr;
    107  1.22      matt 	uint32_t tf_vrsave;
    108  1.22      matt 	uint32_t tf_mq;
    109  1.23      matt 	uint32_t tf_pad1[1];
    110  1.22      matt #endif
    111  1.22      matt #if defined(PPC_BOOKE) || defined(PPC_IBM4XX)
    112  1.27  christos 	__register_t tf_dear;
    113  1.27  christos 	__register_t tf_mcar;
    114  1.27  christos 	__register_t tf_sprg1;
    115  1.22      matt 	uint32_t tf_esr;
    116  1.22      matt 	uint32_t tf_mcsr;
    117  1.22      matt 	uint32_t tf_pid;
    118  1.22      matt 	uint32_t tf_spefscr;
    119  1.22      matt #endif
    120  1.22      matt };
    121  1.26      matt 
    122  1.26      matt #ifdef _LP64
    123  1.26      matt struct trapframe32 {
    124  1.26      matt 	struct reg_sans_pc32 tf_ureg;
    125  1.26      matt 	struct clockframe32 tf_cf;
    126  1.26      matt 	uint32_t tf_exc;
    127  1.26      matt #if defined(PPC_OEA) || defined(PPC_OEA64) || defined(PPC_OEA64_BRIDGE)
    128  1.27  christos 	__register32_t tf_dar;
    129  1.27  christos 	__register32_t tf_pad0[2];
    130  1.26      matt 	uint32_t tf_dsisr;
    131  1.26      matt 	uint32_t tf_vrsave;
    132  1.26      matt 	uint32_t tf_mq;
    133  1.26      matt 	uint32_t tf_pad1[1];
    134  1.26      matt #endif
    135  1.26      matt #if defined(PPC_BOOKE) || defined(PPC_IBM4XX)
    136  1.27  christos 	__register32_t tf_dear;
    137  1.27  christos 	__register32_t tf_mcar;
    138  1.27  christos 	__register32_t tf_sprg1;
    139  1.26      matt 	uint32_t tf_esr;
    140  1.26      matt 	uint32_t tf_mcsr;
    141  1.26      matt 	uint32_t tf_pid;
    142  1.26      matt 	uint32_t tf_spefscr;
    143  1.26      matt #endif
    144  1.26      matt };
    145  1.26      matt #endif /* _LP64 */
    146  1.22      matt #define tf_fixreg	tf_ureg.r_fixreg
    147  1.22      matt #define tf_lr		tf_ureg.r_lr
    148  1.22      matt #define tf_cr		tf_ureg.r_cr
    149  1.22      matt #define tf_xer		tf_ureg.r_xer
    150  1.22      matt #define tf_ctr		tf_ureg.r_ctr
    151  1.22      matt #define tf_srr0		tf_cf.cf_srr0
    152  1.22      matt #define tf_srr1		tf_cf.cf_srr1
    153  1.22      matt #define tf_idepth	tf_cf.cf_idepth
    154  1.22      matt 
    155  1.22      matt struct ktrapframe {
    156  1.27  christos 	__register_t ktf_sp;
    157  1.27  christos 	__register_t ktf_lr;
    158  1.22      matt 	struct trapframe ktf_tf;
    159  1.27  christos 	__register_t ktf_cframe_lr;	/* for DDB */
    160  1.22      matt };
    161  1.10      matt 
    162  1.28       rin #if defined(_KERNEL)
    163  1.10      matt #ifdef _LP64
    164  1.15      matt struct utrapframe32 {
    165  1.27  christos 	__register32_t fixreg[32];
    166  1.27  christos 	__register32_t lr;
    167  1.10      matt 	int cr;
    168  1.10      matt 	int xer;
    169  1.27  christos 	__register32_t ctr;
    170  1.27  christos 	__register32_t srr0;
    171  1.27  christos 	__register32_t srr1;
    172  1.14      matt 	int vrsave;
    173  1.14      matt 	int mq;
    174  1.14      matt 	int spare;
    175  1.10      matt };
    176  1.10      matt #endif
    177  1.28       rin #endif /* _KERNEL */
    178  1.10      matt 
    179   1.1        ws /*
    180   1.1        ws  * This is to ensure alignment of the stackpointer
    181   1.1        ws  */
    182  1.22      matt #define	FRAMELEN	roundup(sizeof(struct ktrapframe), CALLFRAMELEN)
    183  1.22      matt #define	ktrapframe(l)	((struct ktrapframe *)(uvm_lwp_getuarea(l) + USPACE - CALLFRAMELEN - FRAMELEN))
    184  1.22      matt #define	trapframe(l)	(&(ktrapframe(l)->ktf_tf))
    185   1.1        ws 
    186  1.17      matt #define	SFRAMELEN	roundup(sizeof(struct switchframe), CALLFRAMELEN)
    187   1.1        ws struct switchframe {
    188  1.27  christos 	__register_t sf_sp;
    189  1.27  christos 	__register_t sf_lr;
    190  1.27  christos 	__register_t sf_user_sr;		/* VSID on IBM4XX */
    191  1.27  christos 	__register_t sf_cr;		/* why?  CR is volatile. */
    192  1.27  christos 	__register_t sf_fixreg2;
    193  1.27  christos 	__register_t sf_fixreg[19];	/* R13-R31 */
    194   1.1        ws };
    195   1.1        ws 
    196   1.1        ws /*
    197   1.1        ws  * Call frame for PowerPC used during fork.
    198   1.1        ws  */
    199  1.10      matt #define	CALLFRAMELEN	sizeof(struct callframe)
    200   1.1        ws struct callframe {
    201  1.27  christos 	__register_t cf_sp;
    202  1.27  christos 	__register_t cf_lr;
    203  1.27  christos 	__register_t cf_r30;
    204  1.27  christos 	__register_t cf_r31;
    205   1.3      matt };
    206   1.3      matt 
    207   1.8      matt #endif	/* _POWERPC_FRAME_H_ */
    208