Esempio n. 1
0
void
linux_sysctl_fini(void)
{

	sysctl_teardown(&linux_clog2);
	sysctl_teardown(&linux_clog1);
	sysctl_free(&linux_sysctl_root);
}
Esempio n. 2
0
static int
npf_fini(void)
{
	/* At first, detach device and remove pfil hooks. */
#ifdef _MODULE
	devsw_detach(NULL, &npf_cdevsw);
#endif
	npf_pfil_unregister(true);

	/* Flush all sessions, destroy configuration (ruleset, etc). */
	npf_session_tracking(false);
	npf_config_fini();

	/* Finally, safe to destroy the subsystems. */
	npf_ext_sysfini();
	npf_alg_sysfini();
	npf_nat_sysfini();
	npf_session_sysfini();
	npf_tableset_sysfini();
	npf_bpf_sysfini();

	/* Note: worker is the last. */
	npf_worker_sysfini();

	if (npf_sysctl) {
		sysctl_teardown(&npf_sysctl);
	}
	percpu_free(npf_stats_percpu, NPF_STATS_SIZE);

	return 0;
}
Esempio n. 3
0
static int
spdmem_modcmd(modcmd_t cmd, void *opaque)
{
	int error = 0;
#ifdef _MODULE
	static struct sysctllog *spdmem_sysctl_clog;
#endif

	switch (cmd) {
	case MODULE_CMD_INIT:
#ifdef _MODULE
		error = config_init_component(cfdriver_ioconf_spdmem,
		    cfattach_ioconf_spdmem, cfdata_ioconf_spdmem);
#endif
		return error;
	case MODULE_CMD_FINI:
#ifdef _MODULE
		error = config_fini_component(cfdriver_ioconf_spdmem,
		    cfattach_ioconf_spdmem, cfdata_ioconf_spdmem);
		sysctl_teardown(&spdmem_sysctl_clog);
#endif
		return error;
	default:
		return ENOTTY;
	}
}
Esempio n. 4
0
static int
union_modcmd(modcmd_t cmd, void *arg)
{
	int error;

	switch (cmd) {
	case MODULE_CMD_INIT:
		error = vfs_attach(&union_vfsops);
		if (error != 0)
			break;
		sysctl_createv(&union_sysctl_log, 0, NULL, NULL,
			       CTLFLAG_PERMANENT,
			       CTLTYPE_NODE, "union",
			       SYSCTL_DESCR("Union file system"),
			       NULL, 0, NULL, 0,
			       CTL_VFS, 15, CTL_EOL);
		/*
		 * XXX the "15" above could be dynamic, thereby eliminating
		 * one more instance of the "number to vfs" mapping problem,
		 * but "15" is the order as taken from sys/mount.h
		 */
		break;
	case MODULE_CMD_FINI:
		error = vfs_detach(&union_vfsops);
		if (error != 0)
			break;
		sysctl_teardown(&union_sysctl_log);
		break;
	default:
		error = ENOTTY;
		break;
	}

	return (error);
}
int
spdmem_common_detach(struct spdmem_softc *sc, device_t self)
{
	sysctl_teardown(&sc->sc_sysctl_log);

	return 0;
}
Esempio n. 6
0
static int
wmi_hp_detach(device_t self, int flags)
{
	struct wmi_hp_softc *sc = device_private(self);
	device_t parent = sc->sc_parent;

	(void)acpi_wmi_event_deregister(parent);

	if (sc->sc_sme != NULL)
		sysmon_envsys_unregister(sc->sc_sme);

	if (sc->sc_sensor != NULL)
		kmem_free(sc->sc_sensor, WMI_HP_SENSOR_SIZE);

	if (sc->sc_arg != NULL)
		kmem_free(sc->sc_arg, WMI_HP_METHOD_ARG_SIZE);

	pmf_device_deregister(self);

	if (wmihp_sysctllog != NULL)
		sysctl_teardown(&wmihp_sysctllog);
	wmihp_sysctllog = NULL;
	wmi_hp_sc = NULL;

	return 0;
}
Esempio n. 7
0
static int
auich_detach(device_t self, int flags)
{
	struct auich_softc *sc = device_private(self);

	/* audio */
	if (sc->sc_audiodev != NULL)
		config_detach(sc->sc_audiodev, flags);

	/* sysctl */
	sysctl_teardown(&sc->sc_log);

	mutex_enter(&sc->sc_lock);

	/* audio_encoding_set */
	auconv_delete_encodings(sc->sc_encodings);
	auconv_delete_encodings(sc->sc_spdif_encodings);

	/* ac97 */
	if (sc->codec_if != NULL)
		sc->codec_if->vtbl->detach(sc->codec_if);

	mutex_exit(&sc->sc_lock);
	mutex_destroy(&sc->sc_lock);
	mutex_destroy(&sc->sc_intr_lock);

	/* PCI */
	if (sc->sc_ih != NULL)
		pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
	if (sc->mix_size != 0)
		bus_space_unmap(sc->iot, sc->mix_ioh, sc->mix_size);
	if (sc->aud_size != 0)
		bus_space_unmap(sc->iot, sc->aud_ioh, sc->aud_size);
	return 0;
}
Esempio n. 8
0
static int
overlay_modcmd(modcmd_t cmd, void *arg)
{
	int error;

	switch (cmd) {
	case MODULE_CMD_INIT:
		error = vfs_attach(&overlay_vfsops);
		if (error != 0)
			break;
		sysctl_createv(&overlay_sysctl_log, 0, NULL, NULL,
			       CTLFLAG_PERMANENT, CTLTYPE_NODE, "overlay",
			       SYSCTL_DESCR("Overlay file system"),
			       NULL, 0, NULL, 0,
			       CTL_VFS, CTL_CREATE, CTL_EOL);
		break;
	case MODULE_CMD_FINI:
		error = vfs_detach(&overlay_vfsops);
		if (error != 0)
			break;
		sysctl_teardown(&overlay_sysctl_log);
		break;
	default:
		error = ENOTTY;
		break;
	}

	return (error);
}
Esempio n. 9
0
static int
vmt_detach(device_t self, int flags)
{
	struct vmt_softc *sc = device_private(self);

	if (sc->sc_tclo_rpc_open)
		vm_rpc_close(&sc->sc_tclo_rpc);

	if (sc->sc_smpsw_valid) {
		sysmon_pswitch_unregister(&sc->sc_ev_sleep.ev_smpsw);
		sysmon_pswitch_unregister(&sc->sc_ev_reset.ev_smpsw);
		sysmon_pswitch_unregister(&sc->sc_ev_power.ev_smpsw);
	}

	callout_halt(&sc->sc_tick, NULL);
	callout_destroy(&sc->sc_tick);

	callout_halt(&sc->sc_tclo_tick, NULL);
	callout_destroy(&sc->sc_tclo_tick);

	callout_halt(&sc->sc_clock_sync_tick, NULL);
	callout_destroy(&sc->sc_clock_sync_tick);

	if (sc->sc_rpc_buf)
		kmem_free(sc->sc_rpc_buf, VMT_RPC_BUFLEN);

	if (sc->sc_log) {
		sysctl_teardown(&sc->sc_log);
		sc->sc_log = NULL;
	}

	return 0;
}
Esempio n. 10
0
void
netbsd32_sysctl_fini(void)
{

	sysctl_teardown(&netbsd32_clog);
	sysctl_free(&netbsd32_sysctl_root);
}
Esempio n. 11
0
static int
apple_smc_fan_detach(device_t self, int flags)
{
	struct apple_smc_fan_softc *sc = device_private(self);

	/* If we registered with sysmon_envsys, unregister.  */
	if (sc->sc_sme != NULL) {
		sysmon_envsys_unregister(sc->sc_sme);
		sc->sc_sme = NULL;

		KASSERT(sc->sc_fans != NULL);
		KASSERT(sc->sc_nfans > 0);
		KASSERT(sc->sc_nfans < 10);

		/* Release the keys and free the memory for fan records. */
		apple_smc_fan_release_keys(sc);
		kmem_free(sc->sc_fans,
		    (sizeof(sc->sc_fans[0]) * sc->sc_nfans));
		sc->sc_fans = NULL;
		sc->sc_nfans = 0;
	}

#if 0				/* XXX sysctl */
	/* Tear down all the sysctl knobs we set up.  */
	sysctl_teardown(&sc->sc_sysctl_log);
#endif

	return 0;
}
Esempio n. 12
0
static int
vmt_sysctl_setup_root(device_t self)
{
	const struct sysctlnode *machdep_node, *vmt_node;
	struct vmt_softc *sc = device_private(self);
	int rv;

	rv = sysctl_createv(&sc->sc_log, 0, NULL, &machdep_node,
	    CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL,
	    NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL);
	if (rv != 0)
		goto fail;

	rv = sysctl_createv(&sc->sc_log, 0, &machdep_node, &vmt_node,
	    0, CTLTYPE_NODE, device_xname(self), NULL,
	    NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
	if (rv != 0)
		goto fail;

	rv = vmt_sysctl_setup_clock_sync(self, vmt_node);
	if (rv != 0)
		goto fail;

	return 0;

fail:
	sysctl_teardown(&sc->sc_log);
	sc->sc_log = NULL;

	return rv;
}
Esempio n. 13
0
void
ufsdirhash_done(void)
{

	KASSERT(TAILQ_EMPTY(&ufsdirhash_list));
	pool_cache_destroy(ufsdirhashblk_cache);
	pool_cache_destroy(ufsdirhash_cache);
	mutex_destroy(&ufsdirhash_lock);
	sysctl_teardown(&ufsdirhash_sysctl_log);
}
Esempio n. 14
0
static
int
swsensor_fini(void *arg)
{

	sysmon_envsys_unregister(swsensor_sme);

	sysctl_teardown(&swsensor_sysctllog);

	return 0;
}
Esempio n. 15
0
int
acpicpu_md_pstate_stop(void)
{

	if (acpicpu_log == NULL)
		return EALREADY;

	sysctl_teardown(&acpicpu_log);
	acpicpu_log = NULL;

	return 0;
}
Esempio n. 16
0
static int
smbfs_modcmd(modcmd_t cmd, void *arg)
{
	const struct sysctlnode *smb = NULL;
	int error;

	switch (cmd) {
	case MODULE_CMD_INIT:
		error = vfs_attach(&smbfs_vfsops);
		if (error != 0)
			break;
		sysctl_createv(&smbfs_sysctl_log, 0, NULL, NULL,
			       CTLFLAG_PERMANENT,
			       CTLTYPE_NODE, "vfs", NULL,
			       NULL, 0, NULL, 0,
			       CTL_VFS, CTL_EOL);
		sysctl_createv(&smbfs_sysctl_log, 0, NULL, &smb,
			       CTLFLAG_PERMANENT,
			       CTLTYPE_NODE, "samba",
			       SYSCTL_DESCR("SMB/CIFS remote file system"),
			       NULL, 0, NULL, 0,
			       CTL_VFS, CTL_CREATE, CTL_EOL);

		if (smb != NULL) {
			sysctl_createv(&smbfs_sysctl_log, 0, &smb, NULL,
				       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
				       CTLTYPE_INT, "version",
				       SYSCTL_DESCR("smbfs version"),
				       NULL, SMBFS_VERSION, NULL, 0,
				       CTL_CREATE, CTL_EOL);
		}
		break;
	case MODULE_CMD_FINI:
		error = vfs_detach(&smbfs_vfsops);
		if (error != 0)
			break;
		sysctl_teardown(&smbfs_sysctl_log);
		break;
	default:
		error = ENOTTY;
		break;
	}

	return (error);
}
static int
procfs_modcmd(modcmd_t cmd, void *arg)
{
	int error;

	switch (cmd) {
	case MODULE_CMD_INIT:
		error = vfs_attach(&procfs_vfsops);
		if (error != 0)
			break;
		sysctl_createv(&procfs_sysctl_log, 0, NULL, NULL,
			       CTLFLAG_PERMANENT,
			       CTLTYPE_NODE, "vfs", NULL,
			       NULL, 0, NULL, 0,
			       CTL_VFS, CTL_EOL);
		sysctl_createv(&procfs_sysctl_log, 0, NULL, NULL,
			       CTLFLAG_PERMANENT,
			       CTLTYPE_NODE, "procfs",
			       SYSCTL_DESCR("Process file system"),
			       NULL, 0, NULL, 0,
			       CTL_VFS, 12, CTL_EOL);
		/*
		 * XXX the "12" above could be dynamic, thereby eliminating
		 * one more instance of the "number to vfs" mapping problem,
		 * but "12" is the order as taken from sys/mount.h
		 */

		procfs_listener = kauth_listen_scope(KAUTH_SCOPE_PROCESS,
		    procfs_listener_cb, NULL);

		break;
	case MODULE_CMD_FINI:
		error = vfs_detach(&procfs_vfsops);
		if (error != 0)
			break;
		sysctl_teardown(&procfs_sysctl_log);
		kauth_unlisten_scope(procfs_listener);
		break;
	default:
		error = ENOTTY;
		break;
	}

	return (error);
}
Esempio n. 18
0
static int
acpicpu_once_detach(void)
{
	struct acpicpu_softc *sc;

	if (acpicpu_count != 0)
		return EDEADLK;

	cpufreq_deregister();

	if (acpicpu_log != NULL)
		sysctl_teardown(&acpicpu_log);

	if (acpicpu_sc != NULL)
		kmem_free(acpicpu_sc, maxcpus * sizeof(*sc));

	return 0;
}
Esempio n. 19
0
int
gpiopwm_detach(device_t self, int flags)
{
	struct gpiopwm_softc *sc = device_private(self);

	callout_halt(&sc->sc_pulse, NULL);
	callout_destroy(&sc->sc_pulse);
	gpio_pin_write(sc->sc_gpio, &sc->sc_map, 0, GPIO_PIN_LOW);

	pmf_device_deregister(self);
	gpio_pin_unmap(sc->sc_gpio, &sc->sc_map);

	if (sc->sc_log != NULL) {
		sysctl_teardown(&sc->sc_log);
		sc->sc_log = NULL;
	}
	return 0;
}
Esempio n. 20
0
static int
cd9660_modcmd(modcmd_t cmd, void *arg)
{
	int error;

	switch (cmd) {
	case MODULE_CMD_INIT:
		error = vfs_attach(&cd9660_vfsops);
		if (error != 0)
			break;
		sysctl_createv(&cd9660_sysctl_log, 0, NULL, NULL,
			       CTLFLAG_PERMANENT, CTLTYPE_NODE, "vfs", NULL,
			       NULL, 0, NULL, 0,
			       CTL_VFS, CTL_EOL);
		sysctl_createv(&cd9660_sysctl_log, 0, NULL, NULL,
			       CTLFLAG_PERMANENT, CTLTYPE_NODE, "cd9660",
			       SYSCTL_DESCR("ISO-9660 file system"),
			       NULL, 0, NULL, 0,
			       CTL_VFS, 14, CTL_EOL);
		sysctl_createv(&cd9660_sysctl_log, 0, NULL, NULL,
			       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
			       CTLTYPE_INT, "utf8_joliet",
			       SYSCTL_DESCR("Encode Joliet filenames to UTF-8"),
			       NULL, 0, &cd9660_utf8_joliet, 0,
			       CTL_VFS, 14, CD9660_UTF8_JOLIET, CTL_EOL);
		/*
		 * XXX the "14" above could be dynamic, thereby eliminating
		 * one more instance of the "number to vfs" mapping problem,
		 * but "14" is the order as taken from sys/mount.h
		 */
		break;
	case MODULE_CMD_FINI:
		error = vfs_detach(&cd9660_vfsops);
		if (error != 0)
			break;
		sysctl_teardown(&cd9660_sysctl_log);
		break;
	default:
		error = ENOTTY;
		break;
	}

	return (error);
}
Esempio n. 21
0
static int
secmodel_overlay_modcmd(modcmd_t cmd, void *arg)
{
	int error = 0;

	switch (cmd) {
	case MODULE_CMD_INIT:
		error = secmodel_register(&overlay_sm,
		    SECMODEL_OVERLAY_ID, SECMODEL_OVERLAY_NAME,
		    NULL, NULL, NULL);
		if (error != 0)
			printf("secmodel_overlay_modcmd::init: "
			    "secmodel_register returned %d\n", error);

		secmodel_overlay_init();
		secmodel_suser_stop();
		secmodel_securelevel_stop();
		secmodel_overlay_start();
		sysctl_security_overlay_setup(&sysctl_overlay_log);
		break;

	case MODULE_CMD_FINI:
		sysctl_teardown(&sysctl_overlay_log);
		secmodel_overlay_stop();

		error = secmodel_deregister(overlay_sm);
		if (error != 0)
			printf("secmodel_overlay_modcmd::fini: "
			    "secmodel_deregister returned %d\n", error);
		break;

	case MODULE_CMD_AUTOUNLOAD:
		error = EPERM;
		break;

	default:
		error = ENOTTY;
		break;
	}

	return error;
}
Esempio n. 22
0
static int
fujitsu_hk_detach(device_t self, int flags)
{
    struct fujitsu_hk_softc *sc = device_private(self);
    int i;

    pmf_device_deregister(self);

    if (sc->sc_log != NULL)
        sysctl_teardown(&sc->sc_log);

    acpi_deregister_notify(sc->sc_node);

    for (i = 0; i < FUJITSU_HK_PSW_COUNT; i++)
        sysmon_pswitch_unregister(&sc->sc_smpsw[i]);

    mutex_destroy(&sc->sc_mtx);

    return 0;
}
Esempio n. 23
0
static int
mfs_modcmd(modcmd_t cmd, void *arg)
{
	int error;

	switch (cmd) {
	case MODULE_CMD_INIT:
		error = vfs_attach(&mfs_vfsops);
		if (error != 0)
			break;
		sysctl_createv(&mfs_sysctl_log, 0, NULL, NULL,
			       CTLFLAG_PERMANENT,
			       CTLTYPE_NODE, "vfs", NULL,
			       NULL, 0, NULL, 0,
			       CTL_VFS, CTL_EOL);
		sysctl_createv(&mfs_sysctl_log, 0, NULL, NULL,
			       CTLFLAG_PERMANENT|CTLFLAG_ALIAS,
			       CTLTYPE_NODE, "mfs",
			       SYSCTL_DESCR("Memory based file system"),
			       NULL, 1, NULL, 0,
			       CTL_VFS, 3, CTL_EOL);
		/*
		 * XXX the "1" and the "3" above could be dynamic, thereby
		 * eliminating one more instance of the "number to vfs"
		 * mapping problem, but they are in order as taken from
		 * sys/mount.h
		 */
		break;
	case MODULE_CMD_FINI:
		error = vfs_detach(&mfs_vfsops);
		if (error != 0)
			break;
		sysctl_teardown(&mfs_sysctl_log);
		break;
	default:
		error = ENOTTY;
		break;
	}

	return (error);
}
static int
securelevel_modcmd(modcmd_t cmd, void *arg)
{
	int error = 0;

	switch (cmd) {
	case MODULE_CMD_INIT:
		secmodel_securelevel_init();
		error = secmodel_register(&securelevel_sm,
		    SECMODEL_SECURELEVEL_ID, SECMODEL_SECURELEVEL_NAME,
		    NULL, securelevel_eval, NULL);
		if (error != 0)
			printf("securelevel_modcmd::init: secmodel_register "
			    "returned %d\n", error);

		secmodel_securelevel_start();
		sysctl_security_securelevel_setup(&securelevel_sysctl_log);
		break;

	case MODULE_CMD_FINI:
		sysctl_teardown(&securelevel_sysctl_log);
		secmodel_securelevel_stop();

		error = secmodel_deregister(securelevel_sm);
		if (error != 0)
			printf("securelevel_modcmd::fini: secmodel_deregister "
			    "returned %d\n", error);

		break;

	case MODULE_CMD_AUTOUNLOAD:
		error = EPERM;
		break;

	default:
		error = ENOTTY;
		break;
	}

	return (error);
}
Esempio n. 25
0
static int
tapdetach(void)
{
	int error = 0;

	if (tap_count != 0)
		return EBUSY;

#ifdef _MODULE
	if (error == 0)
		error = devsw_detach(NULL, &tap_cdevsw);
#endif
	if (error == 0)
		sysctl_teardown(&tap_sysctl_clog);
	if (error == 0)
		if_clone_detach(&tap_cloners);

	if (error == 0)
		error = config_cfattach_detach(tap_cd.cd_name, &tap_ca);

	return error;
}
Esempio n. 26
0
static int
layerfs_modcmd(modcmd_t cmd, void *arg)
{
#ifdef _MODULE
	static struct sysctllog *layerfs_clog = NULL;
#endif

	switch (cmd) {
	case MODULE_CMD_INIT:
#ifdef _MODULE
		sysctl_vfs_layerfs_setup(&layerfs_clog);
#endif
		return 0;
	case MODULE_CMD_FINI:
#ifdef _MODULE
		sysctl_teardown(&layerfs_clog);
#endif
		return 0;
	default:
		return ENOTTY;
	}
	return 0;
}
Esempio n. 27
0
static int
asus_detach(device_t self, int flags)
{
	struct asus_softc *sc = device_private(self);
	int i;

	acpi_deregister_notify(sc->sc_node);

	if (sc->sc_smpsw_valid != false) {

		for (i = 0; i < ASUS_PSW_LAST; i++)
			sysmon_pswitch_unregister(&sc->sc_smpsw[i]);
	}

	if (sc->sc_sme != NULL)
		sysmon_envsys_unregister(sc->sc_sme);

	if (sc->sc_log != NULL)
		sysctl_teardown(&sc->sc_log);

	pmf_device_deregister(self);

	return 0;
}
Esempio n. 28
0
static int
ext2fs_modcmd(modcmd_t cmd, void *arg)
{
//	printf("In file: %s, fun: %s,lineno: %d\n",__FILE__, __func__, __LINE__);
	int error;

	switch (cmd) {
	case MODULE_CMD_INIT:
		error = vfs_attach(&ext2fs_vfsops);
		if (error != 0)
			break;
		sysctl_createv(&ext2fs_sysctl_log, 0, NULL, NULL,
			       CTLFLAG_PERMANENT,
			       CTLTYPE_NODE, "ext2fs",
			       SYSCTL_DESCR("Linux EXT2FS file system"),
			       NULL, 0, NULL, 0,
			       CTL_VFS, 17, CTL_EOL);
		/*
		 * XXX the "17" above could be dynamic, thereby eliminating
		 * one more instance of the "number to vfs" mapping problem,
		 * but "17" is the order as taken from sys/mount.h
		 */
		break;
	case MODULE_CMD_FINI:
		error = vfs_detach(&ext2fs_vfsops);
		if (error != 0)
			break;
		sysctl_teardown(&ext2fs_sysctl_log);
		break;
	default:
		error = ENOTTY;
		break;
	}

	return (error);
}
Esempio n. 29
0
static void
vmt_attach(device_t parent, device_t self, void *aux)
{
	int rv;
	struct vmt_softc *sc = device_private(self);

	aprint_naive("\n");
	aprint_normal(": %s\n", vmt_type());

	sc->sc_dev = self;
	sc->sc_log = NULL;

	callout_init(&sc->sc_tick, 0);
	callout_init(&sc->sc_tclo_tick, 0);
	callout_init(&sc->sc_clock_sync_tick, 0);

	sc->sc_clock_sync_period_seconds = VMT_CLOCK_SYNC_PERIOD_SECONDS;

	rv = vmt_sysctl_setup_root(self);
	if (rv != 0) {
		aprint_error_dev(self, "failed to initialize sysctl "
		    "(err %d)\n", rv);
		goto free;
	}

	sc->sc_rpc_buf = kmem_alloc(VMT_RPC_BUFLEN, KM_SLEEP);
	if (sc->sc_rpc_buf == NULL) {
		aprint_error_dev(self, "unable to allocate buffer for RPC\n");
		goto free;
	}

	if (vm_rpc_open(&sc->sc_tclo_rpc, VM_RPC_OPEN_TCLO) != 0) {
		aprint_error_dev(self, "failed to open backdoor RPC channel (TCLO protocol)\n");
		goto free;
	}
	sc->sc_tclo_rpc_open = true;

	/* don't know if this is important at all yet */
	if (vm_rpc_send_rpci_tx(sc, "tools.capability.hgfs_server toolbox 1") != 0) {
		aprint_error_dev(self, "failed to set HGFS server capability\n");
		goto free;
	}

	pmf_device_register1(self, NULL, NULL, vmt_shutdown);

	sysmon_task_queue_init();

	sc->sc_ev_power.ev_smpsw.smpsw_type = PSWITCH_TYPE_POWER;
	sc->sc_ev_power.ev_smpsw.smpsw_name = device_xname(self);
	sc->sc_ev_power.ev_code = PSWITCH_EVENT_PRESSED;
	sysmon_pswitch_register(&sc->sc_ev_power.ev_smpsw);
	sc->sc_ev_reset.ev_smpsw.smpsw_type = PSWITCH_TYPE_RESET;
	sc->sc_ev_reset.ev_smpsw.smpsw_name = device_xname(self);
	sc->sc_ev_reset.ev_code = PSWITCH_EVENT_PRESSED;
	sysmon_pswitch_register(&sc->sc_ev_reset.ev_smpsw);
	sc->sc_ev_sleep.ev_smpsw.smpsw_type = PSWITCH_TYPE_SLEEP;
	sc->sc_ev_sleep.ev_smpsw.smpsw_name = device_xname(self);
	sc->sc_ev_sleep.ev_code = PSWITCH_EVENT_RELEASED;
	sysmon_pswitch_register(&sc->sc_ev_sleep.ev_smpsw);
	sc->sc_smpsw_valid = true;

	callout_setfunc(&sc->sc_tick, vmt_tick, sc);
	callout_schedule(&sc->sc_tick, hz);

	callout_setfunc(&sc->sc_tclo_tick, vmt_tclo_tick, sc);
	callout_schedule(&sc->sc_tclo_tick, hz);
	sc->sc_tclo_ping = 1;

	callout_setfunc(&sc->sc_clock_sync_tick, vmt_clock_sync_tick, sc);
	callout_schedule(&sc->sc_clock_sync_tick,
	    mstohz(sc->sc_clock_sync_period_seconds * 1000));

	vmt_sync_guest_clock(sc);

	return;

free:
	if (sc->sc_rpc_buf)
		kmem_free(sc->sc_rpc_buf, VMT_RPC_BUFLEN);
	pmf_device_register(self, NULL, NULL);
	if (sc->sc_log)
		sysctl_teardown(&sc->sc_log);
}
Esempio n. 30
0
static void
apple_smc_fan_attach(device_t parent, device_t self, void *aux)
{
	struct apple_smc_fan_softc *sc = device_private(self);
	const struct apple_smc_attach_args *asa = aux;
	struct apple_smc_key *nfans_key;
	int error;

	/* Identify ourselves.  */
	aprint_normal(": Apple SMC fan sensors\n");

	/* Initialize the softc.  */
	sc->sc_dev = self;
	sc->sc_smc = asa->asa_smc;

	/* Find how to find how many fans there are.  */
	error = apple_smc_named_key(sc->sc_smc, APPLE_SMC_NFANS_KEY,
	    APPLE_SMC_TYPE_UINT8, &nfans_key);
	if (error)
		goto out0;

	/* Find how many fans there are.  */
	error = apple_smc_read_key_1(sc->sc_smc, nfans_key, &sc->sc_nfans);
	if (error)
		goto out1;

	/*
	 * There should be at least one, but just in case the hardware
	 * changed its mind in the interim...
	 */
	if (sc->sc_nfans == 0) {
		aprint_error_dev(self, "no fans\n");
		goto out1;
	}

	/*
	 * The number of fans must fit in a single decimal digit for
	 * the names of the fan keys; see the fan_sensor table above.
	 */
	if (sc->sc_nfans >= 10) {
		aprint_error_dev(self, "too many fans: %"PRIu8"\n",
		    sc->sc_nfans);
		sc->sc_nfans = 9;
	}

#if 0				/* XXX sysctl */
	/* Set up the sysctl tree for controlling the fans.  */
	error = apple_smc_fan_sysctl_setup(sc);
	if (error)
		goto fail0;
#endif

	/* Attach the sensors to sysmon_envsys.  */
	error = apple_smc_fan_attach_sensors(sc);
	if (error)
		goto fail1;

	/* Success!  */
	goto out1;

#if 0
fail2:
	apple_smc_fan_detach_sensors(sc);
#endif

fail1:
#if 0				/* XXX sysctl */
	sysctl_teardown(&sc->sc_sysctl_log);
fail0:
#endif

out1:	apple_smc_release_key(sc->sc_smc, nfans_key);
out0:	return;
}