Print this page
    
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/man/man7d/cpuid.7d.man.txt
          +++ new/usr/src/man/man7d/cpuid.7d.man.txt
   1    1  CPUID(7D)                           Devices                          CPUID(7D)
   2    2  
   3    3  
   4    4  
   5    5  NAME
   6    6         cpuid - CPU identification driver
   7    7  
   8    8  SYNOPSIS
   9    9         /dev/cpu/self/cpuid
  10   10  
  11   11  
  12   12  DESCRIPTION
  13   13     SPARC and x86 system
  14   14         This device provides implementation-private information via ioctls
  15   15         about various aspects of the implementation to Solaris libraries and
  16   16         utilities.
  17   17  
  18   18     x86 systems only
  19   19         This device also provides a file-like view of the namespace and return
  20   20         values of the x86 cpuid instruction. The cpuid instruction takes a
  21   21         single 32-bit integer function code, and returns four 32-bit integer
  22   22         values corresponding to the input value that describe various aspects
  23   23         of the capabilities and configuration of the processor.
  24   24  
  25   25         The API for the character device consists of using the seek offset to
  26   26         set the function code value, and using a read(2) or pread(2) of 16
  27   27         bytes to fetch the four 32-bit return values of the instruction in the
  28   28         order %eax, %ebx, %ecx and %edx.
  29   29  
  30   30         No data can be written to the device. Like the cpuid instruction, no
  31   31         special privileges are required to use the device.
  32   32  
  33   33         The device is useful to enable low-level configuration information to
  34   34         be extracted from the CPU without having to write any assembler code to
  35   35         invoke the cpuid instruction directly. It also allows the kernel to
  36   36         attempt to correct any erroneous data returned by the instruction
  37   37         (prompted by occasional errors in the information exported by various
  38   38         processor implementations over the years).
  39   39  
  40   40         See the processor manufacturers documentation for further information
  41   41         about the syntax and semantics of the wide variety of information
  42   42         available from this instruction.
  43   43  
  44   44         Some systems can be configured to limit the cpuid opcodes which are
  45   45         accessible.  While illumos handles this condition, other software may
  46   46         malfunction when such limits are enabled.  Those settings are typically
  47   47         manipulated in the BIOS.
  48   48  
  49   49  EXAMPLE
  50   50         This example allows you to determine if the current x86 processor
  51   51         supports "long mode," which is a necessary (but not sufficient)
  52   52         condition for running the 64-bit Solaris kernel on the processor.
  53   53  
  54   54           /*
  55   55  
  56   56           #include <sys/types.h>
  57   57           #include <sys/stat.h>
  58   58           #include <fcntl.h>
  59   59           #include <unistd.h>
  60   60           #include <string.h>
  61   61           #include <errno.h>
  62   62           #include <stdio.h>
  63   63  
  64   64           static const char devname[] = "/dev/cpu/self/cpuid";
  65   65  
  66   66           /*ARGSUSED*/
  67   67           int
  68   68           main(int argc, char *argv[])
  69   69           {
  70   70                   struct {
  71   71                           uint32_t r_eax, r_ebx, r_ecx, r_edx;
  72   72                   } _r, *rp = &_r;
  73   73                   int d;
  74   74                   char *s;
  75   75  
  76   76                   if ((d = open(devname, O_RDONLY)) == -1) {
  77   77                           perror(devname);
  78   78                           return (1);
  79   79                   }
  80   80  
  81   81                   if (pread(d, rp, sizeof (*rp), 0) != sizeof (*rp)) {
  82   82                           perror(devname);
  83   83                           goto fail;
  84   84                   }
  85   85  
  86   86                   s = (char *)&rp->r_ebx;
  87   87                   if (strncmp(s, "Auth" "cAMD" "enti", 12) != 0 &&
  88   88                       strncmp(s, "Genu" "ntel" "ineI", 12) != 0)
  89   89                           goto fail;
  90   90  
  91   91                   if (pread(d, rp, sizeof (*rp), 0x80000001) == sizeof (*rp)) {
  92   92                           /*
  93   93                            * Read extended feature word; check bit 29
  94   94                            */
  95   95                           (void) close(d);
  96   96                           if ((rp->r_edx >> 29) & 1) {
  97   97                                   (void) printf("processor supports long mode\n");
  98   98                                   return (0);
  99   99                           }
 100  100                   }
 101  101           fail:
 102  102                   (void) close(d);
 103  103                   return (1);
 104  104           }
 105  105  
 106  106  
 107  107  ERRORS
 108  108         ENXIO
 109  109                   Results from attempting to read data from the device on a
 110  110                   system that does not support the CPU identification
 111  111                   interfaces
 112  112  
 113  113  
 114  114         EINVAL
 115  115                   Results from reading from an offset larger than UINT_MAX, or
 116  116                   attempting to read with a size that is not multiple of 16
 117  117                   bytes.
 118  118  
 119  119  
 120  120  FILES
 121  121         /dev/cpu/self/cpuid
 122  122                                Provides access to CPU identification data.
 123  123  
 124  124  
 125  125  ATTRIBUTES
 126  126         See attributes(5) for descriptions of the following attributes:
 127  127  
 128  128  
 129  129  
 130  130  
 131  131         +--------------------+-----------------+
 132  132         |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 133  133         +--------------------+-----------------+
 134  134         |Interface Stability | Evolving        |
 135  135         +--------------------+-----------------+
 136  136  
 137  137  SEE ALSO
 138  138         psrinfo(1M), prtconf(1M), pread(2), read(2), attributes(5)
 139  139  
 140  140  
 141  141  
 142  142                                   April 9, 2016                       CPUID(7D)
  
    | 
      ↓ open down ↓ | 
    142 lines elided | 
    
      ↑ open up ↑ | 
  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX