1 1.5 pgoyette /* $NetBSD: wsevent_50.c,v 1.5 2019/12/12 02:15:43 pgoyette Exp $ */ 2 1.2 pgoyette 3 1.2 pgoyette /*- 4 1.2 pgoyette * Copyright (c) 2006, 2008 The NetBSD Foundation, Inc. 5 1.2 pgoyette * All rights reserved. 6 1.2 pgoyette * 7 1.2 pgoyette * This code is derived from software contributed to The NetBSD Foundation 8 1.2 pgoyette * by Julio M. Merino Vidal. 9 1.2 pgoyette * 10 1.2 pgoyette * Redistribution and use in source and binary forms, with or without 11 1.2 pgoyette * modification, are permitted provided that the following conditions 12 1.2 pgoyette * are met: 13 1.2 pgoyette * 1. Redistributions of source code must retain the above copyright 14 1.2 pgoyette * notice, this list of conditions and the following disclaimer. 15 1.2 pgoyette * 2. Redistributions in binary form must reproduce the above copyright 16 1.2 pgoyette * notice, this list of conditions and the following disclaimer in the 17 1.2 pgoyette * documentation and/or other materials provided with the distribution. 18 1.2 pgoyette * 19 1.2 pgoyette * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.2 pgoyette * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.2 pgoyette * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.2 pgoyette * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.2 pgoyette * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.2 pgoyette * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.2 pgoyette * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.2 pgoyette * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.2 pgoyette * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.2 pgoyette * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.2 pgoyette * POSSIBILITY OF SUCH DAMAGE. 30 1.2 pgoyette */ 31 1.2 pgoyette 32 1.2 pgoyette /* 33 1.2 pgoyette * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. 34 1.2 pgoyette * 35 1.2 pgoyette * Redistribution and use in source and binary forms, with or without 36 1.2 pgoyette * modification, are permitted provided that the following conditions 37 1.2 pgoyette * are met: 38 1.2 pgoyette * 1. Redistributions of source code must retain the above copyright 39 1.2 pgoyette * notice, this list of conditions and the following disclaimer. 40 1.2 pgoyette * 2. Redistributions in binary form must reproduce the above copyright 41 1.2 pgoyette * notice, this list of conditions and the following disclaimer in the 42 1.2 pgoyette * documentation and/or other materials provided with the distribution. 43 1.2 pgoyette * 3. All advertising materials mentioning features or use of this software 44 1.2 pgoyette * must display the following acknowledgement: 45 1.2 pgoyette * This product includes software developed by Christopher G. Demetriou 46 1.2 pgoyette * for the NetBSD Project. 47 1.2 pgoyette * 4. The name of the author may not be used to endorse or promote products 48 1.2 pgoyette * derived from this software without specific prior written permission 49 1.2 pgoyette * 50 1.2 pgoyette * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 51 1.2 pgoyette * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 52 1.2 pgoyette * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 53 1.2 pgoyette * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 54 1.2 pgoyette * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 55 1.2 pgoyette * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 56 1.2 pgoyette * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 57 1.2 pgoyette * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 58 1.2 pgoyette * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 59 1.2 pgoyette * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 1.2 pgoyette */ 61 1.2 pgoyette 62 1.2 pgoyette /* 63 1.2 pgoyette * Copyright (c) 1992, 1993 64 1.2 pgoyette * The Regents of the University of California. All rights reserved. 65 1.2 pgoyette * 66 1.2 pgoyette * This software was developed by the Computer Systems Engineering group 67 1.2 pgoyette * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 68 1.2 pgoyette * contributed to Berkeley. 69 1.2 pgoyette * 70 1.2 pgoyette * All advertising materials mentioning features or use of this software 71 1.2 pgoyette * must display the following acknowledgement: 72 1.2 pgoyette * This product includes software developed by the University of 73 1.2 pgoyette * California, Lawrence Berkeley Laboratory. 74 1.2 pgoyette * 75 1.2 pgoyette * Redistribution and use in source and binary forms, with or without 76 1.2 pgoyette * modification, are permitted provided that the following conditions 77 1.2 pgoyette * are met: 78 1.2 pgoyette * 1. Redistributions of source code must retain the above copyright 79 1.2 pgoyette * notice, this list of conditions and the following disclaimer. 80 1.2 pgoyette * 2. Redistributions in binary form must reproduce the above copyright 81 1.2 pgoyette * notice, this list of conditions and the following disclaimer in the 82 1.2 pgoyette * documentation and/or other materials provided with the distribution. 83 1.2 pgoyette * 3. Neither the name of the University nor the names of its contributors 84 1.2 pgoyette * may be used to endorse or promote products derived from this software 85 1.2 pgoyette * without specific prior written permission. 86 1.2 pgoyette * 87 1.2 pgoyette * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 88 1.2 pgoyette * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 89 1.2 pgoyette * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 90 1.2 pgoyette * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 91 1.2 pgoyette * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 92 1.2 pgoyette * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 93 1.2 pgoyette * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 94 1.2 pgoyette * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 95 1.2 pgoyette * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 96 1.2 pgoyette * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 97 1.2 pgoyette * SUCH DAMAGE. 98 1.2 pgoyette * 99 1.2 pgoyette * @(#)event.c 8.1 (Berkeley) 6/11/93 100 1.2 pgoyette */ 101 1.2 pgoyette 102 1.2 pgoyette /* 103 1.2 pgoyette * Internal "wscons_event" queue interface for the keyboard and mouse drivers. 104 1.2 pgoyette */ 105 1.2 pgoyette 106 1.2 pgoyette #include <sys/cdefs.h> 107 1.5 pgoyette __KERNEL_RCSID(0, "$NetBSD: wsevent_50.c,v 1.5 2019/12/12 02:15:43 pgoyette Exp $"); 108 1.2 pgoyette 109 1.2 pgoyette #include <sys/param.h> 110 1.2 pgoyette #include <sys/kernel.h> 111 1.2 pgoyette #include <sys/fcntl.h> 112 1.2 pgoyette #include <sys/kmem.h> 113 1.2 pgoyette #include <sys/proc.h> 114 1.2 pgoyette #include <sys/systm.h> 115 1.2 pgoyette #include <sys/vnode.h> 116 1.2 pgoyette #include <sys/select.h> 117 1.2 pgoyette #include <sys/poll.h> 118 1.2 pgoyette #include <sys/compat_stub.h> 119 1.2 pgoyette 120 1.2 pgoyette #include <dev/wscons/wsconsio.h> 121 1.2 pgoyette #include <dev/wscons/wseventvar.h> 122 1.2 pgoyette #include <dev/wscons/wsevent_50.h> 123 1.2 pgoyette 124 1.2 pgoyette static int 125 1.2 pgoyette wsevent_copyout_events50(const struct wscons_event *events, int cnt, 126 1.2 pgoyette struct uio *uio) 127 1.2 pgoyette { 128 1.2 pgoyette int i; 129 1.2 pgoyette 130 1.2 pgoyette for (i = 0; i < cnt; i++) { 131 1.2 pgoyette const struct wscons_event *ev = &events[i]; 132 1.2 pgoyette struct owscons_event ev50; 133 1.2 pgoyette int error; 134 1.2 pgoyette 135 1.2 pgoyette ev50.type = ev->type; 136 1.2 pgoyette ev50.value = ev->value; 137 1.2 pgoyette timespec_to_timespec50(&ev->time, &ev50.time); 138 1.2 pgoyette 139 1.2 pgoyette error = uiomove(&ev50, sizeof(ev50), uio); 140 1.2 pgoyette if (error) { 141 1.2 pgoyette return error; 142 1.2 pgoyette } 143 1.2 pgoyette } 144 1.2 pgoyette return 0; 145 1.2 pgoyette } 146 1.2 pgoyette 147 1.2 pgoyette void 148 1.2 pgoyette wsevent_50_init(void) 149 1.2 pgoyette { 150 1.2 pgoyette 151 1.5 pgoyette MODULE_HOOK_SET(wscons_copyout_events_50_hook, 152 1.2 pgoyette wsevent_copyout_events50); 153 1.2 pgoyette } 154 1.2 pgoyette 155 1.2 pgoyette void 156 1.2 pgoyette wsevent_50_fini(void) 157 1.2 pgoyette { 158 1.2 pgoyette 159 1.4 pgoyette MODULE_HOOK_UNSET(wscons_copyout_events_50_hook); 160 1.2 pgoyette } 161