Print this page
11844 add rdmsr utility
Reviewed by: Dan McDonald <danmcd@joyent.com>


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
  25  * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
  26  * Copyright 2019, Joyent, Inc.
  27  * Copyright (c) 2014, OmniTI Computer Consulting, Inc. All rights reserved.
  28  */
  29 
  30 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  31 /*        All Rights Reserved   */
  32 
  33 
  34 #include <stdio.h>
  35 #include <stdlib.h>
  36 #include <unistd.h>
  37 #include <sys/types.h>
  38 #include <libproc.h>
  39 
  40 #include <ctype.h>
  41 #include <string.h>
  42 #include <sys/dlpi.h>
  43 #include <sys/ipc.h>
  44 #include <sys/ipc_impl.h>
  45 #include <sys/msg.h>
  46 #include <sys/sem.h>


  86 #include <sys/kbio.h>
  87 #include <sys/ptms.h>
  88 #include <sys/aggr.h>
  89 #include <sys/dld.h>
  90 #include <net/simnet.h>
  91 #include <sys/vnic.h>
  92 #include <sys/fs/zfs.h>
  93 #include <inet/kssl/kssl.h>
  94 #include <sys/dkio.h>
  95 #include <sys/fdio.h>
  96 #include <sys/cdio.h>
  97 #include <sys/scsi/impl/uscsi.h>
  98 #include <sys/devinfo_impl.h>
  99 #include <sys/dumpadm.h>
 100 #include <sys/mntio.h>
 101 #include <inet/iptun.h>
 102 #include <sys/zcons.h>
 103 #include <sys/usb/clients/hid/hid.h>
 104 #include <sys/pm.h>
 105 #include <sys/soundcard.h>

 106 
 107 #include "ramdata.h"
 108 #include "proto.h"
 109 
 110 #define FCNTLMIN        F_DUPFD
 111 #define FCNTLMAX        F_FLOCKW
 112 const char *const FCNTLname[] = {
 113         "F_DUPFD",
 114         "F_GETFD",
 115         "F_SETFD",
 116         "F_GETFL",
 117         "F_SETFL",
 118         "F_O_GETLK",
 119         "F_SETLK",
 120         "F_SETLKW",
 121         "F_CHKFL",
 122         "F_DUP2FD",
 123         "F_ALLOCSP",
 124         "F_FREESP",
 125         NULL,           /* 12 */


1653         { (uint_t)PM_GET_DEVICE_THRESHOLD_BASIS,
1654                 "PM_GET_DEVICE_THRESHOLD_BASIS",        "pm_req_t" },
1655         { (uint_t)PM_SET_CURRENT_POWER,         "PM_SET_CURRENT_POWER",
1656                 "pm_req_t" },
1657         { (uint_t)PM_GET_CURRENT_POWER,         "PM_GET_CURRENT_POWER",
1658                 "pm_req_t" },
1659         { (uint_t)PM_GET_FULL_POWER,            "PM_GET_FULL_POWER",
1660                 "pm_req_t" },
1661         { (uint_t)PM_ADD_DEPENDENT,             "PM_ADD_DEPENDENT",
1662                 "pm_req_t" },
1663         { (uint_t)PM_GET_TIME_IDLE,             "PM_GET_TIME_IDLE",
1664                 "pm_req_t" },
1665         { (uint_t)PM_ADD_DEPENDENT_PROPERTY,    "PM_ADD_DEPENDENT_PROPERTY",
1666                 "pm_req_t" },
1667         { (uint_t)PM_GET_CMD_NAME,              "PM_GET_CMD_NAME",
1668                 "pm_req_t" },
1669         { (uint_t)PM_SEARCH_LIST,       "PM_SEARCH_LIST",
1670                 "pm_searchargs_t" },
1671 #endif /* _SYSCALL */
1672 






1673         { (uint_t)0, NULL, NULL }
1674 };
1675 
1676 void
1677 ioctl_ioccom(char *buf, size_t size, uint_t code, int nbytes, int x, int y)
1678 {
1679         const char *inoutstr;
1680 
1681         if (code & IOC_VOID)
1682                 inoutstr = "";
1683         else if ((code & IOC_INOUT) == IOC_INOUT)
1684                 inoutstr = "WR";
1685         else
1686                 inoutstr = code & IOC_IN ? "W" : "R";
1687 
1688         if (isascii(x) && isprint(x))
1689                 (void) snprintf(buf, size, "_IO%sN('%c', %d, %d)", inoutstr,
1690                     x, y, nbytes);
1691         else
1692                 (void) snprintf(buf, size, "_IO%sN(0x%x, %d, %d)", inoutstr,




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
  25  * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
  26  * Copyright 2019 Joyent, Inc.
  27  * Copyright (c) 2014, OmniTI Computer Consulting, Inc. All rights reserved.
  28  */
  29 
  30 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  31 /*        All Rights Reserved   */
  32 
  33 
  34 #include <stdio.h>
  35 #include <stdlib.h>
  36 #include <unistd.h>
  37 #include <sys/types.h>
  38 #include <libproc.h>
  39 
  40 #include <ctype.h>
  41 #include <string.h>
  42 #include <sys/dlpi.h>
  43 #include <sys/ipc.h>
  44 #include <sys/ipc_impl.h>
  45 #include <sys/msg.h>
  46 #include <sys/sem.h>


  86 #include <sys/kbio.h>
  87 #include <sys/ptms.h>
  88 #include <sys/aggr.h>
  89 #include <sys/dld.h>
  90 #include <net/simnet.h>
  91 #include <sys/vnic.h>
  92 #include <sys/fs/zfs.h>
  93 #include <inet/kssl/kssl.h>
  94 #include <sys/dkio.h>
  95 #include <sys/fdio.h>
  96 #include <sys/cdio.h>
  97 #include <sys/scsi/impl/uscsi.h>
  98 #include <sys/devinfo_impl.h>
  99 #include <sys/dumpadm.h>
 100 #include <sys/mntio.h>
 101 #include <inet/iptun.h>
 102 #include <sys/zcons.h>
 103 #include <sys/usb/clients/hid/hid.h>
 104 #include <sys/pm.h>
 105 #include <sys/soundcard.h>
 106 #include <sys/cpuid_drv.h>
 107 
 108 #include "ramdata.h"
 109 #include "proto.h"
 110 
 111 #define FCNTLMIN        F_DUPFD
 112 #define FCNTLMAX        F_FLOCKW
 113 const char *const FCNTLname[] = {
 114         "F_DUPFD",
 115         "F_GETFD",
 116         "F_SETFD",
 117         "F_GETFL",
 118         "F_SETFL",
 119         "F_O_GETLK",
 120         "F_SETLK",
 121         "F_SETLKW",
 122         "F_CHKFL",
 123         "F_DUP2FD",
 124         "F_ALLOCSP",
 125         "F_FREESP",
 126         NULL,           /* 12 */


1654         { (uint_t)PM_GET_DEVICE_THRESHOLD_BASIS,
1655                 "PM_GET_DEVICE_THRESHOLD_BASIS",        "pm_req_t" },
1656         { (uint_t)PM_SET_CURRENT_POWER,         "PM_SET_CURRENT_POWER",
1657                 "pm_req_t" },
1658         { (uint_t)PM_GET_CURRENT_POWER,         "PM_GET_CURRENT_POWER",
1659                 "pm_req_t" },
1660         { (uint_t)PM_GET_FULL_POWER,            "PM_GET_FULL_POWER",
1661                 "pm_req_t" },
1662         { (uint_t)PM_ADD_DEPENDENT,             "PM_ADD_DEPENDENT",
1663                 "pm_req_t" },
1664         { (uint_t)PM_GET_TIME_IDLE,             "PM_GET_TIME_IDLE",
1665                 "pm_req_t" },
1666         { (uint_t)PM_ADD_DEPENDENT_PROPERTY,    "PM_ADD_DEPENDENT_PROPERTY",
1667                 "pm_req_t" },
1668         { (uint_t)PM_GET_CMD_NAME,              "PM_GET_CMD_NAME",
1669                 "pm_req_t" },
1670         { (uint_t)PM_SEARCH_LIST,       "PM_SEARCH_LIST",
1671                 "pm_searchargs_t" },
1672 #endif /* _SYSCALL */
1673 
1674         /* cpuid ioctls */
1675         { (uint_t)CPUID_GET_HWCAP,              "CPUID_GET_HWCAP", NULL },
1676 #if defined(__i386) || defined(__amd64)
1677         { (uint_t)CPUID_RDMSR,                  "CPUID_RDMSR", NULL },
1678 #endif
1679 
1680         { (uint_t)0, NULL, NULL }
1681 };
1682 
1683 void
1684 ioctl_ioccom(char *buf, size_t size, uint_t code, int nbytes, int x, int y)
1685 {
1686         const char *inoutstr;
1687 
1688         if (code & IOC_VOID)
1689                 inoutstr = "";
1690         else if ((code & IOC_INOUT) == IOC_INOUT)
1691                 inoutstr = "WR";
1692         else
1693                 inoutstr = code & IOC_IN ? "W" : "R";
1694 
1695         if (isascii(x) && isprint(x))
1696                 (void) snprintf(buf, size, "_IO%sN('%c', %d, %d)", inoutstr,
1697                     x, y, nbytes);
1698         else
1699                 (void) snprintf(buf, size, "_IO%sN(0x%x, %d, %d)", inoutstr,