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