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
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "gfx.h"
|
||||
#include "param.h"
|
||||
#include "memlayout.h"
|
||||
#include "mmu.h"
|
||||
|
|
@ -49,7 +50,7 @@ extern int panicked;
|
|||
/* */
|
||||
/* cprintf goes to the console, which during a panic is also the screen */
|
||||
/* being painted over -- so the panel builds its strings itself and */
|
||||
/* places them with vga_text_at. */
|
||||
/* places them with gfx_text_at. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
static char *
|
||||
|
|
@ -130,7 +131,7 @@ draw_paren(int cx, int cy, int h, int thick, uint32 color)
|
|||
int dx = isqrt(r * r - dy * dy);
|
||||
// Narrow it: a true half-circle reads as a bracket, not a parenthesis.
|
||||
int x = cx - (dx * 45) / 100;
|
||||
vga_fill_circle(x, cy + dy, thick / 2, color);
|
||||
gfx_fill_circle(x, cy + dy, thick / 2, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -141,8 +142,8 @@ draw_sad_face(int x, int y, int h, uint32 color)
|
|||
int gap = h / 4;
|
||||
|
||||
// The colon.
|
||||
vga_fill_circle(x + dot, y + h / 2 - gap, dot, color);
|
||||
vga_fill_circle(x + dot, y + h / 2 + gap, dot, color);
|
||||
gfx_fill_circle(x + dot, y + h / 2 - gap, dot, color);
|
||||
gfx_fill_circle(x + dot, y + h / 2 + gap, dot, color);
|
||||
|
||||
// The parenthesis, a little to the right of it.
|
||||
draw_paren(x + dot * 2 + h / 2, y + h / 2, h, dot * 2, color);
|
||||
|
|
@ -380,15 +381,15 @@ draw_qr_panel(int sw, int sh, int ch, char *reason, addr_t *pcs, int npcs)
|
|||
int x0 = sw - card - sw / 24;
|
||||
int y0 = sh / 8;
|
||||
|
||||
vga_fill_rect(x0, y0, card, card, PSOGM_CARD);
|
||||
gfx_fill_rect(x0, y0, card, card, PSOGM_CARD);
|
||||
for (int y = 0; y < panic_qr.size; y++)
|
||||
for (int x = 0; x < panic_qr.size; x++)
|
||||
if (panic_qr.mod[y][x])
|
||||
vga_fill_rect(x0 + (x + quiet) * scale, y0 + (y + quiet) * scale,
|
||||
gfx_fill_rect(x0 + (x + quiet) * scale, y0 + (y + quiet) * scale,
|
||||
scale, scale, PSOGM_INK);
|
||||
|
||||
vga_text_at(x0, y0 + card + ch, "Scan for a text copy", PSOGM_DIM);
|
||||
vga_text_at(x0, y0 + card + ch * 2 + 2, "of this report.", PSOGM_DIM);
|
||||
gfx_text_at(x0, y0 + card + ch, "Scan for a text copy", PSOGM_DIM);
|
||||
gfx_text_at(x0, y0 + card + ch * 2 + 2, "of this report.", PSOGM_DIM);
|
||||
|
||||
return card + sw / 24;
|
||||
}
|
||||
|
|
@ -410,19 +411,19 @@ static void
|
|||
paint(char *reason, addr_t *pcs, int npcs)
|
||||
{
|
||||
int sw, sh;
|
||||
vga_dims(&sw, &sh);
|
||||
gfx_dims(&sw, &sh);
|
||||
|
||||
int ch = vga_char_h();
|
||||
int cw = vga_char_w();
|
||||
int ch = gfx_char_h();
|
||||
int cw = gfx_char_w();
|
||||
|
||||
// The whole display, one colour. An earlier version dimmed the previous
|
||||
// screen and floated a panel over it, which looked good and was wrong: the
|
||||
// thing is called a Purple Screen, and half a screen of somebody's abandoned
|
||||
// work behind the report is a distraction at the worst possible moment.
|
||||
vga_clear(PSOGM_BG);
|
||||
gfx_clear(PSOGM_BG);
|
||||
// Glyphs are drawn with their background filled, so the console's cream has
|
||||
// to become the background or every line of text arrives in its own box.
|
||||
vga_set_bg(PSOGM_BG);
|
||||
gfx_set_bg(PSOGM_BG);
|
||||
|
||||
// The symbol goes first, because it decides how much width the text has. It
|
||||
// is drawn before anything can fail: if the encoder refuses the payload the
|
||||
|
|
@ -439,10 +440,10 @@ paint(char *reason, addr_t *pcs, int npcs)
|
|||
|
||||
// Left-aligned, not centred. Centred text reads as a poster; this is a
|
||||
// report, and a report is read down the left edge.
|
||||
vga_text_at(left, y, "SchOS ran into a problem and needs to restart.",
|
||||
gfx_text_at(left, y, "SchOS ran into a problem and needs to restart.",
|
||||
PSOGM_FG);
|
||||
y += ch + ch / 2;
|
||||
vga_text_at(left, y, "Nothing on your disks was touched by this.",
|
||||
gfx_text_at(left, y, "Nothing on your disks was touched by this.",
|
||||
PSOGM_DIM);
|
||||
|
||||
// A rule in the boot splash's accent, the same width as the one under the
|
||||
|
|
@ -452,25 +453,25 @@ paint(char *reason, addr_t *pcs, int npcs)
|
|||
// the line above to read as an underline of that sentence rather than as a
|
||||
// divider before the facts.
|
||||
y += ch * 2;
|
||||
vga_fill_rect(left, y, 120, 2, SCH_ACCENT);
|
||||
gfx_fill_rect(left, y, 120, 2, SCH_ACCENT);
|
||||
y += ch;
|
||||
|
||||
// Facts: quiet labels down the left, bright values in a second column.
|
||||
int vx = left + 14 * cw;
|
||||
for (int i = 0; i < nfields; i++) {
|
||||
vga_text_at(left, y, fields[i].label, PSOGM_DIM);
|
||||
vga_text_at(vx, y, fields[i].value, PSOGM_FG);
|
||||
gfx_text_at(left, y, fields[i].label, PSOGM_DIM);
|
||||
gfx_text_at(vx, y, fields[i].value, PSOGM_FG);
|
||||
y += ch + 2;
|
||||
}
|
||||
|
||||
y += ch;
|
||||
vga_text_at(left, y, "Call chain", PSOGM_DIM);
|
||||
gfx_text_at(left, y, "Call chain", PSOGM_DIM);
|
||||
y += ch + 2;
|
||||
|
||||
for (int i = 0; i < npcs && pcs[i]; i++) {
|
||||
char line[48];
|
||||
trace_line(line, sizeof(line), i, pcs[i]);
|
||||
vga_text_at(vx - 3 * cw, y, line, PSOGM_FG);
|
||||
gfx_text_at(vx - 3 * cw, y, line, PSOGM_FG);
|
||||
y += ch;
|
||||
if (y > sh - ch * 5)
|
||||
break;
|
||||
|
|
@ -479,9 +480,9 @@ paint(char *reason, addr_t *pcs, int npcs)
|
|||
// Two closing lines, bottom left: what to do with the numbers above, and
|
||||
// what this screen is called, so it can be searched for by name. Shortened
|
||||
// from the full command line, which at 62 characters ran under the QR card.
|
||||
vga_text_at(left, sh - ch * 3,
|
||||
gfx_text_at(left, sh - ch * 3,
|
||||
"Resolve: addr2line -e kernel <address>", PSOGM_DIM);
|
||||
vga_text_at(left, sh - ch * 3 + ch + 4,
|
||||
gfx_text_at(left, sh - ch * 3 + ch + 4,
|
||||
"PSOGM -- Purple Screen of Guru Meditation", PSOGM_DIM);
|
||||
}
|
||||
|
||||
|
|
@ -534,7 +535,7 @@ panic(char *s)
|
|||
gather(s, pcs, 10);
|
||||
report_serial(s, pcs, 10);
|
||||
|
||||
if (vga_ready())
|
||||
if (gfx_ready())
|
||||
paint(s, pcs, 10);
|
||||
|
||||
panicked = 1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue