1 /* $OpenBSD: frame.h,v 1.19 2012/06/21 00:56:59 guenther Exp $ */ 2 3 /* 4 * Copyright (c) 1999-2004 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 30 #ifndef _MACHINE_FRAME_H_ 31 #define _MACHINE_FRAME_H_ 32 33 /* 34 * Call frame definitions 35 */ 36 #define HPPA_FRAME_NARGS (12) 37 #define HPPA_FRAME_MAXARGS (HPPA_FRAME_NARGS * 4) 38 #define HPPA_FRAME_ARG(n) (-(32 + 4*((n) + 1))) 39 #define HPPA_FRAME_CARG(n,sp) ((register_t *)((sp) + HPPA_FRAME_ARG(n))) 40 #define HPPA_FRAME_SIZE (64) 41 #define HPPA_FRAME_PSP (-4) 42 #define HPPA_FRAME_EP (-8) 43 #define HPPA_FRAME_CLUP (-12) 44 #define HPPA_FRAME_SL (-16) 45 #define HPPA_FRAME_CRP (-20) 46 #define HPPA_FRAME_ERP (-24) 47 #define HPPA_FRAME_ESR4 (-28) 48 #define HPPA_FRAME_EDP (-32) 49 50 /* 51 * Macros to decode processor status word. 52 */ 53 #define HPPA_PC_PRIV_MASK 3 54 #define HPPA_PC_PRIV_KERN 0 55 #define HPPA_PC_PRIV_USER 3 56 #define USERMODE(pc) ((((register_t)pc) & HPPA_PC_PRIV_MASK) != HPPA_PC_PRIV_KERN) 57 #define KERNMODE(pc) (((register_t)pc) & ~HPPA_PC_PRIV_MASK) 58 59 #ifndef _LOCORE 60 /* 61 * the trapframe is divided into two parts: 62 * one is saved while we are in the physical mode (beginning of the trap), 63 * and should be kept as small as possible, since all the interrupts will 64 * be lost during this phase, also it must be 64-bytes aligned, per 65 * pa-risc stack conventions, and its dependencies in the code (; 66 * the other part is filled out when we are already in the virtual mode, 67 * are able to catch interrupts (they are kept pending) and perform 68 * other trap activities (like tlb misses). 69 */ 70 struct trapframe { 71 /* the `physical' part of the trapframe */ 72 unsigned long tf_t1; /* r22 */ 73 unsigned long tf_t2; /* r21 */ 74 unsigned long tf_sp; /* r30 */ 75 unsigned long tf_t3; /* r20 */ 76 unsigned long tf_iisq_head; /* cr17 */ 77 unsigned long tf_iisq_tail; 78 unsigned long tf_iioq_head; /* cr18 */ 79 unsigned long tf_iioq_tail; 80 unsigned long tf_eiem; /* cr15 */ 81 unsigned long tf_ipsw; /* cr22 */ 82 unsigned long tf_sr3; 83 unsigned long tf_pidr1; /* cr8 */ 84 unsigned long tf_isr; /* cr20 */ 85 unsigned long tf_ior; /* cr21 */ 86 unsigned long tf_iir; /* cr19 */ 87 unsigned long tf_flags; 88 89 /* here starts the `virtual' part */ 90 unsigned long tf_sar; /* cr11 */ 91 unsigned long tf_r1; 92 unsigned long tf_rp; /* r2 */ 93 unsigned long tf_r3; /* frame pointer when -g */ 94 unsigned long tf_r4; 95 unsigned long tf_r5; 96 unsigned long tf_r6; 97 unsigned long tf_r7; 98 unsigned long tf_r8; 99 unsigned long tf_r9; 100 unsigned long tf_r10; 101 unsigned long tf_r11; 102 unsigned long tf_r12; 103 unsigned long tf_r13; 104 unsigned long tf_r14; 105 unsigned long tf_r15; 106 unsigned long tf_r16; 107 unsigned long tf_r17; 108 unsigned long tf_r18; 109 unsigned long tf_t4; /* r19 */ 110 unsigned long tf_arg3; /* r23 */ 111 unsigned long tf_arg2; /* r24 */ 112 unsigned long tf_arg1; /* r25 */ 113 unsigned long tf_arg0; /* r26 */ 114 unsigned long tf_dp; /* r27 */ 115 unsigned long tf_ret0; /* r28 */ 116 unsigned long tf_ret1; /* r29 */ 117 unsigned long tf_r31; 118 unsigned long tf_sr0; 119 unsigned long tf_sr1; 120 unsigned long tf_sr2; 121 unsigned long tf_sr4; 122 unsigned long tf_sr5; 123 unsigned long tf_sr6; 124 unsigned long tf_sr7; 125 unsigned long tf_pidr2; /* cr9 */ 126 unsigned long tf_pidr3; /* cr12 */ 127 unsigned long tf_pidr4; /* cr13 */ 128 unsigned long tf_rctr; /* cr0 */ 129 unsigned long tf_ccr; /* cr10 */ 130 unsigned long tf_eirr; /* cr23 - DDB */ 131 unsigned long tf_vtop; /* cr25 - DDB */ 132 unsigned long tf_cr27; 133 unsigned long tf_cr28; /* - DDB */ 134 unsigned long tf_cr30; /* uaddr */ 135 136 unsigned long tf_pad[3]; /* pad to 256 bytes */ 137 }; 138 139 #ifdef _KERNEL 140 int setstack(struct trapframe *, u_long, register_t); 141 #endif /* _KERNEL */ 142 143 #endif /* !_LOCORE */ 144 145 #endif /* !_MACHINE_FRAME_H_ */ 146