Print this page
11630 remove checks for 64-bit capable hardware


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   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  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.

  24  */
  25 
  26 /*
  27  * Ported from 4.1.1_PSRA: "@(#)openprom.c 1.19 91/02/19 SMI";
  28  *
  29  * Porting notes:
  30  *
  31  * OPROMU2P unsupported after SunOS 4.x.
  32  *
  33  * Only one of these devices per system is allowed.
  34  */
  35 
  36 /*
  37  * Openprom eeprom options/devinfo driver.
  38  */
  39 
  40 #include <sys/types.h>
  41 #include <sys/errno.h>
  42 #include <sys/file.h>
  43 #include <sys/cmn_err.h>


 473         case OPROMSETNODEID:
 474                 if ((mode & FREAD) == 0) {
 475                         return (EPERM);
 476                 }
 477                 node_id = st->current_id;
 478                 break;
 479         case OPROMCOPYOUT:
 480                 if (st->snapshot == NULL)
 481                         return (EINVAL);
 482                 /*FALLTHROUGH*/
 483         case OPROMSNAPSHOT:
 484         case OPROMGETCONS:
 485         case OPROMGETBOOTARGS:
 486         case OPROMGETBOOTPATH:
 487         case OPROMGETVERSION:
 488         case OPROMPATH2DRV:
 489         case OPROMPROM2DEVNAME:
 490 #if !defined(__i386) && !defined(__amd64)
 491         case OPROMGETFBNAME:
 492         case OPROMDEV2PROMNAME:
 493         case OPROMREADY64:
 494 #endif  /* !__i386 && !__amd64 */
 495                 if ((mode & FREAD) == 0) {
 496                         return (EPERM);
 497                 }
 498                 break;
 499 
 500         default:
 501                 return (EINVAL);
 502         }
 503 
 504         /*
 505          * Deal with SNAPSHOT and COPYOUT ioctls first
 506          */
 507         switch (cmd) {
 508         case OPROMCOPYOUT:
 509                 return (oprom_copyout(st, arg));
 510 
 511         case OPROMSNAPSHOT:
 512                 return (oprom_snapshot(st, arg));
 513         }


 960                         valsize = valbuflen + 1;  /* +1 for the '\0' */
 961                 } else {
 962                         if ((namebuflen + 1 + valbuflen + 1) > userbufsize) {
 963                                 error = EINVAL;
 964                                 break;
 965                         }
 966                         valsize = (opp->oprom_array + userbufsize) - valbuf;
 967                 }
 968 
 969                 /*
 970                  * 4010173: 'name' is not an option, but it is a property.
 971                  */
 972                 if (strcmp(opp->oprom_array, "name") == 0)
 973                         error = EINVAL;
 974                 else if (prom_setprop(node_id, opp->oprom_array,
 975                     valbuf, valsize) < 0)
 976                         error = EINVAL;
 977 
 978                 break;
 979         }
 980 
 981         case OPROMREADY64: {
 982                 struct openprom_opr64 *opr =
 983                     (struct openprom_opr64 *)opp->oprom_array;
 984                 int i;
 985                 pnode_t id;
 986 
 987                 if (userbufsize < sizeof (*opr)) {
 988                         error = EINVAL;
 989                         break;
 990                 }
 991 
 992                 valsize = userbufsize -
 993                     offsetof(struct openprom_opr64, message);
 994 
 995                 i = prom_version_check(opr->message, valsize, &id);
 996                 opr->return_code = i;
 997                 opr->nodeid = (int)id;
 998 
 999                 valsize = offsetof(struct openprom_opr64, message);
1000                 valsize += strlen(opr->message) + 1;
1001 
1002                 /*
1003                  * copyout only the part of the user buffer we need to.
1004                  */
1005                 if (copyout(opp, (void *)arg,
1006                     (size_t)(min((uint_t)valsize, userbufsize) +
1007                     sizeof (uint_t))) != 0)
1008                         error = EFAULT;
1009                 break;
1010 
1011         }       /* case OPROMREADY64 */
1012 #endif  /* !__i386 && !__amd64 */
1013         }       /* switch (cmd) */
1014 
1015         kmem_free(opp, userbufsize + sizeof (uint_t) + 1);
1016         return (error);
1017 }
1018 
1019 /*ARGSUSED*/
1020 static int
1021 opromioctl(dev_t dev, int cmd, intptr_t arg, int mode,
1022     cred_t *credp, int *rvalp)
1023 {
1024         struct oprom_state *st;
1025         struct opromioctl_args arg_block;
1026 
1027         if (getminor(dev) >= MAX_OPENS)
1028                 return (ENXIO);
1029 
1030         st = &oprom_state[getminor(dev)];
1031         ASSERT(st->already_open);




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   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  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2019 Peter Tribble.
  25  */
  26 
  27 /*
  28  * Ported from 4.1.1_PSRA: "@(#)openprom.c 1.19 91/02/19 SMI";
  29  *
  30  * Porting notes:
  31  *
  32  * OPROMU2P unsupported after SunOS 4.x.
  33  *
  34  * Only one of these devices per system is allowed.
  35  */
  36 
  37 /*
  38  * Openprom eeprom options/devinfo driver.
  39  */
  40 
  41 #include <sys/types.h>
  42 #include <sys/errno.h>
  43 #include <sys/file.h>
  44 #include <sys/cmn_err.h>


 474         case OPROMSETNODEID:
 475                 if ((mode & FREAD) == 0) {
 476                         return (EPERM);
 477                 }
 478                 node_id = st->current_id;
 479                 break;
 480         case OPROMCOPYOUT:
 481                 if (st->snapshot == NULL)
 482                         return (EINVAL);
 483                 /*FALLTHROUGH*/
 484         case OPROMSNAPSHOT:
 485         case OPROMGETCONS:
 486         case OPROMGETBOOTARGS:
 487         case OPROMGETBOOTPATH:
 488         case OPROMGETVERSION:
 489         case OPROMPATH2DRV:
 490         case OPROMPROM2DEVNAME:
 491 #if !defined(__i386) && !defined(__amd64)
 492         case OPROMGETFBNAME:
 493         case OPROMDEV2PROMNAME:

 494 #endif  /* !__i386 && !__amd64 */
 495                 if ((mode & FREAD) == 0) {
 496                         return (EPERM);
 497                 }
 498                 break;
 499 
 500         default:
 501                 return (EINVAL);
 502         }
 503 
 504         /*
 505          * Deal with SNAPSHOT and COPYOUT ioctls first
 506          */
 507         switch (cmd) {
 508         case OPROMCOPYOUT:
 509                 return (oprom_copyout(st, arg));
 510 
 511         case OPROMSNAPSHOT:
 512                 return (oprom_snapshot(st, arg));
 513         }


 960                         valsize = valbuflen + 1;  /* +1 for the '\0' */
 961                 } else {
 962                         if ((namebuflen + 1 + valbuflen + 1) > userbufsize) {
 963                                 error = EINVAL;
 964                                 break;
 965                         }
 966                         valsize = (opp->oprom_array + userbufsize) - valbuf;
 967                 }
 968 
 969                 /*
 970                  * 4010173: 'name' is not an option, but it is a property.
 971                  */
 972                 if (strcmp(opp->oprom_array, "name") == 0)
 973                         error = EINVAL;
 974                 else if (prom_setprop(node_id, opp->oprom_array,
 975                     valbuf, valsize) < 0)
 976                         error = EINVAL;
 977 
 978                 break;
 979         }
































 980 #endif  /* !__i386 && !__amd64 */
 981         }       /* switch (cmd) */
 982 
 983         kmem_free(opp, userbufsize + sizeof (uint_t) + 1);
 984         return (error);
 985 }
 986 
 987 /*ARGSUSED*/
 988 static int
 989 opromioctl(dev_t dev, int cmd, intptr_t arg, int mode,
 990     cred_t *credp, int *rvalp)
 991 {
 992         struct oprom_state *st;
 993         struct opromioctl_args arg_block;
 994 
 995         if (getminor(dev) >= MAX_OPENS)
 996                 return (ENXIO);
 997 
 998         st = &oprom_state[getminor(dev)];
 999         ASSERT(st->already_open);