10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51991Sheppo * Common Development and Distribution License (the "License"). 61991Sheppo * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*3446Smrj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _KCTL_H 270Sstevel@tonic-gate #define _KCTL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <kmdb/kmdb_auxv.h> 320Sstevel@tonic-gate #include <kmdb/kmdb_wr.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <sys/ddi.h> 350Sstevel@tonic-gate #include <sys/sunddi.h> 360Sstevel@tonic-gate #include <sys/kdi.h> 370Sstevel@tonic-gate #include <sys/modctl.h> 380Sstevel@tonic-gate #include <sys/ksynch.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifdef __cplusplus 410Sstevel@tonic-gate extern "C" { 420Sstevel@tonic-gate #endif 430Sstevel@tonic-gate 440Sstevel@tonic-gate typedef enum { 450Sstevel@tonic-gate KCTL_ST_INACTIVE = 0, /* kmdb is inactive */ 460Sstevel@tonic-gate KCTL_ST_DSEG_ALLOCED, /* kmdb segment has been allocated */ 470Sstevel@tonic-gate KCTL_ST_INITIALIZED, /* kmdb_init has been called */ 480Sstevel@tonic-gate KCTL_ST_KCTL_PREACTIVATED, /* kctl preactivation completed */ 490Sstevel@tonic-gate KCTL_ST_MOD_NOTIFIERS, /* krtld module notifiers registered */ 500Sstevel@tonic-gate KCTL_ST_THREAD_STARTED, /* WR queue thread started */ 510Sstevel@tonic-gate KCTL_ST_DBG_ACTIVATED, /* kmdb activated */ 520Sstevel@tonic-gate KCTL_ST_ACTIVE, /* kernel is aware of kmdb activation */ 530Sstevel@tonic-gate KCTL_ST_DEACTIVATING /* debugger is being deactivated */ 540Sstevel@tonic-gate } kctl_state_t; 550Sstevel@tonic-gate 560Sstevel@tonic-gate typedef enum { 570Sstevel@tonic-gate KCTL_WR_ST_RUN, /* WR queue thread is running */ 580Sstevel@tonic-gate KCTL_WR_ST_STOP, /* WR queue thread is stopping */ 590Sstevel@tonic-gate KCTL_WR_ST_STOPPED /* WR queue thread has stopped */ 600Sstevel@tonic-gate } kctl_wr_state_t; 610Sstevel@tonic-gate 620Sstevel@tonic-gate typedef struct kctl { 630Sstevel@tonic-gate dev_info_t *kctl_drv_dip; /* Driver's device info structure */ 640Sstevel@tonic-gate size_t kctl_memgoalsz; /* Desired size of debugger memory */ 650Sstevel@tonic-gate caddr_t kctl_dseg; /* Debugger segment (Oz) address */ 660Sstevel@tonic-gate size_t kctl_dseg_size; /* Debugger segment (Oz) size */ 670Sstevel@tonic-gate caddr_t kctl_mrbase; /* Add'l Oz memory range base address */ 680Sstevel@tonic-gate size_t kctl_mrsize; /* Add'l Oz memory range size */ 690Sstevel@tonic-gate vnode_t kctl_vp; /* vnode used to allocate dbgr seg */ 700Sstevel@tonic-gate kctl_state_t kctl_state; /* State of debugger */ 710Sstevel@tonic-gate uint_t kctl_boot_loaded; /* Set if debugger loaded at boot */ 720Sstevel@tonic-gate struct bootops *kctl_boot_ops; /* Boot operations (during init only) */ 730Sstevel@tonic-gate const char *kctl_execname; /* Path of this module */ 740Sstevel@tonic-gate uint_t kctl_wr_avail; /* Work available on the WR queue */ 750Sstevel@tonic-gate ksema_t kctl_wr_avail_sem; /* For WR thr: Work avail on WR queue */ 760Sstevel@tonic-gate kthread_t *kctl_wr_thr; /* Thread that processes WR queue */ 770Sstevel@tonic-gate kctl_wr_state_t kctl_wr_state; /* State of WR queue thread */ 780Sstevel@tonic-gate kmutex_t kctl_lock; /* serializes (de)activation */ 790Sstevel@tonic-gate kcondvar_t kctl_wr_cv; /* WR queue thread completion */ 800Sstevel@tonic-gate kmutex_t kctl_wr_lock; /* WR queue thread completion */ 810Sstevel@tonic-gate uint_t kctl_flags; /* KMDB_F_* from kmdb.h */ 820Sstevel@tonic-gate #ifdef __sparc 830Sstevel@tonic-gate caddr_t kctl_tba; /* kmdb's native trap table */ 840Sstevel@tonic-gate #endif 850Sstevel@tonic-gate } kctl_t; 860Sstevel@tonic-gate 870Sstevel@tonic-gate extern kctl_t kctl; 880Sstevel@tonic-gate 890Sstevel@tonic-gate struct bootops; 900Sstevel@tonic-gate 910Sstevel@tonic-gate extern void kctl_dprintf(const char *, ...); 920Sstevel@tonic-gate extern void kctl_warn(const char *, ...); 930Sstevel@tonic-gate 940Sstevel@tonic-gate extern int kctl_preactivate_isadep(void); 95*3446Smrj extern void kctl_activate_isadep(kdi_debugvec_t *); 960Sstevel@tonic-gate extern void kctl_depreactivate_isadep(void); 970Sstevel@tonic-gate extern void kctl_cleanup(void); 980Sstevel@tonic-gate 990Sstevel@tonic-gate extern void *kctl_boot_tmpinit(void); 1000Sstevel@tonic-gate extern void kctl_boot_tmpfini(void *); 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate extern void kctl_auxv_init(kmdb_auxv_t *, const char *, const char **, void *); 1030Sstevel@tonic-gate extern void kctl_auxv_init_isadep(kmdb_auxv_t *, void *); 1040Sstevel@tonic-gate extern void kctl_auxv_fini(kmdb_auxv_t *); 1050Sstevel@tonic-gate extern void kctl_auxv_fini_isadep(kmdb_auxv_t *); 1061991Sheppo #ifdef sun4v 1071991Sheppo extern void kctl_auxv_set_promif(kmdb_auxv_t *); 1081991Sheppo extern void kctl_switch_promif(void); 1091991Sheppo #endif 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate extern void kctl_wrintr(void); 1120Sstevel@tonic-gate extern void kctl_wrintr_fire(void); 1130Sstevel@tonic-gate extern void kctl_wr_thr_start(void); 1140Sstevel@tonic-gate extern void kctl_wr_thr_stop(void); 1150Sstevel@tonic-gate extern void kctl_wr_thr_join(void); 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate extern int kctl_mod_decompress(struct modctl *); 1180Sstevel@tonic-gate extern void kctl_mod_loaded(struct modctl *); 1190Sstevel@tonic-gate extern void kctl_mod_changed(uint_t, struct modctl *); 1200Sstevel@tonic-gate extern void kctl_mod_notify_reg(void); 1210Sstevel@tonic-gate extern void kctl_mod_notify_unreg(void); 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate extern void kctl_dmod_init(void); 1240Sstevel@tonic-gate extern void kctl_dmod_fini(void); 1250Sstevel@tonic-gate extern void kctl_dmod_sync(void); 1260Sstevel@tonic-gate extern void kctl_dmod_autoload(const char *); 1270Sstevel@tonic-gate extern void kctl_dmod_unload_all(void); 1280Sstevel@tonic-gate extern void kctl_dmod_path_reset(void); 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate extern int kctl_wr_process(void); 1310Sstevel@tonic-gate extern void kctl_wr_unload(void); 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate extern char *kctl_basename(char *); 1340Sstevel@tonic-gate extern char *kctl_strdup(const char *); 1350Sstevel@tonic-gate extern void kctl_strfree(char *); 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate #if defined(__sparc) 1380Sstevel@tonic-gate extern kthread_t *kctl_curthread_set(kthread_t *); 1390Sstevel@tonic-gate #endif 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate #ifdef __cplusplus 1420Sstevel@tonic-gate } 1430Sstevel@tonic-gate #endif 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate #endif /* _KCTL_H */ 146