17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51ae08745Sheppo * Common Development and Distribution License (the "License"). 61ae08745Sheppo * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*ae115bc7Smrj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _KCTL_H 277c478bd9Sstevel@tonic-gate #define _KCTL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <kmdb/kmdb_auxv.h> 327c478bd9Sstevel@tonic-gate #include <kmdb/kmdb_wr.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 357c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 367c478bd9Sstevel@tonic-gate #include <sys/kdi.h> 377c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 387c478bd9Sstevel@tonic-gate #include <sys/ksynch.h> 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef __cplusplus 417c478bd9Sstevel@tonic-gate extern "C" { 427c478bd9Sstevel@tonic-gate #endif 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate typedef enum { 457c478bd9Sstevel@tonic-gate KCTL_ST_INACTIVE = 0, /* kmdb is inactive */ 467c478bd9Sstevel@tonic-gate KCTL_ST_DSEG_ALLOCED, /* kmdb segment has been allocated */ 477c478bd9Sstevel@tonic-gate KCTL_ST_INITIALIZED, /* kmdb_init has been called */ 487c478bd9Sstevel@tonic-gate KCTL_ST_KCTL_PREACTIVATED, /* kctl preactivation completed */ 497c478bd9Sstevel@tonic-gate KCTL_ST_MOD_NOTIFIERS, /* krtld module notifiers registered */ 507c478bd9Sstevel@tonic-gate KCTL_ST_THREAD_STARTED, /* WR queue thread started */ 517c478bd9Sstevel@tonic-gate KCTL_ST_DBG_ACTIVATED, /* kmdb activated */ 527c478bd9Sstevel@tonic-gate KCTL_ST_ACTIVE, /* kernel is aware of kmdb activation */ 537c478bd9Sstevel@tonic-gate KCTL_ST_DEACTIVATING /* debugger is being deactivated */ 547c478bd9Sstevel@tonic-gate } kctl_state_t; 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate typedef enum { 577c478bd9Sstevel@tonic-gate KCTL_WR_ST_RUN, /* WR queue thread is running */ 587c478bd9Sstevel@tonic-gate KCTL_WR_ST_STOP, /* WR queue thread is stopping */ 597c478bd9Sstevel@tonic-gate KCTL_WR_ST_STOPPED /* WR queue thread has stopped */ 607c478bd9Sstevel@tonic-gate } kctl_wr_state_t; 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate typedef struct kctl { 637c478bd9Sstevel@tonic-gate dev_info_t *kctl_drv_dip; /* Driver's device info structure */ 647c478bd9Sstevel@tonic-gate size_t kctl_memgoalsz; /* Desired size of debugger memory */ 657c478bd9Sstevel@tonic-gate caddr_t kctl_dseg; /* Debugger segment (Oz) address */ 667c478bd9Sstevel@tonic-gate size_t kctl_dseg_size; /* Debugger segment (Oz) size */ 677c478bd9Sstevel@tonic-gate caddr_t kctl_mrbase; /* Add'l Oz memory range base address */ 687c478bd9Sstevel@tonic-gate size_t kctl_mrsize; /* Add'l Oz memory range size */ 697c478bd9Sstevel@tonic-gate vnode_t kctl_vp; /* vnode used to allocate dbgr seg */ 707c478bd9Sstevel@tonic-gate kctl_state_t kctl_state; /* State of debugger */ 717c478bd9Sstevel@tonic-gate uint_t kctl_boot_loaded; /* Set if debugger loaded at boot */ 727c478bd9Sstevel@tonic-gate struct bootops *kctl_boot_ops; /* Boot operations (during init only) */ 737c478bd9Sstevel@tonic-gate const char *kctl_execname; /* Path of this module */ 747c478bd9Sstevel@tonic-gate uint_t kctl_wr_avail; /* Work available on the WR queue */ 757c478bd9Sstevel@tonic-gate ksema_t kctl_wr_avail_sem; /* For WR thr: Work avail on WR queue */ 767c478bd9Sstevel@tonic-gate kthread_t *kctl_wr_thr; /* Thread that processes WR queue */ 777c478bd9Sstevel@tonic-gate kctl_wr_state_t kctl_wr_state; /* State of WR queue thread */ 787c478bd9Sstevel@tonic-gate kmutex_t kctl_lock; /* serializes (de)activation */ 797c478bd9Sstevel@tonic-gate kcondvar_t kctl_wr_cv; /* WR queue thread completion */ 807c478bd9Sstevel@tonic-gate kmutex_t kctl_wr_lock; /* WR queue thread completion */ 817c478bd9Sstevel@tonic-gate uint_t kctl_flags; /* KMDB_F_* from kmdb.h */ 827c478bd9Sstevel@tonic-gate #ifdef __sparc 837c478bd9Sstevel@tonic-gate caddr_t kctl_tba; /* kmdb's native trap table */ 847c478bd9Sstevel@tonic-gate #endif 857c478bd9Sstevel@tonic-gate } kctl_t; 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate extern kctl_t kctl; 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate struct bootops; 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate extern void kctl_dprintf(const char *, ...); 927c478bd9Sstevel@tonic-gate extern void kctl_warn(const char *, ...); 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate extern int kctl_preactivate_isadep(void); 95*ae115bc7Smrj extern void kctl_activate_isadep(kdi_debugvec_t *); 967c478bd9Sstevel@tonic-gate extern void kctl_depreactivate_isadep(void); 977c478bd9Sstevel@tonic-gate extern void kctl_cleanup(void); 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate extern void *kctl_boot_tmpinit(void); 1007c478bd9Sstevel@tonic-gate extern void kctl_boot_tmpfini(void *); 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate extern void kctl_auxv_init(kmdb_auxv_t *, const char *, const char **, void *); 1037c478bd9Sstevel@tonic-gate extern void kctl_auxv_init_isadep(kmdb_auxv_t *, void *); 1047c478bd9Sstevel@tonic-gate extern void kctl_auxv_fini(kmdb_auxv_t *); 1057c478bd9Sstevel@tonic-gate extern void kctl_auxv_fini_isadep(kmdb_auxv_t *); 1061ae08745Sheppo #ifdef sun4v 1071ae08745Sheppo extern void kctl_auxv_set_promif(kmdb_auxv_t *); 1081ae08745Sheppo extern void kctl_switch_promif(void); 1091ae08745Sheppo #endif 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate extern void kctl_wrintr(void); 1127c478bd9Sstevel@tonic-gate extern void kctl_wrintr_fire(void); 1137c478bd9Sstevel@tonic-gate extern void kctl_wr_thr_start(void); 1147c478bd9Sstevel@tonic-gate extern void kctl_wr_thr_stop(void); 1157c478bd9Sstevel@tonic-gate extern void kctl_wr_thr_join(void); 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate extern int kctl_mod_decompress(struct modctl *); 1187c478bd9Sstevel@tonic-gate extern void kctl_mod_loaded(struct modctl *); 1197c478bd9Sstevel@tonic-gate extern void kctl_mod_changed(uint_t, struct modctl *); 1207c478bd9Sstevel@tonic-gate extern void kctl_mod_notify_reg(void); 1217c478bd9Sstevel@tonic-gate extern void kctl_mod_notify_unreg(void); 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate extern void kctl_dmod_init(void); 1247c478bd9Sstevel@tonic-gate extern void kctl_dmod_fini(void); 1257c478bd9Sstevel@tonic-gate extern void kctl_dmod_sync(void); 1267c478bd9Sstevel@tonic-gate extern void kctl_dmod_autoload(const char *); 1277c478bd9Sstevel@tonic-gate extern void kctl_dmod_unload_all(void); 1287c478bd9Sstevel@tonic-gate extern void kctl_dmod_path_reset(void); 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate extern int kctl_wr_process(void); 1317c478bd9Sstevel@tonic-gate extern void kctl_wr_unload(void); 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate extern char *kctl_basename(char *); 1347c478bd9Sstevel@tonic-gate extern char *kctl_strdup(const char *); 1357c478bd9Sstevel@tonic-gate extern void kctl_strfree(char *); 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate #if defined(__sparc) 1387c478bd9Sstevel@tonic-gate extern kthread_t *kctl_curthread_set(kthread_t *); 1397c478bd9Sstevel@tonic-gate #endif 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1427c478bd9Sstevel@tonic-gate } 1437c478bd9Sstevel@tonic-gate #endif 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate #endif /* _KCTL_H */ 146