xref: /openbsd-src/sys/arch/m88k/include/db_machdep.h (revision 42cc995287453fe7fb6ceff91e03eacadaa32611)
1*42cc9952Sjasper /*	$OpenBSD: db_machdep.h,v 1.20 2021/08/30 08:11:12 jasper Exp $ */
23180e169Smiod /*
33180e169Smiod  * Mach Operating System
43180e169Smiod  * Copyright (c) 1993-1991 Carnegie Mellon University
53180e169Smiod  * Copyright (c) 1991 OMRON Corporation
63180e169Smiod  * All Rights Reserved.
73180e169Smiod  *
83180e169Smiod  * Permission to use, copy, modify and distribute this software and its
93180e169Smiod  * documentation is hereby granted, provided that both the copyright
103180e169Smiod  * notice and this permission notice appear in all copies of the
113180e169Smiod  * software, derivative works or modified versions, and any portions
123180e169Smiod  * thereof, and that both notices appear in supporting documentation.
133180e169Smiod  *
143180e169Smiod  * CARNEGIE MELLON AND OMRON ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
153180e169Smiod  * CONDITION.  CARNEGIE MELLON AND OMRON DISCLAIM ANY LIABILITY OF ANY KIND
163180e169Smiod  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
173180e169Smiod  *
183180e169Smiod  * Carnegie Mellon requests users of this software to return to
193180e169Smiod  *
203180e169Smiod  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
213180e169Smiod  *  School of Computer Science
223180e169Smiod  *  Carnegie Mellon University
233180e169Smiod  *  Pittsburgh PA 15213-3890
243180e169Smiod  *
253180e169Smiod  * any improvements or extensions that they make and grant Carnegie the
263180e169Smiod  * rights to redistribute these changes.
273180e169Smiod  */
283180e169Smiod 
293180e169Smiod #ifndef _M88K_DB_MACHDEP_H_
303180e169Smiod #define _M88K_DB_MACHDEP_H_
313180e169Smiod 
323180e169Smiod /* trap numbers used by ddb */
333180e169Smiod #define	DDB_ENTRY_BKPT_NO	130
343180e169Smiod #define	DDB_ENTRY_TRACE_NO	131
353180e169Smiod #define DDB_ENTRY_TRAP_NO	132
363180e169Smiod 
373180e169Smiod #ifndef	_LOCORE
383180e169Smiod 
39dc3bbfb1Smiod #include <machine/reg.h>
403180e169Smiod #include <machine/trap.h>
413180e169Smiod 
423180e169Smiod #include <uvm/uvm_param.h>
433180e169Smiod 
44bb1d6ae9Smiod #define	SET_PC_REGS(regs, value)					\
45bb1d6ae9Smiod do {									\
46e84b4c13Smiod 	(regs)->sxip = (value);						\
47e84b4c13Smiod 	(regs)->snip = (value) + 4;					\
48bb1d6ae9Smiod } while (0)
493180e169Smiod 
503180e169Smiod #ifdef DDB
513180e169Smiod 
523180e169Smiod #define BKPT_SIZE	(4)	/* number of bytes in bkpt inst. */
531c5400c8Smiod #define BKPT_INST	(0xf000d000 | DDB_ENTRY_BKPT_NO) /* tb0, 0,r0, 130 */
543180e169Smiod #define BKPT_SET(inst)	(BKPT_INST)
553180e169Smiod 
563180e169Smiod /* Entry trap for the debugger - used for inline assembly breaks*/
570b514a07Smiod #define ENTRY_ASM		"tb0 0, %r0, 132"
583180e169Smiod 
593180e169Smiod typedef	long		db_expr_t;
603180e169Smiod typedef	struct reg	db_regs_t;
613180e169Smiod extern db_regs_t	ddb_regs;	/* register state */
623180e169Smiod 
63bb1d6ae9Smiod int	ddb_break_trap(int, db_regs_t *);
64bb1d6ae9Smiod int	ddb_entry_trap(int, db_regs_t *);
65bf37e088Smiod void	m88k_print_instruction(int, u_int, u_int32_t);	/* db_disasm.c */
661c5400c8Smiod 
671c5400c8Smiod /*
681c5400c8Smiod  * inst_call(ins) - is the instruction a function call.
691c5400c8Smiod  * Could be either bsr or jsr.
701c5400c8Smiod  */
711c5400c8Smiod #define	inst_call(I) \
721c5400c8Smiod 	(((I) & 0xf8000000) == 0xc8000000 /* bsr */ || \
731c5400c8Smiod 	 ((I) & 0xfffffbe0) == 0xf400c800 /* jsr */)
741c5400c8Smiod /*
751c5400c8Smiod  * inst_return(ins) - is the instruction a function call return.
761c5400c8Smiod  * Not mutually exclusive with inst_branch. Should be a jmp r1.
771c5400c8Smiod  */
781c5400c8Smiod #define	inst_return(I)	(((I) & 0xfffffbff) == 0xf400c001)
791c5400c8Smiod 
801c5400c8Smiod /*
811c5400c8Smiod  * inst_trap_return(ins) - is the instruction a return from trap.
821c5400c8Smiod  * Should be a rte.
831c5400c8Smiod  */
841c5400c8Smiod #define	inst_trap_return(I)	((I) == 0xf400c000)
853180e169Smiod 
863180e169Smiod /* breakpoint/watchpoint foo */
873180e169Smiod #define IS_BREAKPOINT_TRAP(type,code) ((type)==T_KDB_BREAK)
883180e169Smiod #define IS_WATCHPOINT_TRAP(type,code) 0
893180e169Smiod 
903180e169Smiod /* machine specific commands have been added to ddb */
91bb1d6ae9Smiod #define DB_MACHINE_COMMANDS
923180e169Smiod 
93b2bb8c7eSmiod #ifdef MULTIPROCESSOR
94b2bb8c7eSmiod extern cpuid_t ddb_mp_nextcpu;
95b2bb8c7eSmiod #endif
96b2bb8c7eSmiod 
973180e169Smiod #endif	/* DDB */
983180e169Smiod #endif	/* _LOCORE */
993180e169Smiod 
1003180e169Smiod #endif	/* _M88K_DB_MACHDEP_H_ */
101