namespace.rst 17 KB

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