garage44.eu/jeroen/pinnacle

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

cartopolis-agent · 2026-11-30T14:32:37Z

feat(kernel): Intel graphics, part 1: a write-combining screen and the backlight

The firmware's framebuffer was written through the direct map, which on
a PC is uncached there: a word at a time across the bus, slow on a real
laptop. IA32_PAT is now programmed on every core with entry 1
write-combining (Linux's layout; PWT alone in a page picks it), and the
lit screen gets a window of its own beside the direct map (4 KiB pages,
up to 32 MiB, in the image's directory-pointer table, which every
program's root shares). Scanout::copy and the boot log write through it
and end with an sfence. The boot log says, once, how long a whole frame
takes each way.

The panel's brightness: drivers/i915.rs claims Intel's GPU at 00:02.0
(vendor 8086, class 03:00), maps BAR0 and drives the chipset's backlight
PWM as the firmware left it on: Sunrise/Kaby Point's BLC_PWM_PCH_CTL1/2
(0xC8250/0xC8254, period and duty 16 bits each) and Cannon Point's on
(Coffee Lake to Alder Lake: control, period, duty at 0xC8250, +4, +8,
the controller that is on), the chipset told by the ISA bridge's ID at
00:1f.0 (Linux's intel_pch.c). Anything else, or a PWM left off, is
refused; drivers/backlight.rs then tries ACPI's _BCL/_BCM/_BQC on the
output device (the integrated panel's by _ADR). Never below 5 %.
System call 72, brightness(op, value), not for confined or sealed
programs; rt wrappers; Settings -> Screen gets a slider only where the
call answers; the level kept in /settings/brightness (pinnacle_ui::
brightness, as the volume) and set again by the display server at start.
No modesetting and no 3D: docs/hardware.md says so.

Tested: cargo xtask pc (selfcheck, "backlight: none to set", pc ok);
cargo xtask laptop passes, now also checking for the write-combining
line and "backlight: none to set" (QEMU's VGA is no Intel GPU; 1280x800
frame 13.8 ms write-combining vs 13.8 ms uncached under TCG, which models
no memory types: CPU-only numbers, no evidence either way); cargo xtask
build and clippy -D warnings for both ARM boards, programs, ui and rt;
cargo test -p pinnacle-locale. The backlight itself and the speed-up are
untried until a laptop.
abi/src/lib.rs                   |   7 ++
 docs/hardware.md                 |  24 ++++-
 docs/roadmap.md                  |   1 +
 kernel/src/drivers/backlight.rs  | 172 ++++++++++++++++++++++++++++++
 kernel/src/drivers/display.rs    |  26 +++++
 kernel/src/drivers/i915.rs       | 225 +++++++++++++++++++++++++++++++++++++++
 kernel/src/drivers/mod.rs        |   3 +
 kernel/src/drivers/scanout.rs    |  52 ++++++++-
 kernel/src/drivers/screen_log.rs |   9 +-
 kernel/src/main.rs               |   4 +
 kernel/src/syscall.rs            |   9 ++
 kernel/src/x86_64/mmu.rs         |  89 ++++++++++++++++
 kernel/src/x86_64/smp.rs         |   2 +
 locale/src/nl.rs                 |   3 +-
 programs/src/bin/display.rs      |   6 ++
 programs/src/bin/settings.rs     | 103 ++++++++++++++----
 rt/src/lib.rs                    |  15 +++
 ui/src/brightness.rs             |  21 ++++
 ui/src/lib.rs                    |   1 +
 xtask/src/install.rs             |   7 ++
 20 files changed, 748 insertions(+), 31 deletions(-)

diff --git a/abi/src/lib.rs b/abi/src/lib.rs
index 0cdb431..03dd9ea 100644
--- a/abi/src/lib.rs
+++ b/abi/src/lib.rs
@@ -305,6 +305,13 @@ pub mod call {
     /// programs.
     pub const POWER: u64 = 71;
 }
+    /// `brightness(op, value)`: the built-in screen's brightness, 0 to 100
+    /// (Intel's graphics, or the firmware's ACPI methods). Op 0 returns
+    /// it; op 1 sets it to `value` (never below 5, a black screen being
+    /// one nobody can turn back up) and returns it as it is then.
+    /// [`ERROR`](super::ERROR) when the screen has no brightness to set.
+    /// Not for confined or sealed programs.
+    pub const BRIGHTNESS: u64 = 72;
 
 /// Where the network is, as [`NET_SWITCH`](call::NET_SWITCH) answers.
 pub mod net {
diff --git a/docs/hardware.md b/docs/hardware.md
index 5aab394..d688605 100644
--- a/docs/hardware.md
+++ b/docs/hardware.md
@@ -110,7 +110,9 @@ run on a real machine yet.
 | Intel HDA sound (`drivers/hda.rs`) | the controller reset, its codecs found and spoken to through the command rings (CORB/RIRB; the immediate registers when those do not answer); the first codec with an analog output walked from the speaker's pin and the headphone jack's to a converter, through mixers and selectors, all powered, unmuted at 0 dB, EAPD on; one output stream of 10 ms periods from the kernel's mixer (48 kHz 16-bit stereo), its interrupt as each completes, the position from LPIB; the speaker off while headphones are in (the jack's unsolicited response) | PCI class 04:03 |
 | Intel Ethernet (`drivers/e1000.rs`) | the e1000e family: the 82574L, 82579, and the chipsets' I217, I218 and I219; one ring each way, its interrupt by MSI | PCI 8086, by ID |
 | The keyboard controller (`drivers/ps2.rs`, PC only) | a laptop's own keyboard (set 1, translated by the controller) and its touchpad as a PS/2 mouse, with a wheel where it says so; interrupts 1 and 12 through the I/O APIC | ports 0x60, 0x64 |
-| The firmware's screen (`board::pc`, `drivers::scanout`) | the framebuffer UEFI's GOP left lit, as the loader passes it on: 32-bit RGB either way round, or 16-bit 5-6-5; the boot log drawn on it (`drivers::screen_log`) until the display server takes it | Multiboot2's framebuffer tag |
+| The firmware's screen (`board::pc`, `drivers::scanout`) | the framebuffer UEFI's GOP left lit, as the loader passes it on: 32-bit RGB either way round, or 16-bit 5-6-5, in the mode the firmware set; written through a window of its own mapped write-combining (IA32_PAT's entry 1, as Linux has it; the direct map is uncached there), an `sfence` after each copy, and the boot log says how long a whole frame takes each way (`display: a whole frame … us write-combining, … us uncached`); the boot log drawn on it (`drivers::screen_log`) until the display server takes it | Multiboot2's framebuffer tag |
+| Intel graphics (`drivers/i915.rs`), Skylake (Gen9) to Alder Lake (Gen12) | the function at 00:02.0 claimed and its registers (BAR0) mapped; the panel's backlight through the chipset's PWM, as the firmware left it on: Sunrise and Kaby Point's BLC_PWM_PCH_CTL1/CTL2 (0xC8250, 0xC8254: period and duty cycle 16 bits each), Cannon Point's on (Coffee Lake to Alder and Raptor Lake) control, period and duty registers of their own (0xC8250, +4, +8; the controller the firmware left on), the chipset told by the ISA bridge's ID at 00:1f.0; never below 5 %; `brightness` system call (72), a slider in Settings → Screen, kept in `/settings/brightness` | PCI 8086, class 03:00 |
+| Brightness through ACPI (`drivers/backlight.rs`) | where Intel's PWM is not there or is off: the output device with `_BCM` and `_BCL` (the integrated panel's, its `_ADR`'s display type 4, if one says so), set to the least listed level at or above the share asked, read by `_BQC`. On most Intel laptops `_BCM` hands the level to a graphics driver through the OpRegion and an interrupt Pinnacle does not answer, so this works only where the firmware sets it itself (through the embedded controller) | `_BCM`, `_BCL` |
 | ACPI's power (`x86_64/acpi.rs`) | the FADT: ACPI mode on, off by `\_S5` (its sleep types read from the DSDT's package, not by running AML), restart by the reset register, the power button's fixed event on the SCI; general-purpose events on only for what answers them (the embedded controller's, the firmware's `_Lxx`/`_Exx` methods) | the FADT |
 | The firmware's AML (`aml/`, the crate `pinnacle-aml`; `x86_64/power.rs`) | the DSDT and every SSDT loaded and run by an interpreter of Pinnacle's own: devices, names, methods, operation regions and their fields (memory, I/O, PCI configuration, the embedded controller, CMOS), `_INI`, `_REG`, `_STA`, `_CRS` decoded (I/O, memory, interrupts, GPIO, I²C); a loop runs at most a million times, calls nest at most 64 deep, a device whose body fails loses itself only | the DSDT, SSDTs |
 | The embedded controller (`x86_64/power.rs`) | its two ports and GPE from AML (`PNP0C09`, `_CRS`, `_GPE`), reads and writes for AML's regions, its events (`_Qxx`) run in a kernel task when its GPE fires | `PNP0C09` |
@@ -134,8 +136,14 @@ controllers, `INT34xx`: an I²C touchpad is read every 8 ms instead of
 when its line says), a touchpad's precision mode (fingers, gestures,
 palm rejection: only its mouse report is read), I²C keyboards and touch
 screens, LPSS controllers firmware hides from PCI (its "ACPI mode"),
-Intel's Wi-Fi, a graphics driver (the
-screen stays at the firmware's mode, uncached, without brightness),
+Intel's Wi-Fi; of Intel's graphics all
+but the backlight: no modesetting (the screen stays in the mode the
+firmware set, and a panel whose native resolution needs more than the
+kernel's 16 MiB framebuffer is shown at the loader's smaller mode), no
+other outputs (HDMI, DisplayPort), no panel driven over DisplayPort's AUX
+channel (an OLED's brightness, many newer panels'), no power management
+of the display engine, and no 3D: acceleration on Intel (its command
+streamers, GuC firmware, a Vulkan driver) is a project of its own;
 recording through HDA, HDMI and DisplayPort audio, a codec's vendor-specific
 set-up (some laptops' speakers stay silent without Realtek's coefficients),
 Intel's audio DSP (class 04:01, the "SOF" mode, which some firmware choose
@@ -167,7 +175,11 @@ What that cannot show is what QEMU does not have: an I²C touchpad (QEMU
 has no DesignWare controller: the boot log says `i2c: 0 DesignWare
 controllers`; the protocol is tested against a fake touchpad, `cargo test
 -p pinnacle-hid`), Intel's
-Wi-Fi and graphics, an embedded controller, a laptop's own HDA codec (QEMU's has one
+Wi-Fi and graphics (QEMU's VGA is no Intel GPU: the backlight is untried,
+the boot log says `backlight: none to set` and Settings shows no
+brightness slider; the write-combining window is used, but a virtual
+machine's memory has no bus behind it, so its timings are the CPU's
+own), an embedded controller, a laptop's own HDA codec (QEMU's has one
 line out and no speaker, headphone jack or EAPD, so the jack's switching
 is untried), and every firmware's own mistakes. Those wait for a machine.
 
@@ -201,6 +213,10 @@ What to look for, line by line: `framebuffer:` (the firmware's screen),
 `apic: x2APIC mode` (with `xapic` on the command line as the fallback to
 try), `acpi: a laptop, in ACPI mode; off by \_S5 …; the power button
 heard`, `ps2: a keyboard and a mouse or touchpad` (absent: the keyboard is
+`display: a whole frame … us write-combining, … us uncached` (how much
+the write-combining window gains on this machine), `i915: Intel graphics
+…, backlight by the chipset's PWM …: N %` or why not, then
+`backlight: by ACPI …` or `backlight: none to set`,
 not on the controller, or the touchpad is I²C-only), `i2c: 2 DesignWare
 controllers` and `touchpad: ELAN0001 at 0x15 on \_SB.PC00.I2C1, HID
 04f3:3140, polled` (or why not: no controller of this kernel's, no
diff --git a/docs/roadmap.md b/docs/roadmap.md
index 7673eca..6ce66f1 100644
--- a/docs/roadmap.md
+++ b/docs/roadmap.md
@@ -72,6 +72,7 @@ What is still missing for daily use, and the projects it will take, is in
 | Real hardware, step 1: the screen a bootloader left lit, drawn on (`drivers::scanout`): a `simple-framebuffer` in the device tree, else on an RK3399 the VOP's first window read from its registers (only with its clocks on); the loader's reserved memory (the header's block, `/reserved-memory`) kept from the allocator; `cargo xtask test` boots once as such a loader leaves QEMU, `cargo xtask lit-shot` photographs that screen | Done in QEMU (which boards' loaders leave a lit screen needs a board: a Pinebook Pro's Tow-Boot leaves its panel lit) |
 | A PC's and a laptop's own hardware, on PCI (`hardware.md`): USB through an xHCI controller (`drivers/usb`), each device on a root port addressed and configured, plugged in and pulled out at any time, followed by a kernel task; keyboards by the boot protocol (keys as the virtio keyboard's), mice, tablets and touch screens by their report descriptors; sticks and disks by Bulk-Only Transport and SCSI. Disks behind NVMe (`nvme`) and AHCI (`ahci`, SATA), each a `Controller` under the block layer's cache as virtio-blk is; interrupts by MSI-X or MSI on a PC, INTx on ARM, every driver on a shared line asked. `cargo xtask test` and `pc` give QEMU all of them; the self-check writes a block on each disk and puts it back | Done in QEMU on both architectures (no isochronous transfers or USB 3 streams; one NVMe I/O queue; no SD/eMMC, which waits for the first device) |
 | An Intel laptop without trying one (`hardware.md`, "A laptop, without one"): the firmware's screen (GOP) drawn on, the boot log on it and a panic over it, the machine left on (a laptop has no serial port); x2APIC; the I/O APIC with the MADT's overrides; the keyboard controller's keyboard and touchpad (PS/2), a pointer the display server draws; ACPI's FADT: off by `\_S5`, restart by its reset register, the power button; USB hubs (USB 2 and 3, a translator's route for slower devices); Intel's e1000e Ethernet (82574L to I219); randomness from RDSEED/RDRAND; booted with no virtio device at all. `cargo xtask laptop`: the stick behind a hub installs on NVMe and turns off by ACPI, the disk starts, the password typed on PS/2, the power button turns it off | Done in QEMU (2026-11-29); not tried on a laptop. Not here: I²C-HID touchpads, Intel Wi-Fi and graphics, battery and lid (they need AML run), the I219's PHY waking from ULP |
+| Intel graphics, part 1 (`drivers/i915.rs`, `drivers/backlight.rs`, `hardware.md`), Skylake to Alder Lake: the firmware's framebuffer written through a write-combining window (IA32_PAT entry 1, 4 KiB pages beside the direct map, `sfence` after each copy) instead of uncached; the panel's backlight through the chipset's PWM (Sunrise/Kaby Point's and Cannon Point's on, told by the ISA bridge's ID), else ACPI's `_BCM`/`_BCL`/`_BQC`; never below 5 %; the `brightness` system call (72), a slider in Settings → Screen shown only where it answers, the level kept in `/settings/brightness` and set again at start | Started (2026-11-30): the window runs in QEMU (`cargo xtask laptop`); the backlight is untried, as QEMU has no Intel GPU. Not here: modesetting (native resolutions above the 16 MiB framebuffer, other outputs), panels set over DisplayPort AUX (OLEDs), the OpRegion (ASLE) many laptops' `_BCM` goes through, and 3D, a project of its own |
 | Intel HDA sound (`drivers/hda.rs`, `hardware.md`): the controller reset, CORB/RIRB (immediate registers as the fallback), codecs from STATESTS, the first with an analog output walked from its speaker pin (else line out) and headphone jack to a converter through mixers and selectors, powered, unmuted at 0 dB, EAPD on; one output stream of eight 10 ms periods fed by the kernel's mixer, as virtio-sound's are, an interrupt a period, the position by LPIB, stopped once nothing plays; the speaker off while headphones are in (unsolicited response); `cargo xtask laptop` hears the self-check's tone through QEMU's `ich9-intel-hda` | Done in QEMU (2026-11-30); not tried on a laptop. Not here: recording, HDMI/DP audio, vendor coefficient set-ups, Intel's DSP (SOF) mode, the jack's switching (QEMU's codec has none) |
 | A laptop's battery, charger and lid, from its firmware (`aml/`, `x86_64/power.rs`, `hardware.md`): an AML interpreter of Pinnacle's own (no ACPICA) loads the DSDT and SSDTs and runs their methods, bounded (a million loop rounds, 64 calls deep), a device that fails losing itself only; `_CRS` decoded, GPIO and I²C included; the embedded controller found from AML and driving its regions, its `_Qxx` events and the firmware's `_Lxx`/`_Exx` GPE methods run in a kernel task; `_BIX`/`_BIF`, `_BST`, `_PSR`, `_LID` asked live by the `power` system call (71); a lid or charger change an input event to the display server, which draws the battery in the status bar and locks when the lid closes. `cargo xtask laptop` gives QEMU a battery, charger and lid as an SSDT written with `pinnacle_aml::asm` | Done in QEMU (2026-11-30): QEMU's DSDT loads with no failure; no embedded controller tried (QEMU has none). Not here: sleep (S3, S0ix), battery warnings (`_BTP`), thermal zones and fans |
 | A laptop's touchpad on I²C (`hid/`, `drivers/i2c_dw.rs`, `drivers/i2c_hid.rs`, `hardware.md`): HID report descriptors and the pointer moved out of USB into the crate `pinnacle-hid`, shared by both; HID over I²C (Microsoft's 1.0) as a state machine over an `I2cBus` trait: the HID descriptor from the register `_DSM` names, SET_POWER ON, RESET and its empty answer, the report descriptor, the input register (a length, then a report), the mouse report a precision touchpad sends until told otherwise turned into pointer moves; Intel's LPSS DesignWare I²C controllers (8th to 13th generation) as polled masters, their timings from `FMCN`/`SSCN`; the touchpad found as `PNP0C50` in the AML, its controller by `_ADR`, read every 8 ms by a kernel task | Done in QEMU (2026-11-30) as far as QEMU goes: it has no DesignWare controller (`i2c: 0 DesignWare controllers`), so only the protocol is tested, against a fake ELAN touchpad; untried on a laptop. Not here: GPIO interrupts (the touchpad is polled), the precision touchpad's fingers and gestures, I²C keyboards and touch screens, LPSS in ACPI mode |
diff --git a/kernel/src/drivers/backlight.rs b/kernel/src/drivers/backlight.rs
new file mode 100644
index 0000000..785e02e
--- /dev/null
+++ b/kernel/src/drivers/backlight.rs
@@ -0,0 +1,172 @@
+//! The built-in screen's brightness, 0 to 100, as the `brightness` system
+//! call reads and sets it: through Intel's graphics (`i915`, the chipset's
+//! PWM) where it drives the panel, else through ACPI's methods on the
+//! integrated panel's output device (`_BCL`, `_BCM`, `_BQC`; ACPI 6.5,
+//! appendix B). None on a machine with neither, QEMU's among them.
+//!
+//! ACPI's way is the fallback: on most Intel laptops `_BCM` hands the
+//! level to the graphics driver through the firmware's OpRegion (ASLE)
+//! and an interrupt Pinnacle does not answer, so it changes nothing; on
+//! those whose firmware sets it through the embedded controller, it works.
+//!
+//! Never set below [`i915::MIN_LEVEL`]: a black screen is one nobody can
+//! turn back up.
+
+#[cfg(target_arch = "x86_64")]
+use super::i915::{self, MIN_LEVEL};
+use crate::sync::Mutex;
+#[cfg(target_arch = "x86_64")]
+use alloc::vec::Vec;
+#[cfg(target_arch = "x86_64")]
+use pinnacle_aml::{Path, Value};
+
+enum Control {
+    #[cfg(target_arch = "x86_64")]
+    Native(i915::Backlight),
+    #[cfg(target_arch = "x86_64")]
+    Acpi(Acpi),
+}
+
+/// A Mutex, not a spin lock: ACPI's methods may wait for the embedded
+/// controller.
+static CONTROL: Mutex<Option<Control>> = Mutex::new(None);
+
+/// Finds what sets the brightness, once, after PCI's scan and the
+/// firmware's AML are loaded (a PC's: an ARM board has neither yet). Says
+/// on the boot log what it found.
+#[cfg(target_arch = "x86_64")]
+pub fn init() {
+    let control = match i915::init() {
+        Some(native) => Some(Control::Native(native)),
+        None => Acpi::find().map(Control::Acpi),
+    };
+    if let Some(Control::Acpi(acpi)) = &control {
+        crate::println!(
+            "backlight: by ACPI, {} ({} levels up to {})",
+            acpi.device,
+            acpi.levels.len(),
+            acpi.levels.last().copied().unwrap_or(0)
+        );
+    }
+    if control.is_none() {
+        crate::println!("backlight: none to set");
+    }
+    *CONTROL.lock() = control;
+}
+
+/// The brightness, 0 to 100; None when the screen's cannot be set.
+pub fn level() -> Option<u8> {
+    match CONTROL.lock().as_mut()? {
+        #[cfg(target_arch = "x86_64")]
+        Control::Native(b) => Some(b.level()),
+        #[cfg(target_arch = "x86_64")]
+        Control::Acpi(a) => Some(a.level()),
+        #[allow(unreachable_patterns)]
+        _ => None,
+    }
+}
+
+/// Sets the brightness to `percent` (at least the least level, at most
+/// 100) and returns it as it is then; None when it cannot be set.
+pub fn set(percent: u8) -> Option<u8> {
+    let _ = percent;
+    match CONTROL.lock().as_mut()? {
+        #[cfg(target_arch = "x86_64")]
+        Control::Native(b) => Some(b.set(percent)),
+        #[cfg(target_arch = "x86_64")]
+        Control::Acpi(a) => a.set(percent),
+        #[allow(unreachable_patterns)]
+        _ => None,
+    }
+}
+
+/// The integrated panel's output device in ACPI: the levels its `_BCL`
+/// lists, set by `_BCM`, read by `_BQC` where it has one.
+#[cfg(target_arch = "x86_64")]
+struct Acpi {
+    device: Path,
+    /// The levels it takes, ascending, none of them 0.
+    levels: Vec<u64>,
+    /// What was last set (a percent), for a device without `_BQC`.
+    last: u8,
+}
+
+#[cfg(target_arch = "x86_64")]
+impl Acpi {
+    /// The output device with `_BCM` and `_BCL`: the integrated flat
+    /// panel's (its `_ADR`'s display type, bits 8 to 11, 4) if one says so,
+    /// else the first.
+    fn find() -> Option<Acpi> {
+        crate::power::with_namespace(|ns, host| {
+            let has = |ns: &pinnacle_aml::Namespace, d: &Path, m: &[u8; 4]| ns.get(&d.child(*m)).is_some();
+            let mut found: Vec<(Path, bool)> = Vec::new();
+            for d in ns.devices() {
+                if !(has(ns, &d, b"_BCM") && has(ns, &d, b"_BCL")) {
+                    continue;
+                }
+                let panel = match ns.evaluate_if(&d.child(*b"_ADR"), Vec::new(), host) {
+                    Some(Ok(v)) => v.integer().is_some_and(|a| a >> 8 & 0xf == 4),
+                    _ => false,
+                };
+                found.push((d, panel));
+            }
+            let device = found
+                .iter()
+                .find(|(_, panel)| *panel)
+                .or(found.first())
+                .map(|(d, _)| d.clone())?;
+            let bcl = ns.evaluate(&device.child(*b"_BCL"), Vec::new(), host).ok()?;
+            let list = bcl.package()?;
+            // The first two are the levels on mains and on battery; the
+            // rest are the levels it takes.
+            let mut levels: Vec<u64> = list
+                .iter()
+                .skip(2)
+                .filter_map(Value::integer)
+                .filter(|&l| l > 0)
+                .collect();
+            levels.sort_unstable();
+            levels.dedup();
+            let full = list.first().and_then(Value::integer)?;
+            let max = *levels.last()?;
+            Some(Acpi {
+                device,
+                levels,
+                last: (full.min(max) * 100 / max) as u8,
+            })
+        })?
+    }
+
+    fn level(&mut self) -> u8 {
+        let max = self.levels.last().copied().unwrap_or(1).max(1);
+        let path = self.device.child(*b"_BQC");
+        let now = crate::power::with_namespace(|ns, host| match ns.evaluate_if(&path, Vec::new(), host) {
+            Some(Ok(v)) => v.integer(),
+            _ => None,
+        })
+        .flatten();
+        match now {
+            Some(v) => (v.min(max) * 100 / max) as u8,
+            None => self.last,
+        }
+    }
+
+    /// Sets the level `percent` asks for: the least listed level at or
+    /// above that share of the most, never below [`MIN_LEVEL`]'s.
+    fn set(&mut self, percent: u8) -> Option<u8> {
+        let percent = percent.clamp(MIN_LEVEL, 100);
+        let max = *self.levels.last()?;
+        let wanted = (max * u64::from(percent)).div_ceil(100);
+        let level = self.levels.iter().copied().find(|&l| l >= wanted).unwrap_or(max);
+        let path = self.device.child(*b"_BCM");
+        let done = crate::power::with_namespace(|ns, host| {
+            ns.evaluate(&path, alloc::vec![Value::Integer(level)], host)
+                .is_ok()
+        })?;
+        if !done {
+            return None;
+        }
+        self.last = (level * 100 / max) as u8;
+        Some(self.level())
+    }
+}
diff --git a/kernel/src/drivers/display.rs b/kernel/src/drivers/display.rs
index 2c1ed64..7f3081e 100644
--- a/kernel/src/drivers/display.rs
+++ b/kernel/src/drivers/display.rs
@@ -147,6 +147,8 @@ pub fn init(width: u32, height: u32) -> bool {
         // SAFETY: the new framebuffer, width × height pixels, zeroed.
         let pixels =
             unsafe { core::slice::from_raw_parts(memory.address as *const u32, (width * height) as usize) };
+        #[cfg(target_arch = "x86_64")]
+        time_full_frame(&lit, pixels);
         lit.copy(pixels, 0, 0, width as i32, height as i32);
         true
     } else if gpu::present() {
@@ -167,6 +169,30 @@ pub fn init(width: u32, height: u32) -> bool {
     true
 }
 
+/// Says on the boot log, once, how long a whole frame takes to reach a lit
+/// screen through its write-combining window and through the direct map
+/// (uncached), each copied once: the numbers a laptop's photograph of its
+/// boot log brings back. In a virtual machine both are the CPU's own time,
+/// as memory there has no bus behind it.
+#[cfg(target_arch = "x86_64")]
+fn time_full_frame(lit: &scanout::Scanout, pixels: &[u32]) {
+    static TOLD: core::sync::atomic::AtomicBool = core::sync::atomic::AtomicBool::new(false);
+    if !lit.write_combining() || TOLD.swap(true, Ordering::Relaxed) {
+        return;
+    }
+    let (w, h) = (lit.width as i32, lit.height as i32);
+    let micros = |copy: &dyn Fn()| {
+        let start = crate::arch::tsc();
+        copy();
+        (crate::arch::tsc() - start) * 1_000_000 / crate::timer::frequency().max(1)
+    };
+    let uncached = micros(&|| lit.copy_uncached(pixels, 0, 0, w, h));
+    let combined = micros(&|| lit.copy(pixels, 0, 0, w, h));
+    crate::println!(
+        "display: a whole frame ({w}x{h}) to the screen in {combined} us write-combining, {uncached} us uncached"
+    );
+}
+
 /// Sends the rectangle of the framebuffer to the screen, where the driver
 /// needs telling (the gpu) or the screen is memory of its own (a lit
 /// screen); a ramfb shows it already.
diff --git a/kernel/src/drivers/i915.rs b/kernel/src/drivers/i915.rs
new file mode 100644
index 0000000..3985bf9
--- /dev/null
+++ b/kernel/src/drivers/i915.rs
@@ -0,0 +1,225 @@
+//! Intel's integrated graphics, Skylake (Gen9) to Alder Lake (Gen12, Xe),
+//! as far as Pinnacle goes so far: the panel's backlight. The screen stays
+//! in the mode the firmware (UEFI's GOP) set, drawn through `scanout`; there
+//! is no modesetting and no 3D (a project of its own).
+//!
+//! The function is the one at 00:02.0 (vendor 8086, display class); its
+//! first window, BAR0 (GTTMMADR), holds the registers. An embedded panel's
+//! backlight on these machines is a PWM in the south display engine, in
+//! the chipset (the PCH), which the firmware leaves on at the level it
+//! chose. Two layouts, as Linux's `intel_backlight.c` drives them:
+//!
+//! - Sunrise Point and Kaby Point (Skylake, Kaby Lake; Comet Lake V):
+//!   BLC_PWM_PCH_CTL1 at 0xC8250 (bit 31 on, bit 29 inverted) and
+//!   BLC_PWM_PCH_CTL2 at 0xC8254, the period in its high 16 bits and the
+//!   duty cycle in its low 16 (Linux's `spt_` functions).
+//! - Cannon Point on (Coffee and Comet Lake, Ice Lake, Tiger Lake, Jasper
+//!   Lake, Alder and Raptor Lake): two controllers, each its control at
+//!   0xC8250 + 0x100·n (bits as above), its period at +4 and its duty
+//!   cycle at +8, 32 bits each (Linux's `cnp_` functions; which one the
+//!   panel uses the video BIOS table says, which Pinnacle does not read:
+//!   the one the firmware left on).
+//!
+//! Which chipset it is the ISA bridge at 00:1f.0 says, by its device ID
+//! (Linux's `intel_pch.c`, the ID masked with 0xff80). Any other (an Atom's
+//! Gemini Lake, which has no PCH; Meteor Lake on) is refused, and so is a
+//! PWM the firmware left off: many panels (OLED among them) take their
+//! level over the DisplayPort AUX channel instead, which needs a driver
+//! for the display engine. `backlight` then asks ACPI.
+
+use crate::pci::Function;
+
+/// Which layout the chipset's backlight PWM has.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+enum Layout {
+    /// One controller; period and duty cycle in one register, 16 bits each.
+    Spt,
+    /// Controller `n`; period and duty cycle in registers of their own.
+    Cnp(usize),
+}
+
+/// The PWM's registers, as offsets into BAR0.
+const PCH_CTL1: usize = 0xc8250;
+const PCH_CTL2: usize = 0xc8254;
+const PWM_ENABLE: u32 = 1 << 31;
+const PWM_INVERTED: u32 = 1 << 29;
+
+/// The chipsets whose backlight PWM is laid out as Sunrise Point's
+/// (Skylake's), by the ISA bridge's device ID masked with 0xff80: SPT,
+/// SPT-LP, KBP, CMP-V.
+const SPT: &[u16] = &[0xa100, 0x9d00, 0xa280, 0xa380];
+
+/// Those laid out as Cannon Point's: CNP, CNP-LP, CMP, CMP2, ICP, ICP2,
+/// MCC, TGP, TGP2, JSP, ADP, ADP2, ADP3, ADP4.
+const CNP: &[u16] = &[
+    0xa300, 0x9d80, 0x0280, 0x0680, 0x3480, 0x3880, 0x4b00, 0xa080, 0x4380, 0x4d80, 0x7a80, 0x5180, 0x7a00,
+    0x5480,
+];
+
+/// The layout a chipset's ISA bridge (its device ID) says, if Pinnacle
+/// knows it.
+fn layout_of(bridge: u16) -> Option<Layout> {
+    let id = bridge & 0xff80;
+    if SPT.contains(&id) {
+        Some(Layout::Spt)
+    } else if CNP.contains(&id) {
+        Some(Layout::Cnp(0))
+    } else {
+        None
+    }
+}
+
+/// The panel's backlight, through the chipset's PWM.
+pub struct Backlight {
+    /// BAR0, as the kernel maps it (uncached).
+    regs: usize,
+    layout: Layout,
+}
+
+impl Backlight {
+    fn read(&self, offset: usize) -> u32 {
+        // SAFETY: a register inside BAR0 (16 MiB on every generation here).
+        unsafe { ((self.regs + offset) as *const u32).read_volatile() }
+    }
+
+    fn write(&self, offset: usize, value: u32) {
+        // SAFETY: as in `read`.
+        unsafe { ((self.regs + offset) as *mut u32).write_volatile(value) }
+    }
+
+    fn control(&self) -> u32 {
+        match self.layout {
+            Layout::Spt => self.read(PCH_CTL1),
+            Layout::Cnp(n) => self.read(PCH_CTL1 + 0x100 * n),
+        }
+    }
+
+    /// The period and the duty cycle as the registers hold them.
+    fn pwm(&self) -> (u32, u32) {
+        match self.layout {
+            Layout::Spt => {
+                let ctl2 = self.read(PCH_CTL2);
+                (ctl2 >> 16, ctl2 & 0xffff)
+            }
+            Layout::Cnp(n) => (
+                self.read(PCH_CTL1 + 0x100 * n + 4),
+                self.read(PCH_CTL1 + 0x100 * n + 8),
+            ),
+        }
+    }
+
+    /// Whether the firmware left the PWM on, with a period.
+    fn on(&self) -> bool {
+        self.control() & PWM_ENABLE != 0 && self.pwm().0 != 0
+    }
+
+    /// The level, 0 to 100, as the PWM is now.
+    pub fn level(&self) -> u8 {
+        let (period, duty) = self.pwm();
+        let duty = if self.control() & PWM_INVERTED != 0 {
+            period.saturating_sub(duty)
+        } else {
+            duty
+        };
+        level_of(period, duty)
+    }
+
+    /// Sets the level to `percent`, at least [`MIN_LEVEL`], and returns it.
+    pub fn set(&self, percent: u8) -> u8 {
+        let (period, _) = self.pwm();
+        let mut duty = duty_of(period, percent);
+        if self.control() & PWM_INVERTED != 0 {
+            duty = period - duty;
+        }
+        match self.layout {
+            Layout::Spt => self.write(PCH_CTL2, period << 16 | duty),
+            Layout::Cnp(n) => self.write(PCH_CTL1 + 0x100 * n + 8, duty),
+        }
+        self.level()
+    }
+}
+
+/// The least level a panel is set to: 0 would leave the screen black,
+/// with nothing on it to turn it back up by.
+pub const MIN_LEVEL: u8 = 5;
+
+/// A duty cycle as a level, 0 to 100, rounded.
+fn level_of(period: u32, duty: u32) -> u8 {
+    if period == 0 {
+        return 0;
+    }
+    ((u64::from(duty.min(period)) * 100 + u64::from(period) / 2) / u64::from(period)) as u8
+}
+
+/// The duty cycle for `percent` (at least [`MIN_LEVEL`], at most 100) of
+/// `period`, never 0.
+fn duty_of(period: u32, percent: u8) -> u32 {
+    let percent = u64::from(percent.clamp(MIN_LEVEL, 100));
+    ((u64::from(period) * percent).div_ceil(100) as u32).clamp(1.min(period), period)
+}
+
+/// The integrated graphics, if there is one: claimed, its registers'
+/// window on, and its backlight if the chipset is one Pinnacle knows and
+/// the firmware left the PWM on. Says on the boot log what it found.
+pub fn init() -> Option<Backlight> {
+    let gpu = crate::pci::find_class(0x030000)
+        .into_iter()
+        .chain(crate::pci::find_class(0x038000))
+        .find(|f| f.vendor == 0x8086 && (f.bus, f.device, f.function) == (0, 2, 0))?;
+    let bridge = crate::pci::find_class(0x060100)
+        .into_iter()
+        .find(|f| f.vendor == 0x8086 && (f.bus, f.device) == (0, 0x1f));
+    crate::pci::claim(&gpu, "intel-graphics", crate::device::Class::Display);
+    let Some(regs) = gpu.bar_address(0, 0) else {
+        crate::println!(
+            "i915: Intel graphics {:04x}, without its registers' window",
+            gpu.id
+        );
+        return None;
+    };
+    memory_on(&gpu);
+    let Some(layout) = bridge.as_ref().and_then(|b| layout_of(b.id)) else {
+        crate::println!(
+            "i915: Intel graphics {:04x}, chipset {}: its backlight not one Pinnacle knows",
+            gpu.id,
+            bridge.map_or(alloc::string::String::from("unknown"), |b| alloc::format!(
+                "{:04x}", b.id
+            ))
+        );
+        return None;
+    };
+    // The controller the firmware left on: the panel's.
+    let candidates: &[Layout] = match layout {
+        Layout::Spt => &[Layout::Spt],
+        Layout::Cnp(_) => &[Layout::Cnp(0), Layout::Cnp(1)],
+    };
+    let found = candidates
+        .iter()
+        .map(|&layout| Backlight { regs, layout })
+        .find(Backlight::on);
+    let Some(backlight) = found else {
+        crate::println!(
+            "i915: Intel graphics {:04x}: the backlight's PWM is off (a panel set over DisplayPort AUX?)",
+            gpu.id
+        );
+        return None;
+    };
+    let (period, duty) = backlight.pwm();
+    crate::println!(
+        "i915: Intel graphics {:04x}, backlight by the chipset's PWM ({:?}, period {period}, duty {duty}): {} %",
+        gpu.id,
+        backlight.layout,
+        backlight.level()
+    );
+    Some(backlight)
+}
+
+/// Its memory decoding on (the firmware's GOP has left it so; a firmware
+/// that did not would have no screen).
+fn memory_on(f: &Function) {
+    const MEMORY: u16 = 1 << 1;
+    let command = f.read16(0x04);
+    if command & MEMORY == 0 {
+        f.write16(0x04, command | MEMORY);
+    }
+}
diff --git a/kernel/src/drivers/mod.rs b/kernel/src/drivers/mod.rs
index 9ca3e3a..7059b01 100644
--- a/kernel/src/drivers/mod.rs
+++ b/kernel/src/drivers/mod.rs
@@ -5,6 +5,7 @@
 
 pub mod ahci;
 pub mod block;
+pub mod backlight;
 pub mod display;
 pub mod e1000;
 pub mod gpu;
@@ -15,6 +16,8 @@ pub mod i2c_dw;
 #[cfg(target_arch = "x86_64")]
 pub mod i2c_hid;
 pub mod input;
+#[cfg(target_arch = "x86_64")]
+pub mod i915;
 pub mod net;
 pub mod nvme;
 #[cfg(target_arch = "x86_64")]
diff --git a/kernel/src/drivers/scanout.rs b/kernel/src/drivers/scanout.rs
index f34956f..81c075e 100644
--- a/kernel/src/drivers/scanout.rs
+++ b/kernel/src/drivers/scanout.rs
@@ -13,6 +13,7 @@
 //! which the controller does not see.
 
 use crate::sync::SpinLock;
+use core::sync::atomic::{AtomicUsize, Ordering};
 
 /// How the screen's memory holds a pixel.
 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
@@ -87,10 +88,37 @@ impl Scanout {
             && inside
     }
 
+    /// The kernel's address of its first pixel: on a PC the write-combining
+    /// window [`find`] made, else (or without one) the direct map.
+    pub fn base(&self) -> usize {
+        match WINDOW.load(Ordering::Relaxed) {
+            0 => crate::mmu::virt(self.address),
+            window => window,
+        }
+    }
+
+    /// Whether the screen is written through a write-combining window.
+    #[cfg(target_arch = "x86_64")]
+    pub fn write_combining(&self) -> bool {
+        WINDOW.load(Ordering::Relaxed) != 0
+    }
+
     /// Copies the rectangle at `x`, `y` of `pixels` (the kernel's
     /// framebuffer, `self.width` wide) onto the screen, and cleans it to
-    /// the point of coherency, where the display controller reads.
+    /// the point of coherency, where the display controller reads (on a
+    /// PC, drains the write-combining buffers).
     pub fn copy(&self, pixels: &[u32], x: i32, y: i32, width: i32, height: i32) {
+        self.copy_at(self.base(), pixels, x, y, width, height);
+    }
+
+    /// As [`copy`](Self::copy), through the direct map, as before there was
+    /// a window: uncached on a PC. For the boot log's comparison only.
+    #[cfg(target_arch = "x86_64")]
+    pub fn copy_uncached(&self, pixels: &[u32], x: i32, y: i32, width: i32, height: i32) {
+        self.copy_at(crate::mmu::virt(self.address), pixels, x, y, width, height);
+    }
+
+    fn copy_at(&self, base: usize, pixels: &[u32], x: i32, y: i32, width: i32, height: i32) {
         let x0 = x.clamp(0, self.width as i32) as usize;
         let y0 = y.clamp(0, self.height as i32) as usize;
         let x1 = (x.saturating_add(width)).clamp(0, self.width as i32) as usize;
@@ -98,13 +126,13 @@ impl Scanout {
         if x0 >= x1 || y0 >= y1 {
             return;
         }
-        let base = crate::mmu::virt(self.address);
         let bytes = self.format.bytes() as usize;
         for row in y0..y1 {
             let from = &pixels[row * self.width as usize + x0..row * self.width as usize + x1];
             let at = base + row * self.stride as usize + x0 * bytes;
             // SAFETY: inside the screen's memory (checked by `sane`), which
-            // the page allocator never hands out; mapped Normal.
+            // the page allocator never hands out; mapped Normal, or (a PC)
+            // write-combining in the window, uncached in the direct map.
             unsafe {
                 match self.format.bytes() {
                     4 => {
@@ -128,9 +156,17 @@ impl Scanout {
         unsafe {
             core::arch::asm!("dsb sy", options(nostack))
         };
+        #[cfg(target_arch = "x86_64")]
+        crate::mmu::flush_write_combining();
     }
 }
 
+/// The kernel's address of the screen's first pixel in a write-combining
+/// window of its own (a PC), or 0: the direct map, which on a PC is
+/// uncached there (the firmware's MTRRs call a graphics card's window so,
+/// or the page tables do), and so a word at a time across the bus.
+static WINDOW: AtomicUsize = AtomicUsize::new(0);
+
 /// Writes the cache lines over `len` bytes at `at` back to memory, where a
 /// device that does not snoop the caches reads them.
 fn clean(at: usize, len: usize) {
@@ -196,6 +232,16 @@ pub fn find(device_tree: usize) {
         );
         return;
     }
+    // On a PC, a window of its own, write-combining: the direct map is
+    // uncached there, which a laptop's panel draws a frame through in a
+    // good part of a second.
+    #[cfg(target_arch = "x86_64")]
+    {
+        let (start, end) = scanout.range();
+        if let Some(window) = crate::mmu::map_write_combining(start, end - start) {
+            WINDOW.store(window, Ordering::Relaxed);
+        }
+    }
     *FOUND.lock() = Some(scanout);
 }
 
diff --git a/kernel/src/drivers/screen_log.rs b/kernel/src/drivers/screen_log.rs
index c7e98db..b70f27c 100644
--- a/kernel/src/drivers/screen_log.rs
+++ b/kernel/src/drivers/screen_log.rs
@@ -7,7 +7,8 @@
 //!
 //! Lines are drawn down the screen and start again at the top when they
 //! reach the bottom, the line below the newest cleared: no scrolling, which
-//! would redraw the whole screen a line, through memory that is uncached.
+//! would redraw the whole screen a line, through memory that is uncached
+//! (on a PC, write-combining: faster, and still not cached for reading).
 //! `quiet` on the command line leaves the screen alone.
 
 use super::scanout::Scanout;
@@ -64,9 +65,7 @@ impl Log {
     }
 
     fn pixel(screen: &Scanout, x: usize, y: usize, colour: u32) {
-        let at = crate::mmu::virt(screen.address)
-            + y * screen.stride as usize
-            + x * screen.format.bytes() as usize;
+        let at = screen.base() + y * screen.stride as usize + x * screen.format.bytes() as usize;
         // SAFETY: inside the screen's memory (callers keep x, y on it),
         // which the allocator never hands out.
         unsafe {
@@ -129,6 +128,8 @@ impl Log {
                 }
             }
         }
+        #[cfg(target_arch = "x86_64")]
+        crate::mmu::flush_write_combining();
     }
 }
 
diff --git a/kernel/src/main.rs b/kernel/src/main.rs
index 86244a2..06de0e3 100644
--- a/kernel/src/main.rs
+++ b/kernel/src/main.rs
@@ -85,6 +85,8 @@ extern "C" fn kmain(start_info: usize, magic: u32) -> ! {
         boot.protocol
     );
     let mapped = mmu::map_above_4gib(|start, end| boot.ram().iter().any(|r| r.start < end && r.end > start));
+    // Write-combining as one of the page types, for the screen.
+    mmu::set_pat();
     // The screen the firmware lit, before the allocator, which must not
     // hand out its memory (outside the RAM map, so it does not).
     if let Some(fb) = boot.framebuffer {
@@ -172,6 +174,8 @@ extern "C" fn kmain(start_info: usize, magic: u32) -> ! {
     }
     // The firmware's AML: the embedded controller, battery, charger, lid.
     power::init(boot.rsdp);
+    // The panel's brightness: Intel's graphics, else the firmware's methods.
+    drivers::backlight::init();
     // A touchpad on I²C, found through the AML; read by a task of its own,
     // started beside `power::watch`.
     drivers::i2c_hid::init();
diff --git a/kernel/src/syscall.rs b/kernel/src/syscall.rs
index b2c9f19..77a81e9 100644
--- a/kernel/src/syscall.rs
+++ b/kernel/src/syscall.rs
@@ -333,6 +333,15 @@ fn handle_call(frame: *mut Frame) -> *mut Frame {
         call::KILL_ID => kill_id(a[0]),
         call::LOG => {
             let mut kept = Vec::with_capacity(crate::console::KEPT);
+        call::BRIGHTNESS if confined() => FAILED,
+        call::BRIGHTNESS => {
+            let level = match a[0] {
+                0 => crate::drivers::backlight::level(),
+                1 => crate::drivers::backlight::set(a[1].min(100) as u8),
+                _ => None,
+            };
+            level.map_or(FAILED, |l| (u64::from(l), 0, 0))
+        }
             crate::console::CONSOLE.lock().kept(&mut kept);
             // The newest part, when the buffer is smaller.
             let from = kept.len().saturating_sub(a[1] as usize);
diff --git a/kernel/src/x86_64/mmu.rs b/kernel/src/x86_64/mmu.rs
index f6dcf96..453464e 100644
--- a/kernel/src/x86_64/mmu.rs
+++ b/kernel/src/x86_64/mmu.rs
@@ -106,6 +106,95 @@ fn map_gibs(ram: impl Fn(u64, u64) -> bool) -> usize {
     gib
 }
 
+/// IA32_PAT as every core has it: the power-on layout but for entry 1,
+/// write-combining (WC) instead of write-through, as Linux has it. A page
+/// with PWT alone (and neither PCD nor PAT) is WC; WB, UC- and UC stay
+/// where page tables already name them (none, PCD, PWT | PCD).
+const PAT: u64 = 0x0007_0406_0007_0106;
+
+/// The page bits that pick [`PAT`]'s entry 1, write-combining.
+const WRITE_COMBINING: u64 = 0x08;
+
+/// Programs IA32_PAT (MSR 0x277) with [`PAT`] on this core: on each core,
+/// before it touches a write-combining page, as the cores must agree.
+/// Nothing maps a page WC before the first core has done it, so no cache
+/// or TLB holds a line of the old type.
+pub fn set_pat() {
+    // CPUID 1, EDX bit 16: PAT (every x86-64 core so far).
+    if crate::arch::cpuid(1)[3] & (1 << 16) != 0 {
+        crate::arch::write_msr(0x277, PAT);
+        set_cr3(cr3());
+    }
+}
+
+/// The most a write-combining window maps: a 4K panel's framebuffer and
+/// then some, in 4 KiB pages.
+const WINDOW_TABLES: usize = 16;
+
+/// A window's tables: a directory for its GiB and the page tables under it,
+/// in `.bss` (the window is made before the allocator runs).
+#[repr(C, align(4096))]
+struct Window {
+    directory: Table,
+    pages: [Table; WINDOW_TABLES],
+}
+
+static WINDOW: crate::sync::Global<Window> = crate::sync::Global::new(Window {
+    directory: Table([0; 512]),
+    pages: [const { Table([0; 512]) }; WINDOW_TABLES],
+});
+
+/// Where the window starts: the GiB below the image's, in the image's
+/// directory-pointer table (root entry 511), which every program's root
+/// shares, so the window is everywhere at once.
+const WINDOW_AT: usize = IMAGE_OFFSET - (1 << 30);
+
+/// Maps `len` bytes of the physical address space from `start` (a device's
+/// memory: a framebuffer) write-combining, in 4 KiB pages, beside the
+/// direct map, and returns the kernel's address of `start`. Writes to it
+/// gather in the core's write-combining buffers and go out as bursts,
+/// where the direct map's uncached ones go a word at a time; a reader
+/// (the display controller) sees them after an `sfence`. Once, on the first
+/// core before any other runs; None when it is larger than the window
+/// (`WINDOW_TABLES` × 2 MiB) or a window is already made.
+pub fn map_write_combining(start: usize, len: usize) -> Option<usize> {
+    const PRESENT_WRITABLE: u64 = 0x03;
+    const NO_EXECUTE: u64 = 1 << 63;
+    let first = start & !0xfff;
+    let pages = (start + len).div_ceil(4096) - first / 4096;
+    if len == 0 || pages > WINDOW_TABLES * 512 {
+        return None;
+    }
+    let root = virt((cr3_kernel() & !0xfff) as usize) as *const u64;
+    // SAFETY: the root's last entry, the image's, present since boot.
+    let pdpt = unsafe { root.add(511).read() } & 0x000f_ffff_ffff_f000;
+    let slot = (virt(pdpt as usize) as *mut u64).wrapping_add(WINDOW_AT >> 30 & 511);
+    // SAFETY: an entry of boot's table, mapped; an empty one is free.
+    if unsafe { slot.read_volatile() } != 0 {
+        return None;
+    }
+    // SAFETY: only the first core runs, once (the slot was empty).
+    let window = unsafe { WINDOW.get() };
+    for page in 0..pages {
+        window.pages[page / 512].0[page % 512] =
+            (first + page * 4096) as u64 | PRESENT_WRITABLE | WRITE_COMBINING | NO_EXECUTE;
+    }
+    for t in 0..pages.div_ceil(512) {
+        window.directory.0[t] = physical(window.pages[t].0.as_ptr() as usize) as u64 | PRESENT_WRITABLE;
+    }
+    let directory = physical(window.directory.0.as_ptr() as usize) as u64;
+    // SAFETY: the free entry found above; nothing has a TLB entry for it.
+    unsafe { slot.write_volatile(directory | PRESENT_WRITABLE) };
+    Some(WINDOW_AT + (start - first))
+}
+
+/// Makes writes to write-combining memory visible to the device that
+/// reads it: what sits in the core's write-combining buffers goes out.
+pub fn flush_write_combining() {
+    // SAFETY: a store fence; it changes no data.
+    unsafe { core::arch::asm!("sfence", options(nostack, preserves_flags)) };
+}
+
 /// The direct map: physical address 0 is here (PML4 entry 256).
 pub const KERNEL_OFFSET: usize = 0xffff_8000_0000_0000;
 /// The image: physical 0 is here too, for its first GiB (PML4 entry 511).
diff --git a/kernel/src/x86_64/smp.rs b/kernel/src/x86_64/smp.rs
index 2586674..6092932 100644
--- a/kernel/src/x86_64/smp.rs
+++ b/kernel/src/x86_64/smp.rs
@@ -214,6 +214,8 @@ pub fn online() -> u64 {
 /// interrupt table, its APIC and its timer, says it runs, and idles.
 extern "C" fn secondary_main(core: usize) -> ! {
     set_core(core);
+    // The page types as the boot core has them, before this core draws.
+    crate::mmu::set_pat();
     crate::arch::enable_sse();
     crate::gdt::load(core);
     crate::exceptions::init();
diff --git a/locale/src/nl.rs b/locale/src/nl.rs
index 187226d..338a94b 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); 416] = [
+pub static TEXTS: [(&str, &str); 417] = [
     ("+  New note", "+  Nieuwe notitie"),
     (", kept", ", bewaard"),
     ("1 note", "1 notitie"),
@@ -30,6 +30,7 @@ pub static TEXTS: [(&str, &str); 416] = [
     ("At least eight characters. It opens your data and unlocks the screen.", "Minstens acht tekens. Het opent je gegevens en ontgrendelt het scherm."),
     ("Back", "Terug"),
     ("Bluetooth", "Bluetooth"),
+    ("Brightness", "Helderheid"),
     ("Brush size {}", "Lijndikte {}"),
     ("Busy", "In gesprek"),
     ("Calculator", "Rekenmachine"),
diff --git a/programs/src/bin/display.rs b/programs/src/bin/display.rs
index 5c736c3..a220839 100644
--- a/programs/src/bin/display.rs
+++ b/programs/src/bin/display.rs
@@ -1938,6 +1938,12 @@ fn main(_argument: u64) -> u64 {
     {
         println!("display: volume {volume} %");
     }
+    // And the screen's brightness, where it has one to set.
+    if let Some(level) = pinnacle_ui::brightness::kept()
+        && let Some(set) = pinnacle_rt::set_brightness(level)
+    {
+        println!("display: brightness {set} %");
+    }
     server.canvas().fill(theme::BACKGROUND);
     flush(Rect::new(0, 0, server.width, server.height));
     server.draw_status();
diff --git a/programs/src/bin/settings.rs b/programs/src/bin/settings.rs
index 7b9040e..759ba0a 100644
--- a/programs/src/bin/settings.rs
+++ b/programs/src/bin/settings.rs
@@ -1,5 +1,6 @@
 //! Settings: this device's name, its screen (turned from here as by its
-//! orientation sensor), the sound's volume (a slider the mixer follows), its screen lock (the password that also opens the data), the network, its
+//! orientation sensor) and its brightness (a slider, where the kernel can
+//! set it: a laptop's panel), the sound's volume (a slider the mixer follows), its screen lock (the password that also opens the data), the network, its
 //! disks and its system, and on pages of their own the network (online or
 //! not, over which connection, and its switch), the hardware the
 //! kernel found and which driver took each, which contacts may run
@@ -121,6 +122,8 @@ enum Action {
     Reader,
     /// The volume's slider let go at this percent: kept, and heard.
     Volume(u8),
+    /// The brightness's slider let go at this percent: kept.
+    Brightness(u8),
 }
 
 /// Which of the date and time pages shows.
@@ -145,8 +148,9 @@ struct Row {
     button: Option<(&'static str, Action)>,
     /// A switch, on or off, that does `Action` when flipped.
     switch: Option<(bool, Action)>,
-    /// A slider from 0 to 100 at this value: the sound's volume.
-    volume: Option<u8>,
+    /// A slider at this percent: the sound's volume or the screen's
+    /// brightness.
+    slider: Option<(Slider, u8)>,
 }
 
 fn row(label: &str, value: String) -> Row {
@@ -155,15 +159,59 @@ fn row(label: &str, value: String) -> Row {
         value,
         button: None,
         switch: None,
-        volume: None,
+        slider: None,
     }
 }
 
-/// The volume's slider, at `percent`.
-fn volume(percent: u8) -> Row {
+/// What a row's slider sets.
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+enum Slider {
+    Volume,
+    Brightness,
+}
+
+impl Slider {
+    fn label(self) -> &'static str {
+        match self {
+            Slider::Volume => t("Volume"),
+            Slider::Brightness => t("Brightness"),
+        }
+    }
+
+    /// Its least value: the kernel sets the screen no darker than 5 %.
+    fn min(self) -> u8 {
+        match self {
+            Slider::Volume => 0,
+            Slider::Brightness => 5,
+        }
+    }
+
+    /// Sets it as the slider moves, without keeping it.
+    fn follow(self, percent: u8) {
+        match self {
+            Slider::Volume => {
+                pinnacle_rt::audio::volume(Some(percent));
+            }
+            Slider::Brightness => {
+                pinnacle_rt::set_brightness(percent);
+            }
+        }
+    }
+
+    /// What letting go of it at `percent` does.
+    fn action(self, percent: u8) -> Action {
+        match self {
+            Slider::Volume => Action::Volume(percent),
+            Slider::Brightness => Action::Brightness(percent),
+        }
+    }
+}
+
+/// A row with `slider`, at `percent`.
+fn slider(slider: Slider, percent: u8) -> Row {
     Row {
-        volume: Some(percent),
-        ..row(t("Volume"), alloc::format!("{percent} %"))
+        slider: Some((slider, percent)),
+        ..row(slider.label(), alloc::format!("{percent} %"))
     }
 }
 
@@ -432,11 +480,18 @@ fn sections(width: i32, height: i32) -> Vec<Section> {
         // section, empty, is not shown.
         Section {
             title: t("Sound"),
-            rows: pinnacle_rt::audio::volume(None).map(volume).into_iter().collect(),
+            rows: pinnacle_rt::audio::volume(None)
+                .map(|v| slider(Slider::Volume, v))
+                .into_iter()
+                .collect(),
         },
         Section {
             title: t("Screen"),
-            rows: alloc::vec![with(t("Size"), screen, t("Turn"), Action::Turn)],
+            // The brightness's slider only where the kernel can set it (a
+            // laptop's panel; not QEMU's screen).
+            rows: core::iter::once(with(t("Size"), screen, t("Turn"), Action::Turn))
+                .chain(pinnacle_rt::brightness().map(|b| slider(Slider::Brightness, b)))
+                .collect(),
         },
         Section {
             title: t("Screen lock"),
@@ -1533,6 +1588,7 @@ fn play_tone() {
     player.drain();
 }
 
+        Action::Brightness(_) => "brightness".into(),
 /// The tone's loudest sample before the mixer: `cargo xtask sound-demo`
 /// finds it scaled by the volume in what QEMU heard.
 const TONE_LEVEL: f32 = 8000.0;
@@ -1567,13 +1623,14 @@ fn page(title: &str, sections: &[Section], tapped: &Signal<Option<Action>>) -> V
                         .child(el("span").class("m-list-item__title").child(row.label.clone())),
                 )
                 .child(el("span").class("m-list-item__end").child(move || shown.get()));
-            if let Some(percent) = row.volume {
+            if let Some((kind, percent)) = row.slider {
                 let tapped = tapped.clone();
-                let percent_of = |e: &pinnacle_view::Event| {
+                let min = kind.min();
+                let percent_of = move |e: &pinnacle_view::Event| {
                     e.value
                         .as_deref()
                         .and_then(|v| v.parse::<u8>().ok())
-                        .map(|v| v.min(100))
+                        .map(|v| v.clamp(min, 100))
                 };
                 let moving = said.clone();
                 item = item.child(
@@ -1587,20 +1644,21 @@ fn page(title: &str, sections: &[Section], tapped: &Signal<Option<Action>>) -> V
                                 .attr("min", "0")
                                 .attr("max", "100")
                                 .attr("step", "5")
-                                .attr("aria-label", t("Volume"))
-                                .attr("data-name", "volume")
+                                .attr("aria-label", kind.label())
+                                .attr("data-name", name_of(kind.action(percent)))
                                 .prop("value", alloc::format!("{percent}"))
-                                // Heard as it moves: the mixer follows the
-                                // finger, and what plays with it.
+                                // Followed as it moves: the mixer (and what
+                                // plays with it) or the panel follows the
+                                // finger.
                                 .on("input", move |e| {
                                     if let Some(v) = percent_of(e) {
-                                        pinnacle_rt::audio::volume(Some(v));
+                                        kind.follow(v);
                                         moving.set(alloc::format!("{v} %"));
                                     }
                                 })
                                 .on("change", move |e| {
                                     if let Some(v) = percent_of(e) {
-                                        tapped.set(Some(Action::Volume(v)));
+                                        tapped.set(Some(kind.action(v)));
                                     }
                                 }),
                         ),
@@ -2305,6 +2363,13 @@ fn main(_argument: u64) -> u64 {
                     }
                     Some(Action::InstallConfirm) => {
                         let disks = pinnacle_rt::install::disks();
+                    Some(Action::Brightness(v)) => {
+                        let set = pinnacle_rt::set_brightness(v);
+                        if !pinnacle_ui::brightness::keep(set.unwrap_or(v)) {
+                            pinnacle_rt::println!("settings: the brightness was not kept");
+                        }
+                        pinnacle_rt::println!("settings: brightness {} %", set.unwrap_or(v));
+                    }
                         if let Some(d) = install_choice.and_then(|i| disks.get(i)) {
                             let started = pinnacle_rt::install::start(&d.name);
                             pinnacle_rt::println!(
diff --git a/rt/src/lib.rs b/rt/src/lib.rs
index 3b499f1..661a775 100644
--- a/rt/src/lib.rs
+++ b/rt/src/lib.rs
@@ -509,6 +509,21 @@ pub fn log() -> String {
 #[derive(Clone, Debug, Default, PartialEq)]
 pub struct Battery {
     /// `charging`, `discharging`, `full` or `absent`.
+/// The built-in screen's brightness, 0 to 100: None when it has none to
+/// set (no driver for its graphics or firmware that sets it; QEMU), or for
+/// a confined program.
+pub fn brightness() -> Option<u8> {
+    let v = sys::call2(call::BRIGHTNESS, 0, 0);
+    (v != ERROR).then_some(v as u8)
+}
+
+/// Sets the screen's brightness to `percent` (never below 5, which the
+/// kernel keeps to) and returns it as it is then; None as [`brightness`].
+pub fn set_brightness(percent: u8) -> Option<u8> {
+    let v = sys::call2(call::BRIGHTNESS, 1, u64::from(percent));
+    (v != ERROR).then_some(v as u8)
+}
+
     pub state: String,
     pub percent: Option<u8>,
     /// To empty, discharging; to full, charging.
diff --git a/ui/src/brightness.rs b/ui/src/brightness.rs
new file mode 100644
index 0000000..2ce270a
--- /dev/null
+++ b/ui/src/brightness.rs
@@ -0,0 +1,21 @@
+//! The screen's brightness as Settings keeps it: a percent in
+//! `/settings/brightness`, which the display server gives the kernel at
+//! start, as the volume (`sound`).
+
+/// Where the brightness is kept.
+pub const BRIGHTNESS_PATH: &str = "system:/settings/brightness";
+
+/// The brightness kept, when one is: a percent, 0 to 100 (the kernel sets
+/// no less than 5).
+pub fn kept() -> Option<u8> {
+    pinnacle_rt::fs::read_string(BRIGHTNESS_PATH)?
+        .trim()
+        .parse()
+        .ok()
+        .filter(|v| *v <= 100)
+}
+
+/// Keeps `percent` where [`kept`] finds it.
+pub fn keep(percent: u8) -> bool {
+    pinnacle_rt::fs::write(BRIGHTNESS_PATH, alloc::format!("{percent}").as_bytes())
+}
diff --git a/ui/src/lib.rs b/ui/src/lib.rs
index d909d7a..dc9c86d 100644
--- a/ui/src/lib.rs
+++ b/ui/src/lib.rs
@@ -11,6 +11,7 @@ extern crate alloc;
 
 pub mod access;
 pub mod bluetooth;
+pub mod brightness;
 pub mod command;
 pub mod confirm;
 pub mod fien;
diff --git a/xtask/src/install.rs b/xtask/src/install.rs
index ef1cf15..45204f2 100644
--- a/xtask/src/install.rs
+++ b/xtask/src/install.rs
@@ -766,6 +766,12 @@ pub fn laptop() -> Result {
         "hda: codec 0: ",
         "sound: Intel HDA, 1 stream",
         "audio ok",
+        // The firmware's screen through its write-combining window.
+        "us write-combining, ",
+        // QEMU's VGA is no Intel GPU and its DSDT has no _BCM: no
+        // brightness, and Settings shows no slider for it. The backlight
+        // itself waits for a laptop.
+        "backlight: none to set",
     ]) {
         if !s.read.iter().any(|l| l.contains(line)) {
             return Err(format!("laptop, from the disk: no \"{line}\" in the output"));
@@ -801,5 +807,6 @@ pub fn laptop() -> Result {
     // QEMU has ended, so the WAV is whole.
     expect_tone(&wav, 440.0, 0.25)?;
     println!("ok   laptop: started from its disk, typed on PS/2, heard through HDA, off by its power button");
+    println!("note laptop: brightness untried (QEMU has no Intel GPU); it waits for a laptop");
     Ok(())
 }