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