知道在哪里填充结构 [英] Knowing where op structs are filled

查看:85
本文介绍了知道在哪里填充结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试编写Linux驱动程序,为此,我必须了解一些API才能充分利用它们.通常,我会遇到一种模式,在该模式下我开始研究一个功能,并最终在该函数读取以下内容:

I am currently trying to write a linux driver and for this it is necessary that I understand some apis to make best use of them. Often I come across a pattern where I start digging into a funciton and end up at a point where the function reads:

returnType OperationX(args...) {
    ...
    struct operations_t operations = get_operations();
    if(operations->X)
        return operations->X(args...)

}

基本上get_operations()返回一个指向全局结构的指针,该结构包含指向运行该操作的实际函数的指针.

Basically get_operations() returns a pointer to a global struct, which holds a pointer to the actual function running the operation.

使用 Linux交叉引用来深入研究不同的地方,然后真正理解,我发现它非常繁琐实际发生的分配.有更好的更快方法吗?

I find it very tedious using the linux cross reference to dig into the different places and then actually understand which assignement actually takes place. Is there a better faster way?

一个例子是 dma映射.

推荐答案

git grep和cscope是您最好的朋友.

git grep and cscope are your best friends.

顺便说一下,DMA操作是由平台代码或在IOMMU实现中填充的.我敢打赌,很可能您正在使用lib/swiotlb.c.

By the way, DMA operations are filled either by platform code or in IOMMU implementations. I bet most probably you have lib/swiotlb.c in use for that.

这篇关于知道在哪里填充结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆