<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by KUSHAL CHAKRABORTY on Medium]]></title>
        <description><![CDATA[Stories by KUSHAL CHAKRABORTY on Medium]]></description>
        <link>https://medium.com/@kushaldps1996?source=rss-20cb97d60801------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gQ-P1gT9jdXlxbXZ.jpg</url>
            <title>Stories by KUSHAL CHAKRABORTY on Medium</title>
            <link>https://medium.com/@kushaldps1996?source=rss-20cb97d60801------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 02:27:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kushaldps1996/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Windows ACPI Device Enumeration- From Namespace Nodes to Driver Binding]]></title>
            <link>https://medium.com/@kushaldps1996/windows-acpi-device-enumeration-from-namespace-nodes-to-driver-binding-637e97e03681?source=rss-20cb97d60801------2</link>
            <guid isPermaLink="false">https://medium.com/p/637e97e03681</guid>
            <dc:creator><![CDATA[KUSHAL CHAKRABORTY]]></dc:creator>
            <pubDate>Thu, 06 Aug 2026 03:26:01 GMT</pubDate>
            <atom:updated>2026-08-09T04:55:17.036Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Companion to the Linux ACPI device-enumeration walkthrough, re-expressed for the Windows PnP model. This picks up where namespace construction ends (see the Windows ACPI initialization document -acpi.sys + AMLI have loaded the DSDT/SSDTs and built the namespace) and follows a namespace node all the way to a PDO, a bound function driver (FDO), assigned resources, and its final home in the registry Enum tree and Device Manager.</blockquote><h3>Table of Contents</h3><ol><li>Introduction - the enumeration problem on Windows</li><li>Key Data Structures</li><li>Phase 1: acpi.sys as Bus Driver — DriverEntry / AddDevice</li><li>Phase 2: Namespace Walk (IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations)</li><li>Phase 3: PDO Creation (_STA, _HID, _CID, _UID, _ADR, _DSD)</li><li>Phase 4: Driver Attachment (PnP manager, INF matching, FDO stack)</li><li>Phase 5: Resource Assignment (_CRS → CM_RESOURCE_LIST, arbiters)</li><li>Dependency Resolution (_DEP and Windows dependency ordering)</li><li>Subsystem-Specific Enumeration</li><li>The Unified Property Interface (DEVPROPKEY / _DSD)</li><li>Final Representation (Registry Enum, Device Manager, WMI)</li><li>Key Takeaways + Complete Call Graph</li></ol><h3>1. Introduction</h3><h3>1.1 The enumeration problem on Windows</h3><p>After acpi.sys and AMLI have loaded the DSDT/SSDTs, the kernel holds a fully <strong>parsed ACPI namespace </strong>- a tree of NSOBJ nodes (Device, Processor, ThermalZone, Method, Name, OperationRegion, …) rooted at \. That namespace is <em>inert</em>: it describes AML objects, not something the Windows PnP manager knows how to build a driver stack on.</p><p>The enumeration problem on Windows is <strong>bridging two worlds</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*6CgK-dyeRH0MHUXoZX_6Og.png" /></figure><p>The crucial structural difference from Linux: Windows enumeration is <strong>IRP-driven and layered</strong>, not a single tree walk. acpi.sys is the <strong>bus driver</strong> (FDO) for the ACPI namespace; when the PnP manager asks it “what&#39;s on your bus?” (IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations), acpi.sys walks \_SB, <strong>creates a PDO</strong> for each qualifying device, and returns them. The PnP manager then, per PDO:</p><ol><li>Reads the PDO’s <strong>hardware IDs / compatible IDs</strong> (from _HID/_CID).</li><li>Searches INF databases + the driver store for a <strong>matching driver.</strong></li><li>Builds a device stack: the PDO (owned by acpi.sys) at the bottom, a function driver (FDO) on top, plus optional filter drivers.</li><li>Sends IRP_MN_QUERY_RESOURCE_REQUIREMENTS, runs the arbiters, assigns resources, and sends IRP_MN_START_DEVICE with a CM_RESOURCE_LIST.</li><li>The function driver’s EvtDevicePrepareHardware / StartDevice runs - the device is live.</li></ol><p>So where Linux calls .probe/.add inline during a namespace walk, Windows splits the work between <strong>acpi.sys (produces PDOs + resources from AML) and the PnP manager (matches and starts drivers)</strong>, communicating through IRPs.</p><h3>1.2 The dual role of acpi.sys</h3><p>acpi.sys wears two hats simultaneously - this is essential to understanding everything below:</p><ul><li><strong>Bus driver (FDO) for the ACPI namespace</strong>. It sits on top of the root PDO the PnP manager hands it, enumerates \_SB, and manufactures a PDO for every ACPI device. It answers BusRelations, QueryId, QueryResources, QueryResourceRequirements, and power IRPs <em>on behalf of those PDOs</em>.</li><li><strong>Filter/function driver for ACPI features of other devices</strong>. For a device that has <em>both</em> a real bus (e.g. a PCI device) <em>and</em> an ACPI namespace companion (with _PRW, _PS0, _DSM, _PLD…), acpi.sys inserts itself as a filter in that device&#39;s stack so it can service the ACPI methods. This is the Windows analogue of Linux&#39;s <em>companion</em> / physical_node link.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*K5hG313cI174apywEq76XQ.png" /></figure><h3>1.3 Overview of the enumeration pipeline</h3><p>The phases, mapped to their Linux equivalents:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b2de847c3fe6ff17b5c1d2cd87bdec2/href">https://medium.com/media/1b2de847c3fe6ff17b5c1d2cd87bdec2/href</a></iframe><h3>2. Key Data Structures</h3><p>Windows enumeration revolves around a mix of <strong>documented </strong>driver-model objects (DEVICE_OBJECT, DEVICE_RELATIONS, CM_RESOURCE_LIST) and <strong>internal </strong>acpi.sys structures that wrap namespace nodes. Understanding the mapping makes the rest obvious.</p><h3>2.1 The DEVICE_OBJECT / device node - Linux acpi_device analogue</h3><p>Where Linux has one struct acpi_device per namespace node, Windows has a pair: an <strong>internal </strong>acpi.sys device extension bound to the AML node, plus a <strong>PDO </strong>(DEVICE_OBJECT) that represents it to the PnP manager.</p><pre>typedef struct _DEVICE_OBJECT {<br>    CSHORT              Type;<br>    USHORT              Size;<br>    LONG                ReferenceCount;<br>    struct _DRIVER_OBJECT *DriverObject;   /* acpi.sys for a PDO         */<br>    struct _DEVICE_OBJECT *NextDevice;<br>    struct _DEVICE_OBJECT *AttachedDevice; /* FDO stacked above this PDO */<br>    ...<br>    PVOID               DeviceExtension;   /* acpi.sys per-device state  */<br>    DEVICE_TYPE         DeviceType;<br>    ULONG               Flags;             /* DO_BUS_ENUMERATED_DEVICE … */<br>} DEVICE_OBJECT;</pre><ul><li>The PnP manager identifies each enumerated device by its <strong>devnode </strong>(PDEVICE_NODE), an internal tree structure keyed by the PDO. The devnode holds the device&#39;s state machine (see section 6), instance path, and resource lists.</li><li>acpi.sys&#39;s DeviceExtension on the PDO is the true analogue of struct acpi_device: it stores the AML NSOBJ handle, the decoded status, the cached _HID/_CID/_UID/_ADR, power capabilities, and the _DEP list.</li></ul><h3>2.2 acpi.sys internal device extension - the wrapper</h3><p>Conceptually (names are internal), acpi.sys keeps something like:</p><pre>typedef struct _ACPI_DEVICE_EXTENSION {   // internal to acpi.sys<br>    PDEVICE_OBJECT   Pdo;                 // the PDO handed to PnP<br>    PNSOBJ           AmliNode;            // the namespace node (\_SB.xxx)<br>    DEVICE_STATUS    Status;              // decoded _STA (see §2.4)<br>    ULONG            Flags;               // present/enumerated/dep-unmet…<br>    PWCHAR           HardwareIDs;         // MULTI_SZ from _HID + _CID<br>    PWCHAR           CompatibleIDs;       // MULTI_SZ (subset for compat)<br>    PWCHAR           InstanceID;          // from _UID / _ADR<br>    ULONGLONG        Address;             // from _ADR<br>    DEVICE_POWER_STATE PowerState;        // _PSx / _PRx model<br>    LIST_ENTRY       DependentList;       // _DEP consumers/suppliers<br>    PACPI_POWER_INFO PowerInfo;           // _PRW wake data<br>    ...<br>} ACPI_DEVICE_EXTENSION;</pre><p>This is the structural twin of Linux’s struct acpi_device (see section 2.1 of the Linux doc): one per namespace device, embedding the node handle plus decoded identity, status, power, and dependency data.</p><h3>2.3 DEVICE_RELATIONS - the “children of this bus” list</h3><p>The result acpi.sys returns from IRP_MN_QUERY_DEVICE_RELATIONS (BusRelations). This is the Windows analogue of the <em>set of child devices</em> Linux discovers during acpi_walk_namespace.</p><pre>typedef struct _DEVICE_RELATIONS {<br>    ULONG          Count;<br>    PDEVICE_OBJECT Objects[1];   // variable-length array of child PDOs<br>} DEVICE_RELATIONS, *PDEVICE_RELATIONS;</pre><p>The PnP manager compares the returned list against the previous one to detect arrivals (new PDOs → start them) and departures (missing PDOs → remove them). This diffing is how ACPI hot-plug (dock, dynamic _STA, Notify(0x00) “bus check”) is realised - the analogue of Linux re-running acpi_bus_scan.</p><h3>2.4 Device status - the _STA decode</h3><p>_STA returns a 32-bit value; Windows decodes the low 5 bits identically to the ACPI spec (see section 5.1 for full semantics):</p><pre>// conceptual flags on the decoded _STA<br>#define ACPI_STA_DEVICE_PRESENT      0x01   // bit 0<br>#define ACPI_STA_DEVICE_ENABLED      0x02   // bit 1<br>#define ACPI_STA_DEVICE_UI           0x04   // bit 2 (show in UI)<br>#define ACPI_STA_DEVICE_FUNCTIONING  0x08   // bit 3<br>#define ACPI_STA_BATTERY_PRESENT     0x10   // bit 4 (battery only)</pre><p>The PnP manager surfaces the result through the devnode’s problem code (e.g. CM_PROB_PHANTOM / CM_PROB_NOT_CONFIGURED when not present) and the DN_* device-node flags.</p><h3>2.5 Hardware IDs &amp; Compatible IDs — the identity strings</h3><p>Windows PnP identifies devices by two MULTI_SZ string lists that acpi.sys manufactures from _HID/_CID (returned via IRP_MN_QUERY_ID):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/853ec04294265d0e955a0a4015b28d84/href">https://medium.com/media/853ec04294265d0e955a0a4015b28d84/href</a></iframe><p>The ACPI\ prefix is the <strong>enumerator </strong>name. This ID ranking is the Windows analogue of Linux&#39;s _HID-then-_CID match order (section 6.2 Linux).</p><h3>2.6 CM_RESOURCE_LIST and IO_RESOURCE_REQUIREMENTS_LIST</h3><p>The two resource representations (Windows analogues of Linux struct resource / the _CRS→resource pipeline):</p><ul><li><strong>IO_RESOURCE_REQUIREMENTS_LIST</strong>- the <em>possible/required</em> resources, derived from _CRS (and _PRS for reconfigurable devices). Returned from IRP_MN_QUERY_RESOURCE_REQUIREMENTS. Each IO_RESOURCE_DESCRIPTOR describes an interrupt, memory range, port range, DMA channel, GPIO/serial connection, with min/max/alignment for the arbiter to choose from.</li><li><strong>CM_RESOURCE_LIST</strong>- the <em>assigned</em> resources, produced by the arbiters and delivered in IRP_MN_START_DEVICE. Each CM_PARTIAL_RESOURCE_DESCRIPTOR is a concrete interrupt vector, physical address window, etc.</li></ul><pre>typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {<br>    UCHAR  Type;          // CmResourceTypeInterrupt / Memory / Port / …<br>    UCHAR  ShareDisposition;<br>    USHORT Flags;<br>    union {<br>        struct { PHYSICAL_ADDRESS Start; ULONG Length; } Memory;<br>        struct { ULONG Level, Vector; KAFFINITY Affinity; } Interrupt;<br>        struct { PHYSICAL_ADDRESS Start; ULONG Length; } Port;<br>        struct { UCHAR Class, Type; USHORT reserved; ULONG IdLowPart, IdHighPart; } Connection; // SPB/GPIO<br>        ...<br>    } u;<br>} CM_PARTIAL_RESOURCE_DESCRIPTOR;</pre><p>Full resource handling is Section 7.</p><h3>2.7 The driver objects - DRIVER_OBJECT and WDF equivalents</h3><ul><li><strong>DRIVER_OBJECT</strong> : one per loaded driver binary (acpi.sys, a function driver). Holds the dispatch table (MajorFunction[IRP_MJ_PNP], …POWER, …) and AddDevice. This is the loose analogue of Linux&#39;s struct device_driver wrapped by acpi_driver/platform_driver.</li><li><strong>WDF (KMDF) drivers</strong> don’t fill MajorFunction directly; they register event callbacks (EvtDeviceAdd, EvtDevicePrepareHardware, EvtDeviceReleaseHardware) and the framework translates PnP/power IRPs. Most modern ACPI-enumerated function drivers are KMDF.</li><li>There is no exact Windows twin of Linux’s acpi_scan_handler (a subsystem hook that runs <em>during</em> enumeration). Its closest equivalents are: (a) <strong>acpi.sys</strong> itself for bus/namespace concerns, and (b) <strong>bus/class extensions</strong> (pci.sys, SpbCx, GpioClx, ACPI power) that a function driver imports to get subsystem behaviour. See section 3.4.</li></ul><h3>3. Phase 1: acpi.sys as Bus Driver — DriverEntry / AddDevice</h3><p>This phase corresponds to Linux’s acpi_scan_init() + scan-handler registration, but the Windows model is different: instead of registering subsystem callbacks into a global list, acpi.sys is <em>installed as the bus driver over the ACPI root</em> and the specialised behaviour comes from class extensions and the PnP INF matching that happens later.</p><h3>3.1 How acpi.sys gets to be the ACPI bus driver</h3><p>At boot, the PnP manager builds the device tree from the root down. The root enumerator (\Device\00000000, the HTREE\ROOT / ROOT\ACPI_HAL-style top) produces a PDO for the ACPI subsystem. Because acpi.sys is registered (in the registry CriticalDeviceDatabase / boot config) as the driver for the ACPI HAL/root devnode, the PnP manager loads acpi.sys and calls its AddDevice to create the FDO over that root PDO. From that moment acpi.sys <em>is</em> the bus driver for everything under \_SB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*-WW7uN-A7ohkwuxECAo_Wg.png" /></figure><h3>3.2 acpi.sys!DriverEntry</h3><p>DriverEntry sets up the driver globally (this overlaps with the <em>initialization</em> document, but here we focus on the enumeration-relevant parts):</p><ol><li>Fills the DRIVER_OBJECT dispatch table:</li></ol><ul><li>MajorFunction[IRP_MJ_PNP] → ACPIDispatchPnp (handles START_DEVICE, QUERY_DEVICE_RELATIONS, QUERY_ID, QUERY_RESOURCE_REQUIREMENTS, QUERY_CAPABILITIES, REMOVE_DEVICE, …).</li><li>MajorFunction[IRP_MJ_POWER] → ACPIDispatchPower.</li><li>MajorFunction[IRP_MJ_SYSTEM_CONTROL] → WMI dispatch.</li><li>MajorFunction[IRP_MJ_DEVICE_CONTROL] → IOCTL surface (the documented ACPI IOCTL interface: IOCTL_ACPI_EVAL_METHOD, IOCTL_ACPI_ASYNC_EVAL_METHOD, IOCTL_ACPI_GET_DEVICE_INFORMATION, etc., which is how function drivers evaluate control methods — the analogue of Linux&#39;s acpi_evaluate_object).</li><li>DriverExtension-&gt;AddDevice → ACPIAddDevice.</li></ul><p>2. Initialises the AMLI interpreter globals and the namespace (covered in the init doc).</p><p>3. Prepares the internal caches (device-extension lookaside lists, the NSOBJ→PDO map).</p><h3>3.3 acpi.sys!AddDevice</h3><p>AddDevice is invoked by the PnP manager when the ACPI root PDO appears. It:</p><ol><li>Calls IoCreateDevice to make the <strong>bus FDO</strong> and attaches it over the PDO with IoAttachDeviceToDeviceStack.</li><li>Correlates the FDO with the namespace root (\), so subsequent BusRelations queries walk \_SB.</li><li>Registers device interfaces and marks the FDO ready.</li><li>Does not yet enumerate children — that waits for the PnP manager to send IRP_MN_QUERY_DEVICE_RELATIONS (Phase 2). This lazy, IRP-triggered enumeration is the key contrast with Linux&#39;s eager acpi_bus_scan().</li></ol><h3>3.4 The “scan handler” analogues - class extensions &amp; inbox drivers</h3><p>Linux registers scan handlers (PCI root, processor, EC, memory, platform) <em>before</em> the walk. Windows has no single equivalent; the responsibilities are distributed:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0236984cc95365d5241f505c8256d994/href">https://medium.com/media/0236984cc95365d5241f505c8256d994/href</a></iframe><p>The two genuinely “extension-like” mechanisms are:</p><ul><li><strong>Class extensions</strong> (SpbCx for I2C/SPI, GpioClx for GPIO, NetAdapterCx, etc.): a function driver imports the extension and the extension supplies the bus semantics - the closest Windows analogue to a subsystem &quot;expert&quot; running at enumeration/binding time.</li><li><strong>acpi.sys built-ins:</strong> EC, buttons, thermal, and processor power are partly handled <em>inside</em> acpi.sys itself, so they need no external driver -the analogue of Linux scan handlers that ACPI owns directly.</li></ul><h3>4. Phase 2: Namespace Walk (IRP_MN_QUERY_DEVICE_RELATIONS)</h3><p>This is the Windows analogue of acpi_bus_scan → acpi_walk_namespace. The difference: it is triggered by an IRP from the PnP manager, not run eagerly, and it is <strong>restartable </strong>(the PnP manager can re-query at any time for hot-plug).</p><h3>4.1 The BusRelations query</h3><p>When the PnP manager wants to know what is on the ACPI bus, it sends the FDO an IRP_MN_QUERY_DEVICE_RELATIONS with Parameters.QueryDeviceRelations.Type == BusRelations. acpi.sys&#39;s ACPIDispatchPnp routes it to an internal ACPIBusIrpQueryDeviceRelations handler, which:</p><ol><li>Walks the namespace under \_SB (and the fixed-feature pseudo-devices - power/sleep button, and processors under \_SB or \_PR).</li><li>For each qualifying node, ensures a <strong>PDO </strong>exists (creating it on first sight - Phase 3).</li><li>Builds a DEVICE_RELATIONS array of those PDOs and completes the IRP.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UNixw-FXE2DCDJA9Pm62Dw.png" /></figure><h3>4.2 The namespace walk itself (DFS) and why order matters</h3><p>Internally acpi.sys performs a depth-first traversal of the namespace (the AMLI namespace manager walks NSOBJ children recursively - the analogue of ACPICA&#39;s acpi_walk_namespace). Key points:</p><ul><li><strong>Object-type filtering</strong>. Only Device, Processor, ThermalZone, and PowerResource nodes become PDOs; Method, Name, OperationRegion, Mutex, Event, and Scope-only nodes are skipped. Same filter as Linux&#39;s acpi_bus_check_add.</li><li><strong>Parent-before-child</strong>. A child PDO’s parent devnode must exist first, so the PnP device-tree hierarchy and instance paths are well-formed. This mirrors the Linux DFS rationale (Section 4.2 Linux).</li><li><strong>Bus boundaries.</strong> When a node is a self-enumerating bus (a PCI root PNP0A08), acpi.sys still creates <em>its</em> PDO, but the <strong>children of the PCI bus are enumerated by </strong><strong>pci.sys</strong>, not by acpi.sys. So the ACPI BusRelations walk stops descending into the PCI hierarchy — the analogue of a Linux scan handler returning &gt; 0. acpi.sys remains as a <em>filter</em> on the PCI devices&#39; stacks to service their ACPI methods.</li><li><strong>Depth of walk</strong>. acpi.sys returns as BusRelations <strong>only the immediate ACPI children </strong>appropriate to each bus level; the PnP manager then sends BusRelations to each new devnode&#39;s stack, so deeper ACPI scopes are enumerated <em>lazily</em> as the tree is built downward. (Contrast Linux, which walks the whole subtree in one acpi_walk_namespace call. Same end result, different cadence.)</li></ul><h3>4.3 The per-node decision (Windows acpi_bus_check_add analogue)</h3><p>For each visited node acpi.sys performs the equivalent of Linux&#39;s acpi_bus_check_add:</p><ol><li>AMLIGetObjectType/acpi_get_type → is it a device-class object? If not, skip.</li><li>Is it <strong>hidden/filtered</strong>? Windows also has a notion of devices that should not be surfaced (e.g. certain _HIDs handled by the HAL, or blocklisted via the registry). These are skipped or flagged.</li><li>Does a PDO already exist for this NSOBJ? If so, reuse it (idempotency for re-scans).</li><li>Otherwise, create the PDO and initialise its device extension - Phase 3.</li></ol><h3>4.4 Re-enumeration and hot-plug (Notify)</h3><p>Because enumeration is IRP-driven, Windows handles dynamic change naturally:</p><ul><li>An AML Notify(dev, 0x00) (&quot;Bus Check&quot;) or Notify(dev, 0x01) (&quot;Device Check&quot;) from the SCI/GPE path causes acpi.sys to call IoInvalidateDeviceRelations(pdo, BusRelations).</li><li>The PnP manager responds by re-sending IRP_MN_QUERY_DEVICE_RELATIONS.</li><li>acpi.sys re-walks, re-evaluates _STA, and returns an updated relations list; the PnP manager diffs it ( section 2.3) to start arrivals and remove departures. This is the direct analogue of Linux re-running acpi_bus_scan on a hot-plug notification.</li></ul><h3>5. Phase 3: PDO Creation and Identity Evaluation</h3><p>This is the Windows analogue of acpi_add_single_object. For each qualifying namespace node, acpi.sys creates a PDO and evaluates the identity/status control methods to fill the device extension and answer the PnP QueryId requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QGiPb3dNZkCJJ6ivOJWtXw.png" /></figure><h3>5.1 _STA evaluation - the 5-bit bitmask in detail</h3><p>acpi.sys evaluates _STA first (via AMLI), because it decides whether the device is surfaced. If _STA is absent, the device is assumed present, enabled, functional, and shown (value 0x0F), exactly as on Linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*h6msgwHnFHDLafx3x4xJKQ.png" /></figure><ul><li><strong>Bit 0 : Present. </strong>Master switch; clear = hardware absent.</li><li><strong>Bit 1 : Enabled</strong>. Present <em>and</em> actively decoding/using its resources. A device can be present but not enabled (disabled in firmware); Windows may still create the devnode but leave it unstarted.</li><li><strong>Bit 2 : Show in UI</strong>. Controls whether the device is shown to the user (Device Manager visibility). Windows maps clear-bit-2 to the DN_NO_SHOW_IN_DM device-node flag (hidden device). Does not affect function.</li><li><strong>Bit 3 : Functioning.</strong> The device works. As in the spec, not present + functioning (bit 0 clear, bit 3 set) is legal and meaningful — Windows must still enumerate the node’s children even though the device itself isn’t “present” (dock bays, hot-plug slots).</li><li><strong>Bit 4 : Battery present.</strong> Only for control-method batteries (PNP0C0A); reflects battery insertion - consumed by CmBatt.sys.</li></ul><p>The decode lands in the device extension’s Status; the PnP manager reflects absence via a<strong> devnode problem code</strong> (e.g. CM_PROB_PHANTOM).</p><h3>5.2 What happens when _STA = 0 (not present)</h3><p>If _STA returns 0 (neither present nor functioning):</p><ul><li>Normally <strong>no PDO is surfaced</strong> in DEVICE_RELATIONS, and acpi.sys does not descend into the node&#39;s children - matching Linux&#39;s pruning.</li><li><strong>Exception - not present but functioning (bit 3 set): </strong>per the ACPI spec, children must still be examined, so acpi.sys walks them even though this node isn&#39;t surfaced as a startable device.</li><li><strong>Dynamic status:</strong> if the device has a _STA method (status can change), acpi.sys keeps track so that a later Notify(dev, 1) &quot;Device Check&quot; + re-evaluation can surface the PDO (hot-plug/dock). Windows models the &quot;was there, now gone&quot; case as a devnode with a phantom problem code rather than immediately destroying it, which is how surprise-removal is handled cleanly.</li><li>A genuinely absent + non-functioning subtree is pruned - empty PCIe slots, unpopulated DIMMs, and absent dock devices don’t clutter the device tree.</li></ul><h3>5.3 _HID evaluation - primary hardware ID (BusQueryDeviceID)</h3><p>_HID is the device&#39;s primary identifier, used to build the BusQueryDeviceID string and the first (most specific) HardwareID:</p><ul><li><strong>PNP ID:</strong> AAA#### (3 vendor letters + 4 hex), e.g. PNP0C09, PNP0A08.</li><li><strong>ACPI ID: </strong>NNNN#### (4-char vendor + 4 hex), e.g. ACPI0007, INT33FC.</li></ul><p>acpi.sys reads it via AMLI and formats it with the enumerator prefix: ACPI\PNP0C09. This is the string the PnP manager matches against INFs. If _HID is absent, identity falls to _CID and/or _ADR.</p><h3>5.4 _CID evaluation - compatible IDs (BusQueryHardwareIDs/CompatibleIDs)</h3><p>_CID supplies <strong>fallback IDs</strong> in priority order, the ACPI analogue of DT&#39;s compatible list (and of Windows <em>compatible IDs</em>):</p><ul><li>May return a single ID or a Package{} of IDs.</li><li>acpi.sys appends them, after the _HID, into the HardwareIDs MULTI_SZ and also exposes them as CompatibleIDs.</li><li>PnP matching tries the most specific ID first (_HID), then each _CID — so a device with _HID &quot;VEN0ABCD&quot; and _CID &quot;PNP0501&quot; binds a generic 16550 serial driver if no vendor driver is installed. Identical semantics to Linux (§5.4 Linux), realised through the Windows ranked-HardwareID/CompatID matching.</li></ul><h3>5.5 _UID evaluation - instance differentiation (BusQueryInstanceID)</h3><p>_UID disambiguates multiple instances of the same _HID in one scope (two identical PNP0501 UARTs). May be an integer or string. acpi.sys uses it to build a stable InstanceID so the devnode path (ACPI\PNP0501\&lt;uid&gt;) is persistent across boots — important because the registry Enum key and all device settings hang off that path. _UID is <em>not</em> used for driver matching, only for instancing (same role as Linux section 5.5).</p><h3>5.6 _ADR evaluation - bus-enumerated address</h3><p>_ADR gives the device&#39;s address on its parent bus, for devices enumerated by address rather than _HID:</p><ul><li><strong>PCI</strong>: (device &lt;&lt; 16) | function.</li><li><strong>I2C/SPI/UART child under a controller:</strong> slave address / chip-select.</li></ul><p>A device may have _ADR <strong>instead of </strong>_HID (pure bus-address device) or <strong>in addition.</strong> acpi.sys stores it as Address and, when there&#39;s no _UID, may derive the InstanceID from it. _ADR is the key acpi.sys uses <strong>to match an ACPI node to the physical device</strong> enumerated by the real bus driver - the mechanism behind acpi.sys inserting itself as a filter on that device&#39;s stack (the Windows companion/physical_node analogue).</p><h3>5.7 _DSD evaluation - key-value properties → DEVPROPKEYs</h3><p>_DSD (Device-Specific Data) provides arbitrary <strong>key/value device properties</strong>, the ACPI analogue of DT properties. It returns a UUID-tagged Package{}:</p><ul><li><strong>Device Properties UUID</strong> daffd814-6eba-4d8c-8a91-bc9bbf4aa301 - a package of { &quot;key&quot;, value } pairs.</li><li><strong>Hierarchical Properties UUID</strong> dbb8e3e6-5886-4ba6-8795-1319f52a966b- nested data-node sub-packages.</li></ul><p>acpi.sys parses _DSD and exposes each property both:</p><ul><li>through the documented <strong>device property store</strong>, queryable via IoGetDevicePropertyData / DEVPKEY_* and, from ACPI specifically, the DEVPKEY_Device_.../ACPI-namespaced property keys; and</li><li>to KMDF drivers via WdfDeviceQueryPropertyEx / WdfFdoInitQueryProperty.</li></ul><p>This is what lets a driver read &quot;clock-frequency&quot;, GPIO/interrupt name mappings, etc., from ACPI the same way it would from a Device Tree on other OSes. See section 10 for the unified property surface.</p><h3>5.8 Power and wake method evaluation</h3><p>While building the PDO, acpi.sys captures the device’s ACPI <strong>power model</strong>, which it later uses to service power IRPs and populate IRP_MN_QUERY_CAPABILITIES:</p><ul><li><strong>_PSx (</strong><strong>_PS0.._PS3`)</strong> : methods to place the device in D0–D3.</li><li><strong>_PRx (</strong><strong>_PR0.._PR3</strong><strong>) :</strong> the PowerResource’s that must be ON per D-state.</li><li><strong>_PSC</strong> : current power state query.</li><li><strong>_PRW </strong>: power resources + GPE for wake; parsed into wake capabilities and surfaced through DEVICE_CAPABILITIES.DeviceWake/SystemWake so Windows power management can arm the device as a wake source.</li><li><strong>_EJx/</strong><strong>_RMV/</strong><strong>_LCK</strong> : eject/removable/lock for hot-plug and docking; surfaced through IRP_MN_QUERY_CAPABILITIES (Removable, EjectSupported) and IRP_MN_EJECT.</li><li><strong>_S0W/</strong><strong>_SxW/</strong><strong>_DSW</strong> : device wake-depth hints for modern standby (S0ix).</li></ul><p>acpi.sys’s presence as a filter/bus driver is what makes ACPI power management (D-state transitions via _PSx/_PRx, wake via _PRW+GPE) work for both its own PDOs and the companion devices on other buses.</p><h3>5.9 PDO finalisation</h3><p>Finally the PDO is made real:</p><ol><li>IoCreateDevice created the DEVICE_OBJECT; acpi.sys sets DO_BUS_ENUMERATED_DEVICE and DO_POWER_PAGABLE as appropriate and clears DO_DEVICE_INITIALIZING.</li><li>The device extension is populated with the NSOBJ handle, decoded status, identity strings, power/wake caps, and the _DEP list (§8).</li><li>The PDO is added to the DEVICE_RELATIONS array returned to the PnP manager.</li></ol><p>At this point the device exists as a PDO but has no function <strong>driver bound and no resources assigned </strong>- those are Phases 4 and 5, driven by the PnP manager.</p><h3>6. Phase 4: Driver Attachment (PnP Manager + INF Matching)</h3><p>This is the Windows analogue of acpi_bus_attach (scan handler / acpi_driver binding). But instead of acpi.sys calling a probe callback inline, the PnP manager takes each new PDO through a devnode state machine: it reads the IDs, finds a driver via INF matching, and builds the device stack.</p><h3>6.1 The devnode state machine</h3><p>Each PDO becomes a devnode that the PnP manager advances through states:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hp5I-9N87tOE3jqDmA-ARQ.png" /></figure><h3>6.2 IRP_MN_QUERY_ID - getting the identity strings</h3><p>Before matching, the PnP manager sends the PDO IRP_MN_QUERY_ID for each ID type. acpi.sys returns the strings it computed in Phase 3:</p><ul><li>BusQueryDeviceID → ACPI\PNP0C09</li><li>BusQueryHardwareIDs → ACPI\PNP0C09, *PNP0C09, …</li><li>BusQueryCompatibleIDs → the _CID-derived list</li><li>BusQueryInstanceID → from _UID/_ADR</li><li>BusQueryContainerID → a grouping GUID (physical container)</li></ul><p>These populate the registry Enum key and feed matching.</p><h3>6.3 INF rank matching - the driver-selection algorithm</h3><p>The PnP manager (with the user-mode PnP/driver-install services, PnpMgr + umpnpmgr/drvinst) selects a driver by rank:</p><ol><li>Collect candidate INFs whose Models sections list any of the device&#39;s Hardware IDs or Compatible IDs.</li><li>Compute a <strong>rank </strong>for each match. Lower rank = better. The ranking prefers:</li></ol><ul><li><strong>Hardware ID </strong>matches over <strong>Compatible ID</strong> matches.</li><li>Earlier (more specific) IDs in the list over later ones.</li><li>Signed/trusted, higher driver version/date on ties.</li></ul><p>3. The best-ranked driver wins. Its INF AddService/DDInstall sections name the function driver and any filter drivers.</p><p>This rank algorithm is the Windows analogue of Linux’s acpi_match_device_ids (_HID before _CID, first/most-specific match wins - section 6.2 Linux), but it is INF-database driven and considers driver trust/version, which Linux&#39;s simple ID table match does not.</p><h3>6.4 Scan-handler priority analogue - who binds first</h3><p>Linux gives scan handlers priority over acpi_drivers. Windows achieves the equivalent ordering structurally:</p><ul><li><strong>Buses bind their bus driver.</strong> A PNP0A08 PDO ranks to pci.sys, which then enumerates PCI children itself — so PCI wins &quot;first&quot; over any generic handling, exactly like the Linux PCI scan handler returning &gt; 0.</li><li><strong>acpi.sys built-ins run without a separate driver.</strong> EC, buttons, thermal, and processor-power logic inside acpi.sys act before/instead of an external function driver - the analogue of ACPI-owned scan handlers.</li><li><strong>Generic/platform devices fall through to KMDF function drivers</strong> matched by INF - the analogue of Linux’s platform scan handler being last-resort.</li></ul><h3>6.5 Building the device stack - the FDO</h3><p>Once a driver is chosen, the PnP manager:</p><ol><li>Loads the driver image (if not already loaded) and calls its AddDevice (EvtDriverDeviceAdd for KMDF).</li><li>The driver calls IoCreateDevice/WdfDeviceCreate to make its <strong>FDO </strong>and attaches it over the PDO with IoAttachDeviceToDeviceStack.</li><li><strong>Filter drivers</strong> named in the INF/registry (LowerFilters, UpperFilters) are attached around the FDO. Notably, acpi.sys frequently appears as a lower filter on stacks of devices that have an ACPI companion (matched via _ADR/_HID), so it can service their _PSx/_PRW/ _DSM methods.</li></ol><pre>device stack (top --&gt; bottom):<br>     [ upper filter(s) ]<br>     [ FUNCTION DRIVER  (FDO) ]        &lt;-- the matched driver<br>     [ lower filter(s) — often acpi.sys ]<br>     [ PDO  ]                          &lt;-- owned by acpi.sys (the bus driver)</pre><p>The result is the Windows counterpart of Linux binding an acpi_driver/subsystem device: instead of one .probe, you get a <em>stack</em> of layered drivers, each seeing the PnP/power IRPs in turn.</p><h3>6.6 IRP_MN_START_DEVICE - the “probe” moment</h3><p>After resources are assigned (section 7), the PnP manager sends IRP_MN_START_DEVICE down the stack with the CM_RESOURCE_LIST:</p><ul><li>The function driver’s start handler (EvtDevicePrepareHardware/EvtDeviceD0Entry in KMDF, or the IRP_MN_START_DEVICE completion in WDM) maps its resources, connects its interrupt (IoConnectInterruptEx/WdfInterruptCreate), and brings the hardware to D0.</li><li>This is the true analogue of Linux’s driver .probe/.add — the point where the device becomes operational.</li><li>On success the devnode reaches DeviceNodeStarted; failure sets a problem code visible in Device Manager.</li></ul><h3>6.7 Recursive/child enumeration</h3><p>After a devnode starts, the PnP manager sends it BusRelations (if it&#39;s a bus). So:</p><ul><li>For an ACPI node that is itself a bus in the ACPI sense, acpi.sys (still the bus driver for the sub-scope) answers with the child PDOs - continuing the depth-first build downward, lazily ( section 4.2).</li><li>For a real bus (PCI, USB), the bus’s own driver answers BusRelations and enumerates its hardware, with acpi.sys filtering for ACPI methods.</li></ul><p>This recursive, per-devnode BusRelations cascade is how the entire tree gets built - the Windows analogue of Linux&#39;s recursive acpi_bus_attach over children.</p><h3>7. Phase 5: Resource Assignment (_CRS → CM_RESOURCE_LIST)</h3><p>A driver needs to know its device’s interrupts, memory windows, I/O ports, GPIO/serial connections. On Windows this flows from _CRS through acpi.sys, into an IO_RESOURCE_REQUIREMENTS_LIST, through the <strong>arbiters</strong>, and finally arrives as a CM_RESOURCE_LIST in IRP_MN_START_DEVICE. This is the analogue of Linux&#39;s acpi_dev_get_resources + acpi_register_gsi, but with a formal arbitration step Linux mostly lacks.</p><h3>7.1 _CRS, _PRS, _SRS and the requirements list</h3><ul><li>_CRS (Current Resource Settings) : the AML buffer of resource descriptors the device is currently using.</li><li>_PRS (Possible Resource Settings) : for reconfigurable (usually legacy ISA-style) devices, the alternatives the arbiter may choose among.</li><li>_SRS (Set Resource Settings) : how the OS writes a chosen configuration back; acpi.sys calls it after the arbiter picks an assignment.</li></ul><p>When the PnP manager sends IRP_MN_QUERY_RESOURCE_REQUIREMENTS to the PDO, acpi.sys evaluates _CRS (and _PRS when present) via AMLI and translates the descriptors into an <strong>IO_RESOURCE_REQUIREMENTS_LIST </strong>- one or more alternative IO_RESOURCE_LISTs, each an array of IO_RESOURCE_DESCRIPTORs with min/max/length/alignment and a preferred flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cUGg1vg-WocdojPZ0_Ch3Q.png" /></figure><h3>7.2 The arbiters - Windows’ distinctive step</h3><p>The PnP manager runs a set of <strong>resource arbiters</strong>, each owning one resource class, walking the device tree to hand out non-conflicting resources:</p><ul><li><strong>IRQ arbiter : </strong>assigns interrupt vectors/GSIs (works with the HAL/IOAPIC or GIC). Inspectable in WinDbg with !acpiirqarb and !arbiter.</li><li><strong>Memory arbiter</strong> : assigns MMIO windows within parent bus windows.</li><li><strong>Port (I/O) arbiter</strong> : assigns legacy I/O port ranges.</li><li><strong>DMA arbiter :</strong> assigns DMA channels.</li><li><strong>Bus-number arbiter :</strong> assigns PCI bus-number ranges (for PNP0A08).</li></ul><p>Arbiters descend the tree so a child’s assignment fits inside its parent bridge’s window (e.g. a PCI device’s BAR inside the PCI root’s _CRS window). There is no direct Linux analogue to this formal arbitration for most buses - Linux largely takes _CRS values as-is; Windows can <em>rebalance</em> resources (IRP_MN_QUERY_STOP_DEVICE → reassign → restart) when a new device needs space.</p><h3>7.3 Resource types and their CM/IO mappings</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bd0c8312e1f7ab049b09e08330c095d/href">https://medium.com/media/6bd0c8312e1f7ab049b09e08330c095d/href</a></iframe><h3>7.4 The Connection resource - GPIO/I2C/SPI (SoC devices)</h3><p>For SoC/embedded peripherals, _CRS uses <strong>GpioInt/</strong><strong>GpioIo</strong> and <strong>I2cSerialBus/</strong><strong>SpiSerialBus/</strong><strong>UartSerialBus</strong> descriptors that reference a controller by its ACPI path (ResourceSource). acpi.sys turns each into a CmResourceTypeConnection descriptor carrying a <strong>connection ID </strong>rather than a raw address:</p><ul><li>The consuming driver opens the connection by ID against the controller’s framework (SpbCx for I2C/SPI, GpioClx for GPIO).</li><li>This is the Windows counterpart of Linux resolving I2cSerialBus/GpioInt descriptors through the I2C/GPIO subsystems (section 7.3/section 9 Linux) rather than as a plain struct resource.</li></ul><h3>7.5 Interrupts: GSI → vector, and the arbiter</h3><p>ACPI describes interrupts as GSIs; Windows drivers receive a CmResourceTypeInterrupt descriptor with a translated vector/level/affinity:</p><ul><li><strong>The IRQ arbiter + the HAL</strong> map the _CRS GSI (plus trigger/polarity from the descriptor flags) to a HAL interrupt vector, going through the IOAPIC domain (x86) or GIC (ARM64) - the analogue of Linux&#39;s acpi_register_gsi() → virq.</li><li>For <strong>GpioInt </strong>resources, the interrupt is provided by the GPIO controller; GpioClx bridges it so the consumer&#39;s WdfInterruptCreate connects to a GPIO-backed interrupt — the analogue of Linux&#39;s acpi_dev_gpio_irq_get() + gpiod_to_irq().</li><li>The _PRT (PCI Routing Table) on the PCI root maps PCI INTx pins to GSIs; acpi.sys provides _PRT data so the PCI/IRQ arbiters can route legacy PCI interrupts — the analogue of Linux&#39;s PCI IRQ routing via _PRT.</li></ul><h3>7.6 Delivery to the driver</h3><p>The assigned CM_RESOURCE_LIST arrives in IRP_MN_START_DEVICE (Parameters.StartDevice.AllocatedResources and the <em>translated</em> variant). A KMDF driver reads it in EvtDevicePrepareHardware via WdfCmResourceListGetDescriptor; a WDM driver parses the list directly. From there MmMapIoSpace, IoConnectInterruptEx/WdfInterruptCreate, and SPB/GPIO target opens make the resources usable — the endpoint of the resource pipeline.</p><h3>8. Dependency Resolution (_DEP and Windows Ordering)</h3><h3>8.1 Why _DEP exists (same rationale as Linux)</h3><p>_CRS describes <em>resources</em>, but some devices have <strong>operational dependencies</strong> on <em>other devices</em> not expressible as resources - the classic case being a device whose OperationRegions are backed by an <strong>embedded controller</strong>, a <strong>GPIO </strong>controller, or an <strong>I2C </strong>controller. Such a device cannot run until its provider is up and its operation-region handler installed.</p><p>_DEP returns a Package{} of namespace references to devices that <strong>must be available first.</strong> On Windows this matters especially because acpi.sys must not attempt _STA/_INI/method evaluation that touches, say, an EC operation region before the EC&#39;s region handler exists.</p><pre>Device (TPD0) {<br>    Name (_HID, &quot;ELAN0000&quot;)<br>    Name (_DEP, Package() { \_SB.PCI0.I2C1, \_SB.GPO0, \_SB.PCI0.LPCB.EC0 })<br>}</pre><h3>8.2 How acpi.sys records dependencies</h3><p>During PDO creation (section 5), acpi.sys evaluates _DEP and records, for each listed provider, a dependency edge into the consumer&#39;s device extension (DependentList) and increments an &quot;unmet dependency&quot; count. Providers already known to be satisfied (or that Windows deliberately ignores) are filtered out - the analogue of Linux&#39;s acpi_dep_valid() filtering.</p><h3>8.3 Deferred surfacing / start</h3><p>Windows expresses the deferral through the PnP model rather than a probe-defer return code:</p><ul><li>A consumer with unmet _DEP dependencies is either not surfaced in BusRelations yet, or surfaced but held with its devnode in a <strong>not-started / problem state</strong> until dependencies clear.</li><li>This is functionally the same as Linux skipping acpi_bus_attach for a device with dep_unmet &gt; 0, and it composes with the general PnP dependency features below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gT4outnbCRo8eSm-WULrDA.png" /></figure><h3>8.4 Clearing dependencies</h3><p>When a <strong>supplier </strong>becomes ready - the EC installs its EmbeddedControl operation-region handler, or a GPIO/I2C controller reaches DeviceNodeStarted - acpi.sys walks the dependency edges pointing at that supplier, decrements each consumer&#39;s unmet count, and when a consumer reaches zero triggers IoInvalidateDeviceRelations(..., BusRelations) so the PnP manager re-queries and the previously deferred consumer is now surfaced and started. This is the direct analogue of Linux&#39;s acpi_dev_clear_dependencies() + re-run of acpi_bus_attach.</p><h3>8.5 The broader Windows dependency toolkit</h3><p>Windows layers several <em>general</em> PnP ordering mechanisms on top of _DEP, which together cover cases Linux handles with deferred probe:</p><ul><li><strong>Driver load-order groups &amp; </strong><strong>GroupOrderList</strong> : boot/system-start drivers load in a defined group sequence (acpi.sys is in <em>Boot Bus Extender</em>, early).</li><li><strong>DEVPKEY_Device_Dependencies / device-relations of type </strong><strong>RemovalRelations/</strong><strong>EjectionRelations</strong>:express device grouping for removal and power.</li><li><strong>IRP_MN_QUERY_DEVICE_RELATIONS (</strong><strong>RemovalRelations) :</strong> devices that must be removed together (e.g. everything behind a dock).</li><li>KMDF/UMDF explicit driver dependencies and device-reported PnpBusInformation.</li><li><strong>The general </strong><strong>STATUS_PENDING/rebalance flow :</strong>a driver can decline start and be retried, an outcome-level cousin of Linux -EPROBE_DEFER.</li></ul><p>The net effect matches Linux: an I2C touchpad is never started before the I2C controller, GPIO controller, and EC it depends on are all live.</p><h3>9. Subsystem-Specific Enumeration</h3><p>When a PDO is matched to a bus/class driver, that subsystem frequently enumerates children of its own and/or links the ACPI companion to a physical device. The recurring pattern: acpi.sys owns the PDO + ACPI methods; the bus/class driver provides the subsystem behaviour; acpi.sys may stay as a lower filter for power/_DSM. This is the Windows counterpart of Linux&#39;s per-subsystem .attach/companion logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6h8QZQJYCatJ2srQfKKN0Q.png" /></figure><h3>9.1 PCI: the PNP0A08/PNP0A03 root and full PCI scan</h3><p>acpi.sys creates the PDO for the PCI root (PNP0A08); the PnP manager binds pci.sys as the bus driver. pci.sys then:</p><ol><li>Reads the root’s resource windows (bus-number range, MMIO/IO windows) from the _CRS that acpi.sys supplies via QUERY_RESOURCE_REQUIREMENTS.</li><li>Runs _OSC (via acpi.sys&#39;s method-eval IOCTL) to negotiate control of native PCIe features (hotplug, AER, ASPM, LTR).</li><li>Performs a full recursive PCI enumeration (config-space scan) of every bus/device/function and reports them via its own BusRelations.</li><li>acpi.sys remains a filter on each PCI device stack that has an ACPI companion (matched by _ADR = (dev&lt;&lt;16)|func), servicing _PS0/_PS3, _PRW wake, _DSM, and _PLD. The _PRT on the root routes INTx to GSIs for legacy interrupts.</li></ol><p>This is the analogue of Linux’s acpi_pci_root_add() → pci_scan_root_bus.</p><h3>9.2 I2C: SpbCx controller + I2cSerialBus children</h3><ul><li>The I2C controller is enumerated (usually as an ACPI platform device) and bound by a KMDF driver that imports SpbCx (the Simple Peripheral Bus class extension).</li><li>I2C peripherals are declared as ACPI devices with an I2cSerialBus connection in _CRS referencing the controller. Their PDOs are created by acpi.sys; the peripheral&#39;s function driver opens the controller by the connection ID in its CmResourceTypeConnection resource.</li><li>This is the analogue of Linux’s i2c_acpi_register_devices() creating an i2c_client - but on Windows the &quot;client&quot; is a normal PnP devnode whose resource is a connection ID rather than a bus address.</li></ul><h3>9.3 SPI: SpbCx controller + SpiSerialBus children</h3><p>Identical structure to I2C, using SpiSerialBus _CRS connections. The controller driver imports SpbCx; each SPI peripheral is a PDO whose Connection resource carries chip-select/mode/speed encoded by the descriptor. Analogue of Linux&#39;s acpi_spi_add_device().</p><h3>9.4 GPIO: GpioClx controller, GpioIo/GpioInt, and _AEI</h3><ul><li>The GPIO controller is bound by a KMDF driver importing GpioClx.</li><li><strong>GpioIo </strong>descriptors elsewhere resolve to pins on that controller (opened as GPIO I/O targets); <strong>GpioInt </strong>descriptors become GPIO-backed interrupts consumers connect via WdfInterruptCreate.</li><li>_AEI (ACPI Event Interrupts) on the controller declares GPIO pins that raise ACPI events; acpi.sys + GpioClx install handlers so the corresponding _Exx/_Lxx/_EVT methods run on a GPIO interrupt - the analogue of Linux&#39;s acpi_gpiochip_request_interrupts() / _AEI handling.</li><li>Named-GPIO lookups use _DSD gpio mappings resolved through the property API (section 10), the analogue of Linux&#39;s _DSD gpio-mapping + acpi_get_gpiod_by_index().</li></ul><h3>9.5 CPU: processor PDOs and power drivers</h3><ul><li>acpi.sys creates a PDO for each processor (ACPI0007 device or legacy Processor{}), correlating the ACPI processor UID with the Windows logical processor established by the HAL/ntoskrnl during NUMA/MADT init.</li><li>intelppm.sys / amdppm.sys / processr.sys bind and consume the power methods: _CST (C-states → idle), _PSS/_PCT/_PPC or _CPC (CPPC) (P-states → perfctrl/processor performance), _TSS/_PTC/_TPC (T-states → throttling).</li><li>This is the analogue of Linux’s acpi_processor_add() + cpuidle/cpufreq binding.</li></ul><h3>9.6 Thermal: thermal zones and the thermal manager</h3><ul><li>ThermalZone{} objects are handled largely inside acpi.sys, which reads _TMP, _CRT, _HOT, _PSV, _ACx, _TZP, and the cooling relations _ALx (active) / _PSL (passive).</li><li>acpi.sys surfaces each zone through the thermal management interfaces (GUID_THERMAL_COOLING_INTERFACE, IOCTL_THERMAL_*), and Windows&#39; thermal manager applies policy (active cooling via fans, passive via processor throttling).</li><li>Notify(zone, 0x80/0x81) events re-evaluate the zone.</li><li>This is the analogue of Linux’s acpi_thermal_add() registering a thermal_zone_device.</li></ul><h3>9.7 Battery / buttons / EC (ACPI-owned)</h3><ul><li><strong>Battery (</strong><strong>PNP0C0A)</strong> : CmBatt.sys (with battc.sys class lib) binds the ACPI battery PDO and reads _BIF/_BIX/_BST, exposing a battery to the power subsystem. Analogue of Linux&#39;s battery acpi_driver.</li><li><strong>Buttons (</strong><strong>PNP0C0C/</strong><strong>0D/</strong><strong>0E) </strong>: power/lid/sleep buttons handled inside acpi.sys, surfaced as power events / GUID_DEVICE_LID etc. Analogue of Linux&#39;s button driver.</li><li><strong>EC (</strong><strong>PNP0C09): </strong>handled inside acpi.sys (from ECDT early if needed): installs the EmbeddedControl operation-region handler and services EC transactions and _Qxx query events. Analogue of Linux&#39;s EC scan handler.</li></ul><h3>10. The Unified Property Interface (DEVPROPKEY / _DSD)</h3><h3>10.1 The portability problem and Windows’ answer</h3><p>Just as Linux introduced fwnode so one driver reads properties from either Device Tree or ACPI _DSD, Windows exposes ACPI _DSD properties through its unified device property model (DEVPROPKEY), so a driver reads device properties the same way regardless of how the device was described.</p><ul><li>Windows has always had a device property store (SetupDiGetDeviceProperty in user mode, IoGetDevicePropertyData in the kernel) keyed by DEVPROPKEY (a GUID + property ID).</li><li>acpi.sys parses _DSD (Device Properties UUID, §5.7) and publishes each key/value pair into that store, so ACPI-described properties become first-class device properties.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fXeClC7Tw6zgpp7o_GcAkg.png" /></figure><p>The result mirrors Linux: a SoC peripheral driver reads &quot;clock-frequency&quot; and it works whether the value came from ACPI _DSD, an INF, or (on other systems) Device Tree - the driver never branches on firmware type.</p><h3>10.2 Reading _DSD properties in a driver</h3><ul><li><strong>Kernel (WDM):</strong> IoGetDevicePropertyData(Pdo, &amp;DEVPKEY_..., ...) retrieves a property published from _DSD. acpi.sys maps each _DSD key name to a DEVPROPKEY.</li><li><strong>KMDF: </strong>WdfDeviceQueryPropertyEx / WdfFdoInitQueryPropertyEx with a WDF_DEVICE_PROPERTY_DATA describing the DEVPROPKEY.</li><li><strong>ACPI method eval (dynamic):</strong> for values not exposed as static properties, a driver sends acpi.sys the IOCTL_ACPI_EVAL_METHOD IOCTL to evaluate a control method (_DSM, _DSD, vendor methods) directly - the analogue of Linux calling acpi_evaluate_object()/acpi_evaluate_dsm().</li><li><strong>_DSM (Device-Specific Method)</strong> : the vendor-extensible method invoked by UUID + function index; drivers call it through the eval IOCTL. This is the same _DSM Linux drivers reach via acpi_evaluate_dsm().</li></ul><h3>10.3 Hierarchical _DSD and references</h3><ul><li><strong>Data sub-nodes</strong> (Hierarchical Properties UUID) are exposed as child data the driver can navigate - the analogue of Linux’s fwnode_get_named_child_node() over hierarchical _DSD.</li><li><strong>References </strong>between _DSD entries (the ACPI equivalent of DT phandles, e.g. a device pointing at its GPIO/clock provider) are resolved by acpi.sys and the SPB/GPIO frameworks, analogous to Linux&#39;s fwnode_property_get_reference_args().</li></ul><h3>10.4 Per-model match data - the device_get_match_data analogue</h3><p>Linux drivers attach per-model quirk data to match-table entries and fetch it with device_get_match_data(). Windows achieves the same by different means:</p><ul><li>The matched <strong>Hardware/Compatible ID</strong> itself selects the INF and thus the driver’s configuration; the specific ID that matched is available to the driver (IRP_MN_QUERY_ID results / DEVPKEY_Device_MatchingDeviceId).</li><li>Per-model settings are typically delivered via the INF (AddReg / AddProperty in the model&#39;s DDInstall section) and read back from the registry/property store - the Windows idiom for &quot;quirk data keyed by which ID matched.&quot;</li><li>DEVPKEY_Device_MatchingDeviceId (and DEVPKEY_Device_DriverInfSection) tell the driver exactly which ID/INF section bound it, so it can select model-specific behaviour - the functional equivalent of casting device_get_match_data()&#39;s returned pointer.</li></ul><p>Together, _DSD + DEVPROPKEY + INF-delivered settings are what let the large body of firmware-agnostic Windows drivers (and ported DT-style drivers) run on ACPI platforms — the Windows counterpart of the fwnode portability story, and central to ARM64 Windows (where nearly everything is ACPI + _DSD).</p><h3>11. Final Representation (Registry, Device Manager, WMI)</h3><p>Where Linux surfaces enumeration under /sys, Windows surfaces it in the <strong>registry </strong><strong>Enum tree, Device Manager,</strong> and various <strong>device-interface / WMI namespaces</strong>.</p><h3>11.1 HKLM\SYSTEM\CurrentControlSet\Enum\ACPI\- the devnode store</h3><p>Every ACPI-enumerated device gets a persistent key, the analogue of /sys/bus/acpi/devices/:</p><pre>HKLM\SYSTEM\CurrentControlSet\Enum\ACPI\<br>├── PNP0C09\                       # embedded controller (by _HID)<br>│   └── &lt;InstanceID&gt;\              # from _UID/_ADR, e.g. 2&amp;daba3ff&amp;1<br>│       ├── HardwareID       (MULTI_SZ)  ACPI\PNP0C09, *PNP0C09<br>│       ├── CompatibleIDs    (MULTI_SZ)<br>│       ├── ClassGUID        {system}<br>│       ├── Driver           {class}\NNNN   --&gt; link to driver key<br>│       ├── Service          &quot;ACPIEC&quot;       --&gt; the binding driver service<br>│       ├── DeviceDesc / FriendlyName<br>│       ├── ContainerID<br>│       ├── Capabilities / ConfigFlags<br>│       ├── LocationInformation  (ACPI path \_SB.PCI0.LPCB.EC0)<br>│       └── Device Parameters\    # driver-private + _DSD-derived properties<br>├── PNP0A08\ …                     # PCI root<br>├── ACPI0007\ …                    # processors<br>└── PNP0C0C\ …                     # power button</pre><ul><li>HardwareID/CompatibleIDs come from _HID/_CID (section 5.3–5.4); they drive INF matching and are the equivalent of Linux&#39;s modalias.</li><li>Service names the bound driver (the analogue of the Linux driver symlink).</li><li>LocationInformation carries the ACPI namespace path — the analogue of the Linux path attribute.</li><li>Device Parameters holds driver-private settings <em>and</em> _DSD-published properties (§10).</li></ul><h3>11.2 The Enum keys for companion devices</h3><p>A device that lives on another bus but has an ACPI companion appears under that bus’s enumerator (e.g. Enum\PCI\VEN_....), with the ACPI relationship recorded via DEVPKEY_Device_... properties and the presence of acpi.sys as a filter in its stack - the registry-level view of the companion/physical_node link.</p><h3>11.3 Device Manager and the PnP device tree</h3><ul><li><strong>Device Manager</strong> (devmgmt.msc) renders the live PnP devnode tree; ACPI devices show under their parent bus, and “View → Devices by connection” shows the ACPI enumeration hierarchy directly (the ACPI x86/x64/ARM-based PC root → Microsoft ACPI-Compliant System → children). This is the closest GUI analogue of walking /sys/devices.</li><li><strong>pnputil /enum-devices</strong> dumps devnodes, IDs, and status from the command line.</li><li><strong>The </strong><strong>_STA “show in UI”</strong> bit (section 5.1) controls whether a device is hidden; &quot;Show hidden devices&quot; reveals phantom/not-present devnodes.</li></ul><h3>11.4 Raw ACPI tables (the /sys/firmware/acpi/tables analogue)</h3><ul><li><strong>Registry:</strong> HKLM\HARDWARE\ACPI\ holds the raw tables (DSDT, FACP, APIC, SSDT, SRAT, SLIT, HPET, GTDT, …) as published by the loader.</li><li><strong>Tools:</strong> acpidump.exe (WDK) dumps them; iasl.exe -d dsdt.aml decompiles AML to ASL (the same Intel compiler Linux uses).</li><li><strong>WinDbg:</strong> !acpicache, !acpikd, and the AMLI extension !amli inspect the live namespace and tables (the analogue of reading /sys/firmware/acpi/namespace).</li></ul><h3>11.5 Device interfaces, WMI, and thermal</h3><ul><li><strong>Device interfaces</strong> : drivers register GUID_* interfaces (IoRegisterDeviceInterface) that user mode opens by symbolic link; the analogue of Linux class devices (/sys/class/...). Thermal zones surface via GUID_DEVICE_THERMAL_ZONE; batteries via GUID_DEVICE_BATTERY.</li><li><strong>ACPI WMI (</strong><strong>WMIACPI / </strong><strong>_WDG)</strong> : ACPI _WDG/_WED methods expose vendor WMI blocks (OEM hotkeys, firmware features) through the Windows WMI stack (wmiacpi.sys), queryable via Get-CimInstance in the root\wmi namespace. This is a Windows-specific surface with no direct Linux /sys analogue (Linux exposes similar data via wmi sysfs + platform drivers).</li><li>powercfg /devicequery and powercfg /requests surface the ACPI wake (_PRW) and power capabilities gathered in §5.8.</li></ul><h3>11.6 Interrupt/arbiter inspection</h3><p>!acpiirqarb, !arbiter, and !devnode 0 1 in WinDbg show the assigned interrupt/memory/port resources per devnode - the debugging analogue of reading a Linux device&#39;s resource file and /proc/interrupts.</p><h3>12. Key Takeaways + Complete Call Graph</h3><h3>12.1 Key takeaways</h3><ol><li><strong>Enumeration is IRP-driven and layered.</strong> acpi.sys is the ACPI bus driver; it answers IRP_MN_QUERY_DEVICE_RELATIONS (BusRelations) by manufacturing a PDO per namespace device. The PnP manager then matches, stacks, and starts drivers. (Contrast Linux&#39;s inline acpi_bus_scan + .probe.)</li><li><strong>PDO vs. FDO vs. companion.</strong> One namespace node → one PDO (owned by acpi.sys) + a function driver FDO on top; devices on other buses get an acpi.sys filter for their ACPI methods (the companion link).</li><li><strong>_STA gates surfacing</strong>. Present-or-functioning decides whether a PDO is returned; not-present+not-functioning subtrees are pruned; dynamic status → phantom devnodes + Notify-driven re-query.</li><li><strong>Identity → HardwareIDs/CompatibleIDs.</strong> _HID (most specific) then _CID list build the ranked ID strings; the INF rank match picks a driver (Windows adds trust/version tie-breaking over Linux&#39;s plain ID match). _UID/_ADR do instancing and companion matching.</li><li><strong>_CRS → arbiters → </strong><strong>CM_RESOURCE_LIST</strong>. Windows adds a formal arbitration/rebalance step; GSIs are translated to interrupt vectors by the IRQ arbiter + HAL; GPIO/I2C/SPI become Connection resources resolved by GpioClx/SpbCx.</li><li><strong>_DEP + PnP ordering.</strong> Dependency edges (plus group order and device relations) defer a consumer until its EC/GPIO/I2C suppliers are live; IoInvalidateDeviceRelations re-surfaces it — the analogue of Linux deferred probe.</li><li><strong>_DSD + </strong><strong>DEVPROPKEY = portability</strong>. ACPI properties are published into the unified device-property store, so firmware-agnostic drivers (and ported DT drivers) run on ACPI — central to ARM64 Windows.</li><li><strong>acpi.sys</strong> owns EC/buttons/thermal/processor-power internally, the analogue of ACPI-owned Linux scan handlers.</li></ol><h3>12.2 Complete call graph</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GM2fZMrtxX4Er4R7o78ONA.png" /></figure><h3>12.3 One-line summary of the journey</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*tmlEyw_vF3CiK2yNR0sPFQ.png" /></figure><h3>12.4 Side-by-side: Linux vs. Windows enumeration</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17a195d174dc162c84b20667ee7b6a0d/href">https://medium.com/media/17a195d174dc162c84b20667ee7b6a0d/href</a></iframe><p><strong>Note : </strong>Windows reference: <em>acpi.sys</em> (the ACPI bus/function driver + AMLI interpreter), the PnP manager and I/O manager inside <em>ntoskrnl.exe</em>, the resource arbiters, and subsystem class extensions (<em>pci.sys</em>, <em>SpbCx</em>, <em>GpioClx</em>, <em>msft</em> inbox drivers). Because Windows ACPI internals are largely undocumented, private/internal routine names (prefixed <em>ACPI</em>) reflect reverse-engineering and WDK/debugger symbol conventions; the architecture and the documented DDIs (IRPs, <em>DEVICE_RELATIONS</em>, <em>CM_RESOURCE_LIST</em>, <em>DEVPROPKEY</em>) are firm.</p><h3>References</h3><p><strong>ACPI specification</strong></p><ol><li>ACPI Specifications (UEFI Forum) — <a href="https://uefi.org/acpi/specs">https://uefi.org/acpi/specs</a></li><li>ACPI Spec 6.4, full text (HTML) — <a href="https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/">https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/</a></li></ol><p><strong>ACPICA (reference AML interpreter, used directly by Linux)</strong><br> 3. ACPICA documentation &amp; user guide (Intel) — <a href="https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html">https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html</a><br> 4. ACPICA source (GitHub) — <a href="https://github.com/acpica/acpica">https://github.com/acpica/acpica</a></p><p><strong>Linux ACPI implementation</strong><br> 5. Linuxized ACPICA — how Linux syncs with upstream ACPICA — <a href="https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html">https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html</a><br> 6. Linux kernel ACPI driver-api docs — <a href="https://docs.kernel.org/driver-api/acpi/index.html">https://docs.kernel.org/driver-api/acpi/index.html</a><br> 7. Linux kernel source, drivers/acpi — <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi</a></p><p><strong>Windows internals</strong><br> 8. Windows Driver Kit — Kernel-Mode Driver Architecture — <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/">https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/</a><br> 9. Russinovich, Solomon, Ionescu — <em>Windows Internals</em>, Part 1 (7th ed.) — standard secondary source for undocumented boot/HAL routines like KiSystemStartup, HalInitSystem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=637e97e03681" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux ACPI Device Enumeration - From Namespace Nodes to Driver Binding]]></title>
            <link>https://medium.com/@kushaldps1996/linux-acpi-device-enumeration-from-namespace-nodes-to-driver-binding-f5fdb252045b?source=rss-20cb97d60801------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5fdb252045b</guid>
            <dc:creator><![CDATA[KUSHAL CHAKRABORTY]]></dc:creator>
            <pubDate>Thu, 06 Aug 2026 02:24:19 GMT</pubDate>
            <atom:updated>2026-08-06T02:24:19.968Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A deep dive into how Linux turns the ACPI namespace (built by ACPICA after the DSDT/SSDTs are loaded) into live </em><em>struct device objects with drivers bound to them. This picks up exactly where table loading and namespace construction leave off, and follows a namespace node all the way to </em><em>/sys/bus/... and a probed driver.</em></p><h3>Table of Contents</h3><ol><li>Introduction - the enumeration problem</li><li>Key Data Structures</li><li>Phase 1: Scan Handler Registration (acpi_scan_init)</li><li>Phase 2: Namespace Walk (acpi_bus_scan)</li><li>Phase 3: Device Object Creation (acpi_add_single_object)</li><li>Phase 4: Driver Attachment (acpi_bus_attach)</li><li>Phase 5: Resource Assignment (_CRS)</li><li>Dependency Resolution (_DEP)</li><li>Subsystem-Specific Enumeration</li><li>The fwnode Interface</li><li>Final sysfs Representation</li><li>Key Takeaways + Complete Call Graph</li></ol><h3>1. Introduction</h3><h3>1.1 The enumeration problem: namespace nodes → Linux devices</h3><p>By the time ACPICA has finished loading the DSDT and merging the SSDTs, the kernel holds a fully-parsed ACPI namespace — a tree of named nodes (Device, Processor, ThermalZone, Method, Name, OperationRegion, …) rooted at \. But that namespace is <em>inert</em>: it is an in-memory representation of AML objects, not something the Linux driver model knows how to bind to.</p><p>The enumeration problem is the gap between two worlds:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*HmjClzLTpadZ9YK3814ZuQ.png" /></figure><p><strong>Enumeration </strong>is the machinery that <strong>bridges the gap</strong>. For every interesting namespace node it must:</p><ol><li>Decide whether the device is actually present and usable (evaluate _STA).</li><li>Create a Linux-visible object - struct acpi_device-wrapping the namespace node.</li><li>Compute the device’s identity (_HID, _CID, _UID, _ADR) so a driver can be matched.</li><li>Hand the device to the right subsystem (PCI, I2C, SPI, platform, CPU, thermal …) so a <em>second</em>, bus-specific device object is spawned where needed.</li><li>Resolve resources (_CRS) and dependencies (_DEP) so the device can function.</li><li>Bind a driver and call its .probe/.add callback.</li></ol><p>The end result: a namespace node becomes one (or more) struct devices visible under /sys, with a driver bound and hardware resources assigned.</p><h3>1.2 Overview of the enumeration pipeline</h3><p>Enumeration proceeds in well-defined phases. The whole thing is kicked off once, late in boot, by acpi_scan_init() (called from acpi_init()), and then re-run incrementally for hot-plug events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f343y2vhJm9B7Im7gMJ1ow.jpeg" /></figure><p>The phases, at a glance:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9d3508be863bf05c15c27cc225be6c4/href">https://medium.com/media/c9d3508be863bf05c15c27cc225be6c4/href</a></iframe><h3>2. Key Data Structures</h3><p>Enumeration revolves around a handful of structures in include/acpi/acpi_bus.h and include/linux/acpi.h. Understanding these makes the rest of the pipeline obvious.</p><h3>2.1 struct acpi_device - the core object</h3><p>This is the Linux-side wrapper around one ACPI namespace node. One namespace Device (or Processor, ThermalZone, PowerResource) node ⇒ one acpi_device. It embeds a struct device, so it lives on <strong>the ACPI bus</strong> (/sys/bus/acpi/devices/).</p><pre>struct acpi_device {<br>    u32                     pld_crc;<br>    int                     device_type;      /* ACPI_BUS_TYPE_* (see §2.5) */<br>    acpi_handle             handle;           /* NULL for the fixed root */<br>    struct fwnode_handle    fwnode;           /* the fwnode view (see §10)  */<br>    struct list_head        wakeup_list;<br>    struct list_head        del_list;<br>    struct acpi_device_status status;         /* decoded _STA (see §2.4)    */<br>    struct acpi_device_flags  flags;<br>    struct acpi_device_pnp    pnp;            /* _HID/_CID/_UID/_ADR here   */<br>    struct acpi_device_power  power;          /* _PSx/_PRx power states     */<br>    struct acpi_device_wakeup wakeup;         /* _PRW wake capabilities     */<br>    struct acpi_device_perf   performance;<br>    struct acpi_device_dir    dir;<br>    struct acpi_device_data   data;           /* _DSD properties (see §5)   */<br>    struct acpi_scan_handler *handler;        /* bound scan handler, or NULL*/<br>    struct acpi_hotplug_context *hp;<br>    const struct acpi_gpio_mapping *driver_gpios;<br>    void                    *driver_data;<br>    struct device           dev;              /* the embedded Linux device  */<br>    unsigned int            physical_node_count;<br>    unsigned int            dep_unmet;        /* # of unmet _DEP deps       */<br>    struct list_head        physical_node_list;  /* companion devices       */<br>    struct mutex            physical_node_lock;<br>    void (*remove)(struct acpi_device *);<br>};</pre><p>Key sub-structures:</p><ul><li>struct acpi_device_pnp — holds the identity strings:</li></ul><pre>struct acpi_device_pnp {<br>    acpi_bus_id     bus_id;          /* short name e.g. &quot;TPM0&quot;       */<br>    int             instance_no;<br>    struct acpi_pnp_type type;<br>    acpi_bus_address bus_address;    /* from _ADR                    */<br>    char           *unique_id;       /* from _UID                    */<br>    struct list_head ids;            /* list of _HID + _CID strings  */<br>    char           *device_name;<br>    char           *device_class;<br>};</pre><ul><li>struct acpi_device_flags :bitfield of capabilities discovered during scan: dynamic_status, removable, ejectable, power_manageable, match_driver, initialized, visited, hotplug_notify, is_dock_station, of_compatible_present, coherent_dma, etc.</li><li>driver_data : the acpi_driver&#39;s private pointer (like dev_set_drvdata).</li><li>physical_node_list : links this ACPI device to its <em>companion</em> physical device(s) on another bus (e.g. the PCI struct device that this PNP0A08 bridge corresponds to). This is the ACPI ←-&gt; physical glue.</li></ul><h3>2.2 struct acpi_scan_handler - the subsystem expert</h3><p>A scan handler is registered by a <em>subsystem</em> (PCI, processor, EC, memory hotplug…) that claims responsibility for a class of ACPI devices identified by HID/CID. It runs at <strong>enumeration time</strong>, <em>before</em> (and with priority over) an ordinary acpi_driver.</p><pre>struct acpi_scan_handler {<br>    const struct acpi_device_id *ids;    /* HIDs/CIDs this handler claims  */<br>    struct list_head        list_node;<br>    bool (*match)(const char *idstr,<br>                  const struct acpi_device_id **matchid);<br>    int  (*attach)(struct acpi_device *dev,<br>                   const struct acpi_device_id *id);  /* the real work    */<br>    void (*detach)(struct acpi_device *dev);<br>    void (*bind)(struct device *phys_dev);<br>    void (*unbind)(struct device *phys_dev);<br>    bool hotplug_supported;<br>    struct acpi_hotplug_profile hotplug;<br>};</pre><ul><li>.attach() is where the subsystem does its heavy lifting — e.g. the PCI root handler calls acpi_pci_root_add() which scans the entire PCI bus below the bridge.</li><li>Returning &gt; 0 from .attach() means &quot;handled, and this device is a bus that enumerates its own children&quot; (so ACPI stops recursing into the namespace for child <em>physical</em> devices); 0 means &quot;handled, keep going&quot;; &lt; 0 is an error.</li></ul><h3>2.3 struct acpi_driver - the device driver</h3><p>The ordinary driver interface for devices that ACPI itself drives (battery, button, fan, thermal, video, processor idle, etc.). Bound <em>only if</em> no scan handler claimed the device and the driver’s ID table matches.</p><pre>struct acpi_driver {<br>    char                name[80];<br>    char                class[80];<br>    const struct acpi_device_id *ids;    /* match table                    */<br>    unsigned int        flags;<br>    struct acpi_device_ops ops;          /* .add/.remove/.notify           */<br>    struct device_driver drv;            /* embedded driver-model driver   */<br>    struct module      *owner;<br>};<br>struct acpi_device_ops {<br>    acpi_op_add     add;      /* probe: called on bind                     */<br>    acpi_op_remove  remove;   /* release                                   */<br>    acpi_op_notify  notify;   /* ACPI Notify() events                      */<br>};</pre><p>Distinction to keep straight:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f81fd5438b10f115ee83ba66d220c22/href">https://medium.com/media/1f81fd5438b10f115ee83ba66d220c22/href</a></iframe><h3>2.4 struct acpi_device_status - the _STA bitmask</h3><p>_STA returns a 32-bit integer whose low 5 bits are meaningful. ACPICA decodes it into this bitfield:</p><pre>struct acpi_device_status {<br>    u32 present:1;             /* bit 0 */<br>    u32 enabled:1;             /* bit 1 */<br>    u32 show_in_ui:1;          /* bit 2 */<br>    u32 functional:1;          /* bit 3 */<br>    u32 battery_present:1;     /* bit 4 (battery devices only) */<br>    u32 reserved:27;<br>};</pre><p>Full bit semantics are detailed in section 5.1.</p><h3>2.5 ACPI_BUS_TYPE_* constants</h3><p>acpi_device.device_type records what <em>kind</em> of namespace object this is, which decides which specialised setup runs:</p><pre>#define ACPI_BUS_TYPE_DEVICE        0   /* a normal Device{} node          */<br>#define ACPI_BUS_TYPE_POWER         1   /* PowerResource{}                 */<br>#define ACPI_BUS_TYPE_PROCESSOR     2   /* Processor{} / ACPI0007          */<br>#define ACPI_BUS_TYPE_THERMAL       3   /* ThermalZone{}                   */<br>#define ACPI_BUS_TYPE_POWER_BUTTON  4   /* fixed-feature power button      */<br>#define ACPI_BUS_TYPE_SLEEP_BUTTON  5   /* fixed-feature sleep button      */<br>#define ACPI_BUS_TYPE_ECDT_EC       6   /* EC described by the ECDT        */</pre><p>The first four correspond to real namespace object types; the last three are “fixed feature” pseudo-devices synthesised by the kernel (they have no real namespace Device node — handle is a sentinel).</p><p>Related: acpi_device_id is the match-table entry type shared by scan handlers and drivers:</p><pre>struct acpi_device_id {<br>    __u8   id[ACPI_ID_LEN];   /* e.g. &quot;PNP0A08&quot;                    */<br>    kernel_ulong_t driver_data;<br>    __u32  cls;               /* PCI-style class match (optional)  */<br>    __u32  cls_msk;<br>};</pre><h3>3. Phase 1: Scan Handler Registration (acpi_scan_init)</h3><h3>3.1 What a scan handler is and why it exists</h3><p>Before the namespace is walked, the subsystems that need first crack at certain device classes must <strong>register their scan handlers</strong>. This happens inside acpi_scan_init() (in drivers/acpi/scan.c), which is called once from acpi_init():</p><pre>int __init acpi_scan_init(void)<br>{<br>    acpi_pci_root_init();        /* PNP0A03 / PNP0A08 */<br>    acpi_pci_link_init();        /* PNP0C0F           */<br>    acpi_processor_init();       /* ACPI0007          */<br>    acpi_platform_init();        /* generic fallback  */<br>    acpi_lpss_init();            /* Intel LPSS        */<br>    acpi_apd_init();             /* AMD/misc SoC      */<br>    acpi_cmos_rtc_init();        /* PNP0B00           */<br>    acpi_container_init();       /* ACPI0004          */<br>    acpi_memory_hotplug_init();  /* PNP0C80           */<br>    acpi_watchdog_init();<br>    acpi_pnp_init();<br>    acpi_int340x_thermal_init();<br>    ...<br>    /* Then the actual walk: */<br>    acpi_bus_scan(ACPI_ROOT_OBJECT);<br>    ...<br>}</pre><p>Each *_init() typically calls acpi_scan_add_handler() (or acpi_scan_add_handler_with_hotplug()), which appends the handler to the global acpi_scan_handlers_list.</p><p><strong>Why they exist: </strong>an ordinary acpi_driver binds <em>after</em> the driver core is up and probes asynchronously. But some <strong>ACPI devices</strong> are <strong>buses</strong> whose children must be discovered <em>during</em> enumeration (a PCI root bridge is the canonical case - you cannot enumerate PCI devices without first knowing the bridge exists and its resource windows). Scan handlers give subsystems a synchronous, priority hook at exactly the right moment in the namespace walk.</p><h3>3.2 The registered handlers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MHaaaZXe-QSZh0U7aFwNmw.jpeg" /></figure><p>Each handler in detail:</p><ul><li><strong>PCI root bridge :</strong> PNP0A08 (PCIe) / PNP0A03 (legacy PCI) acpi_pci_root_init() registers acpi_pci_root_handler. Its .attach is acpi_pci_root_add(), which reads _CRS for the bus-number range and MMIO/IO windows, creates the pci_host_bridge, and triggers a full PCI bus scan (pci_scan_root_bus/pci_bus_add_devices). Returns &gt; 0 so ACPI does not try to enumerate PCI children from the namespace itself. See section 9.1.</li><li><strong>Processor :</strong> ACPI0007 (and legacy Processor{} objects) acpi_processor_init() registers the processor scan handler. .attach → acpi_processor_add() sets up the struct acpi_processor, maps the ACPI processor UID/ACPI-ID to a Linux logical CPU, and hooks C-state/P-state data (_CST, _PSS, _CPC). See §9.5.</li><li><strong>Thermal zone</strong> Handled by the thermal acpi_driver (acpi_thermal_add) rather than a scan handler — thermal zones are ACPI_BUS_TYPE_THERMAL objects, not HID-matched Devices. It registers a thermal_zone_device and reads _TMP, _PSV, _CRT, _ACx, _TZP. See §9.6.</li><li><strong>Battery :</strong> PNP0C0A The battery acpi_driver (acpi_battery_add) creates a power_supply class device and reads _BIF/_BIX (info) and _BST (status).</li><li><strong>Button :</strong>PNP0C0C (power) / PNP0C0E (sleep) / PNP0C0D (lid) The button acpi_driver (acpi_button_add) registers an input_dev and wires Notify() events to key/switch events. The fixed-feature power/sleep buttons (no namespace node) come through ACPI_BUS_TYPE_POWER_BUTTON/ _SLEEP_BUTTON instead.</li><li><strong>Embedded Controller :</strong> PNP0C09 acpi_ec handling. The EC is special: it is often needed <em>very</em> early (before general enumeration) so it can also be brought up from the ECDT table (ACPI_BUS_TYPE_ECDT_EC). .attach installs the EC address-space handler so OperationRegion(EC, EmbeddedControl, …) accesses work.</li><li><strong>Memory hotplug :</strong>PNP0C80 acpi_memory_hotplug_init() registers acpi_memory_device_handler. .attach → acpi_memory_device_add() reads _CRS memory ranges (or _MSI-style descriptors) and, on hot-add, calls add_memory() into the memory subsystem.</li><li><strong>Platform / generic handler</strong> acpi_platform_init() registers a catch-all handler whose .attach is acpi_create_platform_device(). Any Device with a _HID/_CID that no specialised handler claimed, and that has resources (_CRS), becomes a platform_device on the platform bus, so an ordinary platform_driver can bind (this is how most SoC/embedded peripherals - I2C controllers, UARTs, GPIO controllers described in ACPI - reach their drivers). See section 9.</li></ul><blockquote><strong><em>Ordering note:</em></strong><em> handlers are matched in registration order via each handler’s </em><em>.ids table; the first match wins. The generic platform handler is effectively last-resort because more specific handlers are registered and matched first.</em></blockquote><h3>4. Phase 2: Namespace Walk (acpi_bus_scan)</h3><p>With handlers registered, acpi_scan_init() calls acpi_bus_scan(handle) on the root object. This is where namespace nodes start becoming devices.</p><pre>int acpi_bus_scan(acpi_handle handle)<br>{<br>    struct acpi_device *device = NULL;<br>/* First pass: create device objects (check_add). */<br>    if (ACPI_SUCCESS(acpi_bus_type_and_status(handle, ...)))<br>        acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,<br>                            acpi_bus_check_add,   /* descending callback */<br>                            NULL,<br>                            NULL, (void **)&amp;device);<br>    /* Second pass: attach handlers/drivers. */<br>    if (device) {<br>        acpi_bus_attach(device, NULL, true);<br>        return 0;<br>    }<br>    return -ENODEV;<br>}</pre><p>Conceptually the scan is two passes over the same subtree:</p><ol><li><strong>Create pass :</strong> acpi_walk_namespace() with the acpi_bus_check_add callback creates an acpi_device for every qualifying node (section 5).</li><li><strong>Attach pass :</strong> acpi_bus_attach() (section 6) walks the freshly-built acpi_device tree and binds handlers/drivers, recursing into children.</li></ol><h3>4.1 acpi_walk_namespace() - DFS explained</h3><p>acpi_walk_namespace() is the ACPICA primitive that performs a <strong>depth-first traversal</strong> of a namespace subtree, invoking a callback on each node:</p><pre>acpi_status<br>acpi_walk_namespace(acpi_object_type type,       /* ACPI_TYPE_ANY here      */<br>                    acpi_handle      start_object,/* subtree root            */<br>                    u32              max_depth,    /* ACPI_UINT32_MAX = all   */<br>                    acpi_walk_callback descending_cb,  /* called pre-order   */<br>                    acpi_walk_callback ascending_cb,   /* called post-order  */<br>                    void            *context,<br>                    void           **return_value);</pre><ul><li>The <strong>descending callback</strong> fires when the walk <em>enters</em> a node (pre-order); the <strong>ascending callback</strong> fires when it <em>leaves</em> (post-order). Enumeration uses the descending callback (acpi_bus_check_add).</li><li>It recurses into every child scope, so the entire \_SB subtree (and \_TZ, \_PR, \_SI, \_GPE) is visited.</li><li>Internally it holds the ACPI namespace mutex and skips non-device object types when asked, but with ACPI_TYPE_ANY it visits everything and the callback decides what to act on.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*OVq1LJLf1qYNGPk3nJKyHw.png" /></figure><p><em>(Dashed numbers show the pre-order visit sequence.)</em></p><h3>4.2 Why depth-first order matters</h3><p>Depth-first, parent-before-child order is not incidental — enumeration depends on it:</p><ul><li><strong>Ancestors must exist first.</strong> An acpi_device&#39;s dev.parent is its parent ACPI device. Creating a child before its parent would break the device-model hierarchy and sysfs paths.</li><li><strong>Bus context flows downward.</strong> When the PCI root handler claims PCI0 and returns &gt; 0, ACPI knows not to descend into PCI children as ACPI devices — the PCI subsystem owns them. That decision must be made at the parent before reaching children.</li><li>_INI <strong>ordering</strong>. The ACPI spec mandates that _INI run top-down; the DFS matches that contract (though _INI itself is run during the earlier acpi_ns_initialize_devices step, the same ordering discipline applies).</li><li><strong>Resource dependencies.</strong> A child’s resources (e.g. an interrupt routed through a parent’s _PRT) may depend on the parent already being set up.</li></ul><h3>4.3 acpi_bus_check_add() - the per-node callback</h3><p>This is the descending callback invoked for every namespace node during the create pass. Its job is to decide <em>whether</em> a node deserves an acpi_device and, if so, to create one.</p><pre>static acpi_status<br>acpi_bus_check_add(acpi_handle handle, u32 lvl, void *context, void **ret)<br>{<br>    struct acpi_device *device = NULL;<br>    acpi_object_type acpi_type;<br>    int type;<br>    acpi_get_type(handle, &amp;acpi_type);<br>    switch (acpi_type) {<br>    case ACPI_TYPE_DEVICE:<br>        if (acpi_device_should_be_hidden(handle))<br>            return AE_OK;                       /* skip (e.g. INTC/blocklist) */<br>        type = ACPI_BUS_TYPE_DEVICE;<br>        break;<br>    case ACPI_TYPE_PROCESSOR:<br>        type = ACPI_BUS_TYPE_PROCESSOR;<br>        break;<br>    case ACPI_TYPE_THERMAL:<br>        type = ACPI_BUS_TYPE_THERMAL;<br>        break;<br>    case ACPI_TYPE_POWER:<br>        type = ACPI_BUS_TYPE_POWER;<br>        break;<br>    default:<br>        return AE_OK;   /* Methods, Names, Regions, Mutexes --&gt;ignored */<br>    }<br>    /* Already created (revisit)? just return it. */<br>    if (acpi_bus_get_device(handle, &amp;device) == 0)<br>        goto out;<br>    acpi_add_single_object(&amp;device, handle, type, ...);  /* Section 5 */<br>out:<br>    if (ret) *ret = device;<br>    return AE_OK;<br>}</pre><p>Key points:</p><ul><li><strong>Object-type filter.</strong> Only Device, Processor, ThermalZone, and PowerResource object types become acpi_devices. Method, Name, OperationRegion, Mutex, Event, etc. are skipped - they are AML plumbing, not devices.</li><li><strong>Hidden/blocklisted nodes</strong> (e.g. certain interrupt controllers Linux handles via other means, or firmware quirks) are skipped via acpi_device_should_be_hidden().</li><li><strong>Idempotency.</strong> During hot-plug re-scans the same node may be visited again; if an acpi_device already exists it is reused rather than duplicated.</li><li>The heavy lifting :_STA, _HID, _CID, object creation - is delegated to acpi_add_single_object() (Phase 3).</li></ul><h3>5. Phase 3: Device Object Creation (acpi_add_single_object)</h3><p>acpi_add_single_object() turns one namespace node into a fully-formed, registered struct acpi_device. Its skeleton:</p><pre>int acpi_add_single_object(struct acpi_device **child,<br>                           acpi_handle handle, int type, bool dep_init)<br>{<br>    struct acpi_device *device;<br>    struct acpi_device_info *info = NULL;<br>    device = kzalloc(sizeof(*device), GFP_KERNEL);<br>    acpi_init_device_object(device, handle, type, ...);<br>    /*  ├─ evaluate _STA          --&gt;device-&gt;status<br>        ├─ evaluate _HID/_CID/... --&gt;device-&gt;pnp.ids<br>        ├─ evaluate _UID/_ADR<br>        ├─ set up power (_PSx/_PRx), wakeup (_PRW)<br>        ├─ read _DSD properties<br>        └─ device_initialize(&amp;device-&gt;dev)  */<br>    acpi_scan_init_status(device);          /* _STA refresh          */<br>    if (dep_init)<br>        acpi_scan_dep_init(device);         /* _DEP (§8)             */<br>    acpi_device_add(device, acpi_device_release);  /* device_add --&gt;sysfs */<br>    acpi_device_add_finalize(device);<br>    *child = device;<br>    return 0;<br>}</pre><p>The interesting work is all in the <strong>object initialisation</strong>. We walk each evaluated method below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*u993gcAjA5oR-ejpIfjbvg.png" /></figure><h3>5.1 _STA evaluation - the 5-bit bitmask in detail</h3><p>_STA (Status) is evaluated first because it determines whether the device even exists. It returns a 32-bit integer; the low 5 bits are defined by the ACPI spec. If _STA is absent, the device is assumed present, enabled, functional, and shown (i.e. value 0x0F-all bits except battery set).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h6msgwHnFHDLafx3x4xJKQ.png" /></figure><ul><li><strong>Bit 0 : Present</strong>. The master switch. If clear, the hardware is not there.</li><li><strong>Bit 1 : Enabled</strong>. Present <em>and</em> actively decoding/using resources. A device can be present (bit 0) but not enabled (bit 1) - e.g. disabled in firmware.</li><li><strong>Bit 2 :Show in UI</strong>. Whether the OS should surface it to the user (affects device-&gt;flags / whether it&#39;s presented in UI-facing enumerations). Does not affect functionality.</li><li><strong>Bit 3 : Functional</strong>. The device works. A device <strong>may be not present (bit 0 clear) yet functional (bit 3 set)</strong> - a legal, meaningful combination that says “there is a valid device method here even though the slot is empty,” which matters for docks and hot-plug bays.</li><li><strong>Bit 4 : Battery present</strong>. Only meaningful for control-method battery devices (PNP0C0A); indicates a battery is inserted.</li></ul><p>The decoded result lands in device-&gt;status (section 2.4).</p><h3>5.2 What happens when _STA = 0 (not present)</h3><p>If _STA returns 0 (nothing set — not present, not functional):</p><ul><li>Normally <strong>no</strong> acpi_device <strong>is created</strong> and enumeration does not descend into the node&#39;s children.</li><li><strong>Exception - the node has children that must still be examined</strong>. Per the ACPI spec, if a device is not present <em>and</em> not functional (bits 0 and 3 both clear), the OS must <strong>not examine</strong> child devices. But if it is not present yet <em>functional</em> (bit 3 set), children must still be enumerated. Linux encodes this in acpi_bus_check_add/acpi_device_is_present():</li></ul><pre>static bool acpi_device_is_present(const struct acpi_device *adev)<br>{<br>    return adev-&gt;status.present || adev-&gt;status.functional;<br>}</pre><ul><li>If dynamic_status is set (the device has a _STA method, so status can change at runtime), the device object may still be created but marked not-present; a later Notify() + re-evaluation can bring it online (hot-plug, dock).</li><li>For a device that is genuinely absent and non-functional, the subtree is pruned - this is how empty PCIe slots, unpopulated DIMMs, and absent dock devices avoid cluttering the device tree.</li></ul><h3>5.3 _HID evaluation - primary device ID</h3><p>_HID (Hardware ID) is the device&#39;s primary identifier, used first for driver matching. It is either:</p><ul><li>A <strong>PNP ID</strong>: a 7-char string AAA#### ,three vendor letters + 4 hex digits (e.g. PNP0A08, PNP0C09), historically encoded as a 32-bit EISAID.</li><li><strong>An ACPI ID:</strong> NNNN#### , a 4-char vendor + 4 hex (e.g. ACPI0007 for a processor, INT33FC for an Intel SoC GPIO controller).</li></ul><p>Linux reads it via ACPICA (acpi_get_object_info populates HardwareId) and stores it as the first entry on device-&gt;pnp.ids. If _HID is absent, the device may be identified purely by _ADR (bus-enumerated) or _CID.</p><h3>5.4 _CID evaluation - compatible IDs list</h3><p>_CID (Compatible ID) provides one or more fallback IDs, in priority order, for when no driver matches the _HID. It is the ACPI analogue of DT&#39;s compatible list. Semantics:</p><ul><li>Can return a single ID or a Package{} of IDs.</li><li>Each is appended to device-&gt;pnp.ids <em>after</em> the _HID.</li><li>Driver matching (acpi_match_device_ids, §6.2) tries _HID first, then each _CID in order — so a device advertising _HID &quot;VENDABCD&quot; and _CID &quot;PNP0501&quot; (a generic 16550 UART) will bind a generic serial driver if no vendor-specific driver exists.</li></ul><h3>5.5 _UID evaluation - instance differentiation</h3><p>_UID (Unique ID) disambiguates <strong>multiple instances of the same</strong> _HID within one scope (e.g. two identical UARTs both PNP0501). It may be an integer or a string. Stored in device-&gt;pnp.unique_id. It is <em>not</em> used for matching a driver — it is used to build a stable, unique device name/bus_id and to let _DSD/_DEP/consumer references pinpoint the right instance.</p><h3>5.6 _ADR evaluation - bus-enumerated address</h3><p>_ADR (Address) gives the device&#39;s address on its parent bus for devices that are enumerated by the bus rather than by _HID (PCI functions, I2C addresses declared as children, etc.). Format is bus-specific:</p><ul><li><strong>PCI:</strong> high word = device number, low word = function number ((dev &lt;&lt; 16) | func).</li><li><strong>I2C/SPI</strong> <strong>child under a controller:</strong> slave address / chip-select.</li></ul><p>A device may have _ADR instead of _HID (pure bus-address device) or in addition to it. Stored in device-&gt;pnp.bus_address; it is how the ACPI device is later matched up (glued) to the physical bus device created by the bus subsystem (the companion/physical_node link).</p><h3>5.7 _DSD evaluation — key-value properties</h3><p>_DSD (Device-Specific Data) is the ACPI mechanism for arbitrary key/value device properties, mirroring Device Tree properties. It returns a Package{} tagged by a well-known UUID:</p><ul><li><strong>Device Properties UUID</strong> daffd814-6eba-4d8c-8a91-bc9bbf4aa301 : a package of { &quot;key&quot;, value } pairs. This is what device_property_read_*() and fwnode_property_*() read (Section10).</li><li><strong>Hierarchical Properties UUID</strong> dbb8e3e6-5886-4ba6-8795-1319f52a966b — nested “data node” sub-packages, giving _DSD a tree of property sets.</li></ul><p>Linux parses _DSD in acpi_init_properties() (drivers/acpi/property.c) and stores it in device-&gt;data, exposing it through the unified fwnode property API so a driver can read &quot;clock-frequency&quot;, &quot;compatible&quot;, GPIO/interrupt name mappings, etc., identically to how it would from DT.</p><h3>5.8 Power management method evaluation</h3><p>During object init, the device’s power model is captured:</p><ul><li>_PSx (<strong>Power State x</strong>) : control methods _PS0.._PS3 to place the device in D0–D3.</li><li>_PRx (<strong>Power Resources for state x</strong>) : _PR0.._PR3 list the PowerResource objects that must be ON for each D-state.</li><li>_PSC : returns the current power state.</li><li>_PRW (<strong>Power Resources for Wake</strong>) : the GPE + power resources that let the device wake the system; parsed into device-&gt;wakeup.</li><li>_EJx/_RMV/_LCK :eject, removable, lock methods for hot-plug/dock.</li></ul><p>If any power methods exist, device-&gt;flags.power_manageable is set and the ACPI power domain (acpi_dev_pm_*) can later manage the device&#39;s runtime PM.</p><h3>5.9 device_initialize() - the Linux device model</h3><p>Finally the embedded struct device is prepared and registered:</p><ol><li>device_initialize(&amp;device-&gt;dev)- initialises the kobject, device fields, and reference count (does not yet make it visible).</li><li>The device’s bus_type is set to acpi_bus_type, dev.parent is set to the parent acpi_device&#39;s dev, and the fwnode is wired up.</li><li>device_add(&amp;device-&gt;dev) (via acpi_device_add) - publishes it: creates /sys/bus/acpi/devices/&lt;name&gt;, emits a KOBJ_ADD uevent, and links it into the driver-model hierarchy.</li><li>The device name (bus_id) is built from the _HID/_UID (e.g. PNP0C09:00, device:00), guaranteeing uniqueness within the bus.</li></ol><p>After this the acpi_device exists in sysfs but has <strong>no driver bound yet - </strong>that is Phase 4.</p><h3>6. Phase 4: Driver Attachment (acpi_bus_attach)</h3><p>After the create pass built the acpi_device tree, acpi_bus_scan() calls acpi_bus_attach() on the root device. This is the <strong>attach pass</strong>: it walks the device tree and, for each device, tries a scan handler first, then an acpi_driver, then recurses into children.</p><pre>static void acpi_bus_attach(struct acpi_device *device,<br>                            void *first_pass, bool first)<br>{<br>    acpi_status status;<br>    int ret;<br>acpi_bus_get_status(device);         /* re-eval _STA (dynamic)      */<br>    if (!acpi_device_is_present(device)) {<br>        device-&gt;flags.initialized = false;<br>        acpi_device_clear_enumerated(device);<br>        return;                          /* absent --&gt; don&#39;t attach       */<br>    }<br>    if (device-&gt;handler)                 /* already attached (re-scan)? */<br>        goto ok;<br>    if (device-&gt;flags.dep_unmet)         /* _DEP not satisfied (§8)     */<br>        return;                          /* defer                       */<br>    ret = acpi_scan_attach_handler(device);   /* try scan handler       */<br>    if (ret &lt; 0) return;<br>    device-&gt;flags.match_driver = true;<br>    if (ret &gt; 0 &amp;&amp; !device-&gt;flags.enumeration_by_parent) {<br>        /* handler claimed a self-enumerating bus --&gt;don&#39;t recurse for<br>           physical children; still recurse for ACPI children below.   */<br>    } else {<br>        ret = device_attach(&amp;device-&gt;dev);   /* --&gt;acpi_device_probe    */<br>    }<br>ok:<br>    /* Recurse into ACPI children. */<br>    list_for_each_entry(child, &amp;device-&gt;children, node)<br>        acpi_bus_attach(child, NULL, false);<br>    if (!ret &amp;&amp; device-&gt;handler == NULL &amp;&amp; ... )<br>        acpi_default_enumeration(device);    /* --&gt;platform_device      */<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*a1bKV7gEuEZyRC0hOmR9Xw.png" /></figure><h3>6.1 acpi_scan_attach_handler() - scan handler priority</h3><p>Scan handlers get <strong>first refusal</strong>. This function walks the device’s ID list and the global handler list looking for a match:</p><pre>static int acpi_scan_attach_handler(struct acpi_device *device)<br>{<br>    struct acpi_hardware_id *hwid;<br>    int ret = 0;<br>list_for_each_entry(hwid, &amp;device-&gt;pnp.ids, list) {<br>        const struct acpi_device_id *devid;<br>        struct acpi_scan_handler *handler;<br>        handler = acpi_scan_match_handler(hwid-&gt;id, &amp;devid);<br>        if (handler) {<br>            device-&gt;handler = handler;<br>            ret = handler-&gt;attach(device, devid);   /* the real work   */<br>            if (ret &gt; 0)<br>                break;                  /* claimed a bus; stop trying   */<br>            device-&gt;handler = NULL;<br>            if (ret &lt; 0)<br>                break;                  /* error                        */<br>        }<br>    }<br>    return ret;<br>}</pre><ul><li>It tries the IDs in priority order: _HID, then each _CID.</li><li>A matching handler’s .attach() is called. If it returns &gt; 0 the device is a self-enumerating bus and the search stops.</li><li>If .attach() returns 0, the handler handled it but the device is not a bus; if it returns &lt; 0, that&#39;s an error.</li><li>If no scan handler matches, the function returns 0 and the device falls through to acpi_driver/platform matching.</li></ul><h3>6.2 acpi_match_device_ids()- HID/CID comparison</h3><p>Both scan-handler matching and acpi_driver matching ultimately compare the device&#39;s ID list against a candidate acpi_device_id[] table:</p><pre>int acpi_match_device_ids(struct acpi_device *device,<br>                          const struct acpi_device_id *ids);</pre><p>The comparison logic (__acpi_match_device):</p><ol><li>For each hwid on device-&gt;pnp.ids (starting with _HID, then _CIDs):</li><li>For each entry in the driver/handler ids[] table:</li><li>Case-insensitively compare the ID strings (and optionally the PCI-style cls/cls_msk class match).</li><li>The first match wins; because _HID is checked before _CIDs, the most specific identity is preferred.</li></ol><p>This is also what the driver core calls through acpi_bus_type.match (acpi_device_match → acpi_driver_match_device) when deciding whether an acpi_driver can bind, and what acpi_match_device() uses to return the matching acpi_device_id (whose driver_data often carries per-model quirks).</p><h3>6.3 acpi_device_probe() - driver ops.add()</h3><p>If no scan handler claimed the device, the driver core’s device_attach() finds a matching acpi_driver and calls the ACPI bus&#39;s probe hook:</p><pre>static int acpi_device_probe(struct device *dev)<br>{<br>    struct acpi_device *acpi_dev = to_acpi_device(dev);<br>    struct acpi_driver *acpi_drv = to_acpi_driver(dev-&gt;driver);<br>    int ret;<br>ret = acpi_bus_driver_init(acpi_dev, acpi_drv);   /* → ops.add()   */<br>    if (ret) return ret;<br>    if (acpi_drv-&gt;ops.notify) {<br>        ret = acpi_device_install_notify_handler(acpi_dev, acpi_drv);<br>        ...<br>    }<br>    return 0;<br>}</pre><p>acpi_bus_driver_init() sets acpi_dev-&gt;driver = acpi_drv, then calls acpi_drv-&gt;ops.add(acpi_dev). That .add callback is the driver&#39;s real probe: e.g. acpi_battery_add, acpi_button_add, acpi_fan_add, acpi_thermal_add. If .ops.notify is set, an ACPI Notify() handler is installed so runtime events (0x80 status change, dock/undock, etc.) reach the driver.</p><h3>6.4 Recursive child attachment</h3><p>After the current device is (or isn’t) bound, acpi_bus_attach() iterates the device&#39;s ACPI children and calls itself on each:</p><pre>list_for_each_entry(child, &amp;device-&gt;children, node)<br>    acpi_bus_attach(child, NULL, false);</pre><ul><li>This continues the depth-first discipline into the <em>device</em> tree (as opposed to the raw namespace tree walked in Phase 2).</li><li>Note the interaction with self-enumerating buses: when a PCI root handler claimed PCI0, the <em>PCI</em> children are enumerated by the PCI subsystem, not here — but any genuine ACPI children of PCI0 in the namespace (power resources, additional Device nodes with _HID) are still walked.</li><li>Devices whose _DEP is unmet are skipped here and revisited once their dependencies clear (§8).</li></ul><h3>7. Phase 5: Resource Assignment (_CRS)</h3><p>A bound driver needs to know <em>what hardware resources</em> its device uses - interrupts, memory windows, I/O ports, GPIO pins, bus connections. That comes from _CRS (Current Resource Settings), an AML buffer of resource descriptors. (<strong>Related:</strong> _PRS lists <em>possible</em> settings and _SRS sets them, used by resource arbitration for reconfigurable legacy devices.)</p><h3>7.1 acpi_dev_get_resources()</h3><p>The main entry point drivers use to convert _CRS into a list of Linux struct resource:</p><pre>int acpi_dev_get_resources(struct acpi_device *adev,<br>                           struct list_head *list,<br>                           int (*preproc)(struct acpi_resource *, void *),<br>                           void *preproc_data);</pre><ul><li>Evaluates _CRS, then walks each descriptor, translating it into a struct resource_entry appended to list.</li><li>The optional preproc callback lets a caller inspect/modify/skip each raw struct acpi_resource before conversion (used to filter resource types).</li><li>Convenience wrappers: acpi_dev_get_memory_resources(), acpi_dev_get_irq_resources(), and acpi_dev_free_resource_list() to release.</li></ul><p>For platform_devices created by the platform scan handler, this happens automatically: acpi_create_platform_device() calls acpi_dev_get_resources() and populates the platform device&#39;s resource[] array so platform_get_resource() / platform_get_irq() work exactly as they do for DT-instantiated platform devices.</p><h3>7.2 acpi_walk_resources()</h3><p>The lower-level ACPICA primitive underneath: it evaluates a named resource method (&quot;_CRS&quot;, &quot;_PRS&quot;, or &quot;_AEI&quot;) and invokes a callback per descriptor.</p><pre>acpi_status<br>acpi_walk_resources(acpi_handle handle, char *name,<br>                    acpi_walk_resource_callback cb, void *context);</pre><p>Each callback receives a struct acpi_resource whose .type selects a union member. acpi_dev_get_resources() is essentially a well-featured acpi_walk_resources() consumer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJFu_Nvhn5qgQMgsln3TYQ.png" /></figure><h3>7.3 Resource types</h3><p>The ACPI resource descriptors Linux understands and their Linux mappings:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6789ed21dd0c9e78b33f2a99599e8e6/href">https://medium.com/media/a6789ed21dd0c9e78b33f2a99599e8e6/href</a></iframe><h3>7.4 Converting ACPI resources to Linux struct resource</h3><p>For the “classic” resource types (IRQ, MEM, IO, DMA), conversion produces a struct resource:</p><pre>struct resource {<br>    resource_size_t start;<br>    resource_size_t end;<br>    const char     *name;<br>    unsigned long   flags;    /* IORESOURCE_MEM / _IO / _IRQ / _DMA + attrs */<br>    ...<br>};</pre><p>acpi_dev_resource_memory(), acpi_dev_resource_io(), acpi_dev_resource_interrupt(), and acpi_dev_resource_address_space() are the per-type helpers that fill start/end/flags. Address-space descriptors carry translation offsets (for bridges) which are applied to compute the CPU view of the range.</p><p>The <em>serial-bus</em> and <em>GPIO</em> descriptors are not turned into struct resource; instead they are looked up on demand by the consuming subsystem (I2C/SPI/GPIO) via the fwnode/connection APIs — see §9.</p><h3>7.5 acpi_register_gsi() → Linux virq</h3><p>Interrupts need special handling because ACPI describes them as <strong>GSIs</strong> (Global System Interrupt numbers) while Linux drivers use <strong>virtual IRQ numbers </strong>(virq) from the irqdomain layer.</p><pre>int acpi_register_gsi(struct device *dev, u32 gsi,<br>                      int trigger, int polarity);</pre><ul><li>Maps a GSI (plus trigger edge/level and polarity from the _CRS interrupt descriptor&#39;s flags) to a Linux virq via the interrupt controller&#39;s irqdomain (IOAPIC domain on x86, GIC domain on ARM64).</li><li>Under the hood it calls irq_create_fwspec_mapping() / acpi_register_gsi_ioapic|gic().</li><li>The returned virq is what ends up in the IORESOURCE_IRQ resource and what request_irq()/platform_get_irq() return.</li><li>acpi_gsi_to_irq() and acpi_unregister_gsi() are the lookup/teardown counterparts.</li><li>For <strong>GpioInt</strong> resources the path differs: the interrupt is provided by a GPIO controller, so acpi_dev_gpio_irq_get() resolves the GPIO pin and calls gpiod_to_irq() to obtain the virq.</li></ul><p>This GSI→virq translation is the final link that lets an ACPI-described device receive interrupts through the standard Linux IRQ machinery.</p><h3>8. Dependency Resolution (_DEP)</h3><h3>8.1 Why _DEP exists</h3><p>_CRS describes a device&#39;s <em>resources</em>, but some devices have operational dependencies on <em>other devices</em> that are not expressible as resources - the classic case being a device whose OperationRegions are backed by an embedded controller or a GPIO/I2C controller. Such a device cannot be initialised until its provider is up and its address-space handler installed.</p><p>_DEP (Dependencies) returns a Package{} of references (namespace paths) to devices that must be <strong>present and initialised first</strong>. It is a load-ordering hint, distinct from resource or power dependencies.</p><p>Typical example - a touchpad on I2C whose interrupt and power come through a GPIO controller and whose _STA/_INI touch EC operation regions:</p><pre>Device (TPD0) {<br>    Name (_HID, &quot;ELAN0000&quot;)<br>    Name (_DEP, Package() { \_SB.PCI0.I2C1, \_SB.GPO0, \_SB.PCI0.LPCB.EC0 })<br>    ...<br>}</pre><h3>8.2 acpi_scan_dep_init()</h3><p>During object creation (§5), acpi_scan_dep_init() evaluates _DEP and records the dependency graph:</p><pre>static void acpi_scan_dep_init(struct acpi_device *adev)<br>{<br>    struct acpi_dep_data *dep;<br>    /* evaluate _DEP → list of provider handles */<br>    for each handle in _DEP package {<br>        if (provider should gate this device) {<br>            dep = kzalloc(...);<br>            dep-&gt;supplier = provider_handle;<br>            dep-&gt;consumer = adev-&gt;handle;<br>            list_add(&amp;dep-&gt;node, &amp;acpi_dep_list);<br>            adev-&gt;dep_unmet++;    /* count unmet dependencies */<br>        }<br>    }<br>}</pre><ul><li>Each edge is stored on the global acpi_dep_list.</li><li>The consumer’s dep_unmet counter tracks how many suppliers are still not ready.</li><li>Some providers are filtered out (e.g. dependencies that Linux knows are already satisfied, or self-references), governed by helpers like acpi_dep_valid() / honeypot HIDs that should not gate probing.</li></ul><h3>8.3 Deferred probe mechanism</h3><p>In acpi_bus_attach() (section 6), a device with dep_unmet &gt; 0 is <strong>not attached</strong>:</p><pre>if (device-&gt;flags.dep_unmet)<br>    return;      /* skip attach; will be revisited */</pre><p>The device object still exists in sysfs, but no scan handler / driver is bound and no children are attached under it. This is the ACPI counterpart of the driver core’s general <strong>deferred probe</strong> (-EPROBE_DEFER) mechanism, but resolved via explicit _DEP edges rather than probe-time failure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*DGqItdcIjQh-QtKSyJ2XfA.png" /></figure><h3>8.4 acpi_dev_clear_dependencies()</h3><p>When a supplier becomes ready - typically at the end of its own attach, once it can service its consumers (e.g. the EC has installed its EmbeddedControl address-space handler, or a GPIO/I2C controller has registered) - it calls:</p><pre>void acpi_dev_clear_dependencies(struct acpi_device *supplier);</pre><p>This:</p><ol><li>Walks acpi_dep_list for edges whose supplier matches.</li><li>For each dependent consumer, decrements consumer-&gt;dep_unmet and removes the edge.</li><li>When a consumer’s dep_unmet reaches 0, the consumer is eligible for (re-)attachment; acpi_bus_attach() is re-invoked (often via acpi_bus_scan() on the consumer or a scheduled rescan) so the previously deferred device now binds its driver and enumerates its children.</li></ol><p>Complementary helpers:</p><ul><li>acpi_dev_ready_for_enumeration() — returns whether a device&#39;s deps are all met (used to gate enumeration).</li><li>acpi_dev_get_first_consumer_dev() — walk from supplier to a consumer, used by subsystems that need to coordinate ordering.</li></ul><p>The net effect: _DEP guarantees that, e.g., an I2C touchpad is never probed before the I2C controller, GPIO controller, and EC it relies on are all live.</p><h3>9. Subsystem-Specific Enumeration</h3><p>When a scan handler .attach() runs (or a platform device is probed), the owning subsystem frequently spawns a <strong>second, bus-specific device</strong> and/or enumerates children of its own. Below are the important cases. The recurring pattern: the acpi_device is the <em>ACPI companion</em>; the bus creates the <em>physical device</em>, and the two are linked via physical_node_list (ACPI_COMPANION() / acpi_device-&gt;physical_node).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bYjvXheX7-FshV93GlqshA.png" /></figure><h3>9.1 PCI: acpi_pci_root_add() → full PCI scan</h3><p>Triggered by the PNP0A08/PNP0A03 scan handler. Steps:</p><ol><li>Parse _CRS for the bus-number range (Producer/BusNumber address descriptor) and the <strong>MMIO / I/O / bus resource windows</strong>.</li><li>Evaluate _SEG (PCI segment) and _BBN (base bus number).</li><li>Run _OSC/_DSM to negotiate which features the OS controls (native PCIe hotplug, AER, ASPM, etc.).</li><li>Create the pci_host_bridge, then call pci_scan_root_bus() / pci_bus_add_devices() — <strong>a full recursive</strong> <strong>PCI enumeration</strong> of every bus, device, and function below the bridge.</li><li>Match each pci_dev back to its ACPI companion (if the namespace declares a child Device with matching _ADR), setting up the physical-node link so ACPI_COMPANION(&amp;pci_dev-&gt;dev) works, and enabling PCI power management via _PSx/_PRx and interrupt routing via _PRT.</li></ol><p>Because the handler returns &gt; 0, ACPI does not re-enumerate the PCI devices from the namespace; PCI owns that subtree.</p><h3>9.2 I2C: i2c_acpi_register_devices()</h3><p>When an I2C <strong>controller</strong> is enumerated (usually as a platform_device via the platform/LPSS/APD handler, then bound by an I2C bus driver), the I2C core scans the controller&#39;s ACPI children for I2C <strong>slave</strong> devices:</p><ul><li>i2c_acpi_register_devices(adapter) walks the namespace under the controller.</li><li>For each child with an I2cSerialBus _CRS connection whose ResourceSource points at this adapter, it builds an i2c_board_info (address from the descriptor, IRQ from a GpioInt/Interrupt resource) and calls i2c_new_client_device() to create an i2c_client.</li><li>The i2c_client is linked to its ACPI companion so the I2C driver can read _DSD properties via the fwnode API.</li></ul><h3>9.3 SPI: acpi_spi_add_device()</h3><p>Analogous to I2C, for SPI controllers:</p><ul><li>acpi_register_spi_devices(ctlr) walks the controller&#39;s ACPI children.</li><li>For each child with a SpiSerialBus connection referencing this controller, acpi_spi_add_device() fills a spi_device -chip-select from the descriptor, mode/CPOL/CPHA, max speed, and IRQ from a GPIO/interrupt resource - and registers it with spi_add_device().</li></ul><h3>9.4 GPIO: acpi_gpiochip_request_regions() / acpi_gpiochip_add()</h3><p>When a GPIO controller is enumerated and its driver registers a gpio_chip, the ACPI GPIO glue wires it into the ACPI world:</p><ul><li>acpi_gpiochip_add(chip) registers the chip so GpioIo/GpioInt _CRS descriptors elsewhere can resolve to this controller&#39;s pins.</li><li>acpi_gpiochip_request_regions() (via acpi_gpiochip_request_interrupts) scans the controller&#39;s _AEI (ACPI Event Interrupts) object and installs GPIO-signaled event handlers — the _Exx/_Lxx/_EVT methods that fire when a GPIO interrupt asserts (used for lids, buttons, hot-plug on SoCs).</li><li>Consumers resolve named GPIOs through _DSD gpio-mapping + acpi_get_gpiod_by_index() / gpiod_get(); interrupts via acpi_dev_gpio_irq_get().</li></ul><h3>9.5 CPU: acpi_processor_add()</h3><p>The ACPI0007 (or legacy Processor{}) scan handler&#39;s .attach:</p><ol><li>Reads the ACPI <strong>processor UID</strong> and the APIC/GIC processor ID, mapping it to a Linux <strong>logical CPU number</strong> (acpi_map_cpuid).</li><li>Allocates struct acpi_processor and registers a struct device under the CPU (arch_register_cpu where applicable), enabling CPU hotplug.</li><li>Hooks power/idle data: _CST (C-states) → cpuidle driver; _PSS/_PCT/ _PPC/_PDL (P-states) or _CPC (CPPC) → cpufreq driver; _TSS/_PTC/_TPC (T-states) → thermal throttling.</li><li>Registers with the processor subsystem so intel_idle/acpi_idle and acpi-cpufreq/cppc_cpufreq can bind.</li></ol><h3>9.6 Thermal: acpi_thermal_add()</h3><p>For ThermalZone{} objects (ACPI_BUS_TYPE_THERMAL), the thermal acpi_driver&#39;s .add:</p><ol><li>Evaluates _TMP (current temp), _CRT (critical), _HOT (S4 trip), _PSV (passive), and _ACx (active-cooling trips) plus _TZP (polling period).</li><li>Reads the associated cooling devices: _ALx (active - fans, referenced as PowerResource/fan devices) and _PSL (passive - processors to throttle).</li><li>Registers a thermal_zone_device with the thermal core (thermal_zone_device_register), binding trip points to cooling devices via the thermal governor.</li><li>Installs a Notify() handler so thermal events (0x80 temp change, 0x81 trip-point change) re-evaluate the zone.</li></ol><p>The resulting zone appears under /sys/class/thermal/thermal_zoneN/.</p><h3>10. The fwnode Interface</h3><h3>10.1 Unified DT + ACPI property API</h3><p>Historically, drivers written for <strong>Device Tree </strong>read properties via of_property_read_*(), and there was no equivalent for ACPI. _DSD (Section 5.7) changed that: it gave ACPI DT-style key/value properties. To let one driver consume properties regardless of the firmware type, Linux introduced the fwnode (firmware node) abstraction - an opaque handle with a vtable of property operations, implemented by both DT (of_fwnode_ops) and ACPI (acpi_fwnode_ops).</p><pre>struct fwnode_handle {<br>    const struct fwnode_operations *ops;   /* of_ or acpi_ */<br>    struct fwnode_handle *secondary;<br>    ...<br>};</pre><ul><li>Every acpi_device embeds a struct fwnode_handle fwnode (§2.1); its .ops is acpi_fwnode_ops, backed by device-&gt;data (_DSD).</li><li>dev_fwnode(dev) returns the device&#39;s firmware node; is_acpi_node(fwnode) / is_of_node(fwnode) discriminate.</li><li>ACPI_COMPANION(dev) / to_acpi_device_node(fwnode) recover the acpi_device from a physical device or fwnode.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*Ntn2zlclfLI4D_mJv9lKHw.png" /></figure><p>The payoff: a SoC peripheral driver reads &quot;clock-frequency&quot; with device_property_read_u32(dev, &quot;clock-frequency&quot;, &amp;freq) and it works whether the board is described by DT or by ACPI _DSD- the driver never branches on firmware type.</p><h3>10.2 fwnode_property_read_u32 / _string</h3><p>The core accessor family (include/linux/property.h):</p><pre>int fwnode_property_read_u32 (const struct fwnode_handle *fwnode,<br>                              const char *propname, u32 *val);<br>int fwnode_property_read_u64 (const struct fwnode_handle *, const char *, u64 *);<br>int fwnode_property_read_string(const struct fwnode_handle *,<br>                                const char *propname, const char **val);<br>int fwnode_property_read_u32_array(const struct fwnode_handle *,<br>                                   const char *propname, u32 *, size_t nval);<br>bool fwnode_property_present(const struct fwnode_handle *, const char *);</pre><ul><li><strong>device_property_*()</strong> variants take a struct device * and internally use dev_fwnode(dev) — the form drivers use most often.</li><li><strong>For ACPI</strong>, these dispatch into acpi_fwnode_ops → acpi_data_get_property() / acpi_data_prop_read(), which look the key up in the parsed _DSD package (§5.7) and coerce the value to the requested type.</li><li><strong>Child data nodes</strong> (hierarchical _DSD) are reached with fwnode_get_named_child_node() / fwnode_for_each_child_node(), mirroring how DT sub-nodes are traversed — so, e.g., per-port properties of a USB or MIPI device work identically across DT and ACPI.</li><li><strong>References</strong> (_DSD refs / DT phandles) are resolved with fwnode_property_get_reference_args() / fwnode_find_reference().</li></ul><h3>10.3 device_get_match_data()</h3><p>Drivers frequently attach per-model quirk data to each entry in their match table and retrieve it after binding. device_get_match_data() is the firmware-agnostic way to do so:</p><pre>const void *device_get_match_data(const struct device *dev);</pre><ul><li>For an <strong>ACPI-matched device</strong>, it returns the driver_data field of the matching struct acpi_device_id (found via acpi_match_device() -section 6.2).</li><li>For a <strong>DT-matched device</strong>, it returns the .data of the matching struct of_device_id (via of_match_device()).</li><li>The driver casts the returned pointer to its private quirk/config struct - one code path, both firmware types.</li></ul><p>Example:</p><pre>static const struct acpi_device_id my_acpi_ids[] = {<br>    { &quot;VEND0001&quot;, (kernel_ulong_t)&amp;config_gen1 },<br>    { &quot;VEND0002&quot;, (kernel_ulong_t)&amp;config_gen2 },<br>    { }<br>};<br>static int my_probe(struct platform_device *pdev)<br>{<br>    const struct my_config *cfg = device_get_match_data(&amp;pdev-&gt;dev);<br>    ...<br>}</pre><p>Together, fwnode + _DSD + device_get_match_data() are what allow the vast body of DT-oriented Linux drivers to run unmodified on ACPI platforms - the key portability story for ARM64 servers and modern x86 SoCs.</p><h3>11. Final sysfs Representation</h3><p>Once enumeration completes, the results are visible under /sys. A single ACPI device typically appears in <strong>two or more places:</strong> on the ACPI bus (the companion), and on whatever physical bus it was enumerated onto.</p><h3>11.1 /sys/bus/acpi/devices/</h3><p>The canonical listing of every acpi_device:</p><pre>/sys/bus/acpi/devices/<br>├── LNXSYSTM:00            # the \ root pseudo-device<br>├── LNXSYBUS:00            # \_SB<br>├── PNP0A08:00 -&gt; …        # PCI root bridge<br>├── PNP0C09:00             # embedded controller<br>├── PNP0C0C:00             # power button<br>├── ACPI0007:00 … :0f      # processors<br>├── device:00              # a HID-less _ADR device<br>└── …</pre><p>Each directory contains attributes derived from enumeration:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6795fe4da5f6a1ddb912944404edb1d2/href">https://medium.com/media/6795fe4da5f6a1ddb912944404edb1d2/href</a></iframe><p>modalias is what drives module autoloading: udev reads it and requests the module whose MODULE_DEVICE_TABLE(acpi, …) matches.</p><h3>11.2 /sys/bus/platform/devices/</h3><p>Devices that fell through to the platform handler (acpi_create_platform_device) appear here as well:</p><pre>/sys/bus/platform/devices/<br>├── INT33C2:00            # Intel LPSS UART, named by HID:instance<br>├── INT33FC:00            # SoC GPIO controller<br>└── …</pre><p>Each has a firmware_node symlink back to its /sys/bus/acpi/devices/… companion, resource (the _CRS-derived struct resource list), and driver (symlink to the bound platform_driver).</p><h3>11.3 /sys/bus/i2c/devices/</h3><p>I2C clients created by i2c_acpi_register_devices() (§9.2):</p><pre>/sys/bus/i2c/devices/<br>├── i2c-0                 # the adapter (from the ACPI-described controller)<br>├── 0-002c               # a client at address 0x2c on adapter 0<br>│   ├── firmware_node -&gt; …/ACPI…   # ACPI companion<br>│   ├── name<br>│   └── driver -&gt; …<br>└── …</pre><p>SPI devices appear analogously under /sys/bus/spi/devices/ (e.g. spi0.0).</p><h3>11.4 /sys/firmware/acpi/tables/</h3><p>The raw ACPI tables (independent of enumeration, but the ground truth everything derives from):</p><pre>/sys/firmware/acpi/tables/<br>├── DSDT                  # the differentiated table (binary AML)<br>├── FACP                  # FADT<br>├── APIC                  # MADT<br>├── SSDT1, SSDT2, …       # supplemental tables<br>├── SRAT, SLIT, HPET, GTDT, MCFG, …<br>└── dynamic/              # tables loaded at runtime via Load()/LoadTable()</pre><p>These can be dumped and decompiled: cp DSDT /tmp/dsdt.dat then iasl -d /tmp/dsdt.dat yields readable ASL. Also present: /sys/firmware/acpi/tables/data/ for data-only tables, and /sys/firmware/acpi/interrupts/ for per-GPE/fixed-event counters.</p><h3>11.5 /sys/class/thermal/</h3><p>Thermal zones registered by acpi_thermal_add() (§9.6):</p><pre>/sys/class/thermal/<br>├── thermal_zone0/<br>│   ├── temp              # current _TMP (millidegrees C)<br>│   ├── type              # zone name<br>│   ├── trip_point_0_temp # _CRT/_PSV/_ACx trip temps<br>│   ├── trip_point_0_type # critical / passive / active<br>│   ├── cdev0 -&gt; …        # bound cooling device (fan / processor)<br>│   └── policy            # governor<br>└── cooling_device0/      # e.g. a fan (from _ALx) or Processor (from _PSL)</pre><h3>11.6 Where else companions surface</h3><ul><li>/sys/devices/… - the true device hierarchy; ACPI and physical devices are interleaved by parent/child relationships.</li><li>/sys/bus/pci/devices/…/firmware_node- PCI functions link to their ACPI companion (for _DSM, power, hotplug).</li><li>/proc/acpi/ - mostly deprecated, a few legacy interfaces remain (e.g. wakeup).</li></ul><h3>12. Key Takeaways + Complete Call Graph</h3><h3>12.1 Key takeaways</h3><ol><li><strong>Enumeration bridges two object models.</strong> Namespace nodes (acpi_namespace_node) become struct acpi_devices become struct devices, and — for buses — spawn a <em>second</em> physical device linked as a companion.</li><li><strong>Five phases, one kickoff. </strong>acpi_scan_init() registers scan handlers then calls acpi_bus_scan(), which does a create pass (build device objects) and an attach pass (bind handlers/drivers), both depth-first.</li><li><strong>_STA gates existence.</strong> A device is created/attached only if present-or-functional; absent+non-functional subtrees are pruned.</li><li><strong>Identity drives matching.</strong> _HID first, then _CID list, compared by acpi_match_device_ids(); _UID/_ADR disambiguate instances and address companions.</li><li><strong>Scan handlers beat drivers.</strong> Subsystem scan handlers (PCI, processor, EC, memory, platform) get first refusal during enumeration; ordinary acpi_drivers are the fallback.</li><li><strong>_CRS → Linux resources</strong>. Interrupts go through acpi_register_gsi() (GSI→virq); memory/IO become struct resource; GPIO/I2C/SPI become connection descriptors resolved by their subsystems.</li><li><strong>_DEP orders probing. </strong>Explicit dependency edges defer a consumer until its suppliers (EC, GPIO, I2C controllers) clear their dependencies.</li><li><strong>fwnode + </strong><strong>_DSD = portability. </strong>DT-oriented drivers run unmodified on ACPI because properties and match-data are read through the firmware-agnostic fwnode/device_property_* API.</li></ol><h3>12.2 Complete call graph</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dtmp7A10gjhiqbDxIunHQ.png" /></figure><h3>12.3 One-line summary of the journey</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*CvH6dLWb5lNJa1WzgnNjCw.png" /></figure><p><strong>Note : </strong>drivers/acpi/scan.c, drivers/acpi/bus.c, drivers/acpi/resource.c, drivers/acpi/property.c, plus subsystem glue in drivers/pci, drivers/i2c, drivers/spi, drivers/gpio, etc. Function names track the mainline kernel (6.x); older trees differ in detail but not in shape.</p><h3>References</h3><p><strong>ACPI specification</strong></p><ol><li>ACPI Specifications (UEFI Forum) — <a href="https://uefi.org/acpi/specs">https://uefi.org/acpi/specs</a></li><li>ACPI Spec 6.4, full text (HTML) — <a href="https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/">https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/</a></li></ol><p><strong>ACPICA (reference AML interpreter, used directly by Linux)</strong><br> 3. ACPICA documentation &amp; user guide (Intel) — <a href="https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html">https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html</a><br> 4. ACPICA source (GitHub) — <a href="https://github.com/acpica/acpica">https://github.com/acpica/acpica</a></p><p><strong>Linux ACPI implementation</strong><br> 5. Linuxized ACPICA — how Linux syncs with upstream ACPICA — <a href="https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html">https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html</a><br> 6. Linux kernel ACPI driver-api docs — <a href="https://docs.kernel.org/driver-api/acpi/index.html">https://docs.kernel.org/driver-api/acpi/index.html</a><br> 7. Linux kernel source, drivers/acpi — <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi</a></p><p><strong>Windows internals</strong><br> 8. Windows Driver Kit — Kernel-Mode Driver Architecture — <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/">https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/</a><br> 9. Russinovich, Solomon, Ionescu — <em>Windows Internals</em>, Part 1 (7th ed.) — standard secondary source for undocumented boot/HAL routines like KiSystemStartup, HalInitSystem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5fdb252045b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows ACPI Initialization Pipeline - A Deep Dive]]></title>
            <link>https://medium.com/@kushaldps1996/windows-acpi-initialization-pipeline-a-deep-dive-41a3e63eb895?source=rss-20cb97d60801------2</link>
            <guid isPermaLink="false">https://medium.com/p/41a3e63eb895</guid>
            <dc:creator><![CDATA[KUSHAL CHAKRABORTY]]></dc:creator>
            <pubDate>Tue, 04 Aug 2026 19:00:53 GMT</pubDate>
            <atom:updated>2026-08-04T19:00:53.020Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Companion to the Linux ACPI initialization walkthrough, re-expressed for the Windows NT kernel (ntoskrnl.exe), the ACPI HAL (hal.dll), the ACPI bus/function driver (acpi.sys), and Microsoft&#39;s in-house AML interpreter (AMLI). Every Linux/ACPICA concept below has been mapped to its Windows counterpart.</blockquote><h3>Table of Contents</h3><ol><li>Introduction</li></ol><ul><li>The Windows ACPI initialization pipeline overview</li><li>AMLI vs. ACPICA — two independent implementations of one spec</li></ul><p>2. Boot Call Chain (KiSystemStartup → Phase1Initialization)</p><ul><li>Complete call graph</li><li>Which routines run in which order</li><li>What each phase accomplishes</li></ul><p>3. HAL Early Init — Firmware/Platform-Specific Bring-up</p><ul><li>HalInitSystem (Phase 0)</li><li>HalpAcpiTableCacheInit / the HAL ACPI table cache</li><li>HalAcpiGetTable</li></ul><p>4. RSDP → XSDT → Table Caching</p><ul><li>Loader-side discovery (winload)</li><li>HalpAcpiFindRsdp / HalpGetAcpiTable</li><li>FADT → DSDT + FACS location</li><li>The HAL ACPI table cache — the internal registry</li></ul><p>5. Early Table Parsing (HAL platform init)</p><ul><li>MADT (APIC/GIC) parsing</li><li>FADT parsing: SCI IRQ, PM timer, flags</li><li>GTDT parsing (ARM64): timer GSIVs</li><li>HPET parsing (x86): timer base</li></ul><p>6. NUMA Initialization (KeNumaInitialize / MmInitializeNuma)</p><ul><li>SRAT parsing: CPU + memory affinity</li><li>SLIT parsing: distance matrix</li><li>ARM64 GICC affinity</li></ul><p>7. acpi.sys Full Init - Namespace Construction</p><ul><li>DriverEntry → ACPIInitializeDDB</li><li>AMLI: AMLILoadDDB, DSDT/SSDT loading</li><li>_INI / _STA walk, device enumeration</li><li>Transition to ACPI mode (SCI_EN) and fixed/GPE events</li></ul><p>8. The ACPI Namespace Tree</p><ul><li>\, \_SB, \_TZ, \_PR, \_GPE, \_SI scopes</li><li>Viewing it: WinDbg !amli, registry, acpidump</li></ul><h3>1. Introduction</h3><h3>1.1 The Windows ACPI initialization pipeline - overview</h3><p>On Linux the ACPI machinery lives <em>inside</em> the monolithic kernel image and is brought up incrementally by start_kernel(). On Windows the same work is split across four cooperating binaries, each owning a distinct slice of the pipeline:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9af45c78d3eace80afdaf17ce2360949/href">https://medium.com/media/9af45c78d3eace80afdaf17ce2360949/href</a></iframe><p>The four binaries hand off in a strict sequence, each consuming the artifacts the previous stage produced:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*Knez3v85KBg_FlcQ4m2-Kg.png" /></figure><p>The essential difference from Linux <strong>is layering by responsibility, not by time</strong>:</p><ul><li>The <strong>HAL</strong> only ever touches the <em>fixed</em> hardware and the <em>static</em> tables it needs to make the box interrupt- and timer-capable. It contains no <strong>AML interpreter</strong>.</li><li>acpi.sys owns <em>everything AML - </em>the DSDT, SSDTs, the namespace, and the interpreter. It is a boot-start PnP driver that acts as the <strong>bus driver for the ACPI enumerated device tree and the function driver for the fixed-feature/embedded devices.</strong></li></ul><h3>1.2 AMLI vs. ACPICA - two independent implementations of one spec</h3><p>Linux (and most Unixes, plus firmware such as EDK2) share a single reference codebase called <strong>ACPICA</strong> (ACPI Component Architecture). Windows does not use ACPICA. Because Microsoft and Intel/Toshiba co-authored the ACPI specification, <strong>Windows ships its own, proprietary implementation</strong>:</p><ul><li><strong>AMLI :</strong> the <em>ACPI Machine Language Interpreter</em> : is the Windows analogue of ACPICA’s acpi_ex_* (executor) and acpi_ds_* (dispatcher) layers. It is statically linked into acpi.sys. Its public symbols are prefixed AMLI (e.g. AMLILoadDDB, AMLIEvalNameSpaceObject, AMLIAsyncEvalObject).</li><li>The <strong>namespace manager</strong> inside acpi.sys (functions prefixed NS, e.g. NSObj, node type NSOBJ) is the analogue of ACPICA&#39;s acpi_ns_* layer.</li><li>The <strong>table access layer </strong>is split: static tables via the <strong>HAL ACPI table cache</strong> (HalpAcpiGetTable*), and definition blocks (DSDT/SSDT) via <strong>AMLI DDB</strong> (Differentiated/Definition Block) loading.</li></ul><p>So the mental mapping is:</p><pre>ACPICA (Linux)                     Windows<br>------------------------------     ---------------------------------<br>acpi_tb_*  (tables)          --&gt;    HalpAcpiGetTable* + AMLI DDB loader<br>acpi_ns_*  (namespace)       --&gt;   acpi.sys NS* namespace manager<br>acpi_ex_/acpi_ds_* (interp)  --&gt;    AMLI interpreter (in acpi.sys)<br>acpi_ev_*  (events/GPE)      --&gt;    acpi.sys GPE/fixed-event engine<br>acpi_os_*  (OSL glue)        --&gt;   acpi.sys &lt;--&gt; ntoskrnl/HAL call-outs</pre><p><strong>Keep this table in mind</strong>: every Linux routine named in the original document maps to one of these Windows layers.</p><h3>2. Boot Call Chain (KiSystemStartup → Phase1Initialization)</h3><p>Where Linux funnels everything through start_kernel(), Windows uses a <strong>two-phase kernel initialization</strong> model, preceded by <strong>the OS loader</strong> (winload.efi) that has already done the low-level firmware discovery.</p><h3>2.1 Complete call graph</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rEyHg2n9_C8JNv3lBDy4lA.jpeg" /></figure><p>The same call chain as a flow diagram :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*5IzDJZgYLWYBAarjhfDwzg.png" /></figure><h3>2.2 Which routines run in which order</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ee3c9d2966db59adecb1022114c28d1/href">https://medium.com/media/7ee3c9d2966db59adecb1022114c28d1/href</a></iframe><h3>2.3 What each phase accomplishes</h3><ul><li><strong>Loader (</strong><strong>winload) :</strong> the equivalent of Linux&#39;s earliest RSDP scan. It is the <em>only</em> component that talks to UEFI firmware boot services for ACPI. It guarantees the kernel receives a <em>flat, already-copied</em> set of tables via the LOADER_PARAMETER_BLOCK, so the kernel/HAL never rescan low memory or the EFI config table themselves.</li><li><strong>HAL Phase 0 :</strong>makes the machine <em>minimally functional</em>: one CPU, a working interrupt controller, and a running clock. Parses only static tables.</li><li><strong>HAL Phase 1 :</strong> brings interrupts/clock fully online for SMP.</li><li><strong>Kernel Phase 1 (NUMA) :</strong> establishes memory topology before the memory manager finishes and before drivers load.</li><li><strong>acpi.sys :the big one:</strong> loads AML, builds the namespace, enters ACPI mode, and begins PnP enumeration of the \_SB tree.</li></ul><h3>3. HAL Early Init : Firmware/Platform-Specific Bring-up</h3><p>This is the Windows analogue of Linux’s setup_arch() - the architecture- and firmware-specific early init. On Windows it is concentrated in HalInitSystem and its helpers, driven twice (Phase 0 then Phase 1).</p><h3>3.1 HalInitSystem(Phase, LoaderBlock)</h3><p>HalInitSystem is the HAL&#39;s master entry point, called by KiInitializeKernel (Phase 0) and Phase1Initialization (Phase 1). Its ACPI responsibilities:</p><p><strong>Phase 0:</strong></p><ol><li>Save the LOADER_PARAMETER_BLOCK pointer (source of all cached ACPI tables).</li><li>Call HalpAcpiTableCacheInit to build the HAL&#39;s private table cache.</li><li>Locate and cache the <strong>FADT</strong> (&#39;FACP&#39; signature) - the root of all fixed-hardware description.</li><li>Determine the interrupt-controller model from the <strong>MADT</strong> (&#39;APIC&#39;) and program the local + I/O APIC (x86/x64) or the GIC distributor/redistributor (ARM64).</li><li>Establish the platform clock source (HPET on x86, generic timer via GTDT on ARM64, or the ACPI PM timer as fallback).</li></ol><p><strong>Phase 1:</strong></p><ol><li>Connect the clock interrupt and profile interrupt.</li><li>Bring the interrupt controller fully online for the boot processor and prepare for AP (application processor) start-up.</li></ol><blockquote><strong><em>Contrast with Linux:</em></strong><em> Linux’s </em><em>acpi_boot_table_init() + </em><em>acpi_table_init() merely </em>register<em> tables; the actual APIC/GIC programming happens later in </em><em>acpi_boot_init() and the IRQ-chip drivers. On Windows the HAL does discovery and programming together in </em><em>HalInitSystem, because the HAL is the interrupt-controller driver.</em></blockquote><h3>3.2 HalpAcpiTableCacheInit - the HAL ACPI table cache</h3><p>This routine is the Windows equivalent of ACPICA’s acpi_initialize_tables(): it constructs the in-memory registry of static ACPI tables. But instead of scanning physical memory for the RSDP (Linux acpi_find_root_pointer), it consumes tables the loader already copied into LoaderBlock-&gt;Extension-&gt;AcpiTable.</p><p><strong>Responsibilities:</strong></p><ul><li>Walk the loader-provided table set (rooted at the RSDP/XSDT copy).</li><li>Validate each table header (signature, length, checksum) - the analogue of ACPICA’s acpi_tb_validate_table.</li><li>Insert each into the HAL’s cache keyed by 4-byte signature.</li><li>Special-case the <strong>FADT</strong> to resolve the physical addresses of the <strong>DSDT</strong> (X_Dsdt/Dsdt field) and FACS (X_FirmwareCtrl/FirmwareCtrl field) - the analogue of ACPICA&#39;s acpi_tb_parse_fadt.</li></ul><p>The cache itself is the Windows analogue of ACPICA’s acpi_gbl_root_table_list[].</p><h3>3.3 HalAcpiGetTable / HalpAcpiGetTable</h3><p>The public accessor other kernel components and drivers use to retrieve a static table by signature:</p><pre>PVOID<br>HalAcpiGetTable (<br>    _In_ PLOADER_PARAMETER_BLOCK LoaderBlock,  // may be NULL post-boot<br>    _In_ ULONG                   Signature     // e.g. &#39;TEPH&#39; for &quot;HPET&quot;<br>    );</pre><ul><li>Returns a pointer to the cached, validated table (header + body).</li><li>Signature is passed as a little-endian ULONG; e.g. &quot;FACP&quot; is the FADT, &quot;APIC&quot; is the MADT, &quot;HPET&quot;, &quot;MCFG&quot;, &quot;SRAT&quot;, &quot;SLIT&quot;, &quot;GTDT&quot;.</li><li>This is the exact analogue of ACPICA’s acpi_get_table().</li></ul><p>acpi.sys uses its own copies for the AML tables, but for <em>static</em> tables (e.g. reading the FADT to learn the SCI vector or the PM1 register block) it calls back into the HAL through this interface.</p><h3>4. RSDP → XSDT → Table Caching</h3><p>This section maps the Linux <em>“find the root pointer, walk the XSDT, register each table”</em> flow onto Windows. The key structural difference: on Windows the <em>root pointer discovery</em> happens in the <strong>loader</strong>, not the kernel.</p><p>The end-to-end table-discovery-and-caching flow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*S8MO6SAr7a-pH1OF6gZUXA.png" /></figure><h3>4.1 Loader-side discovery (winload.efi)</h3><p>Linux’s acpi_find_root_pointer() searches the EBDA and the BIOS ROM area (0xE0000–0xFFFFF) for the &quot;RSD PTR &quot; signature, or on UEFI reads it from the EFI configuration table. Windows does the UEFI path <strong>exclusively</strong> (legacy BIOS boot of modern Windows is not supported on UEFI-class machines):</p><ol><li>winload iterates EFI_SYSTEM_TABLE-&gt;ConfigurationTable[].</li><li>It matches the vendor GUID against:</li></ol><ul><li>ACPI_20_TABLE_GUID (8868E871-E4F1-11D3-BC22-0080C73C8881) : RSDP v2 (preferred, gives the 64-bit XSDT).</li><li>ACPI_TABLE_GUID (EB9D2D30-2D88-11D3-9A16-0090273FC14D) : RSDP v1 (32-bit RSDT fallback).</li></ul><p>3. It validates the RSDP checksum (first 20 bytes for v1; full length for v2).</p><p>4. It follows the XSDT (or RSDT) and copies every referenced table, plus the DSDT and FACS reached via the FADT, into loader-allocated memory.</p><p>5. It records them in LOADER_PARAMETER_BLOCK.Extension-&gt;AcpiTable and mirrors them into the registry (see section 8.3).</p><h3>4.2 HalpAcpiFindRsdp / HalpGetAcpiTable</h3><p>Even though the loader has done the discovery, the HAL retains routines to locate the RSDP again in certain scenarios (e.g. resuming, or when the loader block is unavailable):</p><ul><li>HalpAcpiFindRsdp:obtains the RSDP. It prefers the value stashed by the loader (from UEFI); on legacy paths it can scan physical memory. This is the functional analogue of ACPICA&#39;s acpi_find_root_pointer().</li><li>HalpGetAcpiTable : given the XSDT/RSDT, retrieves and validates a table by signature, mapping it if necessary. Analogue of ACPICA&#39;s acpi_tb_parse_root_table() + acpi_tb_install_standard_table() combined.</li></ul><h3>4.3 XSDT walk and table registration</h3><p>The walk mirrors ACPICA’s acpi_tb_parse_root_table():</p><ol><li>Read the XSDT header; compute the entry count from (Length - sizeof(header)) / 8 (8-byte physical pointers; RSDT uses 4).</li><li>For each 64-bit entry, map the pointed-to table header.</li><li>Validate signature + length + checksum (mostly acpi_tb_validate_table / acpi_tb_verify_checksum).</li><li>Install into the HAL cache (mostly acpi_tb_install_standard_table).</li><li><strong>Note duplicates:</strong> multiple SSDT entries are all retained (they will be merged into the namespace later, exactly as on Linux).</li></ol><h3>4.4 FADT → DSDT + FACS location</h3><p>The <strong>FADT</strong> (signature &#39;FACP&#39;) is special — it is the only table that points to two others by physical address rather than via the XSDT:</p><ul><li>Dsdt (32-bit) / X_Dsdt (64-bit) → the Differentiated System Description Table (the primary AML block).</li><li>FirmwareCtrl (32-bit) / X_FirmwareCtrl (64-bit) → the FACS (Firmware ACPI Control Structure - holds the waking vector and the global lock).</li></ul><p>Windows resolves these when caching the FADT (in HalpAcpiTableCacheInit), the direct analogue of ACPICA&#39;s acpi_tb_parse_fadt(). The DSDT physical address is later handed to acpi.sys, which maps and loads it via AMLI.</p><p>The FADT also yields the fields the HAL needs immediately:</p><ul><li><strong>SCI_INT:</strong> the System Control Interrupt GSI (the ACPI event interrupt).</li><li><strong>PM1a/PM1b</strong> event &amp; control block addresses.</li><li><strong>PM_TMR_BLK :</strong> the ACPI power-management timer (fallback clock source).</li><li><strong>GPE0/GPE1</strong> block addresses.</li><li><strong>SMI_CMD / ACPI_ENABLE / ACPI_DISABLE</strong> : the port + values used to request ACPI mode from the firmware (see section 7.4).</li><li><strong>Flags</strong> (e.g. WBINVD, PWR_BUTTON, SLP_BUTTON, HW_REDUCED_ACPI).</li></ul><h3>4.5 The HAL ACPI table cache - the internal registry</h3><p>The Windows analogue of Linux’s acpi_gbl_root_table_list[] is the HAL&#39;s internal cache built in section 3.2. Properties:</p><ul><li>Keyed by 4-byte signature (with special handling for repeated SSDTs).</li><li>Stores validated pointers into loader-copied memory (persistent for the OS lifetime — not unmapped after boot, unlike some early Linux mappings).</li><li>Queried through HalAcpiGetTable by any component: the kernel (NUMA), the HAL itself (timers/interrupts), and acpi.sys (fixed-register discovery).</li><li>There is no early/late “table override” mechanism exposed to users the way Linux offers acpi= initrd table overrides; Windows table customization is limited (test-signing / debug policies only).</li></ul><h3>5. Early Table Parsing (HAL platform init)</h3><p>This is the analogue of Linux’s acpi_boot_init() - parsing the <em>static</em> interrupt/timer tables. On Windows it happens inside HalInitSystem / HalpInitializePlatform and their per-architecture helpers. No AML is involved; these are pure table walks.</p><h3>5.1 MADT / APIC parsing</h3><p>The MADT (Multiple APIC Description Table, signature &#39;APIC&#39;) describes every interrupt controller. The HAL retrieves it via HalAcpiGetTable(&#39;APIC&#39;) and walks the variable-length list of subtable entries (each with a type byte + length), just like Linux&#39;s acpi_parse_madt() + acpi_table_parse_madt().</p><p>The MADT walk dispatches on the architecture and the per-entry type byte:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p_EUzSTBKtJttCHutq0qbw.png" /></figure><p><strong>x86/x64 entry types the HAL consumes:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2135eb101418290a2feef4cb0725a2d7/href">https://medium.com/media/2135eb101418290a2feef4cb0725a2d7/href</a></iframe><p>The HAL uses the MADT.Flags <strong>PCAT_COMPAT</strong> bit to decide whether legacy 8259 PICs are present and must be masked when switching to APIC mode.</p><p>ARM64 entry types (GIC):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1bfec8f7fc4581ca3949f27563b262de/href">https://medium.com/media/1bfec8f7fc4581ca3949f27563b262de/href</a></iframe><h3>5.2 FADT parsing (fixed-hardware feature flags)</h3><p>Already cached in section 4.4; here the HAL <em>acts</em> on it:</p><ul><li><strong>SCI_INT</strong> : the GSI the HAL will later hand to acpi.sys for the System Control Interrupt (the source of all GPE + fixed-button events).</li><li><strong>PM1a/PM1b register blocks</strong> : used to enter ACPI mode and, later, for the power button / wake logic.</li><li><strong>PM_TMR_BLK :</strong> the 24/32-bit PM timer used as a calibration/fallback clock.</li><li><strong>Flags/</strong><strong>IAPC_BOOT_ARCH:</strong> tells the HAL whether an 8042 keyboard controller / VGA / legacy devices exist (LEGACY_DEVICES, 8042).</li><li><strong>HW_REDUCED_ACPI flag :</strong> on reduced-hardware platforms (common on ARM64), there is no PM1/GPE register model or SMI-based mode switch; events come purely through GPIO/_AEI and the SCI. The HAL/acpi.sys take the hardware-reduced code path (analogue of Linux&#39;s acpi_gbl_reduced_hardware).</li></ul><h3>5.3 GTDT parsing (ARM64) - timer GSIVs</h3><p>The <strong>GTDT</strong> (Generic Timer Description Table, signature &#39;GTDT&#39;) is the ARM64 equivalent of the x86 HPET table. The HAL reads it via HalAcpiGetTable(&#39;GTDT&#39;) to learn:</p><ul><li>The <strong>secure/non-secure EL1</strong> physical timer GSIVs and flags.</li><li>The <strong>virtual timer</strong> GSIV.</li><li>The <strong>EL2 (hypervisor)</strong> timer GSIV.</li><li>Optional <strong>memory-mapped generic timer</strong> (GT block) and <strong>watchdog</strong> (SBSA/SBSA-W) descriptors.</li></ul><p>This is the analogue of Linux’s acpi_gtdt_init() / arch_timer_acpi_init(). The HAL programs the ARM generic timer and connects its per-CPU PPI so KeQueryPerformanceCounter and the scheduler tick work.</p><h3>5.4 HPET parsing (x86) - timer base address</h3><p>The <strong>HPET</strong> table (signature &#39;HPET&#39;) gives the base MMIO address of the High-Precision Event Timer. The HAL (HalpHpetTimerInit / platform timer selection) reads it via HalAcpiGetTable(&#39;HPET&#39;) and:</p><ul><li>Maps the HPET register block.</li><li>Reads the capabilities register (counter width, number of comparators, femtosecond period).</li><li>Decides between HPET, the invariant TSC, and the PM timer as the system clock source (Windows’ clock-source selection is the analogue of Linux’s clocksource registration, but is HAL-internal and not user-selectable at the granularity Linux exposes).</li></ul><p>This is the analogue of Linux’s acpi_hpet_init() / hpet_enable().</p><h3>6. NUMA Initialization (KeNumaInitialize / MmInitializeNuma)</h3><p>This maps Linux’s acpi_numa_init(). On Windows it runs during Phase1Initialization, before the memory manager finalizes its node data structures. The kernel reads the SRAT and SLIT through the HAL table cache.</p><p>The NUMA build sequence — SRAT establishes nodes, SLIT fills distances:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*scZqQ_Sk4-Y29x9oDukrQA.png" /></figure><h3>6.1 SRAT parsing - CPU + memory affinity</h3><p>The <strong>SRAT</strong> (System Resource Affinity Table, signature &#39;SRAT&#39;) associates processors and memory ranges with proximity domains (Windows calls these NUMA nodes). The kernel (KeNumaInitialize → HalpGetProximityId and MmInitializeNuma) walks its subtable entries:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f56c659d61ce4344e1d78365c2c84285/href">https://medium.com/media/f56c659d61ce4344e1d78365c2c84285/href</a></iframe><p>Windows builds an <strong>internal proximity-domain → node-number</strong> table (proximity domain IDs from firmware are not necessarily contiguous, so they are renumbered, exactly as Linux does with pxm_to_node()).</p><h3>6.2 SLIT parsing - the distance matrix</h3><p>The <strong>SLIT</strong> (System Locality Information Table, signature &#39;SLIT&#39;) is an N × N byte matrix of relative distances between localities. Value 10 (0x0A) means &quot;local&quot; (a node to itself), higher values mean progressively farther.</p><p>Windows reads the SLIT and populates its node-distance data used by:</p><ul><li>The memory manager for <strong>node-local allocation</strong> preferences.</li><li>The scheduler for <strong>ideal-node / soft-affinity</strong> decisions.</li><li>KeQueryLogicalProcessorRelationship / GetLogicalProcessorInformationEx (the API surface that exposes NUMA distances to user mode - the analogue of Linux&#39;s /sys/devices/system/node/nodeX/distance).</li></ul><p>If the SLIT is missing or malformed, Windows synthesizes a default matrix (local = 10, remote = 20), mirroring Linux’s fallback in slit_valid().</p><h3>6.3 ARM64 GICC affinity entries</h3><p>On ARM64 there are no APIC IDs; processors are identified by <strong>MPIDR</strong> via the SRAT <strong>GICC Affinity</strong> (type 3) entries, which carry an <em>ACPI Processor UID</em> that cross-references the MADT GICC entry (§5.1). Windows correlates the two so each logical processor is bound to the correct proximity domain. This is the direct analogue of Linux’s acpi_parse_gicc_affinity() + acpi_map_pxm_to_node().</p><h3>6.4 How the distance matrix is built (conceptually)</h3><p>Where Linux calls numa_set_distance(from, to, distance) for each SLIT cell, Windows performs the equivalent internally:</p><ol><li>Enumerate proximity domains from SRAT → assign compact node numbers.</li><li>Allocate the node_count × node_count distance array.</li><li>Fill it from SLIT (or the 10/20 default).</li><li>Register each node’s CPU set and memory ranges with Mm.</li><li>Expose the result through the KeNodeBlock[] array and the <strong>processor-group</strong> topology (Windows also layers processor groups - up to 64 logical CPUs per group - on top of NUMA nodes, a concept Linux lacks).</li></ol><h3>7. acpi.sys Full Init : Namespace Construction</h3><p>This is the Windows analogue of Linux’s acpi_early_init() + acpi_init()- the phase where the <strong>AML interpreter</strong> comes alive, the <strong>DSDT/SSDTs</strong> are loaded, and the namespace is built and enumerated. On Windows this is the job of the boot-start driver acpi.sys and its embedded interpreter <strong>AMLI</strong>.</p><p>acpi.sys is loaded by IoInitSystem very early (its Start value is SERVICE_BOOT_START and its group is <em>&quot;Boot Bus Extender&quot;</em>, so it precedes almost every other driver). It plays two roles at once:</p><ul><li><strong>Bus/FDO driver</strong> for the ACPI namespace device tree (it owns the PDOs for every \_SB device and hands them to PnP).</li><li><strong>Function driver</strong> for fixed features (power button, thermal zones, etc.).</li></ul><p>The full acpi.sys bring-up, from DriverEntry to a populated PnP tree:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*84pVA2uo4sqfsmO8XabEaQ.png" /></figure><h3>7.1 DriverEntry → ACPIInitializeDDB</h3><p>acpi.sys!DriverEntry:</p><ol><li>Sets up the driver object dispatch table (IRP_MJ_PNP, IRP_MJ_POWER, IRP_MJ_SYSTEM_CONTROL, etc.).</li><li>Initializes the AMLI interpreter globals and the namespace root.</li><li>Calls the DDB (Definition Block) loader to bring in the AML tables.</li></ol><p>The root of the namespace - the \ node - is created here, the analogue of ACPICA&#39;s acpi_ns_root_initialize(). Windows pre-populates the predefined root objects (\_GPE, \_PR, \_SB, \_SI, \_TZ, and the predefined names \_OS, \_OSI, \_REV, \_GL) just as ACPICA does.</p><h3>7.2 AMLI subsystem init : the analogue of acpi_initialize_subsystem()</h3><p>Linux’s acpi_initialize_subsystem() decomposes into:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a2741771d6986d2d7dc82eb70b551380/href">https://medium.com/media/a2741771d6986d2d7dc82eb70b551380/href</a></iframe><p>The predefined \_OSI method deserves special mention: Windows&#39; _OSI implementation is what firmware queries to detect the running Windows version (e.g. &quot;Windows 2020&quot;, &quot;Windows 2022&quot;). This is the analogue of Linux answering _OSI(&quot;Linux&quot;)/_OSI(&quot;Windows …&quot;) - except Windows <em>is</em> the string firmware writers target, so its _OSI return set is the de-facto standard.</p><h3>7.3 AMLILoadDDB : the analogue of acpi_load_tables()</h3><p><strong>DDB</strong> = Definition Block (a DSDT or SSDT). AMLI’s AMLILoadDDB is the direct analogue of ACPICA&#39;s acpi_tb_load_namespace() + acpi_ns_load_table():</p><ol><li><strong>DSDT load</strong> : acpi.sys obtains the DSDT physical address (resolved from the FADT in section 4.4), maps it, and calls AMLILoadDDB on it. AMLI parses the AML byte-code:</li></ol><ul><li><strong>Pass 1:</strong> a structural pass that creates namespace nodes for every named object (Device, Method, Name, OperationRegion, Mutex, Processor, ThermalZone, Scope, etc.) without executing method bodies. Analogue of ACPICA&#39;s <em>load pass 1</em>.</li><li><strong>Pass 2 :</strong> resolves forward references and evaluates package/argument expressions needed at load time. Analogue of ACPICA’s <em>load pass 2</em>.</li></ul><p>2. <strong>SSDT merge :</strong> each SSDT found in the XSDT is loaded with AMLILoadDDB in turn; its objects are merged into the <em>same</em> namespace (SSDTs may add scopes like \_SB.PCI0 device methods, _PSS/_CST processor tables, etc.). This is the analogue of Linux&#39;s SSDT merging in acpi_tb_load_namespace().</p><p>3. <strong>Dynamic SSDTs</strong> : AML Load/LoadTable operators can pull in additional SSDTs at runtime; AMLI handles these through the same AMLILoadDDB path, exactly as ACPICA does via acpi_ex_load_op.</p><p>After this, the <strong>complete namespace exists in memory</strong> but device methods have not yet been run.</p><h3>7.4 Entering ACPI mode : the analogue of acpi_enable_subsystem()</h3><p>Linux’s acpi_enable_subsystem() sets the SCI_EN bit and installs fixed-event handlers. Windows does the equivalent, split between the HAL and acpi.sys:</p><ol><li><strong>Hardware-full platforms (x86):</strong> acpi.sys (via the HAL) writes ACPI_ENABLE to the SMI_CMD port (both values from the FADT, section 4.4). It then polls the PM1 control register until the SCI_EN bit reads 1, confirming firmware has handed hardware control from SMM/legacy to the OS. This is the exact analogue of ACPICA&#39;s acpi_hw_set_mode + acpi_enable().</li><li><strong>Hardware-reduced platforms (ARM64, </strong><strong>HW_REDUCED_ACPI set):</strong> there is no SMI_CMD / SCI_EN handshake - the system is <em>always</em> in ACPI mode. This step is skipped, mirroring ACPICA&#39;s reduced-hardware branch.</li><li><strong>SCI connection: </strong>acpi.sys connects an interrupt object to the SCI GSI (from FADT SCI_INT, section 4.4/ section 5.2) so it receives GPE and fixed events. This is the analogue of ACPICA installing the SCI handler (acpi_ev_install_sci_handler).</li><li><strong>Fixed-event handlers:</strong> handlers for the power button, sleep button, and RTC/wake fixed events are installed - analogue of acpi_ev_fixed_event_initialize / acpi_install_fixed_event_handler.</li><li><strong>GPE (General Purpose Event) init:</strong> acpi.sys walks the \_GPE scope, enumerates the _Lxx/_Exx GPE handler methods and any _PRW (power resources for wake) declarations, and enables the appropriate GPE bits - analogue of ACPICA&#39;s acpi_ev_gpe_initialize + acpi_update_all_gpes.</li></ol><h3>7.5 Device enumeration : _INI / _STA walk (the analogue of acpi_scan_init())</h3><p>Once the namespace is built and ACPI mode is on, acpi.sys enumerates the device tree. This corresponds to Linux&#39;s acpi_scan_init() + acpi_bus_scan():</p><ol><li>Starting at \_SB (the system bus scope), acpi.sys walks every Device node.</li><li>For each device it evaluates _STA (status): bit 0 = present, bit 1 = enabled, bit 3 = functioning. This is the analogue of acpi_bus_get_status.</li><li>It runs _INI on devices that are present, in namespace order (parent before child), matching the ACPI-spec-mandated _INI ordering that ACPICA implements in acpi_ns_initialize_devices / acpi_ev_initialize_op_regions.</li><li>It evaluates _HID/_CID/_ADR/_UID to build a PnP device ID for each device (e.g. ACPI\PNP0A08 for a PCIe host bridge), then creates a PDO and reports it to the PnP manager. This is where the ACPI namespace fuses into the Windows PnP device tree - a step Linux performs by creating struct acpi_device and glue platform_devices.</li><li>It evaluates resource methods _CRS (current resources), _PRS (possible resources) and honors _SRS (set resources) for resource arbitration - feeding the PnP resource arbiters. Analogue of Linux&#39;s acpi_dev_get_resources() / acpi_walk_resources().</li><li>Power (_PSx, _PRx, _PS0–_PS3) and wake (_PRW) methods are recorded for later power-management IRPs.</li></ol><p>At the end of this walk the machine has a fully populated PnP tree rooted at \Device\ACPI..., and normal driver loading proceeds (each PDO gets its function driver matched by hardware ID).</p><h3>8. The ACPI Namespace Tree</h3><h3>8.1 What it looks like after DSDT + SSDTs are loaded</h3><p>The namespace acpi.sys/AMLI builds is identical in <em>shape</em> to the one ACPICA builds on Linux — because both derive from the same DSDT/SSDT AML. It is a tree of named nodes rooted at \:</p><pre>\                                   (root)<br>├─ _GL                              (Global Lock mutex)<br>├─ _OSI / _OS / _REV               (predefined query objects)<br>├─ _PIC                            (method: pick PIC vs APIC interrupt model)<br>├─ _SB_                            (System Bus — the device tree root)<br>│   ├─ PCI0  (Device, _HID PNP0A08)<br>│   │   ├─ _CRS / _PRS / _SRS      (bus resources)<br>│   │   ├─ _PRT                    (PCI interrupt routing table)<br>│   │   ├─ SBRG / LPCB …           (bridges)<br>│   │   └─ … PCI functions with _ADR …<br>│   ├─ LNKA…LNKD (Device, PNP0C0F) (PCI interrupt link devices)<br>│   └─ … embedded controller, GPIO, I2C, UART devices …<br>├─ _TZ_                            (Thermal Zones)<br>│   └─ THRM (ThermalZone)<br>│       ├─ _TMP  (current temperature)<br>│       ├─ _AC0/_AL0 (active cooling trip + fan list)<br>│       ├─ _PSV / _CRT (passive / critical trip points)<br>│       └─ _SCP / _TSP …<br>├─ _PR_  (or Processor objects in _SB on modern tables)<br>│   └─ CPU0…CPUn (Processor / Device _HID ACPI0007)<br>│       ├─ _CST  (C-states)<br>│       ├─ _PSS/_PCT/_PPC (P-states)<br>│       └─ _PDC/_OSC (OS-directed cfg handshake)<br>├─ _GPE                            (General Purpose Event handlers)<br>│   ├─ _L01, _E02 …                (level/edge GPE methods)<br>│   └─ _Lxx wake handlers<br>└─ _SI_                            (System Indicators)<br>    └─ _SST / _MSG</pre><h3>8.2 The standard scopes</h3><ul><li><strong>\ (root) :</strong> top of the tree; holds predefined query objects and the global lock. Analogue of ACPICA&#39;s root node.</li><li><strong>\_SB (System Bus):</strong> parent of every enumerable device. This is what acpi.sys walks to build the PnP tree. Analogue of Linux&#39;s scan starting point.</li><li><strong>\_TZ (Thermal Zones) : </strong>thermal zone objects and their trip points/cooling methods. Windows&#39; thermal management (via acpi.sys + thermal policy) consumes these. Analogue of the Linux thermal + acpi_thermal drivers reading the same objects.</li><li><strong>\_PR (Processors): </strong>the legacy container for Processor objects (power/performance-state methods). Modern tables instead declare processors as Devices with _HID ACPI0007 directly under \_SB. Windows&#39; intelppm.sys/amdppm.sys/processr.sys consume _CST/_PSS. Analogue of Linux&#39;s acpi-cpufreq / processor driver.</li><li><strong>\_GPE :</strong> the GPE handler scope (_Lxx/_Exx methods). Analogue of ACPICA&#39;s GPE block handling.</li><li><strong>\_SI:</strong>system indicators (status LEDs, etc.).</li></ul><h3>8.3 How to view the namespace (Windows equivalents of /sys/firmware/acpi)</h3><p>Windows has no /sys/firmware/acpi/namespace pseudo-filesystem. The equivalent inspection methods are:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/832290000b63f5f57437116be12e268c/href">https://medium.com/media/832290000b63f5f57437116be12e268c/href</a></iframe><p>The single <strong>most useful tool is WinDbg’s</strong> !amli extension (from kdexts/acpiex), which is the direct counterpart of walking Linux&#39;s /sys/firmware/acpi/namespace: it can dump the tree, show node types (NSOBJ), and even evaluate methods against the live interpreter.</p><h3>Appendix A - Binary/Component Cheat-Sheet</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bd994e3ba6299cadfeaec1c7de560e5/href">https://medium.com/media/4bd994e3ba6299cadfeaec1c7de560e5/href</a></iframe><h3>Appendix B - Key Structures</h3><ul><li>LOADER_PARAMETER_BLOCK / LOADER_PARAMETER_EXTENSION:the handoff from winload to the kernel; its AcpiTable/AcpiTableSize fields carry the copied ACPI tables. Analogue of Linux passing acpi_rsdp via boot params / EFI.</li><li>AMLI NSOBJ (namespace object) : one node in the namespace tree; carries the 4-char name, object type, and value. Analogue of ACPICA&#39;s struct acpi_namespace_node.</li><li>AMLI DDB handle : represents a loaded definition block; used to unload dynamic SSDTs. Analogue of an ACPICA table index/acpi_table_desc.</li><li>DEVICE_EXTENSION (acpi.sys) :per-device state linking an NSOBJ to its PnP PDO. Analogue of struct acpi_device.</li></ul><h3>Appendix C - Reduced-Hardware (ARM64) Notes</h3><p>On hardware-reduced ACPI platforms (FADT HW_REDUCED_ACPI set - the common ARM64 case):</p><ul><li>No legacy PM1/PM2/PM timer register model as the <em>primary</em> event source; events arrive via the SCI + GPIO-signaled interrupts (_AEI, GpioInt resources) and Event/Notify AML.</li><li>No SMI_CMD/SCI_EN handshake - the system boots already in ACPI mode, so section 7.4 step 1 is skipped.</li><li>Sleep is expressed via the Sleep Control/Status registers (FADT SLEEP_CONTROL_REG/SLEEP_STATUS_REG) rather than PM1 SLP_TYP.</li><li>The generic timer (GTDT, section 5.3) replaces HPET/PM timer entirely.</li><li>CPU idle/perf come from LPI (_LPI, low-power idle states) and, if present, CPPC (_CPC) rather than the classic _CST/_PSS model.</li></ul><p><strong>Note : </strong>Windows reference: <em>acpi.sys</em> (the ACPI bus/function driver + AMLI interpreter), the PnP manager and I/O manager inside <em>ntoskrnl.exe</em>, the resource arbiters, and subsystem class extensions (<em>pci.sys</em>, <em>SpbCx</em>, <em>GpioClx</em>, <em>msft</em> inbox drivers). Because Windows ACPI internals are largely undocumented, private/internal routine names (prefixed <em>ACPI</em>) reflect reverse-engineering and WDK/debugger symbol conventions; the architecture and the documented DDIs (IRPs, <em>DEVICE_RELATIONS</em>, <em>CM_RESOURCE_LIST</em>, <em>DEVPROPKEY</em>) are firm.</p><h3>References</h3><p><strong>ACPI specification</strong></p><ol><li>ACPI Specifications (UEFI Forum) — <a href="https://uefi.org/acpi/specs">https://uefi.org/acpi/specs</a></li><li>ACPI Spec 6.4, full text (HTML) — <a href="https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/">https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/</a></li></ol><p><strong>ACPICA (reference AML interpreter, used directly by Linux)</strong><br> 3. ACPICA documentation &amp; user guide (Intel) — <a href="https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html">https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html</a><br> 4. ACPICA source (GitHub) — <a href="https://github.com/acpica/acpica">https://github.com/acpica/acpica</a></p><p><strong>Linux ACPI implementation</strong><br> 5. Linuxized ACPICA — how Linux syncs with upstream ACPICA — <a href="https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html">https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html</a><br> 6. Linux kernel ACPI driver-api docs — <a href="https://docs.kernel.org/driver-api/acpi/index.html">https://docs.kernel.org/driver-api/acpi/index.html</a><br> 7. Linux kernel source, drivers/acpi — <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi</a></p><p><strong>Windows internals</strong><br> 8. Windows Driver Kit — Kernel-Mode Driver Architecture — <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/">https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/</a><br> 9. Russinovich, Solomon, Ionescu — <em>Windows Internals</em>, Part 1 (7th ed.) — standard secondary source for undocumented boot/HAL routines like KiSystemStartup, HalInitSystem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41a3e63eb895" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Linux Kernel ACPI Initialization Pipeline - start_kernel() to Namespace]]></title>
            <link>https://medium.com/@kushaldps1996/the-linux-kernel-acpi-initialization-pipeline-start-kernel-to-namespace-379984111d05?source=rss-20cb97d60801------2</link>
            <guid isPermaLink="false">https://medium.com/p/379984111d05</guid>
            <dc:creator><![CDATA[KUSHAL CHAKRABORTY]]></dc:creator>
            <pubDate>Tue, 04 Aug 2026 19:00:27 GMT</pubDate>
            <atom:updated>2026-08-04T19:00:27.589Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>A deep dive into how the Linux kernel initializes ACPI after the RSDP has been located: the exact call chain from start_kernel() through setup_arch(), ACPICA table installation, early table parsing (MADT/FADT/GTDT/HPET), NUMA (SRAT/SLIT), full ACPICA bring-up (acpi_early_init → subsystem + namespace), and the resulting ACPI namespace tree.</blockquote><blockquote>This is the sequel to the RSDP-discovery document. Where that one ended at “Linux has the RSDP physical address,” this one traces every function that turns that pointer into a live, walkable ACPI namespace driving device enumeration.</blockquote><blockquote>Applies to x86_64 and ARM64 (arm64). Function names, files, and flow reflect the mainline kernel (drivers/acpi/, drivers/acpi/acpica/, arch/*/kernel/). Line-level details vary by version; the structure is stable across modern trees.</blockquote><h3>Table of Contents</h3><ol><li><a href="https://gist.github.com/kushaldps1996-debug/348fae44ef59f7de35f90baf14446250#1-introduction">Introduction</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/348fae44ef59f7de35f90baf14446250#2-start_kernel-acpi-call-chain">start_kernel() ACPI Call Chain</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/348fae44ef59f7de35f90baf14446250#3-setup_arch--architecture-specific-early-init">setup_arch() - Architecture-Specific Early Init</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/348fae44ef59f7de35f90baf14446250#4-rsdp--xsdt--table-registration">RSDP → XSDT → Table Registration</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/348fae44ef59f7de35f90baf14446250#5-early-table-parsing-acpi_boot_init">Early Table Parsing (acpi_boot_init)</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/348fae44ef59f7de35f90baf14446250#6-numa-initialization-acpi_numa_init">NUMA Initialization (acpi_numa_init)</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/348fae44ef59f7de35f90baf14446250#7-acpica-full-init-acpi_early_init">ACPICA Full Init (acpi_early_init)</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/348fae44ef59f7de35f90baf14446250#8-the-acpi-namespace-tree">The ACPI Namespace Tree</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/348fae44ef59f7de35f90baf14446250#9-key-functions-reference-table">Key Functions Reference Table</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/348fae44ef59f7de35f90baf14446250#10-key-takeaways">Key Takeaways</a></li></ol><h3>1. Introduction</h3><h3>1.1 The Linux ACPI initialization pipeline overview</h3><p>ACPI initialization in Linux is not a single step - it is spread deliberately across the boot timeline because different pieces of the kernel need different ACPI data at different times:</p><ul><li><strong>The memory manager and SMP/interrupt setup</strong> need the <em>static</em> tables (MADT, SRAT, GTDT/HPET) <strong>very early</strong>, before the full ACPICA subsystem and the AML interpreter are even initialized. So Linux does a first pass that only <em>maps and linearly parses</em> those fixed-format tables.</li><li><strong>The AML interpreter, namespace, and device enumeration</strong> need the <em>dynamic</em> tables (DSDT, SSDTs) and a working OS-services layer, memory allocators, and interrupt handling. That comes later, once the kernel is far enough along.</li></ul><p>So there are effectively three tiers of ACPI init:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/232e9d937b780066fe347f1f97ded348/href">https://medium.com/media/232e9d937b780066fe347f1f97ded348/href</a></iframe><p>The elegance is that Tier 1/2 need only the <em>table</em> code (acpi_initialize_tables() + acpi_table_parse*()), which is why <strong>ACPICA</strong> exposes a &quot;tables only&quot; initialization mode that runs before the rest of the subsystem exists.</p><h3>1.2 ACPICA - the shared implementation</h3><p>Linux does not hand-write an ACPI parser. It embeds <strong>ACPICA</strong> (ACPI Component Architecture), Intel’s reference implementation, under drivers/acpi/acpica/. ACPICA provides:</p><ul><li><strong>Table management </strong>(tb*.c) : RSDP/XSDT parsing, table install/validate, acpi_gbl_root_table_list.</li><li><strong>Namespace</strong> (ns*.c) : the \-rooted tree of ACPI objects.</li><li><strong>AML interpreter</strong> (ex*.c, ds*.c, ps*.c) : parses and executes bytecode (control methods, OperationRegion accesses).</li><li><strong>Events/GPE </strong>(ev*.c) : fixed events, General Purpose Events.</li><li><strong>Hardware</strong> (hw*.c) : register access, sleep, ACPI enable.</li><li><strong>Utilities</strong> (ut*.c) : globals, allocation wrappers, mutexes.</li><li><strong>Resources</strong> (rs*.c) : _CRS/_PRS/_SRS resource parsing.</li></ul><p>ACPICA is <strong>OS-agnostic</strong>; it talks to the host through the <strong>OS Services Layer</strong> (OSL), which Linux implements in drivers/acpi/osl.c (functions prefixed acpi_os_*: acpi_os_map_memory, acpi_os_allocate, acpi_os_install_interrupt_handler, acpi_os_read_port, etc.).</p><p>ACPICA calls “<strong>up”</strong> into these; Linux calls “<strong>down”</strong> into ACPICA via the acpi_* public API (acpi_initialize_tables, acpi_load_tables, acpi_enable_subsystem, acpi_get_table, acpi_walk_namespace, …).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KvZHRyrN6-J0D2s9vV7WBA.jpeg" /></figure><h3>2.1 Complete call graph diagram</h3><p>start_kernel() (in init/main.c) is the architecture-independent kernel entry after the arch head code. The ACPI-relevant calls, in order:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*qxY7c0eT6Hy3GL-jsItXHQ.jpeg" /></figure><blockquote><strong><em>[arm64 note]</em></strong><em> On arm64 there is no </em><em>acpi_boot_init() by that name; the equivalent early MADT/GTDT parsing is driven from </em><em>setup_arch()-&gt; </em><em>acpi_boot_table_init() and from the interrupt-controller / timer init paths (</em><em>irqchip/</em><em>arch_timer) which call </em><em>acpi_table_parse_madt() and </em><em>acpi_gtdt_init().</em></blockquote><h3>2.2 Which functions run in which order</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/200f0ce3aa5d77e9c78ede2ffb5cdc41/href">https://medium.com/media/200f0ce3aa5d77e9c78ede2ffb5cdc41/href</a></iframe><h3>2.3 What each phase accomplishes</h3><ul><li><strong>Tier 1</strong> (acpi_initialize_tables) : After this, acpi_gbl_root_table_list contains every table (signature, phys addr, length, mapped-or-not). You can call acpi_get_table(&quot;APIC&quot;, …) / acpi_table_parse(&quot;APIC&quot;, handler). <strong>No AML runs</strong>.</li><li><strong>Tier 2</strong> (acpi_boot_init / acpi_numa_init) : CPUs registered from MADT/GICC, interrupt controllers set up, SCI/PM-timer/HPET timers known, NUMA nodes and distances established. Still <strong>no AML</strong>; these all use fixed-format tables via acpi_table_parse*().</li><li><strong>Tier 3</strong> (acpi_early_init + acpi_init) : ACPICA subsystem initialized, DSDT/SSDT <strong>loaded into the namespace</strong>, the <strong>AML interpreter live</strong>, ACPI mode enabled (SCI_EN), fixed/GPE events armed, _INI/_STA run, and the <strong>PnP device tree</strong> built so drivers can bind.</li></ul><h3>3. setup_arch() - Architecture-Specific Early Init</h3><p>setup_arch() is where ACPI table access is first bootstrapped, because arch code needs MADT/SRAT/GTDT before the generic kernel is up. The exact entry points differ by arch but funnel into the same ACPICA table code.</p><h3>3.1 acpi_boot_table_init()</h3><p><strong>x86</strong> (arch/x86/kernel/acpi/boot.c) and <strong>arm64</strong> (arch/arm64/kernel/acpi.c) each provide acpi_boot_table_init(), called from setup_arch().</p><p>x86 responsibilities:</p><pre>void __init acpi_boot_table_init(void)<br>{<br>    if (acpi_disabled)              // &quot;acpi=off&quot; or no tables<br>        return;<br>    <br>    acpi_table_init();              // &lt;-the real work (see 3.2)<br>    <br>     if (acpi_disabled)             // acpi_table_init may disable on failure<br>        return;<br>    // x86: check blacklist (known-bad BIOSes), FADT sanity, etc.<br>    acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);   // simple boot flag table<br>    ...<br>}</pre><p>arm64 responsibilities (arch/arm64/kernel/acpi.c):</p><pre>void __init acpi_boot_table_init(void)<br>{<br>    // Decide ACPI vs DeviceTree:<br>    //  - if &quot;acpi=off&quot; --&gt;disable<br>    //  - if no DT (or DT says use ACPI) and tables present → enable ACPI<br>    //  - if the FADT is bad or MADT missing --&gt;fall back to DT<br>    if (param_acpi_off || (!param_acpi_on &amp;&amp; !param_acpi_force &amp;&amp; dt_present_and_valid))<br>        { disable_acpi(); return; }<br><br>    if (acpi_table_init()) {         // map + install tables<br>       pr_err(&quot;Failed to init ACPI tables\n&quot;);<br>       if (!param_acpi_force) disable_acpi();<br>       return;<br>    }<br>    // arm64 requires a sane FADT (HW-reduced) + MADT with GIC<br>}</pre><p><strong>Key arm64 detail:</strong> arm64 is <strong>ACPI-or-DeviceTree</strong>, decided here. arm64 mandates hardware-reduced ACPI and rejects tables that don’t meet the arm64 profile.</p><h3>3.2 acpi_table_init()</h3><p>drivers/acpi/tables.c :the generic bridge that</p><p>(a) applies initrd overrides and</p><p>(b) initializes ACPICA&#39;s table subsystem:</p><pre>int __init acpi_table_init(void)<br>{<br>    acpi_status status;<br>    if (acpi_verify_table_checksum) { ... }     // policy flag<br>    acpi_table_upgrade();          // initrd DSDT/SSDT override (discussed later)<br>   <br>    status = acpi_initialize_tables(initial_tables,<br>                                    ACPI_MAX_TABLES,   // static array size<br>                                    0 /* allow_resize? no yet */);<br>    if (ACPI_FAILURE(status))<br>      return -EINVAL;<br>    // Optional: apply user table overrides, print the table list<br>    acpi_table_initrd_scan();      // (details of override injection)<br>    check_multiple_madt();<br>    return 0;<br>}</pre><ul><li>initial_tables is a <strong>static array</strong> (struct acpi_table_desc initial_tables[ACPI_MAX_TABLES]) used <em>before</em> the kernel allocator is available - ACPICA records tables here first, then later acpi_reallocate_root_table() moves the list into kmalloced memory (in acpi_early_init).</li><li>After acpi_table_init() returns, the kernel can parse any fixed table.</li></ul><h3>3.3 acpi_initialize_tables() - ACPICA init (tables-only mode)</h3><p>drivers/acpi/acpica/tbxface.c - the ACPICA entry that sets up table management without initializing the rest of the subsystem (no interpreter, no namespace yet). This is the <strong>tables only</strong> bootstrap:</p><pre>acpi_status ACPI_INIT_FUNCTION<br>acpi_initialize_tables(struct acpi_table_desc *initial_table_array,<br>                       u32 initial_table_count,<br>                       u8 allow_resize)<br>{<br>    acpi_physical_address rsdp_address;<br>    // 1. Set up the root table list storage (caller&#39;s static array or dynamic)<br>    acpi_tb_initialize_facs_and_dsdt_globals();  // globals init<br>    acpi_gbl_root_table_list.tables = initial_table_array;<br>    acpi_gbl_root_table_list.max_table_count = initial_table_count;<br>    acpi_gbl_root_table_list.flags = allow_resize ? ...ALLOW_RESIZE : ...ORIGIN_UNKNOWN;<br>    // 2. Get the RSDP physical address (OS layer - see Section 4.1)<br>    rsdp_address = acpi_os_get_root_pointer();<br>    if (!rsdp_address) return AE_NOT_FOUND;<br>    // 3. Parse RSDP --&gt; RSDT/XSDT, install every table into the list<br>    return acpi_tb_parse_root_table(rsdp_address);   // &lt;-- Section 4.2<br>}</pre><p>After this call the <strong>root table list is populated</strong>. Note it does <strong>not</strong> map whole tables permanently or run any AML; it maps headers to enumerate, records addresses, and validates. Detailed mechanics are in Section 4.</p><h3>4. RSDP →XSDT →Table Registration</h3><p>This is the ACPICA table-management core (drivers/acpi/acpica/tb*.c). It turns the RSDP physical address into acpi_gbl_root_table_list[].</p><h3>4.1 acpi_find_root_pointer() / acpi_os_get_root_pointer()</h3><p>acpi_initialize_tables() obtains the RSDP via the<strong> OS layer</strong> call acpi_os_get_root_pointer() (drivers/acpi/osl.c), which on UEFI returns the address the bootloader captured (prior document Section 5). If the OS layer has nothing and legacy lookup is enabled, ACPICA&#39;s acpi_find_root_pointer() (acpica/tbxfroot.c) does the BIOS EBDA/ROM scan:</p><pre>acpi_status acpi_find_root_pointer(acpi_physical_address *table_address)<br>{<br>    // 1. Map the first KB of the EBDA (from phys 0x40E &lt;&lt; 4), scan 16-byte<br>    //    aligned for &quot;RSD PTR&quot; -&gt;acpi_tb_scan_memory_for_rsdp()<br>    // 2. Else scan 0xE0000–0xFFFFF likewise.<br>    // 3. Validate the candidate (acpi_tb_validate_rsdp): signature + checksum.<br>}</pre><p>On UEFI this path is not used; efi.acpi20 ( → XSDT) wins.</p><h3>4.2 acpi_tb_parse_root_table()</h3><p>drivers/acpi/acpica/tbutils.c - the heart of table registration:</p><pre>acpi_status ACPI_INIT_FUNCTION<br>acpi_tb_parse_root_table(acpi_physical_address rsdp_address)<br>{<br>    struct acpi_table_rsdp *rsdp;<br>    u32   table_entry_size, table_count, i;<br>    acpi_physical_address address, table_address;<br>    // 1. Map the RSDP and validate it<br>    rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp));<br>    // 2. Choose XSDT (rev&gt;=2 &amp;&amp; xsdt!=0) else RSDT; pick entry size 8 or 4<br>    if (rsdp-&gt;revision &gt; 1 &amp;&amp; rsdp-&gt;xsdt_physical_address) {<br>        address = (acpi_physical_address) rsdp-&gt;xsdt_physical_address;<br>        table_entry_size = ACPI_XSDT_ENTRY_SIZE;   // 8<br>    } else {<br>        address = (acpi_physical_address) rsdp-&gt;rsdt_physical_address;<br>        table_entry_size = ACPI_RSDT_ENTRY_SIZE;    // 4<br>    }<br>    acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp));<br>    // 3. Map the XSDT/RSDT itself, compute entry count from its Length<br>    table = acpi_os_map_memory(address, header_len...);<br>    table_count = (table-&gt;length - sizeof(struct acpi_table_header)) / table_entry_size;<br>    // 4. First install the XSDT/RSDT itself as table[0]<br>    acpi_tb_install_table_with_override(... the root ...);<br>    // 5. Loop each entry --&gt;install<br>    table_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header));<br>    for (i = 0; i &lt; table_count; i++) {<br>        table_address = acpi_tb_get_table_entry(table_entry, table_entry_size);<br>        acpi_tb_install_standard_table(table_address,<br>                                       ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,<br>                                       NULL, FALSE /*reload*/, TRUE /*override*/,<br>                                       &amp;table_index);<br>        table_entry += table_entry_size;<br>    }<br>    acpi_os_unmap_memory(table, ...);<br>    // 6. Parse the FADT (find &amp; install DSDT + FACS)<br>    acpi_tb_parse_fadt();          // Section 4.5<br>    return AE_OK;<br>}</pre><h3>4.3 acpi_tb_install_standard_table()</h3><p>drivers/acpi/acpica/tbinstal.c: installs one table into the root list:</p><pre>acpi_status<br>acpi_tb_install_standard_table(acpi_physical_address address, u8 flags,<br>        struct acpi_table_header *table, u8 reload, u8 override,<br>        u32 *table_index)<br>{<br>    struct acpi_table_desc new_table_desc;<br>    // 1. Fill a descriptor: address, flags, and map/read the HEADER to learn<br>    //    signature + length (acpi_tb_acquire_temp_table).<br>    acpi_tb_acquire_temp_table(&amp;new_table_desc, address, flags, table);<br>    // 2. Validate the temp table (signature/length/checksum) - acpi_tb_validate_temp_table<br>    status = acpi_tb_verify_temp_table(&amp;new_table_desc, NULL, &amp;table_index);<br>    // 3. Reject duplicates on reload; handle table override (initrd/host)<br>    //    acpi_tb_override_table() - lets the OS swap in a replacement.<br>    // 4. Append the descriptor to acpi_gbl_root_table_list (grow if allowed)<br>    acpi_tb_append_table(&amp;new_table_desc, table_index);<br>    // 5. Release the temp mapping (the header map); the table is recorded by<br>    //    address and mapped on demand later via acpi_get_table().<br>    acpi_tb_release_temp_table(&amp;new_table_desc);<br>}</pre><p><strong>The important idea:</strong> only the header is mapped to enumerate/validate; the full table is mapped later when someone actually calls acpi_get_table().</p><h3>4.4 acpi_tb_validate_table() / acpi_tb_verify_temp_table()</h3><p>drivers/acpi/acpica/tbutils.c / tbinstal.c:</p><ul><li>acpi_tb_validate_table() ensures the table is mapped (maps it if the descriptor only had a physical address) so its bytes are accessible.</li><li>acpi_tb_verify_temp_table() then:</li></ul><ol><li>Confirms the signature is sane (printable / expected).</li><li>Confirms length ≥ header and matches.</li><li>Calls acpi_tb_verify_checksum() — the 8-bit-sum-to-zero check (prior doc Section 7.3). FACS and S3PT are exempt (no checksum). On mismatch it warns (ACPI_BIOS_WARNING) but, per Linux default, still accepts the table.</li><li>Optionally checks against the table for duplicate/OEM matching on reload.</li></ol><pre>u8 acpi_tb_checksum(u8 *buffer, u32 length) {<br>    u8 sum = 0;<br>    while (length--) sum = (u8)(sum + *buffer++);<br>    return sum;                 // 0 == valid<br>}</pre><h3>4.5 acpi_tb_parse_fadt() - DSDT + FACS location</h3><p>drivers/acpi/acpica/tbfadt.c — the FADT is special because it <em>points to</em> the two tables not in the XSDT:</p><pre>void acpi_tb_parse_fadt(void)<br>{<br>    u32 fadt_index = acpi_gbl_fadt_index;   // FADT already installed by the loop<br>    struct acpi_table_header *table;<br>    // 1. Get and map the FADT<br>    acpi_tb_get_table(&amp;acpi_gbl_root_table_list.tables[fadt_index], &amp;table);<br>    // 2. Create a normalized &quot;local FADT&quot;: zero-extend short FADTs, and<br>    //    SYNTHESIZE the 64-bit X_ fields from 32-bit fields if X_ is zero.<br>    acpi_tb_create_local_fadt(table, table-&gt;length);   // → acpi_gbl_FADT<br>    // 3. Install the DSDT: prefer Xdsdt, else dsdt<br>    acpi_tb_install_standard_table(<br>        (acpi_physical_address) acpi_gbl_FADT.Xdsdt,<br>        ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, NULL, FALSE, TRUE,<br>        &amp;acpi_gbl_dsdt_index);<br>    // 4. Install the FACS (if present / not hw-reduced): prefer Xfacs, else facs<br>    if (acpi_gbl_FADT.Xfacs)<br>        acpi_tb_install_standard_table(acpi_gbl_FADT.Xfacs, ...,<br>                                       &amp;acpi_gbl_facs_index);<br>}</pre><p>Details ACPICA handles:</p><ul><li><strong>acpi_tb_create_local_fadt()</strong> normalizes every historical FADT layout into one internal struct acpi_table_fadt acpi_gbl_FADT, converting legacy 32-bit address fields into the generic-address X_* fields, and validating length buckets (V1 = 116 bytes, V2, V3+, …).</li><li><strong>64-bit precedence </strong>with quirk override: acpi_gbl_use32_bit_fadt_addresses and acpi_gbl_use32_bit_facs_addresses let ACPICA prefer the 32-bit fields when firmware fills the pair inconsistently.</li><li><strong>FACS is not checksummed</strong>; DSDT is.</li><li><strong>Hardware-reduced (FADT flag)</strong>: no FACS; Xfacs == 0, skip.</li></ul><h3>4.6 acpi_gbl_root_table_list[] - the internal registry</h3><p>The master registry after installation:</p><pre>struct acpi_table_list {<br>    struct acpi_table_desc *tables;      // array of descriptors<br>    u32                     current_table_count;<br>    u32                     max_table_count;<br>    u16                     flags;<br>};<br>extern struct acpi_table_list acpi_gbl_root_table_list;<br>struct acpi_table_desc {<br>    acpi_physical_address     address;   // where the table lives (phys)<br>    struct acpi_table_header *pointer;   // mapped VA (NULL until mapped)<br>    u32                       length;<br>    union acpi_name_union     signature; // 4-char sig<br>    acpi_owner_id             owner_id;<br>    u8                        flags;      // mapped? origin? loaded-into-namespace?<br>    u16                       validation_count;<br>};</pre><ul><li>Indexed lookups: acpi_gbl_dsdt_index, acpi_gbl_facs_index, acpi_gbl_fadt_index cache the special ones.</li><li>acpi_get_table(signature, instance, &amp;table) walks this list, maps the table on demand (acpi_tb_validate_table), and returns the VA - used by every early parser ( Section 5) and by acpi_table_parse().</li><li>acpi_reallocate_root_table() (called in acpi_early_init) copies this list out of the static initial_tables array into kmalloced memory once the allocator is up, so the list can grow (for runtime-loaded SSDTs).</li></ul><h3>5. Early Table Parsing (acpi_boot_init)</h3><p>Once the root table list exists, the kernel does <strong>fixed-format parsing</strong> of the static tables to configure CPUs, interrupt controllers, timers, etc. The generic tool is acpi_table_parse(signature, handler) and, for MADT subtables, acpi_table_parse_madt(subtype, handler, max_entries) — both in drivers/acpi/tables.c.<strong> No AML interpreter is involved.</strong></p><pre>// Generic: find a whole table by signature and hand it to a callback<br>int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler);<br><br>// MADT helper: iterate subtables of a given type within the MADT<br>int __init acpi_table_parse_madt(enum acpi_madt_type id,<br>        acpi_tbl_entry_handler handler, unsigned int max_entries);</pre><h3>5.1 MADT parsing</h3><p>The <strong>MADT</strong> (APIC signature) describes interrupt controllers and CPU <strong>local interrupt controller</strong> entries. Entry point:</p><pre>static int __init acpi_parse_madt(struct acpi_table_header *table)<br>{<br>    struct acpi_table_madt *madt = (struct acpi_table_madt *)table;<br>    // record the local interrupt controller address (LAPIC / GICC base)<br>    // then iterate subtables via acpi_table_parse_madt(...)<br>}</pre><p>The MADT is a header followed by variable-length <strong>subtables</strong>, each tagged with a type byte. The parser dispatches by type.</p><h4>5.1.1 ARM64: GICC, GICD, GICR, ITS parsing</h4><p>On arm64 the interrupt model is the <strong>GIC</strong> (Generic Interrupt Controller). The MADT carries GIC subtables; parsing is driven from the GIC <strong>irqchip</strong> drivers (drivers/irqchip/irq-gic-v3.c via gic_acpi_init) and CPU bring-up:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89534c5e0209156d380ab5e8c3414fc3/href">https://medium.com/media/89534c5e0209156d380ab5e8c3414fc3/href</a></iframe><p>Flow on arm64:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9_ATk4EPubSIsKSy-FAOxA.jpeg" /></figure><h4>5.1.2 x86: LAPIC, IOAPIC parsing</h4><p>On x86 the MADT drives APIC setup (arch/x86/kernel/acpi/boot.c):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee34607348b8f4f05ad57ff0a4402396/href">https://medium.com/media/ee34607348b8f4f05ad57ff0a4402396/href</a></iframe><p>Flow on x86:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gCnr1zbzG5-zG1q97Rby4A.jpeg" /></figure><h3>5.2 FADT parsing: SCI IRQ, PM timer, flags</h3><p>The kernel reads the FADT for fixed-hardware facts (already normalized into acpi_gbl_FADT by Section 4.5). On x86 acpi_parse_fadt() (arch/x86/kernel/acpi/boot.c) and generic code extract:</p><ul><li><strong>SCI interrupt</strong> (acpi_gbl_FADT.sci_interrupt) : the System Control Interrupt GSI; registered as the ACPI IRQ (acpi_gbl_FADT.sci_interrupt --&gt;acpi_sci_ioapic_setup() / acpi_register_gsi()), shared, level, active-low.</li><li><strong>PM timer</strong> (acpi_gbl_FADT.xpm_timer_block) : the ACPI Power Management timer I/O address and its 24/32-bit width flag; used as a clocksource (drivers/clocksource/acpi_pm.c).</li><li><strong>Feature flags</strong> (acpi_gbl_FADT.flags, boot_flags) : e.g. ACPI_FADT_HW_REDUCED_ACPI, ACPI_FADT_LOW_POWER_S0, legacy-devices/8042 presence (ACPI_FADT_LEGACY_DEVICES, ACPI_FADT_8042), WBINVD, C-state support hints.</li><li><strong>Reset register</strong> (reset_register, reset_value) : how to reboot via ACPI.</li><li><strong>SMI command port / ACPI enable/disable values </strong>: used later by acpi_enable() to flip SCI_EN (Section 7.3).</li></ul><h3>5.3 GTDT parsing (arm64): timer GSIVs</h3><p>The <strong>GTDT</strong> (Generic Timer Description Table) is arm64’s timer table. Parsed by drivers/acpi/arm64/gtdt.c (acpi_gtdt_init()), consumed by the arm architected timer driver (drivers/clocksource/arm_arch_timer.c):</p><pre>int __init acpi_gtdt_init(struct acpi_table_header *table, int *platform_timer_count);<br>int __init acpi_gtdt_map_ppi(int type);           // per-CPU timer PPIs</pre><p>It provides:</p><ul><li>The <strong>per-CPU architected timer interrupts (GSIVs)</strong> and their trigger/polarity for the four timer types: <strong>EL1 non-secure (virtual/physical), EL1 secure, EL2 (hyp), and virtual EL2 - </strong>mapped as PPIs.</li><li><strong>Platform (memory-mapped) timers</strong> :GT block and SBSA/SP804 watchdog entries: base addresses and GSIVs, iterated via acpi_gtdt_parse_timer_block() and the watchdog parser.</li><li>Feeds arch_timer_acpi_init() which registers the clockevent/clocksource.</li></ul><h3>5.4 HPET parsing (x86): timer base address</h3><p>The HPET (High Precision Event Timer) table on x86 is parsed by acpi_parse_hpet() (arch/x86/kernel/acpi/boot.c):</p><pre>static int __init acpi_parse_hpet(struct acpi_table_header *table)<br>{<br>    struct acpi_table_hpet *hpet_tbl = (struct acpi_table_hpet *)table;<br>    // hpet_tbl-&gt;address.address = MMIO base of the HPET block<br>    hpet_address = hpet_tbl-&gt;address.address;<br>    hpet_blockid = hpet_tbl-&gt;sequence;<br>    // validate, then hpet_enable() later registers it as clocksource/clockevent<br>}</pre><p>It yields the <strong>HPET MMIO base address</strong>, block ID, and minimum tick; the HPET driver (arch/x86/kernel/hpet.c) later maps it and registers a clocksource.</p><h3>6. NUMA Initialization (acpi_numa_init)</h3><p>On NUMA machines, ACPI describes CPU/memory locality via <strong>SRAT</strong> (affinity) and <strong>SLIT</strong> (distance). Linux parses them in acpi_numa_init() (drivers/acpi/numa/srat.c), called from arch NUMA init during setup_arch().</p><pre>int __init acpi_numa_init(void)<br>{<br>    int cnt = 0;<br>    // 1. SRAT - must be parsed before SLIT<br>    if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) {<br>        struct acpi_subtable_proc srat_proc[...] = {<br>            { ACPI_SRAT_TYPE_CPU_AFFINITY,        acpi_parse_processor_affinity },<br>            { ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY, acpi_parse_x2apic_affinity },<br>            { ACPI_SRAT_TYPE_GICC_AFFINITY,       acpi_parse_gicc_affinity },   // arm64<br>            { ACPI_SRAT_TYPE_MEMORY_AFFINITY,     acpi_parse_memory_affinity },<br>            ...<br>        };<br>        acpi_table_parse_srat(...);   // iterate all subtables<br>        cnt = ...;<br>    }<br>    // 2. SLIT - distance matrix<br>    acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit);<br>    // 3. Finalize: register nodes, sanity-check<br>    if (cnt &lt; 0) return cnt;<br>    else if (!parsed_numa_memblks) return -ENOENT;<br>    return 0;<br>}</pre><h3>6.1 SRAT parsing: CPU + memory affinity</h3><p>The <strong>SRAT</strong> (System/Static Resource Affinity Table) maps CPUs and memory ranges to <strong>proximity domains </strong>(NUMA nodes):</p><ul><li><strong>CPU affinity :</strong>acpi_parse_processor_affinity() (x86 LAPIC), acpi_parse_x2apic_affinity() (x86 x2APIC), acpi_parse_gicc_affinity() (arm64). Each entry ties an APIC ID / GICC _UID to a proximity domain. Handler calls:</li></ul><pre>node = acpi_map_pxm_to_node(pxm); // proximity domain --&gt;Linux node id <br>numa_add_cpu? set_apicid_to_node(apicid, node); // record CPU--&gt;node node_set(node, numa_nodes_parsed);</pre><ul><li><strong>Memory affinity</strong> :acpi_parse_memory_affinity(): each entry gives a {base, length, proximity_domain, hotpluggable, enabled} tuple. Handler:</li></ul><pre>numa_add_memblk(node, start, end); // register a memory block for the node</pre><ul><li>Hot-pluggable ranges are marked so the memory manager can treat them as ZONE_MOVABLE candidates.</li></ul><h3>6.2 SLIT parsing: distance matrix</h3><p>The <strong>SLIT</strong> (System Locality Information Table) is an N×N byte matrix of <strong>relative distances </strong>between proximity domains (10 = local, higher = farther; 255 = unreachable):</p><pre>static int __init acpi_parse_slit(struct acpi_table_header *table)<br>{<br>    struct acpi_table_slit *slit = (struct acpi_table_slit *)table;<br>    // slit-&gt;locality_count == N; slit --&gt; entry[i*N + j] = distance(i, j)<br>    if (!slit_valid(slit)) { bad_srat(); return -1; }<br>    acpi_numa_slit_init(slit);    // --&gt; fills the kernel distance table<br>}</pre><h3>6.3 arm64 GICC affinity entries</h3><p>arm64 has no APIC, so SRAT CPU affinity uses GICC affinity subtables (ACPI_SRAT_TYPE_GICC_AFFINITY), which reference a CPU by its ACPI processor UID (matching the GICC _UID in the MADT). acpi_parse_gicc_affinity():</p><pre>static int __init<br>acpi_parse_gicc_affinity(union acpi_subtable_headers *header, const unsigned long end)<br>{<br>    struct acpi_srat_gicc_affinity *pa = (struct acpi_srat_gicc_affinity *)header;<br>    int node = acpi_map_pxm_to_node(pa-&gt;proximity_domain);<br>    // tie pa-&gt;acpi_processor_uid --&gt;node<br>    early_node_cpu_hotplug?  acpi_map_cpu_to_node(...);<br>    node_set(node, numa_nodes_parsed);<br>}</pre><h3>6.4 How numa_set_distance() builds the matrix</h3><p>acpi_numa_slit_init() (generic, in drivers/acpi/numa/srat.c) walks the SLIT and calls the arch NUMA API numa_set_distance(from, to, distance) for every pair:</p><pre>void __init acpi_numa_slit_init(struct acpi_table_slit *slit)<br>{<br>    int i, j;<br>    for (i = 0; i &lt; slit-&gt;locality_count; i++) {<br>        const int from_node = pxm_to_node(i);<br>        if (from_node == NUMA_NO_NODE) continue;<br>        for (j = 0; j &lt; slit-&gt;locality_count; j++) {<br>            const int to_node = pxm_to_node(j);<br>            if (to_node == NUMA_NO_NODE) continue;<br>            numa_set_distance(from_node, to_node,<br>                              slit-&gt;entry[slit-&gt;locality_count * i + j]);<br>        }<br>    }<br>}</pre><p>numa_set_distance() (arch: arch/x86/mm/numa.c, arch/arm64/mm/numa.c) writes into the global numa_distance[] matrix that the scheduler and page allocator use for locality decisions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Keb7oRoGCIYwkNMvJmsJog.jpeg" /></figure><p>If no SLIT is present, Linux synthesizes a default (10 local / 20 remote).</p><h3>7. ACPICA Full Init (acpi_early_init)</h3><p>Now the heavy machinery. acpi_early_init() (drivers/acpi/bus.c), called from start_kernel() after mm/irq/timers are up, brings up the full ACPICA subsystem and <strong>loads the namespace</strong>. The later acpi_enable_subsystem() (from acpi_bus_init() in acpi_init) turns on ACPI mode and events.</p><pre>void __init acpi_early_init(void)<br>{<br>    acpi_status status;<br>    if (acpi_disabled) return;<br>    // 1. Move the root table list from the static array into allocated memory,<br>    //    so it can grow (runtime SSDTs) and survives past init.<br>    status = acpi_reallocate_root_table();<br>    // 2. Initialize the ACPICA subsystem (OS layer, globals, root namespace node)<br>    status = acpi_initialize_subsystem();          // Section 7.1<br>    // 3. Load DSDT + all SSDTs into the namespace (AML parsed, objects created)<br>    status = acpi_load_tables();                    // Section 7.2<br>    // (acpi_enable_subsystem is deferred to acpi_bus_init --&gt;Section 7.3)<br>}</pre><h3>7.1 acpi_initialize_subsystem()</h3><p>drivers/acpi/acpica/utxfinit.c - bootstraps ACPICA&#39;s runtime:</p><pre>acpi_status ACPI_INIT_FUNCTION acpi_initialize_subsystem(void)<br>{<br>    acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;<br>    acpi_ut_init_globals();          // Section 7.1.2  - zero/seed all globals<br>    status = acpi_os_initialize();   // Section 7.1.1  - Linux OSL bring-up<br>    status = acpi_ut_mutex_initialize();   // create the ACPICA global mutexes/locks<br>    status = acpi_ns_root_initialize();    // Section 7.1.3 - create &quot;\&quot; and predefined names<br>    status = acpi_hw_set_mode?             // (mode handling deferred to enable)<br>    ...<br>}</pre><h4>7.1.1 acpi_os_initialize() - OS layer</h4><p>drivers/acpi/osl.c — prepares the Linux side of the OSL:</p><ul><li>Sets up caches/workqueues used by ACPICA callbacks (acpi_os_execute — &gt;kacpid/kacpi_notify workqueues).</li><li>Maps the FADT-referenced fixed hardware registers (PM1a/PM1b, GPE blocks) so acpi_os_read/write_port/_memory work.</li><li>Prepares the deferred-IRQ handling for the SCI.</li></ul><h4>7.1.2 acpi_ut_init_globals()</h4><p>drivers/acpi/acpica/utglobal.c - initializes <strong>every ACPICA global</strong>: the mutex array, GPE lists, the owner-id bitmap, the fixed-event table, cache stats, the acpi_gbl_* flags, and clears the namespace root pointer. Nothing works before this runs.</p><h4>7.1.3 acpi_ns_root_initialize() - the root node</h4><p>drivers/acpi/acpica/nsaccess.c - creates the <strong>root of the namespace</strong> and the predefined objects the AML in the DSDT will reference:</p><pre>acpi_status acpi_ns_root_initialize(void)<br>{<br>    // 1. Create acpi_gbl_root_node  (the &quot;\&quot; scope, a NAMESPACE node)<br>    // 2. Install predefined names from acpi_gbl_pre_defined_names[]:<br>    //      _GPE (GPE block scope), _PR_ (processors, legacy),<br>    //      _SB_ (system bus), _SI_ (system indicators),<br>    //      _TZ_ (thermal zones), _REV, _OS_, _GL_ (global lock),<br>    //      _OSI (interface query method)<br>    // 3. Seed _REV (ACPI revision), _OS_ (&quot;Microsoft Windows NT&quot; by default!),<br>    //    and register _OSI supported-strings.<br>}</pre><p><strong>Note:</strong> Linux, like all OSes, reports _OS_ = “<strong>Microsoft Windows NT</strong>” and answers _OSI(&quot;Windows …&quot;) queries, because most firmware AML branches on those strings. This is set up here, before any DSDT AML runs.</p><h3>7.2 acpi_load_tables()</h3><p>drivers/acpi/acpica/tbxfload.c - parses the AML tables into the namespace:</p><pre>acpi_status ACPI_INIT_FUNCTION acpi_load_tables(void)<br>{<br>    // Load the DSDT and all SSDTs currently in acpi_gbl_root_table_list<br>    status = acpi_tb_load_namespace();       // Section 7.2.1<br>    // Complete any deferred namespace initialization<br>    ...<br>}</pre><h4>7.2.1 acpi_tb_load_namespace()</h4><p>drivers/acpi/acpica/tbxfload.c:</p><pre>acpi_status acpi_tb_load_namespace(void)<br>{<br>    // 1. Find and validate the DSDT (must be present &amp; look like AML)<br>    //    acpi_gbl_root_table_list.tables[acpi_gbl_dsdt_index]<br>    //    Verify signature &quot;DSDT&quot;; guard against a DSDT that was replaced.<br>    // 2. Load the DSDT into the namespace<br>       acpi_ns_load_table(acpi_gbl_dsdt_index, acpi_gbl_root_node);<br>    // 3. Loop every other table; load each SSDT / PSDT / OSDT into the namespace<br>       for (i = 0; i &lt; acpi_gbl_root_table_list.current_table_count; i++) {<br>         if (!ACPI_COMPARE_NAMESEG(table.signature, ACPI_SIG_SSDT) &amp;&amp;<br>            !...PSDT &amp;&amp; !...OSDT) continue;<br>        acpi_ns_load_table(i, acpi_gbl_root_node);   // merges into &quot;\&quot;<br>    }<br>}</pre><h4>7.2.2 DSDT loading: Pass 1 + Pass 2 AML</h4><p>acpi_ns_load_table() --&gt; acpi_ds_load1*/acpi_ds_load2* performs the AML in two passes (drivers/acpi/acpica/dswload.c, dswload2.c):</p><pre>Pass 1 (acpi_ds_load1_begin/end_op):  &quot;namespace construction&quot;<br>    • Walk the AML byte stream (parser ps*.c) building parse-tree ops.<br>    • For each namespace-creating opcode (Scope, Device, Method, Name,<br>      OperationRegion, Field, Processor, ThermalZone, Mutex, Event, ...)<br>      CREATE the namespace node (acpi_ns_lookup with ACPI_NS_NO_UPSEARCH),<br>      but DO NOT evaluate method bodies or field values yet.<br>    • Methods: record the AML start/length; body is NOT executed.</pre><pre> Pass 2 (acpi_ds_load2_begin/end_op):  &quot;operand resolution&quot;<br>    • Second walk resolves arguments that reference other namespace nodes,<br>      finalizes Field unit definitions against their OperationRegions,<br>      attaches package/buffer initializers, resolves forward references.<br>    • Still does NOT run control methods (those run on demand later).</pre><p>Why two passes: AML allows <strong>forward references</strong> (an object used before it is defined textually). Pass 1 creates all names so Pass 2 can resolve any reference.</p><h4>7.2.3 SSDT merging into the namespace</h4><p>Each SSDT is loaded with the <em>same</em> acpi_ns_load_table() into the <em>same</em> root node, so its objects <strong>merge</strong> into the existing tree (e.g., an SSDT can add methods/devices under \_SB or \_PR that the DSDT declared).</p><p><strong>Ordering:</strong> DSDT first, then SSDTs in table-list order. Objects an SSDT defines get a distinct owner_id so they can be unloaded together if the SSDT is later unloaded.</p><h3>7.3 acpi_enable_subsystem()</h3><p>drivers/acpi/acpica/utxfinit.c:called from acpi_bus_init() (in acpi_init), this actually turns ACPI on and arms events:</p><pre>acpi_status ACPI_INIT_FUNCTION acpi_enable_subsystem(u32 flags)<br>{<br>    // 1. Set up the SCI interrupt handler (acpi_ev_install_sci_handler via OSL)<br>    // 2. Initialize the GPE (General Purpose Event) blocks: acpi_ev_gpe_initialize()<br>    // 3. Install the fixed-event handling framework<br>    // 4. Enter ACPI mode:<br>    if (!(flags &amp; ACPI_NO_ACPI_ENABLE))<br>        acpi_enable();                    // §7.3.1 — set SCI_EN<br>    ...<br>}</pre><h4>7.3.1 acpi_enable() → SCI_EN bit</h4><p>drivers/acpi/acpica/hwxface.c / hwacpi.c: switch the platform from <strong>legacy mode</strong> to <strong>ACPI mode</strong>:</p><pre>acpi_status acpi_enable(void)<br>{<br>    // If already in ACPI mode (SCI_EN set), done.<br>    if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) return AE_OK;<br>    // Write the ACPI_ENABLE value to the SMI_CMD port (from the FADT):<br>    acpi_hw_write_port(acpi_gbl_FADT.smi_command, acpi_gbl_FADT.acpi_enable, 8);<br>    // Poll PM1 control register until SCI_EN (bit 0) reads 1.<br>    do { ... } while (!(acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI));<br>}</pre><p>Setting SCI_EN hands control of power-management hardware (power button, thermal, GPEs) to the OS via the <strong>SCI</strong> (System Control Interrupt) instead of the firmware&#39;s SMI. On <strong>hardware-reduced</strong> platforms (most arm64) there is no SMI/SCI enable dance - ACPI mode is implicit and acpi_enable() is effectively a no-op.</p><h4>7.3.2 Fixed event handler installation + object init</h4><ul><li><strong>Fixed events</strong> (acpi_install_fixed_event_handler): power button, sleep button, RTC, PM timer overflow, global-lock release - wired via the OSL&#39;s SCI handler.</li><li><strong>GPE bring-up</strong>: acpi_ev_gpe_initialize() enumerates GPE blocks from the FADT and any _GPE block devices; runtime GPEs are enabled after _PRW/_Lxx/_Exx methods are located.</li><li>acpi_initialize_objects() (called next in acpi_bus_init):</li></ul><p>a) Finalizes OperationRegion address-space handlers (SystemMemory, SystemIO, PCI_Config, EC, etc.) so field accesses work.</p><p>b) Runs _INI methods top-down and evaluates _STA to prune absent devices (per the ACPI device-initialization algorithm).</p><p>c) Completes any deferred package/field resolution.</p><p><strong>After </strong><strong>acpi_enable_subsystem() + </strong><strong>acpi_initialize_objects(), the interpreter is fully live, ACPI mode is on, and </strong><strong>acpi_scan_init() can enumerate devices into the Linux device model.</strong></p><h3>8. The ACPI Namespace Tree</h3><h3>8.1 What it looks like after DSDT + SSDTs are loaded</h3><p>After acpi_load_tables(), the DSDT and every SSDT have been merged into a single hierarchical namespace rooted at \. Each node is a struct acpi_namespace_node with a 4-character name, a type, and an attached object (union acpi_operand_object). A representative tree:</p><pre>\  (root, acpi_gbl_root_node)<br> ├── _GL_          (Global Lock mutex)<br> ├── _OSI          (method: OS interface query)<br> ├── _OS_          (string: &quot;Microsoft Windows NT&quot;)<br> ├── _REV          (integer: ACPI revision)<br> ├── _PR_ / _SB_.PrNN  (processors — legacy \_PR_ or modern \_SB_ Devices)<br> ├── _SB_          (System Bus — the root of the device tree)<br> │    ├── PCI0     (Device: PCI/PCIe root bridge)<br> │    │    ├── _HID (Name: &quot;PNP0A08&quot; — PCIe root bridge ID)<br> │    │    ├── _CRS (Method/Name: current resources — bus/mem/io windows)<br> │    │    ├── _PRT (Name: PCI IRQ routing table)<br> │    │    └── RP01 … (Device: root ports, downstream devices)<br> │    ├── GPI0     (Device: GPIO controller, _HID + _CRS)<br> │    ├── I2C0     (Device: I2C controller; child sensors/touch)<br> │    ├── UAR0     (Device: UART / serial)<br> │    ├── EC00     (Device: Embedded Controller, _GPE, _REG, opregion)<br> │    └── PRnn     (Device: Processor containers on modern systems, _CPC/_PSD)<br> ├── _TZ_          (Thermal Zones)<br> │    └── TZ00     (_TMP, _AC0, _PSL, _CRT methods)<br> ├── _SI_          (System Indicators: _SST, _MSG)<br> └── _GPE          (GPE block scope: _Lxx / _Exx event methods, _Qxx for EC)</pre><h3>8.2 \, SB, TZ, PR scopes (the predefined scopes)</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ea2811aa9ef083303d6326ff34a0e23/href">https://medium.com/media/6ea2811aa9ef083303d6326ff34a0e23/href</a></iframe><h3>8.3 Node kinds: Device, Method, Name, OperationRegion (and more)</h3><p>Every node has an <strong>ACPI object type</strong> (ACPI_TYPE_*). The important ones:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c048c94e61124a3cf2f2c9b1c83b93c/href">https://medium.com/media/5c048c94e61124a3cf2f2c9b1c83b93c/href</a></iframe><p>When PnP (acpi_scan_init() --&gt; acpi_bus_scan()) walks \_SB_, for each Device it evaluates _STA (present/enabled?), _HID/_CID (to match a driver), _CRS (resources), and creates an acpi_device in the Linux device model; matching drivers then bind.</p><h3>8.4 How to view it: /sys/firmware/acpi/namespace and tools</h3><ul><li><strong>Kernel debug (if built with </strong><strong>CONFIG_ACPI_DEBUGGER / </strong><strong>acpidbg)</strong>: /sys/kernel/debug/acpi/… and the in-kernel ACPI debugger let you dump the namespace live.</li><li><strong>Historical: </strong>older kernels exposed /sys/firmware/acpi/namespace and /proc/acpi/…; on current kernels the namespace is not a static sysfs tree, but the <strong>device view</strong> is visible under /sys/bus/acpi/devices/ (one entry per acpi_device, named by ACPI path, e.g. PNP0A08:00, device:xx).</li><li><strong>Userspace dump-and-disassemble (the practical way to <em>see</em> the AML tree):</strong></li></ul><pre>sudo acpidump -b            # dump every table as *.dat </pre><pre>iasl -d dsdt.dat            # disassemble DSDT --&gt; dsdt.dsl (human-readable AML) iasl -d ssdt*.dat           # each SSDT</pre><ul><li>The resulting .dsl shows the exact Device/Method/Name/OperationRegion hierarchy that became the namespace.</li><li>acpica-tools acpiexec can load the dumped tables and interactively walk the namespace (namespace, execute, find commands) — the same ACPICA code the kernel runs, in userspace.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8AuVZXKMGwmpEL03kU8NjA.jpeg" /></figure><h3>9. Key Functions Reference Table</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd8a3e46e1d65f264e6bf7e625465033/href">https://medium.com/media/cd8a3e46e1d65f264e6bf7e625465033/href</a></iframe><h3>10. Key Takeaways</h3><ol><li><strong>ACPI init is tiered, not monolithic.</strong> Tier 1 (table access) and Tier 2 (early fixed-table parse: MADT/FADT/GTDT/HPET/SRAT/SLIT) run inside setup_arch() before any AML interpreter exists. Tier 3 (full ACPICA: subsystem + namespace + enable) runs later from acpi_early_init() and acpi_init().</li><li><strong>ACPICA + OSL split</strong>. Linux embeds ACPICA (drivers/acpi/acpica/) and talks to it via the acpi_* public API; ACPICA calls back into Linux via the OS Services Layer acpi_os_* in drivers/acpi/osl.c. This is why the same parser works on x86 and arm64.</li><li>acpi_initialize_tables() is <strong>tables-only.</strong> It builds acpi_gbl_root_table_list (RSDP→XSDT→install each, parse FADT→DSDT/FACS) with no interpreter, so early arch code can acpi_get_table()/acpi_table_parse() the fixed tables immediately.</li><li><strong>The FADT is the gateway to DSDT and FACS.</strong> acpi_tb_parse_fadt() normalizes any FADT layout into acpi_gbl_FADT, prefers the 64-bit X_Dsdt/X_FirmwareCtrl, installs the DSDT (checksummed) and FACS (no checksum, skipped on hardware-reduced).</li><li><strong>Early parsing configures the machine without AML.</strong> MADT → CPUs + interrupt controllers (x86 LAPIC/IOAPIC; arm64 GICC/GICD/GICR/ITS), FADT → SCI/PM-timer/ flags, GTDT → arm64 timers, HPET → x86 timer, SRAT/SLIT → NUMA nodes and the numa_distance[] matrix via numa_set_distance().</li><li><strong>Namespace loading is two-pass.</strong> DSDT then SSDTs are merged into the single \-rooted tree; Pass 1 creates all names (handling forward references), Pass 2 resolves operands/fields. Control-method bodies are not executed at load time — only on demand later.</li><li>acpi_enable() flips the platform into ACPI mode by writing SMI_CMD and polling SCI_EN; from then the OS (via the SCI + GPEs) owns power management. Hardware-reduced platforms (most arm64) skip this — ACPI mode is implicit.</li><li><strong>The namespace becomes devices.</strong> _SB_ is the device root; acpi_scan_init() evaluates _STA/_HID/_CRS per Device node and creates Linux acpi_devices under /sys/bus/acpi/devices/, which drivers then bind to.</li><li><strong>You can see all of it.</strong> acpidump + iasl -d reconstructs the exact Device/Method/Name/OperationRegion tree; /sys/bus/acpi/devices/ shows the enumerated result; acpiexec replays the ACPICA namespace in userspace.</li></ol><h3>References</h3><p><strong>ACPI specification</strong></p><ol><li>ACPI Specifications (UEFI Forum) — <a href="https://uefi.org/acpi/specs">https://uefi.org/acpi/specs</a></li><li>ACPI Spec 6.4, full text (HTML) — <a href="https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/">https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/</a></li></ol><p><strong>ACPICA (reference AML interpreter, used directly by Linux)</strong><br> 3. ACPICA documentation &amp; user guide (Intel) — <a href="https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html">https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html</a><br> 4. ACPICA source (GitHub) — <a href="https://github.com/acpica/acpica">https://github.com/acpica/acpica</a></p><p><strong>Linux ACPI implementation</strong><br> 5. Linuxized ACPICA — how Linux syncs with upstream ACPICA — <a href="https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html">https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html</a><br> 6. Linux kernel ACPI driver-api docs — <a href="https://docs.kernel.org/driver-api/acpi/index.html">https://docs.kernel.org/driver-api/acpi/index.html</a><br> 7. Linux kernel source, drivers/acpi — <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi</a></p><p><strong>Windows internals</strong><br> 8. Windows Driver Kit — Kernel-Mode Driver Architecture — <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/">https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/</a><br> 9. Russinovich, Solomon, Ionescu — <em>Windows Internals</em>, Part 1 (7th ed.) — standard secondary source for undocumented boot/HAL routines like KiSystemStartup, HalInitSystem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=379984111d05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Windows Finds and Consumes the ACPI Tables UEFI Built - A Deep Dive]]></title>
            <link>https://medium.com/@kushaldps1996/how-windows-finds-and-consumes-the-acpi-tables-uefi-built-a-deep-dive-a9f6b2879a61?source=rss-20cb97d60801------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9f6b2879a61</guid>
            <dc:creator><![CDATA[KUSHAL CHAKRABORTY]]></dc:creator>
            <pubDate>Mon, 03 Aug 2026 18:27:48 GMT</pubDate>
            <atom:updated>2026-08-03T18:27:48.931Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>The Windows companion to the firmware-side story. Where the UEFI document ended with the RSDP sitting in the EFI System Configuration Table, this document traces the Windows side: how the Windows Boot Manager / Windows OS Loader discover the RSDP, how ntoskrnl.exe, the HAL, and ACPI.sys walk the table chain, map it, validate it, and what happens when tables are broken or must be overridden.</blockquote><blockquote>Applies to Windows on UEFI (x64 and ARM64). Where behavior is documented publicly it is stated as such; where it is inferred from Windows’ architecture, debugger symbols, and observable behavior (Windows is closed-source), it is flagged as [inferred]. Legacy BIOS paths are historical context only.</blockquote><h3>Table of Contents</h3><ol><li><a href="https://gist.github.com/#1-introduction">Introduction</a></li><li><a href="https://gist.github.com/#2-exitbootservices--the-point-of-no-return">ExitBootServices() — The Point of No Return</a></li><li><a href="https://gist.github.com/#3-efi-memory-types-relevant-to-acpi">EFI Memory Types Relevant to ACPI</a></li><li><a href="https://gist.github.com/#4-the-efi-system-configuration-table">The EFI System Configuration Table</a></li><li><a href="https://gist.github.com/#5-rsdp-discovery-in-windows">RSDP Discovery in Windows</a></li><li><a href="https://gist.github.com/#6-acpi-table-pointer-chain-walkthrough">ACPI Table Pointer Chain Walkthrough</a></li><li><a href="https://gist.github.com/#7-physical--virtual-memory-mapping">Physical → Virtual Memory Mapping</a></li><li><a href="https://gist.github.com/#8-what-happens-if-tables-are-corrupt">What Happens if Tables Are Corrupt?</a></li><li><a href="https://gist.github.com/#9-key-takeaways--handoff-diagram">Key Takeaways + Handoff Diagram</a></li></ol><h3>1. Introduction</h3><h3>1.1 The fundamental question: how does Windows find ACPI tables that UEFI built?</h3><p>The firmware (companion document) built a tree of ACPI tables in physical DRAM and left a single breadcrumb: the RSDP (Root System Description Pointer) registered in the EFI System Configuration Table under a well-known GUID. Everything Windows does with ACPI hangs off finding that one pointer - exactly as on any other UEFI OS. What differs is who does the finding and which components parse and consume it.</p><p>The Windows discovery/handoff chain:</p><pre>Firmware left:  gST-&gt;ConfigurationTable[i] = { EFI_ACPI_20_TABLE_GUID, &amp;RSDP }<br>                                                                        │<br> Windows must:   1. Windows Boot Manager (bootmgfw.efi) runs as UEFI app,<br>                    has gST, reads config table.<br>                 2. Windows OS Loader (winload.efi) collects firmware data<br>                    into the LOADER_PARAMETER_BLOCK before ExitBootServices().<br>                 3. ntoskrnl.exe + HAL consume the RSDP from the loader block.<br>                 4. ACPI.sys (the ACPI bus/PnP driver) parses DSDT/SSDT,<br>                    builds the ACPI namespace, runs the AML interpreter.<br>                 5. PnP enumerates devices from the namespace.</pre><p>The critical insight is identical to the Linux case but the vocabulary is Microsoft’s: on UEFI, Windows does NOT scan low memory for &quot;RSD PTR &quot;. The loader reads the RSDP address from the EFI configuration table while Boot Services are alive and passes it forward in the Loader Parameter Block. Legacy EBDA/ROM scanning only ever applied to BIOS boots.</p><p>The Windows actors and their ACPI responsibilities:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5fa1c9410d0c96ac54b88f2053fa8ab/href">https://medium.com/media/d5fa1c9410d0c96ac54b88f2053fa8ab/href</a></iframe><p>The rest of this document walks that pipeline end to end, mapping each classic<em> “how does the OS do X”</em> question to its Windows mechanism.</p><h3>2. ExitBootServices() - The Point of No Return</h3><h3>2.1 What happens when ExitBootServices() is called</h3><p>ExitBootServices() is a UEFI firmware service, so the semantics are identical regardless of OS - what changes is that on Windows it is winload.efi that calls it (not GRUB, not an EFI stub inside the kernel). When winload.efi calls gBS-&gt;ExitBootServices(ImageHandle, MapKey):</p><ul><li><strong>Boot Services become invalid.</strong> gBS and all boot-services-only protocols are torn down. gRT (Runtime Services) survives and Windows keeps a pointer to it (surfaced later as HalEfiRuntimeServicesTable / used by ExGetFirmwareEnvironmentVariable → GetVariable).</li><li><strong>Firmware stops touching memory it handed away.</strong> EfiBootServicesCode/Data become reusable; ACPI regions (EfiACPIReclaimMemory, EfiACPIMemoryNVS) are frozen and preserved for the OS.</li><li><strong>The memory map is finalized.</strong> The MapKey passed must match the latest GetMemoryMap(); otherwise EFI_INVALID_PARAMETER and the loader must re-fetch and retry. winload.efi implements the same &quot;get map → immediately exit, retry once&quot; pattern every UEFI loader must.</li><li><strong>Watchdog + firmware timers stop</strong>; no further DXE/BDS drivers run.</li><li><strong>After this, ACPI is completely static</strong>; the physical addresses are valid for the life of the OS session (subject to the reclaim caveat in section 3).</li></ul><p>From this instant, Windows - specifically winload.efi transferring into ntoskrnl.exe -owns the machine, and the only firmware surface left is Runtime Services and the frozen ACPI/SMBIOS/etc. tables.</p><h3>2.2 What the OS bootloader does before calling it</h3><p>On Windows the “bootloader” is a two-stage affair, both PE/COFF UEFI applications signed under Secure Boot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uc4NRYCcPLoPmuKEvRVOdw.jpeg" /></figure><p><strong>Key ACPI point:</strong> like every UEFI OS, <strong>Windows captures the RSDP while Boot Services are alive</strong> (step 2) and forwards it in the <strong>Loader Parameter Block</strong>, so the kernel never has to touch the EFI config table itself. On Windows the vehicle is the LOADER_PARAMETER_BLOCK and its LOADER_PARAMETER_EXTENSION (which carries an AcpiTable pointer/size and firmware information) rather than a Linux boot_params. [<strong>inferred from public debugger symbols / WDK structures</strong>]</p><h3>2.3 GetMemoryMap() - snapshot of all memory</h3><p>winload.efi calls gBS-&gt;GetMemoryMap() for the same reason any loader does - to obtain the <strong>authoritative list of physical ranges and their EFI memory types</strong>, which becomes the seed for Windows&#39; own memory bookkeeping.</p><pre>EFI_STATUS GetMemoryMap (<br>  IN OUT UINTN                 *MemoryMapSize,<br>  IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,       // array of descriptors<br>  OUT    UINTN                 *MapKey,          // token for ExitBootServices()<br>  OUT    UINTN                 *DescriptorSize,  // stride - may exceed struct size!<br>  OUT    UINT32                *DescriptorVersion<br>  );<br><br>typedef struct {<br>  UINT32                Type;            // EfiACPIReclaimMemory, EfiACPIMemoryNVS, ...<br>  EFI_PHYSICAL_ADDRESS  PhysicalStart;<br>  EFI_VIRTUAL_ADDRESS   VirtualStart;<br>  UINT64                NumberOfPages;   // 4KiB pages<br>  UINT64                Attribute;       // EFI_MEMORY_WB / UC / RUNTIME / ...<br>} EFI_MEMORY_DESCRIPTOR;</pre><p>What Windows does with it:</p><ul><li>winload.efi <strong>translates the EFI memory map into the NT </strong><strong>MEMORY_ALLOCATION_DESCRIPTOR</strong> list hanging off the Loader Parameter Block (LoaderBlock-&gt;MemoryDescriptorListHead). Each EFI type maps to an NT TYPE_OF_MEMORY (LoaderXxx) value - e.g. EfiACPIReclaimMemory --&gt; LoaderAcpiReclaimMemory [inferred], EfiACPIMemoryNVS --&gt; LoaderSpecialMemory / firmware-permanent, EfiConventionalMemory --&gt; LoaderFree.</li><li>The NT <strong>memory manager</strong> (Mm) later consumes this list in MmInitSystem phase 0 to build the PFN database and decide which physical ranges are usable RAM vs. reserved-for-firmware vs. ACPI.</li><li>The same DescriptorSize-not-sizeof iteration rule applies :winload strides by the firmware-reported descriptor size.</li><li>The returned MapKey must be the one handed to ExitBootServices(); any allocation in between invalidates it, so winload fetches the map immediately before exiting and retries once on mismatch.</li></ul><p>Net result by the time KiSystemStartup runs: Windows already has a native memory descriptor list in which ACPI-typed ranges are tagged, plus a Loader Parameter Block containing the RSDP.</p><h3>3. EFI Memory Types Relevant to ACPI</h3><p>The EFI memory type of a region dictates whether Windows may reuse it, must preserve it, or must keep it mapped for firmware/runtime. The same four EFI types matter; the difference is how the NT memory manager classifies and treats them.</p><h3>3.1 EfiACPIReclaimMemory (type 9) : what it contains, can Windows free it?</h3><ul><li><strong>Contains:</strong> the bulk of ACPI tables : RSDT, XSDT, FADT, MADT/GTDT, MCFG, SPCR, DSDT, SSDTs, etc. (Often the RSDP too.)</li><li><strong>Can Windows free it?</strong> By the UEFI contract, yes - <em>after</em> the OS has parsed and copied out what it needs. winload tags these ranges as LoaderAcpiReclaimMemory [<strong>inferred</strong>] in the NT descriptor list.</li><li><strong>Windows reality:</strong> Windows, like other OSes, is conservative. ACPI.sys keeps the DSDT/SSDTs referenced for the life of the session (the AMLI interpreter executes control methods at runtime and can load tables dynamically), so those regions stay reserved. After boot the memory manager may reclaim genuinely unused LoaderAcpiReclaimMemory pages into the free list, but tables in active use are retained. In practice you should treat active ACPI tables as effectively permanent for the session.</li></ul><h3>3.2 EfiACPIMemoryNVS (type 10) : what it contains, must NEVER be freed</h3><ul><li><strong>Contains:</strong> the FACS (waking vector, global lock), ACPI hardware regions the firmware/hardware read or write at runtime, and any region referenced by DSDT OperationRegions that must persist across sleep (S3/S4).</li><li><strong>Must NEVER be freed or reused.</strong> “NVS” = Non-Volatile Sleeping. Windows marks these ranges permanently reserved (mapped as firmware/LoaderSpecialMemory equivalents) and preserves them across sleep transitions. The Windows power manager relies on the FACS waking vector for legacy S3 resume; corrupting NVS would break suspend/resume or crash the machine.</li><li>Reflected in the memory map that tools like RAMMap show as reserved; never handed to the page allocator.</li></ul><h3>3.3 EfiRuntimeServicesData : RSDP on some platforms</h3><ul><li>Some firmware places the <strong>RSDP</strong> (and occasionally certain tables) in EfiRuntimeServicesData, which survives ExitBootServices() and is mapped into the OS&#39;s runtime address space via SetVirtualAddressMap().</li><li><strong>Why it matters for Windows:</strong> winload must find the RSDP regardless of which memory type it lands in - reclaim, NVS, or runtime-services. That is precisely why Windows uses the <strong>GUID-based config-table lookup</strong> (which returns a raw physical address independent of memory type) rather than assuming a fixed region. Windows also consumes Runtime Services memory to keep UEFI variable and time services callable at runtime (ExGetFirmwareEnvironmentVariable).</li><li>On ARM64, the RSDP typically lives in EfiACPIReclaimMemory, but Windows treats the config-table pointer captured by winload as the source of truth either way.</li></ul><h3>3.4 Practical implications for Windows memory management</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QBvwG1AmaPVR5UpsF-7sLg.jpeg" /></figure><p>Consequences (Windows-specific):</p><ul><li>A firmware bug placing a live ACPI table in EfiBootServicesData is dangerous: Windows will reuse that RAM after ExitBootServices() and the table becomes garbage. Windows generally trusts the memory map and does not have the same breadth of &quot;reserve boot services&quot; quirks Linux accumulated, so such firmware bugs tend to manifest as ACPI_BIOS_ERROR bugchecks or device enumeration failures.</li><li>Because reclaim memory <em>can</em> be reclaimed, ACPI.sys copies/references what it needs; DSDT/SSDT remain live, so those pages stay reserved.</li><li>The NT MEMORY_ALLOCATION_DESCRIPTOR list built by winload from the EFI map is the seed for Mm&#39;s PFN database — a wrong EFI type there propagates into every downstream Windows memory decision, exactly as e820 does on Linux.</li></ul><h3>4. The EFI System Configuration Table</h3><h3>4.1 What it is and where it lives</h3><p>This is pure UEFI, so it is identical to the Linux document — the difference is only which Windows component reads it. <strong>The EFI System Table</strong> (gST) contains an array of configuration tables:</p><pre>typedef struct {<br>  EFI_TABLE_HEADER               Hdr;<br>  ...<br>  EFI_RUNTIME_SERVICES          *RuntimeServices;   // survives ExitBootServices<br>  EFI_BOOT_SERVICES             *BootServices;       // gone after ExitBootServices<br>  UINTN                          NumberOfTableEntries;<br>  EFI_CONFIGURATION_TABLE       *ConfigurationTable;  // &lt;-- the array<br>} EFI_SYSTEM_TABLE;</pre><pre>typedef struct {<br>  EFI_GUID   VendorGuid;     // WHAT this entry is (ACPI, SMBIOS, ...)<br>  VOID      *VendorTable;    // physical pointer to the thing (e.g., the RSDP)<br>} EFI_CONFIGURATION_TABLE;</pre><p>It is a flat list of {GUID, pointer} pairs (ACPI, SMBIOS, SMBIOS3, memory attributes, properties, ARM device tree, etc.) and it <strong>survives</strong> ExitBootServices(). On Windows, winload.efi is the component that walks it; the NT kernel does not re-read it (it reads the RSDP from the loader block).</p><h3>4.2 gEfiAcpiTableGuid → RSDP address</h3><ul><li><strong>GUID:</strong> EFI_ACPI_20_TABLE_GUID = 8868E871-E4F1-11D3-BC22-0080C73C8881</li><li><strong>VendorTable:</strong> physical address of the ACPI 2.0+ RSDP (36-byte RSDP with a valid 64-bit XsdtAddress).</li></ul><p>This is the entry winload.efi looks for first on any modern system. It yields the 64-bit XSDT. <strong>Windows requires ACPI 2.0+ on UEFI - </strong>a UEFI Windows install expects this GUID/XSDT to be present. (Windows&#39; hardware requirements have mandated ACPI 2.0+ tables on UEFI since Windows 8/Server 2012.)</p><h3>4.3 gEfiAcpi10TableGuid → ACPI 1.0 RSDP</h3><ul><li><strong>GUID:</strong> ACPI_TABLE_GUID = EB9D2D30-2D88-11D3-9A16-0090273FC14D</li><li><strong>VendorTable:</strong> physical address of a 20-byte ACPI 1.0 RSDP pointing only to the 32-bit RSDT.</li></ul><p>Present for legacy compatibility. On UEFI, Windows strongly prefers the 2.0 GUID / XSDT; the 1.0 GUID / RSDT path is effectively a fallback that modern UEFI Windows does not rely on (and on ARM64 the 1.0 GUID / RSDT is not provided — RSDT is deprecated on AArch64, and Windows on ARM requires XSDT).</p><blockquote><strong><em>Preference order (winload):</em></strong><em> ACPI 2.0 GUID (→ XSDT) first; ACPI 1.0 GUID (→ RSDT) only if 2.0 is absent - and on a UEFI Windows system 2.0 is expected to be present.</em></blockquote><h3>4.4 How the Windows Boot Manager / winload passes this to the kernel</h3><p>Windows has no GRUB/systemd-boot; the equivalents are bootmgfw.efi (Boot Manager) and winload.efi (OS Loader). The handoff:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0qpY6yqCr8RZB27HG16KVw.jpeg" /></figure><ul><li>Neither bootmgfw.efi nor winload.efi uses boot_params; the <strong>Loader Parameter Block</strong> (LOADER_PARAMETER_BLOCK, defined in the WDK / visible in public symbols) is the Windows equivalent, and its LOADER_PARAMETER_EXTENSION carries the ACPI RSDP pointer and firmware info. [<strong>inferred from public symbols</strong>]</li><li><strong>Secure Boot:</strong> bootmgfw.efi and winload.efi are Microsoft-signed; the chain of trust is enforced by firmware, but it does not change ACPI discovery.</li><li><strong>The BCD store</strong> (not a config-table thing) can carry ACPI-relevant options ({bootmgr}/{default} elements) : see section 8 for bcdedit knobs.</li></ul><p>By the time ntoskrnl.exe starts, it has the RSDP address in the loader block and does not need to (and does not) re-walk the EFI configuration table.</p><h3>5. RSDP Discovery in Windows</h3><p>On Windows the “discovery” is split: winload.efi <strong>finds the RSDP</strong> (from the EFI config table) and stashes it, then the <strong>kernel/HAL/ACPI.sys read it back from the Loader Parameter Block</strong>. There is no ACPICA equivalent because Windows uses its own ACPI stack (HAL + ACPI.sys + the AMLI interpreter).</p><h3>5.1 winload reading the EFI config table (the Windows efi_get_rsdp_addr analog)</h3><p>The Linux efi_get_rsdp_addr() / efi_config_parse_tables() role is played by winload.efi&#39;s firmware-enumeration code (internal, closed-source). Behaviorally:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yz-Y7qr2fQ7AZie2vK1sTQ.jpeg" /></figure><p>The kernel-side retrieval (what actually consumes it):</p><ul><li><strong>HAL / kernel:</strong> during early init the HAL’s ACPI support reads the RSDP/root tables via the loader block. The internal routine historically referenced in symbols/DDK lore is HalpAcpiGetTable / HalAcpiGetTable [<strong>inferred</strong>], which returns a pointer to a named ACPI table by 4-byte signature. This is the Windows analog of ACPICA&#39;s acpi_get_table().</li><li><strong>Public/driver-visible API:</strong> kernel-mode drivers retrieve ACPI (and other firmware) tables via AuxKlibGetSystemFirmwareTable or the modern EX-level path, and user mode uses EnumSystemFirmwareTables / GetSystemFirmwareTable with provider &#39;ACPI&#39; (0x41435049). These are the <em>documented</em> Windows equivalents of &quot;read an ACPI table.&quot;</li></ul><h3>5.2 Legacy x86 BIOS method (EBDA scan) - historical context</h3><p>On legacy BIOS boots (pre-UEFI, using ntldr→bootmgr→winload.exe), there was no EFI config table, so the low-level firmware code had to scan physical memory for the &quot;RSD PTR &quot; signature - the same algorithm as every other OS:</p><pre>Legacy RSDP scan (x86 BIOS only):<br>   1. Read the EBDA (Extended BIOS Data Area) segment from the word at 0x40E,<br>      scan the first 1 KiB on 16-byte boundaries for &quot;RSD PTR &quot;.<br>   2. Else scan the BIOS ROM area 0x000E0000–0x000FFFFF on 16-byte boundaries.<br>   3. Validate signature + checksum for each candidate.</pre><ul><li>Windows performed the equivalent scan in its HAL ACPI init on BIOS systems.</li><li><strong>x86-only, legacy-BIOS-only.</strong> ARM64 has no EBDA/BIOS ROM region; UEFI Windows bypasses this entirely in favor of the config-table pointer captured by winload.efi.</li><li>Modern Windows (UEFI-only on ARM64, and UEFI+Secure-Boot required for Windows 11 even on x64) does not use this path in normal operation.</li></ul><h3>5.3 The Windows “entry function” - HAL/ACPI.sys table lookup (analog of acpi_find_root_pointer)</h3><p>Windows has no single acpi_find_root_pointer(); the responsibility is layered:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*geuJ3D4aLHZuKleFdpz26A.jpeg" /></figure><p>Decision tree Windows effectively follows (winload side):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MslEfEnAq-sw5iCvq9IfDw.jpeg" /></figure><p>Once the RSDP physical address is chosen and stored, the HAL takes over parsing (next section).</p><h3>6. ACPI Table Pointer Chain Walkthrough</h3><p>The pointer chain is defined by the ACPI specification, so it is byte-for-byte the same tree the Linux document describes; only the <strong>Windows components</strong> that walk it differ. On Windows the HAL builds the initial table cache and <strong>ACPI.sys</strong> consumes DSDT/SSDT for the namespace.</p><h3>6.1 RSDP → XSDT → every table</h3><p>The HAL’s ACPI phase-0 code (HalpSetupAcpiPhase0 / HalpAcpiTableCacheInit [inferred]) performs the equivalent of ACPICA&#39;s acpi_tb_parse_root_table():</p><pre>1. Map the RSDP (physical → virtual).<br> 2. If RSDP.Revision &gt;= 2 and RSDP.XsdtAddress != 0:<br>        use XSDT, entry size = 8 bytes            [preferred on all modern systems]<br>    else:<br>        use RSDT, entry size = 4 bytes            [legacy]<br> 3. Map the XSDT/RSDT header; read Length.<br>        entry_count = (Length - sizeof(header)) / entry_size<br> 4. For each entry:<br>        read the 8-byte (XSDT) / 4-byte (RSDT) physical pointer<br>        map the target table&#39;s header<br>        validate signature + length, verify checksum<br>        insert into the HAL&#39;s signature-indexed table cache<br> 5. Special-case the FADT to reach DSDT and FACS (see 6.3).</pre><p>The result is an internal cache so that HalAcpiGetTable(&#39;APIC&#39;), ...(&#39;MCFG&#39;), ...(&#39;DSDT&#39;) etc. return a mapped pointer on demand — this is what ACPI.sys and other kernel components call. [inferred]</p><h3>6.2 XSDT vs RSDT - why 64-bit matters</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff5323beab6fb1f93a4ddbf553ff6ad4/href">https://medium.com/media/ff5323beab6fb1f93a4ddbf553ff6ad4/href</a></iframe><p>Why 64-bit matters (Windows perspective):</p><ul><li>On large-memory systems firmware may place ACPI tables <strong>above 4 GiB</strong>; only the XSDT’s 8-byte entries can encode those addresses. A 32-bit RSDT entry would truncate, and the HAL would map garbage.</li><li>Windows on UEFI <strong>requires ACPI 2.0+</strong>, so the HAL uses the <strong>XSDT</strong> whenever RSDP.Revision &gt;= 2 and XsdtAddress is valid - which is always, on a compliant UEFI Windows platform.</li><li>On ARM64, <strong>RSDT is forbidden</strong> and XSDT is mandatory; Windows on ARM will not accept an RSDT-only configuration.</li><li>If both RSDT and XSDT exist they must enumerate the same tables; Windows trusts the XSDT.</li></ul><h3>6.3 FADT → DSDT → FACS special chain</h3><p>The FADT (signature &quot;FACP&quot;) is a normal XSDT entry, but it is the only route to two tables that are not in the XSDT:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TmElE342bRV8vV-8K874JQ.jpeg" /></figure><p>Windows behavior in this chain:</p><ul><li><strong>DSDT</strong> is located via FADT.X_Dsdt (preferred) or FADT.Dsdt. The HAL hands the DSDT to ACPI.sys, whose AMLI interpreter loads it as the root of the ACPI namespace (\, \_SB, \_PR/\_SB.Pr, \_GPE, \_TZ, \_SI).</li><li><strong>FACS</strong> is located via FADT.X_FirmwareCtrl (preferred) or FADT.FirmwareCtrl. Windows’ power manager uses the FACS firmware waking vector for legacy S3 resume and the <strong>global lock</strong> for arbitration with firmware over shared hardware (e.g., embedded controller regions). The FACS has no checksum and is not validated by checksum.</li><li><strong>Hardware-reduced ACPI</strong> (FADT HW_REDUCED_ACPI flag, common on ARM64 and modern x64 with connected-standby): no FACS and no legacy sleep registers; Windows uses the _S*/firmware-defined sleep (on ARM, PSCI) instead, and the FADT FACS pointers are 0.</li><li><strong>64-bit precedence:</strong> non-zero X_Dsdt/X_FirmwareCtrl win over the 32-bit fields, matching the spec.</li></ul><h3>6.4 Diagram: complete pointer chain (Windows components annotated)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CW2HH7hWxgAErpBOm704nw.jpeg" /></figure><p>Everything in the XSDT (plus DSDT/FACS via the FADT) ends up in the HAL’s table cache; DSDT/SSDT additionally feed the ACPI.sys namespace.</p><h3>7. Physical → Virtual Memory Mapping</h3><p>Everything discovered is <strong>physical addresses</strong>; the NT kernel runs with paging on and can only dereference <strong>virtual addresses</strong>. Windows must map each table before reading it. The Linux acpi_os_map_memory() role is played by the NT <strong>memory manager</strong> primitives used by the HAL and ACPI.sys.</p><h3>7.1 The Windows analog of acpi_os_map_memory() - why we need virtual addresses</h3><p>Windows has no ACPICA OS layer; instead the HAL/ACPI.sys use NT memory-manager APIs to obtain virtual mappings of physical ACPI ranges:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d50aaf173cdd900f3a4ff9e09791fe80/href">https://medium.com/media/d50aaf173cdd900f3a4ff9e09791fe80/href</a></iframe><p>Why mapping is required (same reasoning as Linux, Windows vocabulary):</p><ul><li>Paging is on from very early in KiSystemStartup; a raw PHYSICAL_ADDRESS is not dereferenceable.</li><li>ACPI tables live in reserved (LoaderAcpiReclaimMemory / NVS) ranges that are not part of the normal nonpaged pool, so they need an explicit mapping - with <strong>cached (write-back) </strong>attributes, because they are memory, not device registers. Using MmNonCached would be wrong and slow.</li><li>The HAL establishes its ACPI table mappings very early (phase 0), before most of the executive exists, then keeps DSDT/FADT and other hot tables mapped for the life of the session; ACPI.sys maps the DSDT/SSDTs it interprets.</li></ul><p>Cleanup counterpart: MmUnmapIoSpace releases a mapping when a table no longer needs to be resident (rarely done for DSDT/FADT, which stay mapped).</p><h3>7.2 How the kernel maps ACPI table regions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8RttF2dAsDMbrxjiTe0tow.jpeg" /></figure><ul><li><strong>Header-first, then full table:</strong> as with any implementation, headers are mapped cheaply to enumerate and validate; tables actually used (DSDT, FADT, MADT) are mapped in full and kept resident.</li><li><strong>Reserved in the PFN database:</strong> ACPI reclaim/NVS ranges are excluded from the general free memory pool by Mm based on the loader descriptor types, so nothing else allocates over a live table.</li><li>You can observe active tables from user mode with GetSystemFirmwareTable(&#39;ACPI&#39;, &lt;TableID&gt;, ...) and enumerate signatures with EnumSystemFirmwareTables(&#39;ACPI&#39;, ...) — these read Windows&#39; cached copies.</li></ul><h3>7.3 Checksum validation: the Windows equivalent of acpi_tb_verify_checksum()</h3><p>Windows validates ACPI tables during the HAL’s table-cache build using the same ACPI rule - <strong>the 8-bit sum of every byte in the table must be 0 - </strong>via an internal routine (no public name; conceptually HalpAcpiTableChecksum / HalpValidateAcpiTable [<strong>inferred</strong>]):</p><pre>// Conceptual equivalent of the Windows internal checksum check:<br>UINT8 AcpiTableChecksum(UINT8 *Table, ULONG Length) {<br>    UINT8 Sum = 0;<br>    for (ULONG i = 0; i &lt; Length; i++)<br>        Sum = (UINT8)(Sum + Table[i]);   // 8-bit wrapping add<br>    return Sum;                          // 0 == valid<br>}<br>// Table is accepted iff AcpiTableChecksum(Table, Table-&gt;Length) == 0</pre><p>Key facts (Windows):</p><ul><li><strong>RSDP is validated specially:</strong> signature &quot;RSD PTR &quot;, the first-20-byte checksum, and (rev ≥ 2) the extended_checksum over the full 36-byte length.</li><li><strong>FACS is exempt</strong> - it has no checksum field, so it is accepted without a checksum test.</li><li><strong>Windows is stricter than Linux by default.</strong> Where Linux logs a warning and continues on a bad checksum, Windows treats critical-table corruption (bad FADT/DSDT/XSDT/RSDP checksum, missing required tables) as fatal — it bugchecks with ACPI_BIOS_ERROR (0xA5) rather than silently proceeding. There is no general &quot;ignore checksums&quot; switch equivalent to Linux&#39;s acpi=nochecksums (see §8).</li></ul><h3>8. What Happens if Tables Are Corrupt?</h3><h3>8.1 Bad checksum / corruption handling</h3><p>Windows is markedly less tolerant than Linux. Where Linux warns-and-continues, Windows tends to fail the boot with a bugcheck when core ACPI data is invalid, because the OS assumes a compliant, WHCP-tested firmware:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uXS5IDdNagSCwgcOx0jpyA.jpeg" /></figure><p>The canonical failure bugcheck is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0a3dc8f48a6bf4f8f57a3f13512628e/href">https://medium.com/media/d0a3dc8f48a6bf4f8f57a3f13512628e/href</a></iframe><p>Contrast with Linux’s ACPI: Incorrect checksum ... - table still used: Windows does not have an equivalent &quot;use it anyway&quot; default for the critical tables.</p><h3>8.2 The Windows analog of acpi=nochecksums</h3><p><strong>There is no supported Windows switch that disables ACPI checksum validation.</strong> Windows’ philosophy is that firmware must pass Microsoft’s hardware compatibility testing (WHCP/HLK) and be correct; a bad table is a firmware bug to be fixed, not tolerated at runtime. The closest Windows knobs are BCD and testing options - none of which is a true checksum bypass:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd89839f5c2ba7a2e6c1957a1e488752/href">https://medium.com/media/bd89839f5c2ba7a2e6c1957a1e488752/href</a></iframe><blockquote><strong><em>Bottom line: </em></strong><em>to “fix” a bad checksum on Windows you fix the </em>firmware<em> (or override the table via the mechanisms in section 8.3) - you cannot tell Windows to ignore it the way </em><em>acpi=nochecksums does on Linux.</em></blockquote><h3>8.3 DSDT / table override mechanisms on Windows</h3><p>Windows offers far fewer end-user override paths than Linux (no CONFIG_ACPI_CUSTOM_DSDT, no initrd table-upgrade). The supported/known mechanisms:</p><h4>8.3.1 Registry-based DSDT override (the Windows compile-time analog)</h4><p>Windows supports loading a replacement DSDT from the <strong>registry</strong> instead of the firmware DSDT - the historical analog of Linux’s CONFIG_ACPI_CUSTOM_DSDT:</p><pre>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ACPI\Parameters<br>     Value:  DSDT   (REG_BINARY)  = &lt;raw AML bytes of the replacement DSDT&gt;</pre><ul><li>When present and valid, <strong>ACPI.sys</strong> uses this DSDT instead of the firmware’s.</li><li>Documented by Microsoft primarily as an <strong>OEM/pre-production</strong> <strong>and debugging facility</strong>; on production systems it is gated by Secure Boot / driver-signing and is not a casual end-user tweak.</li><li>This is a <strong>DSDT-only</strong> override (like the Linux compile-time option), not a general table-append facility.</li></ul><h4>8.3.2 Injecting tables/methods via a driver (the practical modern path)</h4><p>Rather than replace the firmware DSDT, the Windows-idiomatic way to add ACPI behavior is to supply an <strong>ACPI-related driver</strong> / device through the normal driver model:</p><ul><li>An INF-installed function/filter driver on the ACPI device stack can provide the device behavior that a missing/broken AML object would have described.</li><li>Vendors ship <strong>firmware updates (UEFI capsule updates)</strong> to fix the DSDT/SSDT at the source - on Windows this is the <em>expected</em> remedy for broken AML, delivered through Windows Update / the Firmware device class, because the OS itself won&#39;t tolerate or hand-patch bad tables.</li></ul><h4>8.3.3 Runtime / dynamic tables - the Windows analog of /sys/firmware/acpi/tables/dynamic/</h4><p>Windows has <strong>no sysfs</strong>, so there is no /sys/firmware/acpi/tables/dynamic/ directory. The equivalent capabilities are exposed through APIs and the AML interpreter:</p><ul><li><strong>Enumerate/read active tables (user mode):</strong></li></ul><pre>// Provider ‘ACPI’ == 0x41435049 <br>UINT n = EnumSystemFirmwareTables(‘ACPI’, pBuffer, cb); // list table IDs <br>UINT s = GetSystemFirmwareTable(‘ACPI’, ‘TDSS’ /*e.g. SSDT id*/, pTable, cb);</pre><ul><li>This is the closest Windows analog to reading /sys/firmware/acpi/tables/*: you get Windows&#39; cached copy of each active table (including SSDTs).</li><li><strong>Kernel mode:</strong> AuxKlibGetSystemFirmwareTable returns the same data to drivers.</li><li><strong>Dynamically loaded SSDTs:</strong> AML Load/LoadTable operators executed by the AMLI interpreter can load additional SSDTs into the namespace at runtime (e.g., for hot-plug, docking, or \_SB object additions). Windows tracks these internally; they surface through the same GetSystemFirmwareTable enumeration and can be inspected in the kernel debugger with !amli (dump namespace, !amli dns \_SB, set breakpoints on methods) and !acpikd extensions.</li><li><strong>Debugging tools</strong> that stand in for Linux’s sysfs dump:</li></ul><p>i) Get-WmiObject -Namespace root\wmi -Class MSAcpi_* (WMI ACPI classes).</p><p>ii) Sysinternals / third-party (RWEverything, ACPITool) to dump tables.</p><p>iii) acpidump-style extraction then iasl -d to disassemble (iasl is cross-platform) - the analysis workflow is the same even though the <em>override</em> path differs.</p><blockquote><strong><em>Override selection summary (Windows):</em></strong><em> registry </em><em>DSDT value for a full DSDT replacement (OEM/debug, signing-gated); a signed driver on the ACPI stack to add device behavior; and a firmware capsule update as the production fix for bad AML. Runtime inspection is via </em><em>GetSystemFirmwareTable/WMI and the </em><em>!amli / </em><em>!acpikd debugger extensions - there is no writable </em><em>dynamic/ filesystem node.</em></blockquote><h3>9. Key Takeaways + Handoff Diagram</h3><h3>9.1 Key takeaways (Windows)</h3><ol><li><strong>Same breadcrumb, Windows plumbing.</strong> Firmware leaves the RSDP in the EFI System Configuration Table under EFI_ACPI_20_TABLE_GUID. On Windows, winload.efi reads it while Boot Services are alive and forwards it in the <strong>Loader Parameter Block</strong> - the kernel never re-walks the config table.</li><li><strong>Two-stage loader</strong>. bootmgfw.efi (Boot Manager, reads BCD, selects entry) → winload.efi (OS Loader, collects firmware data, builds the loader block, calls ExitBootServices(), transfers to ntoskrnl!KiSystemStartup). No GRUB/EFI-stub.</li><li><strong>ExitBootServices() is still the point of no return</strong> and it is winload that calls it: reclaim/NVS frozen, gBS gone, gRT retained (ExGetFirmwareEnvironmentVariable), memory map finalized via MapKey.</li><li><strong>Memory type → NT loader type.</strong> winload translates the EFI map into MEMORY_ALLOCATION_DESCRIPTORs (LoaderAcpiReclaimMemory, firmware-permanent for NVS, etc.); Mm builds the PFN DB from it. Reclaim is reclaimable in theory but kept while DSDT/SSDT are live; NVS/FACS never freed; RSDP may be in reclaim, NVS, or runtime-services memory - hence the GUID lookup, not a type scan.</li><li><strong>Windows requires ACPI 2.0+ / XSDT on UEFI.</strong> Prefer EFI_ACPI_20_TABLE_GUID → XSDT (8-byte entries, tables anywhere in 64-bit space). RSDT/1.0 GUID is a legacy fallback; forbidden on ARM64. X_Dsdt/X_FirmwareCtrl win over 32-bit fields.</li><li><strong>The Windows ACPI stack = HAL + ACPI.sys + AMLI.</strong> The HAL builds a signature-indexed table cache (analog of acpi_get_table, exposed as HalAcpiGetTable [inferred]); ACPI.sys loads DSDT/SSDT and its AMLI interpreter runs control methods and builds the namespace; PnP enumerates devices from it.</li><li><strong>DSDT and FACS are off the XSDT </strong>- reached only via FADT fields. Windows’ power manager uses the FACS waking vector/global lock for legacy S3; FACS has no checksum. Hardware-reduced ACPI (ARM64, modern x64) drops FACS entirely.</li><li><strong>Mapping uses NT Mm APIs.</strong> MmMapIoSpace(...MmCached) / MmMapLockedPagesSpecifyCache map physical tables to cached (write-back) VA; headers first, hot tables (DSDT/FADT) kept resident. GetSystemFirmwareTable / AuxKlibGetSystemFirmwareTable expose the cached tables to user/kernel mode.</li><li><strong>Windows is strict on corruption.</strong> Bad checksum / missing required table → bugcheck 0xA5 ACPI_BIOS_ERROR, not a warning. There is no acpi=nochecksums equivalent. Fixes: registry DSDT override (OEM/debug, signing-gated), a signed ACPI-stack driver, or — the production path — a UEFI firmware capsule update. Runtime inspection via GetSystemFirmwareTable, WMI MSAcpi_*, and !amli / !acpikd in WinDbg; no writable sysfs dynamic/.</li></ol><h3>9.2 End-to-end handoff diagram (Windows)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iP0ZuvFhB4KYCucmo9ttiQ.jpeg" /></figure><blockquote><strong><em>Note on sourcing:</em></strong><em> Windows is closed-source. Structure names (</em><em>LOADER_PARAMETER_BLOCK, </em><em>LOADER_PARAMETER_EXTENSION), the </em><em>ACPI_BIOS_ERROR bugcheck, the registry </em><em>DSDT override, </em><em>GetSystemFirmwareTable/ </em><em>AuxKlibGetSystemFirmwareTable, WMI </em><em>MSAcpi_*, and the </em><em>!amli/</em><em>!acpikd debugger extensions are publicly documented or visible in public PDB symbols. Internal routine names marked [inferred] (</em><em>HalpSetupAcpiPhase0, </em><em>HalAcpiGetTable, </em><em>HalpAcpiTableCacheInit, etc.) are reconstructed from debugger symbols and Windows Internals literature and may differ across builds; treat them as illustrative of the flow, not as a guaranteed ABI.</em></blockquote><p><strong>Note : </strong>Windows reference: <em>acpi.sys</em> (the ACPI bus/function driver + AMLI interpreter), the PnP manager and I/O manager inside <em>ntoskrnl.exe</em>, the resource arbiters, and subsystem class extensions (<em>pci.sys</em>, <em>SpbCx</em>, <em>GpioClx</em>, <em>msft</em> inbox drivers). Because Windows ACPI internals are largely undocumented, private/internal routine names (prefixed <em>ACPI</em>) reflect reverse-engineering and WDK/debugger symbol conventions; the architecture and the documented DDIs (IRPs, <em>DEVICE_RELATIONS</em>, <em>CM_RESOURCE_LIST</em>, <em>DEVPROPKEY</em>) are firm.</p><h3>References</h3><p><strong>ACPI specification</strong></p><ol><li>ACPI Specifications (UEFI Forum) — <a href="https://uefi.org/acpi/specs">https://uefi.org/acpi/specs</a></li><li>ACPI Spec 6.4, full text (HTML) — <a href="https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/">https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/</a></li></ol><p><strong>ACPICA (reference AML interpreter, used directly by Linux)</strong><br> 3. ACPICA documentation &amp; user guide (Intel) — <a href="https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html">https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html</a><br> 4. ACPICA source (GitHub) — <a href="https://github.com/acpica/acpica">https://github.com/acpica/acpica</a></p><p><strong>Linux ACPI implementation</strong><br> 5. Linuxized ACPICA — how Linux syncs with upstream ACPICA — <a href="https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html">https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html</a><br> 6. Linux kernel ACPI driver-api docs — <a href="https://docs.kernel.org/driver-api/acpi/index.html">https://docs.kernel.org/driver-api/acpi/index.html</a><br> 7. Linux kernel source, drivers/acpi — <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi</a></p><p><strong>Windows internals</strong><br> 8. Windows Driver Kit — Kernel-Mode Driver Architecture — <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/">https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/</a><br> 9. Russinovich, Solomon, Ionescu — <em>Windows Internals</em>, Part 1 (7th ed.) — standard secondary source for undocumented boot/HAL routines like KiSystemStartup, HalInitSystem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9f6b2879a61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How the Linux finds and Consumes ACPI Tables UEFI Built - A Deep Dive]]></title>
            <link>https://medium.com/@kushaldps1996/how-the-linux-finds-and-consumes-acpi-tables-uefi-built-a-deep-dive-ac0cb5b9e055?source=rss-20cb97d60801------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac0cb5b9e055</guid>
            <dc:creator><![CDATA[KUSHAL CHAKRABORTY]]></dc:creator>
            <pubDate>Mon, 03 Aug 2026 18:26:37 GMT</pubDate>
            <atom:updated>2026-08-03T18:26:37.869Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>The companion to the firmware-side story. Where the UEFI document ended with the RSDP sitting in the EFI System Configuration Table, this document picks up at the handoff and traces the OS side: how the bootloader and Linux kernel discover the RSDP, walk the table chain, map it into virtual memory, validate it, and what happens when tables are broken or need to be overridden.</blockquote><blockquote>Applies to Linux on UEFI (x86_64 and ARM64/aarch64). ACPICA internals are common to both. Legacy BIOS paths are called out as historical context only.</blockquote><h3>Table of Contents</h3><ol><li><a href="https://gist.github.com/kushaldps1996-debug/56ce6dc7f3779c15a3f275409de27a58#1-introduction">Introduction</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/56ce6dc7f3779c15a3f275409de27a58#2-exitbootservices--the-point-of-no-return">ExitBootServices() — The Point of No Return</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/56ce6dc7f3779c15a3f275409de27a58#3-efi-memory-types-relevant-to-acpi">EFI Memory Types Relevant to ACPI</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/56ce6dc7f3779c15a3f275409de27a58#4-the-efi-system-configuration-table">The EFI System Configuration Table</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/56ce6dc7f3779c15a3f275409de27a58#5-rsdp-discovery-in-linux">RSDP Discovery in Linux</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/56ce6dc7f3779c15a3f275409de27a58#6-acpi-table-pointer-chain-walkthrough">ACPI Table Pointer Chain Walkthrough</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/56ce6dc7f3779c15a3f275409de27a58#7-physical--virtual-memory-mapping">Physical → Virtual Memory Mapping</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/56ce6dc7f3779c15a3f275409de27a58#8-what-happens-if-tables-are-corrupt">What Happens if Tables Are Corrupt?</a></li><li><a href="https://gist.github.com/kushaldps1996-debug/56ce6dc7f3779c15a3f275409de27a58#9-key-takeaways--handoff-diagram">Key Takeaways + Handoff Diagram</a></li></ol><h3>1. Introduction</h3><h3>1.1 The fundamental question: how does Linux find ACPI tables that UEFI built?</h3><p>The firmware (as covered in the companion document) built a tree of ACPI tables in physical DRAM and left a single breadcrumb: the <strong>RSDP</strong> (Root System Description Pointer) registered in the <strong>EFI System Configuration Table</strong> under a well-known GUID. Everything the OS does with ACPI hangs off finding that one pointer.</p><p>The chain of trust/discovery is deliberately narrow:</p><pre>Firmware left:  gST-&gt;ConfigurationTable[i] = { gEfiAcpiTableGuid, &amp;RSDP }<br>                                                                     │<br> OS must:        1. Get the EFI System Table pointer (from bootloader handoff)<br>                 2. Walk ConfigurationTable[] for the ACPI GUID<br>                 3. Read the RSDP physical address<br>                 4. RSDP --&gt;XSDT --&gt;every other table<br>                 5. Map each table phys--&gt;virt, validate checksums<br>                 6. Parse &amp; drive the hardware</pre><p>The critical insight: <strong>on UEFI systems the OS does NOT scan memory for the </strong><strong>&quot; RSD PTR &quot; signature</strong>. That legacy BIOS behavior (scanning the EBDA and the 0xE0000–0xFFFFF ROM area) is unreliable and unnecessary when firmware has already handed you a typed pointer. The GUID lookup is authoritative.</p><p>Three distinct actors are involved, and it matters which does what:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ecaff0617df97f56b159deb8a69eb701/href">https://medium.com/media/ecaff0617df97f56b159deb8a69eb701/href</a></iframe><p>The rest of this document walks that pipeline end to end.</p><h3>2. ExitBootServices() - The Point of No Return</h3><h3>2.1 What happens when ExitBootServices() is called</h3><p>While UEFI Boot Services are alive, the firmware still owns memory, timers, the watchdog, and driver services. ExitBootServices() is the hard boundary where the OS takes ownership of the machine. Concretely, when the bootloader/EFI-stub calls gBS-&gt;ExitBootServices(ImageHandle, MapKey):</p><ul><li><strong>Boot Services become invalid</strong>. The entire gBS table and every boot-services-only protocol is torn down. Calling any of them afterward is undefined behavior. gRT (Runtime Services) survives.</li><li><strong>Firmware stops touching memory it gave away</strong>. All EfiBootServicesCode and EfiBootServicesData regions become free for the OS to reuse. Crucially, the ACPI regions (EfiACPIReclaimMemory, EfiACPIMemoryNVS) are <strong>frozen and preserved - </strong>the firmware will not move or overwrite them.</li><li><strong>The memory map is finalized.</strong> The MapKey argument must match the current memory map exactly; if firmware changed the map since the last GetMemoryMap(), ExitBootServices() returns EFI_INVALID_PARAMETER and the caller must re-fetch the map and retry (the well-known “call it in a loop, at most twice” pattern).</li><li><strong>The watchdog timer is disabled;</strong> interrupt/timer services stop.</li><li><strong>No more DXE/BDS drivers run</strong>. ACPI is now completely static.</li></ul><p>After this point, the ACPI tables are exactly as firmware left them (plus any BDS-time patching), and their physical addresses are guaranteed valid for the life of the system (with the reclaim caveat in Section 3).</p><h3>2.2 What the OS bootloader does before calling it</h3><p>A UEFI bootloader (or the Linux EFI stub, drivers/firmware/efi/libstub/) does a careful dance <em>before</em> ExitBootServices(), because after it there is no way to ask firmware anything:</p><pre>Bootloader / EFI stub, still in Boot Services:<br>   │<br>   ├─ 1. Load the kernel image + initrd into memory<br>   │<br>   ├─ 2. Query everything it needs from firmware NOW:<br>   │        • Locate RSDP: walk gST-&gt;ConfigurationTable for the ACPI GUID<br>   │        • GOP framebuffer info (for early console)<br>   │        • SMBIOS pointer, device tree (ARM), command line<br>   │        • Any EFI variables needed<br>   │<br>   ├─ 3. Stash those into the kernel handoff structure:<br>   │        x86:   struct boot_params  (setup_data / acpi_rsdp_addr field)<br>   │        ARM64: the &quot;EFI stub&quot; fills a boot protocol / passes via<br>   │               the flattened device tree or efi_entry() globals<br>   │<br>   ├─ 4. GetMemoryMap(&amp;Map, &amp;MapKey)     // snapshot (see 2.3)<br>   │<br>   ├─ 5. ExitBootServices(ImageHandle, MapKey)<br>   │        if EFI_INVALID_PARAMETER → GetMemoryMap again, retry once<br>   │<br>   └─ 6. Jump to the kernel entry with the handoff structure + memory map</pre><p><strong>Key point for ACPI: </strong>the <strong>RSDP address is captured while Boot Services are still up</strong> (step 2) and passed to the kernel explicitly. The Linux EFI stub sets boot_params.acpi_rsdp_addr on x86 so the kernel doesn&#39;t even have to re-walk the config table (though it still can — see Section 5).</p><h3>2.3 GetMemoryMap() - snapshot of all memory</h3><p>gBS-&gt;GetMemoryMap() returns the authoritative description of every physical memory region and its <strong>EFI memory type</strong>. This is <em>the</em> structure that tells the OS which ranges are ACPI tables, which are usable RAM, which are runtime, etc.</p><pre>EFI_STATUS GetMemoryMap (<br>  IN OUT UINTN                 *MemoryMapSize,   // in: buffer size, out: actual size<br>  IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,       // array of descriptors<br>  OUT    UINTN                 *MapKey,          // token for ExitBootServices()<br>  OUT    UINTN                 *DescriptorSize,  // sizeof each entry (may be &gt; struct!)<br>  OUT    UINT32                *DescriptorVersion<br>  );</pre><p>Each EFI_MEMORY_DESCRIPTOR:</p><pre>typedef struct {<br>  UINT32                Type;            // EfiConventionalMemory, EfiACPIReclaimMemory, ...<br>  EFI_PHYSICAL_ADDRESS  PhysicalStart;   // page-aligned<br>  EFI_VIRTUAL_ADDRESS   VirtualStart;    // filled later via SetVirtualAddressMap<br>  UINT64                NumberOfPages;   // 4KiB pages<br>  UINT64                Attribute;       // EFI_MEMORY_WB / UC / RUNTIME / ...<br>} EFI_MEMORY_DESCRIPTOR;</pre><p>Important subtleties:</p><ul><li><strong>Always iterate using </strong>DescriptorSize, <strong>never </strong><strong>sizeof(EFI_MEMORY_DESCRIPTOR)</strong>. Firmware may return larger descriptors; striding by the struct size corrupts your parse. This is a classic bug.</li><li>The map is passed to the kernel and becomes the basis of the kernel’s e820 (x86) / memblock (ARM64) memory map. ACPI-typed ranges are marked so the kernel reserves them appropriately.</li><li>The MapKey returned here must be the one handed to ExitBootServices(). Any intervening allocation (even printing to a UEFI console that allocates) can invalidate it — hence the get-map-then-immediately-exit loop.</li></ul><p>The Linux EFI stub converts this EFI memory map into the kernel’s native format and records ACPI regions so that when ACPICA later asks to map a table’s physical address, the kernel knows the region is real, reserved memory.</p><h3>3. EFI Memory Types Relevant to ACPI</h3><p>The EFI memory type of a region dictates whether Linux may reuse it, must preserve it forever, or must map it read-only. Four types matter for ACPI.</p><h3>3.1 EfiACPIReclaimMemory (type 9) — what it contains, can the OS free it?</h3><ul><li><strong>Contains</strong>: the vast majority of ACPI tables — RSDT, XSDT, FADT, MADT/GTDT, MCFG, SPCR, DSDT, SSDTs, etc. (On many platforms the RSDP too.)</li><li><strong>Can the OS free it?</strong> Yes - <strong>but only <em>after</em> it has parsed</strong> and copied out everything it needs. The name literally means “the OS may reclaim this memory for general use once ACPI has been initialized.” The contract:</li></ul><ol><li>Early boot: kernel treats these ranges as reserved, maps them, parses all static tables, and <strong>copies the table contents</strong> (or the parsed data) into kernel-owned memory.</li><li>Later: the kernel may return the physical range to the page allocator.</li></ol><ul><li><strong>Linux reality:</strong> Linux is conservative. Modern kernels keep the DSDT/SSDTs mapped because the AML interpreter references them at runtime (method evaluation, dynamic table loads). Linux generally does not aggressively reclaim ACPI reclaim memory; it marks it reserved (E820_TYPE_ACPI / IORES_DESC_ACPI_TABLES) and leaves it, prioritizing safety over recovering a few hundred KB. So in practice &quot;reclaimable&quot; ≠ &quot;reclaimed.&quot;</li></ul><h3>3.2 EfiACPIMemoryNVS (type 10) — what it contains, must NEVER be freed</h3><ul><li><strong>Contains:</strong> the <strong>FACS</strong>, the ACPI hardware waking region, and anything the firmware/hardware may read or write at runtime (S3 resume waking vector, BIOS scratch used by AML OperationRegions, sometimes NVS regions referenced by the DSDT).</li><li><strong>Must NEVER be freed or reused by the OS</strong>. “NVS” = Non-Volatile Sleeping. This memory must survive across sleep states (S3) and is potentially touched by firmware behind the OS’s back. Reusing it would corrupt suspend/resume or crash the machine.</li><li><strong>Linux reality:</strong> mapped E820_TYPE_NVS / marked reserved permanently. It is saved and restored across hibernation, and never handed to the page allocator. The FADT&#39;s X_FirmwareCtrl points here.</li></ul><h3>3.3 EfiRuntimeServicesData — RSDP on some platforms</h3><ul><li>Some firmware places the RSDP (and occasionally certain tables) in EfiRuntimeServicesData rather than EfiACPIReclaimMemory. This region is preserved and mapped into the OS&#39;s runtime virtual address space (it survives ExitBootServices() and gets a virtual mapping via SetVirtualAddressMap()).</li><li><strong>Why it matters:</strong> the kernel must be prepared to find the RSDP in <em>any</em> of reclaim, NVS, or runtime-services memory - it should not assume a fixed type. That’s exactly why the GUID-based config-table lookup (which returns a raw physical address regardless of memory type) is the robust discovery method, rather than scanning a specific memory type.</li><li>On ARM64 especially, the RSDP commonly lives in EfiACPIReclaimMemory, but the kernel treats the config-table pointer as the source of truth either way.</li></ul><h3>3.4 Practical implications for Linux memory management</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/749c8ce7cd33fca61265edecd4edb6d5/href">https://medium.com/media/749c8ce7cd33fca61265edecd4edb6d5/href</a></iframe><p>Consequences:</p><ul><li>A firmware bug that places a live ACPI table in EfiBootServicesData is dangerous: Linux will happily reuse that RAM after ExitBootServices() and the table becomes garbage. (Linux has historically added quirks/efi=old_map and &quot;reserve boot services&quot; workarounds for exactly such bugs.)</li><li>Because reclaim memory <em>can</em> be reused, the kernel copies out static table contents early; but DSDT/SSDT stay referenced, so Linux keeps ACPI reclaim reserved in practice.</li><li>The memory map handed at ExitBootServices() is what the kernel converts into its reserved-region bookkeeping — if a table&#39;s type is wrong there, everything downstream inherits the mistake.</li></ul><h3>4. The EFI System Configuration Table</h3><h3>4.1 What it is and where it lives</h3><p>The <strong>EFI System Table </strong>(EFI_SYSTEM_TABLE, pointed to by gST) is the root of all UEFI services. One of its fields is an array of <strong>configuration tables</strong>:</p><pre>typedef struct {<br>  EFI_TABLE_HEADER               Hdr;<br>  ...<br>  EFI_RUNTIME_SERVICES          *RuntimeServices;   // gRT — survives ExitBootServices<br>  EFI_BOOT_SERVICES             *BootServices;       // gBS — gone after ExitBootServices<br>  UINTN                          NumberOfTableEntries;<br>  EFI_CONFIGURATION_TABLE       *ConfigurationTable;  // ← the array we care about<br>} EFI_SYSTEM_TABLE;</pre><pre>typedef struct {<br>  EFI_GUID   VendorGuid;     // identifies WHAT this entry is (ACPI, SMBIOS, ...)<br>  VOID      *VendorTable;    // physical pointer to the thing (e.g., the RSDP)<br>} EFI_CONFIGURATION_TABLE;</pre><p>The ConfigurationTable[] is a flat list of {GUID, pointer} pairs. It holds not just ACPI but SMBIOS, the memory attributes table, device tree (ARM), properties table, etc. It survives ExitBootServices() because the System Table and its config array are runtime-relevant, so the OS can consult it during and after boot.</p><h3>4.2 gEfiAcpiTableGuid → RSDP address</h3><p>The modern ACPI entry:</p><ul><li><strong>GUID</strong>: gEfiAcpiTableGuid (a.k.a. EFI_ACPI_20_TABLE_GUID) = 8868E871-E4F1-11D3-BC22-0080C73C8881</li><li><strong>VendorTable</strong>: physical address of the ACPI 2.0+ RSDP (the 36-byte RSDP with a valid XsdtAddress).</li></ul><p>This is the entry an ACPI-2.0-aware OS (every modern Linux) looks for first. It gives access to the 64-bit <strong>XSDT</strong>.</p><h3>4.3 gEfiAcpi10TableGuid → ACPI 1.0 RSDP</h3><p>The legacy entry:</p><ul><li><strong>GUID</strong>: gEfiAcpi10TableGuid (a.k.a. ACPI_TABLE_GUID) = EB9D2D30-2D88-11D3-9A16-0090273FC14D</li><li><strong>VendorTable</strong>: physical address of an ACPI 1.0 RSDP (20-byte, only a 32-bit RsdtAddress, points to the RSDT).</li></ul><p>Present for pre-2.0 operating systems. Linux prefers the 2.0 GUID and only falls back to the 1.0 GUID if the 2.0 one is absent. On ARM64, the 1.0 GUID is typically <strong>not</strong> provided at all (RSDT is deprecated on AArch64).</p><blockquote><strong><em>Preference order in Linux: </em></strong><em>2.0 GUID (→ XSDT) first, 1.0 GUID (→ RSDT) as fallback. If both point at valid RSDPs, the 2.0/XSDT path wins.</em></blockquote><h3>4.4 How GRUB / systemd-boot passes this to Linux</h3><p>Different bootloaders, same goal — get the RSDP/EFI-System-Table to the kernel:</p><ul><li><strong>Linux EFI stub (the common modern path).</strong> The kernel image is itself a PE/COFF UEFI application. Its stub runs in Boot Services, walks gST-&gt;ConfigurationTable via efi_config_parse_tables() / efi_config_get_vendor_table(), finds the ACPI GUID, and records the RSDP:</li></ul><p>a) <strong>x86_64:</strong> sets boot_params.acpi_rsdp_addr and passes the EFI System Table physical address in boot_params.efi_info (efi_systab / efi_memmap). The kernel proper reads these post-ExitBootServices().</p><p>b) <strong>ARM64:</strong> the stub records the EFI System Table and installs the memory map; it passes the config table / RSDP via the boot protocol (historically via a device-tree linux,uefi-* property set by the stub, and efi_get_fdt_params()), so the kernel&#39;s ACPI init can retrieve it.</p><ul><li><strong>GRUB (EFI)</strong>. When GRUB linuxefi/linux loads the kernel and hands control to the EFI stub, the stub does the discovery as above. GRUB itself may also expose ACPI (its acpi module can <em>replace</em> tables), but for normal boot it simply preserves the EFI environment so the stub can query it. GRUB does not call ExitBootServices() for the kernel; the stub does.</li><li><strong>systemd-boot.</strong> A thin UEFI boot manager. It chainloads the kernel’s EFI stub and, like GRUB, leaves Boot Services intact so the stub performs discovery and the exit. It does minimal work beyond selecting and launching the image.</li></ul><pre>GRUB/systemd-boot (UEFI app)<br>        │  launch kernel image (PE/COFF)<br>        ▼<br> Linux EFI stub (still in Boot Services)<br>        │  efi_config_parse_tables():<br>        │     for each ConfigurationTable[i]:<br>        │        if GUID == ACPI_20  → rsdp = VendorTable   (preferred)<br>        │        if GUID == ACPI_10  → rsdp10 = VendorTable  (fallback)<br>        │  set boot_params.acpi_rsdp_addr = rsdp (x86)<br>        │  GetMemoryMap → ExitBootServices<br>        ▼<br> Kernel proper: reads acpi_rsdp_addr / re-walks config table (see Section 5)</pre><p>The net effect: by the time the kernel proper starts ACPI initialization, it either already has the RSDP physical address (from boot_params / efi.acpi20) or it can obtain it from the preserved EFI System Table.</p><h3>5. RSDP Discovery in Linux</h3><p>Linux ACPI init begins in acpi_boot_table_init() (arch-specific glue) and calls into ACPICA&#39;s acpi_find_root_pointer(). But on UEFI the physical RSDP address is usually already known from the handoff. There are three discovery paths, tried in order of reliability.</p><h3>5.1 efi_get_rsdp_addr() — using the EFI config table</h3><p>On any EFI system this is the authoritative path. During EFI init the kernel populates struct efi with the addresses it found in the config table:</p><pre>struct efi {<br>    unsigned long acpi;        // ACPI 1.0 RSDP phys addr (from gEfiAcpi10TableGuid)<br>    unsigned long acpi20;      // ACPI 2.0 RSDP phys addr (from gEfiAcpiTableGuid)<br>    ...<br>} efi;</pre><p>This happens in efi_config_parse_tables() (in drivers/firmware/efi/efi.c), which iterates every EFI_CONFIGURATION_TABLE entry and matches GUIDs against a table of known GUIDs, storing the ACPI ones into efi.acpi20 / efi.acpi:</p><pre>// simplified<br>for (i = 0; i &lt; nr_tables; i++) {<br>    guid = config_tables[i].guid;<br>    if (!efi_guidcmp(guid, ACPI_20_TABLE_GUID))<br>        efi.acpi20 = config_tables[i].table;     // preferred<br>    else if (!efi_guidcmp(guid, ACPI_TABLE_GUID))<br>        efi.acpi   = config_tables[i].table;      // fallback (1.0)<br>    ...<br>}</pre><p>The x86 EFI-stub helper efi_get_rsdp_addr() (arch/x86/boot/compressed/acpi.c) does the equivalent very early (in the decompressor, before the kernel&#39;s efi struct exists) so features like KASLR can read the SRAT/memory-affinity tables:</p><pre>static acpi_physical_address efi_get_rsdp_addr(void) {<br>    // find EFI system table from boot_params<br>    // walk systab-&gt;tables[] (config tables)<br>    // return the ACPI 2.0 GUID table if present, else the 1.0 GUID table<br>    // returns 0 if not an EFI boot or not found<br>}</pre><p>Preference is always <strong>ACPI 2.0 GUID - -&gt; XSDT</strong> first; fall back to the 1.0 GUID only if 2.0 is missing.</p><h3>5.2 Legacy x86 BIOS method (EBDA scan) - historical context</h3><p>Before UEFI, there was no config table, so the OS had to search physical memory for the &quot;RSD PTR &quot; signature. ACPICA still implements this in acpi_tb_scan_memory_for_rsdp() / acpi_find_root_pointer():</p><pre>Legacy RSDP scan (x86 BIOS only):<br>  1. Read the EBDA (Extended BIOS Data Area) base from the 16-bit word at 0x40E.<br>     Scan the first 1 KiB of the EBDA on 16-byte boundaries for &quot;RSD PTR &quot;.<br>  2. If not found, scan the BIOS read-only area 0x000E0000–0x000FFFFF<br>     on 16-byte boundaries.<br>  3. For each candidate: verify the &quot;RSD PTR &quot; signature and the checksum.</pre><ul><li>The RSDP is always <strong>16-byte aligned</strong> in these regions, which is why the scan strides by 16 bytes.</li><li>This path is<strong> x86-only</strong> and <strong>legacy-BIOS</strong>-only. It does not exist meaningfully on ARM64 (there is no EBDA/BIOS ROM region), and on UEFI it is bypassed entirely in favor of the config-table pointer.</li><li>Kept for old hardware and for coreboot/SeaBIOS-style legacy boots.</li></ul><h3>5.3 acpi_find_root_pointer() - the ACPICA entry function</h3><p>ACPICA’s acpi_find_root_pointer(acpi_physical_address *table_address) is the generic entry that abstracts these paths. On Linux the OS-services layer (acpi_os_get_root_pointer(), in drivers/acpi/osl.c) short-circuits it:</p><pre>acpi_physical_address __init acpi_os_get_root_pointer(void)<br>{<br>    acpi_physical_address pa;<br>    // 1. Did the arch/bootloader already tell us? (x86 boot_params, etc.)<br>    pa = acpi_arch_get_root_pointer();<br>    if (pa)<br>        return pa;<br>    // 2. EFI? Prefer the 2.0 RSDP, fall back to 1.0.<br>    if (efi_enabled(EFI_CONFIG_TABLES)) {<br>        if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)<br>            return efi.acpi20;<br>        if (efi.acpi   != EFI_INVALID_TABLE_ADDR)<br>            return efi.acpi;<br>        pr_err(&quot;System description tables not found\n&quot;);<br>        return 0;<br>    }<br>    // 3. Legacy: scan memory (BIOS x86 only)<br>    else if (IS_ENABLED(CONFIG_ACPI_LEGACY_TABLES_LOOKUP)) {<br>        acpi_find_root_pointer(&amp;pa);<br>        return pa;<br>    }<br>    return 0;<br>}</pre><p>So the decision tree Linux actually follows:</p><pre>acpi_os_get_root_pointer()<br>     │<br>     ├─ arch handoff (boot_params.acpi_rsdp_addr on x86)?  ──▶ use it<br>     │<br>     ├─ EFI config tables enabled?<br>     │       ├─ efi.acpi20 valid?  ──▶ use ACPI 2.0 RSDP (→ XSDT)   [preferred]<br>     │       └─ efi.acpi   valid?  ──▶ use ACPI 1.0 RSDP (→ RSDT)   [fallback]<br>     │<br>     └─ else legacy BIOS  ──▶ acpi_find_root_pointer() scans EBDA + 0xE0000–0xFFFFF</pre><p>Once a physical RSDP address is in hand, control moves to table-chain parsing.</p><h3>6. ACPI Table Pointer Chain Walkthrough</h3><p>With the RSDP physical address, ACPICA’s acpi_tb_parse_root_table() (drivers/acpi/acpica/tbxfroot.c / tbutils.c) builds the root table list — an in-kernel array (acpi_gbl_root_table_list) of every table&#39;s phys addr, length, signature, and (once mapped) virtual pointer.</p><h3>6.1 RSDP → XSDT → every table</h3><pre>// simplified acpi_tb_parse_root_table()<br>rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp));<br>if (rsdp-&gt;revision &gt;= 2 &amp;&amp; rsdp-&gt;xsdt_physical_address) {<br>    table_entry_size = ACPI_XSDT_ENTRY_SIZE;         // 8 bytes<br>    table_address    = rsdp-&gt;xsdt_physical_address;  // use XSDT<br>} else {<br>    table_entry_size = ACPI_RSDT_ENTRY_SIZE;         // 4 bytes<br>    table_address    = rsdp-&gt;rsdt_physical_address;  // fall back to RSDT<br>}<br>acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp));<br>// map the XSDT/RSDT header, read its Length, compute entry count<br>table = acpi_os_map_memory(table_address, length);<br>entry_count = (table-&gt;length - sizeof(struct acpi_table_header)) / table_entry_size;<br>// for each entry: install into acpi_gbl_root_table_list<br>for (i = 0; i &lt; entry_count; i++) {<br>    phys = read_entry(table, i, table_entry_size);   // 4 or 8 bytes<br>    acpi_tb_install_standard_table(phys, ...);        // records sig/addr/len<br>}</pre><p>acpi_tb_install_standard_table() maps just enough of each table to read its header, validates the signature and length, and records it. FADT gets extra handling (Section 6.3). DSDT/FACS are not in the XSDT - they are discovered when the FADT is parsed.</p><h3>6.2 XSDT vs RSDT - why 64-bit matters</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31bde6fc1671ab4fe1aa37e397c7b103/href">https://medium.com/media/31bde6fc1671ab4fe1aa37e397c7b103/href</a></iframe><p>Why 64-bit matters:</p><ul><li>On systems with lots of RAM, firmware may place ACPI tables above <strong>4 GiB</strong>. A 32-bit RSDT entry physically cannot encode such an address, <strong>so only the XSDT can describe them</strong>. Using the RSDT there would truncate the pointer and the OS would map garbage.</li><li>ACPICA therefore <strong>prefers the XSDT whenever the RSDP revision ≥ 2 and </strong><strong>xsdt_physical_address is non-zero</strong>, and only uses the RSDT for genuine ACPI 1.0 systems.</li><li>On <strong>ARM64 the RSDT is forbidden</strong>; firmware provides XSDT only. The kernel would reject an RSDT-only ACPI setup on aarch64.</li><li>Consistency note: if both exist, they should list the same tables; ACPICA trusts the XSDT and ignores the RSDT when the XSDT is valid.</li></ul><h3>6.3 FADT → DSDT → FACS special chain</h3><p>The FADT (signature &quot;FACP&quot;) is found as a normal XSDT entry, but it is the gateway to two tables that are not in the XSDT:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OiF1AhCAE3vpjwNiZYbfXA.jpeg" /></figure><p>ACPICA’s acpi_tb_parse_fadt():</p><pre>// after locating the FADT in the root table list:<br>acpi_tb_parse_fadt() {<br>    // 1. Map the FADT, &quot;convert&quot; it to a normalized internal layout<br>    //    (older/shorter FADTs are zero-extended; X_ fields synthesized<br>    //     from the 32-bit fields if the X_ field is zero).<br>    acpi_tb_create_local_fadt(fadt, length);<br>    // 2. Extract and install the DSDT<br>    dsdt_addr = acpi_gbl_FADT.Xdsdt ? acpi_gbl_FADT.Xdsdt<br>                                    : acpi_gbl_FADT.dsdt;<br>    acpi_tb_install_standard_table(dsdt_addr, ... DSDT ...);<br>    // 3. Extract and install the FACS (if not hardware-reduced)<br>    facs_addr = acpi_gbl_FADT.Xfacs ? acpi_gbl_FADT.Xfacs<br>                                    : acpi_gbl_FADT.facs;<br>    if (facs_addr)<br>        acpi_tb_install_standard_table(facs_addr, ... FACS ...);<br>}</pre><p>Details Linux/ACPICA gets right here:</p><ul><li><strong>64-bit precedence: </strong>if X_Dsdt/X_FirmwareCtrl are non-zero they win over the legacy 32-bit fields. ACPICA has quirk handling for firmware that fills both inconsistently (it can prefer the 32-bit dsdt if the addresses disagree and the 32-bit one is valid — controlled by acpi_gbl_use32_bit_fadt_addresses).</li><li><strong>Hardware-reduced ACPI</strong> (FADT flag ACPI_FADT_HW_REDUCED, common on ARM64): there is no FACS and no legacy sleep registers; facs_addr is 0 and ACPICA skips FACS installation. Sleep is handled via the _S* methods / PSCI instead.</li><li>The FACS has <strong>no checksum</strong>, so it is installed without checksum validation.</li></ul><h3>6.4 Diagram: complete pointer chain</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yooV2ZNKVLHdM4MggxWwBQ.jpeg" /></figure><p>Every table in the XSDT (and DSDT/FACS via the FADT) ends up as an entry in acpi_gbl_root_table_list, ready for mapping and parsing.</p><h3>7. Physical → Virtual Memory Mapping</h3><p>Everything discovered so far is <strong>physical addresses</strong>. The kernel runs with the MMU on and can only dereference <strong>virtual addresses</strong>, so every table must be mapped before its bytes can be read. ACPICA delegates this to the OS layer.</p><h3>7.1 acpi_os_map_memory() - why we need virtual addresses</h3><p>ACPICA calls acpi_os_map_memory(phys, size) whenever it needs to touch a table; Linux implements it in drivers/acpi/osl.c:</p><pre>void __iomem *acpi_os_map_memory(acpi_physical_address phys, acpi_size size)<br>{<br>    // 1. Is this in reserved/E820 ACPI memory (mapped in the kernel linear map)?<br>    //    If it&#39;s normal RAM already mapped, return the existing kernel VA.<br>    // 2. Otherwise create a new mapping:<br>    //       early boot  --&gt; early_memremap()  / early_ioremap()<br>    //       later       --&gt; memremap(MEMREMAP_WB) or ioremap_cache()<br>    // 3. Track the mapping in acpi_ioremaps list (refcounted) so repeat<br>    //    maps of the same region are shared and unmapped correctly.<br>}</pre><p>Why this is needed:</p><ul><li>Paging is on; a raw physical address is not dereferenceable.</li><li>ACPI tables live in reserved (EfiACPIReclaimMemory/NVS) ranges, not necessarily in the kernel&#39;s direct/linear map, so an explicit mapping is required - with <strong>write-back cacheable</strong> attributes (they are normal memory, not device MMIO), which is why memremap(..., MEMREMAP_WB) / ioremap_cache() is used rather than plain uncached ioremap().</li><li><strong>Two-phase mapping:</strong> very early (before the memory allocators/vmalloc are up) ACPICA uses early_memremap()/early_ioremap() with a small fixed set of slots (hence &quot;ACPI Error: Could not map&quot; if too many are held at once). After acpi_early_init()/mm is ready, it switches to permanent memremap.</li></ul><p>Matching cleanup is acpi_os_unmap_memory(), which decrements the refcount and tears down the mapping when the last user unmaps.</p><h3>7.2 How the kernel maps ACPI table regions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cPW5DLfsK8FKKjMFSFAQyg.jpeg" /></figure><ul><li>During enumeration only <strong>headers</strong> are mapped (cheap) ro build the list.</li><li>When a table’s contents are needed, acpi_get_table() maps the <strong>full</strong> <strong>length</strong>. Frequently-used tables (DSDT, FADT) are effectively kept mapped for the life of the system because the AML interpreter and drivers reference them continuously.</li><li>On x86 these ACPI regions are also reflected in e820/iomem as &quot;ACPI Tables&quot; / &quot;ACPI Non-volatile Storage&quot;, which you can see in /proc/iomem.</li></ul><h3>7.3 Checksum validation: acpi_tb_verify_checksum()</h3><p>Before trusting any table, ACPICA verifies its checksum in acpi_tb_verify_checksum() (drivers/acpi/acpica/tbprint.c / tbutils.c):</p><pre>acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)<br>{<br>    u8 checksum;<br>    // FACS and RSDP are special-cased by callers (FACS has no checksum).<br>    checksum = acpi_tb_checksum((u8 *)table, length);   // 8-bit sum of all bytes<br>    if (checksum) {                                     // must sum to 0<br>        ACPI_BIOS_WARNING((AE_INFO,<br>            &quot;Incorrect checksum in table [%4.4s] - 0x%2.2X, &quot;<br>            &quot;should be 0x%2.2X&quot;, table-&gt;signature, table-&gt;checksum,<br>            (u8)(table-&gt;checksum - checksum)));<br>        // By default this is a WARNING, not fatal - the table is still used<br>        // unless acpi_gbl_verify_table_checksum / strict mode says otherwise.<br>    }<br>    return AE_OK;   // (or AE_BAD_CHECKSUM if strict verification enabled)<br>}<br>u8 acpi_tb_checksum(u8 *buffer, u32 length)<br>{<br>    u8 sum = 0;<br>    while (length--)<br>        sum = (u8)(sum + *buffer++);   // 8-bit wrapping add<br>    return sum;                        // 0 == valid<br>}</pre><p>Key facts:</p><ul><li>The rule is identical to the firmware side: <strong>the 8-bit sum of every byte in the table must be 0.</strong></li><li><strong>RSDP</strong> is verified specially: acpi_tb_validate_rsdp() checks the signature &quot;RSD PTR &quot;, the first-20-bytes checksum, and (for rev ≥ 2) the extended_checksum over the full length.</li><li><strong>FACS is skipped</strong> - it has no checksum field.</li><li>The global acpi_gbl_verify_table_checksum (settable, and cleared by the acpi=nochecksums boot option) controls whether a bad checksum is tolerated. By default Linux <strong>warns but continues</strong>, because many shipping BIOSes have buggy checksums and refusing to boot would be worse than proceeding.</li></ul><h3>8. What Happens if Tables Are Corrupt?</h3><h3>8.1 Bad checksum handling</h3><p>When acpi_tb_verify_checksum() finds a non-zero sum, the default Linux behavior is <strong>lenient</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HilodNG5jC6r-8haLQDrlw.jpeg" /></figure><p>Rationale: a huge fraction of shipped firmware has minor checksum bugs (often because an OEM tool patched a table without recomputing). Refusing to boot on a bad checksum would brick countless machines, so Linux warns and proceeds. The warning is visible in dmesg and is a useful signal that a firmware table was modified without fix-up.</p><p>Distinct failure modes and how Linux reacts:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ad0489526c13346fe38bca556b608c6/href">https://medium.com/media/3ad0489526c13346fe38bca556b608c6/href</a></iframe><h3>8.2 acpi=nochecksums boot parameter</h3><p>The kernel command-line option:</p><pre>acpi=nochecksums</pre><p>sets acpi_gbl_verify_table_checksum = FALSE, telling ACPICA to skip checksum verification entirely. Use cases:</p><ul><li>Booting on firmware whose checksums are wrong <em>and</em> whose warnings are noisy or (in a stricter build) fatal.</li><li>Debugging / bring-up where you are hand-editing tables and don’t want to recompute checksums each iteration.</li></ul><p>Related ACPI command-line knobs worth knowing:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65e1f163309373a29d80bf4a12989199/href">https://medium.com/media/65e1f163309373a29d80bf4a12989199/href</a></iframe><h3>8.3 DSDT override mechanisms</h3><p>Sometimes the firmware’s DSDT (or an SSDT) is simply broken or missing a needed device, and you must <strong>replace or supplement</strong> the firmware AML. Linux offers three mechanisms.</p><h4>8.3.1 CONFIG_ACPI_CUSTOM_DSDT (compile-time)</h4><p>Compile a replacement DSDT directly into the kernel:</p><pre>1. Extract the firmware DSDT:<br>       cat /sys/firmware/acpi/tables/DSDT &gt; dsdt.dat<br> 2. Disassemble, edit, recompile with iasl:<br>       iasl -d dsdt.dat            # → dsdt.dsl<br>       $EDITOR dsdt.dsl            # fix the AML<br>       iasl -tc dsdt.dsl          # → dsdt.hex  (C hex array)<br> 3. Kernel config:<br>       CONFIG_ACPI_CUSTOM_DSDT=y<br>       CONFIG_ACPI_CUSTOM_DSDT_FILE=&quot;dsdt.hex&quot;<br> 4. Rebuild the kernel. At boot, acpi_tb_get_table() for the DSDT<br>    returns the built-in AmlCode[] instead of the firmware DSDT.</pre><ul><li><strong>Pros</strong>: deterministic, no initrd dependency.</li><li><strong>Cons</strong>: requires kernel rebuild; overrides the DSDT only; ties the fix to a specific kernel build. Largely superseded by the initrd method.</li></ul><h4>8.3.2 initrd-based override (table upgrade)</h4><p>The modern, flexible mechanism (CONFIG_ACPI_TABLE_UPGRADE). Linux scans the very front of the initramfs for ACPI tables and lets them override or append firmware tables — no kernel rebuild:</p><pre>Build an uncompressed cpio prepended to the real initramfs:<br>   kernel/<br>     firmware/<br>       acpi/<br>         dsdt.aml        # overrides the firmware DSDT<br>         ssdt1.aml       # appended as an extra SSDT<br>         ...<br># Build:<br>   mkdir -p kernel/firmware/acpi<br>   cp dsdt.aml ssdt1.aml kernel/firmware/acpi/<br>   find kernel | cpio -H newc --create &gt; acpi_override.cpio<br>   cat acpi_override.cpio original_initrd.img &gt; new_initrd.img</pre><p>How it works at boot:</p><pre>acpi_table_upgrade()  (called very early, drivers/acpi/tables.c)<br>     │<br>     ├─ find the ACPI tables embedded at the start of the initrd<br>     │   (they must be in an UNCOMPRESSED cpio prepended to the initrd,<br>     │    under kernel/firmware/acpi/)<br>     ├─ for each *.aml:<br>     │     read its signature:<br>     │        DSDT / FACP  --&gt; OVERRIDE the firmware table<br>     │        SSDT (others)--&gt; APPENDED to the table list (installed as extra)<br>     │     copy it into memblock-reserved memory<br>     │     patch acpi_gbl_root_table_list to point at the override<br>     └─ ACPICA then parses the override as if firmware had provided it</pre><ul><li><strong>Signature match determines override vs append:</strong> a DSDT/FACP replaces; new SSDTs are added.</li><li>Requires the override cpio to be uncompressed and first in the initrd, because it must be parsed before the normal initramfs is unpacked and before the AML interpreter starts.</li><li>This is the recommended way to patch AML on a stock distro kernel.</li></ul><h4>8.3.3 /sys/firmware/acpi/tables/ and dynamic table loading</h4><p>The sysfs ACPI interface exposes tables and supports runtime dynamic SSDT loading:</p><pre>/sys/firmware/acpi/tables/<br>   ├─ DSDT              # raw firmware tables, read-only (cat &gt; file to dump)<br>   ├─ FACP<br>   ├─ APIC / GTDT / MCFG / SSDT1 / SSDT2 ...<br>   └─ dynamic/          # tables loaded at RUNTIME via ACPI Load()/LoadTable()<br>        └─ SSDTn        # e.g., loaded by drivers or by the OSPM at runtime</pre><ul><li><strong>/sys/firmware/acpi/tables/&lt;SIG&gt;</strong> : dump the <em>currently active</em> tables (post-override). Great for verifying an initrd override took effect.</li><li><strong>/sys/firmware/acpi/tables/dynamic/</strong> : tables that were loaded after the initial table load, via AML Load/LoadTable operators or hot-plug events. These are the runtime-injected SSDTs.</li><li><strong>ConfigFS dynamic loading</strong> (CONFIG_ACPI_CONFIGFS) — /sys/kernel/config/acpi/table/ lets you load a compiled AML table into a <strong>running</strong> kernel:</li></ul><pre>mkdir /sys/kernel/config/acpi/table/my_ssdt <br>cat my_ssdt.aml &gt; /sys/kernel/config/acpi/table/my_ssdt/aml <br># the SSDT is now live; appears under tables/dynamic/</pre><ul><li>Used for development, GPIO/I2C device injection on embedded boards, etc.</li></ul><blockquote><strong><em>Override selection summary:</em></strong><em> initrd override for production patching (no rebuild), ConfigFS/dynamic for live experimentation, </em><em>CONFIG_ACPI_CUSTOM_DSDT for locked-down embedded builds.</em></blockquote><h3>9. Key Takeaways + Handoff Diagram</h3><h3>9.1 Key takeaways</h3><ol><li><strong>One breadcrumb, one contract</strong>. Firmware’s entire ACPI handoff is the RSDP pointer in the EFI System Configuration Table under gEfiAcpiTableGuid. Find that, and the whole tree unfolds. No memory scanning on UEFI.</li><li><strong>The bootloader captures the RSDP while Boot Services are alive</strong>. The Linux EFI stub walks the config table, stashes the RSDP (boot_params.acpi_rsdp_addr on x86 / boot protocol on ARM64), then does GetMemoryMap() — -&gt; ExitBootServices(). After that, firmware is gone and nothing more can be queried.</li><li><strong>ExitBootServices() freezes ACPI</strong>. Reclaim/NVS regions are preserved; the memory map handed at exit is the OS’s source of truth for what’s reserved.</li><li><strong>Memory type dictates lifetime</strong>. EfiACPIReclaimMemory is reclaimable <em>in theory</em> (Linux keeps it reserved in practice); EfiACPIMemoryNVS (FACS, waking) must never be freed; the RSDP may sit in reclaim, NVS, or runtime-services memory - which is why the GUID pointer, not a memory-type scan, is authoritative.</li><li><strong>Prefer 64-bit everything</strong>. ACPI 2.0 GUID - -&gt; RSDP rev ≥ 2 — -&gt; XSDT (8-byte entries) — -&gt; tables anywhere in 64-bit space. RSDT/1.0 GUID is a fallback and is forbidden on ARM64. X_Dsdt/X_FirmwareCtrl win over the 32-bit fields.</li><li><strong>DSDT and FACS are off the XSDT</strong>. They are reached only through FADT fields. FACS lives in NVS and has no checksum; DSDT holds the AML the interpreter runs.</li><li><strong>Physical — →virtual is mandatory</strong>. ACPICA maps every table via acpi_os_map_memory() (early_memremap early, memremap-WB later) before reading it; headers first for enumeration, full tables when used.</li><li><strong>Checksums are advisory in Linux</strong>. acpi_tb_verify_checksum() warns but continues by default; acpi=nochecksums disables the check. Real-world firmware is buggy enough that strictness would do more harm than good.</li><li><strong>You can override the firmware’s AML</strong>. initrd table-upgrade (production), ConfigFS/dynamic loading (runtime), and CONFIG_ACPI_CUSTOM_DSDT (compile-time). /sys/firmware/acpi/tables/ lets you dump active tables and see dynamically loaded ones.</li></ol><h3>9.2 End-to-end handoff diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wMh7zfiZDkNB2ADSmDkcrw.jpeg" /></figure><h3>References</h3><p><strong>ACPI specification</strong></p><ol><li>ACPI Specifications (UEFI Forum) — <a href="https://uefi.org/acpi/specs">https://uefi.org/acpi/specs</a></li><li>ACPI Spec 6.4, full text (HTML) — <a href="https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/">https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/</a></li></ol><p><strong>ACPICA (reference AML interpreter, used directly by Linux)</strong><br> 3. ACPICA documentation &amp; user guide (Intel) — <a href="https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html">https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html</a><br> 4. ACPICA source (GitHub) — <a href="https://github.com/acpica/acpica">https://github.com/acpica/acpica</a></p><p><strong>Linux ACPI implementation</strong><br> 5. Linuxized ACPICA — how Linux syncs with upstream ACPICA — <a href="https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html">https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html</a><br> 6. Linux kernel ACPI driver-api docs — <a href="https://docs.kernel.org/driver-api/acpi/index.html">https://docs.kernel.org/driver-api/acpi/index.html</a><br> 7. Linux kernel source, drivers/acpi — <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi</a></p><p><strong>Windows internals</strong><br> 8. Windows Driver Kit — Kernel-Mode Driver Architecture — <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/">https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/</a><br> 9. Russinovich, Solomon, Ionescu — <em>Windows Internals</em>, Part 1 (7th ed.) — standard secondary source for undocumented boot/HAL routines like KiSystemStartup, HalInitSystem.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/133846fb6985f60b5e018fb96c51d65b/href">https://medium.com/media/133846fb6985f60b5e018fb96c51d65b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac0cb5b9e055" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UEFI Internals - How ACPI Tables get processed in UEFI]]></title>
            <link>https://medium.com/@kushaldps1996/uefi-internals-how-acpi-tables-get-processed-in-uefi-16511a1f9b27?source=rss-20cb97d60801------2</link>
            <guid isPermaLink="false">https://medium.com/p/16511a1f9b27</guid>
            <dc:creator><![CDATA[KUSHAL CHAKRABORTY]]></dc:creator>
            <pubDate>Sun, 02 Aug 2026 17:55:54 GMT</pubDate>
            <atom:updated>2026-08-02T17:55:54.966Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>A detailed walkthrough of how ACPI tables are produced, installed, and patched inside a UEFI/EDK2 firmware, tracing the boot phases (SEC → PEI → DXE → BDS → TSL), the AcpiTableDxe and AcpiPlatformDxe drivers, the ACPI protocols, and the resulting &gt; physical memory layout. Applies to EDK2-based firmware on both x86 and ARM64 (AArch64). Where an architecture matters (e.g., x86 RSDP in EBDA vs. ARM64 RSDP in reclaim memory, or MADT vs. GTDT), it is called out explicitly.</blockquote><h3>Table of Contents</h3><ol><li><a href="https://gist.github.com/#1-introduction">Introduction</a></li><li><a href="https://gist.github.com/#2-uefi-boot-phases-quick-reference">UEFI Boot Phases Quick Reference</a></li><li><a href="https://gist.github.com/#3-sec-phase">SEC Phase</a></li><li><a href="https://gist.github.com/#4-pei-phase">PEI Phase</a></li><li><a href="https://gist.github.com/#5-dxe-phase--the-main-event">DXE Phase — The Main Event</a></li><li><a href="https://gist.github.com/#6-acpitabledxe-driver-deep-dive">AcpiTableDxe Driver (Deep Dive)</a></li><li><a href="https://gist.github.com/#7-acpiplatformdxe-driver-deep-dive">AcpiPlatformDxe Driver (Deep Dive)</a></li><li><a href="https://gist.github.com/#8-what-installacpitable-does-internally">What InstallAcpiTable() Does Internally</a></li><li><a href="https://gist.github.com/#9-memory-layout-after-dxe">Memory Layout After DXE</a></li><li><a href="https://gist.github.com/#10-bds-phase--final-patching">BDS Phase — Final Patching</a></li><li><a href="https://gist.github.com/#11-key-takeaways--protocol-summary-table">Key Takeaways + Protocol Summary Table</a></li></ol><h3>1. Introduction</h3><h3>1.1 The UEFI phase model overview</h3><p>UEFI firmware does not boot in a single monolithic blob. It executes as a <strong>sequence of well-defined phases</strong>, each with a distinct job, a distinct execution environment (no RAM yet? RAM available? full services?), and a distinct handoff mechanism to the next phase. The canonical phase order defined by the <strong>PI (Platform Initialization) Specification</strong> and the <strong>UEFI Specification</strong> is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mSenxMSMv_BjBtgVxGqaWA.jpeg" /></figure><ul><li><strong>SEC :</strong> Security. First code out of reset. Establishes a temporary RAM (Cache-as-RAM on x86), validates the root of trust, finds and hands off to PEI.</li><li><strong>PEI</strong> : Pre-EFI Initialization. Runs in a constrained environment (often still no permanent DRAM at entry). Its headline job: <strong>initialize main memory (DRAM)</strong>. Produces <strong>HOBs</strong> (Hand-Off Blocks) describing the platform.</li><li><strong>DXE :</strong> Driver Execution Environment. The “real OS of firmware.” Full memory, full services (Boot Services, Runtime Services), a protocol database, and a driver dispatcher. <strong>This is where ACPI tables are built and installed.</strong></li><li><strong>BDS :</strong> Boot Device Selection. Decides what to boot, connects consoles and boot devices, and performs <strong>last-minute ACPI patching</strong>.</li><li><strong>TSL : </strong>Transient System Load. The OS loader (grubx64.efi, BOOTAA64.EFI, Windows Boot Manager) runs. Firmware still owns Boot Services.</li><li><strong>RT / AL </strong>: Runtime / After Life. ExitBootServices() has fired; the OS owns the machine. Only Runtime Services and the ACPI tables (now owned by the OS) remain.</li></ul><h3>1.2 Why DXE is where ACPI lives</h3><p>ACPI tables are <strong>data structures placed in physical memory</strong> that the OS reads after boot to discover hardware (CPUs, interrupt controllers, timers, power management, PCI root bridges, etc.). To build them, the firmware needs three things <strong>that only DXE provides</strong>:</p><ol><li><strong>Permanent DRAM available and mapped</strong>. ACPI tables persist and are pointed to by physical addresses handed to the OS. They must live in <em>stable</em> memory, not the temporary Cache-as-RAM window of SEC/PEI. DRAM is up only after PEI’s memory-init PEIM.</li><li><strong>A real memory allocator with typed memory</strong>. ACPI tables must be placed in specific <strong>EFI memory types :</strong>EfiACPIReclaimMemory (type 9) for most tables and EfiACPIMemoryNVS (type 10) for the FACS and hardware-touched regions. The gBS-&gt;AllocatePages / AllocatePool allocator with typed memory only exists in DXE.</li><li><strong>The protocol model.</strong> ACPI is produced by one driver (AcpiTableDxe) publishing EFI_ACPI_TABLE_PROTOCOL, and consumed by a platform driver (AcpiPlatformDxe) that locates that protocol and calls InstallAcpiTable(). Protocols — the publish/locate/notify database — are a DXE construct managed by the DXE Core.</li></ol><p>Additionally, DXE ends by registering the <strong>RSDP </strong>(Root System Description Pointer) into the <strong>EFI System Configuration Table</strong> via a GUID (gEfiAcpiTableGuid / gEfiAcpi20TableGuid). That configuration table is the <em>only</em> contract by which an OS loader in the UEFI world finds ACPI — and the System Configuration Table is itself a DXE/Boot-Services structure.</p><blockquote><strong><em>One-line answer:</em></strong><em> ACPI lives in DXE because ACPI needs stable DRAM, typed memory allocation, the protocol database, and the EFI System Configuration Table - and all four come into existence only in DXE.</em></blockquote><h3>2. UEFI Boot Phases Quick Reference</h3><h3>2.1 SEC → PEI → DXE → BDS → TSL</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tXlkxYT-AOm_C2UQQJw79g.jpeg" /></figure><h3>2.2 What each phase does for ACPI</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06ba8cc7e8f23fd763edf189c5eeafc8/href">https://medium.com/media/06ba8cc7e8f23fd763edf189c5eeafc8/href</a></iframe><p><em>Rule of thumb: PEI </em>enables<em> ACPI (memory), DXE </em>builds<em> ACPI, BDS </em>finishes<em> ACPI, TSL </em>consumes<em> ACPI.</em></p><h3>3. SEC Phase</h3><h3>3.1 Cache-as-RAM, CPU init</h3><p>At the reset vector the CPU is in its most primitive state:</p><ul><li>On <strong>x86</strong>: real mode (or a firmware-defined early mode), caches disabled or cold, <strong>no DRAM controller trained - </strong>so there is literally no writable RAM. The classic solution is <strong>Cache-as-RAM</strong> (CAR), a.k.a. <strong>“No-Eviction Mode”</strong>: the firmware configures the CPU cache (via MTRRs and cache-control MSRs) to behave like a small scratchpad SRAM. This gives PEI a stack and a heap before DRAM exists.</li><li>On <strong>ARM64</strong>: the SoC boot ROM (BL1) and TF-A (BL2/BL31) typically run out of <strong>on-chip SRAM</strong>.</li></ul><p>SEC responsibilities in EDK2 (SecCore / SecMain):</p><pre>Reset --&gt; SEC entry (assembly stub, e.g. SecEntry.nasm / ModuleEntryPoint.S)<br>           ├─ Set up temporary RAM (CAR on x86 / provided SRAM on ARM)<br>           ├─ Initialize a minimal stack pointer into that temp RAM<br>           ├─ (Optional) Establish root-of-trust: measure/verify PEI Core<br>           ├─ Locate the Boot Firmware Volume (BFV) and find PEI Core<br>           └─ Call SecStartupPhase2() → PeiCore entry point<br>                    passing SEC_PEI_HAND_OFF (temp RAM<br>                    base/size, BFV, stack) + PPI list</pre><p>The handoff structure EFI_SEC_PEI_HAND_OFF carries: BootFirmwareVolumeBase, TemporaryRamBase, TemporaryRamSize, and the stack region. SEC also passes an initial <strong>PPI</strong> <strong>(PEIM-to-PEIM Interface)</strong> list — PPIs are the PEI-phase analog of DXE protocols.</p><h3>3.2 No ACPI involvement : why?</h3><p>SEC touches <strong>zero</strong> ACPI, and it is structurally impossible for it to do otherwise:</p><ol><li><strong>No DRAM</strong>. ACPI tables must be written somewhere permanent. In SEC the only RAM is a few tens/hundreds of KB of cache scratchpad — far too small and, crucially, not visible to the OS as a normal memory range. Placing an RSDP there would point the OS at nothing.</li><li><strong>No memory-type allocator</strong>. ACPI requires EfiACPIReclaimMemory / EfiACPIMemoryNVS. Those are DXE Boot-Services concepts; the notion doesn&#39;t even exist yet.</li><li><strong>No protocol/handle database</strong>. EFI_ACPI_TABLE_PROTOCOL cannot be published because the protocol database is created by the DXE Core.</li><li><strong>Wrong job.</strong> SEC’s contract is narrowly “get to PEI safely.” Adding ACPI logic there would violate the layering and the trust model.</li></ol><blockquote><em>SEC is about </em>trust and survival<em>, not </em>hardware description<em>. ACPI is hardware description. They live at opposite ends of boot.</em></blockquote><h3>4. PEI Phase</h3><h3>4.1 DRAM initialization</h3><p>The single most important thing PEI does - for ACPI and for everything else - is <strong>turn on main memory</strong>. The <strong>MemoryInit PEIM </strong>programs the DRAM controller (DDR training: read/write leveling, gate training, Vref calibration; timing registers; address decode). On coreboot-payload ARM64 platforms this is already done by coreboot, and the EDK2 PEI-equivalent simply <em>discovers</em> the trained ranges rather than training them.</p><p>Once permanent DRAM is available, PEI Core performs <strong>temporary-RAM migration</strong>: the stack and any heap/PPI data built in CAR/SRAM are copied into permanent DRAM, stack pointer relocated, and CAR torn down. From this point the environment has real, abundant, OS-visible memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iqaomKXDmFjyhq3HjJS7dA.jpeg" /></figure><h3>4.2 HOB (Hand-Off Block) creation</h3><p>PEI communicates everything it learned to DXE through the <strong>HOB list - </strong>a singly-linked, append-only list of typed blocks starting with a <strong>Phase Handoff Information Table (PHIT)</strong> HOB. Key HOB types:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e4f67ebb14fda63f2de371bca0e37d8/href">https://medium.com/media/6e4f67ebb14fda63f2de371bca0e37d8/href</a></iframe><p>The DXE Core walks this list at entry (gHob / GetHobList()), converts the resource descriptors into the <strong>GCD (Global Coherency Domain)</strong> memory space map, and thereby knows every byte of RAM it may allocate from. ACPI drivers can also read GUIDed HOBs via GetFirstGuidHob() to learn platform specifics - for example, how many CPU cores to emit in the MADT/GTDT, or a board-specific value to patch into the DSDT.</p><h3>4.3 Why ACPI needs stable DRAM first</h3><p>ACPI tables are <strong>not</strong> consumed while firmware runs; they are consumed by the OS <strong>long after</strong> firmware has handed off. That imposes hard constraints:</p><ul><li><strong>Persistence across the whole handoff.</strong> The RSDP is a physical pointer given to the OS. Everything it (transitively) points to must remain valid and unmoved through DXE, BDS, TSL, ExitBootServices(), and into OS runtime. Only permanent DRAM meets that bar. Temp RAM/CAR is torn down inside PEI - anything there would vanish.</li><li><strong>Correct typing to survive reclaim</strong>. The tables sit in EfiACPIReclaimMemory (the OS may reclaim it <em>after</em> it has copied/parsed the tables) and EfiACPIMemoryNVS (never reclaimed). These types are assigned by the DXE allocator against the GCD map that PEI&#39;s HOBs produced. Without a stable, described memory map there is no way to mark memory as ACPI-typed.</li><li><strong>Deterministic addresses.</strong> Checksums and inter-table pointers (XSDT→FADT, FADT→DSDT/FACS) are computed over final physical addresses. Those addresses only stabilize once the permanent allocator (backed by DRAM) is running.</li></ul><blockquote><em>PEI doesn’t build ACPI, but </em><strong><em>nothing about ACPI is possible until PEI finishes its one crucial job</em></strong><em>: establishing stable, described, permanent DRAM.</em></blockquote><h3>5. DXE Phase - The Main Event</h3><h3>5.1 DXE Core and driver loading model</h3><p>The <strong>DxeIpl PEIM</strong> loads and jumps to the <strong>DXE Core</strong>, handing it the HOB list. The DXE Core bootstraps the environment every later driver relies on:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PLfXHw_Q3PrK_t4rZlJTIg.jpeg" /></figure><p>Two driver models exist in DXE:</p><ul><li><strong>DXE Drivers</strong> (a.k.a. “early”/APRIORI or plain DXE drivers) - run once at dispatch. AcpiTableDxe and AcpiPlatformDxe are DXE drivers of this kind.</li><li><strong>UEFI Drivers</strong> (follow the UEFI Driver Model: Supported/Start/Stop, bound to controllers) - typically bus/device drivers, not ACPI producers.</li></ul><h3>5.2 DEPEX (dependency expressions)</h3><p>Every dispatchable driver carries a <strong>DEPEX - </strong>a small stack-machine expression (section type EFI_SECTION_DXE_DEPEX) listing the <strong>protocol GUIDs</strong> that must be present before the driver may run. The dispatcher evaluates DEPEXes to order loading correctly without hard-coding sequence.</p><p>DEPEX opcodes: PUSH &lt;guid&gt;, AND, OR, NOT, TRUE, FALSE, END (and BEFORE/AFTER/SOR for scheduling hints).</p><p>The relationship between the two ACPI drivers is the textbook DEPEX example:</p><pre>AcpiTableDxe.inf     [Depex] --&gt;TRUE<br>                                 ; needs nothing special, runs early,<br>                                 ; then PUBLISHES gEfiAcpiTableProtocolGuid<br><br>AcpiPlatformDxe.inf  [Depex] --&gt; gEfiAcpiTableProtocolGuid<br>                                 ; will NOT dispatch until AcpiTableDxe<br>                                 ; has installed EFI_ACPI_TABLE_PROTOCOL</pre><p>So the dispatcher guarantees ordering by <strong>data dependency</strong>, not by a fixed list: AcpiPlatformDxe becomes dispatchable only <em>after</em> AcpiTableDxe publishes EFI_ACPI_TABLE_PROTOCOL. (A platform may additionally list ACPI modules in the APRIORI FV GUID file to force early ordering, but DEPEX is the primary mechanism.)</p><h3>5.3 Protocol-based architecture</h3><p>A <strong>protocol</strong> is a {GUID, interface-structure-pointer} pair attached to a <strong>handle</strong> in the DXE handle database. Producers <em>install</em> protocols; consumers <em>locate</em> them; anyone can <em>register for notification</em> when one appears. The core APIs:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3e74c460331929ff283d87efb0b9a3f/href">https://medium.com/media/b3e74c460331929ff283d87efb0b9a3f/href</a></iframe><p>This is exactly how ACPI is wired:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qYVLAZhg5GI1h4a7l_CKyA.jpeg" /></figure><p>The protocol model is what lets a <strong>generic, silicon-vendor-neutral</strong> AcpiTableDxe (in MdeModulePkg) cooperate with a <strong>platform-specific</strong> AcpiPlatformDxe (in the board package) without either knowing the other&#39;s internals - they meet only at the published GUID and the function-pointer table.</p><h3>6. AcpiTableDxe Driver (Deep Dive)</h3><p>AcpiTableDxe lives in <strong>MdeModulePkg/Universal/Acpi/AcpiTableDxe/</strong>. It is the <strong>generic, platform-agnostic ACPI container manager</strong>. It does not know anything about your FADT or your CPU count. Its job is purely mechanical:</p><ul><li>Own and maintain the <strong>root pointers and root tables: </strong>RSDP, RSDT (ACPI 1.0 compatibility), and XSDT (ACPI 2.0+).</li><li>Publish EFI_ACPI_TABLE_PROTOCOL so platform code can add/remove tables.</li><li>Publish EFI_ACPI_SDT_PROTOCOL (when PcdInstallAcpiSdtProtocol == TRUE) so code can <em>inspect and edit</em> installed tables (AML included).</li><li>Handle all the bookkeeping: memory typing, checksums, keeping RSDT/XSDT entry arrays in sync, and special-casing FADT/DSDT/FACS.</li><li>Register the RSDP into the <strong>EFI System Configuration Table</strong>.</li></ul><p>Key source files:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d651cfdc82dcf3166a329e8476ba38d/href">https://medium.com/media/4d651cfdc82dcf3166a329e8476ba38d/href</a></iframe><h3>6.1 What it creates: RSDP, RSDT, XSDT</h3><p>The ACPI root discovery chain the OS must be able to walk:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WjzTHA9QWm74lBhNeEFXog.png" /></figure><p><strong>Notes:</strong></p><ul><li><strong>XSDT is authoritative on modern systems</strong>. RSDT holds 32-bit pointers and exists only for pre-ACPI-2.0 compatibility; ARM64 platforms frequently set RsdtAddress = 0 and provide only the XSDT (RSDT is deprecated and often forbidden on AArch64). x86 typically still populates both.</li><li>The RSDP is <strong>not</strong> listed inside XSDT/RSDT - it <em>is</em> the root and is found via the System Configuration Table (UEFI) or by scanning the EBDA/BIOS ROM (legacy BIOS only).</li><li><strong>FADT never appears through the XSDT alone for DSDT/FACS - </strong>those two are reached via dedicated fields <em>inside</em> the FADT, which is why the driver special-cases them (Section 6.6, 7.4, 7.5).</li></ul><p>Internally, AcpiTableDxe keeps one <strong>EFI_ACPI_TABLE_INSTANCE</strong> holding pointers to the live RSDP, RSDT (there are actually two RSDT variants historically plus the XSDT), the XSDT, the current FADT/FACS/DSDT, and <strong>a linked list of every installed table</strong> (EFI_ACPI_TABLE_LIST nodes, each with the table&#39;s memory address, size, allocated page count, a Handle, and its Signature).</p><h3>6.2 EFI_ACPI_TABLE_PROTOCOL</h3><pre>typedef struct _EFI_ACPI_TABLE_PROTOCOL {<br>  EFI_ACPI_TABLE_INSTALL_ACPI_TABLE    InstallAcpiTable;<br>  EFI_ACPI_TABLE_UNINSTALL_ACPI_TABLE  UninstallAcpiTable;<br>} EFI_ACPI_TABLE_PROTOCOL;</pre><p>Two functions. This is the <strong>write</strong> side of ACPI - the API platform code uses to put tables into the RSDT/XSDT.</p><h4>6.2.1 InstallAcpiTable()</h4><pre>EFI_STATUS<br>EFIAPI<br>InstallAcpiTable (<br>  IN  EFI_ACPI_TABLE_PROTOCOL  *This,<br>  IN  VOID                     *AcpiTableBuffer,   // caller&#39;s copy of the table<br>  IN  UINTN                    AcpiTableBufferSize,<br>  OUT UINTN                    *TableKey           // handle returned to caller<br>  );</pre><ul><li>Input is a <em>caller-owned buffer</em> (often a table .aml/.h blob compiled into the driver or read from an FV). The protocol <strong>copies</strong> it into freshly allocated ACPI memory — the caller may free/reuse its buffer afterward.</li><li>TableKey is an opaque handle the caller keeps so it can later UninstallAcpiTable(TableKey).</li><li>The signature in the first 4 bytes of the buffer tells the driver what kind of table it is, driving the FADT/FACS/DSDT special handling.</li></ul><p>(The full internal algorithm is Section 8.)</p><h4>6.2.2 UninstallAcpiTable()</h4><pre>EFI_STATUS<br>EFIAPI<br>UninstallAcpiTable (<br>  IN  EFI_ACPI_TABLE_PROTOCOL  *This,<br>  IN  UINTN                    TableKey    // the key from InstallAcpiTable<br>  );</pre><p>Reverses an install:</p><ol><li>Find the EFI_ACPI_TABLE_LIST node whose Handle == TableKey.</li><li>Remove its pointer from the RSDT and XSDT entry arrays (and, if it was the FADT/DSDT/FACS, clear the corresponding special fields).</li><li>Shrink the RSDT/XSDT Length, re-pack the entry arrays.</li><li><strong>Recompute checksums</strong> on RSDT, XSDT (and FADT if a pointer field changed).</li><li>gBS-&gt;FreePages the table&#39;s memory and free the list node.</li></ol><p>Uninstall is used mostly during BDS “replace this table with a patched copy”: uninstall the old, install the new.</p><h3>6.3 EFI_ACPI_SDT_PROTOCOL</h3><pre>typedef struct _EFI_ACPI_SDT_PROTOCOL {<br>  EFI_ACPI_SDT_ACPI_VERSION    AcpiVersion;     // which versions are active<br>  EFI_ACPI_GET_ACPI_TABLE2     GetAcpiTable;<br>  EFI_ACPI_REGISTER_NOTIFY     RegisterNotify;<br>  EFI_ACPI_OPEN                Open;<br>  EFI_ACPI_OPEN_SDT            OpenSdt;<br>  EFI_ACPI_CLOSE               Close;<br>  EFI_ACPI_GET_CHILD           GetChild;<br>  EFI_ACPI_FIND_PATH           FindPath;<br>  EFI_ACPI_SET_OPTION          SetOption;<br>  EFI_ACPI_GET_OPTION          GetOption;<br>} EFI_ACPI_SDT_PROTOCOL;</pre><p>This is the<strong> read/inspect/edit side</strong>. Where EFI_ACPI_TABLE_PROTOCOL installs <em>whole tables</em>, the SDT protocol<strong> lets you walk the AML tree inside a table</strong> and patch individual objects/fields. It is gated by PcdInstallAcpiSdtProtocol (default FALSE in MdeModulePkg) because exposing mutable ACPI internals is a mild attack surface; platforms that patch AML at BDS enable it.</p><h4>6.3.1 GetAcpiTable()</h4><pre>EFI_STATUS GetAcpiTable (<br>  IN  UINTN                   Index,        // 0-based index into installed tables<br>  OUT EFI_ACPI_SDT_HEADER     **Table,      // pointer to the table header in memory<br>  OUT EFI_ACPI_TABLE_VERSION  *Version,<br>  OUT UINTN                   *TableKey     // same key semantics as install<br>  );</pre><p>Enumerate every installed table. Loop Index = 0,1,2,... until it returns EFI_NOT_FOUND to find, say, the FADT or the DSDT by scanning signatures.</p><h4>6.3.2 FindPath()</h4><pre>EFI_STATUS FindPath (<br>  IN  EFI_ACPI_HANDLE  HandleIn,     // handle to a table/node (from OpenSdt/Open)<br>  IN  VOID             *AcpiPath,    // ASL namespace path, e.g. &quot;\_SB.PCI0._STA&quot;<br>  OUT EFI_ACPI_HANDLE  *HandleOut    // handle to the located AML object<br>  );</pre><p>Resolves an <strong>ACPI namespace</strong> path (like \_SB.GPIO or \_SB.PCI0.RP01) to a handle on the matching AML node so you can read/patch it. This is the workhorse for targeted AML patching in BDS.</p><h4>6.3.3 SetOption() / GetOption()</h4><pre>EFI_STATUS GetOption (<br>  IN  EFI_ACPI_HANDLE     Handle,       // handle to an AML object (e.g., a Name/Data)<br>  IN  UINTN                Index,        // which operand/child of that object<br>  OUT EFI_ACPI_DATA_TYPE  *DataType,    // INTEGER / STRING / OPCODE / CHILD / NAME_STRING<br>  OUT CONST VOID           **Data,       // pointer to the current value bytes<br>  OUT UINTN                *DataSize<br>  );<br><br>EFI_STATUS SetOption (<br>  IN  EFI_ACPI_HANDLE  Handle,<br>  IN  UINTN            Index,<br>  IN  CONST VOID       *Data,        // new value bytes (must match size/type)<br>  IN  UINTN            DataSize<br>  );</pre><p>GetOption reads a specific operand of an AML object; SetOption overwrites it in place (same encoded size — you patch a value, you don&#39;t restructure the tree). Example: read \_SB.PCI0._UID then set it to a new integer.</p><blockquote><strong><em>Important</em></strong><em>: After any </em><em>SetOption, the enclosing table&#39;s checksum is stale. You must re-checksum (Section 10.5). Some flows re-install the whole table via </em><em>UninstallAcpiTable/</em><em>InstallAcpiTable so the checksum is redone for you.</em></blockquote><h4>6.3.4 Open / OpenSdt / Close / GetChild</h4><pre>EFI_STATUS OpenSdt (IN UINTN TableKey, OUT EFI_ACPI_HANDLE *Handle);<br>    // open a whole installed table (by its key) --&gt; root handle<br>EFI_STATUS Open (IN VOID *Buffer, OUT EFI_ACPI_HANDLE *Handle);<br>    // open an in-memory table/AML buffer --&gt; root handle<br>EFI_STATUS Close (IN EFI_ACPI_HANDLE Handle);<br>    // release a handle obtained from Open/OpenSdt/GetChild/FindPath<br>EFI_STATUS GetChild (IN OUT EFI_ACPI_HANDLE *Handle, ...);<br>    // iterate children of an AML node (walk the namespace tree one level down)</pre><p>Typical AML-walk pattern:</p><pre>OpenSdt(dsdtKey, &amp;root)<br>  └─ FindPath(root, &quot;\_SB.GPIO&quot;, &amp;node)     // jump straight to a node<br>       └─ GetOption(node, idx, &amp;type,&amp;data,&amp;sz)  // read current value<br>       └─ SetOption(node, idx, newData, sz)      // patch it<br>  └─ Close(node)<br>Close(root)</pre><p>or a full crawl: <strong>OpenSdt--&gt;GetChild (loop) --&gt; GetChild ...--&gt; Close</strong>.</p><h3>6.4 How RSDP gets registered in the EFI System Configuration Table</h3><p>The OS/loader in the UEFI world does not scan low memory for &quot;RSD PTR &quot;. Instead it walks gST-&gt;ConfigurationTable[] looking for the ACPI GUID. So the final act of ACPI publication is:</p><pre>// After the RSDP is built and points at the (X)RSDT:<br>gBS-&gt;InstallConfigurationTable (&amp;gEfiAcpiTableGuid,   Rsdp);  // ACPI 2.0+  (EFI_ACPI_20_TABLE_GUID)<br>gBS-&gt;InstallConfigurationTable (&amp;gEfiAcpi10TableGuid, Rsdp);  // ACPI 1.0   (ACPI_TABLE_GUID) - optional/legacy</pre><ul><li>gEfiAcpiTableGuid (a.k.a. gEfiAcpi20TableGuid) = 8868E871-E4F1-11D3-BC22-0080C73C8881 — the modern GUID an OS looks for.</li><li>gEfiAcpi10TableGuid = EB9D2D30-2D88-11D3-9A16-0090273FC14D — legacy.</li></ul><p>InstallConfigurationTable adds/updates an EFI_CONFIGURATION_TABLE entry {VendorGuid, VendorTable=Rsdp} in gST-&gt;ConfigurationTable and bumps gST-&gt;NumberOfTableEntries. From then on any UEFI application (including the OS loader) finds ACPI with:</p><pre>for (i = 0; i &lt; gST-&gt;NumberOfTableEntries; i++)<br>  if (CompareGuid(&amp;gST-&gt;ConfigurationTable[i].VendorGuid, &amp;gEfiAcpiTableGuid))<br>    Rsdp = gST-&gt;ConfigurationTable[i].VendorTable;</pre><p>AcpiTableDxe performs this registration itself (in AcpiTableAcpiTableConstructor / when the first table is installed and the RSDP becomes valid), so platform code never has to.</p><h3>6.5 Code walkthrough: AcpiTableDxe entry point</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y8zABTb1kXWeJE412jEg0w.jpeg" /></figure><p>The moment gEfiAcpiTableProtocolGuid is installed, the DXE dispatcher re-checks DEPEXes, finds AcpiPlatformDxe now satisfiable, and dispatches it. Control flow naturally hands over to Section 7.</p><h3>7. AcpiPlatformDxe Driver (Deep Dive)</h3><p>AcpiPlatformDxe is the <strong>platform-specific producer</strong>. Location varies by board: &lt;Board&gt;Pkg/Acpi/AcpiPlatformDxe/, or generically EmulatorPkg/OvmfPkg/AcpiPlatformDxe, or ARM&#39;s ArmPlatformPkg/silicon-vendor packages. Whatever the location, its shape is the same:<strong> locate the table protocol, then install every table this board needs.</strong></p><h3>7.1 How it locates EFI_ACPI_TABLE_PROTOCOL</h3><p>Two common patterns:</p><p><strong>(a) DEPEX-gated LocateProtocol (simplest).</strong> Because the .inf [Depex] already contains gEfiAcpiTableProtocolGuid, the driver is only dispatched once the protocol exists, so a plain LocateProtocol cannot fail:</p><pre>EFI_STATUS<br>EFIAPI<br>AcpiPlatformEntryPoint (<br>IN EFI_HANDLE ImageHandle, <br>IN EFI_SYSTEM_TABLE *SystemTable<br>)<br>{<br>  EFI_STATUS               Status;<br>  EFI_ACPI_TABLE_PROTOCOL  *AcpiTable;<br>  Status = gBS-&gt;LocateProtocol (<br>                  &amp;gEfiAcpiTableProtocolGuid, <br>                  NULL, (VOID **)&amp;AcpiTable<br>                  );<br>  ASSERT_EFI_ERROR (Status);   // guaranteed present due to DEPEX<br>  ...<br>}</pre><p><strong>(b) Protocol-notify callback (order-independent)</strong>. Register for notification so the install runs whenever the protocol appears - robust even without a DEPEX:</p><pre>EfiCreateProtocolNotifyEvent (<br>  &amp;gEfiAcpiTableProtocolGuid,<br>  TPL_CALLBACK,<br>  AcpiTableNotificationEvent,   // callback does LocateProtocol + installs tables<br>  NULL,<br>  &amp;Registration);</pre><h3>7.2 Installing all static tables (FADT, MADT, GTDT, …)</h3><p><strong>Static </strong>tables are those compiled/known at build time (as C structs in .h/.c or as .aml/.acpi blobs). The driver iterates them and calls InstallAcpiTable for each. The set depends on architecture:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5ea7a104ba915dc84c142e108f05595/href">https://medium.com/media/c5ea7a104ba915dc84c142e108f05595/href</a></iframe><blockquote><em>On ARM64 the interrupt/timer story is GTDT + MADT-with-GIC + PPTT + IORT, and there is typically no </em><strong><em>MADT</em></strong><em>-with-</em><strong><em>LAPIC </em></strong><em>and no FACS. On x86 it is MADT-with-APIC + FACS, no GTDT/IORT.</em></blockquote><p>Typical loop:</p><pre>STATIC EFI_ACPI_DESCRIPTION_HEADER *mTables[] = {<br>  (VOID *)&amp;Fadt, (VOID *)&amp;Madt, (VOID *)&amp;Gtdt, (VOID *)&amp;Mcfg, (VOID *)&amp;Spcr, ...<br>};<br>for (i = 0; i &lt; ARRAY_SIZE(mTables); i++) {<br>  UINTN Key;<br>  // (optionally patch fields from HOB/PCD before install)<br>  Status = AcpiTable-&gt;InstallAcpiTable (<br>             AcpiTable,<br>             mTables[i],<br>             mTables[i]-&gt;Length,     // header Length field is authoritative<br>             &amp;Key);<br>  ASSERT_EFI_ERROR (Status);<br>}</pre><h3>7.3 Loading AML tables from a Firmware Volume</h3><p>DSDT/SSDT AML is often not a C struct — it’s compiled ASL (.asl → .aml via iasl) stored as a raw section inside an FFS file in a Firmware Volume. The driver reads it out with the FV protocol and installs the blob:</p><pre>// Locate all FV2 protocol instances<br>gBS-&gt;LocateHandleBuffer (ByProtocol, &amp;gEfiFirmwareVolume2ProtocolGuid,<br>                          NULL, &amp;NumberOfHandles, &amp;HandleBuffer);<br>for (Index = 0; Index &lt; NumberOfHandles; Index++) {<br>  gBS-&gt;HandleProtocol (HandleBuffer[Index], &amp;gEfiFirmwareVolume2ProtocolGuid,<br>                        (VOID **)&amp;FwVol);<br>  SectionInstance = 0;<br>  do {<br>    // Read the RAW section that holds one AML table (DSDT or SSDT)<br>    Status = FwVol-&gt;ReadSection (<br>               FwVol,<br>               &amp;gEfiCallerIdGuid,        // FFS file GUID that contains the AML<br>               EFI_SECTION_RAW,<br>               SectionInstance,          // 0,1,2,... to walk multiple SSDTs<br>               &amp;Buffer,                  // allocated by FV, holds the table<br>               &amp;Size,<br>               &amp;FvStatus);<br>    if (EFI_ERROR (Status)) break;<br>    // Sanity: the RAW blob starts with an ACPI header; validate its Length<br>    Table = (EFI_ACPI_DESCRIPTION_HEADER *)Buffer;<br>    // Hand the AML to AcpiTableDxe (it copies into ACPI reclaim memory)<br>    AcpiTable-&gt;InstallAcpiTable (AcpiTable, Table, Table-&gt;Length, &amp;TableKey);<br>    gBS-&gt;FreePool (Buffer);                    // FV buffer no longer needed<br>    SectionInstance++;<br>  } while (!EFI_ERROR (Status));<br>}</pre><p>Key subtleties:</p><ul><li>ReadSection with an incrementing SectionInstance is the idiom for pulling <strong>multiple SSDTs</strong> out of one FFS file.</li><li>The FV-provided Buffer is a working copy; InstallAcpiTable copies it again into ACPI-typed memory, so the driver frees Buffer right after.</li><li>On some platforms the DSDT/SSDT is instead linked in as a byte array (AmlCode[] generated from iasl -tc) and installed directly - no FV read.</li></ul><h3>7.4 DSDT installation and the FADT XDsdt pointer</h3><p>The DSDT is not referenced through the XSDT. It is reached only through the FADT’s Dsdt (32-bit) and X_Dsdt (64-bit) fields. So installing a DSDT is a two-step dance, and AcpiTableDxe handles it inside InstallAcpiTable when it sees the DSDT signature:</p><pre>InstallAcpiTable(DSDT buffer)<br>     ├─ copy DSDT into EfiACPIReclaimMemory → DsdtPhysAddr<br>     ├─ record it in the instance (AcpiTableInstance-&gt;Dsdt = ...)<br>     ├─ DO NOT add DSDT to XSDT/RSDT entry array<br>     └─ if a FADT already exists:<br>             Fadt-&gt;Dsdt  = (UINT32) DsdtPhysAddr;    // low 32 bits<br>             Fadt-&gt;XDsdt = (UINT64) DsdtPhysAddr;    // full 64-bit<br>             re-checksum FADT</pre><p><strong>Ordering matters:</strong> if the FADT is installed <em>after</em> the DSDT, the driver fills the FADT’s DSDT pointers at FADT-install time from the remembered DSDT address; if the DSDT is installed after the FADT, it back-patches the existing FADT. Either order works because AcpiTableDxe tracks the current FADT/DSDT/FACS in its instance.</p><blockquote><em>Both </em><em>Dsdt and </em><em>X_Dsdt are set. Modern OSes use </em><em>X_Dsdt; if it is non-zero it takes precedence. On systems where the DSDT sits above 4 GiB, the 32-bit </em><em>Dsdt field is set to 0 and only </em><em>X_Dsdt is valid.</em></blockquote><h3>7.5 FACS allocation in EfiACPIMemoryNVS</h3><p>The <strong>FACS</strong> (Firmware ACPI Control Structure) is unique:</p><ul><li>It contains the <strong>firmware waking vector </strong>and the <strong>global lock - </strong>memory the hardware/OS write to at runtime (e.g., on resume from S3). It therefore must never be reclaimed, so it is placed in EfiACPIMemoryNVS (<strong>type 10</strong>), not EfiACPIReclaimMemory.</li><li>It has <strong>no checksum</strong> of its own and is not an entry in the XSDT/RSDT.</li><li>Like the DSDT it is referenced only through FADT fields: FirmwareCtrl (32-bit) and X_FirmwareCtrl (64-bit).</li><li>It generally must be <strong>32-bit addressable</strong> and aligned (64-byte) because legacy waking logic uses the 32-bit FirmwareCtrl.</li></ul><p>AcpiTableDxe special-cases FACS in InstallAcpiTable:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3h6uEHyOjvJYR3QCdSoTsg.jpeg" /></figure><blockquote><em>ARM64 systems that don’t support the legacy sleep model often omit FACS entirely and use hardware-reduced ACPI (FADT </em><em>HW_REDUCED_ACPI flag set). In that case no FACS is installed and the FADT FACS pointers stay 0.</em></blockquote><h3>7.6 Code walkthrough: the InstallAcpiTable() calls</h3><p>Putting 7.1–7.5 together, a representative AcpiPlatformDxe flow:</p><pre>AcpiPlatformEntryPoint()<br>     ├─ LocateProtocol(gEfiAcpiTableProtocolGuid) --&gt;AcpiTable<br>     ├─ (read platform HOBs/PCDs: CPU count, memory map, board id)<br>     ├─ InstallAcpiTable(FADT)     // installs FADT; DSDT/FACS ptrs filled as those install<br>     ├─ InstallAcpiTable(FACS)     // --&gt; NVS, back-patches FADT.[X]FirmwareCtrl<br>     ├─ InstallAcpiTable(DSDT)     // --&gt;reclaim, back-patches FADT.[X]Dsdt (not in XSDT)<br>     ├─ InstallAcpiTable(MADT/GTDT)// added to XSDT/RSDT<br>     ├─ InstallAcpiTable(MCFG)     // added to XSDT/RSDT<br>     ├─ InstallAcpiTable(SPCR)     // added to XSDT/RSDT<br>     ├─ ... (loop over remaining static tables)<br>     ├─ ReadSection(FV) loop --&gt;InstallAcpiTable(SSDT[0..n])<br>     └─ return EFI_SUCCESS</pre><p>At the end of AcpiPlatformDxe, the ACPI tree is fully built in memory and the RSDP already sits in the System Configuration Table (done by AcpiTableDxe). Only BDS-time finalization (Section 10) remains.</p><h3>8. What InstallAcpiTable() Does Internally</h3><blockquote><em>This is the heart of </em><em>AcpiTableProtocol.c. The public </em><em>InstallAcpiTable wraps an internal </em><em>AddTableToList() plus root-table publication. Full algorithm:</em></blockquote><pre>InstallAcpiTable(This, Buffer, BufferSize, *TableKey)<br>├─ 1. Validate:<br>     │       • Buffer != NULL, BufferSize &gt;= sizeof(header)<br>     │       • header.Length == BufferSize (or within bounds)<br>     │       • recover AcpiTableInstance from This (CR() macro / global)<br>     │<br>     ├─ 2. AddTableToList(Instance, Buffer, TRUE /*checksum*/, Version, &amp;Handle):<br>     │       ├─ a. Allocate an EFI_ACPI_TABLE_LIST node (pool)<br>     │       │<br>     │       ├─ b. Decide memory type + allocation by signature:<br>     │       │        FACS → EfiACPIMemoryNVS   (type 10), &lt;4GiB, 64B aligned<br>     │       │        else → EfiACPIReclaimMemory(type 9)<br>     │       │        AllocatePages(rounded-up pages), get PhysAddr<br>     │       │<br>     │       ├─ c. CopyMem(PhysAddr, Buffer, header.Length)  // firmware owns this copy<br>     │       │<br>     │       ├─ d. node-&gt;Table = PhysAddr; node-&gt;PageCount = ...; node-&gt;Handle = ++counter<br>     │       │<br>     │       ├─ e. Special-case by signature:<br>     │               FADT (FACP):<br>     │                   Instance-&gt;Fadt = copy<br>     │                   if Instance-&gt;Dsdt: Fadt-&gt;Dsdt/XDsdt = Dsdt addr<br>     │                   if Instance-&gt;Facs: Fadt-&gt;FirmwareCtrl/XFirmwareCtrl = Facs addr<br>     │                   (also sync Fadt-&gt;Facs into RSDT/XSDT? NO - FADT itself goes in)<br>     │                   --&gt;FADT *is* added to XSDT/RSDT (below)<br>     │               DSDT:<br>     │                   Instance-&gt;Dsdt = copy<br>     │                   if Instance-&gt;Fadt: back-patch Fadt-&gt;[X]Dsdt<br>     │                   --&gt; NOT added to XSDT/RSDT<br>     │               FACS:<br>     │                   Instance-&gt;Facs = copy<br>     │                   if Instance-&gt;Fadt: back-patch Fadt-&gt;[X]FirmwareCtrl<br>     │                   --&gt; NOT added to XSDT/RSDT<br>     │               others:<br>     │                   --&gt; added to XSDT/RSDT<br>     │<br>     ├─ f. Checksum the copied table (unless FACS/DSDT rules differ):<br>     │       AcpiPlatformChecksum(): zero the Checksum byte, sum all bytes<br>     │       mod 256, store (0x100 - sum) &amp; 0xFF so total == 0.<br>     │<br>     ├─ 3. If table belongs in the roots --&gt;AddTableToRsdtXsdt():<br>     │       ├─ ensure the RSDT/XSDT entry arrays have room (reallocate + grow if full)<br>     │       ├─ RSDT: append (UINT32) PhysAddr   (skip if RSDT disabled/ARM)<br>     │       ├─ XSDT: append (UINT64) PhysAddr<br>     │       ├─ bump RSDT.Length / XSDT.Length by pointer size<br>     │       └─ re-checksum RSDT and XSDT<br>     │<br>     ├─ 4. If FADT pointers changed → re-checksum FADT<br>     │<br>     ├─ 5. *TableKey = node-&gt;Handle<br>     │<br>     ├─ 6. (SDT enabled) SdtNotifyAcpiList(): invoke RegisterNotify callbacks<br>     │       so any registered observer sees the new/changed table<br>     │<br>     └─ 7. return EFI_SUCCESS</pre><h3>8.1 Memory allocation (EfiACPIReclaimMemory)</h3><ul><li>Default type is <strong>EfiACPIReclaimMemory</strong> (9): the OS may reuse this RAM <em>after</em> it has parsed/copied the tables. Almost every table (RSDP, RSDT, XSDT, FADT, MADT/GTDT, DSDT, SSDT, MCFG, ...) lives here.</li><li><strong>EfiACPIMemoryNVS</strong> (10) is reserved for FACS and any region hardware/OS may write at runtime - never reclaimed.</li><li>Allocation is by <strong>pages</strong> (gBS-&gt;AllocatePages, 4 KiB granularity) even for small tables, because ACPI regions must be page-aligned in the memory map so the OS sees clean, typed ranges. The node records PageCount so uninstall can free exactly.</li><li>Address constraints: FACS (and often RSDP/RSDT on x86) prefer below 4 GiB; AllocatePages(AllocateMaxAddress, ..., 0xFFFFFFFF, ...) enforces it.</li></ul><h3>8.2 Checksum computation</h3><p>Every ACPI table (except FACS, which has none, and the RSDP which has <em>two</em> special checksums) must have SUM(all bytes) mod 256 == 0:</p><pre>VOID AcpiPlatformChecksum (VOID *Buffer, UINTN Size, UINTN ChecksumOffset) {<br>  UINT8 Sum = 0;<br>  ((UINT8 *)Buffer)[ChecksumOffset] = 0;      // clear existing checksum<br>  for (UINTN i = 0; i &lt; Size; i++)<br>    Sum = (UINT8)(Sum + ((UINT8 *)Buffer)[i]);   // 8-bit wrap<br>  ((UINT8 *)Buffer)[ChecksumOffset] = (UINT8)(0x100 - Sum);  // make total 0<br>}</pre><p>RSDP specifics:</p><ul><li>Checksum covers the first 20 bytes (ACPI 1.0 part).</li><li>ExtendedChecksum covers the entire Length (typically 36 bytes, ACPI 2.0).</li><li>Both must be recomputed whenever RsdtAddress/XsdtAddress change.</li></ul><p>Any time a pointer inside a table changes (XSDT gains an entry, FADT gets its DSDT/FACS filled), that table’s checksum is redone — otherwise the OS rejects it.</p><h3>8.3 Adding the pointer to the XSDT</h3><p>The XSDT/RSDT are just headers followed by a packed array of table pointers. The “entry count” is derived: (Header.Length - sizeof(Header)) / entry_size (4 bytes RSDT, 8 bytes XSDT). To add a table:</p><pre>Before:  [XSDT hdr | &amp;FADT | &amp;MADT ]              Length = 36 + 2*8 = 52<br>Add MCFG:<br>         reallocate XSDT if the current page cannot hold one more 8-byte entry<br>         write &amp;MCFG at offset (Length)<br>         Length += 8                              Length = 60<br>         re-checksum XSDT<br>After:   [XSDT hdr | &amp;FADT | &amp;MADT | &amp;MCFG ]</pre><p>Because growing the array may require a larger allocation, the XSDT can be reallocated and moved - in which case RSDP.XsdtAddress is updated and the RSDP re-checksummed. AcpiTableDxe typically pre-allocates space for a sensible maximum entry count (EFI_ACPI_MAX_NUM_TABLES, PCD-tunable) to avoid churn.</p><h3>8.4 Notifying registered callbacks</h3><p>When the SDT protocol is enabled, AcpiTableDxe maintains a list of notification callbacks registered via EFI_ACPI_SDT_PROTOCOL.RegisterNotify. After a table is added/removed/modified, it invokes each callback with the table pointer and version. Uses:</p><ul><li>A platform component that wants to <strong>observe/patch</strong> every table as it is installed (e.g., stamp a common OEM ID, or record addresses for later BDS patching).</li><li><strong>Debug/telemetry: </strong>log every ACPI table the platform emits.</li></ul><pre>InstallAcpiTable(...) — success --&gt;for each registered Notify:<br>                                     Notify(Table, Version, TableKey)</pre><p>This closes the loop: installation is not just “write memory,” it’s a small event system so other DXE/BDS components can react to ACPI changes as they happen.</p><h3>9. Memory Layout After DXE</h3><h3>9.1 Physical memory diagram</h3><p>After DXE completes, physical DRAM holds the full ACPI tree. A representative layout (addresses illustrative; exact placement is allocator-dependent):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LsmQewbA9eWHk8du4fzfUQ.png" /></figure><h3>9.2 RSDP →XSDT → all table pointers</h3><p>The discovery chain the OS follows at boot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gNmxsdvm8dghErDwwNZzvQ.jpeg" /></figure><p>Two <strong>exceptions to the XSDT rule</strong> to always remember:</p><ul><li><strong>DSDT</strong> is reached <strong>only</strong> through FADT.Dsdt/FADT.X_Dsdt.</li><li><strong>FACS</strong> is reached <strong>only</strong> through FADT.FirmwareCtrl/FADT.X_FirmwareCtrl.</li></ul><p>Everything else is an entry in the XSDT (and, on legacy x86, mirrored in the RSDT).</p><h3>9.3 FADT → DSDT, FACS special handling recap</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2496c3a49d9936dd0b6808ddfaeec85f/href">https://medium.com/media/2496c3a49d9936dd0b6808ddfaeec85f/href</a></iframe><h3>10. BDS Phase - Final Patching</h3><p>By BDS the ACPI tree is fully installed, but often not yet final. BDS is where runtime-discovered or graphics/console-dependent values get written in. All BDS patching uses EFI_ACPI_SDT_PROTOCOL (read/edit) and, when replacing whole tables, EFI_ACPI_TABLE_PROTOCOL (uninstall/install).</p><h3>10.1 AML patching with EFI_ACPI_SDT_PROTOCOL</h3><p><strong>Pattern:</strong> locate the table →open it → navigate to the AML object → patch value → re-checksum.</p><pre>// 1. Find the DSDT among installed tables<br>for (Index = 0; ; Index++) {<br>  Status = mSdt-&gt;GetAcpiTable (Index, &amp;Table, &amp;Version, &amp;TableKey);<br>  if (EFI_ERROR (Status)) break;              // no more tables<br>  if (Table-&gt;Signature == SIGNATURE_32(&#39;D&#39;,&#39;S&#39;,&#39;D&#39;,&#39;T&#39;)) break;<br>}<br>// 2. Open the table and locate a node by ACPI path<br>mSdt-&gt;OpenSdt (TableKey, &amp;TableHandle);<br>mSdt-&gt;FindPath (TableHandle, &quot;\_SB.GPIO._STA&quot;, &amp;NodeHandle);<br>// 3. Read the current operand, then overwrite it<br>mSdt-&gt;GetOption (NodeHandle, 1, &amp;DataType, &amp;Data, &amp;DataSize);<br>NewVal = 0x0F;                                 // e.g., force device present+enabled<br>mSdt-&gt;SetOption (NodeHandle, 1, &amp;NewVal, DataSize);   // same encoded size!<br>// 4. Release handles<br>mSdt-&gt;Close (NodeHandle);<br>mSdt-&gt;Close (TableHandle);<br>// 5. Re-checksum (Section 10.5) - SetOption does NOT do it for you</pre><p>Common BDS patch targets: _UID, _STA (presence), _CRS (interrupt/GPIO/BAR numbers discovered at runtime), MAC addresses, board revision, memory sizes.</p><h3>10.2 Dynamic SSDT injection</h3><p>Some AML must be <strong>generated at runtime</strong> (e.g., per-CPU _CST/_PSS power states, hot-pluggable devices, NVDIMM regions, or values known only after hardware enumeration). Rather than patch the DSDT, firmware builds a fresh <strong>SSDT</strong> and installs it:</p><pre>BDS: enumerate CPUs / devices at runtime<br>     ├─ Build an SSDT in a buffer  (hand-assembled AML, or via the<br>     │     DynamicTablesPkg &quot;AML Codegen&quot; / Configuration Manager on ARM)<br>     └─ AcpiTable-&gt;InstallAcpiTable(ssdtBuffer, size, &amp;Key)<br>             --&gt; new SSDT copied to reclaim memory<br>             --&gt; appended to XSDT (auto-checksummed)</pre><p>On modern ARM64 EDK2, this is often the whole <strong>DynamicTablesPkg</strong> story: a <strong>Configuration Manager</strong> protocol supplies platform data, and generators emit FADT/GTDT/MADT/DBG2/SSDT programmatically at BDS - replacing hand-written static tables. Either way the sink is the same InstallAcpiTable.</p><h3>10.3 BGRT bitmap update</h3><p>The <strong>BGRT</strong> (Boot Graphics Resource Table) tells the OS what logo the firmware drew and where, so the OS can continue a seamless boot animation. The bitmap address and the “displayed” status can only be known <strong>after</strong> the Graphics Output Protocol (GOP) has drawn the logo - which happens in BDS. So:</p><pre>BDS console/logo step:<br>     ├─ GOP available --&gt;draw OEM logo bitmap to framebuffer/offscreen<br>     ├─ Fill BGRT:<br>     │       Bgrt-&gt;ImageAddress    = &lt;phys addr of the BMP in memory&gt;<br>     │       Bgrt-&gt;ImageOffsetX/Y  = &lt;where it was drawn&gt;<br>     │       Bgrt-&gt;Status          = 1 (displayed) | orientation bits<br>     └─ InstallAcpiTable(Bgrt) or SetOption/re-checksum if already installed</pre><p>The BMP itself must sit in firmware-reserved/ACPI memory that survives to the OS.</p><h3>10.4 Final checksum recalculation</h3><p>Any table modified in BDS (via SetOption, direct memory poke, or pointer changes) has a <strong>stale checksum</strong> and will be rejected by the OS. BDS must fix every touched table:</p><pre>// Re-checksum a table after in-place edits<br>AcpiPlatformChecksum (Table, Table-&gt;Length,<br>                       OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Checksum));</pre><p>Cascade to remember:</p><pre>Edit DSDT AML   --&gt; re-checksum DSDT<br>Add SSDT        --&gt; XSDT gained entry --&gt; re-checksum XSDT<br>Move XSDT       --&gt; RSDP.XsdtAddress changed --&gt; re-checksum RSDP (both checksums)<br>Patch FADT ptr  --&gt; re-checksum FADT</pre><p>If you install/uninstall through the protocols, checksums are handled for you; if you poke memory directly, you own every affected checksum.</p><h3>10.5 Where BDS patching lives in code</h3><pre>BdsEntry (BDS Architectural Protocol)              // MdeModulePkg/Universal/BdsDxe<br>     ├─ PlatformBootManagerBeforeConsole()          // connect early, security<br>     ├─ Connect consoles, GOP → draw logo --&gt;BGRT<br>     ├─ PlatformBootManagerAfterConsole()<br>     │       └─ (platform hook) FinalizeAcpiTables():<br>     │               LocateProtocol(gEfiAcpiSdtProtocolGuid)<br>     │               patch DSDT/SSDT via FindPath/SetOption<br>     │               inject dynamic SSDTs via InstallAcpiTable<br>     │               recompute checksums<br>     ├─ Enumerate boot options (BootOrder / Boot####)<br>     └─ Launch selected OS loader --&gt;TSL</pre><p>At ExitBootServices() the firmware stops touching ACPI; the reclaim/NVS ranges are frozen and handed to the OS through the memory map, and the OS parses the tree starting from the RSDP it found in the configuration table</p><h3>11. Key Takeaways + Protocol Summary Table</h3><h3>11.1 Key takeaways</h3><ol><li><strong>Phase discipline drives ACPI</strong>. SEC survives, PEI brings up DRAM + HOBs, DXE builds ACPI, BDS finalizes it, TSL/OS consumes it. Each capability ACPI needs (stable memory, typed allocation, protocols, config table) appears exactly at DXE — which is why ACPI lives there.</li><li>Two drivers, clean split of concerns:</li></ol><ul><li>AcpiTableDxe (generic, MdeModulePkg) — owns RSDP/RSDT/XSDT, publishes the protocols, does all the mechanical bookkeeping (memory typing, checksums, entry arrays, FADT/DSDT/FACS special-casing).</li><li>AcpiPlatformDxe (board-specific) — knows <em>which</em> tables this hardware needs and their contents; just calls InstallAcpiTable for each.</li></ul><p>3. <strong>DEPEX wires them without hardcoding order</strong>. AcpiPlatformDxe&#39;s DEPEX names gEfiAcpiTableProtocolGuid, so it can&#39;t dispatch until AcpiTableDxe publishes it. Data dependency = ordering.</p><p>4. <strong>DSDT and FACS are special - memorize it</strong>. Neither is in the XSDT/RSDT; both are reached only through FADT fields. FACS goes in EfiACPIMemoryNVS and has no checksum; everything else defaults to EfiACPIReclaimMemory.</p><p>5. <strong>The RSDP handoff is the whole contract</strong>. DXE puts the RSDP into gST-&gt;ConfigurationTable under gEfiAcpiTableGuid. That single GUID lookup is how every UEFI-era OS finds ACPI. No low-memory scanning.</p><p>6. <strong>Checksums are non-negotiable.</strong> Every mutation (add XSDT entry, fill FADT pointer, patch AML) invalidates a checksum. Use the install/uninstall protocol path (auto-checksum) or recompute by hand — a wrong checksum = the OS silently drops the table.</p><p>7. <strong>BDS is the last mile.</strong> Runtime-discovered values, dynamic SSDTs, and the BGRT logo are patched in BDS via EFI_ACPI_SDT_PROTOCOL, then re-checksummed, before the OS loader runs.</p><p>8. <strong>Architecture matters. </strong>x86: RSDT+XSDT, MADT-with-APIC, FACS present. ARM64: XSDT-only, GTDT + MADT-with-GIC</p><ul><li>PPTT + IORT, hardware-reduced ACPI (often no FACS), tables frequently produced by DynamicTablesPkg at BDS rather than static blobs.</li></ul><h3>11.2 Protocol / API summary</h3><h4>EFI_ACPI_TABLE_PROTOCOL</h4><ul><li><strong>GUID / Where:</strong> gEfiAcpiTableProtocolGuid</li><li><strong>Direction:</strong> Write</li><li><strong>Key functions:</strong> InstallAcpiTable, UninstallAcpiTable</li><li><strong>Used by:</strong> AcpiPlatformDxe, BDS finalizers</li></ul><h4>EFI_ACPI_SDT_PROTOCOL</h4><ul><li><strong>GUID / Where: </strong>gEfiAcpiSdtProtocolGuid (PCD-gated)</li><li><strong>Direction: </strong>Read/Edit</li><li><strong>Key functions: </strong>GetAcpiTable, OpenSdt / Open, Close, GetChild, FindPath, GetOption, SetOption, RegisterNotify</li><li><strong>Used by:</strong> BDS AML patchers, observers</li></ul><h4>InstallConfigurationTable</h4><ul><li><strong>GUID / Where:</strong> Boot Service (gBS)</li><li><strong>Direction: </strong>Publish RSDP</li><li><strong>Key functions:</strong> —</li><li><strong>Used by:</strong> AcpiTableDxe (registers RSDP under gEfiAcpiTableGuid)</li></ul><h4>LocateProtocol / RegisterProtocolNotify</h4><ul><li><strong>GUID / Where:</strong> Boot Service (gBS)</li><li><strong>Direction: </strong>Discover</li><li><strong>Key functions: </strong>—</li><li><strong>Used by:</strong> AcpiPlatformDxe (finds table protocol)</li></ul><h4>EFI_FIRMWARE_VOLUME2_PROTOCOL</h4><ul><li><strong>GUID / Where:</strong> gEfiFirmwareVolume2ProtocolGuid</li><li><strong>Direction:</strong> Read AML</li><li><strong>Key functions:</strong> ReadSection</li><li><strong>Used by:</strong> AcpiPlatformDxe (loads DSDT/SSDT blobs)</li></ul><h4>AllocatePages (typed)</h4><ul><li><strong>GUID / Where:</strong> Boot Service (gBS)</li><li><strong>Direction:</strong> Memory</li><li><strong>Key functions:</strong> NA</li><li><strong>Used by:</strong> AcpiTableDxe (EfiACPIReclaimMemory / EfiACPIMemoryNVS)</li></ul><h3>11.3 Key Flow Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wwVJAnY6Z96fqBKEQGaBng.jpeg" /></figure><h3>References</h3><p><strong>ACPI specification</strong></p><ol><li>ACPI Specifications (UEFI Forum) — <a href="https://uefi.org/acpi/specs">https://uefi.org/acpi/specs</a></li><li>ACPI Spec 6.4, full text (HTML) — <a href="https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/">https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/</a></li></ol><p><strong>ACPICA (reference AML interpreter, used directly by Linux)</strong><br> 3. ACPICA documentation &amp; user guide (Intel) — <a href="https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html">https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html</a><br> 4. ACPICA source (GitHub) — <a href="https://github.com/acpica/acpica">https://github.com/acpica/acpica</a></p><p><strong>Linux ACPI implementation</strong><br> 5. Linuxized ACPICA — how Linux syncs with upstream ACPICA — <a href="https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html">https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html</a><br> 6. Linux kernel ACPI driver-api docs — <a href="https://docs.kernel.org/driver-api/acpi/index.html">https://docs.kernel.org/driver-api/acpi/index.html</a><br> 7. Linux kernel source, drivers/acpi — <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi</a></p><p><strong>Windows internals</strong><br> 8. Windows Driver Kit — Kernel-Mode Driver Architecture — <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/">https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/</a><br> 9. Russinovich, Solomon, Ionescu — <em>Windows Internals</em>, Part 1 (7th ed.) — standard secondary source for undocumented boot/HAL routines like KiSystemStartup, HalInitSystem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16511a1f9b27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing ACPI Source Language and Description Table]]></title>
            <link>https://medium.com/@kushaldps1996/writing-acpi-source-language-and-description-table-2c01313a0354?source=rss-20cb97d60801------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c01313a0354</guid>
            <dc:creator><![CDATA[KUSHAL CHAKRABORTY]]></dc:creator>
            <pubDate>Sun, 02 Aug 2026 17:55:12 GMT</pubDate>
            <atom:updated>2026-08-02T17:55:12.702Z</atom:updated>
            <content:encoded><![CDATA[<p>The fundamental question: <em>How does OS know your I2C controller is at address (say 0x11007000) ?</em></p><h3>Table Of Contents</h3><p><strong>1. Introduction</strong></p><p><strong>2. ASL — ACPI Source Language</strong></p><p>2.1 What ASL Looks Like</p><p>2.2 Namespace Concepts</p><p>2.2.1 What Does ACPI Namespace Solve?</p><p>2.2.2 The Address of an ACPI Object</p><p>2.2.3 Common Top-Level Folders You Will See</p><p>2.2.4 What Exactly Lives in the Namespace</p><p>2.2.5 How the OS Uses Namespace</p><p>2.3 Key ASL Constructs</p><p>2.3.1 Device()</p><ul><li>Device Names: Why 4 Characters?</li><li>Where You Usually Put Devices</li><li>What the OS Expects Inside a Device()</li><li>Child Devices Under a Controller</li></ul><p>2.3.2 Processor()</p><ul><li>What Does Processor() Look Like?</li><li>What Happens When Firmware Defines Processor()?</li><li>What Do the Parameters Mean?</li><li>How Does the OS Actually Use Processor()?</li><li>Where Does Processor() Usually Appear? (_PR)</li><li>Attaching P-States (Performance States)</li><li>Attaching C-States (Idle States)</li></ul><p>2.3.3 ThermalZone()</p><ul><li>Why Do We Need a Thermal Zone?</li><li>What Does ThermalZone() Look Like?</li><li>Where It Appears in the Namespace</li><li>What Happens When the OS Boots</li><li>The Most Important Method: _TMP</li><li>Trip Points: Passive (_PSV) and Critical (_CRT)</li><li>Active Cooling: _AC0/_AC1 and _AL0/_AL1</li><li>Cooling Devices</li><li>Polling vs. Event-Driven Response</li><li>Multiple Thermal Zones</li></ul><p>2.3.4 Name()</p><ul><li>What Can Name() Store?</li><li>Why Use Name() Instead of Hardcoding Numbers?</li><li>Reserved Names: _HID, _CID, _UID, _DEP, _DSD</li></ul><p>2.3.5 Method()</p><ul><li>What Does Method() Look Like?</li><li>What Happens When the OS Boots?</li><li>Where Are Methods Used?</li><li>Method Name Rules</li><li>Arguments and Local Variables</li><li>Serialization: NotSerialized vs. Serialized</li><li>What Can a Method Do?</li><li>How a Method Accesses Hardware</li></ul><p><strong>2.4 Detailed Analysis of Key ACPI Constructs</strong></p><p>2.4.1 Method _CRS (Current Resource Settings)</p><ul><li>Why _CRS Exists</li><li>Where _CRS Lives</li><li>What _CRS Returns</li><li>How the OS Uses _CRS</li><li>Common Resource Descriptors (Memory, I/O Ports, Interrupts, GPIO, Serial Bus)</li></ul><p>2.4.2 Method _STA (Status)</p><ul><li>What _STA Returns</li><li>Common _STA Return Values</li><li>Why We Need _STA</li><li>Implementation Patterns</li><li>_STA and Driver Loading</li><li>_STA Interactions with Other Methods</li></ul><p>2.4.3 Method _INI (Initialize)</p><ul><li>What _INI Does</li><li>When the OS Calls _INI</li><li>Example Usage Patterns</li><li>What the OS Does Under the Hood</li><li>_INI and _DEP</li></ul><p>2.4.4 Method _EVT (Event Handling)</p><p>2.4.5 Method _DSM (Device Specific Method)</p><ul><li>Function Index and Function 0</li><li>Example _DSM Implementation</li><li>_DSD vs. _DSM</li></ul><p>2.4.6 OperationRegion()</p><p>2.4.7 _REG Method</p><p>2.4.8 Mutex()</p><ul><li>Acquire/Release</li><li>Mutex vs. Serialized Methods</li><li>SyncLevel</li><li>Timeouts and Failure Handling</li><li>Real-World Use Cases</li><li>Mutex vs. Global Lock</li><li>Practical Power Example</li></ul><p><strong>3. Key Takeaways</strong></p><h3>1. Introduction</h3><p>When OS boots, it must discover what hardware exists and how to talk to it. Some devices are discoverable via buses (PCI enumerates itself), but many platform devices (I2C controllers, GPIO blocks, PMICs thermal sensors, battery fuel gauges, etc) are not self-describing in a generic way.</p><p>That’s where ACPI comes in. UEFI provides the OS with a set of tables that describe:</p><ul><li>Devices present in the system and their relationships</li><li>Resources (MMIO ranges, IRQs, DMA, I/O ports, GPIOs, I2C/SPI Serial buses)</li><li>Control methods (little programs) to manage power, configuration and discovery</li></ul><p>So in the example question - an I2C controller at 0x11007000 - the OS typically learns this from ACPI tables that contain:</p><ul><li>A Device node representing the I2C controller</li><li>A _CRS method returning a resource template that includes:</li></ul><p>a) A Memory32Fixed (or similar) describing the MMIO region</p><p>b) An interrupt descriptor describing the IRQ line(s).</p><p>The OS ACPI subsystem parses those tables, creates device objects, and exposes them to drivers. Drivers match using identifiers like _HID,_CID, and properties from _DSD.</p><h4>High Level Flow</h4><ol><li>UEFI builds ACPI tables containing AML bytecode (compiled from ASL)</li><li>OS loads ACPI tables from UEFI</li><li>OS ACPI interpreter (like ACPICA in Linux) executes control methods (eg. _STA, _CRS).</li><li>OS enumerates devices and binds drivers.</li></ol><h3>2. ASL - ACPI Source Language</h3><h3>2.1 What ASL looks like</h3><p>ASL is a <strong>C-like declarative language</strong> used to describe devices and provide control methods. It compiles into <strong>AML (ACPI Machine Language)</strong>, a compact bytecode.</p><p>Typical ASL file contents :</p><ul><li>One or more <strong>Definition Block sections</strong></li><li>A <strong>namespace rooted at \</strong> with common scopes like \_SB (system bus)</li><li>Devices, methods and resource descriptors</li></ul><pre>DefinitionBlock (&quot;&quot;,&quot;SSDT&quot;,2,&quot;OEMID&quot;,&quot;OEMTAB&quot;,0x00000001)<br>{<br>  Scope (\_SB)<br>   {<br>     Device (I2C0)<br>      {<br>        Name(_HID,&quot;PRP0001&quot;)<br>        Name(_UID, 0)<br>        Method (_STA, 0 , NotSerialized) {Return 0x0F}<br>        Method (_CRS, 0 , NotSerialized)<br>        {<br>          Return (ResourceTemplate() {<br>              Memory32Fixed (ReadWrite, 0x11007000, 0x1000)<br>              Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 32 }<br>          })<br>        }<br>      }<br>    }<br>  } </pre><p>Key syntactic concepts:</p><ul><li><strong>Objects :</strong> are defined by keywords like Device, Name, Method, etc.</li><li><strong>Four character names </strong>(ACPI NameSeg) like I2C0, _CRS,_HID</li><li>Methods are like functions, they return values and execute logic</li><li><strong>ResourceTemplate</strong> is the structured resource list the OS can parse.</li></ul><h3><strong>2.2 Namespace Concepts</strong></h3><p>Think of the ACPI namespace like a filesystem that UEFI gives to the OS.</p><p>Inside this tree the firmware publishes</p><ul><li><strong>Devices</strong> (like I2C controller, battery, thermal sensor, USB controller)</li><li><strong>Methods</strong> (small functions like _STA, _CRS, _PS0)</li><li><strong>Data Objects</strong> (constants, packages, properties like _HID, _UID,_DSD)</li></ul><p>The OS loads this tree at boot and uses it to answer questions like :</p><ul><li>What devices exist on this machine ?</li><li>Where are their registers (MMIO base) ?</li><li>Which IRQ do they use ?</li><li>How do I power them on/off ?</li></ul><h4><strong>2.2.1 What does ACPI Namespace solve ?</strong></h4><p>The OS needs a <strong>unique and organized way</strong> to refer to thousands of things. If you just had random names like TEMP, CTRL, DATA <strong>they would conflict</strong>.</p><p>ACPI forces everything into <strong>hierarchical</strong> tree, so names <strong>become unique</strong> by location.</p><ul><li>\_SB.I2C0 and \_SB.I2C1 can both have a child called DEV0</li><li>It is possible because their full path differs: \_SB.I2C0.DEV0, \_SB.I2C1.DEV0</li></ul><h4><strong>2.2.2 The address of an ACPI object</strong></h4><p>An ACPI object is <strong>referenced using a path</strong> like a file path.</p><ul><li><strong>Absolute Path</strong></li></ul><p>Starts from root \ .</p><p>Example \_SB.I2C0, \_TZ.TZ00</p><ul><li><strong>Relative path</strong></li></ul><p>If you are already inside a scope, you can refer without the full path.</p><p>Example:</p><pre>Scope (\_SB.I2C0)<br>{<br>  Device (TPD0)<br>  {<br>    // Here &quot;TPD0&quot; is in \_SB.I2C0 automatically<br>  }<br>}</pre><p><em>Relative references are convenient, but absolute references are clearre and avoid confusion in large projects.</em></p><h4><strong>2.2.3 Common Top Level folders you will see</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0271ebe3983e59d1e51ddf06466676d/href">https://medium.com/media/c0271ebe3983e59d1e51ddf06466676d/href</a></iframe><h4><strong>2.2.4 What exactly lives in the namespace</strong></h4><p>a) Devices</p><p>b) Methods</p><p>c) Names</p><h4>2.2.5 How the OS uses namespace</h4><ol><li>OS loads ACPI tables → builds the namespace tree in memory</li><li>OS walks through device nodes (mostly under \_SB)</li><li>For each device, OS evaluates :</li></ol><ul><li>_HID/_CID/_UID : Who are you ?</li><li>_STA : Are you present/enabled ?</li><li>_CRS : what resources do you need ?</li></ul><p>4. OS creates a device instance and binds a driver</p><p>So <strong>Namespace = the OS’s map to discover and control platform hardware</strong></p><h3>2.3 Key ASL Constructs</h3><h4><strong>2.3.1 Device()</strong></h4><p>ACPI tables build a big tree called <strong>ACPI namespace</strong> (like folders and files).</p><p><strong>Device() </strong>creates a <strong>folder/node</strong> that <strong>represents a hardware device</strong>. It defines a <strong>device object</strong> in the ACPI namespace. So it is like creating a directory.</p><p>For the OS to actually use it you normally add:</p><ul><li>Identification (_HID, _CID, _UID)</li><li>Status (_STA)</li><li>Resources (_CRS)</li><li>Optional properties (_DSD)</li><li>Optional power methods (_PS0, _PS3, etc.)</li></ul><p>Without those the OS might ignore it or create a device that no driver binds to.</p><p><strong>2.3.1.1 Device Names : Why 4 charcters ?</strong></p><p>ACPI names in the namespace typically follow <strong>NameSeg</strong> rules (commony 4 characters):</p><ul><li><strong>Examples :</strong> I2C0, GPIO0, XHCI, EC00, BAT0</li></ul><p>This matters because:</p><ul><li>The namespace is designed for compact AML encoding</li><li>Many tools and conventions assume 4-charcter segments.</li><li>You can still reference longer paths using multiple segments: \_SB.I2C0.TPD0</li></ul><p><strong>2.3.1.2 Where you usually put devices</strong></p><p>Most real firmware put devices under</p><ul><li><strong>\_SB (System Bus) : </strong>Platform devices, PCI roots, GPIO, I2C, SPI, etc.</li><li><strong>\_SB.PCI0… : </strong>(very common on x86 because PCI hierarchy is central)</li></ul><p><strong>2.3.1.3 What the OS expects inside a Device()</strong></p><p><strong>(A) Identify (who am I ?)</strong></p><ul><li><strong>Name (_HID,”…”)</strong> hardware id</li><li><strong>Name (_CID,”…”)</strong> compatible IDs (optional)</li><li><strong>Name (_UID,…)</strong> unique instance id (optional but useful)</li><li><strong>_DDN</strong> (optional human readable name)</li></ul><p><strong>(B) Presence/enablement (Should OS use me ?)</strong></p><p><strong>Method (_STA,0, …)</strong> returns a bit mask</p><p><strong>(C) Resources (Where are my registers/ IRQs ?)</strong></p><p><strong>Method (_CRS, 0,…)</strong> returns a <strong>ResourceTemplate()</strong> containing :</p><ul><li>Memory Ranges (MMIO)</li><li>Interrupt descriptors</li><li>GPIO / I2C serial bus connection descriptors, etc.</li></ul><p><strong>(D) Properties (extra key-value data)</strong></p><ul><li><strong>Name (_DSD, Package() {…})</strong> used heavily in Linux and in modern ACPI designs</li></ul><p><strong>(E) Power (runtime suspend / resume)</strong></p><ul><li><strong>_PS0, _PS3,_ PR0, _PR3,</strong> etc.</li></ul><p><strong>(F) Dependencies (SoC ordering)</strong></p><ul><li><strong>Name(_DEP, Package(){…})</strong> tells OS <em>“I depend on these devices/providers”</em>.</li></ul><p><strong>2.3.1.3 Child Devices under a controller</strong></p><p>A controller (like I2C) can be a <strong>Device()</strong> and peripherals on it can be child <strong>Device()</strong> nodes.</p><pre>Device (I2C)<br>{<br>  // controller identity, status, resources<br>  Device (TPD0)<br>   {<br>     //touchpad identity, CRS uses I2cSerialBus to reference I2C0<br>   }<br>}<br>// The above code snippet indicates that the touchpad is connected to I2C <br>// controller</pre><h4><strong>2.3.2 Processor()</strong></h4><p><strong>Processor() </strong>is ACPI’s old/legacy way to say:</p><p><em>“Hey OS, here is a CPU core (or logical CPU thread). This is its ACPI identity, and here’s where you can find CPU power/performance control information.”</em></p><p>It <strong>creates a CPU object in the ACPI namespace</strong> so the OS can manage the CPU (power states, performance states, throttling, etc.)</p><p><strong>2.3.2.1 What does Processor() look like ?</strong></p><p><strong>Classic ASL syntax:</strong></p><pre>Processor (CPU0, 0x00, 0x00000000, 0x00)<br>{<br>  // Optional CPU-related objects/methods can go here<br>}</pre><p>You’ll often see multiple :</p><pre>Processor (CPU0, 0x00, 0x00000000, 0x00){}<br>Processor (CPU1, 0x00, 0x00000000, 0x00){}<br>Processor (CPU2, 0x00, 0x00000000, 0x00){}<br>Processor (CPU3, 0x00, 0x00000000, 0x00){}</pre><p><strong>2.3.2.2 What happens when firmware defines Processor() ?</strong></p><p>When firmware defines <strong>Processor(CPU0,..)</strong>, it is adding a <strong>CPU node</strong> into the ACPI namespace - like adding a <strong>“CPU entry”</strong> the OS can discover.</p><p>So the OS, when walking ACPI, learns:</p><ul><li>There is a processor object called <strong>CPU0.</strong></li><li><em>It corresponds to processor ID X.</em></li><li><em>There might be ACPI power/performance info attached to it.</em></li></ul><p><strong>2.3.2.3 What do the parameters mean ?</strong></p><p><strong>(A) Name (example: CPU0)</strong></p><p>Just the <strong>ACPI namespace name</strong> (like a label).</p><ul><li>Typically CPU0, CPU1, etc.</li><li>Must be <strong>unique</strong> in that scope.</li></ul><p><strong>(B) Processor ID (example 0x00)</strong></p><p>This is the <strong>ACPI Processor ID</strong>.</p><ul><li>OS uses this to map <strong>ACPI CPU objects</strong> to actual CPUs it sees via hardware enumeration (APIC on x86, MPIDR-based topology, etc.)</li><li>Commonly sequential: 0,1,2,3..</li></ul><p><strong>(C) PblkAddress and (D) PblkLength</strong></p><p>This is the <strong>Processor Control Block</strong> - historically used for legacy CPU power/perf control registers.</p><ul><li>On many modern systems, you’ll see <strong>0x00000000, 0x00</strong> meaning “not used”.</li><li>Historically (especially older x86), this pointed to I/O port space used for controlling P-states.</li><li>PBLK is often a legacy placeholder.</li></ul><p><strong>2.3.2.4 How does the OS actually use Processor() ?</strong></p><p>When the OS boots, it does roughly this:</p><ol><li><strong>Loads ACPI tables (DSDT + SSDTs)</strong>→ builds namespace</li><li>Finds all <strong>Processor()</strong> objects under <strong>\_PR</strong> (commonly) or other defined scope.</li><li>For each processor object:</li></ol><ul><li>Maps it to a real CPU core/thread.</li><li>Creates an <strong>OS “CPU device”</strong> structure.</li></ul><p>4. Looks for CPU-related ACPI objects/methods associated with that processor, such as:</p><ul><li><strong>Performance states</strong> (P-states) : <strong>_PSS, _PCT, _PCC</strong></li><li><strong>Idle states</strong> (C-states): <strong>_CST (legacy)</strong></li><li><strong>Throttling</strong> (T-states): <strong>_TSS (older)</strong></li><li><strong>Power methods</strong>, platform coordination, etc.</li></ul><p>5. Uses that to implement:</p><ul><li>CPU frequency scaling (P-states)</li><li>CPU idle management (C-states)</li><li>Thermal throttling cooperation</li><li>Multi-core coordination rules (some legacy designs)</li></ul><p><strong>2.3.2.5 Where does Processor() usually appear ? (\_PR)</strong></p><p>Many platforms use:</p><pre>Scope (\_PR)<br>{<br>  Processor (CPU0, 0x00, 0, 0) {}<br>  Processor (CPU1, 0x01, 0, 0) {}<br>}</pre><p>So <strong>\_PR </strong>is like the<strong> CPU folder </strong>in the<strong> ACPI namespace.</strong></p><p>Hence, Processor() usually appears under \_PR namespace.</p><p><strong>2.3.2.6 Typical usage : attaching P-states (Performance States)</strong></p><p>A classic(legacy) P-state setup uses <strong>_PSS packages</strong> under each CPU scope:</p><pre>Scope (\_PR.CPU0)<br>{<br>  Name (_PSS, Package()<br>  {<br>    // Each entry: Frequency, Power, Transition Latency, BusLatency, Control, Status<br>    Package() {2000, 15000, 10, 10, 0x00001000, 0x00001000},<br>    Package() {1500, 9000, 10, 10, 0x00001000, 0x00001000} <br>  })<br>}</pre><p>The OS does the following <strong>with _PSS</strong>:</p><ul><li>It learns available <strong>CPU frequencies/performance levels</strong></li><li>It <strong>chooses one based on policy</strong> (performance vs power saving)</li><li>It uses <strong>control/status fields along with other objects</strong> (_PCT, etc.) to actually program the CPU.</li></ul><p><strong>2.3.2.7 Typical usage : attaching C-states (Idle States)</strong></p><p>Legacy idle states can be described using _CST:</p><pre>Scope (\_PR.CPU0)<br>{<br>  Method (_CST, 0, Serialized)<br>  {<br>    Return (Package()<br>    {<br>     2, // number of C-states<br>     Package() {0x01, 0x00, 0x000003E8, 0x03}, //C1 example<br>     Package() {0x02, 0x00, 0x000007D0, 0x03}  //C2 example<br>    })<br>  }<br>}</pre><p>When CPU has nothing to do, OS can put it into deeper sleep states.</p><h4><strong>2.3.3 ThermalZone()</strong></h4><p>It is ACPI firmware telling the OS :</p><p><em>“Here is a temperature area (a thermal zone). You can ask me for the current temperature, and here are the temperature limits (trip points). When it gets hot, take action (throttle CPU, turn on fans, reduce power or shut down).”</em></p><p><strong>2.3.3.1 Why do we need Thermal Zone at all ?</strong></p><p>Modern devices generate heat. If temperatures rise too high, you get performance throttling, instability, permanent damage, or fire risk.</p><p>The OS needs a standard way to:</p><ul><li><strong>Read temperatures</strong></li><li><strong>Know the safe thresholds</strong></li><li><strong>Control cooling devices</strong></li><li><strong>React to overheating events</strong></li></ul><p><strong>2.3.3.2 What does ThermalZone() look like ?</strong></p><pre>Scope (\_TZ)<br>{<br> ThermalZone(TZ00)<br> {<br>  Method (_TMP,0,NotSerialized)<br>  { <br>    Rteurn (3000)<br>  }<br>  Name (_PSV, 3300)<br>  Name (_CRT, 3700)<br> }<br>}</pre><ul><li>TZ00 = name of this thermal zone</li><li>_TMP = current temperature right now</li><li>_PSV = passive trip point (start throttling)</li><li>_CRT = critical trip point</li></ul><p><strong>2.3.3.3 Where does it appear in the namespace ?</strong></p><p>Thermal Zones usually live <strong>under \_TZ namespace</strong></p><p><strong>2.3.3.4 What happens when the OS boots</strong></p><ol><li>OS loads ACPI tables →builds ACPI namespace</li><li>OS finds thermal zones (<strong>\_TZ.TZ00</strong>, etc.)</li><li>OS checks what methods/objects each zone provides :</li></ol><ul><li><strong>_TMP</strong> (must-have)</li><li>trip points like <strong>_PSV, _CRT,_AC0, etc</strong></li><li>optional methods to list cooling devices.</li></ul><p>4. OS creates an internal <strong>“thermal zone device”</strong></p><p>5. OS periodically or event driven:</p><ul><li>calls <strong>_TMP</strong> to read temperature</li><li>compares temperature with trip points</li><li>triggers appropriate cooling actions.</li></ul><p>So the thermal zone is <strong>basically a contract between firmware and OS.</strong></p><p><strong>2.3.3.5 The most important method : <em>_TMP (current temperature)</em></strong></p><p><em>_TMP = tell me the temperature</em></p><p>The OS calls <strong>_TMP</strong> to get the current temperature of that zone.</p><p>Example :</p><pre>Method (_TMP,0 , Serialized)<br>{<br>  // read sensor value and return it <br>}</pre><p><strong>Units :</strong></p><p>ACPI thermal temperatures are usually returned in <strong>tenths of Kelvin</strong> (0.1K)</p><ul><li>300.0 K → <strong>3000</strong></li><li>273.2K (0 degree Centigrade) → <strong>2732</strong></li></ul><p>Example :</p><ul><li>_TMP returns 3300</li><li>330.0K →56.85 degree centigrade</li></ul><p><strong>2.3.3.6 Trip Points</strong> : <strong><em>“When should the OS react ?”</em></strong></p><p>Trip points are thresholds where the OS changes behavior</p><p><strong>2.3.3.6.1 Passive trip point: _PSV</strong></p><ul><li><em>_PSV = start passive cooling</em></li></ul><p>Passive cooling means <strong>reduce performance to reduce heat</strong></p><pre>Name (_PSV, 3300) //56.85 degree C </pre><ul><li>If <strong>temperature ≥ _PSV,</strong> OS tries to reduce heat by throttling <strong>passively.</strong></li></ul><p><strong>2.3.3.6.2 Critical Point: _CRT</strong></p><ul><li><em>_CRT = critical temperature</em></li><li>When <strong>temperature ≥ _CRT,</strong> OS should take drastic action: <strong>typically emergency shutdown to prevent damage</strong></li></ul><pre>Name (_CRT, 3700) //96.85 degree C</pre><ul><li>Active cooling (fans): _AC0, _AC1,… and _AL0,_AL1..</li><li>If the system has fans, ACPI uses active trip points</li></ul><p><strong>2.3.3.7 Active cooling (fans) : _AC0, _AC1… and AL0, _AL1…</strong></p><p>If the system has fans, ACPI uses <strong>“active trip points”</strong>.</p><p><strong>2.3.3.7.1</strong> <strong>Active Trip points: _AC0, _AC1,…</strong></p><p><em>These define the temperatures where the OS should turn on active cooling.</em></p><p>Example :</p><pre>Name (_AC0, 3200) // turn on fan level 0 at ~46.85 degree C<br>Name (_AC1, 3400) // stronger cooling at ~66.85 degree C</pre><p><strong>2.3.3.7.2 Cooling device lists: _AL0, _AL1,…</strong></p><p><em>These tell the OS which cooling devices to activate at those trip points</em></p><pre>Name (_AL0, Package() {\_SB.FAN0})<br>Name (_AL1, Package() {\_SB.FAN0})</pre><ul><li>At <strong>_AC0</strong>, use <strong>FAN0</strong></li><li>At <strong>_AC1</strong>, also use <strong>FAN0</strong> (maybe at higher speed depending on control methods)</li></ul><p><strong>2.3.3.8 Cooling devices (what are they ?)</strong></p><p>Cooling devices are other ACPI objects that the OS can control to reduce temperature such as fans, CPU throttling, device power limit controls.</p><p>In ACPI, a <strong>cooling device</strong> typically has methods like:</p><ul><li><strong>_ON and _OFF (fan on/off)</strong></li><li>or a performance/limit interface</li></ul><p>Example of a very simple fan device :</p><pre>Device (FAN0)<br>{<br>  Name (_HID, &quot;PNP0C0B&quot;) // Fan device<br>  Method (_ON, 0 , NotSerialized) {/*turn on fan */ }<br>  Method (_OFF, 0 , NotSerialized) {/*turn off fan */ }<br>}</pre><p>Then the thermal zone references <strong>\_SB.FAN0 </strong>in<strong>_AL0.</strong></p><p><strong>2.3.3.9 How does the OS decide “polling vs events” ?</strong></p><p>Two ways for OS to react:</p><p><strong>(A) Polling</strong></p><p>OS periodically calls <strong>_TMP</strong> and checks trip points</p><p><strong>(B) Event-driven</strong></p><p>Some platforms generate ACPI events (often via GPE/SCI) when a temperature changes or a trip is crossed. The OS can then re-evaluate <strong>_TMP</strong> and trip points.</p><p><strong>2.3.3.10 Multiple thermal zones (why more than one ?)</strong></p><p>Multiple Zones may be present in a system :</p><ul><li><strong>CPU zone</strong></li><li><strong>GPU zone</strong></li><li><strong>battery / charger zone</strong></li><li><strong>skin temperature zone</strong> (for handheld devices)</li><li><strong>VRM / PMIC zone</strong></li></ul><p>Example :</p><pre>Scope (\_TZ)<br>{<br>  ThermalZone (TZ00) {/* CPU */ }<br>  ThermalZone (TZ01) {/* Battery */ } <br>}</pre><h4><strong>2.3.4 Name()</strong></h4><p><strong>Name() </strong>defines a <strong>named object </strong>in the<strong> ACPI namespace.</strong></p><p>General form :</p><pre>Name (ObjectName, ObjectValue)</pre><p>Example :</p><pre>Name (_UID, 0)<br>Name (_HID, &quot;PRP0001&quot;)</pre><p>This is how you define data objects - like constants and structured data - that methods and OS can read.</p><p><strong>2.3.4.1 What can Name() store ?</strong></p><p><strong>Name()</strong> can create many kinds of ACPI objects such as:</p><p><strong>(A) Integer</strong></p><pre>Name (BASE, 0x11007000)</pre><p><strong>(B) String</strong></p><pre>Name (_HID, “INT34BB” )</pre><p><strong>(C) Buffer (raw bytes)</strong></p><pre>Name (BFR0, Buffer() {0x01, 0x02, 0x03})</pre><p><strong>(D) Package (array / list)</strong></p><pre>Name (PKG0, Package() {1,2,3})</pre><p><strong>(E) Nested packages (common in _DSD)</strong></p><pre>Name (_DSD, Package()<br>{<br>  ToUUID (&quot;da..&quot;)<br>  Package()<br>  {<br>    Package() {&quot;compatible&quot;, &quot;vendor, device&quot;},<br>    Package() {&quot;reg&quot;, 0x2C}   <br>  <br>  }<br>})</pre><p>So Name() is not just a number - it can <strong>hold up complex structures the OS parses.</strong></p><p>Common ones defined using Name():</p><ul><li>_HID (Hardware ID)</li><li>_CID (Compatible ID)</li><li>_UID (Unique ID)</li><li>_DDN (Description)</li><li>_DEP (Dependencies)</li><li>_DSD (Device properties)</li></ul><p><strong>Note: </strong>Name() creates a new object. <strong>Alias()</strong> creates another name pointing to an existing object</p><p><strong>2.3.4.2 Why use Name() instead of hardcoding numbers everywhere ?</strong></p><p>Because it improves :</p><ul><li>readability</li><li>maintainability</li><li>avoids copy-paste mistakes</li></ul><p>Example :</p><pre>Name (BAS0, 0x11007000)<br>Name (LEN0, 0x1000)<br>Method (_CRS , 0 , NotSerialized)<br>{<br>   Return (ResourceTemplate ()<br>   {<br>     Memory32Fixed (ReadWrite, BAS0, LEN0)<br>   })<br>}</pre><p>If the base address changes, you update it once.</p><p><strong>2.3.4.3 Reserved names</strong></p><p><strong>2.3.4.3.1 _HID</strong></p><pre><br>Name (_HID, “INT34BB”)</pre><p>(i) ACPI’s way of saying <em>“This device’s official hardware ID is INT34BB”</em></p><p>(ii) Creates a <strong>named object</strong> in ACPI namespace with <strong>key = _HID, <br> value = “INT34BB”</strong></p><p>(iii) _HID stands for <strong>hardware ID</strong> <strong>(hardware identity and not device name)</strong>.</p><p>iv) <em>It is a standard ACPI-defined field (resered name) that the OS knows to look for.</em></p><p><strong>What happens at boot-time ? </strong><br>Imagine the OS is walking through ACPI devices like reading a list.<br>For each Device(…) node it does something like:</p><p>a) OS finds a device node (Example \_SB.I2C0)</p><p>b) OS reads _HID</p><p>c) It sees _HID = “INT34BB”</p><p>d) OS searches its driver database:</p><ul><li>On Windows finds a driver whose INF says it supports ACPI\INT34BB.</li><li>On Linux a driver may have an ACPI match table with “INT34BB”.</li></ul><p>e) If a match exists, OS loads/binds the driver to that device</p><p>f) Then OS calls other methods like _STA, _CRS to check if it’s present and to get it’s resources.</p><p><strong>2.3.4.3.2 _CID</strong></p><ul><li>_CID stands for <strong>Compatible ID</strong>.</li><li>It tells the OS:</li></ul><p><em>“If you don’t recognize me by main ID i.e _HID, here are other IDs that I am compatible with”.</em></p><p>So _CID is basically a <strong>backup / alternative ID </strong>list to help the OS pick the right driver.</p><p>Sometimes a device has a specific _HID (unique model ID), but the <strong>OS doesn’t have a driver that matches the exact ID</strong>. However the <strong>device is compatible with a more generic / standard device type that the OS does support</strong>. So firmware provides _CID so the OS can still match a driver.</p><pre>// OPTION A :  Single compatible ID<br>Name (_CID, &quot;PNP0C50&quot;)<br><br>//option B : Multiple compatible IDs : Primary hardware ID is in _HID, but OS<br>// can also treat it as one of these IDs<br>Name (_CID, Package ()<br>{<br>  &quot;PNP0C50&quot;,<br>  &quot;MSFT0001&quot;<br>})</pre><p><strong>What happens at boot-time ?</strong></p><p>When OS enumerates a device:</p><ul><li>It reads _HID first and tries to find a driver match.</li><li>If no driver matches _HID, it checks _CID</li><li>It tries each compatible ID until it finds a driver</li><li>If still no match, device may remain unbound / unknown.</li></ul><p><strong>Real world situations where _CID is used</strong></p><p><strong>A) New revision of hardware, old driver still works</strong></p><ul><li>New device gets a new _HID</li><li>But it’s still compatible with the old driver</li><li>Put old ID in _CID</li></ul><p><strong>B) Vendor-specific ID + generic standard ID</strong></p><ul><li>_HID might be vendor-specific</li><li>_CID contains a generic class so OS can load an inbox driver</li></ul><p><strong>C) Cross-OS support help (sometimes)</strong></p><ul><li>You may want different OSes to find some workable driver path</li><li>_CID can help if one OS recognizes the generic ID while the other recognizes the vendor ID.</li></ul><p><strong>2.3.4.3.3 _UID</strong></p><ul><li>UID stands for <strong>Unique ID</strong>.</li><li>It tells the OS :</li></ul><p><em>“If you have multiple devices of the same type (same _HID), this is which instance I am” .</em></p><ul><li>So _UID is how the OS can <strong>distinguish between duplicates</strong>.</li></ul><p><strong>Real World Example</strong></p><p>Imagine your system has two identical I2C controllers. Both might have the same _HID. Without _UID, the OS would see :</p><p>a) Device A : _HID = XYZ</p><p>b) Device B : _HID = XYZ</p><p>and it would be hard to uniquely name them or reliably apply configuration. With _UID firmware can say:</p><p>a) I2C controller #0 → _UID = 0</p><p>b) I2C controller #1 → _UID = 1</p><pre>Device (I2C0) { Name (_UID, 0) }<br>Device (I2C1) { Name (_UID, 1) }</pre><p>Here :</p><ul><li>I2C0 / I2C1 are namespace names (labels inside the ACPI Tree)</li><li>_UID is an <strong>OS-facing unique instance ID</strong> used in enumeration and identification.</li></ul><p>Now OS can treat them <strong>as two separate instances</strong>.</p><p><strong>Different Types of _UIDs</strong></p><pre>Name (_UID, 0)<br><br>OR<br><br>Name (_UID, 1)<br><br>OR<br><br>Name (_UID , &quot;A&quot;)</pre><p><strong>What happens at boot-time ?</strong></p><p>When OS <strong>enumerates an ACPI device</strong>, it looks at:</p><ul><li><strong>_HID </strong>→<em>”what type of device is this ?”</em></li><li><strong>_UID </strong>→ <em>“which instance of that type is it ?”</em></li></ul><p>This helps OS</p><ul><li><strong>create stable device names</strong></li><li><strong>differentiate identical devices</strong></li><li><strong>apply instance-specific settings</strong></li><li><strong>avoid confusion when multiple devices match the same driver</strong></li></ul><p>You can technically name devices differently in the namespace, but _UID is what the OS uses for <strong>“instance identity” when _HID is the same</strong>.</p><p><strong>Scenarios when _UID is used</strong></p><p>You should include _UID when:</p><ul><li>multiple devices share the same _HID</li><li>you want stable identification across boots</li><li>the OS/driver expects it (common for buses / controllers)</li></ul><p><strong>2.3.4.3.4 _DEP</strong></p><p>_DEP stands for <strong>Dependencies</strong>.</p><p>It is an <strong>ACPI object</strong> that tells the OS:</p><p><em>“Before you try to start /use this device, make sure these other ACPI devices are already discovered/started/available.”</em></p><p>_DEP is <strong>usually a name, not a method</strong>.</p><p><strong>a) What _DEP looks like in ASL</strong></p><pre>Device (TPD0)<br>{<br>  Name (_DEP, Package()<br>  {<br>    \_SB.GPI0,<br>    \_SB.I2C0<br>  })<br>}<br>// In plain words TPD0 depends on GPI0 and I2C0. <br>// Please make sure those are ready before TPD0</pre><p><strong>b) What does _DEP contain ?</strong></p><p>_DEP returns <strong>a Package of references to other ACPI namespace objects</strong> (usually devices). Each element is typically a device path like :</p><p>i) \_SB.GPI0</p><p>ii) \_SB.I2C0</p><p>iii) \_SB.PCI0.XHCI</p><p><strong>c) Why _DEP exists</strong></p><p><strong>The problem: Enumeration order</strong></p><p>The OS discovers many devices at boot, but it does not always know the right order.</p><p>Example scenario (very common):</p><p>Touchpad device uses:</p><ul><li>I²C controller (to communicate)</li><li>GPIO controller (for interrupt pin)</li><li>Pin controller (to mux pins to correct function)</li><li>Power domain (to power it)</li></ul><p>If OS enumerates the touchpad before GPIO/I²C providers are ready, the touchpad driver might fail.</p><p>_DEP is how firmware says:</p><p><em>“Don’t try to start the touchpad until these building blocks are present.”</em></p><p><strong>d) What the OS actually does with _DEP ?</strong></p><p>When OS <strong>enumerates devices</strong>:</p><p>i) OS finds a device node eg TPD0</p><p>ii) OS checks for _DEP</p><p>iii) If _DEP exists, OS reads the list of dependencies (provide devices)</p><p>iv) OS ensures those provider devices are enumerated/started first (ordering)</p><p>v) Only then does OS proceed to fully start/bind the consumer device.</p><p><strong>e) How </strong><strong>_DEP interacts with </strong><strong>_CRS</strong></p><p>Many dependencies exist because consumer devices reference providers in their _CRS.</p><p><strong>Example: a device uses a GPIO interrupt</strong></p><p>In _CRS you might have:</p><pre>GpioInt (..., &quot;\\_SB.GPIO&quot;, ...) { 12 }</pre><p>That GpioInt resource references the GPIO controller \_SB.GPIO</p><p>If \_SB.GPIO is not ready/initialized when the OS is trying to parse/bind resources, things can fail or be incomplete.</p><p>So firmware adds:</p><pre>Name (_DEP, Package () { \_SB.GPIO })</pre><p>Now OS knows the GPIO controller must come first.</p><p><strong>f) Common real-world dependency patterns</strong></p><p><strong>i) I²C peripheral depends on I²C controller + GPIO controller</strong></p><p>Example: Touchpad on I²C with GPIO interrupt</p><pre>Device (TPD0)<br>{<br>    Name (_DEP, Package () { \_SB.I2C0, \_SB.GPI0 })<br>}</pre><p><strong>ii) Device depends on power/clock providers</strong></p><p>For SoCs, devices often need:</p><ul><li>clocks enabled</li><li>power domain on</li><li>resets deasserted</li></ul><p>These may be modeled as ACPI devices too. Then you can depend on them:</p><pre>Name (_DEP, Package () { \_SB.CLK0, \_SB.PWR0, \_SB.RST0 })</pre><p>(Exact modeling varies by platform.)</p><p><strong>iii) Device depends on pinmux/pinctrl device</strong></p><p>If pin configuration must be done first:</p><pre>Name (_DEP, Package () { \_SB.PIN0 })</pre><p><strong>g) </strong><strong>_DEP vs other ACPI &quot;dependency-like&quot; mechanisms</strong></p><p><strong>_DEP is about device start order / availability</strong></p><p>It’s not about interrupts directly and not about power states directly — it’s about <em>ordering and readiness</em>.</p><p><strong>Power resources (</strong><strong>_PR0/</strong><strong>_PR3, PowerResource objects)</strong></p><p>Those control actual power rails/resources for power state transitions.</p><ul><li>Use those for power management semantics.</li><li>Use _DEP for &quot;don&#39;t start me before my providers exist.&quot;</li></ul><p>They often complement each other.</p><p><strong>h) Example (ties together _DEP, _CRS, and a provider)</strong></p><pre>Scope (\_SB)<br>{<br>    Device (GPIO)<br>    {<br>        Name (_HID, &quot;PRP0001&quot;)<br>        Method (_STA, 0, NotSerialized) { Return (0x0F) }<br>        // _CRS for GPIO controller omitted for brevity<br>    }<br><br>    Device (I2C0)<br>    {<br>        Name (_HID, &quot;PRP0001&quot;)<br>        Method (_STA, 0, NotSerialized) { Return (0x0F) }<br>        // _CRS for I2C controller omitted<br>    }<br><br>    Device (TPD0)<br>    {<br>        Name (_HID, &quot;PRP0001&quot;)<br><br>        // Tell OS: GPIO and I2C must be ready first<br>        Name (_DEP, Package () { \_SB.GPIO, \_SB.I2C0 })<br><br>        Method (_STA, 0, NotSerialized) { Return (0x0F) }<br><br>        Method (_CRS, 0, NotSerialized)<br>        {<br>            Return (ResourceTemplate ()<br>            {<br>                I2cSerialBus (0x002C, ControllerInitiated, 400000,<br>                              AddressingMode7Bit, &quot;\\_SB.I2C0&quot;, 0x00,<br>                              ResourceConsumer, , )<br><br>                GpioInt (Level, ActiveLow, Exclusive, PullUp, 0,<br>                         &quot;\\_SB.GPIO&quot;, 0, ResourceConsumer, , )<br>                { 12 }<br>            })<br>        }<br>    }<br>}</pre><ul><li>TPD0 uses I2C0 to talk, and uses GPIO pin 12 as its interrupt line.</li><li><strong>_DEP </strong>ensures I2C0 and GPI0 are set up before TPD0 is started.</li></ul><p><strong>2.3.4.3.5 _DSD</strong></p><ul><li>_DSD stands for <strong>Device Specific Data</strong>.</li><li>It lets firmware <strong>attach extra properties</strong> (key-value pairs) to <strong>an ACPI device</strong> - similar to device tree properties - so the OS / driver can understand device details that are not covered by standard ACPI methods.</li><li>In simple words <strong>_DSD is like a property bag for a device</strong> : compatible name, GPIO names, clocks, quirks, configuration table values, etc. This is especially common on Linux and ARM SoC ACPI platforms but can be useful in general.</li></ul><p><strong>Why do we need _DSD ?</strong></p><p>ACPI already has <strong>standard ways to describe</strong>:</p><ul><li>whether a device exists (_STA),</li><li>what resources it uses (_CRS : MMIO/IRQ/GPIO/I2C addresses, etc.),</li><li>power methods (_PS0 / _PS3).</li></ul><p>But many drivers still <strong>need extra configuration</strong>, like :</p><p>a) <em>“What exact chip is this ?”</em> (compatible),</p><p>b) <em>“What is the reset GPIO ?”</em>,</p><p>c) <em>“What is the IRQ GPIO ?”</em>,</p><p>d) <em>“What is the orientation / panel type / calibration ?”</em>,</p><p>e) <em>“Does the device need a special quirk enabled ?”</em>.</p><p>Those details <strong>don’t always fit nearly into _CRS</strong> or standard ACPI methods. <strong>_DSD solves that by allowing arbitrary properties</strong>.</p><ul><li>Most commonly _DSD is defined as a Name() object containing a package</li></ul><p><strong>What does _DSD look like ?</strong></p><p>Most commonly <strong>_DSD </strong>is defined as a<strong> Name() object </strong>containing a<strong> Package()</strong></p><pre>Name (_DSD , Package ()<br>{<br>  ToUUID (&quot;daffd814-6eba-4d8c-8a91-bc9bbf4aa301&quot;),<br>  Package()<br>  {<br>    Package() {&quot;compatible&quot;, &quot;vendor,my-device&quot;},<br>    Package() {&quot;reg&quot; , 0x2C}<br>  }<br>})<br>/* The UUID daffd814-6eba-4d8c-8a91-bc9bbf4aa301 is the <br>   standard Device Properties UUD used for key-value properties.<br>   When OS sees this UUID, it knows &quot;The following package contains properties&quot;<br>*/<br></pre><p><strong>What is inside _DSD ?</strong></p><p>Inside the properties package, you typically have many entries:</p><pre>Package () {“property-name” , property-value}</pre><p>where :</p><ul><li><strong>“property-name”</strong> is a <strong>string key</strong></li><li><strong>property-value</strong> can be : <strong>Integer, String, Buffer, Package</strong> (list)</li><li>sometimes nested structures</li></ul><p>Example with different types :</p><pre><br>Name (_DSD , Package ()<br>{<br>  ToUUID (&quot;daffd814-6eba-4d8c-8a91-bc9bbf4aa301&quot;),<br>  Package ()<br>  {<br>    Package () {&quot;compatible&quot; , &quot;vendor, my-sensor&quot;}, //string<br>    Package () {&quot;reg&quot; , 0x48}, //integer<br>    Package () {&quot;interrupts&quot; , Package() {5}}, //integer<br>    Package () {&quot;calibration&quot; , Buffer() {0x01, 0x02}}, // bytes  <br>  }<br>})</pre><p><strong>How does the OS use _DSD ?</strong></p><p><strong>a) Linux : Linux reads _DSD and converts it into device properties available to drivers.</strong></p><p>This is heavily used with the special <strong>_HID = “PRP0001”</strong> pattern :</p><ul><li><strong>_HID = “PRP0001” means</strong> : This is a generic device described by properties.</li><li><strong>_DSD</strong> then provides <strong>“compatible”</strong> so Linux can bind a driver like it would with Device Tree.</li><li>So for Linux <strong>_DSD</strong> often acts as : <em>“ACPI version of device-tree properties”.</em></li></ul><p><strong>b) Windows : Windows </strong>is generally more<strong> _HID / _CID + INF </strong>driven for driver binding. _DSD can still be used as a way to provide additional configuration to a custom Windows driver, but it’s not as universally relied upon as Linux does.</p><p><strong>Common Properties</strong></p><p>a) <strong>“compatible”</strong></p><p>b) <strong>“reg”</strong></p><p>c) <strong>“interrupts”</strong></p><p>d) <strong>“reset-gpios”, “irq-gpios”</strong></p><p>e) <strong>“clock-frequency” / “clocks”</strong></p><p>f) <strong>“wake-capable” / quirks flag</strong></p><p><strong>Caution : </strong>In ACPI, GPIO and bus connections are often better expressed via <strong>_CRS</strong> descriptors (GpioInt, I2cSerialBus). <strong>_DSD </strong>then adds descriptive properties or driver-specific knobs</p><p><strong>A small complete example (device described using _HID = PRP0001 + _DSD)</strong></p><pre><br>Device (SEN0)<br>{<br>  Name (_HID ,&quot;PRP0001&quot;)<br>  Name (_UID, 0)<br>  Name (_DSD, Package()<br>  {<br>    ToUUID (&quot;daffd814-6eba-4d8c-8a91-bc9bbf4aa301&quot;),<br>    Package()<br>    {<br>      Package() {&quot;compatible&quot;,&quot;vendor,temp-sensor&quot;},<br>      Package() {&quot;reg&quot;, 0x48}<br>    }<br>  })<br>  Method (_CRS , 0 , NotSerialized)<br>  {<br>    Return (ResourceTemplate() <br>    {<br>      I2cSerialBus (0x0048, ControllerInitiated, 400000,<br>                    AddressingMode7Bit, &quot;\\_SB.I2C0&quot;, 0x00,<br>                    ResourceConsumer,,)<br>    })<br><br>  }<br>}</pre><h4><strong>2.3.5 Method()</strong></h4><p>In ACPI <strong>Method ()</strong> is like a <strong>small function</strong> that firmware provides for the OS to run.</p><p>So ACPI is not just “static data tables”. It can also include <strong>executable logic</strong>. The OS runs this logic through ACPI interpreter to do things like:</p><ul><li>check if a device exists (<strong>_STA</strong>)</li><li>tell the OS what resources a device uses <strong>(_CRS)</strong></li><li>turn devices on/off <strong>(_PS0, _PS3)</strong>.</li><li>read temperature <strong>(_TMP).</strong></li><li>expose vendor features <strong>(_DSM)</strong></li></ul><p><strong>2.3.5.1 What does Method() look like ?</strong></p><p>Basic Syntax :</p><pre>Method (NAME, ArgCount, SerializationRule)<br>{<br> // AML statements<br>}</pre><p>Example:</p><pre>Method (_STA, 0, NotSerialized)<br>{<br>   Return (0x0F)<br>}</pre><ul><li>Method Name: <strong>_STA</strong></li><li>It takes <strong>0 arguments</strong></li><li>It is <strong>not Serialized</strong></li><li>It returns <strong>0x0F</strong> when the OS asks for status</li></ul><p><strong>2.3.5.2 What happens when the OS boots ?</strong></p><ol><li>UEFI gives the OS ACPI tables.</li><li>OS builds ACPI namespace: devices, names, and methods.</li><li>Methods are stored as “callable code blocks” in that namespace.</li><li>Later when OS needs info or needs to perform an action, it <strong>calls the method.</strong></li><li>OS runs the method inside the <strong>ACPI interpreter</strong> ( a VM inside OS kernel).</li><li>The method returns a value (sometimes) and may read/write hardware registers via ACPI defined regions.</li></ol><p><strong>Note :</strong> Methods don’t run automatically just because they exist. They run when the OS (or a driver) evaluates them.</p><p><strong>2.3.5.3 Where are Methods used ? (What they do in real life)</strong></p><p><strong>i) Name Methods OS calls for device discovery</strong></p><ul><li><strong>_HID / _CID :</strong> Identity</li><li><strong>_STA :</strong> Status (present ? enabled ?)</li><li><strong>_CRS : </strong>Resources (MMIO, IRQ, GPIO, I2C connections)</li></ul><p>These methods are critical because they decide whether a device is enumerated and how a driver finds it.</p><p><strong>ii) Methods OS calls for power management</strong></p><ul><li><strong>_PS0, _PS3 : </strong>Turn device on / off.</li><li><strong>_PR0, _PR3 :</strong> Power resources packages.</li><li><strong>_S0W, _DSW, wake related methods :</strong> Wake capability and configuration</li></ul><p><strong>iii) Methods for Thermal</strong></p><ul><li><strong>_TMP :</strong> Read temperature</li><li><strong>Trip points : </strong>Sometimes provided as Name objects, sometimes dynamic via methods.</li></ul><p><strong>iv) Vendor extension methods</strong></p><ul><li><strong>_DSM :</strong> A standardized entry point for vendor-specific functions.</li></ul><p><strong>2.3.5.4 Method Name Rules</strong></p><p><strong>2.3.5.4.1 Reserved methods start with underscore (_)</strong></p><p>Names beginning with underscore have defined meanings in the ACPI spec. Eg: _STA, _CRS, etc.</p><p>These have <strong>expected arguments and return types</strong>.</p><p>Example :</p><ul><li>_STA : returns an Integer bitmask</li><li>_CRS : returns a ResourceTemplate buffer</li><li>_TMP : returns temperature</li></ul><p>If you return the wrong type, OS may ignore the device or throw errors.</p><p><strong>2.3.5.4.2 Custom methods</strong></p><p>You can create your own methods too:</p><pre>Method (ENBL, 0 , NotSerialized) {...}</pre><p>But OS will not call them unless:</p><ul><li>another ACPI method calls them, or</li><li>a driver explicitly evaluates them</li></ul><p><strong>2.3.5.5 Arguments and locals (how data flows inside a method)</strong></p><p><strong>2.3.5.5.1 Arguments Arg0…Arg6</strong></p><p>A method can take upto<strong> 7 arguments.</strong></p><p>Example of 2 arguments:</p><pre>Method (ADD2, 2, Local0)<br>{<br>  Add (Arg0, Arg1, Local0)<br>  Return (Local0)<br>}</pre><p><strong>2.3.5.5.2 Local Variables Local0…Local7</strong></p><p>A method has <strong>8 local variables.</strong></p><p>Example :</p><pre>Method (TEST, 0 , NotSerialized)<br>{<br>  Store (123, Local0)<br>  Return (Local0)<br>}</pre><p><strong>2.3.5.6 Serialization: NotSerialized vs Serialized (why it matters)</strong></p><p>ACPI methods may be called concurrently by the OS (especially on multi-core systems).</p><p><strong>2.3.5.6.1 NotSerialized</strong></p><p>Means : <em>“OS can run this method in parallel with other methods.”</em></p><p>Good for :</p><ul><li>pure computations</li><li>returning constant data</li><li>reading state that is safe</li></ul><p>Risky if :</p><ul><li>it reads/writes shared hardware registers without protection.</li></ul><p><strong>2.3.5.6.2 Serialized</strong></p><p>Means : <em>“Only one thread can execute this method at a time”</em></p><p>Use this when :</p><ul><li>the method manipulate shared registers</li><li>it does multi-step sequences that must not interleave</li><li>it touches EC or sensitive hradware sequencing.</li></ul><p><strong>2.3.5.7 What can a method do ?</strong></p><p>Methods can :</p><ul><li>do math (<strong>Add</strong>, <strong>Subtract</strong>, <strong>Multiply</strong>)</li><li>do bit operations (<strong>And</strong>, <strong>Or</strong>, <strong>ShiftLeft</strong>)</li><li>compare (<strong>LEqual</strong>, <strong>LGreater</strong>)</li><li>control flow (<strong>If</strong>, <strong>Else</strong>, <strong>While</strong>)</li><li>read/write namespace objects (<strong>Store</strong>)</li><li>call other methods (<strong>Call </strong>is implicit: just write <strong>MTHD(…)</strong>)</li><li>return values (<strong>Return</strong>)</li></ul><p><strong>2.3.5.8 How does a method access hardware ?</strong></p><p>Methods don’t do raw pointer dereferences. Instead they access hardware through ACPI constructs like :</p><ul><li><strong>OperationRegion() </strong>defines where registers live.</li><li><strong>Field() </strong>defines named bitfields/register variables.</li></ul><h3>2.4 Detailed Analysis of Key ACPI Constructs</h3><h4><strong>2.4.1 Method _CRS</strong></h4><p>_CRS stands for <strong>Current Resource settings</strong>.</p><p>It is an ACPI method that tells the OS: <em>“Here are the exact hardware resources this device is using right now - its register addresses, interrupts, GPIO pins, I2C/SPI connections, DMA channels”.</em></p><p>Without <strong>_CRS</strong>, the OS usually <strong>cannot know where the device lives in memory or what interrupt it uses - so a driver can’t talk to it.</strong></p><p><strong>2.4.1.1 Why does _CRS exist ?</strong></p><p>Every hardware device needs <strong>“resources”</strong> to operate, for example:</p><ul><li><strong>MMIO register range</strong> (memory-mapped registers)</li><li><strong>I/O port range</strong> (legacy x86)</li><li><strong>Interrupt line(s)</strong> (IRQ)</li><li><strong>DMA channels</strong> (less common now)</li><li><strong>GPIO pins</strong> (interrupt pins, reset pins, enable pins)</li><li><strong>Serial bus connections</strong> (I²C address, SPI chip select, UART parameters)</li></ul><p>The OS needs these resources so it can:</p><ol><li>create a device object,</li><li>assign the resources to a driver,</li><li>configure the interrupt controller / pin controller,</li><li>and let the driver map registers and handle interrupts.</li></ol><p><strong>_CRS</strong> is the standardized way ACPI provides this information.</p><p><strong>2.4.1.2 Where does _CRS live?</strong></p><p>Usually lives inside a <strong>Device()</strong></p><pre>Device (I2C0)<br>{<br>  Method (_CRS, 0, NotSerialized)<br>  {<br>    Return (ResourceTemplate() {...})<br>  }<br><br>}</pre><p>So the OS calls <strong>“\_SB.I2C0._CRS”</strong> to get resources for that device.</p><p><strong>2.4.1.3 What does _CRS return ?</strong></p><p>_CRS returns a <strong>resource list</strong> encoded in a standard binary format called an <strong>ACPI resource template.</strong> In ACPI you write it using <strong>ResourceTemplate()</strong> which is like a <strong>builder</strong> that generates the binary blob.</p><p>Example:</p><pre>Method (_CRS, 0, NotSerialized)<br>{<br>    Return (ResourceTemplate ()<br>    {<br>        Memory32Fixed (ReadWrite, 0x11007000, 0x1000)<br>        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 32 }<br>    })<br>}</pre><p>Simple meaning:</p><ul><li>“My registers are at 0x11007000, size 0x1000&quot;</li><li>“I use IRQ 32, level-triggered, active-high, exclusive&quot;</li></ul><p><strong>2.4.1.4 How the OS uses _CRS</strong></p><p>When the OS enumerates ACPI devices :</p><ol><li>OS discovers a device node in the ACPI namespace.</li><li>OS reads <strong>_HID/_CID/_UID</strong> to identify it.</li><li>OS calls <strong>_STA</strong> to check if it’s present/enabled.</li><li>OS calls <strong>_CRS</strong> to fetch resources.</li><li>OS parses the resource template into structured resources like memory ranges, interrupts, GPIO descriptors, serial bus connections.</li><li>OS creates an OS device object and stores these resources in it.</li><li>When a driver binds to the device, OS hands the driver these resources:</li></ol><ul><li>base address for ioremap() (Linux) / MmMapIoSpace() (Windows kernel)</li><li>IRQ number and trigger/polarity for request_irq() (Linux) / IoConnectInterruptEx() (Windows)</li><li>bus connection info (I2C address, SPI chip select, etc)</li></ul><p><strong>2.4.1.5 Common Resource Descriptors inside _CRS</strong></p><p>Common resource descriptors inside _CRS</p><p><strong>A) Memory resources (MMIO)</strong></p><ul><li>Used for register mapping</li><li>Common ASL forms :</li></ul><p>i) <strong>Memory32Fixed(…)</strong> for a fixed 32 bit base/length</p><p>ii) <strong>QWordMemory(…) </strong>for a 64-bit ranges/large ranges</p><p>Example:</p><pre>Memory32Fixed (ReadWrite, 0x11007000, 0x1000) </pre><p>OS should map this address range and allow R/W access.</p><ul><li>ReadOnly vs ReadWrite affects OS expectations.</li><li>Base + Length must match real hardware registers or the driver breaks.</li></ul><p><strong>B) I/O Port resources (legacy x86)</strong></p><p>Used for old-style I/O ports</p><p>Example (conceptually):</p><ul><li><strong>IO (…)</strong></li></ul><p>Modern ARM SoCs rarely use this, x86 can still use it for legacy devices.</p><p><strong>C) Interrupt resources (IRQs)</strong></p><pre>Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) {32}</pre><p>Firmware will tell the OS : <em>This device will signal the CPU using interrupt number </em><strong><em>32</em></strong><em>. Configure that interrupt as level-triggered, active-high and exclusive (not shared).</em></p><ul><li><strong>32 is the interrupt line number </strong>the OS will register handler for. In ARM SoCs this often corresponds closely to the interrupt ID in the interrupt controller depending on Platform conventions and ACPI tables. <strong>On x86 it often maps to a GSI</strong> (Global System Interrupt) which is routed through IOAPIC.</li><li><strong>Resource Consumer (who owns/uses this interrupt) </strong>: Device is an <strong>interrupt consumer</strong> meaning that <em>the device needs this interrupt to notify the CPU</em>. Most device IRQ descriptors are Resource Consumer (ResourceProducer rarely used).</li><li><strong>Level-triggered :</strong> The interrupt signal stays asserted until the device clears the condition. [<strong>ActiveHigh</strong> (0 →1) and <strong>ActiveLow</strong> (1 → 0)] :</li></ul><p>i) Device raises interrupt line and keeps it active (stays high or low depending on polarity).</p><p>ii) CPU receives interrupt.</p><p>iii) OS calls driver’s interrupt handler</p><p>iv) Driver must <strong>clear the interrupt cause</strong> in the device (write to a status register, read a register)</p><p>v) Once cleared, device releases the line →interrupt stops</p><ul><li><strong>Edge Triggered : </strong>For an <strong>edge-triggered</strong> [<strong>Active High + Edge</strong> : (Rising Edge :0 →1) and <strong>Active Low + Edge </strong>: (Falling Edge :1 →0)]following happens:</li></ul><p>i) Device <strong>generates a pulse</strong> on the interrupt line.</p><p>ii) The interrupt controller detects the edge and flags an interrupt</p><p>iii) CPU jumps into the OS interrupt handler</p><p>iv) OS calls the driver’s ISR.</p><p>v) Driver handles the interrupt</p><ul><li><strong>Risks</strong> related to<strong> not clearing the interrupt:</strong></li></ul><p>a) For <strong>level triggered</strong> if the driver does not clear the cause, the line stays asserted → OS gets the interrupt again immediately →<strong>interrupt storm</strong> (CPU stuck servicing interrupts because the line stays asserted).</p><p>b) For <strong>edge-triggered</strong> , failing to clear more commonly causes <strong>missing future interrupts</strong>. <strong>Common miss </strong>Scenarios include :</p><p>- The device generates an edge <strong>before</strong> the driver has enabled the interrupt</p><p>-The interrupt pulse is too short or there is filtering/debounce issues.</p><ul><li>The driver reads the device state <strong>too late</strong> and loses the event context.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*9jrXA_5xBvYPGlB5kG6r5Q.png" /></figure><ul><li><strong>Exclusive</strong>: means the <strong>interrupt line is dedicated </strong>to this one device and will not be shared.<br>If an interrupt is <strong>shared</strong>, <strong>multiple devices can raise the same interrupt line</strong>. In that case the OS calls handlers for mutiple devices sharing it. <strong>Each handler checks “was it me ? ”</strong> and returns accordingly. With exclusive the OS assumes only this device will trigger it and sharing is not allowed.</li></ul><p><strong>D) GPIO resources (GpioInt / GpioIo)</strong></p><p>Used when devices usde GPIO pins for : interrupts, reset lines, enable lines, wake signals</p><p>Example interrupt GPIO :</p><pre>GpioInt (Level, ActiveLow, ExclusiveAndWake, Pullup, 0, <br>         &quot;\\SB.GPI0&quot;,0, ResourceConsumer,,)<br>{12}</pre><p>It means <em>“My interrupt comes from GPIO controller \_SB.GPI0, pin 12. It is level-triggered, active-low, can wake the system, has pull-up.”</em></p><p><strong>E) Serial Bus Connection resources (I2CSerialBus, SpiSerialBus, UartSerialBus)</strong></p><pre>I2CSerialBus (0x002C, ControllerInitiated,400000, <br>              AddressingMode7Bit, &quot;\\_SB.I2C0&quot;, 0x00, <br>              ResourceConsumer,,) </pre><p>The device is at I2C address <strong>0x2C</strong>, speed 400kHz, Connected to controller <strong>\_SB.I2C0.</strong></p><p><strong>Note:</strong></p><ul><li><strong>_PRS</strong> = Possible Resource Settings [<em>“Here are the resource options this device could use.”</em>],</li><li><strong>_SRS </strong>= Set Resource Settings [<em>“OS chooses one option and tells the firmware to set it.”</em>]</li></ul><p><strong>Example:</strong></p><pre>Method (_CRS, 0, NotSerialized)<br>{<br>    Return (ResourceTemplate ()<br>    {<br>        Memory32Fixed (ReadWrite, 0x11007000, 0x1000)<br>        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 32 }<br>    })<br>}</pre><ul><li>“Driver, your registers are at 0x11007000–0x11007FFF.&quot;</li><li>“Driver, use interrupt 32.&quot;</li><li>“OS, configure that interrupt as level-triggered, active-high, and exclusive.”</li></ul><p><strong>Q) How does Windows and Linux OS reacts when there is a resource conflict between two entities (like devices) in _CRS ?</strong></p><p><strong>Windows</strong></p><p>Windows uses a centralized <strong>PnP Manager</strong> with per-resource-class <strong>arbiters</strong> (IO, memory, IRQ, DMA):</p><ul><li>When enumerating a device, Windows calls _PRS (Possible Resource Settings) to learn <em>all</em> the resource combinations a device could use, and _CRS for what it&#39;s currently using.</li><li>If two devices’ current settings collide, the PnP Manager tries to <strong>rebalance</strong>: it walks each device’s _PRS list looking for an alternative resource set that avoids the conflict, then calls _SRS (Set Resource Settings) to apply the new configuration.</li><li>If no non-conflicting combination exists (e.g., a device only exposes one fixed set in _CRS with no _PRS alternatives), Windows disables the device. You see this in<strong> Device Manager as a yellow warning icon</strong> - classically <strong>Code 12</strong>: <em>&quot;This device cannot find enough free resources that it can use.&quot;</em></li><li>IRQ conflicts are usually harmless for PCI/PCIe since those lines are level-triggered and can be shared; it’s legacy ISA-style edge-triggered IRQs, or fixed I/O port/memory ranges, that actually cause unresolvable conflicts.</li><li>This whole process is largely automatic and invisible unless something fails, at which point Device Manager’s Resources tab shows the conflicting device list.</li></ul><p><strong>Linux</strong></p><p>Linux takes a more decentralized, “first claim wins” approach built on the kernel’s I/O resource tree:</p><ul><li>Drivers call request_region() / request_mem_region() to claim ranges in the kernel&#39;s global resource tree (ioport_resource / iomem_resource). If a range overlaps something already reserved, the call fails - there&#39;s no automatic search through _PRS alternatives for most modern ACPI-enumerated devices.</li><li>Legacy _PRS-capable devices <em>do</em> get handled with some negotiation, but through a separate, older subsystem - <strong>PNPACPI</strong> (drivers/pnp/pnpacpi/) — which mimics Windows-style resource assignment for old-style PNP devices, not the general modern device model.</li><li>Separately, ACPI reserves any I/O/memory region that firmware’s AML code touches via OperationRegion (things like SMBus, Super I/O sensors, EC registers), so that native Linux drivers don&#39;t fight with the ACPI-based control methods for the same hardware behind the OS&#39;s back. This shows up as messages like:</li></ul><pre>ACPI: I/O resource smsc47m1 [0xa00-0xa7f] conflicts with ACPI region RNTR [0xa00-0xa7f]</pre><p>and the offending driver’s probe simply fails to load, or logs a warning and proceeds unprotected, depending on the acpi_enforce_resources boot parameter (strict / lax / no / auto) - lax is typically the default, meaning it warns but lets the native driver load anyway (at the risk of racing with firmware).</p><ul><li>There’s generally no automatic “try a different resource set and retry” rebalancing loop for ordinary ACPI devices the way Windows does with _SRS; a real conflict usually just means the driver doesn&#39;t bind, and you find out via dmesg.</li></ul><p><strong>The core difference</strong></p><p>Windows treats resource assignment as a <strong>negotiation</strong> the OS actively manages (arbitrate → rebalance via _PRS/_SRS → disable as last resort). Linux treats it more as a <strong>claim-and-fail</strong> model (first successful request_region() wins, ACPI-owned regions are protected against native drivers, and there&#39;s no general-purpose automatic renegotiation outside the legacy PNPACPI path) - so conflicts tend to surface as a driver silently not loading and a log line, rather than a GUI error state.</p><h4><strong>2.4.2 Method _STA</strong></h4><p>_STA stands for <strong>Status</strong>.</p><p>It is an ACPI method that the OS calls to ask a device : <em>“Are you actually present on this machine, are you enabled, and are you working ? ”</em></p><p><strong>2.4.2.1 Where </strong><strong>_STA lives and what it looks like</strong></p><p>_STA usually appears inside a Device()</p><pre>Device (I2C0)<br>{<br>    Method (_STA, 0, NotSerialized)<br>    {<br>        Return (0x0F)<br>    }<br>}</pre><p>That means: whenever OS asks for \_SB.I2C0._STA, return 0x0F.</p><p><strong>2.4.2.2 What does </strong><strong>_STA return?</strong><br><strong>_STA</strong> returns an <strong>integer bitmask</strong>. Each bit has a meaning:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*X-leHtKKKQxU8Z5N7fCG0g.png" /></figure><p>So</p><p>0x0F = 0x01 + 0x02 + 0x04 + 0x08 [Meaning : Everything is good]</p><p><strong>2.4.2.3 Common </strong><strong>_STA return values (and what they mean)</strong></p><p><strong>a) Return (</strong><strong>0x0F)</strong></p><p><em>“Device is present, enabled, should be visible, and is functioning.”</em></p><p>This is the standard for devices that are always there.</p><p><strong>b) Return (</strong><strong>0x00)</strong></p><p><em>“Device is not present (ignore it).”</em></p><p>OS will usually not enumerate it / won’t bind drivers.</p><p><strong>c) Return (</strong><strong>0x0D) (</strong><strong>1101b)</strong></p><p><em>Present + show + functioning, but </em><strong><em>not enabled</em></strong><em> (bit1 = 0).</em></p><p>Sometimes used when device exists but is disabled by firmware setting.</p><p><strong>d) Return (</strong><strong>0x0B) (</strong><strong>1011b)</strong></p><p><em>Present + enabled + functioning, but not </em><strong><em>“UI visible”</em></strong><em>.</em></p><p>Less common, depends on how firmware wants it presented.</p><p><strong>2.4.2.4 Why do we need </strong><strong>_STA?</strong></p><p><strong>a) Same firmware image supports different hardware variants</strong></p><p>Example: one laptop model has a fingerprint sensor, another doesn’t.<br> Firmware contains both device nodes, but _STA returns 0 only when the hardware isn&#39;t actually populated.</p><p><strong>b) Board straps / SKU / optional modules</strong></p><p>A GPIO strap can indicate presence of a module (LTE modem, extra sensor, etc.).</p><p><strong>c) BIOS/UEFI setup options</strong></p><p>User disables a device in BIOS setup (e.g., disable camera). _STA returns &quot;not enabled.&quot;</p><p><strong>d) Runtime hotplug-like cases (less common)</strong></p><p>Some devices appear/disappear or are gated by power domains (platform dependent).</p><p><strong>2.4.2.5 How </strong><strong>_STA is implemented (simple patterns)</strong></p><p><strong>Pattern A: Always present</strong></p><pre>Method (_STA, 0, NotSerialized)<br>{<br>    Return (0x0F)<br>}</pre><p><strong>Pattern B: Presence depends on a GPIO strap / register bit</strong></p><p>Firmware reads some status bit (through OperationRegion + Field) and decides.</p><pre>Method (_STA, 0, NotSerialized)<br>{<br>    If (LEqual (MODP, 1)) { Return (0x0F) } // module present<br>    Return (0x00)<br>}</pre><p><strong>Pattern C: Device exists but disabled by configuration</strong></p><pre>Method (_STA, 0, NotSerialized)<br>{<br>    If (LEqual (DISA, 1)) { Return (0x0D) } // not enabled<br>    Return (0x0F)<br>}</pre><p><strong>2.4.2.6 </strong><strong>_STA and driver loading (Linux + Windows view)</strong></p><p><strong>Windows</strong></p><ul><li>Uses ACPI IDs (_HID/_CID) to find drivers.</li><li>_STA influences whether the device is started/enumerated.</li><li>If _STA returns 0, it generally won&#39;t start the device at all.</li></ul><p><strong>Linux</strong></p><ul><li>Similar: Linux ACPI enumeration checks _STA</li><li>If not present, Linux may not create the device or may mark it absent.</li><li>Drivers won’t bind if the device never gets enumerated.</li></ul><p>In both OSes: _STA returning &quot;absent&quot; is one of the fastest ways to hide a device from the OS.</p><p><strong>2.4.2.7 </strong><strong>_STA interactions with other methods</strong></p><p><strong>a)</strong><strong>_STA and </strong><strong>_INI</strong></p><ul><li>OS may call _INI during enumeration.</li><li>If _STA returns 0 (not present), OS usually won&#39;t run _INI for that device.</li><li>So if your _INI is needed to make _STA accurate, you can get ordering problems.</li></ul><p><strong>Best practice:</strong> _STA should be able to decide presence without depending on complex init that might not have run.</p><p><strong>b) </strong><strong>_STA and </strong><strong>_CRS</strong></p><ul><li>If _STA says present, OS expects _CRS to provide correct resources.</li><li>If _STA returns present but _CRS is missing/wrong, the OS can enumerate the device but the driver fails.</li></ul><p><strong>c)</strong><strong>_STA and power states</strong></p><p>Some platforms try to make _STA depend on power state (e.g., return not present when power-gated). This can be risky:</p><ul><li>OS may interpret “not present” as physically absent and not re-enumerate later.</li><li>Better to manage power through _PS0/_PS3 and power resources rather than hiding devices via _STA unless it truly is optional hardware.</li></ul><h4><strong>2.4.3 Method _INI</strong></h4><p>_INI stands for <strong>Initialize</strong>.</p><p><em>It is an ACPI method that the OS may run to let firmware do device-specific setup work when that device is being brought into the system. When the OS discovers the device, run this small initialization script.</em></p><p><strong>2.4.3.1 Where _INI lives and what it looks like</strong></p><p>You usually see _INI inside a Device()</p><pre>Device (I2C0)<br>{<br>  Method (_INI, 0 , NotSerialized)<br>   {<br>     //initialization code<br>   }<br>}</pre><p>It is a <strong>no-argument method</strong>.</p><p>Typically it <strong>returns nothing</strong> (it’s executed only for side effects).</p><p><strong>2.4.3.2 What does _INI actually do ?</strong></p><p>_INI can do things like :</p><ul><li>setup internal ACPI variables (store values in <strong>Name()</strong> objects)</li><li>program hardware registers via <strong>Operation Regions</strong> + <strong>Field</strong></li><li>enable clocks or power rails</li><li>configure a MUX or pin settings</li><li>run checks and set flags that other methods will use</li></ul><p><strong>2.4.3.3 When does the OS call _INI ?</strong></p><p><strong>Typical behavior</strong></p><p>When OS is enumerating ACPI namespace devices, it may :</p><ul><li>find a device,</li><li>evaluate <strong>_STA</strong> (is it present ?),</li><li>if present, run _INI (initialize),</li><li>then continue with resource methods (<strong>_CRS</strong>) and driver binding.</li></ul><p>However, <strong>exact timing depends on OS </strong>and the device class. The ACPI spec defines intent, but real OS implementations can differ slightly.</p><p>Think of _INI as being called: <em>“Around the time the OS is seeing up / enumerating that device.” Do </em><strong><em>not</em></strong><em> assume _INI is called at a precise moment relative to every other method unless you have confirmed the OS behavior for your target environment.</em></p><p><strong>2.4.3.4 Simple examples of </strong><strong>_INI usage</strong></p><p><strong>Example A: Set a flag used by other methods</strong></p><pre>Name (ENAB, 0)<br><br>Method (_INI, 0, NotSerialized)<br>{<br>    Store (1, ENAB)<br>}<br><br>Method (_STA, 0, NotSerialized)<br>{<br>    If (LEqual (ENAB, 1))<br>    {<br>        Return (0x0F)<br>    }<br>    Return (0x00)<br>}</pre><p><strong>Simple meaning:</strong> _INI sets a variable so _STA later reports the device as present.</p><p>But this is actually a <strong>risky pattern</strong> (see pitfalls below), because OS might call _STA before _INI</p><p><strong>Example B: Initialize a register (hardware side effect)</strong></p><pre>OperationRegion (REGN, SystemMemory, 0x12340000, 0x100)<br>Field (REGN, DWordAcc, NoLock, Preserve)<br>{<br>    Offset (0x00),<br>    CTRL, 32<br>}<br><br>Method (_INI, 0, Serialized)<br>{<br>    // Set bit0 to enable something<br>    Or (CTRL, 0x1, CTRL)<br>}</pre><p><strong>Simple meaning:</strong> When OS initializes the device, AML sets an enable bit in hardware.</p><p><strong>Example C: Device-specific setup that drivers rely on (common intent)</strong></p><p>Firmware might:</p><ul><li>select a routing path</li><li>program a board-specific setting</li><li>set up a wake configuration</li></ul><p>Then drivers can work with less platform-specific complexity.</p><p><strong>2.4.3.5 What OS does “under the hood” when executing </strong><strong>_INI</strong></p><ol><li>OS ACPI interpreter locates the <strong>_INI</strong> method in the namespace.</li><li>It creates an execution context (stack frame) for that method.</li><li>It executes AML statements line by line :</li></ol><ul><li>calculations,</li><li>reads/writes to Field() objects,</li><li>stores to Name() objects,</li><li>calls other methods.</li></ul><p>4. When done, interpreter returns.</p><p><strong>2.4.3.6 </strong><strong>_INI and dependencies (</strong><strong>_DEP) - how they relate</strong></p><p>On SoCs, your device might depend on a provider device (GPIO controller, clock controller, power domain controller).</p><p>_DEP is the declarative way to say:</p><p><em>“Before starting me, make sure those devices are enumerated.”</em></p><p>This helps because _INI might access those providers or assume they exist.</p><p>Example concept:</p><pre>Device (TPD0)<br>{<br>    Name (_DEP, Package() { \_SB.GPI0 })<br><br>    Method (_INI, 0, NotSerialized)<br>    {<br>        // maybe configure something that relies on GPIO controller existing<br>    }<br>}</pre><h4><strong>2.4.4 Method _EVT</strong></h4><p><em>A function that gets called when an event happens, and it receives an event code that tells what happened.</em></p><p>_EVT runs to interpret the event and take appropriate action.</p><p><strong>a) What it usually looks like</strong></p><pre>Method (_EVT, 1, NotSerialized)<br>{<br> // Arg0 = event code<br> // Decide what to do based on Arg0<br>}</pre><ul><li>_EVT takes 1 argument (Arg0).</li><li>Arg0 is typically an <strong>event number/code</strong>.</li><li>The method uses <strong>If/ Switch</strong> logic to handle different event codes.</li></ul><p>Example :</p><pre>Method (_EVT, 1, NotSerialized)<br>{<br>  If (LEqual (Arg0, 0x10))<br>    {<br><br>       // Event 0x10 happened<br>       // Maybe update a status variable and notify OS<br><br>     }<br>   ElseIf (LEqual (Arg0, 0x20))<br>   {<br><br>     // Another Event<br>    }</pre><p><strong>b) Where do these events come from?</strong></p><p>Most commonly, events come from an <strong>Embedded Controller (EC)</strong> or an ACPI event source like a <strong>GPE</strong> (General Purpose Event).</p><p><strong>Mental model:</strong></p><ul><li>GPE = “doorbell rang” (an interrupt/event line into ACPI)</li><li>_EVT = &quot;go check why the doorbell rang and what it means&quot;</li></ul><p>Often the chain is:</p><ol><li>Hardware triggers an EC/GPE event (SCI interrupt).</li><li>OS ACPI subsystem sees the GPE.</li><li>ACPI dispatch logic runs a control method.</li><li>That method may call _EVT with an event code.</li></ol><p><strong>c) What does </strong><strong>_EVT typically do?</strong></p><p>Inside _EVT, firmware might:</p><p><strong>i) Update ACPI variables / status objects</strong></p><p>Example: set a Name() value that later changes what _STA or _TMP returns.</p><p><strong>ii) Call </strong><strong>Notify() to tell the OS &quot;something changed&quot;</strong></p><p>Notify(Device, code) is how ACPI tells the OS to re-check a device.</p><p>Example (conceptually):</p><ul><li>Battery status changed → notify battery device</li><li>AC adapter plugged/unplugged → notify AC adapter device</li><li>Thermal trip occurred → notify thermal zone</li></ul><p>So _EVT often ends with something like:</p><ul><li><em>“notify device X so OS re-reads its status/data”</em></li></ul><p><strong>iii) Trigger re-evaluation of methods</strong></p><p>After a notify, the OS may call methods like:</p><ul><li>_STA, _PSR, _BST, _TMP, etc., depending on device class and notification code.</li></ul><p><strong>d) Important clarification: </strong><strong>_EVT vs </strong><strong>_Lxx/</strong><strong>_Exx</strong></p><p>You may also see GPE handler methods like:</p><ul><li>_L0F (Level-triggered GPE 0x0F)</li><li>_E0F (Edge-triggered GPE 0x0F)</li></ul><p>Those are <strong>direct GPE handlers</strong>.</p><p>A common design is:</p><ul><li>_L0F runs when GPE happens,</li><li>_L0F reads an event/status register from EC,</li><li>then calls _EVT(eventCode) to handle the specific event.</li></ul><p>So:</p><ul><li>_Lxx/_Exx = &quot;something happened on GPE line xx&quot;</li><li>_EVT = &quot;handle a specific event code meaningfully&quot;</li></ul><p><strong>e) Is </strong><strong>_EVT required by ACPI spec?</strong></p><p>For most device enumeration tasks (your earlier topics like _STA, _CRS, _INI, _DEP), _EVT is not required.</p><p>You mainly see it in:</p><ul><li>EC-driven event handling designs</li><li>OEM/platform-specific event routing frameworks</li></ul><p>So it’s <strong>valid and useful</strong>, but not as universally standardized in day-to-day ACPI device bring up as _CRS/_STA.</p><h4><strong>2.4.5 Method _DSM</strong></h4><p>_DSM stands for <strong>Device Specific Method</strong>.</p><p>It’s an ACPI method that lets firmware expose <strong>extra, vendor-specific features</strong> of a device that are <strong>not covered by standard ACPI methods</strong>.</p><p><em>It’s like a “special command interface” (a private API) between the OS/driver and the firmware for that device.</em></p><p><strong>a) Why does _DSM exist ?</strong></p><p>ACPI has many standard methods. But sometimes a vendor wants to support something custom. Instead of inventing many new method names, ACPI provides one <em>“standard hook”</em> called _DSM.</p><p><strong>b) What _DSM look like</strong></p><p>_DSM always has <strong>4 arguments:</strong></p><pre>Method (_DSM, 4 , NotSerialized)<br>{<br>  // Arg0: UUID (which feature set is this ?)<br>  // Arg1: Revision (version of the DSM interface)<br>  // Arg2: Function Index (which function to run)<br>  // Arg3: Parameters (input package / buffer)<br>}</pre><ul><li><strong>Arg0 (UUID) :</strong> “Which vendor feature group are you asking for ?”</li><li><strong>Arg1 (Revision) :</strong> “Which version of this interface do you support ?”</li><li><strong>Arg2 (Function Index) :</strong> “Which command do you want to execute ?”</li><li><strong>Arg3 (Params) :</strong> “Here are the inputs for that command”</li></ul><p>So _DSM is like calling :</p><pre>_DSM (feature_group, version, command_number, input_data)</pre><p>and it returns output data</p><p><strong>c) How an OS/driver uses _DSM</strong></p><ol><li>The device driver (or OS ACPI layer) finds a device in the namespace.</li><li>It checks if _DSM exists for that device.</li><li>It calls _DSM with a specific UUID and function index.</li><li>AML code inside _DSM runs.</li><li>_DSM returns data (Integer/Buffer/Package) or performs an action.</li></ol><p><strong>Important:</strong> _DSM is usually called by a <strong>driver</strong>, not randomly by the OS during enumeration</p><p><strong>d) Discussion about Function Index and Function 0</strong></p><p>So when you call _DSM, you must tell it which action you want. That which action is the <strong>function index</strong>.</p><p>In ACPI terms: <strong>Arg2</strong> = Function Index. It is basically the <strong>command number</strong>. <strong>Function index 1</strong> might mean “Get Feature state”, <strong>Function index 2</strong> might mean “Set feature state”, <strong>Function index 3</strong> might mean “Return calibration Data”.</p><p><strong>Not every device supports every command</strong>. Some devices might implement only function 1 and 2 not 3. So drivers first ask <strong><em>“Which function indexes do you support ?”</em></strong>. S<strong>upported functions means: the list of command numbers that this _DSM implementation understands.</strong></p><p>Because the OS/driver must not call a function that firmware doesn’t implement. So there’s a standard convention: <strong>_DSM function index 0</strong> is special. <strong>When the driver calls Arg2=0 it means Tell me which other function indexes you support. So function 0 is like a “help / capabilities” command.</strong></p><p><strong>Real World Analogy :</strong></p><p>Imagine _DSM is a TV remote system: The remote has buttons 1,2,3,4,5…. Some cheap TVs don’t have all features, so some buttons do nothing. SO you first ask the TV: “Which buttons are valid on your model ?” That answer is the supported functions. Then you only press those buttons.</p><p>Usually <strong>_DSM function 0 returns a Buffer bitmask</strong>.</p><ul><li>If bit n is 1 →function index n is supported.</li><li>If bit n is 0 → not supported</li></ul><p>Suppose firmware supports functions 1 and 2. then function 0 might return a bit mask like : 0b00000110 (bit1 = 1 supports function 1, bit 2 = 1 supports function 2)</p><pre>If (LEqual (Arg2, 0))<br>{<br>  Return (Buffer() {0x06})<br>}</pre><p><strong>e) Example _DSM implementation</strong></p><pre>Method (_DSM, 4, NotSerialized)<br>{<br>  // Check UUID matches our supported feature set<br>  If(LEqual (Arg0 , ToUUID(&quot;12345678-1234-1234-1234-1234-123456789ab&quot;)))<br>  {<br>    // Function 0: report supported functions (bitmask in a Buffer)<br>    If (LEqual (Arg2,0))<br>    {<br>      // Example : support functions 1 and 2 (bits 1 and 2)<br>      Return (Buffer() {0x06})<br>    }<br>    // Function 1: query feature state<br>    If (LEqual (Arg2, 1))<br>    {<br>       Return (1) //enabled<br>     }<br>    // Function 2 : set feature state, Arg3 carries parameters<br>    If (LEqual (Arg2, 2))<br>     {<br>       // Suppose Arg3 is an Integer: 0 = dsbale, 1 = enable<br>       Store (Arg3, FENB)<br>       Return (0) // success <br>     } <br>  }<br>// Unknown UUID or unsupported function<br>Return (Buffer() {0x00})<br>}</pre><p><strong>f)</strong> <strong>_DSD vs _DSM</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*Du5dOHzs9fAYs5P6T6ZXLQ.png" /></figure><h4><strong>2.4.6 OperationRegion()</strong></h4><p>In ACPI, firmware sometimes wants the OS to run AML methods like:</p><ul><li>STA,</li><li>_PS0/_PS3,</li><li>_TMP,</li><li>_DSM,</li><li>_REG.</li></ul><p>To implement those methods AML may need to touch hardware registers such as :</p><ul><li>enable a power rail,</li><li>check a status bit,</li><li>read a temperature sensor value,</li><li>toggle a GPIO-like bit (sometimes via EC/MMIO/IO ports).</li></ul><p>But AML can’t just do random MMIO read/write unless you define where that hardware lives.</p><p>That’s exactly what <strong>Operation Region()</strong> does:</p><ul><li>it defines <strong>where and what type of address space</strong> AML is allowed to access.</li></ul><pre>OperationRegion (REGN, SystemMemory, 0x11007000, 0x1000)</pre><ul><li><strong>REGN :</strong> A label/name for this region</li><li><strong>SystemMemory : </strong>the type of address space (MMIO)</li><li><strong>0x11007000 :</strong> base address. Base must match the real hardware register base.</li><li><strong>0x1000 :</strong> length (size of the region). <strong>Must cover all offsets you will access in Field().</strong></li><li>Create a region called REGN that represents 0x1000 bytes of MMIO starting at 0x11007000.</li></ul><p><strong>a) How does it work at runtime ?</strong></p><p>When the OS loads ACPI :</p><ol><li>It parses AML and sees OperationRegion(..)</li><li>It records “REGN refers to MMIO at base X, size Y”</li><li>Nothing is read/written yet — this is just declaring it.</li></ol><p>Later when OS executes an AML method that references fields inside that region:</p><ul><li>The OS’s ACPI interpreter performs actual reads/writes to that region on behalf of the AML code.</li><li>So AML doesn’t directly poke hardware; the interpreter does it safely through defined regions</li></ul><p><strong>b) The typical pairing : OperationRegion() + Field()</strong></p><ul><li><strong>OperationRegion() defines the register block</strong>.</li></ul><p>Field() defines named <strong>“register variables”</strong> inside it. It tells these are the register names/bitfields inside that block.</p><pre>OperationRegion (PMRG, SystemMemory, 0x12340000, 0x1000)<br>Field (PMRG, DwordAcc, NoLock, Preserve)<br>{<br>  Offset (0x00),<br>  CTRL, 32, // Control register at 0x00<br>  STAT, 32  // Status register at 0x04 <br>}</pre><p>Now AML can do:</p><pre>Method (ENBL, 0 , NotSerialized)<br>{<br>  Or (CTRL, 0x1, CTRL) //set enable<br>}</pre><ul><li>CTRL and STAT behave like variables but underneath reading/writing them causes MMIO reads/writes.</li></ul><p>Different region types means that OperationRegion supports mutiple address spaces (called RegionSpace). Common Ones are:</p><ul><li><strong>SystemMemory :</strong> MMIO registers (most SoC and many chipset registers)</li><li><strong>SystemIO :</strong> I/O port space (very commonly on legacy x86)</li><li><strong>PCI_Config :</strong> PCI configuration space access via AML (common on x86)</li><li><strong>EmbeddedControl :</strong> EC registers (very common for laptops, battery, fan, thermal)</li></ul><h4><strong>2.4.7 _REG method</strong></h4><p>Sometimes ACPI defines a special method named _REG under a device <strong>to be notified when a region becomes available</strong>.</p><p>It is required because some regions <strong>might not be usable until something else is initialized</strong> (power/clock enabled, etc.).</p><p>Tells the OS <strong>when the register region is ready to use</strong></p><pre>Method (_REG, 2, NotSerialized)<br>{<br>  // Arg0 = region space ID<br>  // Arg1 = 1 if available, 0 if unavailable<br>}</pre><h4>2.4.8 Mutex()</h4><p>Mutex() in ACPI creates a named lock that ACPI methods can use to prevent two pieces of AML code from touching the same shared thing at the same time.</p><p>In simple words:</p><p><em>A mutex is a “key”: only one person (one AML execution thread) can hold it at a time.</em></p><p>This matters because the OS can run ACPI methods concurrently (multi-core, multiple events), and ACPI methods may access shared hardware/registers/EC resources.</p><p><strong>a) Why do we need a Mutex in ACPI?</strong></p><p>ACPI methods can be invoked:</p><ul><li>by OS enumeration (_STA, _CRS, _INI)</li><li>by power transitions (_PS0, _PS3)</li><li>by thermal polling (_TMP)</li><li>by notifications/events (GPE handlers)</li><li>sometimes concurrently (multiple threads)</li></ul><p>If two methods do something like:</p><ul><li>write to the same register block,</li><li>talk to the Embedded Controller (EC),</li><li>update the same shared variable used for power sequencing,</li></ul><p>then interleaving can cause:</p><ul><li>corrupted writes (one overwrites the other)</li><li>broken sequencing (turning off power while another method expects it on)</li><li>EC protocol failures</li><li>random intermittent bugs</li></ul><p>A Mutex solves this by forcing mutual exclusion.</p><p><strong>b) Syntax: what </strong><strong>Mutex() looks like</strong></p><pre>Mutex (MTX0, 0)</pre><p>Parameters:</p><ol><li><strong>Name:</strong> MTX0 (a 4-char name is common)</li><li><strong>SyncLevel:</strong> 0 (more on this below)</li></ol><p>This creates a mutex object at that namespace location.</p><p>Example inside a device:</p><pre>Device (DEV0)<br>{<br>    Mutex (MLCK, 0)<br>    Method (DOIT, 0, NotSerialized)<br>    {<br>        Acquire (MLCK, 0xFFFF)<br>        // critical section<br>        Release (MLCK)<br>    }<br>}</pre><p><strong>c) How do you actually use the mutex? (</strong><strong>Acquire / </strong><strong>Release)</strong></p><p>Defining a mutex does nothing by itself — you must <strong>Acquire</strong> it before the protected operations and <strong>Release</strong> it after.</p><p><strong>Acquire</strong></p><pre>Acquire (MLCK, 0xFFFF)</pre><ul><li>MLCK = mutex object</li><li>timeout = how long to wait for the lock</li></ul><p><strong>Timeout meaning (simple):</strong></p><ul><li>If someone else holds the mutex, this method waits until either:</li><li>it becomes available, or</li><li>the timeout expires</li></ul><p><strong>Timeout values:</strong></p><ul><li>0 → &quot;don&#39;t wait; fail immediately if locked&quot;</li><li>0xFFFF → commonly used as &quot;wait a long time / effectively forever&quot; (implementation-defined but widely used as &quot;wait until available&quot;)</li></ul><p><strong>Release</strong></p><pre>Release (MLCK)</pre><p>You must release the mutex or you can deadlock other AML execution paths.</p><p><strong>d) What happens at runtime when you Acquire/Release?</strong></p><ol><li>OS ACPI interpreter starts running a method (e.g., _PS0).</li><li>It encounters Acquire (MLCK, ...)</li><li>If MLCK is free:</li></ol><ul><li>interpreter marks it as owned by this execution thread</li><li>method continues</li></ul><p>4. If MLCK is already owned:</p><p>i) interpreter blocks this method (waits) until:</p><ul><li>lock released, then continues, or</li><li>timeout occurs, then Acquire fails</li></ul><p>5. When method hits Release (MLCK):</p><ul><li>lock becomes free</li><li>a waiting method (if any) can proceed</li></ul><p><strong>Key idea:</strong> this locking is managed by the OS AML interpreter (not by firmware “hardware locks”).</p><p><strong>e) Mutex vs </strong><strong>Serialized methods</strong></p><p><strong>Serialized in </strong><strong>Method()</strong></p><p>If you declare:</p><pre>Method (_PS0, 0, Serialized)</pre><p>the interpreter ensures <strong>only one thread executes that method</strong> at a time.</p><p>But:</p><ul><li>it does <strong>not</strong> automatically protect shared resources used by multiple methods.</li></ul><p><strong>Mutex protects shared resources across multiple methods</strong></p><p>If both _PS0 and _PS3 touch the same register:</p><ul><li>Serialized only serializes each method with itself</li><li>but _PS0 and _PS3 can still run concurrently unless you use a shared mutex</li></ul><p>So you often do:</p><pre>Mutex (PWRM, 0)<br>Method (_PS0, 0, NotSerialized)<br>{<br>    Acquire (PWRM, 0xFFFF)<br>    // power on sequence<br>    Release (PWRM)<br>}<br>Method (_PS3, 0, NotSerialized)<br>{<br>    Acquire (PWRM, 0xFFFF)<br>    // power off sequence<br>    Release (PWRM)<br>}</pre><p><strong>Rule of thumb:</strong></p><ul><li>Use Serialized when a single method must not be re-entered.</li><li>Use Mutex when multiple methods must not overlap because they share a resource.</li></ul><p>Often you use both.</p><p><strong>f) SyncLevel (2nd argument) - what is it and why does it exist?</strong></p><p>Mutex (Name, SyncLevel) defines a synchronization level used to prevent deadlocks when multiple locks are involved.</p><p><strong>Simple mental model</strong></p><p>SyncLevel is like “lock priority.”</p><ul><li>If you already hold a <strong>higher-level</strong> lock, you should not acquire a <strong>lower-level</strong> lock afterward (depending on rules), because that can create circular waits.</li></ul><p><strong>In practice:</strong></p><ul><li>Most firmware uses 0 for almost all mutexes.</li><li>Higher levels appear in complicated AML where nested locking is needed.</li></ul><p>If you’re new, use 0 unless you have a specific reason and you understand your platform&#39;s locking order.</p><p><strong>g) Timeouts and failure handling</strong></p><p>Acquire() can fail if it times out.</p><p>In ASL, Acquire() returns a status internally (success/failure), but you typically handle it with conditional logic.</p><p>Example pattern:</p><pre>Method (SAFE, 0, NotSerialized)<br>{<br>    If (Acquire (MLCK, 100))<br>    {<br>        // If acquire failed, exit or return error<br>        Return (0)<br>    }<br>    // critical section<br>    Release (MLCK)<br>    Return (1)<br>}</pre><p><strong>Note:</strong> Many AML codebases don’t check failure and use long timeouts. That can be okay, but it can also create boot hangs if something goes wrong and lock is never released.</p><p><strong>h) Where mutexes are commonly used in real firmware</strong></p><p><strong>A) Embedded Controller (EC) access</strong></p><p>The EC is a shared communication channel. Many methods (battery, thermal, fan, lid switch) may talk to it.</p><p>Mutex ensures the EC protocol is not corrupted by concurrent access.</p><p><strong>B) Power sequencing</strong></p><p>Powering a device on/off often requires:</p><ul><li>multiple register writes</li><li>delays</li><li>checking status bits</li></ul><p>If two methods interleave, you can brick the sequence.</p><p><strong>C) Shared OperationRegions / Fields</strong></p><p>If two methods write to the same register block using Field() objects, you typically protect it.</p><p><strong>D) GPE event handlers</strong></p><p>Events can fire while other AML is running. If the event handler touches shared state, you need protection.</p><p><strong>i) Mutex vs Global Lock</strong></p><p>ACPI also has a concept called the <strong>Global Lock</strong> (used by some Field() definitions or explicit Acquire/Release of global lock mechanisms).</p><ul><li><strong>Mutex:</strong> a named ACPI object lock you define (Mutex (MLCK, 0))</li><li><strong>Global Lock:</strong> a special ACPI-wide locking mechanism intended for certain hardware/firmware coordination (legacy-ish, used carefully)</li></ul><p><strong>Practical tip:</strong> prefer your own Mutex for most AML synchronization needs unless you specifically need the global lock semantics.</p><p><strong>11) A practical “power example”</strong></p><pre>Device (WIFI)<br>{<br>    Mutex (PWML, 0)    <br>    OperationRegion (REGN, SystemMemory, 0x12340000, 0x100)<br>    Field (REGN, DWordAcc, NoLock, Preserve)<br>    {<br>        Offset (0x00),<br>        PWR,   32,<br>        STAT,  32<br>    }<br>    Method (_PS0, 0, NotSerialized)<br>    {<br>        Acquire (PWML, 0xFFFF)<br>        Or (PWR, 0x1, PWR)   // power on bit<br>        // maybe wait for STAT bit to become ready...<br>        Release (PWML)<br>    }<br>    Method (_PS3, 0, NotSerialized)<br>    {<br>        Acquire (PWML, 0xFFFF)<br>        And (PWR, 0xFFFFFFFE, PWR)  // power off bit<br>        Release (PWML)<br>    }<br>}</pre><p><strong>Simple explanation:</strong></p><ul><li>_PS0 and _PS3 both touch the same power register.</li><li>The mutex ensures they don’t run at the same time.</li></ul><p><strong>Note regarding Package Implementation: </strong>According to ACPI Specification, an ACPI<strong> Package </strong>can contain a maximum of <strong>255 elements (objects)</strong>. In AML, the element count field for a package is defined as an 8-bit integer (NumElements byte). This strictly limits the total number of top-level items inside any single package to 255. A package’s total size in memory — including all its nested data - cannot exceed the maximum PkgLength encoding format, which caps out at 256 Megabytes. An element here refers to any individual, comma-separated data object or variable stored in the package array.It can be integers, strings, Buffers, Object References, Nested Packages.</p><pre>Name (MYDATA, Package() {<br>       0x12,   // Elemnet 1 : An Integer<br>       &quot;Temperature Sensor&quot; , // Element 2: A String<br>        \_SB.PCIo.LPCB, // Element 3 : Object Reference<br>        Package() {1,2,3} // Element 4 : A nested package (counts as 1 item here) <br>   <br>   })</pre><h3>3. Key Takeaways</h3><p>We started with a simple question - <em>how does the OS know your I2C controller is at 0x11007000? - </em>and the answer turned out to be a whole language. ASL lets firmware describe devices (Device), identify them (_HID, _CID, _UID), declare their resources (_CRS with memory, interrupt, GPIO, and serial-bus descriptors), express dependencies and properties (_DEP, _DSD), expose custom commands (_DSM), and reach into real hardware safely (OperationRegion + Field). Compiled to AML and handed to the OS, these constructs are exactly how a non-discoverable platform device becomes a fully driver-bound, power-managed part of your running system.</p><h3>References</h3><p><strong>ACPI specification</strong></p><ol><li>ACPI Specifications (UEFI Forum) — <a href="https://uefi.org/acpi/specs">https://uefi.org/acpi/specs</a></li><li>ACPI Spec 6.4, full text (HTML) — <a href="https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/">https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/</a></li></ol><p><strong>ACPICA (reference AML interpreter, used directly by Linux)</strong><br> 3. ACPICA documentation &amp; user guide (Intel) — <a href="https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html">https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html</a><br> 4. ACPICA source (GitHub) — <a href="https://github.com/acpica/acpica">https://github.com/acpica/acpica</a></p><p><strong>Linux ACPI implementation</strong><br> 5. Linuxized ACPICA — how Linux syncs with upstream ACPICA — <a href="https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html">https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html</a><br> 6. Linux kernel ACPI driver-api docs — <a href="https://docs.kernel.org/driver-api/acpi/index.html">https://docs.kernel.org/driver-api/acpi/index.html</a><br> 7. Linux kernel source, drivers/acpi — <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi</a></p><p><strong>Windows internals</strong><br> 8. Windows Driver Kit — Kernel-Mode Driver Architecture — <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/">https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/</a><br> 9. Russinovich, Solomon, Ionescu — <em>Windows Internals</em>, Part 1 (7th ed.) — standard secondary source for undocumented boot/HAL routines like KiSystemStartup, HalInitSystem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c01313a0354" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From ASL to AML: The Complete Journey of an ACPI Table]]></title>
            <link>https://medium.com/@kushaldps1996/from-asl-to-aml-the-complete-journey-of-an-acpi-table-7095e158fdc6?source=rss-20cb97d60801------2</link>
            <guid isPermaLink="false">https://medium.com/p/7095e158fdc6</guid>
            <dc:creator><![CDATA[KUSHAL CHAKRABORTY]]></dc:creator>
            <pubDate>Sat, 01 Aug 2026 13:47:35 GMT</pubDate>
            <atom:updated>2026-08-01T13:47:35.592Z</atom:updated>
            <content:encoded><![CDATA[<p><em>ACPI tables aren’t shipped as the human-readable ASL you write - they’re compiled into AML, a compact bytecode that a stack-based interpreter runs live, for the entire life of the machine. If you’ve ever decompiled a DSDT to figure out why a device won’t enumerate, or you’re a firmware engineer whose </em><em>_STA method won&#39;t validate, this is for you.</em></p><p><em>This piece covers the language side of that pipeline: what </em><em>iASL does when it compiles your ASL, how AML opcodes are encoded at the byte level, why the interpreter behaves like a tiny tree-walking VM rather than a normal CPU, and where that interpreter lives in the OS. (How EDK2 firmware builds these tables and hands them off at boot is its own story - coming in a follow-up.)</em></p><h3>Table Of Contents</h3><ol><li>iASL Compiler</li><li>Command-Line Usage</li><li>AML Bytecode</li><li>The AML Interpreter in the Kernel</li><li>EDK2 Build System Integration</li></ol><ul><li>5.1 How .asl Files Are Listed in .inf Files</li><li>5.2 How the Build Actually Processes ASL - A Brief Overview</li><li>5.3 How Compiled .aml Gets Into the Firmware Volume - A Brief Overview</li><li>5.4 Build Command and Output</li></ul><p>6. Deep Dive - How ACPI Information is put into Firmware Volume</p><ul><li>6.1 The build: how each source becomes a table blob</li><li>6.2 Processing a .asl file → .aml</li><li>6.3 Processing a .aslc file → .acpi (raw table)</li><li>6.4 The blob itself — what “an ACPI table” actually is</li><li>6.5 Packaging into the Firmware Volume (6.5.1–6.5.5)</li></ul><p>End-to-end picture</p><p>Key Takeaways</p><h3><strong>1. iASL Compiler</strong></h3><p><strong>What iASL Does ?</strong></p><p><strong>iASL</strong> = <strong>i</strong>ntel ASL compiler (also called <strong>ACPICA compiler</strong>). It’s the reference open-source tool from Intel’s ACPICA project for working with ACPI tables. It handles the full round trip:</p><pre>ASL source (.asl / .dsl) -- [compiler]--&gt; AML bytecode (.aml)<br>AML bytecode (.aml) -- [decompile] --&gt; ASL source (.dsl)</pre><p><strong>ASL (ACPI Source Language)</strong> is the human-readable C-like language firmware authors write. AML (ACPI Machine Language) is the compiled bytecode that the OS’s <strong>ACPI interpreter</strong> (in Linux : the ACPICA interpreter inside the kernel; in Windows ACPI.sys) executes at runtime.</p><p>iASL performs four jobs :</p><ol><li><strong>Parse</strong> : Lexes and parses ASL text into a parse tree. Catches syntax errors (missing braces, bad operators, malformed object names).</li><li><strong>Semantic check</strong> : Validates the tree against the ACPI specification: name resolution (does \_SB.PCI0.LPCB actually exist ?), argument counts, type, compatibility, illegal nesting, reserved-name method signatures. (eg _STA must return an integer, _CRS must return a Buffer). This is where most real bugs are caught. iASL has one of the most thorough semantic checkers of any compiler because runtime bugs are extremely hard to debug on real hardware.</li><li><strong>Generate AML : </strong>Emits the binary opcode stream, computes package lengths, resolves name references into relative / absolute name paths.</li><li><strong>Emit output files</strong> : Writes .aml and optionally .hex, .lst and other listing formats.</li></ol><h3>2. Command-Line Usage</h3><p><strong>iasl-tc : Compile and emit a C hex table</strong></p><pre>iasl -tc dsdt.asl</pre><ul><li><strong>-tc</strong> = table create as a C source file. It compiles the ASL and additionally emits a <strong>.hex</strong> file containing the <strong>AML as a C array</strong> (unsigned char AmlCode[] = {0x44, 0x53,…};). This is used when firmware wants to embed the table directly into a C source file compiled into the ROM image.</li><li>Related variants:</li></ul><p>a) <strong>-ta : </strong>emit as ASL constants</p><p>b) <strong>-ts : </strong>emit as ASM source</p><p>c) <strong>-i c / -ic</strong> : force include-file output style</p><p>So <strong>-tc</strong> is fundamentally <em>“compile and give me the bytes in a form I can #include into C firmware code.”</em></p><p><strong>iasl -d : Decompile AML back to ASL</strong></p><pre>iasl -d dsdt.aml</pre><ul><li><strong>-d</strong> = disassemble / decompile. Takes a binary .aml (or a full .dat / table dump) and reconstructs .dsl ASL source. This is how you inspect firmware you don’t have source for - eg. dump your laptop’s DSDT and read it.</li><li><strong>-da file1.aml file2.aml…. : </strong>disassemble multiple tables together so cross-table references (external symbols) resolve correctly. Essential when your DSDT references objects defined in SSDTs.</li><li><strong>-e file.aml : </strong>supply <em>“external”</em> tables for reference during disassembly (they are used for symbol resolution but not themselves decompiled).</li></ul><p>A very common real-world invocation on Linux:</p><pre># Dump the live tables from the running system<br>sudo cp /sys/firmware/acpi/tables/DSDT dsdt.dat<br>sudo cp /sys/firmware/acpi/tables/SSDT* .<br><br># Decompile them together<br>iasl -d dsdt.dat SSDT1 SSDT2<br><br># Edit the resulting dsdt.dsl, then recompile<br>iasl dsdt.dsl # produces dsdt.aml  </pre><p><strong>Other flags worth knowing</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f86c5542669eaae344d7d2487d07dff/href">https://medium.com/media/1f86c5542669eaae344d7d2487d07dff/href</a></iframe><p><strong>Output Files</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9686d98bf79b340dd80f874f2bcc20b8/href">https://medium.com/media/9686d98bf79b340dd80f874f2bcc20b8/href</a></iframe><h3>3. AML Bytecode</h3><p><strong>What AML Opcodes Look Like</strong></p><p>AML is a compact, self-describing binary encoding of the ASL you wrote. Every construct becomes one or more opcodes followed by their operands. Key encoding facts :</p><ul><li><strong>Most opcodes are one byte.</strong> A block of extended opcodes are two bytes, prefixed with 0x5B (the ExtOpPrefix, which is the ASCII [ character).</li><li><strong>Data is prefixed by type bytes :</strong> 0x0A = ByteConst (1 byte follows), 0x0B = WordConst (2 bytes), 0x0C = DWordConst (4 bytes), 0x0E = QWordConst (8 bytes), 0x0D = String (null-terminated).</li><li><strong>Small integer constants have dedicated single-byte opcodes:</strong> 0x00 = Zero, 0x01 = One, 0xFF = Ones (all-bits-set), 0x5B 0x30 = Revision.</li><li><strong>NameSegs are always exactly 4 bytes, ASCII padded with _ (underscore) if shorter.</strong> That’s why every ACPI name is ≤4 chars per segment: _SB_, PCI0,_HID. Names longer visually (LPCB) are exactly 4; shorter ones (EC) becomes EC__.</li></ul><p>A tiny worked example. This ASL :</p><pre>Name (_HID , EisaId (&quot;PNP0A03&quot;))</pre><p>compiles to these AML bytes :</p><pre>08         NameOp              ; &quot;define a named object&quot;<br>5F 48 49 44 &quot;_HID&quot;             ; the 4-byte NameSeg<br>0C          DWordPrefix        ; the value is a 4-byte integer<br>41 D0 0A 03 0x030AD041         ; EisaId (&quot;PNP0A03&quot;) packed  </pre><p>Another, showing a method with a package-length prefix:</p><pre>Method (FOO , 1) {Return (Arg0) }</pre><pre>14       MethodOp<br>08       PkgLength (8 bytes of body follow - length is self-describing)<br>46 4F 4F 5F  &quot;FOO_&quot;<br>01       MethodFlags (1 argument, not serialized)<br>A4       ReturnOp<br>68       Arg0</pre><p>Note the <strong>PkgLength</strong> encoding: it’s a variable-length integer (1 - 4 bytes). The top two bits of the first byte say how many additional bytes follow, so lengths up to 0x0FFFFFFF are encoded compactly. This is why the control-flow blocks (If, While, Method, Scope) don’t need explicit “end” markers - the length tells the interpreter exactly where the block ends.</p><p>Common opcodes to recognize:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b4d9ef9515a2a541805fb97d967aa62/href">https://medium.com/media/7b4d9ef9515a2a541805fb97d967aa62/href</a></iframe><p><strong>How AML is a Stack-Based VM</strong></p><p>The ACPI interpreter executes AML as a tree-walking / stack-based virtual machine. It’s not a register machine like real CPU - it’s much closer to a <strong>bytecode interpreter</strong> . Key characteristics :</p><ul><li><strong>Prefix (Polish) notation.</strong> Operators come <em>before</em> operands: Add (A, B, Result) is AddOp A B Result. The interpreter reads the opcode, then recursively evaluates each operand (which may itself be a nested expression), pushing intermediate results, then applies the operator. This is why AML has no operator-precedence ambiguity - the tree structure encodes it directly.</li><li><strong>Everything is an object.</strong> Operands evaluate to ACPI objects (Integer, String, Buffer, Package, or a reference). The interpreter maintains an operand stack of these objects.</li><li><strong>The Namespace is the “memory”.</strong> Named objects live in a hierarchical namespace (a tree rooted at \). Store, Field accesses, and name references read/write this namespace. Namespace lookup uses ACPI&#39;s scoping/search rules (search upward through parent scopes for unqualified single NameSegs).</li><li><strong>Method invocation</strong> pushes a new frame with its own Arg0..Arg6 and Local0..Local7 slots. Methods can be <em>serialized</em> (a mutex-guarded critical section) or not.</li><li><strong>Region accesses have side effects on real hardware.</strong> When AML reads a Field in a SystemMemory / SystemIO / PCI_Config / EmbeddedControl OperationRegion, the interpreter performs an actual hardware access. This is the whole point: AML is firmware code that pokes hardware in a hardware-abstracted, OS-portable way.</li></ul><p><strong>Execution model summary:</strong> the OS calls a named control method (e.g. evaluates \_SB.PCI0.PS0), the interpreter walks that method&#39;s AML tree, evaluating expressions in prefix order, reading/writing the namespace and hardware regions, and returns an object to the OS.</p><h3>4. The AML Interpreter in the Kernel</h3><ul><li><strong>Linux:</strong> The interpreter is <strong>ACPICA</strong> (the same codebase iASL comes from), incorporated into the kernel under drivers/acpi/acpica/. At boot, the kernel:</li></ul><ol><li>Finds the <strong>RSDP</strong> (Root System Description Pointer) in low memory / EFI config table.</li><li>Follows it to the <strong>RSDT/XSDT</strong>, which lists all other tables.</li><li>Loads the <strong>DSDT</strong> and any <strong>SSDTs</strong>, which contain AML, into the namespace (acpi_load_tables()).</li><li>Runs the interpreter to evaluate methods on demand — during device enumeration (_HID, _CRS, _STA), power management (_PSx, _Sx), thermal (_TMP), GPE/event handling, etc.</li></ol><p>The interpreter core files are dsopcode.c, exoparg*.c (execute operator, N arguments), psparse.c (parse), nsaccess.c (namespace). You can watch it work with CONFIG_ACPI_DEBUG and the acpi.debug_level / debug_layer kernel params, or trace method execution via /sys/module/acpi/parameters/.</p><ul><li><strong>Windows:</strong> ACPI.sys contains a functionally equivalent (Microsoft&#39;s own) AML interpreter. This is the <em>other</em> reference implementation, and divergences between the ACPICA and Microsoft interpreters are a classic source of <em>&quot;works on Windows, breaks on Linux&quot;</em> firmware bugs - which is why some firmware checks \_OSI(&quot;Windows 2020&quot;) and takes different code paths.</li></ul><p><strong>The critical mental model:</strong> <strong><em>AML is not run once and discarded.</em></strong> It stays resident and the OS re-invokes methods throughout the machine’s life. A _TMP thermal method might be called every few seconds; a _DSM might be called whenever a driver probes a device</p><h3>5. EDK2 Build System Integration</h3><p>EDK2 (the TianoCore reference UEFI implementation) has a specific, metadata-driven build system. Here’s how ASL/AML flows through it and lands in the firmware image.</p><h4>5.1 How .asl Files Are Listed in .inf Files</h4><p>In EDK2, every module is described by an .inf (module information) file. A module that provides ACPI tables lists its .asl sources in the [Sources] section, exactly like C files:</p><pre># MyPlatformAcpiTables.inf<br>[Defines]<br>  INF_VERSION    = 0x00010005<br>  BASE_NAME      = MyPlatformAcpiTables<br>  FILE_GUID      = a1b2c3d4-.....        # unique GUID<br>  MODULE_TYPE    = USER_DEFINED<br>  VERSION_STRING = 1.0<br><br>[Sources]<br>  Dsdt.asl<br>  Ssdt.asl<br>  Facs.aslc              # some tables are hand-written as .aslc (C)<br>  Madt.aslc<br>  Fadt.aslc<br><br>[Packages]<br>  MdePkg/MdePkg.dec<br>  MdeModulePkg/MdeModulePkg.dec<br><br>[BuildOptions]<br>  # optional: pass extra flags to iASL</pre><p>Key points:</p><ul><li>MODULE_TYPE = USER_DEFINED is typical for pure ACPI-table modules - they don&#39;t produce an executable PE/COFF, just data tables.</li><li>The EDK2 build tool recognizes the .asl extension and automatically routes it through iASL (the toolchain defines ASL_PATH, ASL_FLAGS, ASLPP_FLAGS in tools_def.txt / Conf/tools_def.txt).</li><li>Tables that need to compute values with C macros (like FADT/MADT/FACS, which are mostly structured binary data rather than AML methods) are often written as .aslc -C files that #include EDK2&#39;s ACPI header structs and are compiled by the C compiler, not iASL. DSDT/SSDT (which contain actual AML methods) are .asl and go through iASL.</li></ul><p><strong>Please note that this module is not a DXE driver with an entry point</strong> - it’s a passive <em>“table storage”</em> module that produces data, not executable code. A separate DXE driver AcpiPlatformDxe is what actually reads that data at boot and installs it.</p><h4>5.2 How the Build Actually Processes ASL - A Brief Overview</h4><p>The EDK2 build (build command / AutoGen) does this per .asl file:</p><ol><li><strong>C preprocessor pass</strong> : The .asl is run through the C preprocessor first (ASLPP), expanding #include, #define, #if. This lets ASL share constants with C headers.</li><li><strong>iASL compile</strong> : Produces the .aml binary.</li><li><strong>Wrap into a raw section / FFS file</strong> : GenFfs/GenSec wrap the .aml into an EFI Firmware File System (FFS) file with the correct section type (EFI_SECTION_RAW), so it can be placed in a Firmware Volume.</li></ol><p>The relevant module is usually AcpiTableDxe (the DXE driver that installs tables) plus a AcpiPlatform driver that reads the raw AML sections and calls InstallAcpiTable().</p><h4>5.3 How Compiled .aml Gets Into the Firmware Volume - A Brief Overview</h4><p>The firmware image layout is described by .fdf (Flash Description File) and the platform .dsc (Description) file:</p><ul><li>.dsc : lists which modules (.inf) are built for the platform. Your ACPI-tables .inf gets a line under [Components]:</li></ul><pre>[Components]<br>  MyPlatformPkg/AcpiTables/MyPlatformAcpiTables.inf</pre><p>.fdf : places the built output into a <strong>Firmware Volume (FV)</strong> within the flash device (FD). The ACPI tables FV is referenced so the .aml data ends up as FFS files inside an FV in the ROM:</p><pre>[FV.DXEFV]<br>  INF MyPlatformPkg/AcpiTables/MyPlatformAcpiTables.inf</pre><p>At runtime, the boot flow is:</p><ol><li>The AcpiPlatformDxe driver locates the raw AML sections (by GUID/section type) inside the FV.</li><li>2. It calls the EFI ACPI Table Protocol (InstallAcpiTable()), which copies each table into ACPI-reclaim memory and links it into the RSDT/XSDT.</li></ol><p>3. The RSDP is installed into the EFI System Configuration Table.</p><p>4. The OS loader/kernel finds the RSDP → XSDT → your DSDT/SSDTs → interpreter runs them (which closes the loop back to AML bytecode).</p><h4>5.4 Build Command and Output</h4><p>Typical EDK2 build invocation:</p><pre># 1. Set up the environment (once per shell) <br><br>source edksetup.sh <br><br># 2. Build the platform <br><br>build -a X64 -t GCC5 -p MyPlatformPkg/MyPlatformPkg.dsc -b RELEASE <br>#      |      |      |                                  | <br>#      |      |      └─ platform description (.dsc)     └─ build target<br>#      |      └─ toolchain tag (defined in tools_def.txt) <br>#      └─ architecture                                                   </pre><p>Output tree (under Build/):</p><pre>Build/MyPlatformPkg/RELEASE_GCC5/ <br>├── X64/ <br>│      └── MyPlatformPkg/AcpiTables/MyPlatformAcpiTables/OUTPUT/ <br>│            ├── Dsdt.aml ← iASL output <br>│            ├── Ssdt.aml <br>│            └── *.acpi ← wrapped/renamed table blobs <br>└── FV/ <br>     └── DXEFV.Fv ← the firmware volume containing your tables<br>     └── FVMain.fd /*.fd ← final flash image (this is what you flash / boot) </pre><p>The <strong>final .fd</strong> is the complete flash image which is flashed to the SPI ROM.</p><h3>6. Deep Dive - How ACPI Information is put into Firmware Volume</h3><h4>6.1 The build: how each source becomes a table blob</h4><p>EDK2’s build is metadata-driven. The rules live in Conf/build_rule.txt (keyed by file extension) and toolchain paths/flags live in Conf/tools_def.txt (ASL_PATH, ASL_FLAGS, ASLPP_FLAGS, ASLDLINK_FLAGS, etc.).</p><h4>6.2 Processing a .asl file → .aml</h4><p>The build rule ([Acpi-Source-Language-File]) runs a <strong>three-step pipeline</strong> per .asl:</p><ol><li><strong>Trim</strong> (an EDK2 python tool) : strips/prepares the ASL so the C preprocessor can run over it (--asl-file mode).</li><li><strong>ASLPP : </strong>the C preprocessor (your C compiler in -E mode) expands #include, #define, #if. This is why ASL can share constant headers with C code. Output is a .i file.</li><li><strong>iASL</strong> (ASL_PATH, i.e. the iasl binary) : compiles the preprocessed ASL → .aml binary. Same compiler as the iASL topic; EDK2 just calls it with platform flags.</li></ol><p>The .aml is then treated as the table blob (.acpi).</p><h4>6.3 Processing a .aslc file → .acpi (raw table)</h4><p>This one is sneaky and worth knowing exactly, because it’s <em>not</em> iASL:</p><ol><li>$(CC) compiles the .aslc as ordinary C → an object file. The table struct ends up in the object&#39;s data.</li><li>$(ASLDLINK) links it into a tiny PE/COFF image (.dll).</li><li>GenFw --acpi (GENFW tool) reads that PE image, finds the table bytes, strips all PE/COFF headers and sections, and writes out just the raw table as a .acpi file.</li></ol><p>So .aslc never touches iASL — it&#39;s <strong>&quot;author a binary table in C, then extract the raw bytes.&quot;</strong> The result is byte-identical in nature to a .aml: a pure ACPI table blob.</p><h4>6.4 The blob itself - what “an ACPI table” actually is</h4><p>Whatever the path, the produced blob is a binary that <strong>starts with the standard 36-byte description header</strong> (EFI_ACPI_DESCRIPTION_HEADER):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K6v-YECKJmXGLSqX9BOmMQ.jpeg" /></figure><ul><li>For <strong>DSDT/SSDT</strong>, the body after the header is <strong>AML bytecode</strong>.</li><li>For <strong>MADT/FADT/etc</strong>, the body is a fixed C struct layout.</li></ul><p>That header + body is <strong>“the ACPI blob.”</strong> At this point in the build it’s sitting in</p><p>Build/&lt;Plat&gt;/&lt;TARGET&gt;_&lt;TOOLCHAIN&gt;/&lt;ARCH&gt;/.../OUTPUT/*.aml (or *.acpi).</p><h4>6.5 Packaging into the Firmware Volume</h4><p>Now the blobs must get into the ROM image. There are two mechanisms to store ACPI structures (Here we have mentioned them as Mechanism A and Mechanism B), because they use different FFS structures.</p><h4>6.5.1 The FV structure primer (needed for both)</h4><p>A flash image is described by two files:</p><ul><li>.dsc (Description) : the list of modules (.inf) to build, under [Components].</li><li>.fdf (Flash Description) : the <em>physical layout:</em> which <strong>Firmware Volumes (FV)</strong> exist and which modules/files go in each, and how FVs are placed in the <strong>Flash Device (FD)</strong> = the final ROM image.</li></ul><p>Inside an FV, everything is stored as <strong>FFS files</strong> (Firmware File System). Each FFS file has:</p><ul><li>A <strong>GUID</strong> (its name),</li><li>A <strong>file type</strong> (EFI_FV_FILETYPE_*),</li><li>One or more <strong>sections</strong> (EFI_SECTION_*).</li></ul><h4>6.5.2 Mechanism A : Packaging: raw AML blob → FREEFORM FFS file</h4><p>The storage INF (AcpiTables.inf) is USER_DEFINED:</p><pre># AcpiTables.inf<br><br>[Defines]<br>  INF_VERSION    = 0x00010005<br>  BASE_NAME      = AcpiTables<br>  FILE_GUID      = 7E374E25-8E01-4FEE-87F2-390C23C606CD    # &lt;-- remember this GUID<br>  MODULE_TYPE    = USER_DEFINED<br>  VERSION_STRING = 1.0<br><br>[Sources]<br>  Dsdt.asl<br>  Ssdt.asl<br>  Fadt.aslc<br>  Madt.aslc<br>  Hpet.aslc<br><br>[Packages]<br>  MdePkg/MdePkg.dec</pre><ul><li>.dsc lists it under [Components].</li><li>.fdf puts it in the DXE firmware volume:</li></ul><pre>[FV.DXEFV]<br><br>  INF RuleOverride = ACPITABLE  MyPlatformPkg/AcpiTables/AcpiTables.inf</pre><pre>[Rule.Common.USER_DEFINED.ACPITABLE]<br>  FILE FREEFORM = $(NAMED_GUID) {<br>      RAW ACPI Optional               | .acpi<br>      RAW ASL  Optional               | .aml<br>      UI      STRING=&quot;$(MODULE_NAME)&quot; Optional<br>      VERSION STRING=&quot;$(INF_VERSION)&quot; Optional BUILD_NUM=$(BUILD_NUMBER)<br>  }<br>/* This is the ACPITABLE rule from build_rule.txt, <br>which tells GenFds to package every .aml and .acpi produced by a <br>USER_DEFINED ACPI module into a FREEFORM FFS file, with each table <br>becoming a RAW section. */</pre><p>During <strong>GenFds</strong>, the tool takes all the compiled blobs from this one module and <strong>wraps them into a single FFS file</strong>:</p><ul><li><strong>FFS file type</strong> = EFI_FV_FILETYPE_FREEFORM (0x02) — &quot;just data, no code.&quot;</li><li><strong>FFS file GUID</strong> = the module’s FILE_GUID (7E374E25-... above).</li><li><strong>Each table blob becomes one </strong><strong>EFI_SECTION_RAW (0x19) section</strong> inside that file. So the FREEFORM file contains N RAW sections:</li></ul><pre>[RAW: Dsdt]<br>[RAW: Ssdt]<br>[RAW: Fadt]<br>[RAW: Madt]<br>[RAW: Hpet]</pre><p>The controlling rule (ACPITABLE in build_rule.txt) is what says <strong>&quot;make each </strong><strong>.aml/</strong><strong>.acpi a RAW section and bundle them into a FREEFORM file named by the module GUID.&quot;</strong> So in the ROM you now have:</p><pre>FV.DXEFV<br>└── FFS file {7E374E25-...}  type=FREEFORM<br>    ├── RAW section → DSDT bytes<br>    ├── RAW section → SSDT bytes<br>    ├── RAW section → FADT bytes<br>    ├── RAW section → MADT bytes<br>    └── RAW section → HPET bytes</pre><p>That GUID is then published to the consumer driver via a PCD, typically PcdAcpiTableStorageFile, set to {7E374E25-...}.</p><h4>6.5.3 Mechanism B : Packaging: struct stays inside the driver .efi</h4><p>Here the INF is a <strong>real DXE driver</strong>:</p><pre># AcpiPlatformDxe.inf (Mechanism B example)<br>[Defines]<br>  MODULE_TYPE = DXE_DRIVER</pre><p>The .aslc sources are compiled into normal object files, linked into the driver&#39;s <strong>PE/COFF</strong> image (.efi), and the ACPI table data simply becomes part of the driver&#39;s .data section.</p><p>There is <strong>no FREEFORM FFS file</strong>, and there are <strong>no RAW sections</strong>.</p><p>Instead, the firmware volume contains only the DXE driver’s FFS file:</p><pre>FV.DXEFV<br>└── FFS file {Driver GUID} type=DRIVER<br>    └── PE32 section<br>        └── AcpiPlatformDxe.efi<br>            ├── .text<br>            ├── .data<br>            │     ├── FADT struct<br>            │     ├── MADT struct<br>            │     └── ...<br>            └── ...</pre><p>The ACPI table bytes live as initialized data inside that PE image; there is <strong>no separate RAW section</strong>.</p><p>So in Mechanism B, <strong>“the table is in the FV” only in the sense that it’s embedded in the driver’s code image.</strong></p><h4>6.5.4 Runtime producer: AcpiTableDxe and InstallAcpiTable()</h4><p>Before any table can be installed, <strong>AcpiTableDxe</strong> (a DXE driver in the FV) loads and publishes gEfiAcpiTableProtocolGuid. Everything downstream depends on this protocol existing.</p><p>When anyone calls</p><pre>InstallAcpiTable(This, TableBuffer, TableSize, &amp;TableKey)</pre><p><strong>AcpiTableDxe</strong> does the following (this is the heart of the whole system):</p><ol><li><strong>Validate</strong> : checks the table’s signature and that Length matches TableSize.</li><li><strong>Allocate the right memory type and copy the table in:</strong></li></ol><ul><li>Most tables → <strong>EfiACPIReclaimMemory</strong> (UEFI memory type 9). The OS is allowed to <strong>reclaim this memory after it has parsed the tables</strong>.</li><li>FACS and tables that must survive → <strong>EfiACPIMemoryNVS</strong> (type 10). The OS must preserve this (it holds the firmware waking vector, hardware signature, etc.).</li><li>This is why the physical location of the table changes between build-time and runtime: <strong>InstallAcpiTable copies the blob out of the FV into freshly allocated ACPI memory.</strong> The FV copy is <strong>not</strong> what the OS reads.</li></ul><p>3.<strong> Link it into the root tables:</strong></p><ul><li>Regular tables (MADT, HPET, SSDT, MCFG…) get their physical address appended to both the <strong>RSDT</strong> (32-bit entries) and <strong>XSDT</strong> (64-bit entries).</li><li><strong>FADT</strong> (signature &quot;FACP&quot;) is special: <strong>AcpiTableDxe</strong> patches the FADT&#39;s Dsdt/XDsdt and FirmwareCtrl/XFirmwareCtrl fields to point at the DSDT and FACS.</li><li><strong>DSDT and FACS are NOT added to RSDT/XSDT directly</strong> — they are reached only through the FADT. (A very common <em>“my DSDT isn’t showing up”</em> bug is expecting it in the XSDT list.)</li></ul><p><strong>4. Recompute checksums</strong> : the installed table’s checksum byte, plus the RSDT and XSDT checksums, are recalculated so every table sums to <strong>0 (mod 256).</strong></p><p><strong>5. First-table bootstrap</strong> : the very first install triggers creation of the <strong>RSDP, RSDT, and XSDT</strong>, and the RSDP is installed into the <strong>UEFI System Configuration Table</strong> via</p><pre>gBS-&gt;InstallConfigurationTable(&amp;gEfiAcpi20TableGuid, Rsdp)</pre><p>(and optionally gEfiAcpi10TableGuid).</p><p><strong>6. Return a </strong><strong>TableKey</strong> so the caller can later uninstall/replace it.</p><p>The RSDP that <strong>AcpiTableDxe</strong> builds contains physical pointers:</p><pre>RSDP<br>   └── (RsdtAddress, XsdtAddress)<br>            └── arrays of table pointers</pre><h4><strong>6.5.5 Runtime consumers: getting the blobs to </strong><strong>InstallAcpiTable()</strong></h4><h4>a) Mechanism A: AcpiPlatformDxe reads RAW sections from the FV</h4><p>This is the standard flow. AcpiPlatformDxe&#39;s entry point:</p><ol><li>Locates gEfiAcpiTableProtocolGuid (from AcpiTableDxe).</li><li>Reads PcdAcpiTableStorageFile → the FFS GUID (7E374E25-...) of the storage file.</li><li>Finds that FFS file in the firmware volumes. It typically loops over all EFI_FIRMWARE_VOLUME2_PROTOCOL instances and calls</li></ol><pre>Fv-&gt;ReadSection(..., EFI_SECTION_RAW, Index, ...)</pre><p>with increasing Index (0, 1, 2, ...).</p><p>4. For each RAW section returned (each is one ACPI blob - the DSDT, then SSDT, then FADT…), it calls:</p><pre>AcpiTable-&gt;InstallAcpiTable(<br>    AcpiTable,<br>    Blob,<br>    BlobSize,<br>    &amp;Key<br>);</pre><p>5. Loops until ReadSection returns EFI_NOT_FOUND — meaning all tables installed.</p><p>So the RAW blobs built in <strong>Stage 3</strong> are pulled out one by one and handed to the producer. (Platform variants sometimes patch tables here first - e.g. filling in the number of CPUs into the MADT, or a runtime-generated table. <strong>OVMF</strong> is an extreme case: it generates most tables from QEMU’s fw_cfg at boot rather than storing static blobs, but it still ends at the same InstallAcpiTable() call.)</p><h4>b) Mechanism B: the driver installs its own struct</h4><p>Much simpler — <strong>no FV reading</strong>:</p><pre>EFI_STATUS EFIAPI InstallMyAcpiTables(...) {<br>    EFI_ACPI_TABLE_PROTOCOL *AcpiTable;<br>    UINTN Key;<br>     gBS-&gt;LocateProtocol(<br>        &amp;gEfiAcpiTableProtocolGuid,<br>        NULL,<br>        (VOID **)&amp;AcpiTable<br>    );<br>    // &amp;Madt is a pointer into THIS driver&#39;s own image bytes<br>    AcpiTable-&gt;InstallAcpiTable(<br>        AcpiTable,<br>        &amp;Madt,<br>        Madt.Header.Length,<br>        &amp;Key<br>    );<br>    return EFI_SUCCESS;<br>}</pre><p>The table pointer points into the driver’s own loaded image. InstallAcpiTable still copies it into EfiACPIReclaimMemory, so it doesn&#39;t matter that the source was inside a PE image.</p><p><strong>Both a) and b) end identically:</strong> the table now lives in ACPI memory and is linked into the XSDT/RSDT (or referenced by FADT).</p><h3>End-to-end picture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f5amLEiZJwUyS-st9bNT6w.jpeg" /></figure><h3>Key Takeaways</h3><ul><li>ACPI tables live a double life: authored as human-readable ASL, but shipped and executed as AML - a compact, stack-based bytecode that runs live for the machine’s entire uptime, not just at boot.</li><li>iASL (ACPICA’s compiler) does the heavy lifting on the language side: parsing, semantic validation against the ACPI spec, AML code generation, and round-trip decompilation for reverse-engineering firmware you don’t have source for.</li><li>AML encoding is deliberately compact and self-describing - one-byte opcodes for common constructs, variable-length PkgLength fields instead of end markers, and fixed 4-byte NameSegs - which is what lets the interpreter walk it as a tree without ambiguity.</li><li>The AML interpreter (ACPICA in Linux, ACPI.sys in Windows) behaves like a small tree-walking VM: prefix notation, an operand stack, a namespace acting as memory, and per-method call frames - and it has real side effects, since Field accesses in an OperationRegion touch actual hardware.</li><li>On the firmware side, EDK2 turns compiled .aml/.acpi blobs into FFS sections inside a Firmware Volume, and a DXE driver later calls InstallAcpiTable() to copy each table into ACPI-reclaim (or NVS) memory and link it into the RSDT/XSDT - the FV copy is never what the OS actually reads.</li><li>Two distinct EDK2 mechanisms exist for getting a table into the image: Mechanism A (raw AML/.acpi blobs wrapped in a FREEFORM FFS file) versus Mechanism B (a C struct compiled straight into a DXE driver&#39;s .data section) — both converge on the same InstallAcpiTable() call at runtime.</li><li>The whole pipeline is one continuous loop: ASL → AML → Firmware Volume → UEFI install → RSDP/RSDT/XSDT → OS → AML interpreter - and understanding each hop is what makes DSDT decompiles and _STA/_CRS bugs debuggable instead of mysterious.</li></ul><h3>References</h3><p><strong>ACPI specification</strong></p><ol><li>ACPI Specifications (UEFI Forum) — <a href="https://uefi.org/acpi/specs">https://uefi.org/acpi/specs</a></li><li>ACPI Spec 6.4, full text (HTML) — <a href="https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/">https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/</a></li></ol><p><strong>ACPICA (reference AML interpreter, used directly by Linux)</strong><br> 3. ACPICA documentation &amp; user guide (Intel) — <a href="https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html">https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html</a><br> 4. ACPICA source (GitHub) — <a href="https://github.com/acpica/acpica">https://github.com/acpica/acpica</a></p><p><strong>Linux ACPI implementation</strong><br> 5. Linuxized ACPICA — how Linux syncs with upstream ACPICA — <a href="https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html">https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html</a><br> 6. Linux kernel ACPI driver-api docs — <a href="https://docs.kernel.org/driver-api/acpi/index.html">https://docs.kernel.org/driver-api/acpi/index.html</a><br> 7. Linux kernel source, drivers/acpi — <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi</a></p><p><strong>Windows internals</strong><br> 8. Windows Driver Kit — Kernel-Mode Driver Architecture — <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/">https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/</a><br> 9. Russinovich, Solomon, Ionescu — <em>Windows Internals</em>, Part 1 (7th ed.) — standard secondary source for undocumented boot/HAL routines like KiSystemStartup, HalInitSystem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7095e158fdc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ACPI Tables Demystified: The purpose and the Complete Hierarchy]]></title>
            <link>https://medium.com/@kushaldps1996/acpi-tables-demystified-the-purpose-and-the-complete-hierarchy-161414492293?source=rss-20cb97d60801------2</link>
            <guid isPermaLink="false">https://medium.com/p/161414492293</guid>
            <dc:creator><![CDATA[KUSHAL CHAKRABORTY]]></dc:creator>
            <pubDate>Sat, 01 Aug 2026 13:45:22 GMT</pubDate>
            <atom:updated>2026-08-01T13:45:22.038Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Ever wondered how your laptop “knows” to sleep when you close the lid or why shutting down your PC powers off completely without you holding the power button ? Meet ACPI - the unsung hero quietly managing your computer’s power and hardware.</em></p><h3>Table of Contents</h3><ol><li>What is ACPI</li><li>Why was ACPI created</li><li>The Purpose of ACPI</li><li>ACPI Table Hierarchy - The Complete Reference</li><li>Initial Analysis of ACPI Table</li><li>iASL vs C structures - The Big Misconception</li><li>The ACPI Table Common Header</li><li>Wrap up and KeyTakeaways</li></ol><h3><strong>1. What is ACPI ?</strong></h3><p><strong>ACPI</strong>, short for <strong>Advanced Configuration and Power Interface</strong>, is an open industry standard that defines how an OS communicates with a computer’s hardware - specifically for <strong>power management, device configuration </strong>and<strong> thermal control</strong>.</p><p>In simpler terms:</p><p><em>ACPI is the bridge between your OS and your hardware’s power management capabilities.</em></p><p>It was first introduced in <strong>1996</strong> as a collaborative effort between three tech giants:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*dAvMqlhkugT7pGLHfTM9eQ.jpeg" /></figure><p>Since then, ACPI has evolved through multiple versions and is now maintained by <strong>UEFI Forum</strong>.</p><h3>2. Why Was ACPI Created ?</h3><p>Before ACPI existed, computers relied on older standard called<strong> APM (Advanced Power Management). </strong>While APM was a step forward in its time,it had significant <strong>limitations</strong> :</p><p>a) <strong>BIOS controlled power management</strong> : the OS had little to no say in how power was managed.</p><p>b) <strong>Vendor specific implementations</strong> : every hardware manufacturer did things differently, leading to compatibility nightmares.</p><p>c) <strong>Limited flexibility : </strong>APM couldn’t handle modern devices, hotplugging, or fine-grained device control.</p><p>d) <strong>No standardized thermal management :</strong> Systems couldn’t intelligently respond to temperature changes.</p><p>This fragmented landscape was unsustainable. As computers became more complex - especially with the rise of laptops, portable devices, and power hungry CPUs - the industry needed a unified solution.</p><p>So in 1996 Intel,Microsoft, Toshiba came together and designed ACPI to solve all of these problems at once, replacing APM with a <strong>flexible, OS-directed, hardware-agnostic standard.</strong></p><p>Hence ACPI solves <strong>platform abstraction :</strong></p><p>a) Firmware/UEFI can ship one OS-agnostic hardware description.</p><p>b) OS can boot on many platforms without hardcoding board-specific details.</p><p>c) Devices can be described consistently and discovered dynamically.</p><h3><strong>3. The Purpose of ACPI</strong></h3><p>ACPI serves four major purposes in a modern computer system :</p><ol><li><strong>Power Management : </strong>The most well-known feaure of ACPI. It allows the OS to intelligently control the power consumption of the entire system and individual components - extending battery life and reducing energy waste.</li><li><strong>Hardware Configuration : </strong>ACPI enables <strong>Plug-and-Play</strong> functionality - the OS can discover, configure and allocate resources (IRQs, memory, I/O ports) for hardware devices dynamically, without requiring manual configuration.</li><li><strong>Thermal Management : </strong>ACPI provides a framework for temperature monitoring and response. The OS can read thermal sensors and take actions like adjusting fan speeds, throttling the CPU, or initiating a system shutdown to prevent overheating.</li><li><strong>Device &amp; System Management : </strong>ACPI defines standardized power states for both the system and individual devices, allowing seamless transitions between working, sleeping and powered-off states.</li></ol><p>At boot, OS needs to answer questions like:</p><p>a. How many CPUs exist and how do I bring them online ?</p><p>b. Which interrupt controllers are present and where are it’s registers ?</p><p>c. How do I enumerate PCI and map interrupts ?</p><p>d. Where are I2C/UART/SPI controllers and their child devices ?</p><p>e. Which devices can wake the system ?</p><p>f. What is the thermal policy and how do I read temperatures ?</p><p>g. How do I interpret firmware error logs ?</p><p>ACPI tables are the structured <strong>dataset + executable model,</strong> OS uses to answer these.</p><p>Hence ACPI can also be considered as a <strong>firmware-to-OS contract</strong> that describes :</p><p>a) <strong>Hardware toplogy</strong> (CPUs, interrupt controllers, timers, PCIe root complexes, IOMMUs)</p><p>b) <strong>Device presence and configuration</strong> (what devices exist and how to talk to them)</p><p>c) <strong>Power management model</strong> (sleep states, wake, thermal, battery)</p><p>d) <strong>Runtime Hooks</strong> via <strong>AML (ACPI Machine Language) methods</strong> (eg <strong>_STA </strong>, <strong>_CRS</strong>, <strong>_DSM </strong>, <strong>_PS0 </strong>,<strong>_PRW</strong>)</p><h3>4. ACPI Table Hierarchy - The Complete Reference</h3><h4>4.1 Part 1: Hierarchy Diagram</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc2bd50f9f2d7fa31becefd5e814d2b9/href">https://medium.com/media/fc2bd50f9f2d7fa31becefd5e814d2b9/href</a></iframe><h4>4.2 Part 2 : Complete Table Reference (By Category)</h4><h4>4.2.1 Root &amp; Core</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d9a114f736fe3c1637cb018a226e7f0/href">https://medium.com/media/4d9a114f736fe3c1637cb018a226e7f0/href</a></iframe><h4>4.2.2 CPU / Interrupts / Topology</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/475c2dd27cfdeb2a9d386c31f625e8ba/href">https://medium.com/media/475c2dd27cfdeb2a9d386c31f625e8ba/href</a></iframe><h4>4.2.3 Timers / Power</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e5280fd2c00acc44652a1eb793e6bb14/href">https://medium.com/media/e5280fd2c00acc44652a1eb793e6bb14/href</a></iframe><h4>4.2.4 PCI / Buses / Devices</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83c53c4fa24a47aabb0a9f7752280a6a/href">https://medium.com/media/83c53c4fa24a47aabb0a9f7752280a6a/href</a></iframe><h4>4.2.5 NUMA / Memory / Persistent Memory</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd80986b79f4f1e967f31f9d89907674/href">https://medium.com/media/cd80986b79f4f1e967f31f9d89907674/href</a></iframe><h4><strong>4.2.6 RAS / APEI (Error Handling)</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3674f4d86a309f6479b29357be72bd57/href">https://medium.com/media/3674f4d86a309f6479b29357be72bd57/href</a></iframe><h4>4.2.7 Security / Trust / Measurement</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae85d2a64f6e0f574043a482bfb601db/href">https://medium.com/media/ae85d2a64f6e0f574043a482bfb601db/href</a></iframe><h4>4.2.8 Power Source / Thermal / Battery</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aafce64468ff2013a396745c8319a801/href">https://medium.com/media/aafce64468ff2013a396745c8319a801/href</a></iframe><h4>4.2.9 Misc / Debug / Platform / Vendor</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a58f6cd4a3612ad99801b89195ae5955/href">https://medium.com/media/a58f6cd4a3612ad99801b89195ae5955/href</a></iframe><h4>4.2.10 Widely-Deployed Industry/Vendor Tables</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c5b4e7c26c97c375582a2caaf13bcd1/href">https://medium.com/media/5c5b4e7c26c97c375582a2caaf13bcd1/href</a></iframe><h4>4.2.11 Deprecated / Obsolete Signatures</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e994ce63a18b245c2b0ce3c229353c4/href">https://medium.com/media/2e994ce63a18b245c2b0ce3c229353c4/href</a></iframe><p><strong>Note:</strong> Many tables above are optional or vendor/architecture-specific (some ARM64-only, some x86-only, some server/BMC-only). Real-world Linux/Windows support varies by platform - absence of a table on a given machine doesn&#39;t mean it&#39;s “missing,” it may simply not apply to that hardware class.</p><h3>5. Initial Analysis of the ACPI Tables</h3><h4><strong>A) RSDP → XSDT → All Tables</strong></h4><p>The OS begins ACPI discovery from <strong>RSDP (Root System Description Pointer)</strong>. On UEFI systems, the bootloader finds it from the <strong>Configuration Table within the EFI System Table.</strong></p><p><strong>RSDP</strong> points to:</p><p>a) <strong>RSDT</strong> (ACPI 1.0 32-bit table pointers)</p><p>b) <strong>XSDT</strong> (ACPI 2.0+, 64-bit pointers; modern systems)</p><h4><strong>B) Why DSDT is NOT in XSDT (goes via FADT)</strong></h4><p><strong>B.1) First Reason - The Historical Reason :</strong></p><p>When ACPI was first designed the table hierarchy was: RSDP →RSDT →FADT → DSDT. At this point, RSDT held pointers to fixed/static hardware description tables. DSDT was treated differently - it was AML bytecode, not a simple hardware description table. FADT was a master hardware configuration table and DSDT was considered its dependent child - a natural extension of FADT. When ACPI 2.0 introduced XSDT (64-bit version of RSDT), the decision was made to keep DSDT as a child of FADT - not promote it as a direct XSDT entry. This preserves <strong>backward compatibility -</strong>every existing ACPI parser already knew to find DSDT via FADT, and breaking that would have been catastrophic.</p><p><strong>B.2) Second Reason - The Architectural Reason :</strong></p><p><strong>FADT</strong> and <strong>DSDT</strong> are inseparable by design. Think of it as this way:</p><p><strong>FADT</strong> = hardware map = which says <em>“Here is your hardware: the SCI IRQ is pin 9, the RTC is at this address,..”</em></p><p><strong>DSDT</strong> = Software instruction to use that map = which says “Here is the AML code to control that hardware”.</p><p>They are two halves of the same description - FADT describes the <strong>fixed/static hardware registers</strong>, and DSDT provides the <strong>programmable logic</strong> to operate them.</p><p><strong>B.3) The Boot Criticality Reason</strong></p><p>During early boot, the OS needs to find RSDP →find XSDT → find FADT → find DSDT →load and parse AML from DSDT →Build ACPI namespace → Initialize devices. DSDT must be <strong>available before any device can be initialized</strong>. By anchoring DSDT directly inside FADT with a dedicated pointer field, the OS always has a guaranteed <strong>O(1) lookup path (No scanning needed). If DSDT were just another entry inside XSDT, the OS would have to scan the entire XSDT Table list to find it - potentialy slower and error-prone during a critical boot phase.</strong></p><p><strong>B.4) The 32-bit vs 64-bit Reason</strong></p><p>FADT actually holds <strong>2 pointers</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fa70b8962c8c17946d8ecc4b71bac44/href">https://medium.com/media/4fa70b8962c8c17946d8ecc4b71bac44/href</a></iframe><ul><li>If DSDT were inside XSDT, it would only have a 64-bit pointer</li><li>By staying in FADT, DSDT can be referenced by both 32-bit and 64-bit systems</li><li>This ensures maximum backward compatibility across all ACPI versions. <strong>Modern OS parsers prefer X_DSDT over DSDT when both are present.</strong></li></ul><p><strong>B.5) The SSDT Comparison</strong></p><p>DSDT = Only ONE AML root namespace - mandatory, singular, boot-critical</p><p>SSDT = Optional extensions to DSDT - can be many, loaded after DSDT, can even be injected at runtime.</p><p>Putting DSDT in XSDT would mean the OS has to scan XSDT to find which entry is DSDT among possibly dozens of SSDTs - ambiguous and fragile. Having it pinned to FADT makes it always deterministic.</p><h3>6. iASL vs C structures - The Big Misconception</h3><p>This is a frequent source of confusion, so let’s lock it down.</p><h4>6.1 What iASL compiles</h4><p>The iASL compiler compiles ASL source into AML bytecode for:</p><ul><li>DSDT</li><li>SSDTs</li></ul><p>These are <strong>ACPI Definition Blocks</strong>.</p><p>AML is execued by the OS’s ACPI interpreter.</p><h4>6.2 What is written as C structures</h4><p>Most other ACPI tables are <strong>static binary data tables</strong> with fixed structures. In <strong>UEFI (EDK2)</strong> they are typically authored as <strong>C structs</strong> and installed via <strong>EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable()</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83d98b91fe91fcc7f2892625d9c7bad4/href">https://medium.com/media/83d98b91fe91fcc7f2892625d9c7bad4/href</a></iframe><h3>7. The ACPI Table Common Header</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ede9a8a1b9894594d0cdeef5629c4e02/href">https://medium.com/media/ede9a8a1b9894594d0cdeef5629c4e02/href</a></iframe><p><strong>A quick debugging tip:</strong> the <strong>checksum</strong> field is what makes the <em>entire table</em> sum to zero. When firmware patches a table at runtime (for example, filling in the DSDT pointer inside the FADT), it must recompute this checksum, or the OS will reject the table as corrupt.</p><h3>8. Key Takeaways</h3><p>ACPI is, at its heart, a contract: the firmware describes the hardware once, in a standard form, and any OS can read that description and drive the platform’s power, configuration, and thermal behavior. The table hierarchy - anchored at RSDP, branching through RSDT/XSDT, with FADT holding the special keys to DSDT and FACS - is simply the physical layout of that contract.</p><p>In the next articles we’ll go one level deeper: <strong>how ASL source becomes AML bytecode</strong>, and <strong>how you actually write the ASL and description tables</strong> that describe real devices like an I2C controller.</p><h3>References</h3><p><strong>ACPI specification</strong></p><ol><li>ACPI Specifications (UEFI Forum) — <a href="https://uefi.org/acpi/specs">https://uefi.org/acpi/specs</a></li><li>ACPI Spec 6.4, full text (HTML) — <a href="https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/">https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/</a></li></ol><p><strong>ACPICA (reference AML interpreter, used directly by Linux)</strong><br> 3. ACPICA documentation &amp; user guide (Intel) — <a href="https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html">https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/documentation.html</a><br> 4. ACPICA source (GitHub) — <a href="https://github.com/acpica/acpica">https://github.com/acpica/acpica</a></p><p><strong>Linux ACPI implementation</strong><br> 5. Linuxized ACPICA — how Linux syncs with upstream ACPICA — <a href="https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html">https://docs.kernel.org/driver-api/acpi/linuxized-acpica.html</a><br> 6. Linux kernel ACPI driver-api docs — <a href="https://docs.kernel.org/driver-api/acpi/index.html">https://docs.kernel.org/driver-api/acpi/index.html</a><br> 7. Linux kernel source, drivers/acpi — <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/acpi</a></p><p><strong>Windows internals</strong><br> 8. Windows Driver Kit — Kernel-Mode Driver Architecture — <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/">https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/</a><br> 9. Russinovich, Solomon, Ionescu — <em>Windows Internals</em>, Part 1 (7th ed.) — standard secondary source for undocumented boot/HAL routines like KiSystemStartup, HalInitSystem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=161414492293" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>