xref: /openbsd-src/sys/arch/sparc64/include/frame.h (revision e786f1bc9e99d14d7ff6a938e84c5bfe448c84a5)
1*e786f1bcSmiod /*	$OpenBSD: frame.h,v 1.11 2024/04/08 20:07:53 miod Exp $	*/
2bd12f793Sart /*	$NetBSD: frame.h,v 1.9 2001/03/04 09:28:35 mrg Exp $ */
3bd12f793Sart 
4bd12f793Sart /*
5bd12f793Sart  * Copyright (c) 1992, 1993
6bd12f793Sart  *	The Regents of the University of California.  All rights reserved.
7bd12f793Sart  *
8bd12f793Sart  * This software was developed by the Computer Systems Engineering group
9bd12f793Sart  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
10bd12f793Sart  * contributed to Berkeley.
11bd12f793Sart  *
12bd12f793Sart  * All advertising materials mentioning features or use of this software
13bd12f793Sart  * must display the following acknowledgement:
14bd12f793Sart  *	This product includes software developed by the University of
15bd12f793Sart  *	California, Lawrence Berkeley Laboratory.
16bd12f793Sart  *
17bd12f793Sart  * Redistribution and use in source and binary forms, with or without
18bd12f793Sart  * modification, are permitted provided that the following conditions
19bd12f793Sart  * are met:
20bd12f793Sart  * 1. Redistributions of source code must retain the above copyright
21bd12f793Sart  *    notice, this list of conditions and the following disclaimer.
22bd12f793Sart  * 2. Redistributions in binary form must reproduce the above copyright
23bd12f793Sart  *    notice, this list of conditions and the following disclaimer in the
24bd12f793Sart  *    documentation and/or other materials provided with the distribution.
2529295d1cSmillert  * 3. Neither the name of the University nor the names of its contributors
26bd12f793Sart  *    may be used to endorse or promote products derived from this software
27bd12f793Sart  *    without specific prior written permission.
28bd12f793Sart  *
29bd12f793Sart  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30bd12f793Sart  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31bd12f793Sart  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32bd12f793Sart  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33bd12f793Sart  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34bd12f793Sart  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35bd12f793Sart  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36bd12f793Sart  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37bd12f793Sart  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38bd12f793Sart  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39bd12f793Sart  * SUCH DAMAGE.
40bd12f793Sart  *
41bd12f793Sart  *	@(#)frame.h	8.1 (Berkeley) 6/11/93
42bd12f793Sart  */
43bd12f793Sart 
442fa72412Spirofti #ifndef _MACHINE_FRAME_H_
452fa72412Spirofti #define _MACHINE_FRAME_H_
46eb79e960Shenric 
47bd12f793Sart /*
48248a8d5aSmiod  * CC64FSZ (C Compiler 64-bit Frame SiZe) is the size of a stack frame used
49248a8d5aSmiod  * by the compiler in 64-bit mode.  It is (16)*8; space for 8 ins, 8 outs.
50248a8d5aSmiod  */
51248a8d5aSmiod #define CC64FSZ		176
52248a8d5aSmiod 
53248a8d5aSmiod /*
54248a8d5aSmiod  * v9 stacks all have a bias of 2047 added to the %sp and %fp, so you can easily
55248a8d5aSmiod  * detect it by testing the register for an odd value.  Why 2K-1 I don't know.
56248a8d5aSmiod  */
57248a8d5aSmiod #define BIAS	(2048-1)
58248a8d5aSmiod 
59248a8d5aSmiod #if defined(_KERNEL) && !defined(_LOCORE)
60248a8d5aSmiod 
61248a8d5aSmiod /*
62bd12f793Sart  * Sparc v9 stack frame format.
63bd12f793Sart  *
64bd12f793Sart  * Note that the contents of each stack frame may be held only in
65bd12f793Sart  * machine register windows.  In order to get an accurate picture
66bd12f793Sart  * of the frame, you must first force the kernel to write any such
67bd12f793Sart  * windows to the stack.
68bd12f793Sart  *
698be8d618Sclaudio  * V9 frames have an odd bias, so you can tell a v9 frame from
70bd12f793Sart  * a v8 frame by testing the stack pointer's lsb.
71bd12f793Sart  */
721c00236eSmiod struct frame {
73bd12f793Sart 	int64_t	fr_local[8];	/* space to save locals (%l0..%l7) */
74bd12f793Sart 	int64_t	fr_arg[6];	/* space to save arguments (%i0..%i5) */
75bd12f793Sart 	u_int64_t	fr_fp;		/* space to save frame pointer (%i6) */
76bd12f793Sart 	u_int64_t	fr_pc;		/* space to save return pc (%i7) */
77bd12f793Sart 	/*
78bd12f793Sart 	 * SVR4 reserves a bunch of extra stuff.
79bd12f793Sart 	 */
80bd12f793Sart 	int64_t fr_argd[6];	/* `register save area' (lunacy) */
81bd12f793Sart 	int64_t	fr_argx[0];	/* arg extension (args 7..n; variable size) */
82bd12f793Sart };
83bd12f793Sart 
841c00236eSmiod #define v9next_frame(f)		((struct frame*)(f->fr_fp+BIAS))
85bd12f793Sart 
86bd12f793Sart /*
87*e786f1bcSmiod  * The v9 trapframe.
881c00236eSmiod  */
891c00236eSmiod struct trapframe {
901c00236eSmiod 	int64_t		tf_tstate;	/* tstate register */
911c00236eSmiod 	int64_t		tf_pc;		/* return pc */
921c00236eSmiod 	int64_t		tf_npc;		/* return npc */
931c00236eSmiod 	int		tf_y;		/* %y register -- 32-bits */
941c00236eSmiod 	short		tf_tt;		/* What type of trap this was */
951c00236eSmiod 	char		tf_pil;		/* What IRQ we're handling */
961c00236eSmiod 	char		tf_oldpil;	/* What our old SPL was */
971c00236eSmiod 	int64_t		tf_global[8];	/* global registers in trap's caller */
981c00236eSmiod 	int64_t		tf_out[8];	/* output registers in trap's caller */
991c00236eSmiod 	int64_t		tf_local[8];	/* local registers in trap's caller */
1001c00236eSmiod 	int64_t		tf_in[8];	/* in registers in trap's caller (for debug) */
1011c00236eSmiod };
102248a8d5aSmiod 
103248a8d5aSmiod #endif	/* _KERNEL && !_LOCORE */
1041c00236eSmiod 
1052fa72412Spirofti #endif /* _MACHINE_FRAME_H_ */
106