You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9c20e2c
Browse filesBrowse the repository at this point in the historyBrowse files
iokit doc: add 'what a kernel registry looks like' (the /sys analogy)
Concrete breakdown for shared understanding: the registry as an in-kernel
device tree of nodes+property bags (like the data behind Linux /sys, via API
not a filesystem); a Linux/Apple/FreeBSD mapping table; a worked example (the
8260 registry node + IntelWiFi.kext personality + the matcher binding them);
and the three pieces (registry / IOCatalogue / matcher) with what newbus
already provides vs what Option B must build.
Copy file name to clipboardExpand all lines: nextbsd-inkernel-iokit-feasibility.html
+32Lines changed: 32 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,38 @@ <h2 id="apple">2. How Apple actually does it — the kernel decides, the dae
93
93
94
94
<p>Consequence: an Apple-<em>faithful</em> NextBSD puts matching in the kernel and reduces kextd to a loader. A userland matcher is a real architecture — but it splits device-tree authority (kernel) from binding authority (userland), loses the kernel’s atomic match locking, and can’t bind critical-path devices until userland is up. It should be chosen with eyes open, documented as a divergence.</p>
95
95
96
+
<h3>What a “kernel registry” actually looks like (yes — like the data behind Linux <code>/sys</code>)</h3>
97
+
<p>Concretely, the registry is an <strong>in-kernel, in-memory tree</strong>: one <em>node</em> per device or service, each holding a <em>property dictionary</em> (key/value pairs). It is built live as buses enumerate hardware (nothing on disk) and torn down on unplug. The closest mental model is <strong>the device model behind Linux’s <code>/sys</code></strong> — the same kind of data (a tree of devices with properties), just reached through an API rather than a mounted filesystem.</p>
98
+
<table>
99
+
<tr><th></th><th>The in-kernel tree</th><th>How userland reads it</th><th>The match database</th></tr>
<p>A node for your t420’s WiFi is just a path in the tree plus a property bag — pure <em>data</em> describing the hardware found (it carries no logic, and no IDs are hardcoded in the kernel):</p>
105
+
<pre><code>IORegistry (in kernel)
106
+
└─ pci0
107
+
└─ IOPCIDevice@4:0:0 <- one registry node = one device
108
+
IOProviderClass = "IOPCIDevice"
109
+
vendor-id = 0x8086 (Intel)
110
+
device-id = 0x24f3 (Wireless-AC 8260)
111
+
class-code = 0x028000 (network controller)
112
+
IONameMatch = "pci8086,24f3"
113
+
(no driver bound yet)</code></pre>
114
+
<p>Beside the registry sits the <strong>IOCatalogue</strong> — the union of every kext’s <code>IOKitPersonalities</code>. <code>IntelWiFi.kext</code>’s personality is also just data, and <em>this</em> is where device IDs live:</p>
<p>The <strong>matcher</strong> is the kernel code that, when the registry gains the 8260 node, walks the IOCatalogue, finds the personality whose <code>IOPCIPrimaryMatch</code> equals the node’s <code>vendor-id</code>/<code>device-id</code>, and — since that driver’s code isn’t resident — asks kextd to load <code>IntelWiFi.kext</code>. So an “in-kernel IOKit registry” is really <em>three</em> cooperating pieces:</p>
121
+
<ol>
122
+
<li><strong>Registry</strong> — the live device tree + property bags (the <code>/sys</code>-like data).</li>
123
+
<li><strong>IOCatalogue</strong> — the in-kernel set of all kext personalities (the match rules; the IDs live here, in the kexts).</li>
124
+
<li><strong>Matcher</strong> — the engine that binds a registry node to a catalogue personality and triggers the load.</li>
125
+
</ol>
126
+
<p>newbus already gives us #1 (the <code>device_t</code> tree + discovery) and a probe/attach engine close to #3. What Option B adds is a registry <em>representation</em> with property bags, an IOCatalogue holding <em>externalized</em> personalities (vs newbus’s compiled-in ID tables), and the matcher + the kernel→kextd load request. That delta is the build.</p>
127
+
96
128
<h2id="freebsd">3. The FreeBSD substrate we build on (newbus)</h2>
97
129
<p>The good news: newbus is structurally close to IOKit, and <em>already in-kernel</em>. A faithful IOKit matcher is closer to a superset of newbus than a from-scratch subsystem.</p>
0 commit comments