一.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模型的更多相关文章

  1. Linux IO模型和网络编程模型

    术语概念描述: IO有内存IO.网络IO和磁盘IO三种,通常我们说的IO指的是后两者. 阻塞和非阻塞,是函数/方法的实现方式,即在数据就绪之前是立刻返回还是等待. 以文件IO为例,一个IO读过程是文件 ...

  2. Server Develop (五) Linux并发模型

    Linux并发模型 目前可以实现并发程序的方法有Apache模型(Process Per Connection,简称PPC),TPC(Thread PerConnection)模型,以及select模 ...

  3. linux设备模型_转

    建议原博文查看,效果更佳. 转自:http://www.cnblogs.com/wwang/category/269350.html Linux设备模型 (1) 随着计算机的周边外设越来越丰富,设备管 ...

  4. Linux设备模型(9)_device resource management ---devm申请空间【转】

    转自:http://www.wowotech.net/linux_kenrel/device_resource_management.html . 前言 蜗蜗建议,每一个Linux驱动工程师,都能瞄一 ...

  5. Linux设备模型(总线、设备、驱动程序和类)

    Linux设备驱动程序学习(13) -Linux设备模型(总线.设备.驱动程序和类)[转] 文章的例子和实验使用<LDD3>所配的lddbus模块(稍作修改). 提示:在学习这部分内容是一 ...

  6. Linux设备模型 学习总结

    看LDD3中设备模型一章,觉得思维有些混乱.这里从整体的角度来理理思路.本文从四个方面来总结一些内容: 1.底层数据结构:kobject,kset.2.linux设备模型层次关系:bus_type,d ...

  7. Linux设备模型——设备驱动模型和sysfs文件系统解读

    本文将对Linux系统中的sysfs进行简单的分析,要分析sysfs就必须分析内核的driver-model(驱动模型),两者是紧密联系的.在分析过程中,本文将以platform总线和spi主控制器的 ...

  8. Linux 线程模型的比较:LinuxThreads 和 NPTL

    Linux 线程模型的比较:LinuxThreads 和 NPTL GNU_LIBPTHREAD_VERSION 宏 大部分现代 Linux 发行版都预装了 LinuxThreads 和 NPTL,因 ...

  9. 探索 Linux 内存模型--转

    引用:http://www.ibm.com/developerworks/cn/linux/l-memmod/index.html 理解 Linux 使用的内存模型是从更大程度上掌握 Linux 设计 ...

随机推荐

  1. JAVA使用HttpClient时报错:Algorithm constraints check failed on signature algorithm: MD5withRSA

    今天使用httpClient.executeMethod时抛出异常:java.security.cert.CertPathValidatorException: Algorithm constrain ...

  2. JustSoso笔记

    当时想了大半天,想着到底要怎么绕过MD5呢,结果还是没做出来,即使问了学长,自己还是漏了一个步骤,file=hint.php,特此笔记,又学到了个引用变量的知识 学习自 https://www.ctf ...

  3. Qt+mpg123+openal播放MP3流

    #ifndef PLAYSTREAM_H #define PLAYSTREAM_H #include <QObject> #include "../libMPG123/mpg12 ...

  4. [SDOI2009]HH的项链-树状数组/线段树

    树状数组: #include<bits/stdc++.h> using namespace std; ; int id[maxn],tree[maxn],vis[maxn],num[max ...

  5. 收藏一个可以学习javascript prototype的链接

    https://github.com/mqyqingfeng/Blog/issues/2

  6. javascript任务队列

    摘自:https://www.cnblogs.com/liangyin/p/9783342.html,谢谢作者分享! 任务队列 所有任务可以分成两种,一种是 同步任务(synchronous),另一种 ...

  7. C#多条件查出来的多个DataSet,然后循环将数据整合

    private List<string> barList;        public List<string> BarList        {            get ...

  8. C语言--第0份作业

        对网络专业的了解 •网络专业是现如今比较难学的科目,要学习利用计算机对网络进行管理开发. •网络专业对于思维的要求比较高,需要我们有一定的数学思维. •网络专业的人才比较缺失,只要我们学的足够 ...

  9. 关于haproxy

    高性能负载均衡软件 haproxy 一.四层和七层负载均衡的区别: 所谓的四层就是OSI参考模型中的第四层,四层负载均衡也称为四层交换机,他主要是通过分析IP层及TCP/UDP层的流量实现的基于IP加 ...

  10. Continuity of arithmetic operations

    Arithmetic operations taught in elementary schools are continuous in the high level topological poin ...