Linux 内核头文件

发布于 10-10 09:46 字数 243 浏览 5 评论 0原文

  • 我想了解,内核基目录中的“/includes/”下放置了什么类型的头文件。这些文件在某种意义上是否旨在成为“公共”标头/API?从而忽略了体系结构、已启用/禁用的配置开关等?

  • 简而言之,如果我想在驱动程序中使用某些核心内核功能,我可以安全地假设我正在寻找的功能将包含在“/includes”下的相关头文件之一中,而不是其他地方吗?简而言之

期待一些评论。

谢谢..!

  • I want to understand, what type of header files are placed under "/includes/" in the base directory of the kernel. Are these files intended to be the "public" headers/API's in some sense ? Thereby being, oblivious of the architecture, config switches that have been enabled/disabled etc ?

  • In short, if I want to use some core kernel functionality within my driver, may I safely assume that the functionality I am looking for, would be contained in one of the relevant header files under "/includes" and nowhere else ?

Look forward to some comments.

Thanks..!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

明媚殇2024-10-17 09:46:07

我最近自己也在研究这个问题。

我不知道这个答案有多么相关,因为听起来您只关心了解手头的内核源代码的打包。这个答案可能只与你的第二个问题有关。尽管如此,这里还是我发现的一些关于内核头的东西。

根据我的发现,有两个潜在位置最终被称为“内核头”。

第一个位置是 /usr/src/linux-headers-`version' (至少在我的 Ubuntu 机器上)。这是安装内核(源代码?)以及随附标头的位置。如果您想构建内核模块,那么您将需要根据此处找到的标头进行构建。

另一方面 /usr/include/{linux,asm} 也包含“内核头”。您可以将这些头文件视为内核的用户层接口。它是内核导出的 API,因此用户层程序可以进行系统调用。您的 libc 将利用此 API,以便它可以根据可用的系统调用创建函数(在 /usr/include 中)。

这里有几个文档来支持我刚才所说的内容并进一步澄清一些事情:

这是关于 RHEL4 上 /usr/src/linux-headers-`version' 和 /usr/include 之间差异的链接。

http://www.linuxquestions.org /questions/red-hat-31/rhel4-kernel-devel-headers-packages-missing-directories-697552/

这是有关“导出”内核标头的链接:
http://www.kernel.org/doc/Documentation/make/headers_install.txt

最后这是内核头的另一个解释:
http://www.overclockers.com/forums/showthread.php?t=647638

所以也许您已经知道这一点,并且只想知道如何使用内核包中的源代码创建驱动程序,但至少有了这个答案,您知道它绝对是起点。

I've been looking into this matter a little bit myself recently.

I don't know how related this answer is since it sounds like you are only concerned about understanding the packaging of the kernel source you have on hand. This answer probably only pertains to your second question. Nevertheless here is some stuff I've found about kernel headers.

From what I've found there are two potential locations that end up being referred to as "kernel headers".

The first location is in /usr/src/linux-headers-`version' (at least on my Ubuntu machine). This is where your kernel (source?) is installed as well as the accompanying headers. If you want to build kernel modules then you will need to build against the headers found here.

On the other hand /usr/include/{linux,asm} also contain "kernel headers". You can think of these header files as the userland interface to your kernel. It is the API exported by the kernel so userland programs can make system calls. Your libc will take advantage of this API so it can create functions (in /usr/include) based on which system calls are available.

Here are a couple of documents to back up what I've just said and to clarify things a bit more:

Here is a link about the difference between /usr/src/linux-headers-`version' and /usr/include on RHEL4.

http://www.linuxquestions.org/questions/red-hat-31/rhel4-kernel-devel-headers-packages-missing-directories-697552/

Here is a link about 'exporting' kernel headers:
http://www.kernel.org/doc/Documentation/make/headers_install.txt

Finally here is another explanation of what kernel headers are for:
http://www.overclockers.com/forums/showthread.php?t=647638

So maybe you knew this already and you just wanted to know how to create a driver using the sources in your kernel package, but at least with this answer you know that its definitely the place to start.

弥枳2024-10-17 09:46:07

是的,include 包含用于内核开发的标准 API。

Yes, include contains the standard APIs for use with kernel development.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文