No empty .Rs/.Re
[netbsd-mini2440.git] / sys / compat / irix / irix_kmem.c
blobe83b67a25038c758806c1ed9f230535e950be699
1 /* $NetBSD: irix_kmem.c,v 1.9 2009/03/14 21:04:18 dsl Exp $ */
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Emmanuel Dreyfus.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: irix_kmem.c,v 1.9 2009/03/14 21:04:18 dsl Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/proc.h>
38 #include <sys/errno.h>
39 #include <sys/ioctl.h>
40 #include <sys/device.h>
41 #include <sys/vnode.h>
42 #include <sys/conf.h>
44 #include <compat/irix/irix_kmem.h>
45 #include <compat/irix/irix_sysmp.h>
48 * We have no idea of theses value's meaning yet, but time will come
50 long irix_kernel_var[32] = { 0x7fff2fc8, 0x0fb72194, 0x00000000, 0x0fb68890,
51 0x7fff2f74, 0x7fff2fc8, 0x7fff2fc8, 0x7fff2f74,
52 0x7fff2f7c, 0x0fb7246c, 0x0fbd9178, 0x0fb910d4,
53 0x0fb65440, 0x00000800, 0x00400034, 0x0000000a,
54 0x00000008, 0x0fb73fb0, 0x00000000, 0x00000000,
55 0x00000000, 0x7fff3000, 0x00000001, 0x7fff2f74,
56 0x7fff2d24, 0x0fa85880, 0x00000001, 0x0fb60188,
57 0x00000004, 0x00000000, 0x00000000, 0x00000001,
59 struct irix_kmem_softc {
60 struct device irix_kmem_dev;
63 dev_type_open(irix_kmemopen);
64 dev_type_close(irix_kmemclose);
65 dev_type_read(irix_kmemread);
66 dev_type_write(irix_kmemwrite);
68 const struct cdevsw irix_kmem_cdevsw = {
69 irix_kmemopen, irix_kmemclose, irix_kmemread, irix_kmemwrite,
70 noioctl, nostop, notty, nopoll, nommap, nokqfilter,
73 void
74 irix_kmemattach(struct device *parent, struct device *self, void *aux)
76 return;
79 int
80 irix_kmemopen(dev_t dev, int flags, int fmt, struct lwp *l)
82 return 0;
85 int
86 irix_kmemread(dev_t dev, struct uio *uio, int flag)
88 void *buf = NULL;
89 off_t buflen = 0;
90 void *offset;
91 int error = 0;
93 #ifdef DEBUG_IRIX
94 printf("irix_kmemread(): offset = 0x%08lx\n", (long)uio->uio_offset);
95 printf("irix_kmemread(): addr = %p\n", uio->uio_iov->iov_base);
96 printf("irix_kmemread(): len = 0x%08lx\n", (long)uio->uio_iov->iov_len);
97 #endif
98 offset = (void *)(uintptr_t)uio->uio_offset; /* XXX */
99 if (offset == &averunnable) { /* load average */
100 struct irix_loadavg iav;
101 int scale = averunnable.fscale / IRIX_LOADAVG_SCALE;
103 (void)memset(&iav, 0, sizeof(iav));
104 iav.ldavg[0] = averunnable.ldavg[0] / scale;
105 iav.ldavg[1] = averunnable.ldavg[1] / scale;
106 iav.ldavg[2] = averunnable.ldavg[2] / scale;
107 buf = (void *)&iav;
108 buflen = sizeof(iav);
111 if (offset == &irix_kernel_var) { /* kernel variables */
112 buf = &irix_kernel_var;
113 buflen = sizeof(irix_kernel_var);
116 if (buflen != 0)
117 error = uiomove(buf, buflen, uio);
118 return error;
122 irix_kmemwrite(dev_t dev, struct uio *uio, int flag)
124 return 0;
128 irix_kmemclose(dev_t dev, int flags, int fmt, struct lwp *l)
130 return 0;