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