Skip to content

Laptop battery from real firmware, more Settings, new input drivers, winrun power and shlwapi - #114

Merged
v3nn7 merged 6 commits into
mainfrom
v3nn7/sweet-archimedes-d75mf2
Nov 10, 2026
Merged

v3nn7 merged 6 commits into
mainfrom
v3nn7/sweet-archimedes-d75mf2

Conversation

@v3nn7

@v3nn7 v3nn7 commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

What does this change?

Battery on laptops (root cause). The AML interpreter could not load or run tables written the way laptop firmware is. A ThinkPad-style table lost every method of its battery device at the first Package (0x04) {}, so no battery state was shown. Found by running firmware tables compiled with iasl; fixed in third_party/aml (details in OSYX-CHANGES.md):

  • packages with fewer initializers than elements; a table keeps loading after an object the interpreter cannot parse; device initialisation goes on after a failing _INI
  • Acquire time-out encoding (every method that takes a mutex failed), fields read as values when used (they were read later, from the wrong EC page), fields wider than 64 bits, fields at odd offsets, IndexField, BankField
  • package arguments by reference, nested Index targets, implicit conversion on stores, CondRefOf with a target, RefOf, FindSetLeftBit/RightBit, Match, Timer, FromBCD/ToBCD, Load/Unload
  • no panics on CreateQWordField, Fatal, stale handles (a panic ended batteryd)

batteryd logs what a table lost and which firmware method failed (with the interpreter's error), and publishes the battery's identity, thermal zones and lid. The desktop warns at a low and at a critical charge.

Settings. New sections Power and Mouse & Touchpad; Keyboard gains German, UK and French layouts; Sound gains volume and mute; Date & Time gains 22 time zones and the clock format. Layout and pointer options apply within seconds (PRISM follows the files).

Drivers.

  • USB HID absolute pointers: tablets, touch screens, the pointer of QEMU/VirtualBox/remote consoles (they were refused)
  • virtio-input: keyboards, mice and tablets of virtual machines
  • ACPI thermal zones and lid, through batteryd

winrun.

  • GetSystemPowerStatus, CallNtPowerInformation (battery state, capabilities), GetPwrCapabilities, PowerDeterminePlatformRole answer from the firmware's battery
  • 76 more shlwapi path and string helpers, wide and ANSI, also for 32-bit programs; shlwapi coverage in the parity scan 3.9 % → 23.9 % (x64), 20.8 % (x86)

CI runs the osyx-battery, osyx-usb, osyx-i2c and osyx-i2chid host tests.

How was it tested?

  • Host tests: cargo test for the CI crate list plus osyx-battery (14 + 17 + 13), osyx-usb (45), osyx-i2c, osyx-i2chid, osyx-input (20), osyx-ui (32), prism-core (45): all pass
  • Firmware tables compiled by iasl (checked in with their .asl sources): three firmware styles, a secondary table, an operator conformance table (9 methods, each run twice)
  • QEMU (q35, OVMF, TCG) with the live ISO built by scripts/build-linux.sh:
    • -acpitable file=scripts/acpi/qemu-battery.aml: kernel firmware interface → batteryd → task bar indicator, Settings > Power, notification on click
    • init.args=tests,battery-demo: "Battery low: 12 %" notification
    • Settings pages driven through QMP: clock format, zone list scrolling, pointer speed slider, German layout typed into a text field
    • usb-tablet; virtio-keyboard-pci + virtio-tablet-pci; virtio-keyboard-pci + virtio-mouse-pci, each as the only input devices
    • winrun shlpath.exe: 123 passed, 0 failed; winrun power.exe: 26 passed with the battery table, 17 without a battery service
  • python3 scripts/winparity.py scan and its unit tests pass

Limitations or screenshots

  • No laptop was available: the fixtures are written in the style of real firmware, not copied from one. The ThinkPad T495 still needs a run; the serial log now names what failed if the battery stays unknown.
  • The Windows/WSL suite (scripts/test.ps1, win-test.ps1) was not run; build-wintests.ps1 and win_checks.rs gained power.exe untested through those scripts (the same clang command was used on Linux).
  • The Windows expectations in shlpath.c follow the documentation; the test was not run on Windows.
  • Not done: key repeat settings, display brightness, keyboard layout identity for Windows programs (GetKeyboardLayout stays US), HID over I2C touch screens.
  • cargo clippy -D warnings has findings that predate this change (userspace/battery/src/model.rs, third_party/aml); the new code has none.

Labels

Labels: enhancement, drivers, desktop, kernel


Generated by Claude Code

The AML interpreter could not load or run tables written the way laptop
firmware is. A ThinkPad-style table lost every method of its battery device
at the first `Package (0x04) {}`, so OSyx showed no battery state; a
method that took a mutex failed at `Acquire`; fields were stored as
objects and read later from the wrong embedded controller page; a
`CreateQWordField` panicked the daemon.

third_party/aml (details in OSYX-CHANGES.md):
- packages with fewer initializers than elements, tables that keep loading
  after an object the interpreter cannot parse, device initialisation that
  goes on after a failing `_INI`
- `Acquire` time-out encoding, fields read as values when used, fields wider
  than 64 bits, fields at odd offsets, `IndexField` and `BankField`
- package arguments by reference, nested `Index` targets, implicit
  conversion on stores to named objects, `CondRefOf` with a target
- `RefOf`, `FindSetLeftBit`, `FindSetRightBit`, `Match`, `Timer`, `FromBCD`,
  `ToBCD`, `Load`, `LoadTable`, `Unload`
- no panics on buffer fields, `Fatal`, stale handles

batteryd:
- logs what a table lost while loading and which firmware method failed,
  with the interpreter's error, once per method
- publishes what each battery says about itself (/run/battery.info), the
  thermal zones' temperatures (/run/thermal) and the lid (/run/lid)
- stops re-reading the namespace after three scans without a battery device

Tests: firmware tables compiled by iasl, written in the style of three
firmware families, a secondary table and an operator conformance table;
scripts/acpi/qemu-battery.aml gives QEMU a battery through -acpitable.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wky8K22juFHFi5Lsqrq5dG
…er settings

USB HID devices with absolute X/Y were refused ("not a boot keyboard or
relative pointer"): QEMU's usb-tablet, the pointer VirtualBox and remote
consoles present, touch screens and pens. They are pointers now:

- osyx-usb: TabletLayout finds absolute X/Y, buttons, a wheel and a
  digitizer's tip switch in a report descriptor and scales positions to
  one range
- osyx-input: event kind ABSOLUTE (position across the whole screen)
- kernel: xHCI HID attaches such devices and reports their positions
- PRISM: maps positions to the screen

PRISM also takes pointer settings from /etc/osyx/pointer (speed, natural
scrolling, left-handed buttons) and follows that file and the keyboard
layout while it runs, so Settings can apply them without a new session.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wky8K22juFHFi5Lsqrq5dG
…olume options

Settings gains two sections and its Keyboard, Sound and Date & Time
sections more options. The five are built from one model (groups of rows:
facts, switches, choices, sliders, meters) that lays itself out and
scrolls with the wheel.

- Power: charge, state and time left, power draw, energy, health, voltage,
  the battery's model, maker, chemistry, serial number and charge cycles,
  the power adapter, the lid and the thermal zones, all as batteryd reads
  them from the firmware; whether the task bar shows the percentage, and
  the charge at which it warns (/etc/osyx/power)
- Mouse & Touchpad: pointer speed, left-handed buttons, natural scrolling
  (/etc/osyx/pointer, applied by PRISM within seconds)
- Keyboard: German (QWERTZ), United Kingdom and French (AZERTY) layouts
  beside US and Polish; a layout applies without a new session
- Sound: output volume and mute
- Date & Time: 22 time zones, 12- or 24-hour clock, seconds, date
  (/etc/osyx/clock)

Desktop: a notification when the battery reaches the low threshold and
another when it is almost empty, once per discharge; the task bar clock
and battery indicator follow the new options.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wky8K22juFHFi5Lsqrq5dG
…wapi helpers

Power: GetSystemPowerStatus reported "unknown" and CallNtPowerInformation
"AC power, no battery" on every machine. They now answer from the battery
batteryd reads: AC line, charge, flags and time left; SystemBatteryState
with capacities and the rate; SystemPowerCapabilities (also through the new
GetPwrCapabilities) with the lid, thermal control and batteries;
PowerDeterminePlatformRole(Ex) is mobile on a machine with a battery.

shlwapi: path predicates, path editing and string helpers in their wide and
ANSI forms (shlstr.rs), the ones ordinary programs and installers import:
PathIsRelative, PathAddBackslash, PathCanonicalize, PathQuoteSpaces,
StrCmpI, StrToIntEx, StrFormatByteSize and others. shlwapi coverage in the
parity scan goes from 3.9 % to 23.9 % (x64) and to 20.8 % for 32-bit
programs through the WoW64 bridge.

Tests: power.exe (new) checks the relations between the power calls with
and without a battery; shlpath.exe grows from 33 to 123 checks.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wky8K22juFHFi5Lsqrq5dG
A virtual machine with virtio input devices and no USB or PS/2 ones had no
keyboard or pointer. The kernel now attaches virtio-input devices
(1af4:1052): it reads the name, the event types and the absolute ranges
from the configuration space, keeps 64 event buffers on the event queue,
and one kernel thread collects the events of every device about 250 times
a second.

The events are Linux evdev events. osyx-input::evdev turns them into what
the input core takes (keys by HID usage, buttons, motion and positions
gathered until the synchronisation event, wheel detents) and is tested on
the host.

Checked in QEMU with virtio-keyboard-pci, virtio-tablet-pci and
virtio-mouse-pci as the only input devices: typing, clicking by position,
relative motion.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wky8K22juFHFi5Lsqrq5dG
…ut paths

- CI runs the osyx-battery, osyx-usb, osyx-i2c and osyx-i2chid host tests
  (the firmware tables compiled by iasl are checked in, so no ACPI
  compiler is needed there)
- docs: absolute pointers, virtio-input and the pointer and keyboard
  settings (graphics.md); the QEMU devices each input driver is checked
  with (testing.md); README lists the input drivers and the laptop support
- keyboard layouts and the power options without clippy findings; the AML
  interpreter loses the helpers the field rewrite left unused

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wky8K22juFHFi5Lsqrq5dG
@v3nn7 v3nn7 added enhancement New feature or request desktop Area: desktop kernel Area: kernel drivers Area: drivers labels Nov 10, 2026 — with Claude
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@codspeed

codspeed Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 36 untouched benchmarks


Comparing v3nn7/sweet-archimedes-d75mf2 (bc363b4) with main (248fa5b)

Open in CodSpeed

@v3nn7
v3nn7 marked this pull request as ready for review November 10, 2026 10:22
@v3nn7
v3nn7 merged commit 5453738 into main Nov 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Area: desktop drivers Area: drivers enhancement New feature or request kernel Area: kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants