Same disease as the network stack, one subsystem over. kernel/dev/vga.c
was three things wearing one name: the owner of the framebuffer, a
bitmap drawing library, and the text console. Only the first is a
driver, and because they shared a file they shared a prefix -- so
panic.c drew the crash screen with vga_fill_rect, console.c printed with
vga_putc, /dev/fb0 handed out vga_fb_phys, and every one of those files
named a display driver it had no business knowing about.
Split three ways:
- kernel/drivers/gpu/vga/vga_fb.c owns the VBE framebuffer -- the mode
the loader programmed and handed over, the aperture, and the display
class vtable. It is a driver and now lives with the driver that
finds the card on the bus.
- kernel/dev/gfx.c draws: pixels, shapes, glyphs, the cursor, scroll,
the ANSI erase operations. It names no driver. The framebuffer
arrives through gfx_attach_scanout(), so a driver publishes what it
owns and this file draws on it without knowing what it is.
- include/gfx.h is the interface, and says why it is deliberately not
the display class: that one is about frames -- acquire, present,
vblank -- and the crash screen has to work when nothing else does.
main() no longer calls a display driver. platform_register_devices()
takes the framebuffer address and brings up whatever owns it, which is
where driver names belong; kernel/drivers/registry.c is the file whose
entire job is naming every driver in the kernel.
virtio-gpu got the e1000 treatment as well: instances in an array, the
instance hung on dev->priv by an `attached` hook, and every op reading
it rather than a file-static. It refused the second adapter outright
before, which is not hypothetical -- integrated plus discrete is an
ordinary laptop. The VGA driver deliberately has no such hook, and says
so: there is one framebuffer the loader programmed however many
VGA-class controllers the bus turns up, and a second one publishing the
same scanout is the truth rather than a bug.
Private headers moved next to their drivers: include/virtio.h and
include/xhci.h each had exactly one includer. include/ is for headers
the rest of the kernel needs.
Deleted rather than moved: consoleinit() programmed the sixteen ANSI
colours into the VGA DAC and disabled text-mode blink, by writing ports
0x3C0-0x3C9 from the console. The comment three lines above the colour
table already said this does nothing in a 32bpp linear mode -- there is
no palette to index -- so it was both dead and in the wrong file.
Verified, and this is a refactor so the evidence is that nothing moved:
- bootcheck -Fb -Net: 59 [ok], no failures. That covers the console
through every command, /dev/fb0's geometry, writing pixels through
write() and mapping the framebuffer through mmap.
- make crashshot: the crash screen renders exactly as before --
shapes, glyphs, logo and QR code -- which is the whole of gfx.c
exercised at once, in a panic, with the scanout attached by a driver.
- make schcom-test: five pixel assertions from the host oracle still
pass, so the display class and the compositor above it are unmoved.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
57 lines
3.1 KiB
C
57 lines
3.1 KiB
C
#pragma once
|
|
|
|
// SchOS visual identity — one palette, shared by everything that draws.
|
|
//
|
|
// This header exists because there were three unrelated designs and the seams
|
|
// showed. The bootloader splash was deep purple with gold text, deliberately
|
|
// matching the *panic* screen; the kernel console was cream with near-black
|
|
// text; the panic screen was the purple both were copying. So a normal boot
|
|
// looked like a crash, then abruptly became an amber terminal, and none of the
|
|
// three looked like the same product.
|
|
//
|
|
// The rule now: **normal states are calm and dark; only failure is loud.**
|
|
// Boot, console and shell share SCH_BG/SCH_FG. The panic screen keeps the
|
|
// full-bleed purple entirely to itself, which is what makes it mean something.
|
|
//
|
|
// Included by boot/bios/stage2main.c (freestanding, pre-kernel), kernel/dev/vga.c,
|
|
// kernel/core/console.c and kernel/core/panic.c. Plain #defines only — no
|
|
// types, no code — because stage2 is compiled 32-bit against a different
|
|
// world than the kernel.
|
|
//
|
|
// Colours are 0xRRGGBB. gfx_draw_pixel packs them for whatever depth the
|
|
// framebuffer actually is.
|
|
|
|
// --- the product ---------------------------------------------------------
|
|
// Near-black with a slight blue cast rather than pure #000: pure black on an
|
|
// LCD reads as "the machine is off", and every serious platform sits a few
|
|
// points above it.
|
|
#define SCH_BG 0x0C0E13
|
|
#define SCH_FG 0xE6E8EC // primary text
|
|
#define SCH_DIM 0x707784 // secondary text, hints, version strings
|
|
#define SCH_ACCENT 0x7C5CFF // the one accent: violet, keeping the
|
|
// project's purple lineage without the
|
|
// eye-searing chroma of the old splash
|
|
#define SCH_ACCENT_DIM 0x2A2440 // unused track behind a progress bar
|
|
#define SCH_OK 0x4ADE80 // reserved: success states
|
|
#define SCH_WARN 0xFBBF24 // reserved: warnings that are not panics
|
|
|
|
// --- failure -------------------------------------------------------------
|
|
// PSOGM. Deliberately unlike anything above, because its whole job is to be
|
|
// unmistakable. See kernel/core/panic.c.
|
|
//
|
|
// These are the values panic.c actually renders. It used to carry a second,
|
|
// different set of PSOGM_* defines of its own, so the two disagreed about what
|
|
// the crash screen looked like and this header was quietly fiction. There was
|
|
// also a PSOGM_TITLE in gold here, left over from a splash design that no
|
|
// longer exists -- the screen is one background and two weights of text, on
|
|
// purpose, because a crash screen with an accent colour is a crash screen
|
|
// someone was enjoying designing.
|
|
#define PSOGM_BG 0x4B1D9A // the purple
|
|
#define PSOGM_FG 0xFFFFFF // the face, the headline, the values
|
|
#define PSOGM_DIM 0xC3AEEC // labels and the closing lines
|
|
|
|
// The one exception to "two weights of text": the QR card has to be a light
|
|
// panel with dark modules, because that is what a scanner needs. It reads as a
|
|
// label stuck onto the screen, which is roughly what it is.
|
|
#define PSOGM_CARD 0xFFFFFF
|
|
#define PSOGM_INK 0x000000
|