xref: /freebsd/share/man/man4/smb.4 (revision 3d33d453a0df3c104bce80d7155abac2ad42a575)
1eb8752d5SNicolas Souchu.\" Copyright (c) 1998, Nicolas Souchu
27d2d5f80SJoerg Wunsch.\" Copyright (c) 2004, Joerg Wunsch
3eb8752d5SNicolas Souchu.\" All rights reserved.
4eb8752d5SNicolas Souchu.\"
5eb8752d5SNicolas Souchu.\" Redistribution and use in source and binary forms, with or without
6eb8752d5SNicolas Souchu.\" modification, are permitted provided that the following conditions
7eb8752d5SNicolas Souchu.\" are met:
8eb8752d5SNicolas Souchu.\" 1. Redistributions of source code must retain the above copyright
9eb8752d5SNicolas Souchu.\"    notice, this list of conditions and the following disclaimer.
10eb8752d5SNicolas Souchu.\" 2. Redistributions in binary form must reproduce the above copyright
11eb8752d5SNicolas Souchu.\"    notice, this list of conditions and the following disclaimer in the
12eb8752d5SNicolas Souchu.\"    documentation and/or other materials provided with the distribution.
13eb8752d5SNicolas Souchu.\"
14eb8752d5SNicolas Souchu.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15eb8752d5SNicolas Souchu.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16eb8752d5SNicolas Souchu.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17eb8752d5SNicolas Souchu.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18eb8752d5SNicolas Souchu.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19eb8752d5SNicolas Souchu.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20eb8752d5SNicolas Souchu.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21eb8752d5SNicolas Souchu.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22eb8752d5SNicolas Souchu.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23eb8752d5SNicolas Souchu.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24eb8752d5SNicolas Souchu.\" SUCH DAMAGE.
25eb8752d5SNicolas Souchu.\"
267f3dea24SPeter Wemm.\" $FreeBSD$
27eb8752d5SNicolas Souchu.\"
283d33d453SJohn Baldwin.Dd February 6, 2009
29eb8752d5SNicolas Souchu.Dt SMB 4
303d45e180SRuslan Ermilov.Os
31eb8752d5SNicolas Souchu.Sh NAME
32eb8752d5SNicolas Souchu.Nm smb
33eb083802SRuslan Ermilov.Nd SMB generic I/O device driver
34eb8752d5SNicolas Souchu.Sh SYNOPSIS
35b9781e20SJeroen Ruigrok van der Werven.Cd "device smb"
36eb8752d5SNicolas Souchu.Sh DESCRIPTION
37eb8752d5SNicolas SouchuThe
38eb8752d5SNicolas Souchu.Em smb
39eb8752d5SNicolas Souchucharacter device driver provides generic i/o to any
40eb8752d5SNicolas Souchu.Xr smbus 4
416d249eeeSSheldon Hearninstance.
427d2d5f80SJoerg WunschIn order to control SMB devices, use
43bf7f20c2SRuslan Ermilov.Pa /dev/smb?
447d2d5f80SJoerg Wunschwith the ioctls described below.
457d2d5f80SJoerg WunschAny of these ioctl commands takes a pointer to
467d2d5f80SJoerg Wunsch.Vt struct smbcmd
477d2d5f80SJoerg Wunschas its argument.
48eb8752d5SNicolas Souchu.Pp
497d2d5f80SJoerg Wunsch.Bd -literal
507d2d5f80SJoerg Wunsch#include <sys/types.h>
517d2d5f80SJoerg Wunsch
527d2d5f80SJoerg Wunschstruct smbcmd {
537d2d5f80SJoerg Wunsch	char cmd;
547d2d5f80SJoerg Wunsch	int count;
557d2d5f80SJoerg Wunsch	u_char slave;
567d2d5f80SJoerg Wunsch	union {
577d2d5f80SJoerg Wunsch		char byte;
587d2d5f80SJoerg Wunsch		short word;
597d2d5f80SJoerg Wunsch
607d2d5f80SJoerg Wunsch		char *byte_ptr;
617d2d5f80SJoerg Wunsch		short *word_ptr;
627d2d5f80SJoerg Wunsch
637d2d5f80SJoerg Wunsch		struct {
647d2d5f80SJoerg Wunsch			short sdata;
657d2d5f80SJoerg Wunsch			short *rdata;
667d2d5f80SJoerg Wunsch		} process;
677d2d5f80SJoerg Wunsch	} data;
687d2d5f80SJoerg Wunsch};
697d2d5f80SJoerg Wunsch.Ed
707d2d5f80SJoerg Wunsch.Pp
717d2d5f80SJoerg WunschThe
727d2d5f80SJoerg Wunsch.Fa slave
737d2d5f80SJoerg Wunschfield is always used, and provides the address of the
747d2d5f80SJoerg WunschSMBus slave device to talk to.
753d33d453SJohn BaldwinThe slave address is specified in the seven most significant bits
763d33d453SJohn Baldwin.Pq i.e. Dq "left-justified" .
773d33d453SJohn BaldwinThe least significant bit of the slave address must be zero.
787d2d5f80SJoerg Wunsch.Pp
79bf7f20c2SRuslan Ermilov.Bl -column ".Dv SMB_QUICK_WRITE" -compact
80eb8752d5SNicolas Souchu.It Em Ioctl Ta Em Description
817d2d5f80SJoerg Wunsch.Pp
82bf7f20c2SRuslan Ermilov.It Dv SMB_QUICK_WRITE Ta
837d2d5f80SJoerg WunschThe
847d2d5f80SJoerg Wunsch.Em QuickWrite
857d2d5f80SJoerg Wunschcommand just issues the device address with write intent
867d2d5f80SJoerg Wunschto the bus, without transferring any data.
87bf7f20c2SRuslan Ermilov.It Dv SMB_QUICK_READ Ta
887d2d5f80SJoerg WunschThe
897d2d5f80SJoerg Wunsch.Em QuickRead
907d2d5f80SJoerg Wunschcommand just issues the device address with read intent
917d2d5f80SJoerg Wunschto the bus, without transferring any data.
92bf7f20c2SRuslan Ermilov.It Dv SMB_SENDB Ta
937d2d5f80SJoerg WunschThe
947d2d5f80SJoerg Wunsch.Em SendByte
957d2d5f80SJoerg Wunschcommand sends the byte provided in the
967d2d5f80SJoerg Wunsch.Fa cmd
977d2d5f80SJoerg Wunschfield to the device.
98bf7f20c2SRuslan Ermilov.It Dv SMB_RECVB Ta
997d2d5f80SJoerg WunschThe
1007d2d5f80SJoerg Wunsch.Em ReceiveByte
1017d2d5f80SJoerg Wunschcommand reads a single byte from the device which will
1027d2d5f80SJoerg Wunschbe returned in the
1037d2d5f80SJoerg Wunsch.Fa cmd
1047d2d5f80SJoerg Wunschfield.
105bf7f20c2SRuslan Ermilov.It Dv SMB_WRITEB Ta
1067d2d5f80SJoerg WunschThe
1077d2d5f80SJoerg Wunsch.Em WriteByte
1087d2d5f80SJoerg Wunschcommand first sends the byte from the
1097d2d5f80SJoerg Wunsch.Fa cmd
1107d2d5f80SJoerg Wunschfield to the device, followed by the byte given in
1117d2d5f80SJoerg Wunsch.Fa data.byte .
112bf7f20c2SRuslan Ermilov.It Dv SMB_WRITEW Ta
1137d2d5f80SJoerg WunschThe
1147d2d5f80SJoerg Wunsch.Em WriteWord
1157d2d5f80SJoerg Wunschcommand first sends the byte from the
1167d2d5f80SJoerg Wunsch.Fa cmd
1177d2d5f80SJoerg Wunschfield to the device, followed by the word given in
1187d2d5f80SJoerg Wunsch.Fa data.word .
1197d2d5f80SJoerg WunschNote that the SMBus byte-order is little-endian by definition.
120bf7f20c2SRuslan Ermilov.It Dv SMB_READB Ta
1217d2d5f80SJoerg WunschThe
1227d2d5f80SJoerg Wunsch.Em ReadByte
1237d2d5f80SJoerg Wunschcommand first sends the byte from the
1247d2d5f80SJoerg Wunsch.Fa cmd
1257d2d5f80SJoerg Wunschfield to the device, and then reads one byte of data from
1267d2d5f80SJoerg Wunschthe device.
1277d2d5f80SJoerg WunschThe returned data will be stored in the location pointed to by
1287d2d5f80SJoerg Wunsch.Fa data.byte_ptr .
129bf7f20c2SRuslan Ermilov.It Dv SMB_READW Ta
1307d2d5f80SJoerg WunschThe
1317d2d5f80SJoerg Wunsch.Em ReadWord
1327d2d5f80SJoerg Wunschcommand first sends the byte from the
1337d2d5f80SJoerg Wunsch.Fa cmd
1347d2d5f80SJoerg Wunschfield to the device, and then reads one word of data from
1357d2d5f80SJoerg Wunschthe device.
1367d2d5f80SJoerg WunschThe returned data will be stored in the location pointed to by
1377d2d5f80SJoerg Wunsch.Fa data.word_ptr .
138bf7f20c2SRuslan Ermilov.It Dv SMB_PCALL Ta
1397d2d5f80SJoerg WunschThe
1407d2d5f80SJoerg Wunsch.Em ProcedureCall
1417d2d5f80SJoerg Wunschcommand first sends the byte from the
1427d2d5f80SJoerg Wunsch.Fa cmd
1437d2d5f80SJoerg Wunschfield to the device, followed by the word provided in
1447d2d5f80SJoerg Wunsch.Fa data.process.sdata .
1457d2d5f80SJoerg WunschIt then reads one word of data from the device, and returns it
1467d2d5f80SJoerg Wunschin the location pointed to by
1477d2d5f80SJoerg Wunsch.Fa data.process.rdata .
148bf7f20c2SRuslan Ermilov.It Dv SMB_BWRITE Ta
1497d2d5f80SJoerg WunschThe
1507d2d5f80SJoerg Wunsch.Em BlockWrite
1517d2d5f80SJoerg Wunschcommand first sends the byte from the
1527d2d5f80SJoerg Wunsch.Fa cmd
1537d2d5f80SJoerg Wunschfield to the device, followed by
1547d2d5f80SJoerg Wunsch.Fa count
1557d2d5f80SJoerg Wunschbytes of data that are taken from the buffer pointed to by
1567d2d5f80SJoerg Wunsch.Fa data.byte_ptr .
1577d2d5f80SJoerg WunschThe SMBus specification mandates that no more than 32 bytes of
1587d2d5f80SJoerg Wunschdata can be transferred in a single block read or write command.
1597d2d5f80SJoerg WunschThis value is available in the constant
1607d2d5f80SJoerg Wunsch.Dv SMB_MAXBLOCKSIZE .
161bf7f20c2SRuslan Ermilov.It Dv SMB_BREAD Ta
1627d2d5f80SJoerg WunschThe
1637d2d5f80SJoerg Wunsch.Em BlockRead
1647d2d5f80SJoerg Wunschcommand first sends the byte from the
1657d2d5f80SJoerg Wunsch.Fa cmd
1667d2d5f80SJoerg Wunschfield to the device, and then reads
1677d2d5f80SJoerg Wunsch.Fa count
1687d2d5f80SJoerg Wunschbytes of data that from the device.
1697d2d5f80SJoerg WunschThese data will be returned in the buffer pointed to by
1707d2d5f80SJoerg Wunsch.Fa data.byte_ptr .
171eb8752d5SNicolas Souchu.El
172eb8752d5SNicolas Souchu.Pp
1737d2d5f80SJoerg WunschThe
1747d2d5f80SJoerg Wunsch.Xr read 2
1757d2d5f80SJoerg Wunschand
1767d2d5f80SJoerg Wunsch.Xr write 2
1777d2d5f80SJoerg Wunschsystem calls are not implemented by this driver.
1787d2d5f80SJoerg Wunsch.Sh ERRORS
1797d2d5f80SJoerg WunschThe
18049aa339eSRuslan Ermilov.Xr ioctl 2
1817d2d5f80SJoerg Wunschcommands can cause the following driver-specific errors:
1827d2d5f80SJoerg Wunsch.Bl -tag -width Er
1837d2d5f80SJoerg Wunsch.It Bq Er ENXIO
1847d2d5f80SJoerg WunschDevice did not respond to selection.
1857d2d5f80SJoerg Wunsch.It Bq Er EBUSY
1867d2d5f80SJoerg WunschDevice still in use.
1877d2d5f80SJoerg Wunsch.It Bq Er ENODEV
1887d2d5f80SJoerg WunschOperation not supported by device (not supposed to happen).
1897d2d5f80SJoerg Wunsch.It Bq Er EINVAL
1907d2d5f80SJoerg WunschGeneral argument error.
1917d2d5f80SJoerg Wunsch.It Bq Er EWOULDBLOCK
1927d2d5f80SJoerg WunschSMBus transaction timed out.
1937d2d5f80SJoerg Wunsch.El
194eb8752d5SNicolas Souchu.Sh SEE ALSO
1957d2d5f80SJoerg Wunsch.Xr ioctl 2 ,
196eb8752d5SNicolas Souchu.Xr smbus 4
197eb8752d5SNicolas Souchu.Sh HISTORY
198eb8752d5SNicolas SouchuThe
199eb8752d5SNicolas Souchu.Nm
200eb8752d5SNicolas Souchumanual page first appeared in
201eb8752d5SNicolas Souchu.Fx 3.0 .
202def37e7cSMike Pritchard.Sh AUTHORS
203eb8752d5SNicolas SouchuThis
204eb8752d5SNicolas Souchumanual page was written by
205eb8752d5SNicolas Souchu.An Nicolas Souchu .
206