- 5
- 0
- 约2.95万字
- 约 37页
- 2021-10-17 发布于江苏
- 举报
Linux 串口(serial、uart)驱动程序设计
/space.php?uido=blogid=34481
一、核心数据结构
串口驱动有3个核心数据结构,它们都定义在#includelinux/serial_core.h
1、uart_driver
uart_driver包含了串口设备名、串口驱动名、主次设备号、串口控制台(可选)
等信息,还封装了tty_driver(底层串口驱动无需关心tty_driver)。
struct uart_driver {
struct module *owner; /* 拥有该uart_driver 的模块,一般为THIS_MODULE
*/
const char *driver_name; /* 串口驱动名,串口设备文件名以驱动名为基础
*/
const char *dev_name; /* 串口设备名 */
int major; /* 主设备号 */
int minor; /* 次设备号 */
int nr; /* 该uart_driver 支持的串口个数(最大) */
struct console *cons; /* 其对应的console.若该uart_driver 支持serial console,
否则为NULL */
/*
* these are private; the low level driver should not
* touch these; they should be initialised to NULL
*/
struct uart_state *state;
struct tty_driver *tty_driver;
};
2、uart_port
uart_port用于描述串口端口的I/O端口或I/O内存地址、FIFO大小、端口类型、
串口时钟等信息。实际上,一个uart_port实例对应一个串口设备
struct uart_port {
spinlock_t lock; /* 串口端口锁 */
unsigned int iobase ; /* IO 端口基地址 */
unsigned char __iomem *membase ; /* IO 内存基地址,经映射(如ioremap)
后的IO 内存虚拟基地址 */
unsigned int irq ; /* 中断号 */
unsigned int uartclk ; /* 串口时钟 */
unsigned int fifosize ; /* 串口FIFO 缓冲大小 */
unsigned char x_char ; /* xon/xoff 字符 */
unsigned char regshift ; /* 寄存器位移 */
unsigned char iotype ; /* IO 访问方式 */
unsigned char unused1 ;
#define UPIO_PORT (0) /* IO 端口 */
#define UPIO_HUB6 (1)
#define UPIO_MEM (2) /* IO 内存 */
#define UPIO_MEM32 (3)
#define UPIO_AU (4) /* Au1x00 type IO */
#define UPIO_TSI (5) /* Tsi108/109 type IO */
#define UPIO_DWAPB (6) /* DesignWare APB UART */
#define UPIO_RM9000 (7) /* RM9000 type IO */
unsigned int read_status_mask ; /* 关心的Rx error status */
unsigned int ignore_status_mask ;/* 忽略的Rx error status */
struct uart_info *info; /* pointer to parent info */
struct uart_icount icount ; /* 计数器 */
struct console *cons; /* console 结构体 */
#ifdef CONFIG_SERIAL_CORE_CONSOLE
unsigned long sysrq ; /* sysrq timeout */
#endif
upf_t flags ;
#define UPF_FOURPORT ((__force upf_t) (1 1))
#
您可能关注的文档
最近下载
- 明代宗教信仰与思想控制.docx VIP
- 江苏省南通市2024-2025学年高二上学期期末学业质量监测语文试卷(含答案).pdf VIP
- 国就有成人演出的电影了?想看就要冒生命危险.pdf VIP
- 综合素质练习题及答案.doc VIP
- 2020-2021学年北京高三化学二轮复习 反应原理型简答题(突破二卷)(word版 含答案).docx VIP
- 电力拖动控制线路安装与检修(白银矿冶职业技术学院)知到智慧树答案.docx VIP
- 煤炭巷道掘砌工(高级工)资格考试题库(全真题库).docx VIP
- 影像叙事中情感共鸣生成机制.docx VIP
- 同轴二级圆柱齿轮减速器的设计(硬齿面).doc VIP
- 基于GPU多线程多通道图像高速重构方法、设备及介质.pdf VIP
原创力文档

文档评论(0)