namespace.txt 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. ACPI Device Tree - Representation of ACPI Namespace
  2. Copyright (C) 2013, Intel Corporation
  3. Author: Lv Zheng <lv.zheng@intel.com>
  4. Abstract:
  5. The Linux ACPI subsystem converts ACPI namespace objects into a Linux
  6. device tree under the /sys/devices/LNXSYSTEM:00 and updates it upon
  7. receiving ACPI hotplug notification events. For each device object in this
  8. hierarchy there is a corresponding symbolic link in the
  9. /sys/bus/acpi/devices.
  10. This document illustrates the structure of the ACPI device tree.
  11. Credit:
  12. Thanks for the help from Zhang Rui <rui.zhang@intel.com> and Rafael J.
  13. Wysocki <rafael.j.wysocki@intel.com>.
  14. 1. ACPI Definition Blocks
  15. The ACPI firmware sets up RSDP (Root System Description Pointer) in the
  16. system memory address space pointing to the XSDT (Extended System
  17. Description Table). The XSDT always points to the FADT (Fixed ACPI
  18. Description Table) using its first entry, the data within the FADT
  19. includes various fixed-length entries that describe fixed ACPI features
  20. of the hardware. The FADT contains a pointer to the DSDT
  21. (Differentiated System Descripition Table). The XSDT also contains
  22. entries pointing to possibly multiple SSDTs (Secondary System
  23. Description Table).
  24. The DSDT and SSDT data is organized in data structures called definition
  25. blocks that contain definitions of various objects, including ACPI
  26. control methods, encoded in AML (ACPI Machine Language). The data block
  27. of the DSDT along with the contents of SSDTs represents a hierarchical
  28. data structure called the ACPI namespace whose topology reflects the
  29. structure of the underlying hardware platform.
  30. The relationships between ACPI System Definition Tables described above
  31. are illustrated in the following diagram.
  32. +---------+ +-------+ +--------+ +------------------------+
  33. | RSDP | +->| XSDT | +->| FADT | | +-------------------+ |
  34. +---------+ | +-------+ | +--------+ +-|->| DSDT | |
  35. | Pointer | | | Entry |-+ | ...... | | | +-------------------+ |
  36. +---------+ | +-------+ | X_DSDT |--+ | | Definition Blocks | |
  37. | Pointer |-+ | ..... | | ...... | | +-------------------+ |
  38. +---------+ +-------+ +--------+ | +-------------------+ |
  39. | Entry |------------------|->| SSDT | |
  40. +- - - -+ | +-------------------| |
  41. | Entry | - - - - - - - -+ | | Definition Blocks | |
  42. +- - - -+ | | +-------------------+ |
  43. | | +- - - - - - - - - -+ |
  44. +-|->| SSDT | |
  45. | +-------------------+ |
  46. | | Definition Blocks | |
  47. | +- - - - - - - - - -+ |
  48. +------------------------+
  49. |
  50. OSPM Loading |
  51. \|/
  52. +----------------+
  53. | ACPI Namespace |
  54. +----------------+
  55. Figure 1. ACPI Definition Blocks
  56. NOTE: RSDP can also contain a pointer to the RSDT (Root System
  57. Description Table). Platforms provide RSDT to enable
  58. compatibility with ACPI 1.0 operating systems. The OS is expected
  59. to use XSDT, if present.
  60. 2. Example ACPI Namespace
  61. All definition blocks are loaded into a single namespace. The namespace
  62. is a hierarchy of objects identified by names and paths.
  63. The following naming conventions apply to object names in the ACPI
  64. namespace:
  65. 1. All names are 32 bits long.
  66. 2. The first byte of a name must be one of 'A' - 'Z', '_'.
  67. 3. Each of the remaining bytes of a name must be one of 'A' - 'Z', '0'
  68. - '9', '_'.
  69. 4. Names starting with '_' are reserved by the ACPI specification.
  70. 5. The '\' symbol represents the root of the namespace (i.e. names
  71. prepended with '\' are relative to the namespace root).
  72. 6. The '^' symbol represents the parent of the current namespace node
  73. (i.e. names prepended with '^' are relative to the parent of the
  74. current namespace node).
  75. The figure below shows an example ACPI namespace.
  76. +------+
  77. | \ | Root
  78. +------+
  79. |
  80. | +------+
  81. +-| _PR | Scope(_PR): the processor namespace
  82. | +------+
  83. | |
  84. | | +------+
  85. | +-| CPU0 | Processor(CPU0): the first processor
  86. | +------+
  87. |
  88. | +------+
  89. +-| _SB | Scope(_SB): the system bus namespace
  90. | +------+
  91. | |
  92. | | +------+
  93. | +-| LID0 | Device(LID0); the lid device
  94. | | +------+
  95. | | |
  96. | | | +------+
  97. | | +-| _HID | Name(_HID, "PNP0C0D"): the hardware ID
  98. | | | +------+
  99. | | |
  100. | | | +------+
  101. | | +-| _STA | Method(_STA): the status control method
  102. | | +------+
  103. | |
  104. | | +------+
  105. | +-| PCI0 | Device(PCI0); the PCI root bridge
  106. | +------+
  107. | |
  108. | | +------+
  109. | +-| _HID | Name(_HID, "PNP0A08"): the hardware ID
  110. | | +------+
  111. | |
  112. | | +------+
  113. | +-| _CID | Name(_CID, "PNP0A03"): the compatible ID
  114. | | +------+
  115. | |
  116. | | +------+
  117. | +-| RP03 | Scope(RP03): the PCI0 power scope
  118. | | +------+
  119. | | |
  120. | | | +------+
  121. | | +-| PXP3 | PowerResource(PXP3): the PCI0 power resource
  122. | | +------+
  123. | |
  124. | | +------+
  125. | +-| GFX0 | Device(GFX0): the graphics adapter
  126. | +------+
  127. | |
  128. | | +------+
  129. | +-| _ADR | Name(_ADR, 0x00020000): the PCI bus address
  130. | | +------+
  131. | |
  132. | | +------+
  133. | +-| DD01 | Device(DD01): the LCD output device
  134. | +------+
  135. | |
  136. | | +------+
  137. | +-| _BCL | Method(_BCL): the backlight control method
  138. | +------+
  139. |
  140. | +------+
  141. +-| _TZ | Scope(_TZ): the thermal zone namespace
  142. | +------+
  143. | |
  144. | | +------+
  145. | +-| FN00 | PowerResource(FN00): the FAN0 power resource
  146. | | +------+
  147. | |
  148. | | +------+
  149. | +-| FAN0 | Device(FAN0): the FAN0 cooling device
  150. | | +------+
  151. | | |
  152. | | | +------+
  153. | | +-| _HID | Name(_HID, "PNP0A0B"): the hardware ID
  154. | | +------+
  155. | |
  156. | | +------+
  157. | +-| TZ00 | ThermalZone(TZ00); the FAN thermal zone
  158. | +------+
  159. |
  160. | +------+
  161. +-| _GPE | Scope(_GPE): the GPE namespace
  162. +------+
  163. Figure 2. Example ACPI Namespace
  164. 3. Linux ACPI Device Objects
  165. The Linux kernel's core ACPI subsystem creates struct acpi_device
  166. objects for ACPI namespace objects representing devices, power resources
  167. processors, thermal zones. Those objects are exported to user space via
  168. sysfs as directories in the subtree under /sys/devices/LNXSYSTM:00. The
  169. format of their names is <bus_id:instance>, where 'bus_id' refers to the
  170. ACPI namespace representation of the given object and 'instance' is used
  171. for distinguishing different object of the same 'bus_id' (it is
  172. two-digit decimal representation of an unsigned integer).
  173. The value of 'bus_id' depends on the type of the object whose name it is
  174. part of as listed in the table below.
  175. +---+-----------------+-------+----------+
  176. | | Object/Feature | Table | bus_id |
  177. +---+-----------------+-------+----------+
  178. | N | Root | xSDT | LNXSYSTM |
  179. +---+-----------------+-------+----------+
  180. | N | Device | xSDT | _HID |
  181. +---+-----------------+-------+----------+
  182. | N | Processor | xSDT | LNXCPU |
  183. +---+-----------------+-------+----------+
  184. | N | ThermalZone | xSDT | LNXTHERM |
  185. +---+-----------------+-------+----------+
  186. | N | PowerResource | xSDT | LNXPOWER |
  187. +---+-----------------+-------+----------+
  188. | N | Other Devices | xSDT | device |
  189. +---+-----------------+-------+----------+
  190. | F | PWR_BUTTON | FADT | LNXPWRBN |
  191. +---+-----------------+-------+----------+
  192. | F | SLP_BUTTON | FADT | LNXSLPBN |
  193. +---+-----------------+-------+----------+
  194. | M | Video Extension | xSDT | LNXVIDEO |
  195. +---+-----------------+-------+----------+
  196. | M | ATA Controller | xSDT | LNXIOBAY |
  197. +---+-----------------+-------+----------+
  198. | M | Docking Station | xSDT | LNXDOCK |
  199. +---+-----------------+-------+----------+
  200. Table 1. ACPI Namespace Objects Mapping
  201. The following rules apply when creating struct acpi_device objects on
  202. the basis of the contents of ACPI System Description Tables (as
  203. indicated by the letter in the first column and the notation in the
  204. second column of the table above):
  205. N:
  206. The object's source is an ACPI namespace node (as indicated by the
  207. named object's type in the second column). In that case the object's
  208. directory in sysfs will contain the 'path' attribute whose value is
  209. the full path to the node from the namespace root.
  210. F:
  211. The struct acpi_device object is created for a fixed hardware
  212. feature (as indicated by the fixed feature flag's name in the second
  213. column), so its sysfs directory will not contain the 'path'
  214. attribute.
  215. M:
  216. The struct acpi_device object is created for an ACPI namespace node
  217. with specific control methods (as indicated by the ACPI defined
  218. device's type in the second column). The 'path' attribute containing
  219. its namespace path will be present in its sysfs directory. For
  220. example, if the _BCL method is present for an ACPI namespace node, a
  221. struct acpi_device object with LNXVIDEO 'bus_id' will be created for
  222. it.
  223. The third column of the above table indicates which ACPI System
  224. Description Tables contain information used for the creation of the
  225. struct acpi_device objects represented by the given row (xSDT means DSDT
  226. or SSDT).
  227. The forth column of the above table indicates the 'bus_id' generation
  228. rule of the struct acpi_device object:
  229. _HID:
  230. _HID in the last column of the table means that the object's bus_id
  231. is derived from the _HID/_CID identification objects present under
  232. the corresponding ACPI namespace node. The object's sysfs directory
  233. will then contain the 'hid' and 'modalias' attributes that can be
  234. used to retrieve the _HID and _CIDs of that object.
  235. LNXxxxxx:
  236. The 'modalias' attribute is also present for struct acpi_device
  237. objects having bus_id of the "LNXxxxxx" form (pseudo devices), in
  238. which cases it contains the bus_id string itself.
  239. device:
  240. 'device' in the last column of the table indicates that the object's
  241. bus_id cannot be determined from _HID/_CID of the corresponding
  242. ACPI namespace node, although that object represents a device (for
  243. example, it may be a PCI device with _ADR defined and without _HID
  244. or _CID). In that case the string 'device' will be used as the
  245. object's bus_id.
  246. 4. Linux ACPI Physical Device Glue
  247. ACPI device (i.e. struct acpi_device) objects may be linked to other
  248. objects in the Linux' device hierarchy that represent "physical" devices
  249. (for example, devices on the PCI bus). If that happens, it means that
  250. the ACPI device object is a "companion" of a device otherwise
  251. represented in a different way and is used (1) to provide configuration
  252. information on that device which cannot be obtained by other means and
  253. (2) to do specific things to the device with the help of its ACPI
  254. control methods. One ACPI device object may be linked this way to
  255. multiple "physical" devices.
  256. If an ACPI device object is linked to a "physical" device, its sysfs
  257. directory contains the "physical_node" symbolic link to the sysfs
  258. directory of the target device object. In turn, the target device's
  259. sysfs directory will then contain the "firmware_node" symbolic link to
  260. the sysfs directory of the companion ACPI device object.
  261. The linking mechanism relies on device identification provided by the
  262. ACPI namespace. For example, if there's an ACPI namespace object
  263. representing a PCI device (i.e. a device object under an ACPI namespace
  264. object representing a PCI bridge) whose _ADR returns 0x00020000 and the
  265. bus number of the parent PCI bridge is 0, the sysfs directory
  266. representing the struct acpi_device object created for that ACPI
  267. namespace object will contain the 'physical_node' symbolic link to the
  268. /sys/devices/pci0000:00/0000:00:02:0/ sysfs directory of the
  269. corresponding PCI device.
  270. The linking mechanism is generally bus-specific. The core of its
  271. implementation is located in the drivers/acpi/glue.c file, but there are
  272. complementary parts depending on the bus types in question located
  273. elsewhere. For example, the PCI-specific part of it is located in
  274. drivers/pci/pci-acpi.c.
  275. 5. Example Linux ACPI Device Tree
  276. The sysfs hierarchy of struct acpi_device objects corresponding to the
  277. example ACPI namespace illustrated in Figure 2 with the addition of
  278. fixed PWR_BUTTON/SLP_BUTTON devices is shown below.
  279. +--------------+---+-----------------+
  280. | LNXSYSTEM:00 | \ | acpi:LNXSYSTEM: |
  281. +--------------+---+-----------------+
  282. |
  283. | +-------------+-----+----------------+
  284. +-| LNXPWRBN:00 | N/A | acpi:LNXPWRBN: |
  285. | +-------------+-----+----------------+
  286. |
  287. | +-------------+-----+----------------+
  288. +-| LNXSLPBN:00 | N/A | acpi:LNXSLPBN: |
  289. | +-------------+-----+----------------+
  290. |
  291. | +-----------+------------+--------------+
  292. +-| LNXCPU:00 | \_PR_.CPU0 | acpi:LNXCPU: |
  293. | +-----------+------------+--------------+
  294. |
  295. | +-------------+-------+----------------+
  296. +-| LNXSYBUS:00 | \_SB_ | acpi:LNXSYBUS: |
  297. | +-------------+-------+----------------+
  298. | |
  299. | | +- - - - - - - +- - - - - - +- - - - - - - -+
  300. | +-| PNP0C0D:00 | \_SB_.LID0 | acpi:PNP0C0D: |
  301. | | +- - - - - - - +- - - - - - +- - - - - - - -+
  302. | |
  303. | | +------------+------------+-----------------------+
  304. | +-| PNP0A08:00 | \_SB_.PCI0 | acpi:PNP0A08:PNP0A03: |
  305. | +------------+------------+-----------------------+
  306. | |
  307. | | +-----------+-----------------+-----+
  308. | +-| device:00 | \_SB_.PCI0.RP03 | N/A |
  309. | | +-----------+-----------------+-----+
  310. | | |
  311. | | | +-------------+----------------------+----------------+
  312. | | +-| LNXPOWER:00 | \_SB_.PCI0.RP03.PXP3 | acpi:LNXPOWER: |
  313. | | +-------------+----------------------+----------------+
  314. | |
  315. | | +-------------+-----------------+----------------+
  316. | +-| LNXVIDEO:00 | \_SB_.PCI0.GFX0 | acpi:LNXVIDEO: |
  317. | +-------------+-----------------+----------------+
  318. | |
  319. | | +-----------+-----------------+-----+
  320. | +-| device:01 | \_SB_.PCI0.DD01 | N/A |
  321. | +-----------+-----------------+-----+
  322. |
  323. | +-------------+-------+----------------+
  324. +-| LNXSYBUS:01 | \_TZ_ | acpi:LNXSYBUS: |
  325. +-------------+-------+----------------+
  326. |
  327. | +-------------+------------+----------------+
  328. +-| LNXPOWER:0a | \_TZ_.FN00 | acpi:LNXPOWER: |
  329. | +-------------+------------+----------------+
  330. |
  331. | +------------+------------+---------------+
  332. +-| PNP0C0B:00 | \_TZ_.FAN0 | acpi:PNP0C0B: |
  333. | +------------+------------+---------------+
  334. |
  335. | +-------------+------------+----------------+
  336. +-| LNXTHERM:00 | \_TZ_.TZ00 | acpi:LNXTHERM: |
  337. +-------------+------------+----------------+
  338. Figure 3. Example Linux ACPI Device Tree
  339. NOTE: Each node is represented as "object/path/modalias", where:
  340. 1. 'object' is the name of the object's directory in sysfs.
  341. 2. 'path' is the ACPI namespace path of the corresponding
  342. ACPI namespace object, as returned by the object's 'path'
  343. sysfs attribute.
  344. 3. 'modalias' is the value of the object's 'modalias' sysfs
  345. attribute (as described earlier in this document).
  346. NOTE: N/A indicates the device object does not have the 'path' or the
  347. 'modalias' attribute.