- Android系統級深入開發
- 韓超 梁泉
- 286字
- 2018-12-29 13:39:35
4.4.4 TTY終端的驅動程序
GoldFish虛擬處理器的TTY終端的驅動程序,也就是提供了虛擬串口功能的驅動程序,相關文件如下所示:
drivers/char/goldfish_tty.c
GoldFish的TTY終端的驅動程序在sys文件系統的driver路徑如下所示:
# ls /sys/bus/platform/drivers/goldfish_tty goldfish_tty.0 goldfish_tty.1 goldfish_tty.2 uevent unbind bind
GoldFish的TTY終端的驅動程序在用戶空間有3個設備,節點分別為/dev/ttyS0,/dev/ttyS1和/dev/ttyS2。
這個驅動程序只支持寫操作,驅動程序寫的功能在goldfish_tty_do_write中實現,操作如下所示:
static void goldfish_tty_do_write(int line, const char *buf, unsigned count) { unsigned long irq_flags; struct goldfish_tty *qtty = &goldfish_ttys[line]; uint32_t base = qtty->base; spin_lock_irqsave(&qtty->lock, irq_flags); writel(buf, base + GOLDFISH_TTY_DATA_PTR); /* 寫入虛擬串口寄存器:數據指針 */ writel(count, base + GOLDFISH_TTY_DATA_LEN); /* 寫入虛擬串口寄存器:數據長度 */ writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, base + GOLDFISH_TTY_CMD); spin_unlock_irqrestore(&qtty->lock, irq_flags); }
串口的功能比實際的串口功能要簡單得多,進行的是直接對虛擬寄存器的寫操作,仿真器環境根據情況進行處理。
推薦閱讀
- MATLAB應用與實驗教程
- 精通網絡視頻核心開發技術
- 劍指MySQL:架構、調優與運維
- QGIS By Example
- Hands-On Full Stack Development with Go
- Learning Laravel's Eloquent
- Advanced Express Web Application Development
- D3.js By Example
- 智能搜索和推薦系統:原理、算法與應用
- 計算語言學導論
- Xamarin Cross-Platform Development Cookbook
- MongoDB Cookbook
- Building Web and Mobile ArcGIS Server Applications with JavaScript(Second Edition)
- Zend Framework 2 Cookbook
- 基于JavaScript的WebGIS開發