linux mailbox模型
一.device tree中的写法
二. mailbox框架 (driver/mailbox/mailbox.c)
struct mbox_controller {
struct device *dev; // 特定mailbox驱动probe时赋值 dev = &pdev->dev
const struct mbox_chan_ops *ops; // mailbox channel需要实现的功能函数
struct mbox_chan *chans; // mailbox channel指针数组
int num_chans; // mailbox channel个数
bool txdone_irq; // 通过中断来判断上次传输是否完成
bool txdone_poll; // 通过poll机制来判断上次传输是否完成
unsigned txpoll_period; // POLL 周期, 以ms计
struct mbox_chan *(*of_xlate)(struct mbox_controller *mbox,
const struct of_phandle_args *sp); // 获取特定channel的回调函数
/* Internal to API */
struct hrtimer poll_hrt;
struct list_head node;
};
struct mbox_chan {
struct mbox_controller *mbox; // contronller指针
unsigned txdone_method;
struct mbox_client *cl; // client指针
struct completion tx_complete; //
void *active_req;
unsigned msg_count, msg_free;
void *msg_data[MBOX_TX_QUEUE_LEN];
spinlock_t lock; /* Serialise access to the channel */
void *con_priv;
};
struct mbox_chan_ops {
int (*send_data)(struct mbox_chan *chan, void *data); // 发送数据(需要last data sent)
int (*startup)(struct mbox_chan *chan); // 特定mailbox 启动
void (*shutdown)(struct mbox_chan *chan); // 特定mailbox 关闭
bool (*last_tx_done)(struct mbox_chan *chan); // 如果TXDONE_BY_POLL 该回调会被使用
bool (*peek_data)(struct mbox_chan *chan); // 检测是否有数据
};
struct mbox_client {
struct device *dev; // client 设备
bool tx_block; // block until last data is all transmitted
unsigned long tx_tout; // max block period for timeout
bool knows_txdone; // txdone 回调,如果controller已经有txdone,则该配置无效
void (*rx_callback)(struct mbox_client *cl, void *mssg); // 收到数据
void (*tx_prepare)(struct mbox_client *cl, void *mssg); // 准备数据
void (*tx_done)(struct mbox_client *cl, void *mssg, int r); // 检测txdone
};
三. mailbox client 流程
通过mbox_request_channel_byname 根据"mbox-names"申请channel
创建mbox设备
通过mbox设备的write read 函数访问controller
其中write 通过调用mbox_send_message,
add_to_rbuf拷贝msg到chan->msg_data[MAX = 20]
msg_submit读取msg_data[idx],放到tx_prepare中,调用具体驱动的send message写寄存器
其中read 通过irq驱动
irq读取寄存器得到消息,调用mailbox.c中的mbox_chan_received_data,再调用client的rx_callback将得到的数据放到client->rx_buffer中
四. mailbox driver流程
配置controller属性:
申请chan,配置chan个数
配置of_xlate回调,获取chan
配置chan_ops
配置txdone判断方式
通过mailbox_controller_register 注册controller
五. 总结
driver 通过mbox_controller_register 注册controller
client 通过mbox_request_channel调用driver->startup
client 通过mbox_send_message调用driver->send_data,并等待txdone
driver 收到remote的中断读取数据调用mbox_chan_received_data将数据放到 client->rx_buffer中
linux mailbox模型的更多相关文章
- Linux IO模型和网络编程模型
术语概念描述: IO有内存IO.网络IO和磁盘IO三种,通常我们说的IO指的是后两者. 阻塞和非阻塞,是函数/方法的实现方式,即在数据就绪之前是立刻返回还是等待. 以文件IO为例,一个IO读过程是文件 ...
- Server Develop (五) Linux并发模型
Linux并发模型 目前可以实现并发程序的方法有Apache模型(Process Per Connection,简称PPC),TPC(Thread PerConnection)模型,以及select模 ...
- linux设备模型_转
建议原博文查看,效果更佳. 转自:http://www.cnblogs.com/wwang/category/269350.html Linux设备模型 (1) 随着计算机的周边外设越来越丰富,设备管 ...
- Linux设备模型(9)_device resource management ---devm申请空间【转】
转自:http://www.wowotech.net/linux_kenrel/device_resource_management.html . 前言 蜗蜗建议,每一个Linux驱动工程师,都能瞄一 ...
- Linux设备模型(总线、设备、驱动程序和类)
Linux设备驱动程序学习(13) -Linux设备模型(总线.设备.驱动程序和类)[转] 文章的例子和实验使用<LDD3>所配的lddbus模块(稍作修改). 提示:在学习这部分内容是一 ...
- Linux设备模型 学习总结
看LDD3中设备模型一章,觉得思维有些混乱.这里从整体的角度来理理思路.本文从四个方面来总结一些内容: 1.底层数据结构:kobject,kset.2.linux设备模型层次关系:bus_type,d ...
- Linux设备模型——设备驱动模型和sysfs文件系统解读
本文将对Linux系统中的sysfs进行简单的分析,要分析sysfs就必须分析内核的driver-model(驱动模型),两者是紧密联系的.在分析过程中,本文将以platform总线和spi主控制器的 ...
- Linux 线程模型的比较:LinuxThreads 和 NPTL
Linux 线程模型的比较:LinuxThreads 和 NPTL GNU_LIBPTHREAD_VERSION 宏 大部分现代 Linux 发行版都预装了 LinuxThreads 和 NPTL,因 ...
- 探索 Linux 内存模型--转
引用:http://www.ibm.com/developerworks/cn/linux/l-memmod/index.html 理解 Linux 使用的内存模型是从更大程度上掌握 Linux 设计 ...
随机推荐
- linux oops调试
参考文章: arm 指令定位错误 https://blog.csdn.net/songcdut/article/details/41383483 linux mips指令学习 https://www. ...
- Linux的简单命令
Linux的简单命令 1.更改linux服务器的登录密码 成功登录后输入命令: passwd 然后按照提示操作即可 2.在当前路径下新建文件夹:mkdir 新建文件夹名 3.解压和压缩文件tar.gz ...
- 3D Slicer中文教程(六)—调用matlab函数(MatlabBridge使用方法)
1.安装MatlabBridge插件 (1)在工具栏找到Extension,点击进入Extension Manager (2)找到MatlabBridge,安装 2.配置MATLAB环境 (1)在模块 ...
- QT学习之解决QT中QIcon图标不显示的问题
第一种:图标存放目录问题 :/文件夹名称/文件名 如:文件夹为:/img 文件名为:a.png 路径: :/img/a.png 这里注意前面的":". 第二种:编译生成 ...
- neo4j-cypher
cypher查询务必在需要查询的节点上加上标签,否则数据量一大查询就会非常慢(在查询时必须设置实体标签,否则不走索引),另外Neo4j索引做好了查询的优化基本上就完成了80%.需要注意index是建立 ...
- redis哨兵主从自动切换
1.用的是TP5框架,改写框架自带的redis类 thinkphp/library/think/cache/driver/Redis.php //两台服务器都配置好了监控哨兵 //主从配置要设置好密码 ...
- CentOS7.6最小化纯净版安装xfce桌面
安装Xfce桌面环境 yum groupinstall "X Window system" yum install epel-release yum groupinstall xf ...
- Safari无痕模式是不能只使用localStorage存储数据要用Cookie做补丁
safari 无痕浏览情况测试(部分手机) 1.测试机型 iPhone7 Plus 版本 11.3 iPhone6 Plus 版本 11.3.1 iPhone6 版本 10.2.1 iP ...
- buaaoo_second_improvement
你不优化,我不优化,那大家就都是满分啦 (一)写在最前 电梯问题由于和实际关联比较紧密,所以实际上可以操作的空间比较多. 但第二单元的电梯,需要实现捎带:第三单元的电梯,需要实现楼层限制.人数限制.三 ...
- ***微信小程序学习文档和资料归档收集
微信小程序官方文档: https://cloud.tencent.com/document/product/619 小程序培训视频教程: https://xw.qq.com/edu/201805140 ...