xref: /onnv-gate/usr/src/uts/common/sys/sunldi.h (revision 12288:70ddea689280)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
54845Svikram  * Common Development and Distribution License (the "License").
64845Svikram  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*12288SChris.Horne@Sun.COM  * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef	_SYS_SUNLDI_H
260Sstevel@tonic-gate #define	_SYS_SUNLDI_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include <sys/modctl.h>
290Sstevel@tonic-gate #include <sys/stream.h>
300Sstevel@tonic-gate #include <sys/open.h>
310Sstevel@tonic-gate 
320Sstevel@tonic-gate /*
330Sstevel@tonic-gate  * DDI interfaces for Layered driver support.
340Sstevel@tonic-gate  */
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #ifdef	__cplusplus
370Sstevel@tonic-gate extern "C" {
380Sstevel@tonic-gate #endif
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #ifdef	_KERNEL
410Sstevel@tonic-gate 
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate  * Opaque layered driver data structures.
450Sstevel@tonic-gate  *
460Sstevel@tonic-gate  * The contents of these data structures are private to this
470Sstevel@tonic-gate  * implementation of Solaris and are subject to change at any
480Sstevel@tonic-gate  * time without notice.
490Sstevel@tonic-gate  *
500Sstevel@tonic-gate  * Applications and drivers accessing the contents of these structures
510Sstevel@tonic-gate  * directly will fail to run on future releases.
520Sstevel@tonic-gate  */
530Sstevel@tonic-gate typedef struct __ldi_ident		*ldi_ident_t;
540Sstevel@tonic-gate 
550Sstevel@tonic-gate typedef struct __ldi_handle		*ldi_handle_t;
560Sstevel@tonic-gate 
570Sstevel@tonic-gate typedef struct __ldi_callback_id	*ldi_callback_id_t;
580Sstevel@tonic-gate 
594845Svikram typedef struct __ldi_ev_cookie		*ldi_ev_cookie_t;
604845Svikram 
614845Svikram /*
624845Svikram  * LDI event interface related
634845Svikram  */
644845Svikram #define	LDI_EV_SUCCESS	0
654845Svikram #define	LDI_EV_FAILURE	(-1)
664845Svikram #define	LDI_EV_NONE	(-2)	/* no matching callbacks registered */
674845Svikram #define	LDI_EV_OFFLINE	"LDI:EVENT:OFFLINE"
684845Svikram #define	LDI_EV_DEGRADE	"LDI:EVENT:DEGRADE"
69*12288SChris.Horne@Sun.COM #define	LDI_EV_DEVICE_REMOVE	"LDI:EVENT:DEVICE_REMOVE"
704845Svikram 
714845Svikram #define	LDI_EV_CB_VERS_1	1
724845Svikram #define	LDI_EV_CB_VERS		LDI_EV_CB_VERS_1
734845Svikram 
744845Svikram typedef struct ldi_ev_callback {
754845Svikram 	uint_t cb_vers;
764845Svikram 	int (*cb_notify)(ldi_handle_t, ldi_ev_cookie_t, void *, void *);
774845Svikram 	void (*cb_finalize)(ldi_handle_t, ldi_ev_cookie_t, int, void *, void *);
784845Svikram } ldi_ev_callback_t;
794845Svikram 
800Sstevel@tonic-gate /*
810Sstevel@tonic-gate  * LDI Ident manipulation functions
820Sstevel@tonic-gate  */
830Sstevel@tonic-gate extern ldi_ident_t ldi_ident_from_anon(void);
840Sstevel@tonic-gate 
850Sstevel@tonic-gate extern int ldi_ident_from_mod(struct modlinkage *, ldi_ident_t *);
860Sstevel@tonic-gate extern int ldi_ident_from_major(major_t major, ldi_ident_t *);
870Sstevel@tonic-gate extern int ldi_ident_from_dip(dev_info_t *dip, ldi_ident_t *);
880Sstevel@tonic-gate extern int ldi_ident_from_dev(dev_t, ldi_ident_t *);
890Sstevel@tonic-gate extern int ldi_ident_from_stream(struct queue *, ldi_ident_t *);
900Sstevel@tonic-gate extern void ldi_ident_release(ldi_ident_t);
910Sstevel@tonic-gate 
920Sstevel@tonic-gate 
930Sstevel@tonic-gate /*
940Sstevel@tonic-gate  * LDI Handle manipulation functions
950Sstevel@tonic-gate  */
960Sstevel@tonic-gate extern int ldi_open_by_dev(dev_t *, int, int, cred_t *,
970Sstevel@tonic-gate     ldi_handle_t *, ldi_ident_t);
980Sstevel@tonic-gate extern int ldi_open_by_name(char *, int, cred_t *,
990Sstevel@tonic-gate     ldi_handle_t *, ldi_ident_t);
1000Sstevel@tonic-gate extern int ldi_open_by_devid(ddi_devid_t, char *, int, cred_t *,
1010Sstevel@tonic-gate     ldi_handle_t *, ldi_ident_t);
10211958SGeorge.Wilson@Sun.COM extern int ldi_vp_from_name(char *, vnode_t **);
10311958SGeorge.Wilson@Sun.COM extern int ldi_vp_from_devid(ddi_devid_t, char *, vnode_t **);
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate extern int ldi_close(ldi_handle_t, int flag, cred_t *);
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate extern int ldi_read(ldi_handle_t, struct uio *, cred_t *);
1080Sstevel@tonic-gate extern int ldi_write(ldi_handle_t, struct uio *, cred_t *);
1090Sstevel@tonic-gate extern int ldi_ioctl(ldi_handle_t, int, intptr_t, int, cred_t *, int *);
1100Sstevel@tonic-gate extern int ldi_poll(ldi_handle_t, short, int, short *, struct pollhead **);
1110Sstevel@tonic-gate extern int ldi_get_size(ldi_handle_t, uint64_t *);
1120Sstevel@tonic-gate extern int ldi_prop_op(ldi_handle_t, ddi_prop_op_t, int,
1130Sstevel@tonic-gate     char *, caddr_t, int *);
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate extern int ldi_strategy(ldi_handle_t, struct buf *);
1160Sstevel@tonic-gate extern int ldi_dump(ldi_handle_t, caddr_t, daddr_t, int);
1170Sstevel@tonic-gate extern int ldi_devmap(ldi_handle_t, devmap_cookie_t, offset_t,
1180Sstevel@tonic-gate     size_t, size_t *, uint_t);
1190Sstevel@tonic-gate extern int ldi_aread(ldi_handle_t, struct aio_req *, cred_t *);
1200Sstevel@tonic-gate extern int ldi_awrite(ldi_handle_t, struct aio_req *, cred_t *);
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate extern int ldi_putmsg(ldi_handle_t, mblk_t *);
1230Sstevel@tonic-gate extern int ldi_getmsg(ldi_handle_t, mblk_t **, timestruc_t *);
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate extern int ldi_prop_lookup_int_array(ldi_handle_t lh,
1260Sstevel@tonic-gate     uint_t flags, char *name, int **data, uint_t *nelements);
1270Sstevel@tonic-gate extern int ldi_prop_lookup_int64_array(ldi_handle_t lh,
1280Sstevel@tonic-gate     uint_t flags, char *name, int64_t **data, uint_t *nelements);
1290Sstevel@tonic-gate extern int ldi_prop_lookup_string_array(ldi_handle_t lh,
1300Sstevel@tonic-gate     uint_t flags, char *name, char ***data, uint_t *nelements);
1310Sstevel@tonic-gate extern int ldi_prop_lookup_string(ldi_handle_t lh,
1320Sstevel@tonic-gate     uint_t flags, char *name, char **data);
1330Sstevel@tonic-gate extern int ldi_prop_lookup_byte_array(ldi_handle_t lh,
1340Sstevel@tonic-gate     uint_t flags, char *name, uchar_t **data, uint_t *nelements);
1350Sstevel@tonic-gate extern int ldi_prop_get_int(ldi_handle_t lh,
1360Sstevel@tonic-gate     uint_t flags, char *name, int defvalue);
1370Sstevel@tonic-gate extern int64_t ldi_prop_get_int64(ldi_handle_t lh,
1380Sstevel@tonic-gate     uint_t flags, char *name, int64_t defvalue);
1390Sstevel@tonic-gate extern int ldi_prop_exists(ldi_handle_t lh,
1400Sstevel@tonic-gate     uint_t flags, char *name);
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate extern int ldi_get_dev(ldi_handle_t, dev_t *);
1430Sstevel@tonic-gate extern int ldi_get_otyp(ldi_handle_t, int *);
1440Sstevel@tonic-gate extern int ldi_get_devid(ldi_handle_t, ddi_devid_t *);
1450Sstevel@tonic-gate extern int ldi_get_minor_name(ldi_handle_t, char **);
1460Sstevel@tonic-gate 
1474845Svikram /*
1484845Svikram  * LDI events related declarations
1494845Svikram  */
1504845Svikram extern int ldi_ev_get_cookie(ldi_handle_t lh, char *evname,
1514845Svikram     ldi_ev_cookie_t *cookiep);
1524845Svikram extern char *ldi_ev_get_type(ldi_ev_cookie_t cookie);
1534845Svikram extern int ldi_ev_register_callbacks(ldi_handle_t lh,
1544845Svikram     ldi_ev_cookie_t cookie, ldi_ev_callback_t *callb,
1554845Svikram     void *arg, ldi_callback_id_t *id);
1564845Svikram extern int ldi_ev_notify(dev_info_t *dip, minor_t minor, int spec_type,
1574845Svikram     ldi_ev_cookie_t cookie, void *ev_data);
1584845Svikram extern void ldi_ev_finalize(dev_info_t *dip, minor_t minor, int spec_type,
1594845Svikram     int ldi_result, ldi_ev_cookie_t cookie, void *ev_data);
1604845Svikram extern int ldi_ev_remove_callbacks(ldi_callback_id_t id);
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate #endif	/* _KERNEL */
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate #ifdef	__cplusplus
1650Sstevel@tonic-gate }
1660Sstevel@tonic-gate #endif
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate #endif	/* _SYS_SUNLDI_H */
169