sysmon_component.c revision 1.1
11.1Spooka/*	$NetBSD: sysmon_component.c,v 1.1 2014/03/13 01:47:07 pooka Exp $	*/
21.1Spooka
31.1Spooka/*
41.1Spooka * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
51.1Spooka *
61.1Spooka * Redistribution and use in source and binary forms, with or without
71.1Spooka * modification, are permitted provided that the following conditions
81.1Spooka * are met:
91.1Spooka * 1. Redistributions of source code must retain the above copyright
101.1Spooka *    notice, this list of conditions and the following disclaimer.
111.1Spooka * 2. Redistributions in binary form must reproduce the above copyright
121.1Spooka *    notice, this list of conditions and the following disclaimer in the
131.1Spooka *    documentation and/or other materials provided with the distribution.
141.1Spooka *
151.1Spooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
161.1Spooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
171.1Spooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
181.1Spooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
191.1Spooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
201.1Spooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
211.1Spooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
221.1Spooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
231.1Spooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
241.1Spooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
251.1Spooka * SUCH DAMAGE.
261.1Spooka */
271.1Spooka
281.1Spooka#include <sys/cdefs.h>
291.1Spooka__KERNEL_RCSID(0, "$NetBSD: sysmon_component.c,v 1.1 2014/03/13 01:47:07 pooka Exp $");
301.1Spooka
311.1Spooka#include <sys/param.h>
321.1Spooka#include <sys/conf.h>
331.1Spooka#include <sys/device.h>
341.1Spooka#include <sys/stat.h>
351.1Spooka
361.1Spooka#include <dev/sysmon/sysmon_taskq.h>
371.1Spooka#include <dev/sysmon/sysmonvar.h>
381.1Spooka
391.1Spooka#include "rump_private.h"
401.1Spooka#include "rump_dev_private.h"
411.1Spooka#include "rump_vfs_private.h"
421.1Spooka
431.1Spooka#include "ioconf.c"
441.1Spooka
451.1Spookavoid swwdogattach(int);
461.1Spookavoid swsensorattach(int);
471.1Spooka
481.1SpookaRUMP_COMPONENT(RUMP_COMPONENT_DEV)
491.1Spooka{
501.1Spooka	extern const struct cdevsw sysmon_cdevsw;
511.1Spooka	devmajor_t bmaj, cmaj;
521.1Spooka	int error;
531.1Spooka
541.1Spooka	if ((error = config_init_component(cfdriver_ioconf_swwdog,
551.1Spooka	    cfattach_ioconf_swwdog, cfdata_ioconf_swwdog)) != 0) {
561.1Spooka		printf("cannot attach swwdog: %d\n", error);
571.1Spooka		return;
581.1Spooka	}
591.1Spooka
601.1Spooka	bmaj = cmaj = -1;
611.1Spooka	if ((error = devsw_attach("sysmon", NULL, &bmaj,
621.1Spooka	    &sysmon_cdevsw, &cmaj)) != 0)
631.1Spooka		panic("sysmon devsw attach failed: %d", error);
641.1Spooka
651.1Spooka	if ((error = rump_vfs_makeonedevnode(S_IFCHR, "/dev/sysmon",
661.1Spooka	    cmaj, SYSMON_MINOR_ENVSYS)) != 0)
671.1Spooka		panic("cannot create /dev/sysmon: %d", error);
681.1Spooka	if ((error = rump_vfs_makeonedevnode(S_IFCHR, "/dev/watchdog",
691.1Spooka	    cmaj, SYSMON_MINOR_WDOG)) != 0)
701.1Spooka		panic("cannot create /dev/watchdog: %d", error);
711.1Spooka	if ((error = rump_vfs_makeonedevnode(S_IFCHR, "/dev/power",
721.1Spooka	    cmaj, SYSMON_MINOR_POWER)) != 0)
731.1Spooka		panic("cannot create /dev/power: %d", error);
741.1Spooka
751.1Spooka	sysmon_task_queue_preinit();
761.1Spooka	sysmon_task_queue_init();
771.1Spooka	sysmon_envsys_init();
781.1Spooka	sysmon_power_init();
791.1Spooka	sysmon_wdog_init();
801.1Spooka
811.1Spooka	rump_pdev_add(swwdogattach, 0);
821.1Spooka}
83