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