1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM *
4*7836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM *
8*7836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM * and limitations under the License.
12*7836SJohn.Forte@Sun.COM *
13*7836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM *
19*7836SJohn.Forte@Sun.COM * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23*7836SJohn.Forte@Sun.COM * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM */
25*7836SJohn.Forte@Sun.COM
26*7836SJohn.Forte@Sun.COM /*
27*7836SJohn.Forte@Sun.COM * This file contains interface code to make the kernel look it has
28*7836SJohn.Forte@Sun.COM * an svr4.2 ddi/ddk. It also adds a little other system dependent
29*7836SJohn.Forte@Sun.COM * functionality that is useful for drivers lower than nsctl.
30*7836SJohn.Forte@Sun.COM */
31*7836SJohn.Forte@Sun.COM
32*7836SJohn.Forte@Sun.COM #include <sys/types.h>
33*7836SJohn.Forte@Sun.COM #ifndef DS_DDICT
34*7836SJohn.Forte@Sun.COM #include <sys/time.h> /* only DDI compliant as of 5.9 */
35*7836SJohn.Forte@Sun.COM #endif
36*7836SJohn.Forte@Sun.COM #include <sys/param.h>
37*7836SJohn.Forte@Sun.COM #include <sys/errno.h>
38*7836SJohn.Forte@Sun.COM #include <sys/kmem.h>
39*7836SJohn.Forte@Sun.COM #include <sys/ksynch.h>
40*7836SJohn.Forte@Sun.COM #include <sys/cmn_err.h>
41*7836SJohn.Forte@Sun.COM #include <sys/uio.h>
42*7836SJohn.Forte@Sun.COM #include <sys/conf.h>
43*7836SJohn.Forte@Sun.COM #include <sys/modctl.h>
44*7836SJohn.Forte@Sun.COM #ifndef DS_DDICT
45*7836SJohn.Forte@Sun.COM #include <sys/vnode.h>
46*7836SJohn.Forte@Sun.COM #endif
47*7836SJohn.Forte@Sun.COM #include <sys/open.h>
48*7836SJohn.Forte@Sun.COM #include <sys/ddi.h>
49*7836SJohn.Forte@Sun.COM
50*7836SJohn.Forte@Sun.COM #include "nsc_thread.h"
51*7836SJohn.Forte@Sun.COM
52*7836SJohn.Forte@Sun.COM #ifdef DS_DDICT
53*7836SJohn.Forte@Sun.COM #include <sys/nsctl/contract.h>
54*7836SJohn.Forte@Sun.COM #endif
55*7836SJohn.Forte@Sun.COM
56*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsctl.h>
57*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsvers.h>
58*7836SJohn.Forte@Sun.COM #include "nskernd.h"
59*7836SJohn.Forte@Sun.COM #include "nsc_list.h"
60*7836SJohn.Forte@Sun.COM
61*7836SJohn.Forte@Sun.COM kmutex_t _nskern_lock;
62*7836SJohn.Forte@Sun.COM
63*7836SJohn.Forte@Sun.COM void _nsc_stop_proc(void);
64*7836SJohn.Forte@Sun.COM void _nsc_start_proc(void);
65*7836SJohn.Forte@Sun.COM
66*7836SJohn.Forte@Sun.COM
67*7836SJohn.Forte@Sun.COM /*
68*7836SJohn.Forte@Sun.COM * Solaris specific driver module interface code.
69*7836SJohn.Forte@Sun.COM */
70*7836SJohn.Forte@Sun.COM
71*7836SJohn.Forte@Sun.COM static struct cb_ops nskern_cb_ops = {
72*7836SJohn.Forte@Sun.COM nulldev, /* open */
73*7836SJohn.Forte@Sun.COM nulldev, /* close */
74*7836SJohn.Forte@Sun.COM nodev, /* strategy */
75*7836SJohn.Forte@Sun.COM nodev, /* print */
76*7836SJohn.Forte@Sun.COM nodev, /* dump */
77*7836SJohn.Forte@Sun.COM nodev, /* read */
78*7836SJohn.Forte@Sun.COM nodev, /* write */
79*7836SJohn.Forte@Sun.COM nodev, /* ioctl */
80*7836SJohn.Forte@Sun.COM nodev, /* devmap routine */
81*7836SJohn.Forte@Sun.COM nodev, /* mmap routine */
82*7836SJohn.Forte@Sun.COM nodev, /* segmap */
83*7836SJohn.Forte@Sun.COM nochpoll, /* chpoll */
84*7836SJohn.Forte@Sun.COM ddi_prop_op,
85*7836SJohn.Forte@Sun.COM 0, /* not a STREAMS driver, no cb_str routine */
86*7836SJohn.Forte@Sun.COM D_NEW | D_MP | D_64BIT, /* safe for multi-thread/multi-processor */
87*7836SJohn.Forte@Sun.COM CB_REV,
88*7836SJohn.Forte@Sun.COM nodev, /* aread */
89*7836SJohn.Forte@Sun.COM nodev, /* awrite */
90*7836SJohn.Forte@Sun.COM };
91*7836SJohn.Forte@Sun.COM
92*7836SJohn.Forte@Sun.COM static int _nskern_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
93*7836SJohn.Forte@Sun.COM static int _nskern_attach(dev_info_t *, ddi_attach_cmd_t);
94*7836SJohn.Forte@Sun.COM static int _nskern_detach(dev_info_t *, ddi_detach_cmd_t);
95*7836SJohn.Forte@Sun.COM
96*7836SJohn.Forte@Sun.COM static struct dev_ops nskern_ops = {
97*7836SJohn.Forte@Sun.COM DEVO_REV, /* Driver build version */
98*7836SJohn.Forte@Sun.COM 0, /* device reference count */
99*7836SJohn.Forte@Sun.COM _nskern_getinfo,
100*7836SJohn.Forte@Sun.COM nulldev, /* identify */
101*7836SJohn.Forte@Sun.COM nulldev, /* probe */
102*7836SJohn.Forte@Sun.COM _nskern_attach,
103*7836SJohn.Forte@Sun.COM _nskern_detach,
104*7836SJohn.Forte@Sun.COM nodev, /* reset */
105*7836SJohn.Forte@Sun.COM &nskern_cb_ops,
106*7836SJohn.Forte@Sun.COM (struct bus_ops *)NULL
107*7836SJohn.Forte@Sun.COM };
108*7836SJohn.Forte@Sun.COM
109*7836SJohn.Forte@Sun.COM static struct modldrv nskern_ldrv = {
110*7836SJohn.Forte@Sun.COM &mod_driverops,
111*7836SJohn.Forte@Sun.COM "nws:Kernel Interface:" ISS_VERSION_STR,
112*7836SJohn.Forte@Sun.COM &nskern_ops
113*7836SJohn.Forte@Sun.COM };
114*7836SJohn.Forte@Sun.COM
115*7836SJohn.Forte@Sun.COM static dev_info_t *nskern_dip;
116*7836SJohn.Forte@Sun.COM
117*7836SJohn.Forte@Sun.COM static struct modlinkage nskern_modlinkage = {
118*7836SJohn.Forte@Sun.COM MODREV_1,
119*7836SJohn.Forte@Sun.COM &nskern_ldrv,
120*7836SJohn.Forte@Sun.COM NULL
121*7836SJohn.Forte@Sun.COM };
122*7836SJohn.Forte@Sun.COM
123*7836SJohn.Forte@Sun.COM /*
124*7836SJohn.Forte@Sun.COM * Solaris module load time code
125*7836SJohn.Forte@Sun.COM */
126*7836SJohn.Forte@Sun.COM
127*7836SJohn.Forte@Sun.COM int
_init(void)128*7836SJohn.Forte@Sun.COM _init(void)
129*7836SJohn.Forte@Sun.COM {
130*7836SJohn.Forte@Sun.COM void nskern_init();
131*7836SJohn.Forte@Sun.COM int err;
132*7836SJohn.Forte@Sun.COM
133*7836SJohn.Forte@Sun.COM mutex_init(&_nskern_lock, NULL, MUTEX_DRIVER, NULL);
134*7836SJohn.Forte@Sun.COM
135*7836SJohn.Forte@Sun.COM err = mod_install(&nskern_modlinkage);
136*7836SJohn.Forte@Sun.COM if (err) {
137*7836SJohn.Forte@Sun.COM mutex_destroy(&_nskern_lock);
138*7836SJohn.Forte@Sun.COM cmn_err(CE_WARN, "nskern_init: mod_install err %d", err);
139*7836SJohn.Forte@Sun.COM return (err);
140*7836SJohn.Forte@Sun.COM }
141*7836SJohn.Forte@Sun.COM
142*7836SJohn.Forte@Sun.COM nskern_init();
143*7836SJohn.Forte@Sun.COM
144*7836SJohn.Forte@Sun.COM return (DDI_SUCCESS);
145*7836SJohn.Forte@Sun.COM }
146*7836SJohn.Forte@Sun.COM
147*7836SJohn.Forte@Sun.COM /*
148*7836SJohn.Forte@Sun.COM * Solaris module unload time code
149*7836SJohn.Forte@Sun.COM */
150*7836SJohn.Forte@Sun.COM
151*7836SJohn.Forte@Sun.COM int
_fini(void)152*7836SJohn.Forte@Sun.COM _fini(void)
153*7836SJohn.Forte@Sun.COM {
154*7836SJohn.Forte@Sun.COM int err;
155*7836SJohn.Forte@Sun.COM
156*7836SJohn.Forte@Sun.COM if ((err = mod_remove(&nskern_modlinkage)) == 0) {
157*7836SJohn.Forte@Sun.COM nskernd_stop();
158*7836SJohn.Forte@Sun.COM _nsc_stop_proc();
159*7836SJohn.Forte@Sun.COM nskernd_deinit();
160*7836SJohn.Forte@Sun.COM
161*7836SJohn.Forte@Sun.COM mutex_destroy(&_nskern_lock);
162*7836SJohn.Forte@Sun.COM }
163*7836SJohn.Forte@Sun.COM
164*7836SJohn.Forte@Sun.COM return (err);
165*7836SJohn.Forte@Sun.COM }
166*7836SJohn.Forte@Sun.COM
167*7836SJohn.Forte@Sun.COM int
_info(struct modinfo * modinfop)168*7836SJohn.Forte@Sun.COM _info(struct modinfo *modinfop)
169*7836SJohn.Forte@Sun.COM {
170*7836SJohn.Forte@Sun.COM return (mod_info(&nskern_modlinkage, modinfop));
171*7836SJohn.Forte@Sun.COM }
172*7836SJohn.Forte@Sun.COM
173*7836SJohn.Forte@Sun.COM /*
174*7836SJohn.Forte@Sun.COM * Attach an instance of the device. This happens before an open
175*7836SJohn.Forte@Sun.COM * can succeed.
176*7836SJohn.Forte@Sun.COM */
177*7836SJohn.Forte@Sun.COM
178*7836SJohn.Forte@Sun.COM static int
_nskern_attach(dev_info_t * dip,ddi_attach_cmd_t cmd)179*7836SJohn.Forte@Sun.COM _nskern_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
180*7836SJohn.Forte@Sun.COM {
181*7836SJohn.Forte@Sun.COM if (cmd == DDI_ATTACH) {
182*7836SJohn.Forte@Sun.COM nskern_dip = dip;
183*7836SJohn.Forte@Sun.COM return (DDI_SUCCESS);
184*7836SJohn.Forte@Sun.COM } else {
185*7836SJohn.Forte@Sun.COM return (DDI_FAILURE);
186*7836SJohn.Forte@Sun.COM }
187*7836SJohn.Forte@Sun.COM }
188*7836SJohn.Forte@Sun.COM
189*7836SJohn.Forte@Sun.COM /* ARGSUSED */
190*7836SJohn.Forte@Sun.COM
191*7836SJohn.Forte@Sun.COM static int
_nskern_detach(dev_info_t * dip,ddi_detach_cmd_t cmd)192*7836SJohn.Forte@Sun.COM _nskern_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
193*7836SJohn.Forte@Sun.COM {
194*7836SJohn.Forte@Sun.COM if (cmd == DDI_DETACH) {
195*7836SJohn.Forte@Sun.COM nskern_dip = NULL;
196*7836SJohn.Forte@Sun.COM return (DDI_SUCCESS);
197*7836SJohn.Forte@Sun.COM } else {
198*7836SJohn.Forte@Sun.COM return (DDI_FAILURE);
199*7836SJohn.Forte@Sun.COM }
200*7836SJohn.Forte@Sun.COM }
201*7836SJohn.Forte@Sun.COM
202*7836SJohn.Forte@Sun.COM /* ARGSUSED */
203*7836SJohn.Forte@Sun.COM static int
_nskern_getinfo(dev_info_t * dip,ddi_info_cmd_t cmd,void * arg,void ** result)204*7836SJohn.Forte@Sun.COM _nskern_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
205*7836SJohn.Forte@Sun.COM {
206*7836SJohn.Forte@Sun.COM int rc = DDI_FAILURE;
207*7836SJohn.Forte@Sun.COM
208*7836SJohn.Forte@Sun.COM switch (cmd) {
209*7836SJohn.Forte@Sun.COM case DDI_INFO_DEVT2DEVINFO:
210*7836SJohn.Forte@Sun.COM *result = nskern_dip;
211*7836SJohn.Forte@Sun.COM rc = DDI_SUCCESS;
212*7836SJohn.Forte@Sun.COM break;
213*7836SJohn.Forte@Sun.COM
214*7836SJohn.Forte@Sun.COM case DDI_INFO_DEVT2INSTANCE:
215*7836SJohn.Forte@Sun.COM /* single instance */
216*7836SJohn.Forte@Sun.COM *result = 0;
217*7836SJohn.Forte@Sun.COM rc = DDI_SUCCESS;
218*7836SJohn.Forte@Sun.COM break;
219*7836SJohn.Forte@Sun.COM }
220*7836SJohn.Forte@Sun.COM
221*7836SJohn.Forte@Sun.COM return (rc);
222*7836SJohn.Forte@Sun.COM }
223*7836SJohn.Forte@Sun.COM
224*7836SJohn.Forte@Sun.COM /* ARGSUSED */
225*7836SJohn.Forte@Sun.COM
226*7836SJohn.Forte@Sun.COM int
_nskern_print(dev_t dev,char * s)227*7836SJohn.Forte@Sun.COM _nskern_print(dev_t dev, char *s)
228*7836SJohn.Forte@Sun.COM {
229*7836SJohn.Forte@Sun.COM cmn_err(CE_WARN, "nskern:%s", s);
230*7836SJohn.Forte@Sun.COM return (0);
231*7836SJohn.Forte@Sun.COM }
232*7836SJohn.Forte@Sun.COM
233*7836SJohn.Forte@Sun.COM /*
234*7836SJohn.Forte@Sun.COM * nskern_init - initialize the nskern layer at module load time.
235*7836SJohn.Forte@Sun.COM */
236*7836SJohn.Forte@Sun.COM
237*7836SJohn.Forte@Sun.COM void
nskern_init(void)238*7836SJohn.Forte@Sun.COM nskern_init(void)
239*7836SJohn.Forte@Sun.COM {
240*7836SJohn.Forte@Sun.COM _nsc_start_proc();
241*7836SJohn.Forte@Sun.COM nskernd_init();
242*7836SJohn.Forte@Sun.COM
243*7836SJohn.Forte@Sun.COM (void) nst_startup();
244*7836SJohn.Forte@Sun.COM }
245*7836SJohn.Forte@Sun.COM
246*7836SJohn.Forte@Sun.COM
247*7836SJohn.Forte@Sun.COM #if (defined(DS_DDICT))
248*7836SJohn.Forte@Sun.COM static clock_t
nskern_lbolt(void)249*7836SJohn.Forte@Sun.COM nskern_lbolt(void)
250*7836SJohn.Forte@Sun.COM {
251*7836SJohn.Forte@Sun.COM #ifdef _SunOS_5_6
252*7836SJohn.Forte@Sun.COM clock_t lbolt;
253*7836SJohn.Forte@Sun.COM
254*7836SJohn.Forte@Sun.COM if (drv_getparm(LBOLT, &lbolt) == 0)
255*7836SJohn.Forte@Sun.COM return (lbolt);
256*7836SJohn.Forte@Sun.COM
257*7836SJohn.Forte@Sun.COM return (0);
258*7836SJohn.Forte@Sun.COM #else
259*7836SJohn.Forte@Sun.COM return (ddi_get_lbolt());
260*7836SJohn.Forte@Sun.COM #endif
261*7836SJohn.Forte@Sun.COM }
262*7836SJohn.Forte@Sun.COM #endif /* ddict */
263*7836SJohn.Forte@Sun.COM
264*7836SJohn.Forte@Sun.COM
265*7836SJohn.Forte@Sun.COM /*
266*7836SJohn.Forte@Sun.COM * nsc_usec()
267*7836SJohn.Forte@Sun.COM * - return the value of the "microsecond timer emulation".
268*7836SJohn.Forte@Sun.COM *
269*7836SJohn.Forte@Sun.COM * Pre-SunOS 5.9:
270*7836SJohn.Forte@Sun.COM * Actually this is a fake free running counter based on the lbolt value.
271*7836SJohn.Forte@Sun.COM *
272*7836SJohn.Forte@Sun.COM * SunOS 5.9+
273*7836SJohn.Forte@Sun.COM * This is based on the gethrtime(9f) DDI facility.
274*7836SJohn.Forte@Sun.COM */
275*7836SJohn.Forte@Sun.COM
276*7836SJohn.Forte@Sun.COM #if (defined(DS_DDICT))
277*7836SJohn.Forte@Sun.COM /* these two #defines need to match! */
278*7836SJohn.Forte@Sun.COM #define USEC_SHIFT 16
279*7836SJohn.Forte@Sun.COM #define INCR_TYPE uint16_t
280*7836SJohn.Forte@Sun.COM #endif /* ! _SunOS_5_9+ */
281*7836SJohn.Forte@Sun.COM
282*7836SJohn.Forte@Sun.COM clock_t
nsc_usec(void)283*7836SJohn.Forte@Sun.COM nsc_usec(void)
284*7836SJohn.Forte@Sun.COM {
285*7836SJohn.Forte@Sun.COM /* avoid divide by zero */
286*7836SJohn.Forte@Sun.COM return (gethrtime() / 1000);
287*7836SJohn.Forte@Sun.COM }
288*7836SJohn.Forte@Sun.COM
289*7836SJohn.Forte@Sun.COM
290*7836SJohn.Forte@Sun.COM /*
291*7836SJohn.Forte@Sun.COM * nsc_yield - yield the cpu.
292*7836SJohn.Forte@Sun.COM */
293*7836SJohn.Forte@Sun.COM void
nsc_yield(void)294*7836SJohn.Forte@Sun.COM nsc_yield(void)
295*7836SJohn.Forte@Sun.COM {
296*7836SJohn.Forte@Sun.COM /* can't call yield() unless there is an lwp context */
297*7836SJohn.Forte@Sun.COM /* do this for now */
298*7836SJohn.Forte@Sun.COM
299*7836SJohn.Forte@Sun.COM delay(2);
300*7836SJohn.Forte@Sun.COM }
301*7836SJohn.Forte@Sun.COM
302*7836SJohn.Forte@Sun.COM
303*7836SJohn.Forte@Sun.COM /*
304*7836SJohn.Forte@Sun.COM * void
305*7836SJohn.Forte@Sun.COM * ls_ins_before(ls_elt_t *, ls_elt_t *)
306*7836SJohn.Forte@Sun.COM * Link new into list before old.
307*7836SJohn.Forte@Sun.COM *
308*7836SJohn.Forte@Sun.COM * Calling/Exit State:
309*7836SJohn.Forte@Sun.COM * None.
310*7836SJohn.Forte@Sun.COM */
311*7836SJohn.Forte@Sun.COM #ifdef lint
312*7836SJohn.Forte@Sun.COM void
nsc_ddi_ls_ins_before(ls_elt_t * old,ls_elt_t * new)313*7836SJohn.Forte@Sun.COM nsc_ddi_ls_ins_before(ls_elt_t *old, ls_elt_t *new)
314*7836SJohn.Forte@Sun.COM #else
315*7836SJohn.Forte@Sun.COM void
316*7836SJohn.Forte@Sun.COM ls_ins_before(ls_elt_t *old, ls_elt_t *new)
317*7836SJohn.Forte@Sun.COM #endif
318*7836SJohn.Forte@Sun.COM {
319*7836SJohn.Forte@Sun.COM new->ls_prev = old->ls_prev;
320*7836SJohn.Forte@Sun.COM new->ls_next = old;
321*7836SJohn.Forte@Sun.COM new->ls_prev->ls_next = new;
322*7836SJohn.Forte@Sun.COM new->ls_next->ls_prev = new;
323*7836SJohn.Forte@Sun.COM }
324*7836SJohn.Forte@Sun.COM
325*7836SJohn.Forte@Sun.COM /*
326*7836SJohn.Forte@Sun.COM * void
327*7836SJohn.Forte@Sun.COM * ls_ins_after(ls_elt_t *, ls_elt_t *)
328*7836SJohn.Forte@Sun.COM * Link new into list after old.
329*7836SJohn.Forte@Sun.COM *
330*7836SJohn.Forte@Sun.COM * Calling/Exit State:
331*7836SJohn.Forte@Sun.COM * None.
332*7836SJohn.Forte@Sun.COM */
333*7836SJohn.Forte@Sun.COM #ifdef lint
334*7836SJohn.Forte@Sun.COM void
nsc_ddi_ls_ins_after(ls_elt_t * old,ls_elt_t * new)335*7836SJohn.Forte@Sun.COM nsc_ddi_ls_ins_after(ls_elt_t *old, ls_elt_t *new)
336*7836SJohn.Forte@Sun.COM #else
337*7836SJohn.Forte@Sun.COM void
338*7836SJohn.Forte@Sun.COM ls_ins_after(ls_elt_t *old, ls_elt_t *new)
339*7836SJohn.Forte@Sun.COM #endif
340*7836SJohn.Forte@Sun.COM {
341*7836SJohn.Forte@Sun.COM new->ls_next = old->ls_next;
342*7836SJohn.Forte@Sun.COM new->ls_prev = old;
343*7836SJohn.Forte@Sun.COM new->ls_next->ls_prev = new;
344*7836SJohn.Forte@Sun.COM new->ls_prev->ls_next = new;
345*7836SJohn.Forte@Sun.COM }
346*7836SJohn.Forte@Sun.COM
347*7836SJohn.Forte@Sun.COM /*
348*7836SJohn.Forte@Sun.COM * ls_elt_t *
349*7836SJohn.Forte@Sun.COM * ls_remque(ls_elt_t *)
350*7836SJohn.Forte@Sun.COM * Unlink first element in the specified list.
351*7836SJohn.Forte@Sun.COM *
352*7836SJohn.Forte@Sun.COM * Calling/Exit State:
353*7836SJohn.Forte@Sun.COM * Returns the element's address or 0 if list is empty.
354*7836SJohn.Forte@Sun.COM * Resets elements pointers to empty list state.
355*7836SJohn.Forte@Sun.COM */
356*7836SJohn.Forte@Sun.COM ls_elt_t *
ls_remque(ls_elt_t * p)357*7836SJohn.Forte@Sun.COM ls_remque(ls_elt_t *p)
358*7836SJohn.Forte@Sun.COM {
359*7836SJohn.Forte@Sun.COM ls_elt_t *result = 0;
360*7836SJohn.Forte@Sun.COM
361*7836SJohn.Forte@Sun.COM if (!LS_ISEMPTY(p)) {
362*7836SJohn.Forte@Sun.COM result = p->ls_next;
363*7836SJohn.Forte@Sun.COM result->ls_prev->ls_next = result->ls_next;
364*7836SJohn.Forte@Sun.COM result->ls_next->ls_prev = result->ls_prev;
365*7836SJohn.Forte@Sun.COM LS_INIT(result);
366*7836SJohn.Forte@Sun.COM }
367*7836SJohn.Forte@Sun.COM return (result);
368*7836SJohn.Forte@Sun.COM }
369*7836SJohn.Forte@Sun.COM
370*7836SJohn.Forte@Sun.COM /*
371*7836SJohn.Forte@Sun.COM * void
372*7836SJohn.Forte@Sun.COM * ls_remove(ls_elt_t *)
373*7836SJohn.Forte@Sun.COM * Unlink donated element for list.
374*7836SJohn.Forte@Sun.COM *
375*7836SJohn.Forte@Sun.COM * Calling/Exit State:
376*7836SJohn.Forte@Sun.COM * Resets elements pointers to empty list state.
377*7836SJohn.Forte@Sun.COM */
378*7836SJohn.Forte@Sun.COM #ifdef lint
379*7836SJohn.Forte@Sun.COM void
nsc_ddi_ls_remove(ls_elt_t * p)380*7836SJohn.Forte@Sun.COM nsc_ddi_ls_remove(ls_elt_t *p)
381*7836SJohn.Forte@Sun.COM #else
382*7836SJohn.Forte@Sun.COM void
383*7836SJohn.Forte@Sun.COM ls_remove(ls_elt_t *p)
384*7836SJohn.Forte@Sun.COM #endif
385*7836SJohn.Forte@Sun.COM {
386*7836SJohn.Forte@Sun.COM p->ls_prev->ls_next = p->ls_next;
387*7836SJohn.Forte@Sun.COM p->ls_next->ls_prev = p->ls_prev;
388*7836SJohn.Forte@Sun.COM LS_INIT(p);
389*7836SJohn.Forte@Sun.COM }
390