xref: /netbsd-src/sys/compat/common/sysmon_power_40.c (revision 8a031a1d1e0aac23d43015c71ae6350b917c8347)
1*8a031a1dSpgoyette /*	$NetBSD: sysmon_power_40.c,v 1.4 2019/12/12 02:15:42 pgoyette Exp $	*/
2d91f98a8Spgoyette 
3d91f98a8Spgoyette /*-
4d91f98a8Spgoyette  * Copyright (c) 2007 Juan Romero Pardines.
5d91f98a8Spgoyette  * All rights reserved.
6d91f98a8Spgoyette  *
7d91f98a8Spgoyette  * Redistribution and use in source and binary forms, with or without
8d91f98a8Spgoyette  * modification, are permitted provided that the following conditions
9d91f98a8Spgoyette  * are met:
10d91f98a8Spgoyette  * 1. Redistributions of source code must retain the above copyright
11d91f98a8Spgoyette  *    notice, this list of conditions and the following disclaimer.
12d91f98a8Spgoyette  * 2. Redistributions in binary form must reproduce the above copyright
13d91f98a8Spgoyette  *    notice, this list of conditions and the following disclaimer in the
14d91f98a8Spgoyette  *    documentation and/or other materials provided with the distribution.
15d91f98a8Spgoyette  *
16d91f98a8Spgoyette  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17d91f98a8Spgoyette  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18d91f98a8Spgoyette  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19d91f98a8Spgoyette  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20d91f98a8Spgoyette  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21d91f98a8Spgoyette  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22d91f98a8Spgoyette  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23d91f98a8Spgoyette  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24d91f98a8Spgoyette  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25d91f98a8Spgoyette  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26d91f98a8Spgoyette  */
27d91f98a8Spgoyette 
28d91f98a8Spgoyette /*
29d91f98a8Spgoyette  * Copyright (c) 2003 Wasabi Systems, Inc.
30d91f98a8Spgoyette  * All rights reserved.
31d91f98a8Spgoyette  *
32d91f98a8Spgoyette  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
33d91f98a8Spgoyette  *
34d91f98a8Spgoyette  * Redistribution and use in source and binary forms, with or without
35d91f98a8Spgoyette  * modification, are permitted provided that the following conditions
36d91f98a8Spgoyette  * are met:
37d91f98a8Spgoyette  * 1. Redistributions of source code must retain the above copyright
38d91f98a8Spgoyette  *    notice, this list of conditions and the following disclaimer.
39d91f98a8Spgoyette  * 2. Redistributions in binary form must reproduce the above copyright
40d91f98a8Spgoyette  *    notice, this list of conditions and the following disclaimer in the
41d91f98a8Spgoyette  *    documentation and/or other materials provided with the distribution.
42d91f98a8Spgoyette  * 3. All advertising materials mentioning features or use of this software
43d91f98a8Spgoyette  *    must display the following acknowledgement:
44d91f98a8Spgoyette  *	This product includes software developed for the NetBSD Project by
45d91f98a8Spgoyette  *	Wasabi Systems, Inc.
46d91f98a8Spgoyette  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
47d91f98a8Spgoyette  *    or promote products derived from this software without specific prior
48d91f98a8Spgoyette  *    written permission.
49d91f98a8Spgoyette  *
50d91f98a8Spgoyette  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
51d91f98a8Spgoyette  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
52d91f98a8Spgoyette  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53d91f98a8Spgoyette  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
54d91f98a8Spgoyette  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
55d91f98a8Spgoyette  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
56d91f98a8Spgoyette  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
57d91f98a8Spgoyette  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
58d91f98a8Spgoyette  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
59d91f98a8Spgoyette  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
60d91f98a8Spgoyette  * POSSIBILITY OF SUCH DAMAGE.
61d91f98a8Spgoyette  */
62d91f98a8Spgoyette 
63d91f98a8Spgoyette 
64d91f98a8Spgoyette #include <sys/cdefs.h>
65*8a031a1dSpgoyette __KERNEL_RCSID(0, "$NetBSD: sysmon_power_40.c,v 1.4 2019/12/12 02:15:42 pgoyette Exp $");
66d91f98a8Spgoyette 
67d91f98a8Spgoyette #if defined(_KERNEL_OPT)
68d91f98a8Spgoyette #include "opt_compat_netbsd.h"
69d91f98a8Spgoyette #endif
70d91f98a8Spgoyette 
71d91f98a8Spgoyette #include <sys/param.h>
72d91f98a8Spgoyette #include <sys/systm.h>
73d91f98a8Spgoyette #include <sys/power.h>
74d91f98a8Spgoyette #include <sys/compat_stub.h>
75d91f98a8Spgoyette 
76d91f98a8Spgoyette #include <dev/sysmon/sysmonvar.h>
77d91f98a8Spgoyette 
78d91f98a8Spgoyette #include <compat/common/compat_mod.h>
79d91f98a8Spgoyette 
80d91f98a8Spgoyette static void
compat_40_sysmon_power(power_event_t * pev,struct sysmon_pswitch * pswitch,int event)81d91f98a8Spgoyette compat_40_sysmon_power(power_event_t *pev, struct sysmon_pswitch *pswitch,
82d91f98a8Spgoyette     int event)
83d91f98a8Spgoyette {
84d91f98a8Spgoyette 
85d91f98a8Spgoyette 	pev->pev_switch.psws_state = event;
86d91f98a8Spgoyette 	pev->pev_switch.psws_type = pswitch->smpsw_type;
87d91f98a8Spgoyette 
88d91f98a8Spgoyette 	if (pswitch->smpsw_name) {
89d91f98a8Spgoyette 		(void)strlcpy(pev->pev_switch.psws_name,
90d91f98a8Spgoyette 		          pswitch->smpsw_name,
91d91f98a8Spgoyette 		          sizeof(pev->pev_switch.psws_name));
92d91f98a8Spgoyette 	}
93d91f98a8Spgoyette }
94d91f98a8Spgoyette 
95d91f98a8Spgoyette void
sysmon_power_40_init(void)96d91f98a8Spgoyette sysmon_power_40_init(void)
97d91f98a8Spgoyette {
98d91f98a8Spgoyette 
99*8a031a1dSpgoyette 	MODULE_HOOK_SET(compat_sysmon_power_40_hook, compat_40_sysmon_power);
100d91f98a8Spgoyette }
101d91f98a8Spgoyette 
102d91f98a8Spgoyette void
sysmon_power_40_fini(void)103d91f98a8Spgoyette sysmon_power_40_fini(void)
104d91f98a8Spgoyette {
105d91f98a8Spgoyette 
1068c2f80f1Spgoyette 	MODULE_HOOK_UNSET(compat_sysmon_power_40_hook);
107d91f98a8Spgoyette }
108