garage44.eu/jeroen/pinnacle

logclone: git clone https://garage44.eu/jeroen/pinnacle.git

cartopolis-agent · 2026-11-30T14:36:15Z

feat(settings): each driver as open code alone or with closed firmware

The DEVICES call gives a fifth column, the closed firmware the device's
driver handed it (`Intel, <file>`, from device::note_firmware) or `-`;
pinnacle_rt::Device has it as `firmware`. Settings → Hardware shows a
card "Open and closed": each driver (× n for several devices) as "open
driver" or "open driver + closed firmware (Intel, <file>)"; what no
driver took now reads "no driver". Dutch for the four new texts.

Tested on mac-2: pinnacle-locale's tests (every text translated and
sorted) pass; clippy for abi, rt, ui and programs shows nothing; `cargo
xtask pc` passes. The firmware row appears only with an Intel Wi-Fi
chip, which QEMU has not.
abi/src/lib.rs               |  7 +++---
 kernel/src/device.rs         | 21 ++++++++++++++++++
 kernel/src/syscall.rs        |  7 +++++-
 locale/src/nl.rs             |  6 +++++-
 programs/src/bin/settings.rs | 51 ++++++++++++++++++++++++++++++++------------
 rt/src/lib.rs                |  4 ++++
 6 files changed, 77 insertions(+), 19 deletions(-)

diff --git a/abi/src/lib.rs b/abi/src/lib.rs
index 03dd9ea..d8de86e 100644
--- a/abi/src/lib.rs
+++ b/abi/src/lib.rs
@@ -208,9 +208,10 @@ pub mod call {
     /// What `poll` is elsewhere: readiness, for event loops.
     pub const WAIT: u64 = 54;
     /// `devices(buffer, len)`: the hardware the kernel found, one device a
-    /// line: class, driver, node name and what it is compatible with,
-    /// tab-separated; class and driver `-` for one no driver took. Returns
-    /// the length written.
+    /// line: class, driver, node name, what it is compatible with and the
+    /// closed firmware its driver handed it (`Intel, <file>`),
+    /// tab-separated; class and driver `-` for one no driver took, firmware
+    /// `-` for none. Returns the length written.
     pub const DEVICES: u64 = 55;
     /// `gpu()`: a channel to a context of its own on the 3D GPU, whose Venus
     /// runs the program's Vulkan on the host's (the messages in
diff --git a/kernel/src/device.rs b/kernel/src/device.rs
index 2c6afda..12d6e93 100644
--- a/kernel/src/device.rs
+++ b/kernel/src/device.rs
@@ -192,3 +192,24 @@ pub fn mark_compatible(compatible: &str, driver: &'static str, class: Class) {
 pub fn all() -> Vec<Device> {
     DEVICES.lock().clone()
 }
+
+/// What closed firmware a device's driver handed it, by the device's
+/// name: `Intel, iwlwifi-so-a0-gf-a0-89.ucode`. A driver of Pinnacle's own
+/// with no such note runs no closed code on its device.
+static FIRMWARE: SpinLock<Vec<(String, String)>> = SpinLock::new(Vec::new());
+
+/// Notes that `name`'s driver uses closed firmware: `vendor` and its file.
+pub fn note_firmware(name: &str, vendor: &str, file: &str) {
+    let mut notes = FIRMWARE.lock();
+    notes.retain(|(n, _)| n != name);
+    notes.push((String::from(name), alloc::format!("{vendor}, {file}")));
+}
+
+/// The closed firmware noted for `name`, if any.
+pub fn firmware(name: &str) -> Option<String> {
+    FIRMWARE
+        .lock()
+        .iter()
+        .find(|(n, _)| n == name)
+        .map(|(_, f)| f.clone())
+}
diff --git a/kernel/src/syscall.rs b/kernel/src/syscall.rs
index 77a81e9..d8b5279 100644
--- a/kernel/src/syscall.rs
+++ b/kernel/src/syscall.rs
@@ -306,7 +306,12 @@ fn handle_call(frame: *mut Frame) -> *mut Frame {
                 let (driver, class) = d
                     .driver
                     .map_or(("-", "-"), |(driver, class)| (driver, class.name()));
-                text += &alloc::format!("{class}\t{driver}\t{}\t{}\n", d.name, d.compatible.join(","));
+                let firmware = crate::device::firmware(&d.name).unwrap_or_else(|| "-".into());
+                text += &alloc::format!(
+                    "{class}\t{driver}\t{}\t{}\t{firmware}\n",
+                    d.name,
+                    d.compatible.join(",")
+                );
             }
             let len = text.len().min(a[1] as usize);
             if write_user(a[0] as usize, &text.as_bytes()[..len]) {
diff --git a/locale/src/nl.rs b/locale/src/nl.rs
index 338a94b..949a046 100644
--- a/locale/src/nl.rs
+++ b/locale/src/nl.rs
@@ -3,7 +3,7 @@
 //! missing here fails `every_text_the_programs_ask_for_is_translated`.
 
 #[rustfmt::skip]
-pub static TEXTS: [(&str, &str); 417] = [
+pub static TEXTS: [(&str, &str); 421] = [
     ("+  New note", "+  Nieuwe notitie"),
     (", kept", ", bewaard"),
     ("1 note", "1 notitie"),
@@ -225,6 +225,7 @@ pub static TEXTS: [(&str, &str); 417] = [
     ("Online", "Online"),
     ("Online, wired", "Online, via een kabel"),
     ("Open", "Open"),
+    ("Open and closed", "Open en gesloten"),
     ("Open the folder it goes to, then Move here", "Open de map waar het heen gaat, dan Hierheen verplaatsen"),
     ("Open the folder the copy goes to, then Copy here", "Open de map waar de kopie heen gaat, dan Hierheen kopiëren"),
     ("Opening…", "Openen…"),
@@ -370,8 +371,11 @@ pub static TEXTS: [(&str, &str); 417] = [
     ("its list of files is not one", "zijn lijst van bestanden klopt niet"),
     ("its manifest is not one", "zijn manifest klopt niet"),
     ("link", "link"),
+    ("no driver", "geen stuurprogramma"),
     ("off", "uit"),
     ("on", "aan"),
+    ("open driver", "open stuurprogramma"),
+    ("open driver + closed firmware ({})", "open stuurprogramma + gesloten firmware ({})"),
     ("screen reader", "schermlezer"),
     ("sideways", "liggend"),
     ("slider", "schuifregelaar"),
diff --git a/programs/src/bin/settings.rs b/programs/src/bin/settings.rs
index 759ba0a..539185f 100644
--- a/programs/src/bin/settings.rs
+++ b/programs/src/bin/settings.rs
@@ -243,7 +243,8 @@ fn mib(bytes: u64) -> String {
 }
 
 /// The hardware page: each class of device and the drivers that took
-/// them, then what no driver took, as many rows as fit in `height`.
+/// them, each driver as open code alone or with a vendor's closed
+/// firmware, then what no driver took, as many rows as fit in `height`.
 fn hardware(height: i32) -> Vec<Section> {
     let devices = pinnacle_rt::devices();
     let bound = devices.iter().filter(|d| d.driver.is_some()).count();
@@ -298,24 +299,42 @@ fn hardware(height: i32) -> Vec<Section> {
         .iter()
         .map(|(class, drivers)| row(&capital(class), listed(drivers)))
         .collect();
-    // What room is left below the first two cards, a row each.
+    // Each driver, and whether its device runs closed code of another's:
+    // the drivers are all Pinnacle's own, some hand their device a
+    // vendor's firmware (`firmware/`, docs/hardware.md).
+    let mut code: Vec<((String, String), usize)> = Vec::new();
+    for d in &devices {
+        if let Some(driver) = &d.driver {
+            let what = match &d.firmware {
+                Some(firmware) => tf("open driver + closed firmware ({})", &[firmware.as_str()]),
+                None => t("open driver").into(),
+            };
+            match code.iter_mut().find(|(key, _)| key.0 == *driver && key.1 == what) {
+                Some((_, k)) => *k += 1,
+                None => code.push(((driver.clone(), what), 1)),
+            }
+        }
+    }
+    let times = |k: usize| {
+        if k > 1 {
+            alloc::format!(" × {k}")
+        } else {
+            String::new()
+        }
+    };
+    let code: Vec<Row> = code
+        .iter()
+        .map(|((driver, what), k)| row(&alloc::format!("{driver}{}", times(*k)), what.clone()))
+        .collect();
+    // What room is left below the first three cards, a row each.
     let used = 120
-        + 2 * (settings::HEADING + 28)
-        + (1 + with_driver.len() as i32) * settings::ROW
+        + 3 * (settings::HEADING + 28)
+        + (1 + with_driver.len() as i32 + code.len() as i32) * settings::ROW
         + settings::HEADING;
     let room = ((height - used - 24) / settings::ROW).max(1) as usize;
     let mut rest: Vec<Row> = without
         .iter()
-        .map(|(name, k)| {
-            row(
-                name,
-                if *k > 1 {
-                    alloc::format!("× {k}")
-                } else {
-                    String::new()
-                },
-            )
-        })
+        .map(|(name, k)| row(&alloc::format!("{name}{}", times(*k)), t("no driver").into()))
         .collect();
     if rest.len() > room {
         let hidden = rest.len() - room + 1;
@@ -342,6 +361,10 @@ fn hardware(height: i32) -> Vec<Section> {
             title: t("With a driver"),
             rows: with_driver,
         },
+        Section {
+            title: t("Open and closed"),
+            rows: code,
+        },
     ];
     if !rest.is_empty() {
         sections.push(Section {
diff --git a/rt/src/lib.rs b/rt/src/lib.rs
index 661a775..2196c0f 100644
--- a/rt/src/lib.rs
+++ b/rt/src/lib.rs
@@ -394,6 +394,9 @@ pub struct Device {
     pub name: alloc::string::String,
     /// What it is compatible with, most specific first.
     pub compatible: alloc::string::String,
+    /// The closed firmware its driver handed it, `Intel, <file>`; `None`
+    /// when it runs none (or has no driver).
+    pub firmware: Option<alloc::string::String>,
 }
 
 /// The hardware the kernel found, and which driver took each.
@@ -415,6 +418,7 @@ pub fn devices() -> Vec<Device> {
                 driver: some(parts.next()?),
                 name: parts.next()?.into(),
                 compatible: parts.next()?.into(),
+                firmware: parts.next().and_then(some),
             })
         })
         .collect()