1c10c16deSRichard Lowe.\" Copyright (c) 2009, Sun Microsystems, Inc., All Rights Reserved 242772362SJason King.\" Copyright 2018, Joyent, Inc. 342772362SJason King.\" The contents of this file are subject to the terms of the 442772362SJason King.\" Common Development and Distribution License (the "License"). 542772362SJason King.\" You may not use this file except in compliance with the License. 642772362SJason King.\" 742772362SJason King.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 842772362SJason King.\" or http://www.opensolaris.org/os/licensing. 942772362SJason King.\" See the License for the specific language governing permissions 1042772362SJason King.\" and limitations under the License. 1142772362SJason King.\" 1242772362SJason King.\" When distributing Covered Code, include this CDDL HEADER in each 1342772362SJason King.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1442772362SJason King.\" If applicable, add the following below this CDDL HEADER, with the 1542772362SJason King.\" fields enclosed by brackets "[]" replaced with your own identifying 1642772362SJason King.\" information: Portions Copyright [yyyy] [name of copyright owner] 1742772362SJason King.Dd July 9, 2018 1842772362SJason King.Dt CB_OPS 9S 1942772362SJason King.Os 2042772362SJason King.Sh NAME 2142772362SJason King.Nm cb_ops 2242772362SJason King.Nd character/block entry points structure 2342772362SJason King.Sh SYNOPSIS 2442772362SJason King.In sys/conf.h 2542772362SJason King.In sys/ddi.h 2642772362SJason King.In sys/sunddi.h 2742772362SJason King.Sh INTERFACE LEVEL 28*3184921aSRichard Loweillumos DDI specific (illumos DDI) 2942772362SJason King.Sh DESCRIPTION 3042772362SJason KingThe 3142772362SJason King.Nm 3242772362SJason Kingstructure contains all entry points for drivers that support 3342772362SJason Kingboth character and block entry points. 3442772362SJason KingAll leaf device drivers that support 3542772362SJason Kingdirect user process access to a device should declare a 3642772362SJason King.Nm 3742772362SJason Kingstructure. 3842772362SJason King.Pp 39c10c16deSRichard LoweAll drivers that safely allow multiple threads of execution in the driver at 4042772362SJason Kingthe same time must set the 4142772362SJason King.Dv D_MP 4242772362SJason Kingflag in the 4342772362SJason King.Fa cb_flag 4442772362SJason Kingfield. 4542772362SJason KingSee 4642772362SJason King.Xr open 9E . 4742772362SJason King.Pp 48c10c16deSRichard LoweIf the driver properly handles 64-bit offsets, it should also set the 4942772362SJason King.Dv D_64BIT 5042772362SJason Kingflag in the 5142772362SJason King.Fa cb_flag 5242772362SJason Kingfield. 5342772362SJason KingThis specifies that the driver 5442772362SJason Kingwill use the 5542772362SJason King.Fa uio_loffset 5642772362SJason Kingfield of the 5742772362SJason King.Xr uio 9S 5842772362SJason Kingstructure. 5942772362SJason King.Pp 6042772362SJason KingIf the driver returns 6142772362SJason King.Er EINTR 6242772362SJason Kingfrom 6342772362SJason King.Xr open 9E , 6442772362SJason Kingit should also set the 6542772362SJason King.Dv D_OPEN_RETURNS_EINTR 6642772362SJason Kingflag in the 6742772362SJason King.Fa cb_flag 6842772362SJason Kingfield. 6942772362SJason KingThis lets the 7042772362SJason Kingframework know that it is safe for the driver to return 7142772362SJason King.Er EINTR 7242772362SJason Kingwhen waiting, to provide exclusion for a last-reference 7342772362SJason King.Xr close 9E 7442772362SJason Kingcall to complete before calling 7542772362SJason King.Xr open 9E . 7642772362SJason King.Pp 7742772362SJason KingThe 7842772362SJason King.Xr mt-streams 9F 7942772362SJason Kingfunction describes other flags that can be set in the 8042772362SJason King.Fa cb_flag 8142772362SJason Kingfield. 8242772362SJason King.Pp 8342772362SJason KingThe 8442772362SJason King.Fa cb_rev 8542772362SJason Kingis the 8642772362SJason King.Vt cb_ops 8742772362SJason Kingstructure revision number. 8842772362SJason KingThis field must 8942772362SJason Kingbe set to 9042772362SJason King.Dv CB_REV . 9142772362SJason King.Pp 9242772362SJason King.Pf Non- Ns Sy STREAMS 9342772362SJason Kingdrivers should set 9442772362SJason King.Fa cb_str 9542772362SJason Kingto 9642772362SJason King.Sy NULL . 9742772362SJason King.Pp 9842772362SJason KingThe following 9942772362SJason King.Sy DDI/DKI 10042772362SJason Kingor 10142772362SJason King.Sy DKI Ns -only 10242772362SJason Kingor 10342772362SJason King.Sy DDI Ns -only 10442772362SJason Kingfunctions are provided in the character/block driver operations structure. 10542772362SJason King.Bl -column "block/char" "Function" "Description" 10642772362SJason King.It block/char Function Description 10742772362SJason King.It b/c XXopen DDI/DKI 10842772362SJason King.It b/c XXclose DDI/DKI 10942772362SJason King.It b XXstrategy DDI/DKI 11042772362SJason King.It b XXprint DDI/DKI 11142772362SJason King.It b XXdump DDI(Sun) 11242772362SJason King.It c XXread DDI/DKI 11342772362SJason King.It c XXwrite DDI/DKI 11442772362SJason King.It c XXioctl DDI/DKI 11542772362SJason King.It c XXdevmap DDI(Sun) 11642772362SJason King.It c XXmmap DKI 11742772362SJason King.It c XXsegmap DKI 11842772362SJason King.It c XXchpoll DDI/DKI 11942772362SJason King.It c XXprop_op DDI(Sun) 12042772362SJason King.It c XXaread DDI(Sun) 12142772362SJason King.It c XXawrite DDI(Sun) 12242772362SJason King.El 12342772362SJason King.Sh STRUCTURE MEMBERS 12442772362SJason King.Bd -literal -offset 2n 125c10c16deSRichard Loweint (*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp); 126c10c16deSRichard Loweint (*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp); 127c10c16deSRichard Loweint (*cb_strategy)(struct buf *bp); 128c10c16deSRichard Loweint (*cb_print)(dev_t dev, char *str); 129c10c16deSRichard Loweint (*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk); 130c10c16deSRichard Loweint (*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp); 131c10c16deSRichard Loweint (*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp); 132c10c16deSRichard Loweint (*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode, 133c10c16deSRichard Lowe cred_t *credp, int *rvalp); 134c10c16deSRichard Loweint (*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off, 135c10c16deSRichard Lowe size_t len, size_t *maplen, uint_t model); 136c10c16deSRichard Loweint (*cb_mmap)(dev_t dev, off_t off, int prot); 137c10c16deSRichard Loweint (*cb_segmap)(dev_t dev, off_t off, struct as *asp, 138c10c16deSRichard Lowe caddr_t *addrp, off_t len, unsigned int prot, 139c10c16deSRichard Lowe unsigned int maxprot, unsigned int flags, cred_t *credp); 140c10c16deSRichard Loweint (*cb_chpoll)(dev_t dev, short events, int anyyet, 141c10c16deSRichard Lowe short *reventsp, struct pollhead **phpp); 142c10c16deSRichard Loweint (*cb_prop_op)(dev_t dev, dev_info_t *dip, 143c10c16deSRichard Lowe ddi_prop_op_t prop_op, int mod_flags, 144c10c16deSRichard Lowe char *name, caddr_t valuep, int *length); 145c10c16deSRichard Lowestruct streamtab *cb_str; /* streams information */ 146c10c16deSRichard Loweint cb_flag; 147c10c16deSRichard Loweint cb_rev; 148c10c16deSRichard Loweint (*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp); 149c10c16deSRichard Loweint (*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp); 15042772362SJason King.Ed 15142772362SJason King.Sh SEE ALSO 15242772362SJason King.Xr aread 9E , 15342772362SJason King.Xr awrite 9E , 15442772362SJason King.Xr chpoll 9E , 15542772362SJason King.Xr close 9E , 15642772362SJason King.Xr dump 9E , 15742772362SJason King.Xr ioctl 9E , 15842772362SJason King.Xr mmap 9E , 15942772362SJason King.Xr open 9E , 16042772362SJason King.Xr print 9E , 16142772362SJason King.Xr prop_op 9E , 16242772362SJason King.Xr read 9E , 16342772362SJason King.Xr segmap 9E , 16442772362SJason King.Xr strategy 9E , 16542772362SJason King.Xr write 9E , 16642772362SJason King.Xr nochpoll 9F , 16742772362SJason King.Xr nodev 9F , 16842772362SJason King.Xr nulldev 9F , 16942772362SJason King.Xr dev_ops 9S , 17042772362SJason King.Xr qinit 9S 17142772362SJason King.Rs 17242772362SJason King.%T Writing Device Drivers 17342772362SJason King.Re 17442772362SJason King.Rs 17542772362SJason King.%T STREAMS Programming Guide 17642772362SJason King.Re 177