160727d8bSWarner Losh /*- 2*51369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause 3*51369649SPedro F. Giffuni * 4fb75554eSBenno Rice * Copyright (C) 1995, 1996 Wolfgang Solfrank. 5fb75554eSBenno Rice * Copyright (C) 1995, 1996 TooLs GmbH. 6fb75554eSBenno Rice * All rights reserved. 7fb75554eSBenno Rice * 8fb75554eSBenno Rice * Redistribution and use in source and binary forms, with or without 9fb75554eSBenno Rice * modification, are permitted provided that the following conditions 10fb75554eSBenno Rice * are met: 11fb75554eSBenno Rice * 1. Redistributions of source code must retain the above copyright 12fb75554eSBenno Rice * notice, this list of conditions and the following disclaimer. 13fb75554eSBenno Rice * 2. Redistributions in binary form must reproduce the above copyright 14fb75554eSBenno Rice * notice, this list of conditions and the following disclaimer in the 15fb75554eSBenno Rice * documentation and/or other materials provided with the distribution. 16fb75554eSBenno Rice * 3. All advertising materials mentioning features or use of this software 17fb75554eSBenno Rice * must display the following acknowledgement: 18fb75554eSBenno Rice * This product includes software developed by TooLs GmbH. 19fb75554eSBenno Rice * 4. The name of TooLs GmbH may not be used to endorse or promote products 20fb75554eSBenno Rice * derived from this software without specific prior written permission. 21fb75554eSBenno Rice * 22fb75554eSBenno Rice * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 23fb75554eSBenno Rice * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24fb75554eSBenno Rice * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25fb75554eSBenno Rice * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26fb75554eSBenno Rice * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27fb75554eSBenno Rice * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28fb75554eSBenno Rice * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29fb75554eSBenno Rice * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30fb75554eSBenno Rice * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31fb75554eSBenno Rice * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32dfeade78SDavid E. O'Brien * 33dfeade78SDavid E. O'Brien * $NetBSD: frame.h,v 1.2 1999/01/10 10:13:15 tsubai Exp $ 34fb75554eSBenno Rice */ 35dfeade78SDavid E. O'Brien 36fb75554eSBenno Rice #ifndef _MACHINE_FRAME_H_ 37fb75554eSBenno Rice #define _MACHINE_FRAME_H_ 38fb75554eSBenno Rice 39a379a142SPeter Grehan #include <sys/types.h> 40fb75554eSBenno Rice 41fb75554eSBenno Rice /* 42fb75554eSBenno Rice * We have to save all registers on every trap, because 43fb75554eSBenno Rice * 1. user could attach this process every time 44fb75554eSBenno Rice * 2. we must be able to restore all user registers in case of fork 45fb75554eSBenno Rice * Actually, we do not save the fp registers on trap, since 46fb75554eSBenno Rice * these are not used by the kernel. They are saved only when switching 47fb75554eSBenno Rice * between processes using the FPU. 48fb75554eSBenno Rice * 49fb75554eSBenno Rice * Change ordering to cluster together these register_t's. XXX 50fb75554eSBenno Rice */ 51fb75554eSBenno Rice struct trapframe { 52fb75554eSBenno Rice register_t fixreg[32]; 53fb75554eSBenno Rice register_t lr; 54c3e289e1SNathan Whitehorn register_t cr; 55c3e289e1SNathan Whitehorn register_t xer; 56fb75554eSBenno Rice register_t ctr; 57fb75554eSBenno Rice register_t srr0; 58fb75554eSBenno Rice register_t srr1; 59c3e289e1SNathan Whitehorn register_t exc; 60f14cf38dSNathan Whitehorn register_t dar; /* DAR/DEAR filled in on DSI traps */ 61786e4a1bSRafal Jaworowski union { 62786e4a1bSRafal Jaworowski struct { 63f14cf38dSNathan Whitehorn /* dsisr only filled on a DSI trap */ 64c3e289e1SNathan Whitehorn register_t dsisr; 65786e4a1bSRafal Jaworowski } aim; 66786e4a1bSRafal Jaworowski struct { 67786e4a1bSRafal Jaworowski register_t esr; 680a35b40fSRafal Jaworowski register_t dbcr0; 69786e4a1bSRafal Jaworowski } booke; 70786e4a1bSRafal Jaworowski } cpu; 71fb75554eSBenno Rice }; 72786e4a1bSRafal Jaworowski 73fb75554eSBenno Rice /* 74c3e289e1SNathan Whitehorn * FRAMELEN is the size of the stack region used by the low-level trap 75c3e289e1SNathan Whitehorn * handler. It is the size of its data (trapframe) plus the callframe 76c3e289e1SNathan Whitehorn * header (sizeof(struct callframe) - 3 register widths). It must also 77c3e289e1SNathan Whitehorn * be 16-byte aligned. 78fb75554eSBenno Rice */ 79c3e289e1SNathan Whitehorn #define FRAMELEN roundup(sizeof(struct trapframe) + \ 80c3e289e1SNathan Whitehorn sizeof(struct callframe) - 3*sizeof(register_t), 16) 815fd2c51eSMark Peek #define trapframe(td) ((td)->td_frame) 82fb75554eSBenno Rice 83fb75554eSBenno Rice /* 84fb75554eSBenno Rice * Call frame for PowerPC used during fork. 85fb75554eSBenno Rice */ 86c3e289e1SNathan Whitehorn #ifdef __powerpc64__ 87c3e289e1SNathan Whitehorn struct callframe { 88c3e289e1SNathan Whitehorn register_t cf_dummy_fp; /* dummy frame pointer */ 89c3e289e1SNathan Whitehorn register_t cf_cr; 90c3e289e1SNathan Whitehorn register_t cf_lr; 91c3e289e1SNathan Whitehorn register_t cf_compiler; 92c3e289e1SNathan Whitehorn register_t cf_linkeditor; 93c3e289e1SNathan Whitehorn register_t cf_toc; 94c3e289e1SNathan Whitehorn register_t cf_func; 95c3e289e1SNathan Whitehorn register_t cf_arg0; 96c3e289e1SNathan Whitehorn register_t cf_arg1; 97a5715964SNathan Whitehorn register_t _padding; /* Maintain 16-byte alignment */ 98c3e289e1SNathan Whitehorn }; 99c3e289e1SNathan Whitehorn #else 100fb75554eSBenno Rice struct callframe { 101bddfaa89SPeter Grehan register_t cf_dummy_fp; /* dummy frame pointer */ 102bddfaa89SPeter Grehan register_t cf_lr; /* space for link register save */ 1034eed0cf1SBenno Rice register_t cf_func; 1044eed0cf1SBenno Rice register_t cf_arg0; 1054eed0cf1SBenno Rice register_t cf_arg1; 106653a5825SNathan Whitehorn register_t _padding; /* Maintain 16-byte alignment */ 107fb75554eSBenno Rice }; 108c3e289e1SNathan Whitehorn #endif 109c3e289e1SNathan Whitehorn 110c3e289e1SNathan Whitehorn /* Definitions for syscalls */ 111c3e289e1SNathan Whitehorn #define FIRSTARG 3 /* first arg in reg 3 */ 11260ead00eSBenno Rice #define NARGREG 8 /* 8 args in regs */ 11360ead00eSBenno Rice 114fb75554eSBenno Rice #endif /* _MACHINE_FRAME_H_ */ 115