xref: /minix/minix/commands/swifi/db_machdep.h (revision 83133719)
1 /*
2  * Mach Operating System
3  * Copyright (c) 1991,1990 Carnegie Mellon University
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify and distribute this software and its
7  * documentation is hereby granted, provided that both the copyright
8  * notice and this permission notice appear in all copies of the
9  * software, derivative works or modified versions, and any portions
10  * thereof, and that both notices appear in supporting documentation.
11  *
12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15  *
16  * Carnegie Mellon requests users of this software to return to
17  *
18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19  *  School of Computer Science
20  *  Carnegie Mellon University
21  *  Pittsburgh PA 15213-3890
22  *
23  * any improvements or extensions that they make and grant Carnegie Mellon
24  * the rights to redistribute these changes.
25  */
26 
27 #ifndef _MACHINE_DB_MACHDEP_H_
28 #define	_MACHINE_DB_MACHDEP_H_
29 
30 #if 0
31 //#include <machine/frame.h>
32 //#include <machine/psl.h>
33 #endif
34 
35 #ifndef TRUE
36 #define TRUE 1
37 #endif
38 
39 #ifndef FALSE
40 #define FALSE 0
41 #endif
42 
43 #define i386_saved_state trapframe
44 
45 typedef	vm_offset_t	db_addr_t;	/* address - unsigned */
46 typedef	int		db_expr_t;	/* expression - signed */
47 
48 typedef struct i386_saved_state db_regs_t;
49 extern db_regs_t	ddb_regs;	/* register state */
50 #define	DDB_REGS	(&ddb_regs)
51 
52 #define	PC_REGS(regs)	(((regs)->tf_cs & 0xfffc) == 0x08 \
53 			 ? (db_addr_t)(regs)->tf_eip : 0)
54 
55 #define	BKPT_INST	0xcc		/* breakpoint instruction */
56 #define	BKPT_SIZE	(1)		/* size of breakpoint inst */
57 #define	BKPT_SET(inst)	(BKPT_INST)
58 
59 #define	FIXUP_PC_AFTER_BREAK	ddb_regs.tf_eip -= 1;
60 
61 #define	db_clear_single_step(regs)	((regs)->tf_eflags &= ~PSL_T)
62 #define	db_set_single_step(regs)	((regs)->tf_eflags |=  PSL_T)
63 
64 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BPTFLT)
65 /*
66  * Watchpoints are not supported.  The debug exception type is in %dr6
67  * and not yet in the args to this macro.
68  */
69 #define IS_WATCHPOINT_TRAP(type, code)	0
70 
71 #define	I_CALL		0xe8
72 #define	I_CALLI		0xff
73 #define	I_RET		0xc3
74 #define	I_IRET		0xcf
75 
76 #define	inst_trap_return(ins)	(((ins)&0xff) == I_IRET)
77 #define	inst_return(ins)	(((ins)&0xff) == I_RET)
78 #define	inst_call(ins)		(((ins)&0xff) == I_CALL || \
79 				 (((ins)&0xff) == I_CALLI && \
80 				  ((ins)&0x3800) == 0x1000))
81 #define inst_load(ins)		0
82 #define inst_store(ins)		0
83 
84 /*
85  * There no interesting addresses below _kstack = 0xefbfe000.  There
86  * are small absolute values for GUPROF, but we don't want to see them.
87  * Treat "negative" addresses below _kstack as non-small to allow for
88  * future reductions of _kstack and to avoid sign extension problems.
89  *
90  * There is one interesting symbol above -db_maxoff = 0xffff0000,
91  * namely _APTD = 0xfffff000.  Accepting this would mess up the
92  * printing of small negative offsets.  The next largest symbol is
93  * _APTmap = 0xffc00000.  Accepting this is OK (unless db_maxoff is
94  * set to >= 0x400000 - (max stack offset)).
95  */
96 #define	DB_SMALL_VALUE_MAX	0x7fffffff
97 #define	DB_SMALL_VALUE_MIN	(-0x400001)
98 
99 #endif /* !_MACHINE_DB_MACHDEP_H_ */
100