static struct uart_ops serial8250_pops = {
.tx_empty = serial8250_tx_empty,
.set_mctrl = serial8250_set_mctrl,
.get_mctrl = serial8250_get_mctrl,
.stop_tx = serial8250_stop_tx,
.start_tx = serial8250_start_tx,
.stop_rx = serial8250_stop_rx,
.enable_ms = serial8250_enable_ms,
.break_ctl = serial8250_break_ctl,
.startup = serial8250_startup,
.shutdown = serial8250_shutdown,
.set_termios = serial8250_set_termios,
.pm = serial8250_pm,
.type = serial8250_type,
.release_port = serial8250_release_port,
.request_port = serial8250_request_port,
.config_port = serial8250_config_port,
.verify_port = serial8250_verify_port,
};
static struct uart_driver serial8250_reg = {
.owner = THIS_MODULE,
.driver_name = "serial",
.dev_name = "ttyS",
.major = TTY_MAJOR,
.minor = 64,
.nr = UART_NR,
.cons = SERIAL8250_CONSOLE,
};
在串口的操作中,除了一些初始化的操作外,最重要的就是串口的读和写了。串口的写有两种方式,一种是查询方式,另外一种是中断
方式,当上层发送写的请求时,串口驱动先检查(看LSR中TE和THE)是否符合串口的写,如果符合写的条件,开始写入串口控制器的FIFO,
写完一次等待发送中断,表示上一次的数据已经发送成功,可以继续送入发送的数据。
而在串口的读操作中,是通过中断方式实现,如果有数据接收到,串口控制器会发送接收中断,驱动在中断处理函数中接收到数据,返回上层。