Kernel中uart接口的bluetooth driver初始化分析
来源:互联网 发布:软件技术开发公司 编辑:程序博客网 时间:2024/06/03 01:42
在前面几篇文章中,我们把kernel中bluetooth stack相关的初始化分析完成,今天晓东带大家来一起分析uart接口的bluetooth driver的初始化。首先,我们来到kernel/drivers/bluetooth目录,看hci_ldisc.c文件。又见到我们熟悉的module_init:
module_init(hci_uart_init);好吧,动手来看吧:
static int __init hci_uart_init(void){static struct tty_ldisc_ops hci_uart_ldisc;int err;BT_INFO("HCI UART driver ver %s", VERSION);/* Register the tty discipline */memset(&hci_uart_ldisc, 0, sizeof (hci_uart_ldisc));hci_uart_ldisc.magic= TTY_LDISC_MAGIC;hci_uart_ldisc.name= "n_hci";hci_uart_ldisc.open= hci_uart_tty_open;hci_uart_ldisc.close= hci_uart_tty_close;hci_uart_ldisc.read= hci_uart_tty_read;hci_uart_ldisc.write= hci_uart_tty_write;hci_uart_ldisc.ioctl= hci_uart_tty_ioctl;hci_uart_ldisc.poll= hci_uart_tty_poll;hci_uart_ldisc.receive_buf= hci_uart_tty_receive;hci_uart_ldisc.write_wakeup= hci_uart_tty_wakeup;hci_uart_ldisc.owner= THIS_MODULE;//注册了一个tty的新的线路规程,为N_HCI,并定义了他的一系列的操作/*线路规程有什么作用呢,我们可以这样理解,tty向应用层注册了一系列的通用接口,这些接口(比如写数据)被调用后会根据对应的线路规程去找对应的driver,然后driver会对数据做一些处理发送到硬件中去。这个通路反过来也是成立。大概的模型如下:-----tty层---------------线路规程----------driver层------------硬件层---------*/if ((err = tty_register_ldisc(N_HCI, &hci_uart_ldisc))) {BT_ERR("HCI line discipline registration failed. (%d)", err);return err;}//以h4为例来进行讲解h4_init();……return 0;}int __init h4_init(void){//就是向uart protol中注册对应的driver,详细分析见下面。int err = hci_uart_register_proto(&h4p);if (!err)BT_INFO("HCI H4 protocol initialized");elseBT_ERR("HCI H4 protocol registration failed");return err;}static struct hci_uart_proto h4p = {.id= HCI_UART_H4,.open= h4_open,.close= h4_close,.recv= h4_recv,.enqueue= h4_enqueue,.dequeue= h4_dequeue,.flush= h4_flush,};int hci_uart_register_proto(struct hci_uart_proto *p){if (p->id >= HCI_UART_MAX_PROTO)return -EINVAL;if (hup[p->id])return -EEXIST;//其实说白了就是初始化hup数组(hci uart proto)//在这之后的open,write,read什么的就可以通过这个数组找到对应proto的相应的调用接口中去 hup[p->id] = p;return 0;}
所以,总的来说,uart这边的脉络还是很清楚的,就是首先注册线路规程,所有和蓝牙相关的数据将会选择HCI这个线路规程,然后根据各家的方案设计不同,注册对应的proto,数据最终会根据proto选择对应的driver去做处理后发送到对应的硬件(蓝牙controller中)。
- Kernel中uart接口的bluetooth driver初始化分析
- Kernel中uart接口的bluetooth driver初始化分析
- kernel中bluetooth的初始化
- kernel中bluetooth的初始化
- Kernel中bluetooth相关的config选项
- Kernel中bluetooth相关的config选项
- Kernel中bluetooth相关的config选项
- linux kernel初始化分析
- UART driver
- uart driver
- Bluetooth driver
- Kernel中rfcomm层的初始化
- Kernel中Hid和Bnep的初始化
- Kernel中rfcomm层的初始化
- Kernel中Hid和Bnep的初始化
- UART串口软件接口的设计与分析
- Win7中VirtualBox Cannot access the kernel driver的解决
- 一、Bluetooth Native层与协议栈的接口及其初始化过程
- 学习Javascript闭包(Closure)
- c#winform treeview根据菜单创建节点
- 借助网盘搭建SVN服务器
- 强制转换
- [HDU 3746]Cyclic Nacklace[kmp求周期]
- Kernel中uart接口的bluetooth driver初始化分析
- 用Windows Server 2008搭建时钟同步服务器
- NC5自定义多级按钮
- [H265/HEVC]开源项目
- 子模块
- rsa_eay_private_encrypt
- java图片处理类(图片水印,图片缩放)
- 正则表达式
- 详细解析Java中抽象类和接口的区别(转)