首页 文章

如何在Linux内核驱动程序上获取ACPI设备列表?

提问于
浏览
1

我正在开发一个Linux内核驱动程序 . 部分要求是获取系统上的ACPI设备列表并进行迭代 . 虽然以下代码适用于用户模式,但它不会在内核上编译 .

#include <dirent.h>
#include <stdio.h>

int main(void)
{
   DIR           * d;
   struct dirent * dir;
   d = opendir("/sys/bus/acpi/devices");

   if (d)
   {
      while ((dir = readdir(d)) != NULL)
      {
         printf("%s\n", dir->d_name);
      }

      closedir(d);
   }

   return 0;
}

内核中是否有类似的功能可供我获取ACPI设备列表?

1 回答

  • 1

    您使用linux内核空间头文件和内核中未使用的函数编写的代码 . Linux内核有自己的处理设备的方式 .

    在内核中:ACPI实现枚举总线(平台,SPI和I2C)后面的设备,创建物理设备并将它们绑定到ACPI名称空间中的ACPI句柄 . 阅读完整的内核文本here .

相关问题