xref: /csrg-svn/old/adb/adb.tahoe/machdep.h (revision 36562)
1*36562Sbostic /*
2*36562Sbostic  * Copyright (c) 1988 The Regents of the University of California.
3*36562Sbostic  * All rights reserved.
4*36562Sbostic  *
5*36562Sbostic  *	@(#)machdep.h	5.1 (Berkeley) 01/16/89
6*36562Sbostic  */
7*36562Sbostic 
8*36562Sbostic /*
9*36562Sbostic  * hword_t is a 2-byte (`halfword') type, used for (eg) w, l, x commands;
10*36562Sbostic  * addr_t is address type, must be unsigned; registers pc, fp, sp
11*36562Sbostic  *	(where those exist) are assumed to be of this type, and
12*36562Sbostic  *	addresses in the debuggee are of this type;
13*36562Sbostic  * expr_t is expression result type, size must be >= size of addr_t and
14*36562Sbostic  *	reg_t; must be unsigned; it is treated as the fullword type
15*36562Sbostic  *	and should therefore be 4 bytes long;
16*36562Sbostic  * sexpr_t is a signed version of expr_t.
17*36562Sbostic  *
18*36562Sbostic  * SHOULD WORK ON ALLOWING (eg) 1 AND 2 BYTE, OR 4 AND 8 BYTE, ETC, WORDS
19*36562Sbostic  */
20*36562Sbostic typedef	u_int	addr_t;
21*36562Sbostic typedef	u_int	expr_t;
22*36562Sbostic typedef	int	sexpr_t;
23*36562Sbostic typedef	u_short	hword_t;
24*36562Sbostic 
25*36562Sbostic /*
26*36562Sbostic  * Since values of type addr_t, hword_t, and expr_t must be printed,
27*36562Sbostic  * and the varargs mechanism assumes that the programmer has accounted
28*36562Sbostic  * for any extension from `small' types (char, short) to `regular' types
29*36562Sbostic  * (int), we define the following macros.  Each is supposed to produce
30*36562Sbostic  * a (possibly sign-extended) expr_t value:
31*36562Sbostic  *
32*36562Sbostic  *	SH_ARG	a signed halfword (%d, %q formats)
33*36562Sbostic  *	UH_ARG	an unsigned halfword (o, u, x)
34*36562Sbostic  *	SF_ARG	a signed fullword (D, Q)
35*36562Sbostic  *	UF_ARG	an unsigned fullword (O, U, X)
36*36562Sbostic  */
37*36562Sbostic #define SH_ARG	(expr_t)(short)va_arg(ap, int)
38*36562Sbostic #define	UH_ARG	(expr_t)(unsigned short)va_arg(ap, int)
39*36562Sbostic #define	SF_ARG	(expr_t)va_arg(ap, int)
40*36562Sbostic #define	UF_ARG	(expr_t)va_arg(ap, int)
41*36562Sbostic 
42*36562Sbostic /*
43*36562Sbostic  * bpt_t is used to hold original instructions when their breakpoint
44*36562Sbostic  * replacement(s) is/are set.
45*36562Sbostic  */
46*36562Sbostic typedef	char	bpt_t;
47*36562Sbostic 
48*36562Sbostic /*
49*36562Sbostic  * ADDRESS_WRAP is a predicate that returns true if the two addr_t
50*36562Sbostic  * arguments are in different spaces.
51*36562Sbostic  */
52*36562Sbostic #define	ADDRESS_WRAP(a, b) (((a) ^ (b)) >> 30)
53*36562Sbostic 
54*36562Sbostic /*
55*36562Sbostic  * Struct activation is used for tracing through stack frames.
56*36562Sbostic  * It must hold any information needed to locate an activation record
57*36562Sbostic  * (variables and parameters) for a function, and must have two fields
58*36562Sbostic  * of type addr_t called `a_pc' and `a_fp', the `program counter' and
59*36562Sbostic  * the `frame pointer'.  a_pc is used by the expression evaluator to
60*36562Sbostic  * find symbols; a_fp is returned as the result from an expression of
61*36562Sbostic  * the form `name.' (a routine name, but no local symbol).
62*36562Sbostic  * The field a_valid is cleared by a_prev() when there are no more
63*36562Sbostic  * activation records on the stack.
64*36562Sbostic  */
65*36562Sbostic struct activation {
66*36562Sbostic 	int	a_valid;		/* set iff frame is valid */
67*36562Sbostic 	addr_t	a_fp;			/* fp */
68*36562Sbostic 	addr_t	a_pc;			/* pc */
69*36562Sbostic };
70*36562Sbostic 
71*36562Sbostic /*
72*36562Sbostic  * On the tahoe, the frame pointer of a `struct frame' points to the
73*36562Sbostic  * frame's fr_savfp field, not to the base address of the frame.
74*36562Sbostic  */
75*36562Sbostic #define	FRAMEOFF 8		/* (int)&fr.fr_savfp - (int)&fr */
76*36562Sbostic 
77*36562Sbostic /*
78*36562Sbostic  * The reglist structure holds information needed to set and examine
79*36562Sbostic  * registers.  It must contain an r_name field; this name must be unique
80*36562Sbostic  * across the register set, cannot be a single letter or digit, and
81*36562Sbostic  * cannot be a substring of any other register name.
82*36562Sbostic  *
83*36562Sbostic  * On the Tahoe, we keep an offset into the u. area, either from the
84*36562Sbostic  * base of the u. area (in the pcb), or, for those registers that
85*36562Sbostic  * are saved by syscalls, in the save area pointed to by u.u_ar0.
86*36562Sbostic  * Offsets into the latter region are negative.
87*36562Sbostic  *
88*36562Sbostic  * We also keep a pointer into the current pcb for use when debugging
89*36562Sbostic  * the kernel.
90*36562Sbostic  */
91*36562Sbostic struct reglist {
92*36562Sbostic 	char	*r_name;	/* name */
93*36562Sbostic 	int	r_offset;	/* offset into pcb, or from u.u_ar0 */
94*36562Sbostic 	int	*r_pcbaddr;	/* if kcore, address in current pcb */
95*36562Sbostic };
96*36562Sbostic 
97*36562Sbostic /*
98*36562Sbostic  * ispace_reg() is true iff register r points into I-space (usually just PC).
99*36562Sbostic  */
100*36562Sbostic #ifdef lint
101*36562Sbostic #define	ispace_reg(r)	((r) == NULL)
102*36562Sbostic #else
103*36562Sbostic #define	ispace_reg(r)	0	/* ispace==dspace on Tahoe */
104*36562Sbostic #endif
105*36562Sbostic 
106*36562Sbostic /*
107*36562Sbostic  * getpc() returns as an addr_t the current PC; setpc() sets PC to its
108*36562Sbostic  * addr_t argument.  entrypc() returns the addr_t value of the appropriate
109*36562Sbostic  * startup PC.
110*36562Sbostic  */
111*36562Sbostic addr_t	getpc();
112*36562Sbostic #define	entrypc()	((addr_t)0)	/* ??? */
113*36562Sbostic 
114*36562Sbostic /*
115*36562Sbostic  * INSTACK is true when its argument is a stack address.  It is
116*36562Sbostic  * only used for consistency checking and may be overly permissive.
117*36562Sbostic  * INKERNEL is true iff its argument is a kernel space address.
118*36562Sbostic  */
119*36562Sbostic #define	INSTACK(a)	(((a) & 0xc0000000) == 0x80000000) /* p2 space */
120*36562Sbostic #define	INKERNEL(a)	(((a) & 0xc0000000) == 0xc0000000) /* sys space */
121*36562Sbostic 
122*36562Sbostic #define	KERNTEXTOFF	(KERNBASE + 0x800)	/* start of kernel text */
123