1139825Simp/*- 268549Sbenno * Copyright (C) 1995, 1996 Wolfgang Solfrank. 368549Sbenno * Copyright (C) 1995, 1996 TooLs GmbH. 468549Sbenno * All rights reserved. 568549Sbenno * 668549Sbenno * Redistribution and use in source and binary forms, with or without 768549Sbenno * modification, are permitted provided that the following conditions 868549Sbenno * are met: 968549Sbenno * 1. Redistributions of source code must retain the above copyright 1068549Sbenno * notice, this list of conditions and the following disclaimer. 1168549Sbenno * 2. Redistributions in binary form must reproduce the above copyright 1268549Sbenno * notice, this list of conditions and the following disclaimer in the 1368549Sbenno * documentation and/or other materials provided with the distribution. 1468549Sbenno * 3. All advertising materials mentioning features or use of this software 1568549Sbenno * must display the following acknowledgement: 1668549Sbenno * This product includes software developed by TooLs GmbH. 1768549Sbenno * 4. The name of TooLs GmbH may not be used to endorse or promote products 1868549Sbenno * derived from this software without specific prior written permission. 1968549Sbenno * 2068549Sbenno * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 2168549Sbenno * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2268549Sbenno * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2368549Sbenno * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2468549Sbenno * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2568549Sbenno * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 2668549Sbenno * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2768549Sbenno * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 2868549Sbenno * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 2968549Sbenno * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3070585Sobrien * 3177944Sobrien * $NetBSD: frame.h,v 1.2 1999/01/10 10:13:15 tsubai Exp $ 3270585Sobrien * $FreeBSD: releng/11.0/sys/powerpc/include/frame.h 279601 2015-03-04 21:06:57Z nwhitehorn $ 3368549Sbenno */ 3470585Sobrien 3568549Sbenno#ifndef _MACHINE_FRAME_H_ 3668549Sbenno#define _MACHINE_FRAME_H_ 3768549Sbenno 38103614Sgrehan#include <sys/types.h> 3968549Sbenno 4068549Sbenno/* 4168549Sbenno * We have to save all registers on every trap, because 4268549Sbenno * 1. user could attach this process every time 4368549Sbenno * 2. we must be able to restore all user registers in case of fork 4468549Sbenno * Actually, we do not save the fp registers on trap, since 4568549Sbenno * these are not used by the kernel. They are saved only when switching 4668549Sbenno * between processes using the FPU. 4768549Sbenno * 4868549Sbenno * Change ordering to cluster together these register_t's. XXX 4968549Sbenno */ 5068549Sbennostruct trapframe { 5168549Sbenno register_t fixreg[32]; 5268549Sbenno register_t lr; 53209975Snwhitehorn register_t cr; 54209975Snwhitehorn register_t xer; 5568549Sbenno register_t ctr; 5668549Sbenno register_t srr0; 5768549Sbenno register_t srr1; 58209975Snwhitehorn register_t exc; 59279601Snwhitehorn register_t dar; /* DAR/DEAR filled in on DSI traps */ 60176742Sraj union { 61176742Sraj struct { 62279601Snwhitehorn /* dsisr only filled on a DSI trap */ 63209975Snwhitehorn register_t dsisr; 64176742Sraj } aim; 65176742Sraj struct { 66176742Sraj register_t esr; 67189100Sraj register_t dbcr0; 68176742Sraj } booke; 69176742Sraj } cpu; 7068549Sbenno}; 71176742Sraj 7268549Sbenno/* 73209975Snwhitehorn * FRAMELEN is the size of the stack region used by the low-level trap 74209975Snwhitehorn * handler. It is the size of its data (trapframe) plus the callframe 75209975Snwhitehorn * header (sizeof(struct callframe) - 3 register widths). It must also 76209975Snwhitehorn * be 16-byte aligned. 7768549Sbenno */ 78209975Snwhitehorn#define FRAMELEN roundup(sizeof(struct trapframe) + \ 79209975Snwhitehorn sizeof(struct callframe) - 3*sizeof(register_t), 16) 8083682Smp#define trapframe(td) ((td)->td_frame) 8168549Sbenno 8268549Sbenno/* 8368549Sbenno * Call frame for PowerPC used during fork. 8468549Sbenno */ 85209975Snwhitehorn#ifdef __powerpc64__ 8668549Sbennostruct callframe { 87132520Sgrehan register_t cf_dummy_fp; /* dummy frame pointer */ 88209975Snwhitehorn register_t cf_cr; 89209975Snwhitehorn register_t cf_lr; 90209975Snwhitehorn register_t cf_compiler; 91209975Snwhitehorn register_t cf_linkeditor; 92209975Snwhitehorn register_t cf_toc; 93209975Snwhitehorn register_t cf_func; 94209975Snwhitehorn register_t cf_arg0; 95209975Snwhitehorn register_t cf_arg1; 96255273Snwhitehorn register_t _padding; /* Maintain 16-byte alignment */ 97209975Snwhitehorn}; 98209975Snwhitehorn#else 99209975Snwhitehornstruct callframe { 100209975Snwhitehorn register_t cf_dummy_fp; /* dummy frame pointer */ 101132520Sgrehan register_t cf_lr; /* space for link register save */ 10291467Sbenno register_t cf_func; 10391467Sbenno register_t cf_arg0; 10491467Sbenno register_t cf_arg1; 105255282Snwhitehorn register_t _padding; /* Maintain 16-byte alignment */ 10668549Sbenno}; 107209975Snwhitehorn#endif 10868549Sbenno 10997397Sbenno/* Definitions for syscalls */ 11097397Sbenno#define FIRSTARG 3 /* first arg in reg 3 */ 11197397Sbenno#define NARGREG 8 /* 8 args in regs */ 112209975Snwhitehorn#define MOREARGS(sp) ((caddr_t)((uintptr_t)(sp) + \ 113209975Snwhitehorn sizeof(struct callframe) - 3*sizeof(register_t))) /* more args go here */ 11497397Sbenno 11568549Sbenno#endif /* _MACHINE_FRAME_H_ */ 116