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 525e8c5aaSvikram * Common Development and Distribution License (the "License"). 625e8c5aaSvikram * 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*328d222bSChris Horne * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _SYS_SUNLDI_H 267c478bd9Sstevel@tonic-gate #define _SYS_SUNLDI_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 297c478bd9Sstevel@tonic-gate #include <sys/stream.h> 307c478bd9Sstevel@tonic-gate #include <sys/open.h> 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate /* 337c478bd9Sstevel@tonic-gate * DDI interfaces for Layered driver support. 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 377c478bd9Sstevel@tonic-gate extern "C" { 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef _KERNEL 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * Opaque layered driver data structures. 457c478bd9Sstevel@tonic-gate * 467c478bd9Sstevel@tonic-gate * The contents of these data structures are private to this 477c478bd9Sstevel@tonic-gate * implementation of Solaris and are subject to change at any 487c478bd9Sstevel@tonic-gate * time without notice. 497c478bd9Sstevel@tonic-gate * 507c478bd9Sstevel@tonic-gate * Applications and drivers accessing the contents of these structures 517c478bd9Sstevel@tonic-gate * directly will fail to run on future releases. 527c478bd9Sstevel@tonic-gate */ 537c478bd9Sstevel@tonic-gate typedef struct __ldi_ident *ldi_ident_t; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate typedef struct __ldi_handle *ldi_handle_t; 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate typedef struct __ldi_callback_id *ldi_callback_id_t; 587c478bd9Sstevel@tonic-gate 5925e8c5aaSvikram typedef struct __ldi_ev_cookie *ldi_ev_cookie_t; 6025e8c5aaSvikram 6125e8c5aaSvikram /* 6225e8c5aaSvikram * LDI event interface related 6325e8c5aaSvikram */ 6425e8c5aaSvikram #define LDI_EV_SUCCESS 0 6525e8c5aaSvikram #define LDI_EV_FAILURE (-1) 6625e8c5aaSvikram #define LDI_EV_NONE (-2) /* no matching callbacks registered */ 6725e8c5aaSvikram #define LDI_EV_OFFLINE "LDI:EVENT:OFFLINE" 6825e8c5aaSvikram #define LDI_EV_DEGRADE "LDI:EVENT:DEGRADE" 69*328d222bSChris Horne #define LDI_EV_DEVICE_REMOVE "LDI:EVENT:DEVICE_REMOVE" 7025e8c5aaSvikram 7125e8c5aaSvikram #define LDI_EV_CB_VERS_1 1 7225e8c5aaSvikram #define LDI_EV_CB_VERS LDI_EV_CB_VERS_1 7325e8c5aaSvikram 7425e8c5aaSvikram typedef struct ldi_ev_callback { 7525e8c5aaSvikram uint_t cb_vers; 7625e8c5aaSvikram int (*cb_notify)(ldi_handle_t, ldi_ev_cookie_t, void *, void *); 7725e8c5aaSvikram void (*cb_finalize)(ldi_handle_t, ldi_ev_cookie_t, int, void *, void *); 7825e8c5aaSvikram } ldi_ev_callback_t; 7925e8c5aaSvikram 807c478bd9Sstevel@tonic-gate /* 817c478bd9Sstevel@tonic-gate * LDI Ident manipulation functions 827c478bd9Sstevel@tonic-gate */ 837c478bd9Sstevel@tonic-gate extern ldi_ident_t ldi_ident_from_anon(void); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate extern int ldi_ident_from_mod(struct modlinkage *, ldi_ident_t *); 867c478bd9Sstevel@tonic-gate extern int ldi_ident_from_major(major_t major, ldi_ident_t *); 877c478bd9Sstevel@tonic-gate extern int ldi_ident_from_dip(dev_info_t *dip, ldi_ident_t *); 887c478bd9Sstevel@tonic-gate extern int ldi_ident_from_dev(dev_t, ldi_ident_t *); 897c478bd9Sstevel@tonic-gate extern int ldi_ident_from_stream(struct queue *, ldi_ident_t *); 907c478bd9Sstevel@tonic-gate extern void ldi_ident_release(ldi_ident_t); 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * LDI Handle manipulation functions 957c478bd9Sstevel@tonic-gate */ 967c478bd9Sstevel@tonic-gate extern int ldi_open_by_dev(dev_t *, int, int, cred_t *, 977c478bd9Sstevel@tonic-gate ldi_handle_t *, ldi_ident_t); 987c478bd9Sstevel@tonic-gate extern int ldi_open_by_name(char *, int, cred_t *, 997c478bd9Sstevel@tonic-gate ldi_handle_t *, ldi_ident_t); 1007c478bd9Sstevel@tonic-gate extern int ldi_open_by_devid(ddi_devid_t, char *, int, cred_t *, 1017c478bd9Sstevel@tonic-gate ldi_handle_t *, ldi_ident_t); 102dcba9f3fSGeorge Wilson extern int ldi_vp_from_name(char *, vnode_t **); 103dcba9f3fSGeorge Wilson extern int ldi_vp_from_devid(ddi_devid_t, char *, vnode_t **); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate extern int ldi_close(ldi_handle_t, int flag, cred_t *); 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate extern int ldi_read(ldi_handle_t, struct uio *, cred_t *); 1087c478bd9Sstevel@tonic-gate extern int ldi_write(ldi_handle_t, struct uio *, cred_t *); 1097c478bd9Sstevel@tonic-gate extern int ldi_ioctl(ldi_handle_t, int, intptr_t, int, cred_t *, int *); 1107c478bd9Sstevel@tonic-gate extern int ldi_poll(ldi_handle_t, short, int, short *, struct pollhead **); 1117c478bd9Sstevel@tonic-gate extern int ldi_get_size(ldi_handle_t, uint64_t *); 1127c478bd9Sstevel@tonic-gate extern int ldi_prop_op(ldi_handle_t, ddi_prop_op_t, int, 1137c478bd9Sstevel@tonic-gate char *, caddr_t, int *); 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate extern int ldi_strategy(ldi_handle_t, struct buf *); 1167c478bd9Sstevel@tonic-gate extern int ldi_dump(ldi_handle_t, caddr_t, daddr_t, int); 1177c478bd9Sstevel@tonic-gate extern int ldi_devmap(ldi_handle_t, devmap_cookie_t, offset_t, 1187c478bd9Sstevel@tonic-gate size_t, size_t *, uint_t); 1197c478bd9Sstevel@tonic-gate extern int ldi_aread(ldi_handle_t, struct aio_req *, cred_t *); 1207c478bd9Sstevel@tonic-gate extern int ldi_awrite(ldi_handle_t, struct aio_req *, cred_t *); 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate extern int ldi_putmsg(ldi_handle_t, mblk_t *); 1237c478bd9Sstevel@tonic-gate extern int ldi_getmsg(ldi_handle_t, mblk_t **, timestruc_t *); 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate extern int ldi_prop_lookup_int_array(ldi_handle_t lh, 1267c478bd9Sstevel@tonic-gate uint_t flags, char *name, int **data, uint_t *nelements); 1277c478bd9Sstevel@tonic-gate extern int ldi_prop_lookup_int64_array(ldi_handle_t lh, 1287c478bd9Sstevel@tonic-gate uint_t flags, char *name, int64_t **data, uint_t *nelements); 1297c478bd9Sstevel@tonic-gate extern int ldi_prop_lookup_string_array(ldi_handle_t lh, 1307c478bd9Sstevel@tonic-gate uint_t flags, char *name, char ***data, uint_t *nelements); 1317c478bd9Sstevel@tonic-gate extern int ldi_prop_lookup_string(ldi_handle_t lh, 1327c478bd9Sstevel@tonic-gate uint_t flags, char *name, char **data); 1337c478bd9Sstevel@tonic-gate extern int ldi_prop_lookup_byte_array(ldi_handle_t lh, 1347c478bd9Sstevel@tonic-gate uint_t flags, char *name, uchar_t **data, uint_t *nelements); 1357c478bd9Sstevel@tonic-gate extern int ldi_prop_get_int(ldi_handle_t lh, 1367c478bd9Sstevel@tonic-gate uint_t flags, char *name, int defvalue); 1377c478bd9Sstevel@tonic-gate extern int64_t ldi_prop_get_int64(ldi_handle_t lh, 1387c478bd9Sstevel@tonic-gate uint_t flags, char *name, int64_t defvalue); 1397c478bd9Sstevel@tonic-gate extern int ldi_prop_exists(ldi_handle_t lh, 1407c478bd9Sstevel@tonic-gate uint_t flags, char *name); 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate extern int ldi_get_dev(ldi_handle_t, dev_t *); 1437c478bd9Sstevel@tonic-gate extern int ldi_get_otyp(ldi_handle_t, int *); 1447c478bd9Sstevel@tonic-gate extern int ldi_get_devid(ldi_handle_t, ddi_devid_t *); 1457c478bd9Sstevel@tonic-gate extern int ldi_get_minor_name(ldi_handle_t, char **); 1467c478bd9Sstevel@tonic-gate 14725e8c5aaSvikram /* 14825e8c5aaSvikram * LDI events related declarations 14925e8c5aaSvikram */ 15025e8c5aaSvikram extern int ldi_ev_get_cookie(ldi_handle_t lh, char *evname, 15125e8c5aaSvikram ldi_ev_cookie_t *cookiep); 15225e8c5aaSvikram extern char *ldi_ev_get_type(ldi_ev_cookie_t cookie); 15325e8c5aaSvikram extern int ldi_ev_register_callbacks(ldi_handle_t lh, 15425e8c5aaSvikram ldi_ev_cookie_t cookie, ldi_ev_callback_t *callb, 15525e8c5aaSvikram void *arg, ldi_callback_id_t *id); 15625e8c5aaSvikram extern int ldi_ev_notify(dev_info_t *dip, minor_t minor, int spec_type, 15725e8c5aaSvikram ldi_ev_cookie_t cookie, void *ev_data); 15825e8c5aaSvikram extern void ldi_ev_finalize(dev_info_t *dip, minor_t minor, int spec_type, 15925e8c5aaSvikram int ldi_result, ldi_ev_cookie_t cookie, void *ev_data); 16025e8c5aaSvikram extern int ldi_ev_remove_callbacks(ldi_callback_id_t id); 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1657c478bd9Sstevel@tonic-gate } 1667c478bd9Sstevel@tonic-gate #endif 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate #endif /* _SYS_SUNLDI_H */ 169