简体   繁体   English

访问 Linux 驱动程序

[英]Accessing Linux Drivers

Simply put, can a user space application access device drivers running in kernel mode?简单地说,用户空间应用程序可以访问在内核模式下运行的设备驱动程序吗? If I want to read from the I2C Linux character driver, can a basic C executable (extensionless) do that or do I need to develop a kernel module specifically for that task?如果我想从 I2C Linux 字符驱动程序中读取数据,基本的 C 可执行文件(无扩展)可以做到这一点,还是我需要专门为该任务开发内核模块? If a basic C app can access the I2C character driver, what does that gcc makefile look like?如果基本的 C 应用程序可以访问 I2C 字符驱动程序,那么 gcc 生成文件是什么样的?

Yes.是的。 User space application can access the kernel driver if the driver is character device or the driver exposing the stream interfaces.如果驱动程序是字符设备或暴露流接口的驱动程序,则用户空间应用程序可以访问内核驱动程序。

Specific to i2c, user space application can write and reads to the i2c device via sysfs api.特定于 i2c,用户空间应用程序可以通过 sysfs api 写入和读取 i2c 设备。 Refer the kernel document here https://www.kernel.org/doc/Documentation/i2c/dev-interface请参阅此处的内核文档https://www.kernel.org/doc/Documentation/i2c/dev-interface

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM