国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
mailbox的controller


tiantao20122017-09-19 14:41:44 
版權(quán)聲明:本文為博主原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請(qǐng)附上原文出處鏈接和本聲明。
版權(quán)
mailbox是kernel提供的一種板子上的硬件和soc通過(guò)messages queue,interrupt 進(jìn)行通訊的一個(gè)架構(gòu)。正式版的英文翻譯如下:menuconfig MAILBOXbool "Mailbox Hardware Support"help  Mailbox is a framework to control hardware communication between  on-chip processors through queued messages and interrupt driven  signals. Say Y if your platform supports hardware mailboxes.mailbox的實(shí)現(xiàn)分為contoller和client。簡(jiǎn)單的說(shuō)就是clinet 可以通過(guò)controller提供的channle發(fā)送信息給conroller因此在drivers/mailbox下實(shí)現(xiàn)的都是controller的源碼具體到某個(gè)廠商的硬件,則描述如下:config ARM_MHU    tristate "ARM MHU Mailbox"    depends on ARM_AMBA    help      Say Y here if you want to build the ARM MHU controller driver.      The controller has 3 mailbox channels, the last of which can be      used in Secure mode only.通過(guò)makefile我們知道要實(shí)現(xiàn)mailbox的源文件其實(shí)只有兩個(gè)obj-$(CONFIG_MAILBOX)+= mailbox.oobj-$(CONFIG_ARM_MHU)+= arm_mhu.o其中mailbox.c 是kernel提供的framework,arm_mhu.c 則是具體廠商的實(shí)現(xiàn)這里直接看arm_mhu.c的probe函數(shù)static int mhu_probe(struct amba_device *adev, const struct amba_id *id){int i, err;struct arm_mhu *mhu;struct device *dev = &adev->dev;int mhu_reg[MHU_CHANS] = {MHU_LP_OFFSET, MHU_HP_OFFSET, MHU_SEC_OFFSET};/* Allocate memory for device */mhu = devm_kzalloc(dev, sizeof(*mhu), GFP_KERNEL);if (!mhu)return -ENOMEM;mhu->base = devm_ioremap_resource(dev, &adev->res);if (IS_ERR(mhu->base)) {dev_err(dev, "ioremap failed\n");return PTR_ERR(mhu->base);}//mailbox的channel 表示可以發(fā)送信息的寄存器for (i = 0; i < MHU_CHANS; i++) {mhu->chan[i].con_priv = &mhu->mlink[i];mhu->mlink[i].irq = adev->irq[i];mhu->mlink[i].rx_reg = mhu->base + mhu_reg[i];mhu->mlink[i].tx_reg = mhu->mlink[i].rx_reg + TX_REG_OFFSET;}//初始化mbox的結(jié)構(gòu)體mhu->mbox.dev = dev;mhu->mbox.chans = &mhu->chan[0];mhu->mbox.num_chans = MHU_CHANS;//mbox.ops 表示mailbox這個(gè)硬件具體的操作,例如發(fā)送數(shù)據(jù),初始化等mhu->mbox.ops = &mhu_ops;//發(fā)送數(shù)據(jù)采用poll的方式mhu->mbox.txdone_irq = false;mhu->mbox.txdone_poll = true;mhu->mbox.txpoll_period = 1;amba_set_drvdata(adev, mhu);//所有的controller 最終都要通過(guò)mbox_controller_register 來(lái)注冊(cè)自己err = mbox_controller_register(&mhu->mbox);if (err) {dev_err(dev, "Failed to register mailboxes %d\n", err);return err;}dev_info(dev, "ARM MHU Mailbox registered\n");return 0;}int mbox_controller_register(struct mbox_controller *mbox){int i, txdone;//下面這四個(gè)任何一個(gè)為null,就退出注冊(cè)/* Sanity check */if (!mbox || !mbox->dev || !mbox->ops || !mbox->num_chans)return -EINVAL;//client發(fā)送數(shù)據(jù)是通過(guò)poll的方式還是irq的方式,后面針對(duì)兩種方式有不同的處理方式if (mbox->txdone_irq)txdone = TXDONE_BY_IRQ;else if (mbox->txdone_poll)txdone = TXDONE_BY_POLL;else /* It has to be ACK then */txdone = TXDONE_BY_ACK;//如果是poll的方式,則注冊(cè)一個(gè)timer,定時(shí)查詢if (txdone == TXDONE_BY_POLL) {if (!mbox->ops->last_tx_done) {dev_err(mbox->dev, "last_tx_done method is absent\n");return -EINVAL;}hrtimer_init(&mbox->poll_hrt, CLOCK_MONOTONIC,     HRTIMER_MODE_REL);mbox->poll_hrt.function = txdone_hrtimer;}//初始化controller的channel,表示contoller 同時(shí)能盡量幾路信息的傳遞for (i = 0; i < mbox->num_chans; i++) {struct mbox_chan *chan = &mbox->chans[i];chan->cl = NULL;chan->mbox = mbox;chan->txdone_method = txdone;spin_lock_init(&chan->lock);}if (!mbox->of_xlate)mbox->of_xlate = of_mbox_index_xlate;//所有的mailbox最終都會(huì)添加到mbox_cons 這個(gè)list中mutex_lock(&con_mutex);list_add_tail(&mbox->node, &mbox_cons);mutex_unlock(&con_mutex);return 0;}
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Linux下的LCD驅(qū)動(dòng)分析
CAN Readme-linux
SPI Driver for Linux Based Embedded System | Invotronics
E1?T1口的配置
IP沖突檢測(cè)程序源碼及分析
Android音頻框架筆記
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服