日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

嵌入式设备串口命名的地方

發布時間:2025/3/15 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 嵌入式设备串口命名的地方 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一下函數在dricers/serial/s3c2410.c中

static int s3c24xx_serial_initconsole(void) {struct s3c24xx_uart_info *info;struct platform_device *dev = s3c24xx_uart_devs[0];dbg("s3c24xx_serial_initconsole\n");/* select driver based on the cpu */if (dev == NULL) {printk(KERN_ERR "s3c24xx: no devices for console init\n");return 0;}if (strcmp(dev->name, "s3c2400-uart") == 0) {info = s3c2400_uart_inf_at;} else if (strcmp(dev->name, "s3c2410-uart") == 0) {info = s3c2410_uart_inf_at;} else if (strcmp(dev->name, "s3c2440-uart") == 0) {info = s3c2440_uart_inf_at;} else if (strcmp(dev->name, "s3c2412-uart") == 0) {info = s3c2412_uart_inf_at;} else {printk(KERN_ERR "s3c24xx: no driver for %s\n", dev->name);return 0;}if (info == NULL) {printk(KERN_ERR "s3c24xx: no driver for console\n");return 0;}s3c24xx_serial_console.data = &s3c24xx_uart_drv;s3c24xx_serial_init_ports(info);register_console(&s3c24xx_serial_console); //向內核注冊串口return 0; }

/* s3c24xx_serial_initconsole** initialise the console from one of the uart drivers */static struct console s3c24xx_serial_console = {.name = S3C24XX_SERIAL_NAME,.device = uart_console_device,.flags = CON_PRINTBUFFER,.index = -1,.write = s3c24xx_serial_console_write,.setup = s3c24xx_serial_console_setup }

可以看出S3C24XX_SERIAL_NAME被定義為ttySAC因此在創建串口設備的時候使用的是名字是ttySAC0,其中的0代表使用的是串口0,也就是第一個串口。
從途中還是可以看出設備的主設備號是204次設備號是64,要是使用手動創建也使用這個主設備號和次設備號

內核根據kernel/printk.c中的

__setup("console=", console_setup);

確定printk輸出的設備。
內核開始執行時,發現形如"console=…“的命令參數時,就會調用console_setup函數進行解析。對于參數"console=ttySAC0”,它會解析出設備名(name)為ttySAC,索引為(index)0,這些信息會保存在console_cmdline中,

.flags = CON_PRINTBUFFER, 定義之后就可以使用printk打印在內核沒有啟動console之前的printk信息,因為在硬件初始化之前就是用了printk函數,但是當時沒有初始化串口無法與用戶進行交互,只能將信息放到緩沖區中。
既然printk輸出的信息是先保存在緩沖區log_buf中的,那么也可以讀取log_buf,以獲取這些信息,系統啟動之后想看printk信息,直接運行dmesg命令即可。

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的嵌入式设备串口命名的地方的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。