vm_version_solaris_sparc.cpp revision 1472
0N/A/*
1472N/A * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
0N/A# include "incls/_precompiled.incl"
0N/A# include "incls/_vm_version_solaris_sparc.cpp.incl"
0N/A
641N/A# include <sys/auxv.h>
641N/A# include <sys/auxv_SPARC.h>
0N/A# include <sys/systeminfo.h>
0N/A
641N/A// We need to keep these here as long as we have to build on Solaris
641N/A// versions before 10.
641N/A#ifndef SI_ARCHITECTURE_32
641N/A#define SI_ARCHITECTURE_32 516 /* basic 32-bit SI_ARCHITECTURE */
641N/A#endif
641N/A
641N/A#ifndef SI_ARCHITECTURE_64
641N/A#define SI_ARCHITECTURE_64 517 /* basic 64-bit SI_ARCHITECTURE */
641N/A#endif
641N/A
641N/Astatic void do_sysinfo(int si, const char* string, int* features, int mask) {
641N/A char tmp;
641N/A size_t bufsize = sysinfo(si, &tmp, 1);
641N/A
641N/A // All SI defines used below must be supported.
641N/A guarantee(bufsize != -1, "must be supported");
641N/A
641N/A char* buf = (char*) malloc(bufsize);
641N/A
641N/A if (buf == NULL)
641N/A return;
641N/A
641N/A if (sysinfo(si, buf, bufsize) == bufsize) {
641N/A // Compare the string.
641N/A if (strcmp(buf, string) == 0) {
641N/A *features |= mask;
641N/A }
641N/A }
641N/A
641N/A free(buf);
641N/A}
641N/A
0N/Aint VM_Version::platform_features(int features) {
641N/A // getisax(2), SI_ARCHITECTURE_32, and SI_ARCHITECTURE_64 are
641N/A // supported on Solaris 10 and later.
641N/A if (os::Solaris::supports_getisax()) {
641N/A#ifndef PRODUCT
641N/A if (PrintMiscellaneous && Verbose)
641N/A tty->print_cr("getisax(2) supported.");
641N/A#endif
0N/A
641N/A // Check 32-bit architecture.
641N/A do_sysinfo(SI_ARCHITECTURE_32, "sparc", &features, v8_instructions_m);
641N/A
641N/A // Check 64-bit architecture.
641N/A do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m);
641N/A
641N/A // Extract valid instruction set extensions.
641N/A uint_t av;
641N/A uint_t avn = os::Solaris::getisax(&av, 1);
641N/A assert(avn == 1, "should only return one av");
0N/A
641N/A if (av & AV_SPARC_MUL32) features |= hardware_mul32_m;
641N/A if (av & AV_SPARC_DIV32) features |= hardware_div32_m;
641N/A if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
641N/A if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m;
643N/A if (av & AV_SPARC_POPC) features |= hardware_popc_m;
641N/A if (av & AV_SPARC_VIS) features |= vis1_instructions_m;
641N/A if (av & AV_SPARC_VIS2) features |= vis2_instructions_m;
641N/A } else {
641N/A // getisax(2) failed, use the old legacy code.
641N/A#ifndef PRODUCT
641N/A if (PrintMiscellaneous && Verbose)
641N/A tty->print_cr("getisax(2) not supported.");
641N/A#endif
641N/A
641N/A char tmp;
641N/A size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1);
641N/A char* buf = (char*) malloc(bufsize);
0N/A
641N/A if (buf != NULL) {
641N/A if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) {
641N/A // Figure out what kind of sparc we have
641N/A char *sparc_string = strstr(buf, "sparc");
641N/A if (sparc_string != NULL) { features |= v8_instructions_m;
641N/A if (sparc_string[5] == 'v') {
641N/A if (sparc_string[6] == '8') {
641N/A if (sparc_string[7] == '-') { features |= hardware_mul32_m;
641N/A features |= hardware_div32_m;
641N/A } else if (sparc_string[7] == 'p') features |= generic_v9_m;
641N/A else features |= generic_v8_m;
641N/A } else if (sparc_string[6] == '9') features |= generic_v9_m;
641N/A }
641N/A }
641N/A
641N/A // Check for visualization instructions
641N/A char *vis = strstr(buf, "vis");
641N/A if (vis != NULL) { features |= vis1_instructions_m;
641N/A if (vis[3] == '2') features |= vis2_instructions_m;
0N/A }
0N/A }
641N/A free(buf);
0N/A }
0N/A }
0N/A
641N/A // Determine the machine type.
641N/A do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m);
0N/A
0N/A return features;
0N/A}