17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*19397407SSherry Moore * Common Development and Distribution License (the "License"). 6*19397407SSherry Moore * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*19397407SSherry Moore * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #include <sys/types.h> 287c478bd9Sstevel@tonic-gate #include <sys/stat.h> 297c478bd9Sstevel@tonic-gate #include <sys/conf.h> 307c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 317c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 327c478bd9Sstevel@tonic-gate #include <sys/callb.h> 337c478bd9Sstevel@tonic-gate #include <sys/strlog.h> 347c478bd9Sstevel@tonic-gate #include <sys/file.h> 357c478bd9Sstevel@tonic-gate #include <sys/lom_io.h> 367c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 377c478bd9Sstevel@tonic-gate #include <sys/time.h> 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #define LOMIOCALCTL_OLD _IOW('a', 4, ts_aldata_t) 407c478bd9Sstevel@tonic-gate #define LOMIOCALSTATE_OLD _IOWR('a', 5, ts_aldata_t) 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate struct tsalarm_softc { 437c478bd9Sstevel@tonic-gate dev_info_t *dip; 447c478bd9Sstevel@tonic-gate kmutex_t mutex; 457c478bd9Sstevel@tonic-gate }; 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #define getsoftc(minor) \ 487c478bd9Sstevel@tonic-gate ((struct tsalarm_softc *)ddi_get_soft_state(statep, (minor))) 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * Driver entry points 517c478bd9Sstevel@tonic-gate */ 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* dev_ops and cb_ops entry point function declarations */ 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate static int tsalarm_attach(dev_info_t *, ddi_attach_cmd_t); 567c478bd9Sstevel@tonic-gate static int tsalarm_detach(dev_info_t *, ddi_detach_cmd_t); 577c478bd9Sstevel@tonic-gate static int tsalarm_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **); 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate static int tsalarm_open(dev_t *, int, int, cred_t *); 607c478bd9Sstevel@tonic-gate static int tsalarm_close(dev_t, int, int, cred_t *); 617c478bd9Sstevel@tonic-gate static int tsalarm_ioctl(dev_t, int, intptr_t, int, cred_t *, int *); 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate static struct cb_ops tsalarm_cb_ops = { 647c478bd9Sstevel@tonic-gate tsalarm_open, /* open */ 657c478bd9Sstevel@tonic-gate tsalarm_close, /* close */ 667c478bd9Sstevel@tonic-gate nodev, /* strategy() */ 677c478bd9Sstevel@tonic-gate nodev, /* print() */ 687c478bd9Sstevel@tonic-gate nodev, /* dump() */ 697c478bd9Sstevel@tonic-gate nodev, /* read() */ 707c478bd9Sstevel@tonic-gate nodev, /* write() */ 717c478bd9Sstevel@tonic-gate tsalarm_ioctl, /* ioctl() */ 727c478bd9Sstevel@tonic-gate nodev, /* devmap() */ 737c478bd9Sstevel@tonic-gate nodev, /* mmap() */ 747c478bd9Sstevel@tonic-gate ddi_segmap, /* segmap() */ 757c478bd9Sstevel@tonic-gate nochpoll, /* poll() */ 767c478bd9Sstevel@tonic-gate ddi_prop_op, /* prop_op() */ 777c478bd9Sstevel@tonic-gate NULL, /* cb_str */ 787c478bd9Sstevel@tonic-gate D_NEW | D_MP /* cb_flag */ 797c478bd9Sstevel@tonic-gate }; 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate static struct dev_ops tsalarm_ops = { 837c478bd9Sstevel@tonic-gate DEVO_REV, 847c478bd9Sstevel@tonic-gate 0, /* ref count */ 857c478bd9Sstevel@tonic-gate tsalarm_getinfo, /* getinfo() */ 867c478bd9Sstevel@tonic-gate nulldev, /* identify() */ 877c478bd9Sstevel@tonic-gate nulldev, /* probe() */ 887c478bd9Sstevel@tonic-gate tsalarm_attach, /* attach() */ 897c478bd9Sstevel@tonic-gate tsalarm_detach, /* detach */ 907c478bd9Sstevel@tonic-gate nodev, /* reset */ 917c478bd9Sstevel@tonic-gate &tsalarm_cb_ops, /* pointer to cb_ops structure */ 927c478bd9Sstevel@tonic-gate (struct bus_ops *)NULL, 93*19397407SSherry Moore nulldev, /* power() */ 94*19397407SSherry Moore ddi_quiesce_not_needed, /* quiesce() */ 957c478bd9Sstevel@tonic-gate }; 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * Loadable module support. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate extern struct mod_ops mod_driverops; 1017c478bd9Sstevel@tonic-gate static void *statep; 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate static struct modldrv modldrv = { 1047c478bd9Sstevel@tonic-gate &mod_driverops, /* Type of module. This is a driver */ 105*19397407SSherry Moore "tsalarm control driver", /* Name of the module */ 1067c478bd9Sstevel@tonic-gate &tsalarm_ops /* pointer to the dev_ops structure */ 1077c478bd9Sstevel@tonic-gate }; 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = { 1107c478bd9Sstevel@tonic-gate MODREV_1, 1117c478bd9Sstevel@tonic-gate &modldrv, 1127c478bd9Sstevel@tonic-gate NULL 1137c478bd9Sstevel@tonic-gate }; 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate extern int rmclomv_alarm_get(int alarm_type, int *alarm_state); 1167c478bd9Sstevel@tonic-gate extern int rmclomv_alarm_set(int alarm_type, int new_state); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate int 1197c478bd9Sstevel@tonic-gate _init(void) 1207c478bd9Sstevel@tonic-gate { 1217c478bd9Sstevel@tonic-gate int e; 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate if (e = ddi_soft_state_init(&statep, 1247c478bd9Sstevel@tonic-gate sizeof (struct tsalarm_softc), 1)) { 1257c478bd9Sstevel@tonic-gate return (e); 1267c478bd9Sstevel@tonic-gate } 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate if ((e = mod_install(&modlinkage)) != 0) { 1297c478bd9Sstevel@tonic-gate ddi_soft_state_fini(&statep); 1307c478bd9Sstevel@tonic-gate } 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate return (e); 1337c478bd9Sstevel@tonic-gate } 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate int 1377c478bd9Sstevel@tonic-gate _fini(void) 1387c478bd9Sstevel@tonic-gate { 1397c478bd9Sstevel@tonic-gate int e; 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate if ((e = mod_remove(&modlinkage)) != 0) { 1427c478bd9Sstevel@tonic-gate return (e); 1437c478bd9Sstevel@tonic-gate } 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate ddi_soft_state_fini(&statep); 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 1487c478bd9Sstevel@tonic-gate } 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate int 1527c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop) 1537c478bd9Sstevel@tonic-gate { 1547c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 1557c478bd9Sstevel@tonic-gate } 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1597c478bd9Sstevel@tonic-gate static int 1607c478bd9Sstevel@tonic-gate tsalarm_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result) 1617c478bd9Sstevel@tonic-gate { 1627c478bd9Sstevel@tonic-gate int inst = getminor((dev_t)arg); 1637c478bd9Sstevel@tonic-gate int retval = DDI_SUCCESS; 1647c478bd9Sstevel@tonic-gate struct tsalarm_softc *softc; 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate switch (cmd) { 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2DEVINFO: 1697c478bd9Sstevel@tonic-gate if ((softc = getsoftc(inst)) == NULL) { 1707c478bd9Sstevel@tonic-gate *result = (void *)NULL; 1717c478bd9Sstevel@tonic-gate retval = DDI_FAILURE; 1727c478bd9Sstevel@tonic-gate } else { 1737c478bd9Sstevel@tonic-gate *result = (void *)softc->dip; 1747c478bd9Sstevel@tonic-gate } 1757c478bd9Sstevel@tonic-gate break; 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2INSTANCE: 178d15360a7Ssc121708 *result = (void *)(uintptr_t)inst; 1797c478bd9Sstevel@tonic-gate break; 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate default: 1827c478bd9Sstevel@tonic-gate retval = DDI_FAILURE; 1837c478bd9Sstevel@tonic-gate } 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate return (retval); 1867c478bd9Sstevel@tonic-gate } 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate static int 1897c478bd9Sstevel@tonic-gate tsalarm_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) 1907c478bd9Sstevel@tonic-gate { 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate int inst; 1937c478bd9Sstevel@tonic-gate struct tsalarm_softc *softc = NULL; 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate switch (cmd) { 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate case DDI_ATTACH: 1987c478bd9Sstevel@tonic-gate inst = ddi_get_instance(dip); 1997c478bd9Sstevel@tonic-gate /* 2007c478bd9Sstevel@tonic-gate * Allocate a soft state structure for this instance. 2017c478bd9Sstevel@tonic-gate */ 2027c478bd9Sstevel@tonic-gate if (ddi_soft_state_zalloc(statep, inst) != DDI_SUCCESS) 2037c478bd9Sstevel@tonic-gate goto attach_failed; 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate softc = getsoftc(inst); 2067c478bd9Sstevel@tonic-gate softc->dip = dip; 2077c478bd9Sstevel@tonic-gate mutex_init(&softc->mutex, NULL, MUTEX_DRIVER, NULL); 2087c478bd9Sstevel@tonic-gate /* 2097c478bd9Sstevel@tonic-gate * Create minor node. The minor device number, inst, has no 2107c478bd9Sstevel@tonic-gate * meaning. The model number above, which will be added to 2117c478bd9Sstevel@tonic-gate * the device's softc, is used to direct peculiar behavior. 2127c478bd9Sstevel@tonic-gate */ 2137c478bd9Sstevel@tonic-gate if (ddi_create_minor_node(dip, "lom", S_IFCHR, 0, 2147c478bd9Sstevel@tonic-gate DDI_PSEUDO, NULL) == DDI_FAILURE) 2157c478bd9Sstevel@tonic-gate goto attach_failed; 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate ddi_report_dev(dip); 2187c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate case DDI_RESUME: 2217c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate default: 2247c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 2257c478bd9Sstevel@tonic-gate } 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate attach_failed: 2287c478bd9Sstevel@tonic-gate /* Free soft state, if allocated. remove minor node if added earlier */ 2297c478bd9Sstevel@tonic-gate if (softc) { 2307c478bd9Sstevel@tonic-gate mutex_destroy(&softc->mutex); 2317c478bd9Sstevel@tonic-gate ddi_soft_state_free(statep, inst); 2327c478bd9Sstevel@tonic-gate } 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate ddi_remove_minor_node(dip, NULL); 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 2377c478bd9Sstevel@tonic-gate } 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate static int 2407c478bd9Sstevel@tonic-gate tsalarm_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) 2417c478bd9Sstevel@tonic-gate { 2427c478bd9Sstevel@tonic-gate int inst; 2437c478bd9Sstevel@tonic-gate struct tsalarm_softc *softc; 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate switch (cmd) { 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate case DDI_DETACH: 2487c478bd9Sstevel@tonic-gate inst = ddi_get_instance(dip); 2497c478bd9Sstevel@tonic-gate if ((softc = getsoftc(inst)) == NULL) 2507c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 2517c478bd9Sstevel@tonic-gate /* 2527c478bd9Sstevel@tonic-gate * Free the soft state and remove minor node added earlier. 2537c478bd9Sstevel@tonic-gate */ 2547c478bd9Sstevel@tonic-gate ddi_remove_minor_node(dip, NULL); 2557c478bd9Sstevel@tonic-gate mutex_destroy(&softc->mutex); 2567c478bd9Sstevel@tonic-gate ddi_soft_state_free(statep, inst); 2577c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate case DDI_SUSPEND: 2607c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate default: 2637c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate } 2667c478bd9Sstevel@tonic-gate } 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2697c478bd9Sstevel@tonic-gate static int 2707c478bd9Sstevel@tonic-gate tsalarm_open(dev_t *devp, int flag, int otyp, cred_t *credp) 2717c478bd9Sstevel@tonic-gate { 2727c478bd9Sstevel@tonic-gate int inst = getminor(*devp); 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate return (getsoftc(inst) == NULL ? ENXIO : 0); 2757c478bd9Sstevel@tonic-gate } 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2797c478bd9Sstevel@tonic-gate static int 2807c478bd9Sstevel@tonic-gate tsalarm_close(dev_t dev, int flag, int otyp, cred_t *credp) 2817c478bd9Sstevel@tonic-gate { 2827c478bd9Sstevel@tonic-gate int inst = getminor(dev); 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate return (getsoftc(inst) == NULL ? ENXIO : 0); 2857c478bd9Sstevel@tonic-gate } 2867c478bd9Sstevel@tonic-gate 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2897c478bd9Sstevel@tonic-gate static int 2907c478bd9Sstevel@tonic-gate tsalarm_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, 2917c478bd9Sstevel@tonic-gate cred_t *credp, int *rvalp) 2927c478bd9Sstevel@tonic-gate { 2937c478bd9Sstevel@tonic-gate int inst = getminor(dev); 2947c478bd9Sstevel@tonic-gate struct tsalarm_softc *softc; 2957c478bd9Sstevel@tonic-gate int retval = 0; 2967c478bd9Sstevel@tonic-gate ts_aldata_t ts_alinfo; 2977c478bd9Sstevel@tonic-gate int alarm_type, alarm_state = 0; 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate if ((softc = getsoftc(inst)) == NULL) 3007c478bd9Sstevel@tonic-gate return (ENXIO); 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate mutex_enter(&softc->mutex); 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate switch (cmd) { 3057c478bd9Sstevel@tonic-gate 3067c478bd9Sstevel@tonic-gate case LOMIOCALSTATE: 3077c478bd9Sstevel@tonic-gate case LOMIOCALSTATE_OLD: 3087c478bd9Sstevel@tonic-gate { 3097c478bd9Sstevel@tonic-gate if (ddi_copyin((caddr_t)arg, (caddr_t)&ts_alinfo, 3107c478bd9Sstevel@tonic-gate sizeof (ts_aldata_t), mode) != 0) { 3117c478bd9Sstevel@tonic-gate retval = EFAULT; 3127c478bd9Sstevel@tonic-gate goto end; 3137c478bd9Sstevel@tonic-gate } 3147c478bd9Sstevel@tonic-gate 3157c478bd9Sstevel@tonic-gate alarm_type = ts_alinfo.alarm_no; 3167c478bd9Sstevel@tonic-gate if ((alarm_type < ALARM_CRITICAL) || 3177c478bd9Sstevel@tonic-gate (alarm_type > ALARM_USER)) { 3187c478bd9Sstevel@tonic-gate retval = EINVAL; 3197c478bd9Sstevel@tonic-gate goto end; 3207c478bd9Sstevel@tonic-gate } 3217c478bd9Sstevel@tonic-gate 3227c478bd9Sstevel@tonic-gate retval = rmclomv_alarm_get(alarm_type, &alarm_state); 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate if (retval != 0) 3257c478bd9Sstevel@tonic-gate goto end; 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate if ((alarm_state != 0) && (alarm_state != 1)) { 3287c478bd9Sstevel@tonic-gate retval = EIO; 3297c478bd9Sstevel@tonic-gate goto end; 3307c478bd9Sstevel@tonic-gate } 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate ts_alinfo.alarm_state = alarm_state; 3337c478bd9Sstevel@tonic-gate if (ddi_copyout((caddr_t)&ts_alinfo, (caddr_t)arg, 3347c478bd9Sstevel@tonic-gate sizeof (ts_aldata_t), mode) != 0) { 3357c478bd9Sstevel@tonic-gate retval = EFAULT; 3367c478bd9Sstevel@tonic-gate goto end; 3377c478bd9Sstevel@tonic-gate } 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate } 3407c478bd9Sstevel@tonic-gate break; 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate case LOMIOCALCTL: 3437c478bd9Sstevel@tonic-gate case LOMIOCALCTL_OLD: 3447c478bd9Sstevel@tonic-gate { 3457c478bd9Sstevel@tonic-gate if (ddi_copyin((caddr_t)arg, (caddr_t)&ts_alinfo, 3467c478bd9Sstevel@tonic-gate sizeof (ts_aldata_t), mode) != 0) { 3477c478bd9Sstevel@tonic-gate retval = EFAULT; 3487c478bd9Sstevel@tonic-gate goto end; 3497c478bd9Sstevel@tonic-gate } 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate alarm_type = ts_alinfo.alarm_no; 3527c478bd9Sstevel@tonic-gate alarm_state = ts_alinfo.alarm_state; 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate if ((alarm_type < ALARM_CRITICAL) || 3557c478bd9Sstevel@tonic-gate (alarm_type > ALARM_USER)) { 3567c478bd9Sstevel@tonic-gate retval = EINVAL; 3577c478bd9Sstevel@tonic-gate goto end; 3587c478bd9Sstevel@tonic-gate } 3597c478bd9Sstevel@tonic-gate if ((alarm_state < ALARM_OFF) || 3607c478bd9Sstevel@tonic-gate (alarm_state > ALARM_ON)) { 3617c478bd9Sstevel@tonic-gate retval = EINVAL; 3627c478bd9Sstevel@tonic-gate goto end; 3637c478bd9Sstevel@tonic-gate } 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate retval = rmclomv_alarm_set(alarm_type, alarm_state); 3667c478bd9Sstevel@tonic-gate } 3677c478bd9Sstevel@tonic-gate break; 3687c478bd9Sstevel@tonic-gate 3697c478bd9Sstevel@tonic-gate default: 3707c478bd9Sstevel@tonic-gate retval = EINVAL; 3717c478bd9Sstevel@tonic-gate break; 3727c478bd9Sstevel@tonic-gate } 3737c478bd9Sstevel@tonic-gate 3747c478bd9Sstevel@tonic-gate end: 3757c478bd9Sstevel@tonic-gate mutex_exit(&softc->mutex); 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate return (retval); 3787c478bd9Sstevel@tonic-gate } 379