1 /* $NetBSD: irix_systeminfo.c,v 1.15 2007/12/20 23:02:51 dsl Exp $ */
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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_systeminfo.c,v 1.15 2007/12/20 23:02:51 dsl Exp $");
35 #include <sys/types.h>
36 #include <sys/signal.h>
37 #include <sys/param.h>
38 #include <sys/mount.h>
39 #include <sys/kernel.h>
41 #include <sys/systm.h>
42 #include <sys/sysctl.h>
43 #include <sys/syscallargs.h>
45 #include <compat/common/compat_util.h>
47 #include <compat/svr4/svr4_systeminfo.h>
48 #include <compat/svr4/svr4_types.h>
49 #include <compat/svr4/svr4_signal.h>
50 #include <compat/svr4/svr4_ucontext.h>
51 #include <compat/svr4/svr4_lwp.h>
52 #include <compat/svr4/svr4_syscallargs.h>
54 #include <compat/irix/irix_types.h>
55 #include <compat/irix/irix_signal.h>
56 #include <compat/irix/irix_sysctl.h>
57 #include <compat/irix/irix_syscallargs.h>
59 char irix_si_vendor
[128] = "Silicon Graphics, Inc.";
60 char irix_si_os_provider
[128] = "Silicon Graphics, Inc.";
61 char irix_si_os_name
[128] = "IRIX";
62 char irix_si_hw_name
[128] = "IP22"; /* XXX */
63 char irix_si_osrel_maj
[128] = "6";
64 char irix_si_osrel_min
[128] = "5";
65 char irix_si_osrel_patch
[128] = "0";
66 char irix_si_processors
[128] = "R5000 1.0"; /* XXX */
67 char irix_si_version
[128] = "04131232";
72 irix_sys_systeminfo(struct lwp
*l
, const struct irix_sys_systeminfo_args
*uap
, register_t
*retval
)
76 syscallarg(char *) buf;
79 const char *str
= NULL
;
80 char strbuf
[BUF_SIZE
+ 1];
85 u_int rlen
= SCARG(uap
, len
);
87 switch (SCARG(uap
, what
)) {
88 case SVR4_MIPS_SI_VENDOR
:
92 case SVR4_MIPS_SI_OS_PROVIDER
:
93 str
= irix_si_os_provider
;
96 case SVR4_MIPS_SI_OS_NAME
:
97 str
= irix_si_os_name
;
100 case SVR4_MIPS_SI_HW_NAME
:
101 str
= irix_si_hw_name
;
104 case SVR4_MIPS_SI_OSREL_MAJ
:
105 str
= irix_si_osrel_maj
;
108 case SVR4_MIPS_SI_OSREL_MIN
:
109 str
= irix_si_osrel_min
;
112 case SVR4_MIPS_SI_OSREL_PATCH
:
113 str
= irix_si_osrel_patch
;
116 case SVR4_MIPS_SI_PROCESSORS
:
117 str
= irix_si_processors
;
120 case SVR4_MIPS_SI_NUM_PROCESSORS
:
121 case SVR4_MIPS_SI_AVAIL_PROCESSORS
: {
122 snprintf(strbuf
, BUF_SIZE
, "%d", ncpu
);
127 case SVR4_SI_HW_SERIAL
:
128 snprintf(strbuf
, BUF_SIZE
, "%d", (int32_t)hostid
);
132 case SVR4_MIPS_SI_HOSTID
:
133 snprintf(strbuf
, BUF_SIZE
, "%08x", (int32_t)hostid
);
137 case SVR4_MIPS_SI_SERIAL
: /* Unimplemented yet */
139 return svr4_sys_systeminfo(l
, (const void *)uap
, retval
);
144 * This duplicates some code in
145 * svr4_sys_systeminfo().
146 * Ideally, it should be merged.
149 len
= strlen(str
) + 1;
153 if (SCARG(uap
, buf
)) {
154 error
= copyout(str
, SCARG(uap
, buf
), len
);
157 /* make sure we are NULL terminated */
159 error
= copyout(buf
, &(SCARG(uap
, buf
)[len
- 1]), 1);