4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * Retargetable Kmdb/PROM interface
36 #include <sys/types.h>
39 #include <sys/regset.h>
42 #include <mdb/mdb_kreg.h>
43 #include <mdb/mdb_target.h>
44 #include <kmdb/kmdb_auxv.h>
45 #include <kmdb/kmdb_dpi_isadep.h>
46 #include <kmdb/kmdb_kctl.h>
49 * The following directive tells the mapfile generator that only those
50 * prototypes and declarations ending with a "Driver OK" comment should be
51 * included in the mapfile.
53 * MAPFILE: export "Driver OK"
60 #define DPI_MASTER_CPUID (-1) /* matches CPU ID for master */
62 #define DPI_ALLOW_FAULTS NULL
64 #define DPI_STATE_INIT 1 /* debugger initializing */
65 #define DPI_STATE_STOPPED 2 /* User-requested stop (debug_enter) */
66 #define DPI_STATE_FAULTED 3 /* Breakpoint, watchpoint, etc. */
67 #define DPI_STATE_LOST 4 /* debugger fault */
69 #define DPI_STATE_WHY_BKPT 1
70 #define DPI_STATE_WHY_V_WAPT 2
71 #define DPI_STATE_WHY_P_WAPT 3
72 #define DPI_STATE_WHY_TRAP 4
74 #define DPI_WAPT_TYPE_PHYS 0x1 /* Physical address (SPARC only) */
75 #define DPI_WAPT_TYPE_VIRT 0x2 /* Virtual address */
76 #define DPI_WAPT_TYPE_IO 0x4 /* I/O space (Intel only) */
78 #define DPI_CPU_STATE_NONE 0
79 #define DPI_CPU_STATE_MASTER 1
80 #define DPI_CPU_STATE_SLAVE 2
82 typedef struct dpi_ops dpi_ops_t
;
84 typedef struct kmdb_wapt
{
85 uintptr_t wp_addr
; /* Watchpoint base address */
86 size_t wp_size
; /* Size of watched area, in bytes */
87 int wp_type
; /* DPI_WAPT_TYPE_* */
88 uint_t wp_wflags
; /* access modes */
89 void *wp_priv
; /* DPI-private data */
92 extern int kmdb_dpi_init(kmdb_auxv_t
*);
94 extern void kmdb_dpi_enter_mon(void);
96 extern void kmdb_dpi_modchg_register(void (*)(struct modctl
*, int));
97 extern void kmdb_dpi_modchg_cancel(void);
99 extern int kmdb_dpi_get_cpu_state(int);
100 extern int kmdb_dpi_get_master_cpuid(void);
102 extern const mdb_tgt_gregset_t
*kmdb_dpi_get_gregs(int);
104 extern int kmdb_dpi_get_register(const char *, kreg_t
*);
105 extern int kmdb_dpi_set_register(const char *, kreg_t
);
107 extern jmp_buf *kmdb_dpi_set_fault_hdlr(jmp_buf *);
108 extern void kmdb_dpi_restore_fault_hdlr(jmp_buf *);
110 extern int kmdb_dpi_brkpt_arm(uintptr_t, mdb_instr_t
*);
111 extern int kmdb_dpi_brkpt_disarm(uintptr_t, mdb_instr_t
);
113 extern int kmdb_dpi_wapt_validate(kmdb_wapt_t
*);
114 extern int kmdb_dpi_wapt_reserve(kmdb_wapt_t
*);
115 extern void kmdb_dpi_wapt_release(kmdb_wapt_t
*);
116 extern void kmdb_dpi_wapt_arm(kmdb_wapt_t
*);
117 extern void kmdb_dpi_wapt_disarm(kmdb_wapt_t
*);
118 extern int kmdb_dpi_wapt_match(kmdb_wapt_t
*);
120 extern void kmdb_dpi_set_state(int, int);
121 extern int kmdb_dpi_get_state(int *);
123 extern int kmdb_dpi_step(void);
125 extern uintptr_t kmdb_dpi_call(uintptr_t, uint_t
, const uintptr_t *);
127 extern void kmdb_dpi_process_work_queue(void);
128 extern int kmdb_dpi_work_required(void); /* Driver OK */
130 extern void kmdb_dpi_flush_slave_caches(void);
132 extern void kmdb_dpi_dump_crumbs(uintptr_t, int);
135 * Debugger/Kernel suspend
138 extern jmp_buf kmdb_dpi_entry_pcb
;
139 extern uint_t kmdb_dpi_resume_requested
; /* Driver OK */
140 extern uint_t kmdb_dpi_switch_target
; /* Driver OK */
141 extern jmp_buf kmdb_dpi_resume_pcb
;
143 extern int kmdb_dpi_reenter(void);
144 extern void kmdb_dpi_resume(void);
145 extern void kmdb_dpi_resume_unload(void);
146 extern int kmdb_dpi_switch_master(int);
152 #endif /* _KMDB_DPI_H */