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 5*1677Sdp * Common Development and Distribution License (the "License"). 6*1677Sdp * 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*1677Sdp * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <sys/modctl.h> 290Sstevel@tonic-gate #include <sys/sunddi.h> 300Sstevel@tonic-gate #include <sys/dtrace.h> 310Sstevel@tonic-gate #include <sys/kobj.h> 320Sstevel@tonic-gate #include <sys/stat.h> 330Sstevel@tonic-gate #include <sys/conf.h> 340Sstevel@tonic-gate #include <vm/seg_kmem.h> 350Sstevel@tonic-gate #include <sys/stack.h> 360Sstevel@tonic-gate #include <sys/sdt_impl.h> 370Sstevel@tonic-gate 380Sstevel@tonic-gate #define SDT_PATCHVAL 0xf0 390Sstevel@tonic-gate #define SDT_ADDR2NDX(addr) ((((uintptr_t)(addr)) >> 4) & sdt_probetab_mask) 400Sstevel@tonic-gate #define SDT_PROBETAB_SIZE 0x1000 /* 4k entries -- 16K total */ 410Sstevel@tonic-gate 420Sstevel@tonic-gate static dev_info_t *sdt_devi; 430Sstevel@tonic-gate static int sdt_verbose = 0; 440Sstevel@tonic-gate static sdt_probe_t **sdt_probetab; 450Sstevel@tonic-gate static int sdt_probetab_size; 460Sstevel@tonic-gate static int sdt_probetab_mask; 470Sstevel@tonic-gate 480Sstevel@tonic-gate /*ARGSUSED*/ 490Sstevel@tonic-gate static int 500Sstevel@tonic-gate sdt_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax) 510Sstevel@tonic-gate { 520Sstevel@tonic-gate uintptr_t stack0, stack1, stack2, stack3, stack4; 530Sstevel@tonic-gate int i = 0; 540Sstevel@tonic-gate sdt_probe_t *sdt = sdt_probetab[SDT_ADDR2NDX(addr)]; 550Sstevel@tonic-gate 560Sstevel@tonic-gate #ifdef __amd64 570Sstevel@tonic-gate /* 580Sstevel@tonic-gate * On amd64, stack[0] contains the dereferenced stack pointer, 590Sstevel@tonic-gate * stack[1] contains savfp, stack[2] contains savpc. We want 600Sstevel@tonic-gate * to step over these entries. 610Sstevel@tonic-gate */ 620Sstevel@tonic-gate i += 3; 630Sstevel@tonic-gate #endif 640Sstevel@tonic-gate 650Sstevel@tonic-gate for (; sdt != NULL; sdt = sdt->sdp_hashnext) { 660Sstevel@tonic-gate if ((uintptr_t)sdt->sdp_patchpoint == addr) { 670Sstevel@tonic-gate /* 680Sstevel@tonic-gate * When accessing the arguments on the stack, we must 690Sstevel@tonic-gate * protect against accessing beyond the stack. We can 700Sstevel@tonic-gate * safely set NOFAULT here -- we know that interrupts 710Sstevel@tonic-gate * are already disabled. 720Sstevel@tonic-gate */ 730Sstevel@tonic-gate DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT); 740Sstevel@tonic-gate stack0 = stack[i++]; 750Sstevel@tonic-gate stack1 = stack[i++]; 760Sstevel@tonic-gate stack2 = stack[i++]; 770Sstevel@tonic-gate stack3 = stack[i++]; 780Sstevel@tonic-gate stack4 = stack[i++]; 790Sstevel@tonic-gate DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT | 800Sstevel@tonic-gate CPU_DTRACE_BADADDR); 810Sstevel@tonic-gate 820Sstevel@tonic-gate dtrace_probe(sdt->sdp_id, stack0, stack1, 830Sstevel@tonic-gate stack2, stack3, stack4); 840Sstevel@tonic-gate 850Sstevel@tonic-gate return (DTRACE_INVOP_NOP); 860Sstevel@tonic-gate } 870Sstevel@tonic-gate } 880Sstevel@tonic-gate 890Sstevel@tonic-gate return (0); 900Sstevel@tonic-gate } 910Sstevel@tonic-gate 920Sstevel@tonic-gate /*ARGSUSED*/ 930Sstevel@tonic-gate static void 940Sstevel@tonic-gate sdt_provide_module(void *arg, struct modctl *ctl) 950Sstevel@tonic-gate { 960Sstevel@tonic-gate struct module *mp = ctl->mod_mp; 970Sstevel@tonic-gate char *modname = ctl->mod_modname; 980Sstevel@tonic-gate sdt_probedesc_t *sdpd; 990Sstevel@tonic-gate sdt_probe_t *sdp, *old; 1000Sstevel@tonic-gate sdt_provider_t *prov; 1010Sstevel@tonic-gate int len; 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate /* 1040Sstevel@tonic-gate * One for all, and all for one: if we haven't yet registered all of 1050Sstevel@tonic-gate * our providers, we'll refuse to provide anything. 1060Sstevel@tonic-gate */ 1070Sstevel@tonic-gate for (prov = sdt_providers; prov->sdtp_name != NULL; prov++) { 1080Sstevel@tonic-gate if (prov->sdtp_id == DTRACE_PROVNONE) 1090Sstevel@tonic-gate return; 1100Sstevel@tonic-gate } 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate if (mp->sdt_nprobes != 0 || (sdpd = mp->sdt_probes) == NULL) 1130Sstevel@tonic-gate return; 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate for (sdpd = mp->sdt_probes; sdpd != NULL; sdpd = sdpd->sdpd_next) { 1160Sstevel@tonic-gate char *name = sdpd->sdpd_name, *func, *nname; 1170Sstevel@tonic-gate int i, j; 1180Sstevel@tonic-gate sdt_provider_t *prov; 1190Sstevel@tonic-gate ulong_t offs; 1200Sstevel@tonic-gate dtrace_id_t id; 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate for (prov = sdt_providers; prov->sdtp_prefix != NULL; prov++) { 1230Sstevel@tonic-gate char *prefix = prov->sdtp_prefix; 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate if (strncmp(name, prefix, strlen(prefix)) == 0) { 1260Sstevel@tonic-gate name += strlen(prefix); 1270Sstevel@tonic-gate break; 1280Sstevel@tonic-gate } 1290Sstevel@tonic-gate } 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate nname = kmem_alloc(len = strlen(name) + 1, KM_SLEEP); 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate for (i = 0, j = 0; name[j] != '\0'; i++) { 1340Sstevel@tonic-gate if (name[j] == '_' && name[j + 1] == '_') { 1350Sstevel@tonic-gate nname[i] = '-'; 1360Sstevel@tonic-gate j += 2; 1370Sstevel@tonic-gate } else { 1380Sstevel@tonic-gate nname[i] = name[j++]; 1390Sstevel@tonic-gate } 1400Sstevel@tonic-gate } 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate nname[i] = '\0'; 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate sdp = kmem_zalloc(sizeof (sdt_probe_t), KM_SLEEP); 1450Sstevel@tonic-gate sdp->sdp_loadcnt = ctl->mod_loadcnt; 1460Sstevel@tonic-gate sdp->sdp_ctl = ctl; 1470Sstevel@tonic-gate sdp->sdp_name = nname; 1480Sstevel@tonic-gate sdp->sdp_namelen = len; 1490Sstevel@tonic-gate sdp->sdp_provider = prov; 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate func = kobj_searchsym(mp, sdpd->sdpd_offset, &offs); 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate if (func == NULL) 1540Sstevel@tonic-gate func = "<unknown>"; 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate /* 1570Sstevel@tonic-gate * We have our provider. Now create the probe. 1580Sstevel@tonic-gate */ 1590Sstevel@tonic-gate if ((id = dtrace_probe_lookup(prov->sdtp_id, modname, 1600Sstevel@tonic-gate func, nname)) != DTRACE_IDNONE) { 1610Sstevel@tonic-gate old = dtrace_probe_arg(prov->sdtp_id, id); 1620Sstevel@tonic-gate ASSERT(old != NULL); 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate sdp->sdp_next = old->sdp_next; 1650Sstevel@tonic-gate sdp->sdp_id = id; 1660Sstevel@tonic-gate old->sdp_next = sdp; 1670Sstevel@tonic-gate } else { 1680Sstevel@tonic-gate sdp->sdp_id = dtrace_probe_create(prov->sdtp_id, 1690Sstevel@tonic-gate modname, func, nname, 3, sdp); 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate mp->sdt_nprobes++; 1720Sstevel@tonic-gate } 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate sdp->sdp_hashnext = 1750Sstevel@tonic-gate sdt_probetab[SDT_ADDR2NDX(sdpd->sdpd_offset)]; 1760Sstevel@tonic-gate sdt_probetab[SDT_ADDR2NDX(sdpd->sdpd_offset)] = sdp; 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate sdp->sdp_patchval = SDT_PATCHVAL; 1790Sstevel@tonic-gate sdp->sdp_patchpoint = (uint8_t *)sdpd->sdpd_offset; 1800Sstevel@tonic-gate sdp->sdp_savedval = *sdp->sdp_patchpoint; 1810Sstevel@tonic-gate } 1820Sstevel@tonic-gate } 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate /*ARGSUSED*/ 1850Sstevel@tonic-gate static void 1860Sstevel@tonic-gate sdt_destroy(void *arg, dtrace_id_t id, void *parg) 1870Sstevel@tonic-gate { 1880Sstevel@tonic-gate sdt_probe_t *sdp = parg, *old, *last, *hash; 1890Sstevel@tonic-gate struct modctl *ctl = sdp->sdp_ctl; 1900Sstevel@tonic-gate int ndx; 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate if (ctl != NULL && ctl->mod_loadcnt == sdp->sdp_loadcnt) { 1930Sstevel@tonic-gate if ((ctl->mod_loadcnt == sdp->sdp_loadcnt && 1940Sstevel@tonic-gate ctl->mod_loaded)) { 1950Sstevel@tonic-gate ((struct module *)(ctl->mod_mp))->sdt_nprobes--; 1960Sstevel@tonic-gate } 1970Sstevel@tonic-gate } 1980Sstevel@tonic-gate 1990Sstevel@tonic-gate while (sdp != NULL) { 2000Sstevel@tonic-gate old = sdp; 2010Sstevel@tonic-gate 2020Sstevel@tonic-gate /* 2030Sstevel@tonic-gate * Now we need to remove this probe from the sdt_probetab. 2040Sstevel@tonic-gate */ 2050Sstevel@tonic-gate ndx = SDT_ADDR2NDX(sdp->sdp_patchpoint); 2060Sstevel@tonic-gate last = NULL; 2070Sstevel@tonic-gate hash = sdt_probetab[ndx]; 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate while (hash != sdp) { 2100Sstevel@tonic-gate ASSERT(hash != NULL); 2110Sstevel@tonic-gate last = hash; 2120Sstevel@tonic-gate hash = hash->sdp_hashnext; 2130Sstevel@tonic-gate } 2140Sstevel@tonic-gate 2150Sstevel@tonic-gate if (last != NULL) { 2160Sstevel@tonic-gate last->sdp_hashnext = sdp->sdp_hashnext; 2170Sstevel@tonic-gate } else { 2180Sstevel@tonic-gate sdt_probetab[ndx] = sdp->sdp_hashnext; 2190Sstevel@tonic-gate } 2200Sstevel@tonic-gate 2210Sstevel@tonic-gate kmem_free(sdp->sdp_name, sdp->sdp_namelen); 2220Sstevel@tonic-gate sdp = sdp->sdp_next; 2230Sstevel@tonic-gate kmem_free(old, sizeof (sdt_probe_t)); 2240Sstevel@tonic-gate } 2250Sstevel@tonic-gate } 2260Sstevel@tonic-gate 2270Sstevel@tonic-gate /*ARGSUSED*/ 2280Sstevel@tonic-gate static void 2290Sstevel@tonic-gate sdt_enable(void *arg, dtrace_id_t id, void *parg) 2300Sstevel@tonic-gate { 2310Sstevel@tonic-gate sdt_probe_t *sdp = parg; 2320Sstevel@tonic-gate struct modctl *ctl = sdp->sdp_ctl; 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate ctl->mod_nenabled++; 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate /* 2370Sstevel@tonic-gate * If this module has disappeared since we discovered its probes, 2380Sstevel@tonic-gate * refuse to enable it. 2390Sstevel@tonic-gate */ 2400Sstevel@tonic-gate if (!ctl->mod_loaded) { 2410Sstevel@tonic-gate if (sdt_verbose) { 2420Sstevel@tonic-gate cmn_err(CE_NOTE, "sdt is failing for probe %s " 2430Sstevel@tonic-gate "(module %s unloaded)", 2440Sstevel@tonic-gate sdp->sdp_name, ctl->mod_modname); 2450Sstevel@tonic-gate } 2460Sstevel@tonic-gate goto err; 2470Sstevel@tonic-gate } 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate /* 2500Sstevel@tonic-gate * Now check that our modctl has the expected load count. If it 2510Sstevel@tonic-gate * doesn't, this module must have been unloaded and reloaded -- and 2520Sstevel@tonic-gate * we're not going to touch it. 2530Sstevel@tonic-gate */ 2540Sstevel@tonic-gate if (ctl->mod_loadcnt != sdp->sdp_loadcnt) { 2550Sstevel@tonic-gate if (sdt_verbose) { 2560Sstevel@tonic-gate cmn_err(CE_NOTE, "sdt is failing for probe %s " 2570Sstevel@tonic-gate "(module %s reloaded)", 2580Sstevel@tonic-gate sdp->sdp_name, ctl->mod_modname); 2590Sstevel@tonic-gate } 2600Sstevel@tonic-gate goto err; 2610Sstevel@tonic-gate } 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate while (sdp != NULL) { 2640Sstevel@tonic-gate *sdp->sdp_patchpoint = sdp->sdp_patchval; 2650Sstevel@tonic-gate sdp = sdp->sdp_next; 2660Sstevel@tonic-gate } 2670Sstevel@tonic-gate err: 2680Sstevel@tonic-gate ; 2690Sstevel@tonic-gate } 2700Sstevel@tonic-gate 2710Sstevel@tonic-gate /*ARGSUSED*/ 2720Sstevel@tonic-gate static void 2730Sstevel@tonic-gate sdt_disable(void *arg, dtrace_id_t id, void *parg) 2740Sstevel@tonic-gate { 2750Sstevel@tonic-gate sdt_probe_t *sdp = parg; 2760Sstevel@tonic-gate struct modctl *ctl = sdp->sdp_ctl; 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate ctl->mod_nenabled--; 2790Sstevel@tonic-gate 2800Sstevel@tonic-gate if (!ctl->mod_loaded || ctl->mod_loadcnt != sdp->sdp_loadcnt) 2810Sstevel@tonic-gate goto err; 2820Sstevel@tonic-gate 2830Sstevel@tonic-gate while (sdp != NULL) { 2840Sstevel@tonic-gate *sdp->sdp_patchpoint = sdp->sdp_savedval; 2850Sstevel@tonic-gate sdp = sdp->sdp_next; 2860Sstevel@tonic-gate } 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate err: 2890Sstevel@tonic-gate ; 2900Sstevel@tonic-gate } 2910Sstevel@tonic-gate 2920Sstevel@tonic-gate static dtrace_pops_t sdt_pops = { 2930Sstevel@tonic-gate NULL, 2940Sstevel@tonic-gate sdt_provide_module, 2950Sstevel@tonic-gate sdt_enable, 2960Sstevel@tonic-gate sdt_disable, 2970Sstevel@tonic-gate NULL, 2980Sstevel@tonic-gate NULL, 2990Sstevel@tonic-gate sdt_getargdesc, 3000Sstevel@tonic-gate NULL, 3010Sstevel@tonic-gate NULL, 3020Sstevel@tonic-gate sdt_destroy 3030Sstevel@tonic-gate }; 3040Sstevel@tonic-gate 3050Sstevel@tonic-gate /*ARGSUSED*/ 3060Sstevel@tonic-gate static int 3070Sstevel@tonic-gate sdt_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) 3080Sstevel@tonic-gate { 3090Sstevel@tonic-gate sdt_provider_t *prov; 3100Sstevel@tonic-gate 3110Sstevel@tonic-gate if (ddi_create_minor_node(devi, "sdt", S_IFCHR, 3120Sstevel@tonic-gate 0, DDI_PSEUDO, NULL) == DDI_FAILURE) { 3130Sstevel@tonic-gate cmn_err(CE_NOTE, "/dev/sdt couldn't create minor node"); 3140Sstevel@tonic-gate ddi_remove_minor_node(devi, NULL); 3150Sstevel@tonic-gate return (DDI_FAILURE); 3160Sstevel@tonic-gate } 3170Sstevel@tonic-gate 3180Sstevel@tonic-gate ddi_report_dev(devi); 3190Sstevel@tonic-gate sdt_devi = devi; 3200Sstevel@tonic-gate 3210Sstevel@tonic-gate if (sdt_probetab_size == 0) 3220Sstevel@tonic-gate sdt_probetab_size = SDT_PROBETAB_SIZE; 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate sdt_probetab_mask = sdt_probetab_size - 1; 3250Sstevel@tonic-gate sdt_probetab = 3260Sstevel@tonic-gate kmem_zalloc(sdt_probetab_size * sizeof (sdt_probe_t *), KM_SLEEP); 3270Sstevel@tonic-gate dtrace_invop_add(sdt_invop); 3280Sstevel@tonic-gate 3290Sstevel@tonic-gate for (prov = sdt_providers; prov->sdtp_name != NULL; prov++) { 3300Sstevel@tonic-gate if (dtrace_register(prov->sdtp_name, prov->sdtp_attr, 331*1677Sdp DTRACE_PRIV_KERNEL, NULL, 3320Sstevel@tonic-gate &sdt_pops, prov, &prov->sdtp_id) != 0) { 3330Sstevel@tonic-gate cmn_err(CE_WARN, "failed to register sdt provider %s", 3340Sstevel@tonic-gate prov->sdtp_name); 3350Sstevel@tonic-gate } 3360Sstevel@tonic-gate } 3370Sstevel@tonic-gate 3380Sstevel@tonic-gate return (DDI_SUCCESS); 3390Sstevel@tonic-gate } 3400Sstevel@tonic-gate 3410Sstevel@tonic-gate /*ARGSUSED*/ 3420Sstevel@tonic-gate static int 3430Sstevel@tonic-gate sdt_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) 3440Sstevel@tonic-gate { 3450Sstevel@tonic-gate sdt_provider_t *prov; 3460Sstevel@tonic-gate 3470Sstevel@tonic-gate switch (cmd) { 3480Sstevel@tonic-gate case DDI_DETACH: 3490Sstevel@tonic-gate break; 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate case DDI_SUSPEND: 3520Sstevel@tonic-gate return (DDI_SUCCESS); 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate default: 3550Sstevel@tonic-gate return (DDI_FAILURE); 3560Sstevel@tonic-gate } 3570Sstevel@tonic-gate 3580Sstevel@tonic-gate for (prov = sdt_providers; prov->sdtp_name != NULL; prov++) { 3590Sstevel@tonic-gate if (prov->sdtp_id != DTRACE_PROVNONE) { 3600Sstevel@tonic-gate if (dtrace_unregister(prov->sdtp_id) != 0) 3610Sstevel@tonic-gate return (DDI_FAILURE); 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate prov->sdtp_id = DTRACE_PROVNONE; 3640Sstevel@tonic-gate } 3650Sstevel@tonic-gate } 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate dtrace_invop_remove(sdt_invop); 3680Sstevel@tonic-gate kmem_free(sdt_probetab, sdt_probetab_size * sizeof (sdt_probe_t *)); 3690Sstevel@tonic-gate 3700Sstevel@tonic-gate return (DDI_SUCCESS); 3710Sstevel@tonic-gate } 3720Sstevel@tonic-gate 3730Sstevel@tonic-gate /*ARGSUSED*/ 3740Sstevel@tonic-gate static int 3750Sstevel@tonic-gate sdt_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) 3760Sstevel@tonic-gate { 3770Sstevel@tonic-gate int error; 3780Sstevel@tonic-gate 3790Sstevel@tonic-gate switch (infocmd) { 3800Sstevel@tonic-gate case DDI_INFO_DEVT2DEVINFO: 3810Sstevel@tonic-gate *result = (void *)sdt_devi; 3820Sstevel@tonic-gate error = DDI_SUCCESS; 3830Sstevel@tonic-gate break; 3840Sstevel@tonic-gate case DDI_INFO_DEVT2INSTANCE: 3850Sstevel@tonic-gate *result = (void *)0; 3860Sstevel@tonic-gate error = DDI_SUCCESS; 3870Sstevel@tonic-gate break; 3880Sstevel@tonic-gate default: 3890Sstevel@tonic-gate error = DDI_FAILURE; 3900Sstevel@tonic-gate } 3910Sstevel@tonic-gate return (error); 3920Sstevel@tonic-gate } 3930Sstevel@tonic-gate 3940Sstevel@tonic-gate /*ARGSUSED*/ 3950Sstevel@tonic-gate static int 3960Sstevel@tonic-gate sdt_open(dev_t *devp, int flag, int otyp, cred_t *cred_p) 3970Sstevel@tonic-gate { 3980Sstevel@tonic-gate return (0); 3990Sstevel@tonic-gate } 4000Sstevel@tonic-gate 4010Sstevel@tonic-gate static struct cb_ops sdt_cb_ops = { 4020Sstevel@tonic-gate sdt_open, /* open */ 4030Sstevel@tonic-gate nodev, /* close */ 4040Sstevel@tonic-gate nulldev, /* strategy */ 4050Sstevel@tonic-gate nulldev, /* print */ 4060Sstevel@tonic-gate nodev, /* dump */ 4070Sstevel@tonic-gate nodev, /* read */ 4080Sstevel@tonic-gate nodev, /* write */ 4090Sstevel@tonic-gate nodev, /* ioctl */ 4100Sstevel@tonic-gate nodev, /* devmap */ 4110Sstevel@tonic-gate nodev, /* mmap */ 4120Sstevel@tonic-gate nodev, /* segmap */ 4130Sstevel@tonic-gate nochpoll, /* poll */ 4140Sstevel@tonic-gate ddi_prop_op, /* cb_prop_op */ 4150Sstevel@tonic-gate 0, /* streamtab */ 4160Sstevel@tonic-gate D_NEW | D_MP /* Driver compatibility flag */ 4170Sstevel@tonic-gate }; 4180Sstevel@tonic-gate 4190Sstevel@tonic-gate static struct dev_ops sdt_ops = { 4200Sstevel@tonic-gate DEVO_REV, /* devo_rev, */ 4210Sstevel@tonic-gate 0, /* refcnt */ 4220Sstevel@tonic-gate sdt_info, /* get_dev_info */ 4230Sstevel@tonic-gate nulldev, /* identify */ 4240Sstevel@tonic-gate nulldev, /* probe */ 4250Sstevel@tonic-gate sdt_attach, /* attach */ 4260Sstevel@tonic-gate sdt_detach, /* detach */ 4270Sstevel@tonic-gate nodev, /* reset */ 4280Sstevel@tonic-gate &sdt_cb_ops, /* driver operations */ 4290Sstevel@tonic-gate NULL, /* bus operations */ 4300Sstevel@tonic-gate nodev /* dev power */ 4310Sstevel@tonic-gate }; 4320Sstevel@tonic-gate 4330Sstevel@tonic-gate /* 4340Sstevel@tonic-gate * Module linkage information for the kernel. 4350Sstevel@tonic-gate */ 4360Sstevel@tonic-gate static struct modldrv modldrv = { 4370Sstevel@tonic-gate &mod_driverops, /* module type (this is a pseudo driver) */ 4380Sstevel@tonic-gate "Statically Defined Tracing", /* name of module */ 4390Sstevel@tonic-gate &sdt_ops, /* driver ops */ 4400Sstevel@tonic-gate }; 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate static struct modlinkage modlinkage = { 4430Sstevel@tonic-gate MODREV_1, 4440Sstevel@tonic-gate (void *)&modldrv, 4450Sstevel@tonic-gate NULL 4460Sstevel@tonic-gate }; 4470Sstevel@tonic-gate 4480Sstevel@tonic-gate int 4490Sstevel@tonic-gate _init(void) 4500Sstevel@tonic-gate { 4510Sstevel@tonic-gate return (mod_install(&modlinkage)); 4520Sstevel@tonic-gate } 4530Sstevel@tonic-gate 4540Sstevel@tonic-gate int 4550Sstevel@tonic-gate _info(struct modinfo *modinfop) 4560Sstevel@tonic-gate { 4570Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 4580Sstevel@tonic-gate } 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate int 4610Sstevel@tonic-gate _fini(void) 4620Sstevel@tonic-gate { 4630Sstevel@tonic-gate return (mod_remove(&modlinkage)); 4640Sstevel@tonic-gate } 465