1*47819Sbostic /*- 236562Sbostic * Copyright (c) 1988 The Regents of the University of California. 336562Sbostic * All rights reserved. 436562Sbostic * 5*47819Sbostic * %sccs.include.proprietary.c% 6*47819Sbostic * 7*47819Sbostic * @(#)machdep.h 5.3 (Berkeley) 04/04/91 836562Sbostic */ 936562Sbostic 1036562Sbostic /* 1136562Sbostic * hword_t is a 2-byte (`halfword') type, used for (eg) w, l, x commands; 1236562Sbostic * addr_t is address type, must be unsigned; registers pc, fp, sp 1336562Sbostic * (where those exist) are assumed to be of this type, and 1436562Sbostic * addresses in the debuggee are of this type; 1536562Sbostic * expr_t is expression result type, size must be >= size of addr_t and 1636562Sbostic * reg_t; must be unsigned; it is treated as the fullword type 1736562Sbostic * and should therefore be 4 bytes long; 1836562Sbostic * sexpr_t is a signed version of expr_t. 1936562Sbostic * 2036562Sbostic * SHOULD WORK ON ALLOWING (eg) 1 AND 2 BYTE, OR 4 AND 8 BYTE, ETC, WORDS 2136562Sbostic */ 2236562Sbostic typedef u_int addr_t; 2336562Sbostic typedef u_int expr_t; 2436562Sbostic typedef int sexpr_t; 2536562Sbostic typedef u_short hword_t; 2636562Sbostic 2736562Sbostic /* 2836562Sbostic * Since values of type addr_t, hword_t, and expr_t must be printed, 2936562Sbostic * and the varargs mechanism assumes that the programmer has accounted 3036562Sbostic * for any extension from `small' types (char, short) to `regular' types 3136562Sbostic * (int), we define the following macros. Each is supposed to produce 3236562Sbostic * a (possibly sign-extended) expr_t value: 3336562Sbostic * 3436562Sbostic * SH_ARG a signed halfword (%d, %q formats) 3536562Sbostic * UH_ARG an unsigned halfword (o, u, x) 3636562Sbostic * SF_ARG a signed fullword (D, Q) 3736562Sbostic * UF_ARG an unsigned fullword (O, U, X) 3836562Sbostic */ 3936562Sbostic #define SH_ARG (expr_t)(short)va_arg(ap, int) 4036562Sbostic #define UH_ARG (expr_t)(unsigned short)va_arg(ap, int) 4136562Sbostic #define SF_ARG (expr_t)va_arg(ap, int) 4236562Sbostic #define UF_ARG (expr_t)va_arg(ap, int) 4336562Sbostic 4436562Sbostic /* 4536562Sbostic * bpt_t is used to hold original instructions when their breakpoint 4636562Sbostic * replacement(s) is/are set. 4736562Sbostic */ 4836562Sbostic typedef char bpt_t; 4936562Sbostic 5036562Sbostic /* 5136562Sbostic * ADDRESS_WRAP is a predicate that returns true if the two addr_t 5236562Sbostic * arguments are in different spaces. 5336562Sbostic */ 5436562Sbostic #define ADDRESS_WRAP(a, b) (((a) ^ (b)) >> 30) 5536562Sbostic 5636562Sbostic /* 5736562Sbostic * Struct activation is used for tracing through stack frames. 5836562Sbostic * It must hold any information needed to locate an activation record 5936562Sbostic * (variables and parameters) for a function, and must have two fields 6036562Sbostic * of type addr_t called `a_pc' and `a_fp', the `program counter' and 6136562Sbostic * the `frame pointer'. a_pc is used by the expression evaluator to 6236562Sbostic * find symbols; a_fp is returned as the result from an expression of 6336562Sbostic * the form `name.' (a routine name, but no local symbol). 6436562Sbostic * The field a_valid is cleared by a_prev() when there are no more 6536562Sbostic * activation records on the stack. 6636562Sbostic */ 6736562Sbostic struct activation { 6836562Sbostic int a_valid; /* set iff frame is valid */ 6936562Sbostic addr_t a_fp; /* fp */ 7036562Sbostic addr_t a_pc; /* pc */ 7136562Sbostic }; 7236562Sbostic 7336562Sbostic /* 7436562Sbostic * On the tahoe, the frame pointer of a `struct frame' points to the 7536562Sbostic * frame's fr_savfp field, not to the base address of the frame. 7636562Sbostic */ 7736562Sbostic #define FRAMEOFF 8 /* (int)&fr.fr_savfp - (int)&fr */ 7836562Sbostic 7936562Sbostic /* 8036562Sbostic * The reglist structure holds information needed to set and examine 8136562Sbostic * registers. It must contain an r_name field; this name must be unique 8236562Sbostic * across the register set, cannot be a single letter or digit, and 8336562Sbostic * cannot be a substring of any other register name. 8436562Sbostic * 8536562Sbostic * On the Tahoe, we keep an offset into the u. area, either from the 8636562Sbostic * base of the u. area (in the pcb), or, for those registers that 8736562Sbostic * are saved by syscalls, in the save area pointed to by u.u_ar0. 8836562Sbostic * Offsets into the latter region are negative. 8936562Sbostic * 9036562Sbostic * We also keep a pointer into the current pcb for use when debugging 9136562Sbostic * the kernel. 9236562Sbostic */ 9336562Sbostic struct reglist { 9436562Sbostic char *r_name; /* name */ 9536562Sbostic int r_offset; /* offset into pcb, or from u.u_ar0 */ 9636562Sbostic int *r_pcbaddr; /* if kcore, address in current pcb */ 9736562Sbostic }; 9836562Sbostic 9936562Sbostic /* 10036562Sbostic * ispace_reg() is true iff register r points into I-space (usually just PC). 10136562Sbostic */ 10236562Sbostic #ifdef lint 10336562Sbostic #define ispace_reg(r) ((r) == NULL) 10436562Sbostic #else 10536562Sbostic #define ispace_reg(r) 0 /* ispace==dspace on Tahoe */ 10636562Sbostic #endif 10736562Sbostic 10836562Sbostic /* 10936562Sbostic * getpc() returns as an addr_t the current PC; setpc() sets PC to its 11036562Sbostic * addr_t argument. entrypc() returns the addr_t value of the appropriate 11136562Sbostic * startup PC. 11236562Sbostic */ 11336562Sbostic addr_t getpc(); 11436562Sbostic #define entrypc() ((addr_t)0) /* ??? */ 11536562Sbostic 11636562Sbostic /* 11736562Sbostic * INSTACK is true when its argument is a stack address. It is 11836562Sbostic * only used for consistency checking and may be overly permissive. 11936562Sbostic * INKERNEL is true iff its argument is a kernel space address. 12036562Sbostic */ 12136562Sbostic #define INSTACK(a) (((a) & 0xc0000000) == 0x80000000) /* p2 space */ 12236562Sbostic #define INKERNEL(a) (((a) & 0xc0000000) == 0xc0000000) /* sys space */ 123