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 #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include <sys/dtrace.h> 30*7c478bd9Sstevel@tonic-gate #include <sys/systrace.h> 31*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> 32*7c478bd9Sstevel@tonic-gate #include <sys/systm.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/conf.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 36*7c478bd9Sstevel@tonic-gate #include <sys/atomic.h> 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #define SYSTRACE_ARTIFICIAL_FRAMES 1 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #define SYSTRACE_SHIFT 16 41*7c478bd9Sstevel@tonic-gate #define SYSTRACE_ISENTRY(x) ((int)(x) >> SYSTRACE_SHIFT) 42*7c478bd9Sstevel@tonic-gate #define SYSTRACE_SYSNUM(x) ((int)(x) & ((1 << SYSTRACE_SHIFT) - 1)) 43*7c478bd9Sstevel@tonic-gate #define SYSTRACE_ENTRY(id) ((1 << SYSTRACE_SHIFT) | (id)) 44*7c478bd9Sstevel@tonic-gate #define SYSTRACE_RETURN(id) (id) 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate #if ((1 << SYSTRACE_SHIFT) <= NSYSCALL) 47*7c478bd9Sstevel@tonic-gate #error 1 << SYSTRACE_SHIFT must exceed number of system calls 48*7c478bd9Sstevel@tonic-gate #endif 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate static dev_info_t *systrace_devi; 51*7c478bd9Sstevel@tonic-gate static dtrace_provider_id_t systrace_id; 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate static void 54*7c478bd9Sstevel@tonic-gate systrace_init(struct sysent *actual, systrace_sysent_t **interposed) 55*7c478bd9Sstevel@tonic-gate { 56*7c478bd9Sstevel@tonic-gate systrace_sysent_t *sysent = *interposed; 57*7c478bd9Sstevel@tonic-gate int i; 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate if (sysent == NULL) { 60*7c478bd9Sstevel@tonic-gate *interposed = sysent = kmem_zalloc(sizeof (systrace_sysent_t) * 61*7c478bd9Sstevel@tonic-gate NSYSCALL, KM_SLEEP); 62*7c478bd9Sstevel@tonic-gate } 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate for (i = 0; i < NSYSCALL; i++) { 65*7c478bd9Sstevel@tonic-gate struct sysent *a = &actual[i]; 66*7c478bd9Sstevel@tonic-gate systrace_sysent_t *s = &sysent[i]; 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate if (LOADABLE_SYSCALL(a) && !LOADED_SYSCALL(a)) 69*7c478bd9Sstevel@tonic-gate continue; 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate if (a->sy_callc == dtrace_systrace_syscall) 72*7c478bd9Sstevel@tonic-gate continue; 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 75*7c478bd9Sstevel@tonic-gate if (a->sy_callc == dtrace_systrace_syscall32) 76*7c478bd9Sstevel@tonic-gate continue; 77*7c478bd9Sstevel@tonic-gate #endif 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate s->stsy_underlying = a->sy_callc; 80*7c478bd9Sstevel@tonic-gate } 81*7c478bd9Sstevel@tonic-gate } 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 84*7c478bd9Sstevel@tonic-gate static void 85*7c478bd9Sstevel@tonic-gate systrace_provide(void *arg, const dtrace_probedesc_t *desc) 86*7c478bd9Sstevel@tonic-gate { 87*7c478bd9Sstevel@tonic-gate int i; 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate if (desc != NULL) 90*7c478bd9Sstevel@tonic-gate return; 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gate systrace_init(sysent, &systrace_sysent); 93*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 94*7c478bd9Sstevel@tonic-gate systrace_init(sysent32, &systrace_sysent32); 95*7c478bd9Sstevel@tonic-gate #endif 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate for (i = 0; i < NSYSCALL; i++) { 98*7c478bd9Sstevel@tonic-gate if (systrace_sysent[i].stsy_underlying == NULL) 99*7c478bd9Sstevel@tonic-gate continue; 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate if (dtrace_probe_lookup(systrace_id, NULL, 102*7c478bd9Sstevel@tonic-gate syscallnames[i], "entry") != 0) 103*7c478bd9Sstevel@tonic-gate continue; 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate (void) dtrace_probe_create(systrace_id, NULL, syscallnames[i], 106*7c478bd9Sstevel@tonic-gate "entry", SYSTRACE_ARTIFICIAL_FRAMES, 107*7c478bd9Sstevel@tonic-gate (void *)((uintptr_t)SYSTRACE_ENTRY(i))); 108*7c478bd9Sstevel@tonic-gate (void) dtrace_probe_create(systrace_id, NULL, syscallnames[i], 109*7c478bd9Sstevel@tonic-gate "return", SYSTRACE_ARTIFICIAL_FRAMES, 110*7c478bd9Sstevel@tonic-gate (void *)((uintptr_t)SYSTRACE_RETURN(i))); 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate systrace_sysent[i].stsy_entry = DTRACE_IDNONE; 113*7c478bd9Sstevel@tonic-gate systrace_sysent[i].stsy_return = DTRACE_IDNONE; 114*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 115*7c478bd9Sstevel@tonic-gate systrace_sysent32[i].stsy_entry = DTRACE_IDNONE; 116*7c478bd9Sstevel@tonic-gate systrace_sysent32[i].stsy_return = DTRACE_IDNONE; 117*7c478bd9Sstevel@tonic-gate #endif 118*7c478bd9Sstevel@tonic-gate } 119*7c478bd9Sstevel@tonic-gate } 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 122*7c478bd9Sstevel@tonic-gate static void 123*7c478bd9Sstevel@tonic-gate systrace_destroy(void *arg, dtrace_id_t id, void *parg) 124*7c478bd9Sstevel@tonic-gate { 125*7c478bd9Sstevel@tonic-gate int sysnum = SYSTRACE_SYSNUM((uintptr_t)parg); 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate /* 128*7c478bd9Sstevel@tonic-gate * There's nothing to do here but assert that we have actually been 129*7c478bd9Sstevel@tonic-gate * disabled. 130*7c478bd9Sstevel@tonic-gate */ 131*7c478bd9Sstevel@tonic-gate if (SYSTRACE_ISENTRY((uintptr_t)parg)) { 132*7c478bd9Sstevel@tonic-gate ASSERT(systrace_sysent[sysnum].stsy_entry == DTRACE_IDNONE); 133*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 134*7c478bd9Sstevel@tonic-gate ASSERT(systrace_sysent32[sysnum].stsy_entry == DTRACE_IDNONE); 135*7c478bd9Sstevel@tonic-gate #endif 136*7c478bd9Sstevel@tonic-gate } else { 137*7c478bd9Sstevel@tonic-gate ASSERT(systrace_sysent[sysnum].stsy_return == DTRACE_IDNONE); 138*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 139*7c478bd9Sstevel@tonic-gate ASSERT(systrace_sysent32[sysnum].stsy_return == DTRACE_IDNONE); 140*7c478bd9Sstevel@tonic-gate #endif 141*7c478bd9Sstevel@tonic-gate } 142*7c478bd9Sstevel@tonic-gate } 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 145*7c478bd9Sstevel@tonic-gate static void 146*7c478bd9Sstevel@tonic-gate systrace_enable(void *arg, dtrace_id_t id, void *parg) 147*7c478bd9Sstevel@tonic-gate { 148*7c478bd9Sstevel@tonic-gate int sysnum = SYSTRACE_SYSNUM((uintptr_t)parg); 149*7c478bd9Sstevel@tonic-gate int enabled = (systrace_sysent[sysnum].stsy_entry != DTRACE_IDNONE || 150*7c478bd9Sstevel@tonic-gate systrace_sysent[sysnum].stsy_return != DTRACE_IDNONE); 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate if (SYSTRACE_ISENTRY((uintptr_t)parg)) { 153*7c478bd9Sstevel@tonic-gate systrace_sysent[sysnum].stsy_entry = id; 154*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 155*7c478bd9Sstevel@tonic-gate systrace_sysent32[sysnum].stsy_entry = id; 156*7c478bd9Sstevel@tonic-gate #endif 157*7c478bd9Sstevel@tonic-gate } else { 158*7c478bd9Sstevel@tonic-gate systrace_sysent[sysnum].stsy_return = id; 159*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 160*7c478bd9Sstevel@tonic-gate systrace_sysent32[sysnum].stsy_return = id; 161*7c478bd9Sstevel@tonic-gate #endif 162*7c478bd9Sstevel@tonic-gate } 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate if (enabled) { 165*7c478bd9Sstevel@tonic-gate ASSERT(sysent[sysnum].sy_callc == dtrace_systrace_syscall); 166*7c478bd9Sstevel@tonic-gate return; 167*7c478bd9Sstevel@tonic-gate } 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate (void) casptr(&sysent[sysnum].sy_callc, 170*7c478bd9Sstevel@tonic-gate (void *)systrace_sysent[sysnum].stsy_underlying, 171*7c478bd9Sstevel@tonic-gate (void *)dtrace_systrace_syscall); 172*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 173*7c478bd9Sstevel@tonic-gate (void) casptr(&sysent32[sysnum].sy_callc, 174*7c478bd9Sstevel@tonic-gate (void *)systrace_sysent32[sysnum].stsy_underlying, 175*7c478bd9Sstevel@tonic-gate (void *)dtrace_systrace_syscall32); 176*7c478bd9Sstevel@tonic-gate #endif 177*7c478bd9Sstevel@tonic-gate } 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 180*7c478bd9Sstevel@tonic-gate static void 181*7c478bd9Sstevel@tonic-gate systrace_disable(void *arg, dtrace_id_t id, void *parg) 182*7c478bd9Sstevel@tonic-gate { 183*7c478bd9Sstevel@tonic-gate int sysnum = SYSTRACE_SYSNUM((uintptr_t)parg); 184*7c478bd9Sstevel@tonic-gate int disable = (systrace_sysent[sysnum].stsy_entry == DTRACE_IDNONE || 185*7c478bd9Sstevel@tonic-gate systrace_sysent[sysnum].stsy_return == DTRACE_IDNONE); 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate if (disable) { 188*7c478bd9Sstevel@tonic-gate (void) casptr(&sysent[sysnum].sy_callc, 189*7c478bd9Sstevel@tonic-gate (void *)dtrace_systrace_syscall, 190*7c478bd9Sstevel@tonic-gate (void *)systrace_sysent[sysnum].stsy_underlying); 191*7c478bd9Sstevel@tonic-gate 192*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 193*7c478bd9Sstevel@tonic-gate (void) casptr(&sysent32[sysnum].sy_callc, 194*7c478bd9Sstevel@tonic-gate (void *)dtrace_systrace_syscall32, 195*7c478bd9Sstevel@tonic-gate (void *)systrace_sysent32[sysnum].stsy_underlying); 196*7c478bd9Sstevel@tonic-gate #endif 197*7c478bd9Sstevel@tonic-gate } 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate if (SYSTRACE_ISENTRY((uintptr_t)parg)) { 200*7c478bd9Sstevel@tonic-gate systrace_sysent[sysnum].stsy_entry = DTRACE_IDNONE; 201*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 202*7c478bd9Sstevel@tonic-gate systrace_sysent32[sysnum].stsy_entry = DTRACE_IDNONE; 203*7c478bd9Sstevel@tonic-gate #endif 204*7c478bd9Sstevel@tonic-gate } else { 205*7c478bd9Sstevel@tonic-gate systrace_sysent[sysnum].stsy_return = DTRACE_IDNONE; 206*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 207*7c478bd9Sstevel@tonic-gate systrace_sysent32[sysnum].stsy_return = DTRACE_IDNONE; 208*7c478bd9Sstevel@tonic-gate #endif 209*7c478bd9Sstevel@tonic-gate } 210*7c478bd9Sstevel@tonic-gate } 211*7c478bd9Sstevel@tonic-gate 212*7c478bd9Sstevel@tonic-gate static dtrace_pattr_t systrace_attr = { 213*7c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON }, 214*7c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN }, 215*7c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA }, 216*7c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON }, 217*7c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA }, 218*7c478bd9Sstevel@tonic-gate }; 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate static dtrace_pops_t systrace_pops = { 221*7c478bd9Sstevel@tonic-gate systrace_provide, 222*7c478bd9Sstevel@tonic-gate NULL, 223*7c478bd9Sstevel@tonic-gate systrace_enable, 224*7c478bd9Sstevel@tonic-gate systrace_disable, 225*7c478bd9Sstevel@tonic-gate NULL, 226*7c478bd9Sstevel@tonic-gate NULL, 227*7c478bd9Sstevel@tonic-gate NULL, 228*7c478bd9Sstevel@tonic-gate NULL, 229*7c478bd9Sstevel@tonic-gate NULL, 230*7c478bd9Sstevel@tonic-gate systrace_destroy 231*7c478bd9Sstevel@tonic-gate }; 232*7c478bd9Sstevel@tonic-gate 233*7c478bd9Sstevel@tonic-gate static int 234*7c478bd9Sstevel@tonic-gate systrace_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) 235*7c478bd9Sstevel@tonic-gate { 236*7c478bd9Sstevel@tonic-gate switch (cmd) { 237*7c478bd9Sstevel@tonic-gate case DDI_ATTACH: 238*7c478bd9Sstevel@tonic-gate break; 239*7c478bd9Sstevel@tonic-gate case DDI_RESUME: 240*7c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 241*7c478bd9Sstevel@tonic-gate default: 242*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 243*7c478bd9Sstevel@tonic-gate } 244*7c478bd9Sstevel@tonic-gate 245*7c478bd9Sstevel@tonic-gate systrace_probe = dtrace_probe; 246*7c478bd9Sstevel@tonic-gate membar_enter(); 247*7c478bd9Sstevel@tonic-gate 248*7c478bd9Sstevel@tonic-gate if (ddi_create_minor_node(devi, "systrace", S_IFCHR, 0, 249*7c478bd9Sstevel@tonic-gate DDI_PSEUDO, NULL) == DDI_FAILURE || 250*7c478bd9Sstevel@tonic-gate dtrace_register("syscall", &systrace_attr, DTRACE_PRIV_USER, 0, 251*7c478bd9Sstevel@tonic-gate &systrace_pops, NULL, &systrace_id) != 0) { 252*7c478bd9Sstevel@tonic-gate systrace_probe = systrace_stub; 253*7c478bd9Sstevel@tonic-gate ddi_remove_minor_node(devi, NULL); 254*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 255*7c478bd9Sstevel@tonic-gate } 256*7c478bd9Sstevel@tonic-gate 257*7c478bd9Sstevel@tonic-gate ddi_report_dev(devi); 258*7c478bd9Sstevel@tonic-gate systrace_devi = devi; 259*7c478bd9Sstevel@tonic-gate 260*7c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 261*7c478bd9Sstevel@tonic-gate } 262*7c478bd9Sstevel@tonic-gate 263*7c478bd9Sstevel@tonic-gate static int 264*7c478bd9Sstevel@tonic-gate systrace_detach(dev_info_t *devi, ddi_detach_cmd_t cmd) 265*7c478bd9Sstevel@tonic-gate { 266*7c478bd9Sstevel@tonic-gate switch (cmd) { 267*7c478bd9Sstevel@tonic-gate case DDI_DETACH: 268*7c478bd9Sstevel@tonic-gate break; 269*7c478bd9Sstevel@tonic-gate case DDI_SUSPEND: 270*7c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 271*7c478bd9Sstevel@tonic-gate default: 272*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 273*7c478bd9Sstevel@tonic-gate } 274*7c478bd9Sstevel@tonic-gate 275*7c478bd9Sstevel@tonic-gate if (dtrace_unregister(systrace_id) != 0) 276*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 277*7c478bd9Sstevel@tonic-gate 278*7c478bd9Sstevel@tonic-gate ddi_remove_minor_node(devi, NULL); 279*7c478bd9Sstevel@tonic-gate systrace_probe = systrace_stub; 280*7c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 281*7c478bd9Sstevel@tonic-gate } 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 284*7c478bd9Sstevel@tonic-gate static int 285*7c478bd9Sstevel@tonic-gate systrace_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) 286*7c478bd9Sstevel@tonic-gate { 287*7c478bd9Sstevel@tonic-gate int error; 288*7c478bd9Sstevel@tonic-gate 289*7c478bd9Sstevel@tonic-gate switch (infocmd) { 290*7c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2DEVINFO: 291*7c478bd9Sstevel@tonic-gate *result = (void *)systrace_devi; 292*7c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 293*7c478bd9Sstevel@tonic-gate break; 294*7c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2INSTANCE: 295*7c478bd9Sstevel@tonic-gate *result = (void *)0; 296*7c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 297*7c478bd9Sstevel@tonic-gate break; 298*7c478bd9Sstevel@tonic-gate default: 299*7c478bd9Sstevel@tonic-gate error = DDI_FAILURE; 300*7c478bd9Sstevel@tonic-gate } 301*7c478bd9Sstevel@tonic-gate return (error); 302*7c478bd9Sstevel@tonic-gate } 303*7c478bd9Sstevel@tonic-gate 304*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 305*7c478bd9Sstevel@tonic-gate static int 306*7c478bd9Sstevel@tonic-gate systrace_open(dev_t *devp, int flag, int otyp, cred_t *cred_p) 307*7c478bd9Sstevel@tonic-gate { 308*7c478bd9Sstevel@tonic-gate return (0); 309*7c478bd9Sstevel@tonic-gate } 310*7c478bd9Sstevel@tonic-gate 311*7c478bd9Sstevel@tonic-gate static struct cb_ops systrace_cb_ops = { 312*7c478bd9Sstevel@tonic-gate systrace_open, /* open */ 313*7c478bd9Sstevel@tonic-gate nodev, /* close */ 314*7c478bd9Sstevel@tonic-gate nulldev, /* strategy */ 315*7c478bd9Sstevel@tonic-gate nulldev, /* print */ 316*7c478bd9Sstevel@tonic-gate nodev, /* dump */ 317*7c478bd9Sstevel@tonic-gate nodev, /* read */ 318*7c478bd9Sstevel@tonic-gate nodev, /* write */ 319*7c478bd9Sstevel@tonic-gate nodev, /* ioctl */ 320*7c478bd9Sstevel@tonic-gate nodev, /* devmap */ 321*7c478bd9Sstevel@tonic-gate nodev, /* mmap */ 322*7c478bd9Sstevel@tonic-gate nodev, /* segmap */ 323*7c478bd9Sstevel@tonic-gate nochpoll, /* poll */ 324*7c478bd9Sstevel@tonic-gate ddi_prop_op, /* cb_prop_op */ 325*7c478bd9Sstevel@tonic-gate 0, /* streamtab */ 326*7c478bd9Sstevel@tonic-gate D_NEW | D_MP /* Driver compatibility flag */ 327*7c478bd9Sstevel@tonic-gate }; 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate static struct dev_ops systrace_ops = { 330*7c478bd9Sstevel@tonic-gate DEVO_REV, /* devo_rev, */ 331*7c478bd9Sstevel@tonic-gate 0, /* refcnt */ 332*7c478bd9Sstevel@tonic-gate systrace_info, /* get_dev_info */ 333*7c478bd9Sstevel@tonic-gate nulldev, /* identify */ 334*7c478bd9Sstevel@tonic-gate nulldev, /* probe */ 335*7c478bd9Sstevel@tonic-gate systrace_attach, /* attach */ 336*7c478bd9Sstevel@tonic-gate systrace_detach, /* detach */ 337*7c478bd9Sstevel@tonic-gate nodev, /* reset */ 338*7c478bd9Sstevel@tonic-gate &systrace_cb_ops, /* driver operations */ 339*7c478bd9Sstevel@tonic-gate NULL, /* bus operations */ 340*7c478bd9Sstevel@tonic-gate nodev /* dev power */ 341*7c478bd9Sstevel@tonic-gate }; 342*7c478bd9Sstevel@tonic-gate 343*7c478bd9Sstevel@tonic-gate /* 344*7c478bd9Sstevel@tonic-gate * Module linkage information for the kernel. 345*7c478bd9Sstevel@tonic-gate */ 346*7c478bd9Sstevel@tonic-gate static struct modldrv modldrv = { 347*7c478bd9Sstevel@tonic-gate &mod_driverops, /* module type (this is a pseudo driver) */ 348*7c478bd9Sstevel@tonic-gate "System Call Tracing", /* name of module */ 349*7c478bd9Sstevel@tonic-gate &systrace_ops, /* driver ops */ 350*7c478bd9Sstevel@tonic-gate }; 351*7c478bd9Sstevel@tonic-gate 352*7c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = { 353*7c478bd9Sstevel@tonic-gate MODREV_1, 354*7c478bd9Sstevel@tonic-gate (void *)&modldrv, 355*7c478bd9Sstevel@tonic-gate NULL 356*7c478bd9Sstevel@tonic-gate }; 357*7c478bd9Sstevel@tonic-gate 358*7c478bd9Sstevel@tonic-gate int 359*7c478bd9Sstevel@tonic-gate _init(void) 360*7c478bd9Sstevel@tonic-gate { 361*7c478bd9Sstevel@tonic-gate return (mod_install(&modlinkage)); 362*7c478bd9Sstevel@tonic-gate } 363*7c478bd9Sstevel@tonic-gate 364*7c478bd9Sstevel@tonic-gate int 365*7c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop) 366*7c478bd9Sstevel@tonic-gate { 367*7c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 368*7c478bd9Sstevel@tonic-gate } 369*7c478bd9Sstevel@tonic-gate 370*7c478bd9Sstevel@tonic-gate int 371*7c478bd9Sstevel@tonic-gate _fini(void) 372*7c478bd9Sstevel@tonic-gate { 373*7c478bd9Sstevel@tonic-gate return (mod_remove(&modlinkage)); 374*7c478bd9Sstevel@tonic-gate } 375