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.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * SDBC user level ioctl interface
33 #include <sys/types.h>
37 #include <sys/nsctl/sd_cache.h>
38 #include <sys/nsctl/sd_conf.h>
39 #include <sys/nsctl/sdbc_ioctl.h>
40 #include <sys/unistat/spcs_s.h>
41 #include <sys/unistat/spcs_s_u.h>
43 #include <sys/nsctl/sv.h>
44 #include <sys/nsctl/sv_impl.h>
47 const char *__sdbc_dev
= "/dev/sdbc";
56 fd
= open("/dev/nsctl", O_RDONLY
);
60 fd
= open(__sdbc_dev
, O_RDONLY
);
64 return (__sdbc_fd
= fd
);
72 sv_name_t
*svn_system
;
77 fd
= open(SV_DEVICE
, O_RDONLY
);
81 bzero(&svl
, sizeof (svl
));
82 bzero(&svn
[0], sizeof (svn
));
84 svl
.svl_names
= &svn
[0];
85 svl
.svl_error
= spcs_s_ucreate();
87 if (ioctl(fd
, SVIOC_LIST
, &svl
) < 0)
90 svn_system
= calloc(svl
.svl_maxdevs
, sizeof (*svn
));
91 if (svn_system
== NULL
)
94 /* Grab the system list from the driver */
95 svl
.svl_count
= svl
.svl_maxdevs
;
96 svl
.svl_names
= svn_system
;
98 (void) ioctl(fd
, SVIOC_LIST
, &svl
);
101 spcs_s_ufree(&svl
.svl_error
);
106 sdbc_ioctl(long cmd
, long a0
, long a1
, long a2
, long a3
, long a4
,
107 spcs_s_info_t
*ustatus
)
114 if (!__sdbc_fd
&& __sdbc_open() < 0)
119 * These ioctls work on open cache descriptors. The sv_list() function
120 * has the side-effect of re-opening all configured descriptors.
121 * Without this call, devices seem to "disappear" from the system when
122 * certain reconfiguration operations, for example II or SNDR disable,
124 * It does rely on SV being configured, so in an STE-only environment
125 * the disappearing will still seem to happen.
127 case SDBC_SET_CD_HINT
:
128 case SDBC_GET_CD_HINT
:
130 case SDBC_GET_CD_BLK
:
145 args
.magic
= _SD_MAGIC
; /* for versioning */
146 args
.sdbc_ustatus
= spcs_s_ucreate();
148 if ((rc
= ioctl(__sdbc_fd
, cmd
, &args
)) < 0) {
149 *ustatus
= args
.sdbc_ustatus
;
151 spcs_s_ufree(&args
.sdbc_ustatus
);