TTY IOCTL 助手¶
-
unsigned int tty_chars_in_buffer(struct tty_struct *tty)¶
待处理字符
参数
struct tty_struct *tty
终端
返回值
设备私有输出队列中的数据字节数。如果没有提供私有方法,则假定设备上没有队列。
-
unsigned int tty_write_room(struct tty_struct *tty)¶
写入队列空间
参数
struct tty_struct *tty
终端
返回值
当前可以排队到此设备的字节数。结果应被视为保证,并且驱动程序提供的数值在后续缩小幅度上不能超过写入的字节数。如果没有提供方法,则始终返回 2K,并且可能会丢失数据,因为没有流量控制。
-
void tty_driver_flush_buffer(struct tty_struct *tty)¶
丢弃内部缓冲区
参数
struct tty_struct *tty
终端
描述
丢弃此设备的内部输出缓冲区。如果没有提供方法,则缓冲区无法进行硬件刷新,或者没有驱动程序端的缓冲区。
-
void tty_unthrottle(struct tty_struct *tty)¶
流量控制
参数
struct tty_struct *tty
终端
描述
指示 tty 可以继续向下堆栈传输数据。使用 tty_struct->termios_rwsem
来防止并行 throttle/unthrottle,并确保驱动程序在此处实现软件流量控制时可以一致地引用其自己的 termios 数据。
但是,驱动程序应记住,堆栈可以发出 throttle,然后更改流量控制方法,然后 unthrottle。
-
bool tty_throttle_safe(struct tty_struct *tty)¶
流量控制
参数
struct tty_struct *tty
终端
描述
指示 tty 应停止向下堆栈传输数据。tty_throttle_safe()
仅在 tty->flow_change 为 TTY_THROTTLE_SAFE
时才会尝试 throttle。防止由于在 throttle 之前评估的因素而导致 throttle 有条件时,由于竞争条件而意外 throttle。
返回值
如果 tty 被 throttle(或已被 throttle),则为 true
-
bool tty_unthrottle_safe(struct tty_struct *tty)¶
流量控制
参数
struct tty_struct *tty
终端
描述
与 tty_unthrottle()
类似,但仅在 tty->flow_change 为 TTY_UNTHROTTLE_SAFE
时才会尝试 unthrottle。防止由于在 unthrottle 之前评估的因素而导致 unthrottle 有条件时,由于竞争条件而意外 unthrottle。
返回值
如果 tty 被 unthrottle(或已被 unthrottle),则为 true
-
void tty_wait_until_sent(struct tty_struct *tty, long timeout)¶
等待 I/O 完成
参数
struct tty_struct *tty
我们正在等待的 tty
long timeout
我们将等待多久
描述
等待 tty 驱动程序中待处理的字符到达线路,或等待超时发生(例如,由于流量控制)。
锁定:无
-
void tty_termios_copy_hw(struct ktermios *new, const struct ktermios *old)¶
复制硬件设置
参数
struct ktermios *new
新 termios
const struct ktermios *old
旧 termios
描述
将硬件特定的终端设置位从 old termios 结构传播到 new 结构。这用于硬件不支持重新配置的情况,或者作为仅支持最小重新配置的一些情况下的助手。
-
bool tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b)¶
检查设置更改
参数
const struct ktermios *a
termios
const struct ktermios *b
要比较的 termios
描述
检查影响哑设备的任何位是否在两个 termios 结构之间发生了更改,或者是否需要速度更改。
返回值
如果需要更改,则为 true
-
unsigned char tty_get_char_size(unsigned int cflag)¶
获取字符大小
参数
unsigned int cflag
termios cflag 值
返回值
取决于 cflag 的 CSIZE
设置的字符大小(以位为单位)
-
unsigned char tty_get_frame_size(unsigned int cflag)¶
获取帧大小
参数
unsigned int cflag
termios cflag 值
描述
根据 cflag 的 CSIZE
、CSTOPB
和 PARENB
设置获取帧的大小(以位为单位)。结果是字符大小、起始位和停止位(每个一位)、第二个停止位(如果设置)以及奇偶校验位(如果设置)的总和。
返回值
取决于 cflag 设置的帧的大小(以位为单位)。
-
int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios)¶
更新 termios 值
参数
struct tty_struct *tty
要更新的 tty
struct ktermios *new_termios
所需的新值
描述
对在此 tty 上设置的 termios 值执行更新。主 pty 的 termios 永远不应设置。
-
int set_termios(struct tty_struct *tty, void __user *arg, int opt)¶
设置 tty 的 termios 值
参数
struct tty_struct *tty
终端设备
void __user *arg
用户数据
int opt
选项信息
描述
在实际进行更改之前,使用助手函数准备 termios 数据并运行必要的其他函数,然后使用 tty_set_termios()
。
锁定:调用的函数采用 tty_struct->ldisc_sem
和 tty_struct->termios_rwsem
锁
返回值
成功时为 0,否则为错误
-
int set_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb)¶
设置旧式终端值
参数
struct tty_struct *tty
tty 结构
struct sgttyb __user *sgttyb
指向旧式终端结构的指针
描述
从旧式 BSD 终端信息结构更新终端。
返回值
成功时为 0,否则为错误
-
int tty_change_softcar(struct tty_struct *tty, bool enable)¶
载波更改 ioctl 助手
参数
struct tty_struct *tty
要更新的 tty
bool enable
启用/禁用
CLOCAL
描述
执行 CLOCAL
状态的更改,并调用驱动程序层使其可见。
返回值
成功时为 0,否则为错误
-
int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)¶
模式相关的 ioctl
参数
struct tty_struct *tty
ioctl 的 tty
unsigned int cmd
命令
unsigned long arg
ioctl 参数
描述
执行非线路规程特定的模式控制 ioctl。这旨在由线路规程调用,以确保它们提供一致的模式设置。
-
speed_t tty_get_baud_rate(const struct tty_struct *tty)¶
获取 tty 比特率
参数
const struct tty_struct *tty
要查询的 tty
返回值
此终端的波特率(整数)
描述
锁定:调用方必须持有 termios 锁。