annotate src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children 6af0a709d52b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_vm_version_solaris_sparc.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 # include <sys/systeminfo.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 int VM_Version::platform_features(int features) {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // We determine what sort of hardware we have via sysinfo(SI_ISALIST, ...).
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // This isn't the best of all possible ways because there's not enough
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // detail in the isa list it returns, but it's a bit less arcane than
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // generating assembly code and an illegal instruction handler. We used
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // to generate a getpsr trap, but that's even more arcane.
a61af66fc99e Initial load
duke
parents:
diff changeset
36 //
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // Another possibility would be to use sysinfo(SI_PLATFORM, ...), but
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // that would require more knowledge here than is wise.
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // isalist spec via 'man isalist' as of 01-Aug-2001
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 char tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
44 char* buf = (char*)malloc(bufsize);
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 if (buf != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Figure out what kind of sparc we have
a61af66fc99e Initial load
duke
parents:
diff changeset
49 char *sparc_string = strstr(buf, "sparc");
a61af66fc99e Initial load
duke
parents:
diff changeset
50 if (sparc_string != NULL) { features |= v8_instructions_m;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 if (sparc_string[5] == 'v') {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 if (sparc_string[6] == '8') {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 if (sparc_string[7] == '-') features |= hardware_int_muldiv_m;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 else if (sparc_string[7] == 'p') features |= generic_v9_m;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 else features |= generic_v8_m;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 } else if (sparc_string[6] == '9') features |= generic_v9_m;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Check for visualization instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
61 char *vis = strstr(buf, "vis");
a61af66fc99e Initial load
duke
parents:
diff changeset
62 if (vis != NULL) { features |= vis1_instructions_m;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 if (vis[3] == '2') features |= vis2_instructions_m;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 free(buf);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 bufsize = sysinfo(SI_MACHINE, &tmp, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 buf = (char*)malloc(bufsize);
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 if (buf != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 if (sysinfo(SI_MACHINE, buf, bufsize) == bufsize) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 if (strstr(buf, "sun4v") != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 features |= sun4v_m;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 free(buf);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 return features;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }