1cpuid(7D)                           Devices                          cpuid(7D)
2
3
4

NAME

6       cpuid - CPU identification driver
7

SYNOPSIS

9       /dev/cpu/self/cpuid
10
11

DESCRIPTION

13   SPARC and x86 system
14       This  device  provides  implementation-private  information  via ioctls
15       about various aspects of the implementation to  Solaris  libraries  and
16       utilities.
17
18   x86 systems only
19       This  device also provides a file-like view of the namespace and return
20       values of the x86 cpuid instruction. The cpuid instruction takes a sin‐
21       gle  32-bit integer function code, and returns four 32-bit integer val‐
22       ues corresponding to the input value that describe various  aspects  of
23       the capabilities and configuration of the processor.
24
25
26       The  API  for the character device consists of using the seek offset to
27       set the function code value, and using a  read(2)  or  pread(2)  of  16
28       bytes  to fetch the four 32-bit return values of the instruction in the
29       order %eax, %ebx, %ecx and %edx.
30
31
32       No data can be written to the device. Like the  cpuid  instruction,  no
33       special privileges are required to use the device.
34
35
36       The  device  is useful to enable low-level configuration information to
37       be extracted from the CPU without having to write any assembler code to
38       invoke  the  cpuid  instruction  directly. It also allows the kernel to
39       attempt to correct any  erroneous  data  returned  by  the  instruction
40       (prompted  by occassional errors in the information exported by various
41       processor implementations over the years).
42
43
44       See the processor manufacturers documentation for  further  information
45       about  the  syntax  and  semantics  of  the wide variety of information
46       available from this instruction.
47

EXAMPLE

49       This example allows you to determine if the current x86 processor  sup‐
50       ports  "long mode," which is a necessary (but not sufficient) condition
51       for running the 64-bit Solaris kernel on the processor.
52
53         /*
54
55         #include <sys/types.h>
56         #include <sys/stat.h>
57         #include <fcntl.h>
58         #include <unistd.h>
59         #include <string.h>
60         #include <errno.h>
61         #include <stdio.h>
62
63         static const char devname[] = "/dev/cpu/self/cpuid";
64
65         /*ARGSUSED*/
66         int
67         main(int argc, char *argv[])
68         {
69                 struct {
70                         uint32_t r_eax, r_ebx, r_ecx, r_edx;
71                 } _r, *rp = &_r;
72                 int d;
73                 char *s;
74
75                 if ((d = open(devname, O_RDONLY)) == -1) {
76                         perror(devname);
77                         return (1);
78                 }
79
80                 if (pread(d, rp, sizeof (*rp), 0) != sizeof (*rp)) {
81                         perror(devname);
82                         goto fail;
83                 }
84
85                 s = (char *)&rp->r_ebx;
86                 if (strncmp(s, "Auth" "cAMD" "enti", 12) != 0 &&
87                     strncmp(s, "Genu" "ntel" "ineI", 12) != 0)
88                         goto fail;
89
90                 if (pread(d, rp, sizeof (*rp), 0x80000001) == sizeof (*rp)) {
91                         /*
92                          * Read extended feature word; check bit 29
93                          */
94                         (void) close(d);
95                         if ((rp->r_edx >> 29) & 1) {
96                                 (void) printf("processor supports long mode\n");
97                                 return (0);
98                         }
99                 }
100         fail:
101                 (void) close(d);
102                 return (1);
103         }
104
105

ERRORS

107       ENXIO     Results from attempting to read data from  the  device  on  a
108                 system  that  does  not support the CPU identification inter‐
109                 faces
110
111
112       EINVAL    Results from reading from an offset larger than UINT_MAX,  or
113                 attempting  to  read  with  a size that is not multiple of 16
114                 bytes.
115
116

FILES

118       /dev/cpu/self/cpuid    Provides access to CPU identification data.
119
120

ATTRIBUTES

122       See attributes(5) for descriptions of the following attributes:
123
124
125
126
127       ┌─────────────────────────────┬─────────────────────────────┐
128       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
129       ├─────────────────────────────┼─────────────────────────────┤
130       │Availability                 │SUNWckr                      │
131       ├─────────────────────────────┼─────────────────────────────┤
132       │Interface Stability          │Evolving                     │
133       └─────────────────────────────┴─────────────────────────────┘
134

SEE ALSO

136       psrinfo(1M), prtconf(1M), pread(2), read(2), attributes(5)
137
138
139
140SunOS 5.11                        16 Sep 2004                        cpuid(7D)
Impressum