SMB(4)
π SMB(4) β the Kernel Interfaces Manual girlies know
okay so bestie, this is the smb page from the Kernel Interfaces Manual, and it's literally all about the SMB generic I/O device driver. strap in π
β¨ NAME β¨
smb β SMB generic I/O device driver
πΈ SYNOPSIS πΈ
device smb
π¦ DESCRIPTION π¦
The smb character device driver provides generic I/O to any smbus(4) instance. no cap, any of them. π
To control SMB devices, you use /dev/smb? with the ioctls described below. Every single one of these ioctl commands takes a pointer to struct smbcmd as its argument. yes, all of them, it's giving consistent π
#include <sys/types.h>
struct smbcmd {
u_char cmd;
u_char reserved;
u_short op;
union {
char byte;
char buf[2];
short word;
} wdata;
union {
char byte;
char buf[2];
short word;
} rdata;
int slave;
char *wbuf; /* use wdata if NULL */
int wcount;
char *rbuf; /* use rdata if NULL */
int rcount;
};
The slave field is always used β like, every time, it's not optional, it's the main character. It gives you the address of the SMBus slave device. π«Ά
β οΈ the slave address is specified in the seven most significant bits (i.e., "left-justified"), and the least significant bit of the slave address must be zero. periodt.
okay now the actual menu of ioctls, bestie. here's what each one does π
SMB_QUICK_WRITEβ QuickWrite does not transfer any data. it just issues the device address with write intent to the bus. that's it, that's the whole job πSMB_QUICK_READβ QuickRead does not transfer any data either. it just issues the device address with read intent to the bus. twin behavior, different intent β¨SMB_SENDBβ SendByte sends the byte provided incmdto the device.SMB_RECVBβ ReceiveByte reads a single byte from the device, and that byte is returned incmd.SMB_WRITEBβ WriteByte first sends the byte fromcmdto the device, followed by the byte given inwdata.byte.SMB_WRITEWβ WriteWord first sends the byte fromcmdto the device, followed by the word given inwdata.word. note that the SMBus byte-order is little-endian by definition β that's not a choice, that's just the rules πSMB_READBβ ReadByte first sends the byte fromcmdto the device, then reads one byte of data from the device. the returned data is stored inrdata.byte.SMB_READWβ ReadWord first sends the byte fromcmdto the device, then reads one word of data from the device. the returned data is stored inrdata.word.SMB_PCALLβ ProcedureCall first sends the byte fromcmdto the device, followed by the word provided inwdata.word. then it reads one word of data from the device and returns it inrdata.word. it's giving full round trip π₯SMB_BWRITEβ BlockWrite first sends the byte fromcmdto the device, then the byte fromwcount, followed bywcountbytes of data taken from the buffer pointed to bywbuf.
heads up bestie: the SMBus specification mandates that no more than 32 bytes of data can be transferred in a single block read or write command. you can read that value from the constant SMB_MAXBLOCKSIZE. don't push it π
SMB_BREADβ BlockRead first sends the byte fromcmdto the device, then reads a count of data bytes that the device is going to provide, and then reads that many bytes. the count is returned inrcount. the data is returned in the buffer pointed to byrbuf.
real talk: theread(2)andwrite(2)system calls are not implemented by this driver. like, at all. don't try it π
π ERRORS π
The ioctl(2) commands can cause the following driver-specific errors β these are the specific ones this driver can throw at you:
[ENXIO]β Device did not respond to selection. it's ghosting you π[EBUSY]β Device still in use.[ENODEV]β Operation not supported by device (not supposed to happen).[EINVAL]β General argument error.[EWOULDBLOCK]β SMBus transaction timed out.
π SEE ALSO π
π HISTORY π
The smb manual page first appeared in FreeBSD 3.0. iconic from day one β¨
π«Ά AUTHORS π«Ά
This manual page was written by Nicolas Souchu and extended by Michael Gmelin <freebsd@grem.de>. give them their flowers π
and that's the whole page, bestie!! this one came from Debian, dated April 25, 2015 β so yeah, vintage but still serving. mwah π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1998, Nicolas Souchu
- Copyright (c) 2004, Joerg Wunsch
- Copyright (c) 2015, Michael Gmelin <freebsd@grem.de>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms