1/* 2 * CDDL HEADER START 3 * 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 7 * with the License. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27#ifndef _KMDB_DPI_H 28#define _KMDB_DPI_H 29 30#pragma ident "%Z%%M% %I% %E% SMI" 31 32/* 33 * Retargetable Kmdb/PROM interface 34 */ 35 36#include <sys/types.h> 37#include <setjmp.h> 38#ifdef __sparc 39#include <sys/regset.h> 40#endif /* __sparc */ 41 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> 47 48/* 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. 52 * 53 * MAPFILE: export "Driver OK" 54 */ 55 56#ifdef __cplusplus 57extern "C" { 58#endif 59 60#define DPI_MASTER_CPUID (-1) /* matches CPU ID for master */ 61 62#define DPI_ALLOW_FAULTS NULL 63 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 */ 68 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 73 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) */ 77 78#define DPI_CPU_STATE_NONE 0 79#define DPI_CPU_STATE_MASTER 1 80#define DPI_CPU_STATE_SLAVE 2 81 82typedef struct dpi_ops dpi_ops_t; 83 84typedef 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 */ 90} kmdb_wapt_t; 91 92extern int kmdb_dpi_init(kmdb_auxv_t *); 93 94extern void kmdb_dpi_enter_mon(void); 95 96extern void kmdb_dpi_modchg_register(void (*)(struct modctl *, int)); 97extern void kmdb_dpi_modchg_cancel(void); 98 99extern int kmdb_dpi_get_cpu_state(int); 100extern int kmdb_dpi_get_master_cpuid(void); 101 102extern const mdb_tgt_gregset_t *kmdb_dpi_get_gregs(int); 103 104extern int kmdb_dpi_get_register(const char *, kreg_t *); 105extern int kmdb_dpi_set_register(const char *, kreg_t); 106 107extern jmp_buf *kmdb_dpi_set_fault_hdlr(jmp_buf *); 108extern void kmdb_dpi_restore_fault_hdlr(jmp_buf *); 109 110extern int kmdb_dpi_brkpt_arm(uintptr_t, mdb_instr_t *); 111extern int kmdb_dpi_brkpt_disarm(uintptr_t, mdb_instr_t); 112 113extern int kmdb_dpi_wapt_validate(kmdb_wapt_t *); 114extern int kmdb_dpi_wapt_reserve(kmdb_wapt_t *); 115extern void kmdb_dpi_wapt_release(kmdb_wapt_t *); 116extern void kmdb_dpi_wapt_arm(kmdb_wapt_t *); 117extern void kmdb_dpi_wapt_disarm(kmdb_wapt_t *); 118extern int kmdb_dpi_wapt_match(kmdb_wapt_t *); 119 120extern void kmdb_dpi_set_state(int, int); 121extern int kmdb_dpi_get_state(int *); 122 123extern int kmdb_dpi_step(void); 124 125extern uintptr_t kmdb_dpi_call(uintptr_t, uint_t, const uintptr_t *); 126 127extern void kmdb_dpi_process_work_queue(void); 128extern int kmdb_dpi_work_required(void); /* Driver OK */ 129 130extern void kmdb_dpi_flush_slave_caches(void); 131 132extern void kmdb_dpi_dump_crumbs(uintptr_t, int); 133 134/* 135 * Debugger/Kernel suspend 136 */ 137 138extern jmp_buf kmdb_dpi_entry_pcb; 139extern uint_t kmdb_dpi_resume_requested; /* Driver OK */ 140extern uint_t kmdb_dpi_switch_target; /* Driver OK */ 141extern jmp_buf kmdb_dpi_resume_pcb; 142 143extern int kmdb_dpi_reenter(void); 144extern void kmdb_dpi_resume(void); 145extern void kmdb_dpi_resume_unload(void); 146extern int kmdb_dpi_switch_master(int); 147 148#ifdef __cplusplus 149} 150#endif 151 152#endif /* _KMDB_DPI_H */ 153