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