1 # Copyright 2018 syzkaller project authors. All rights reserved. 2 # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 include <uapi/linux/i2c-dev.h> 5 include <uapi/linux/i2c.h> 6 7 define I2C_MAX_BLOCK (I2C_SMBUS_BLOCK_MAX + 2) 8 9 resource fd_i2c[fd] 10 11 syz_open_dev$I2C(dev ptr[in, string["/dev/i2c-#"]], id intptr, flags flags[open_flags]) fd_i2c 12 13 ioctl$I2C_RETRIES(fd fd_i2c, cmd const[I2C_RETRIES], arg intptr) 14 ioctl$I2C_TIMEOUT(fd fd_i2c, cmd const[I2C_TIMEOUT], arg intptr) 15 ioctl$I2C_SLAVE(fd fd_i2c, cmd const[I2C_SLAVE], arg intptr[0:0x3ff]) 16 ioctl$I2C_SLAVE_FORCE(fd fd_i2c, cmd const[I2C_SLAVE_FORCE], arg intptr[0:0x3ff]) 17 ioctl$I2C_TENBIT(fd fd_i2c, cmd const[I2C_TENBIT], arg boolptr) 18 ioctl$I2C_PEC(fd fd_i2c, cmd const[I2C_PEC], arg intptr) 19 20 ioctl$I2C_FUNCS(fd fd_i2c, cmd const[I2C_FUNCS], arg ptr[in, intptr]) 21 ioctl$I2C_RDWR(fd fd_i2c, cmd const[I2C_RDWR], arg ptr[in, i2c_rdwr_ioctl_data]) 22 ioctl$I2C_SMBUS(fd fd_i2c, cmd const[I2C_SMBUS], arg ptr[in, i2c_smbus_ioctl_data]) 23 24 i2c_smbus_ioctl_data { 25 read_write bool8 26 command int8 27 size int32[I2C_SMBUS_QUICK:I2C_SMBUS_I2C_BLOCK_DATA] 28 data ptr[in, i2c_smbus_data] 29 } 30 31 i2c_smbus_data [ 32 byte int8 33 word int16 34 block array[int8, I2C_MAX_BLOCK] 35 ] 36 37 i2c_rdwr_ioctl_data { 38 msgs ptr[in, array[i2c_msg]] 39 nmsgs len[msgs, int32] 40 } 41 42 i2c_msg { 43 addr int16 44 flags flags[i2c_msg_flags, int16] 45 len len[buf, int16] 46 buf ptr[in, array[int8]] 47 } 48 49 i2c_msg_flags = I2C_M_RD, I2C_M_TEN, I2C_M_DMA_SAFE, I2C_M_RECV_LEN, I2C_M_NO_RD_ACK, I2C_M_IGNORE_NAK, I2C_M_REV_DIR_ADDR, I2C_M_NOSTART, I2C_M_STOP 50