gfx: the console and the crash screen stop drawing on a driver by name
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>
This commit is contained in:
parent
20cc673a41
commit
817d666068
22 changed files with 942 additions and 752 deletions
|
|
@ -74,20 +74,22 @@ kmain(uint32 fb_addr)
|
|||
if (boot_verbose) cprintf("verbose boot: uartinit done\n");
|
||||
mouseinit();
|
||||
if (boot_verbose) cprintf("verbose boot: mouseinit done\n");
|
||||
vga_init(fb_addr);
|
||||
if (boot_verbose) cprintf("verbose boot: vga_init done (fb=0x%x)\n", fb_addr);
|
||||
// No splash drawing here on purpose. The loader owns the splash, logo and
|
||||
// all, and vga_init() deliberately does not clear -- so it is still on the
|
||||
// display right through to console_takeover(). Painting it again from here
|
||||
// would land in the last few hundred milliseconds of boot and change nothing.
|
||||
// After vga_init, because the display driver cross-checks the framebuffer
|
||||
// address it finds on the bus against the one VBE reported -- and it can
|
||||
// only do that once vga.c has read the VBE block.
|
||||
// The devices that are simply known to be on a PC rather than enumerated by
|
||||
// any bus. Registered before pci_init() so that /proc/devices lists them
|
||||
// first, which puts the machine's fixed furniture above whatever happened to
|
||||
// be plugged into it.
|
||||
platform_register_devices();
|
||||
// any bus, and the framebuffer the loader left running. Registered before
|
||||
// pci_init() so that /proc/devices lists them first, which puts the machine's
|
||||
// fixed furniture above whatever happened to be plugged into it -- and
|
||||
// because the display has to work long before any bus is walked.
|
||||
//
|
||||
// main() names no display driver. Whichever one owns the boot framebuffer
|
||||
// publishes it there as this kernel's scanout, and the console and crash
|
||||
// screen draw on that; see include/gfx.h.
|
||||
//
|
||||
// No splash drawing here on purpose. The loader owns the splash, logo and
|
||||
// all, and bringing the framebuffer up deliberately does not clear it -- so
|
||||
// it stays on the display right through to console_takeover(). Painting it
|
||||
// again from here would land in the last few hundred milliseconds of boot
|
||||
// and change nothing.
|
||||
platform_register_devices(fb_addr);
|
||||
pci_init();
|
||||
if (boot_verbose) cprintf("verbose boot: pci_init done\n");
|
||||
pinit();
|
||||
|
|
|
|||
Loading…
Reference in a new issue