Print this page
    
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/man/man7d/cpuid.7d
          +++ new/usr/src/man/man7d/cpuid.7d
   1    1  '\" te
   2    2  .\" Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved
   3    3  .\" Copyright 2015, Joyent, Inc.
   4    4  .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   5    5  .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   6    6  .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
   7    7  .TH CPUID 7D "April 9, 2016"
   8    8  .SH NAME
   9    9  cpuid \- CPU identification driver
  10   10  .SH SYNOPSIS
  11   11  .LP
  12   12  .nf
  13   13  \fB/dev/cpu/self/cpuid\fR
  14   14  .fi
  15   15  
  16   16  .SH DESCRIPTION
  17   17  .SS "SPARC and x86 system"
  18   18  .LP
  19   19  This device provides implementation-private information via ioctls about
  20   20  various aspects of the implementation to Solaris libraries and utilities.
  21   21  .SS "x86 systems only"
  22   22  .LP
  23   23  This device also provides a file-like view of the namespace and return values
  24   24  of the x86 cpuid instruction. The cpuid instruction takes a single 32-bit
  25   25  integer function code, and returns four 32-bit integer values corresponding to
  26   26  the input value that describe various aspects of the capabilities and
  27   27  configuration of the processor.
  28   28  .LP
  29   29  The API for the character device consists of using the seek offset to set the
  30   30  function code value, and using a \fBread\fR(2) or \fBpread\fR(2) of 16 bytes to
  31   31  fetch the four 32-bit return values of the instruction in the order %\fBeax\fR,
  32   32  %\fBebx\fR, %\fBecx\fR and %\fBedx\fR.
  33   33  .LP
  34   34  No data can be written to the device. Like the \fBcpuid\fR instruction, no
  35   35  special privileges are required to use the device.
  36   36  .LP
  37   37  The device is useful to enable low-level configuration information to be
  38   38  extracted from the CPU without having to write any assembler code to invoke the
  39   39  \fBcpuid\fR instruction directly. It also allows the kernel to attempt to
  40   40  correct any erroneous data returned by the instruction (prompted by occasional
  41   41  errors in the information exported by various processor implementations over
  42   42  the years).
  43   43  .LP
  44   44  See the processor manufacturers documentation for further information about the
  45   45  syntax and semantics of the wide variety of information available from this
  46   46  instruction.
  47   47  .LP
  48   48  Some systems can be configured to limit the cpuid opcodes which are accessible.
  49   49  While illumos handles this condition, other software may malfunction when such
  50   50  limits are enabled.  Those settings are typically manipulated in the BIOS.
  51   51  .SH EXAMPLE
  52   52  .LP
  53   53  This example allows you to determine if the current x86 processor supports
  54   54  "long mode," which is a necessary (but not sufficient) condition for running
  55   55  the 64-bit Solaris kernel on the processor.
  56   56  .sp
  57   57  .in +2
  58   58  .nf
  59   59  /*
  60   60  
  61   61  #include <sys/types.h>
  62   62  #include <sys/stat.h>
  63   63  #include <fcntl.h>
  64   64  #include <unistd.h>
  65   65  #include <string.h>
  66   66  #include <errno.h>
  67   67  #include <stdio.h>
  68   68  
  69   69  static const char devname[] = "/dev/cpu/self/cpuid";
  70   70  
  71   71  /*ARGSUSED*/
  72   72  int
  73   73  main(int argc, char *argv[])
  74   74  {
  75   75          struct {
  76   76                  uint32_t r_eax, r_ebx, r_ecx, r_edx;
  77   77          } _r, *rp = &_r;
  78   78          int d;
  79   79          char *s;
  80   80  
  81   81          if ((d = open(devname, O_RDONLY)) == -1) {
  82   82                  perror(devname);
  83   83                  return (1);
  84   84          }
  85   85  
  86   86          if (pread(d, rp, sizeof (*rp), 0) != sizeof (*rp)) {
  87   87                  perror(devname);
  88   88                  goto fail;
  89   89          }
  90   90  
  91   91          s = (char *)&rp->r_ebx;
  92   92          if (strncmp(s, "Auth" "cAMD" "enti", 12) != 0 &&
  93   93              strncmp(s, "Genu" "ntel" "ineI", 12) != 0)
  94   94                  goto fail;
  95   95  
  96   96          if (pread(d, rp, sizeof (*rp), 0x80000001) == sizeof (*rp)) {
  97   97                  /*
  98   98                   * Read extended feature word; check bit 29
  99   99                   */
 100  100                  (void) close(d);
 101  101                  if ((rp->r_edx >> 29) & 1) {
 102  102                          (void) printf("processor supports long mode\en");
 103  103                          return (0);
 104  104                  }
 105  105          }
 106  106  fail:
 107  107          (void) close(d);
 108  108          return (1);
 109  109  }
 110  110  .fi
 111  111  .in -2
 112  112  
 113  113  .SH ERRORS
 114  114  .ne 2
 115  115  .na
 116  116  \fBENXIO\fR
 117  117  .ad
 118  118  .RS 10n
 119  119  Results from attempting to read data from the device on a system that does not
 120  120  support the CPU identification interfaces
 121  121  .RE
 122  122  
 123  123  .sp
 124  124  .ne 2
 125  125  .na
 126  126  \fBEINVAL\fR
 127  127  .ad
 128  128  .RS 10n
 129  129  Results from reading from an offset larger than UINT_MAX, or attempting to read
 130  130  with a size that is not multiple of 16 bytes.
 131  131  .RE
 132  132  
 133  133  .SH FILES
 134  134  .ne 2
 135  135  .na
 136  136  \fB\fB/dev/cpu/self/cpuid\fR\fR
 137  137  .ad
 138  138  .RS 23n
 139  139  Provides access to CPU identification data.
 140  140  .RE
 141  141  
 142  142  .SH ATTRIBUTES
 143  143  .LP
 144  144  See \fBattributes\fR(5) for descriptions of the following attributes:
 145  145  .sp
 146  146  
 147  147  .sp
 148  148  .TS
 149  149  box;
 150  150  c | c
 151  151  l | l .
 152  152  ATTRIBUTE TYPE  ATTRIBUTE VALUE
 153  153  _
 154  154  Interface Stability     Evolving
 155  155  .TE
 156  156  
 157  157  .SH SEE ALSO
 158  158  .LP
 159  159  \fBpsrinfo\fR(1M), \fBprtconf\fR(1M), \fBpread\fR(2), \fBread\fR(2),
 160  160  \fBattributes\fR(5)
  
    | 
      ↓ open down ↓ | 
    160 lines elided | 
    
      ↑ open up ↑ | 
  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX