Compare commits

..
Author SHA1 Message Date
t3hn3rd aa28d62e03 feature: mirror all diagnostics to syslog, add VESA fallback for gfxd crashes
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
- syslogDump now outputs all five diagnostic sections (Fault Info,
  CPU Registers, Process Info, System Info, Call Stack) to serial,
  matching the on-screen BSOD content
- panic() detects if the crash occurred in the gfxd process and
  falls back to rendering the BSOD directly to the VESA framebuffer
  via driver.video text drawing, bypassing LVGL entirely
- Add DrawChar, DrawString, DrawHex, DrawInt to driver.video for
  8x16 bitmap font rendering directly to the framebuffer
- Export SHOULD_CRASH flag from svc.gfxd interface so test commands
  can trigger a deliberate gfxd crash
- Add app.divzero with DIV0, PF, and CRASHGFXD test commands
- Update doc/src/core/core.panic.md and doc/src/driver/video/driver.video.md
2026-03-10 12:35:22 +00:00
41 changed files with 772 additions and 70774 deletions

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN dpkg --add-architecture i386 RUN dpkg --add-architecture i386
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
curl dos2unix wget git make nasm binutils xorriso grub-pc-bin gcc gcc-multilib \ curl dos2unix wget git make nasm binutils xorriso grub-pc-bin gcc gcc-multilib \
python3 python3-pip python3-pil && \ python3 python3-pip && \
apt-get clean my room apt-get clean my room
RUN pip3 install --no-cache-dir --break-system-packages "mkdocs>=1.6,<2" mkdocs-material RUN pip3 install --no-cache-dir --break-system-packages "mkdocs>=1.6,<2" mkdocs-material
+21 -3
View File
@@ -4,7 +4,9 @@ Architecture-agnostic kernel panic (BSOD) engine.
## Overview ## Overview
`core.panic` implements a graphical and serial kernel panic handler for the Asuro kernel. When a fatal condition is detected anywhere in the kernel, `panic` is called with a fault identifier, a human-readable description, and an optional CPU register snapshot. The unit outputs the fault information to the serial syslog for headless debugging and, if LVGL has been initialised, displays a graphical Blue Screen of Death (BSOD). `core.panic` implements a graphical and serial kernel panic handler for the Asuro kernel. When a fatal condition is detected anywhere in the kernel, `panic` is called with a fault identifier, a human-readable description, and an optional CPU register snapshot. All diagnostic sections (Fault Info, CPU Registers, Process Info, System Info, Call Stack) are mirrored to the serial syslog for headless debugging. If LVGL has been initialised, a graphical Blue Screen of Death (BSOD) is displayed.
If the panic occurs inside the `gfxd` graphics-rendering process, LVGL state may be corrupt. In this case the unit falls back to rendering the panic screen directly to the VESA framebuffer using `driver.video.DrawString`, `driver.video.DrawHex`, and `driver.video.DrawInt`, bypassing LVGL entirely.
The BSOD screen and all its LVGL widgets are pre-allocated at `init` time so that no dynamic LVGL allocation is needed when a panic fires. At panic time only label text is updated via `lv_label_set_text`, the pre-built screen is loaded, and a single render pass is forced. Text formatting uses static heap buffers and avoids calling any string library routines that might themselves fault. The BSOD screen and all its LVGL widgets are pre-allocated at `init` time so that no dynamic LVGL allocation is needed when a panic fires. At panic time only label text is updated via `lv_label_set_text`, the pre-built screen is loaded, and a single render pass is forced. Text formatting uses static heap buffers and avoids calling any string library routines that might themselves fault.
@@ -16,7 +18,7 @@ If `init` has not been called before a panic (early boot panic), the unit gracef
- `io.syslog` — serial fault output - `io.syslog` — serial fault output
- `debug.tracer` — call-stack capture and freeze - `debug.tracer` — call-stack capture and freeze
- `driver.video` — frame buffer flush - `driver.video` — frame buffer flush and text drawing (DrawString, DrawHex, DrawInt) for VESA fallback
- `memory.heap` — buffer allocation - `memory.heap` — buffer allocation
- `driver.video.lvgl` — LVGL widget creation and rendering - `driver.video.lvgl` — LVGL widget creation and rendering
- `core.version` — version constants for the system info panel - `core.version` — version constants for the system info panel
@@ -24,6 +26,8 @@ If `init` has not been called before a panic (early boot panic), the unit gracef
- `proc.types` — process state enumeration - `proc.types` — process state enumeration
- `core.fmt.targa` — teapot TGA image decoding - `core.fmt.targa` — teapot TGA image decoding
- `core.gfx.texture` — pixel buffer type - `core.gfx.texture` — pixel buffer type
- `core.strings` — string comparison for gfxd process detection
- `core.gfx.color` — TRGB32 colour type for direct pixel drawing
## Constants ## Constants
@@ -71,7 +75,7 @@ Creates the hidden BSOD LVGL screen and pre-allocates all widget objects and tex
```pascal ```pascal
procedure panic(fault : pchar; info : pchar; regs : PRegisterSnapshot); procedure panic(fault : pchar; info : pchar; regs : PRegisterSnapshot);
``` ```
Triggers a kernel panic. Freezes the call-stack tracer, dumps fault information to syslog, and (if the BSOD screen is ready) displays the graphical panic screen. Then calls the registered halt procedure. Re-entrant calls are detected by a guard flag; if `panic` is called while a panic is already in progress, the system halts immediately without further output. Triggers a kernel panic. Freezes the call-stack tracer, dumps all diagnostic sections (Fault Info, CPU Registers, Process Info, System Info, Call Stack) to syslog, and displays the graphical panic screen. If the crash occurred in the `gfxd` process, LVGL is bypassed and the screen is rendered directly to the VESA framebuffer. Otherwise, if the LVGL BSOD screen is ready, it is used. Then calls the registered halt procedure. Re-entrant calls are detected by a guard flag; if `panic` is called while a panic is already in progress, the system halts immediately without further output.
Parameters: Parameters:
- `fault` — short fault identifier string, e.g. `'arch.x86.fault.gpf'`. - `fault` — short fault identifier string, e.g. `'arch.x86.fault.gpf'`.
@@ -93,3 +97,17 @@ The teapot image is loaded from a TGA binary linked into the kernel image via an
All text formatting in the panic path uses a set of internal buffer-writing helpers (`writeHexToBuffer`, `writeStrToBuffer`, `writeIntToBuffer`) that do not call the kernel string library, making the panic path robust against faults in those subsystems. All text formatting in the panic path uses a set of internal buffer-writing helpers (`writeHexToBuffer`, `writeStrToBuffer`, `writeIntToBuffer`) that do not call the kernel string library, making the panic path robust against faults in those subsystems.
A compile-time switch `BSOD_ENABLE` gates the display path; if disabled, `panic` only writes to syslog and halts. A compile-time switch `BSOD_ENABLE` gates the display path; if disabled, `panic` only writes to syslog and halts.
### gfxd Crash Detection
When `panic` is triggered, it checks whether the currently executing process is `gfxd` (the graphics daemon). If so, LVGL’s internal state may be corrupt (since `gfxd` drives the LVGL render pipeline), so the unit falls back to `showVESAFallbackScreen`. This procedure fills the screen with the BSOD background colour and renders all diagnostic sections using `driver.video.DrawString`, `driver.video.DrawHex`, and `driver.video.DrawInt` (which draw 8×16 bitmap font glyphs via `DrawPixel`). The layout mirrors the LVGL BSOD but uses a simpler single-column text format.
### Syslog Output
All five diagnostic sections are written to syslog in every panic, regardless of the display path:
1. **Fault Info** — fault identifier and human-readable description
2. **CPU Registers** — name/value pairs from the register snapshot
3. **Process Info** — name, PID, parent PID, state, and priority of the current process
4. **System Info** — kernel version, build date, compiler, revision, heap status, process count, uptime
5. **Call Stack** — frozen tracer output
+29
View File
@@ -13,6 +13,7 @@ This unit is the central video interface for the Asuro kernel. It holds a single
- `driver.video.gpu` - `driver.video.gpu`
- `driver.video.vesa32` (and other BPP variants) - `driver.video.vesa32` (and other BPP variants)
- `core.hashmap` - `core.hashmap`
- `core.gfx.fonts` — 8×16 bitmap font data for text drawing
- `syslog` - `syslog`
## Functions and Procedures ## Functions and Procedures
@@ -69,6 +70,34 @@ function backBuffer: PVideoBuffer;
``` ```
Returns a pointer to `VideoInterface.BackBuffer`. Returns a pointer to `VideoInterface.BackBuffer`.
## Text Drawing
These functions render text directly to the framebuffer using the 8×16 bitmap font from `core.gfx.fonts`. They are useful for panic screens or other contexts where LVGL is unavailable. Each function returns the X coordinate immediately after the last drawn pixel, allowing calls to be chained for inline formatting.
### DrawChar
```pascal
function DrawChar(X, Y : uint32; C : char; Color : TRGB32) : uint32;
```
Draws a single 8×16 bitmap glyph at `(X, Y)` in the given colour. Returns `X + 8`.
### DrawString
```pascal
function DrawString(X, Y : uint32; Str : pchar; Color : TRGB32) : uint32;
```
Draws a null-terminated string starting at `(X, Y)`. Each character advances X by 8 pixels. Returns the X coordinate after the last character.
### DrawHex
```pascal
function DrawHex(X, Y : uint32; Value : uint32; Color : TRGB32) : uint32;
```
Draws a `uint32` as a `0xHHHHHHHH` hex string at `(X, Y)`. Returns the X coordinate after the string.
### DrawInt
```pascal
function DrawInt(X, Y : uint32; Value : uint32; Color : TRGB32) : uint32;
```
Draws an unsigned integer in decimal at `(X, Y)`. Returns the X coordinate after the last digit.
## Notes ## Notes
- All drawing operations target the back buffer (`DefaultBuffer`) when double buffering is active. `Flush` transfers the result to the front (visible) buffer. - All drawing operations target the back buffer (`DefaultBuffer`) when double buffering is active. `Flush` transfers the result to the front (visible) buffer.
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

-49056
View File
File diff suppressed because it is too large. Load diff
-3456
View File
File diff suppressed because it is too large. Load diff
-12576
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -30,8 +30,8 @@
#define LV_LIMITS_INCLUDE <limits.h> #define LV_LIMITS_INCLUDE <limits.h>
#define LV_STDARG_INCLUDE <stdarg.h> #define LV_STDARG_INCLUDE <stdarg.h>
/* Built-in memory pool: 1 MB for complex UI (file browser etc.) */ /* Built-in memory pool: 256 KB should be plenty for our UI */
#define LV_MEM_SIZE (1024 * 1024U) #define LV_MEM_SIZE (256 * 1024U)
#define LV_MEM_POOL_EXPAND_SIZE 0 #define LV_MEM_POOL_EXPAND_SIZE 0
#define LV_MEM_ADR 0 #define LV_MEM_ADR 0
+57
View File
@@ -0,0 +1,57 @@
{
Prog->Ping - ICMP Ping command.
Sends 10 ICMP echo requests to a host, printing round-trip time
for each reply. Sleeps 1 second between pings. Each invocation
uses a heap-allocated state record so multiple terminals can app.ping
concurrently without corrupting each other.
@author(Kieron Morris <[email protected]>)
}
unit app.divzero;
interface
uses
io.stdio, debug.tracer;
procedure init();
implementation
uses
arch.x86.bda, driver.net.types, driver.net.proto.icmp, driver.net.util, core.strings,
proc.mgr, core.util, arch.x86.util, memory.heap, svc.gfxd;
{ ---- Command entry point (runs as a process) ---- }
procedure run_div0(Params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
begin
asm
XOR EAX, EAX
DIV EAX { this will trigger a divide by zero exception (interrupt 0) }
end;
end;
procedure run_pf(Params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
begin
asm
MOV EAX, $DEADBEEF
MOV [EAX], EAX { this will trigger a page fault (interrupt 14) }
end;
end;
procedure run_div0_gfxd(Params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
begin
svc.gfxd.SHOULD_CRASH := true; { set flag to trigger crash in graphics service }
end;
procedure init();
begin
debug.tracer.push_trace('divzero.init');
io.stdio.registerCommand('DIV0', @run_div0, 'Force a divide by zero exception.');
io.stdio.registerCommand('PF', @run_pf, 'Force a page fault.');
io.stdio.registerCommand('CRASHGFXD', @run_div0_gfxd, 'Force a divide by zero exception in the graphics service.');
end;
end.
File diff suppressed because it is too large. Load diff
+116 -4
View File
@@ -61,7 +61,6 @@ uses
driver.video.lvgl, driver.video.lvgl,
driver.storage.types, driver.storage.types,
core.strings, core.strings,
core.strings.helpers,
io.syslog, io.syslog,
debug.tracer, debug.tracer,
core.util, arch.x86.util, core.util, arch.x86.util,
@@ -263,6 +262,119 @@ begin
if cb <> nil then cb(sel_path, userdata); if cb <> nil then cb(sel_path, userdata);
end; end;
{ ============================================================
fmtFileSize — returns a kalloc'd human-readable size string.
Caller must kfree the result.
============================================================ }
function fmtFileSize(sz: uint32): pchar;
var
whole, frac : uint32;
s1, s2, s3, res : pchar;
begin
if sz < 1024 then begin
s1 := intToString(sz);
res := stringConcat(s1, ' B');
kfree(void(s1));
end else if sz < uint32(1024 * 1024) then begin
whole := sz div 1024;
frac := (sz mod 1024) * 10 div 1024;
s1 := intToString(whole);
s2 := stringConcat(s1, '.'); kfree(void(s1));
s3 := intToString(frac);
s1 := stringConcat(s2, s3); kfree(void(s2)); kfree(void(s3));
res := stringConcat(s1, ' KB'); kfree(void(s1));
end else begin
whole := sz div (1024 * 1024);
frac := (sz mod (1024 * 1024)) * 10 div (1024 * 1024);
s1 := intToString(whole);
s2 := stringConcat(s1, '.'); kfree(void(s1));
s3 := intToString(frac);
s1 := stringConcat(s2, s3); kfree(void(s2)); kfree(void(s3));
res := stringConcat(s1, ' MB'); kfree(void(s1));
end;
fmtFileSize := res;
end;
{ ============================================================
matchesFilter
Returns true when name ends with the filter extension, or
when filter is nil (show everything).
============================================================ }
function matchesFilter(name: pchar; fltr: pchar): boolean;
var
nlen, flen, i: uint32;
begin
matchesFilter := true;
if fltr = nil then exit;
nlen := stringSize(name);
flen := stringSize(fltr);
if flen = 0 then exit;
if nlen < flen then begin matchesFilter := false; exit; end;
for i := 0 to flen - 1 do
if name[nlen - flen + i] <> fltr[i] then begin
matchesFilter := false;
exit;
end;
end;
{ ============================================================
strLess — case-sensitive alphabetical comparison for sort
============================================================ }
function strLess(a, b: pchar): boolean;
var
i: uint32;
begin
strLess := false;
if (a = nil) or (b = nil) then exit;
i := 0;
while (a[i] <> #0) and (b[i] <> #0) do begin
if ord(a[i]) < ord(b[i]) then begin strLess := true; exit; end;
if ord(a[i]) > ord(b[i]) then exit;
i := i + 1;
end;
strLess := (a[i] = #0) and (b[i] <> #0);
end;
{ Simple insertion sort on a pchar array of length n }
procedure sortNames(var arr: array of pchar; n: uint32);
var
i, j : uint32;
tmp : pchar;
begin
if n < 2 then exit;
for i := 1 to n - 1 do begin
tmp := arr[i];
j := i;
while (j > 0) and strLess(tmp, arr[j - 1]) do begin
arr[j] := arr[j - 1];
j := j - 1;
end;
arr[j] := tmp;
end;
end;
{ Insertion sort on name array, swapping a parallel size array in lockstep }
procedure sortNamesWithSizes(var names: array of pchar; var sizes: array of uint32; n: uint32);
var
i, j : uint32;
tmpN : pchar;
tmpS : uint32;
begin
if n < 2 then exit;
for i := 1 to n - 1 do begin
tmpN := names[i];
tmpS := sizes[i];
j := i;
while (j > 0) and strLess(tmpN, names[j - 1]) do begin
names[j] := names[j - 1];
sizes[j] := sizes[j - 1];
j := j - 1;
end;
names[j] := tmpN;
sizes[j] := tmpS;
end;
end;
{ ============================================================ { ============================================================
fp_collect_cb fp_collect_cb
core.ds.hashmap.forEach callback: classifies each VFS entry as dir or file core.ds.hashmap.forEach callback: classifies each VFS entry as dir or file
@@ -283,7 +395,7 @@ begin
ctx^.dir_count := ctx^.dir_count + 1; ctx^.dir_count := ctx^.dir_count + 1;
end; end;
otFILE, otVFILE: otFILE, otVFILE:
if stringEndsWith(key, ctx^.filter) then if matchesFilter(key, ctx^.filter) then
if ctx^.file_count < ENTRY_MAX then begin if ctx^.file_count < ENTRY_MAX then begin
ctx^.file_names^[ctx^.file_count] := key; ctx^.file_names^[ctx^.file_count] := key;
ctx^.file_sizes^[ctx^.file_count] := obj^.FileSize; ctx^.file_sizes^[ctx^.file_count] := obj^.FileSize;
@@ -375,8 +487,8 @@ begin
io.syslog.logln('FPCIK', 'do_refresh: collection done, sorting'); io.syslog.logln('FPCIK', 'do_refresh: collection done, sorting');
{ --- Sort both collections alphabetically --- } { --- Sort both collections alphabetically --- }
if dir_count > 0 then sortStringArray(@dir_names^[0], dir_count); if dir_count > 0 then sortNames(dir_names^, dir_count);
if file_count > 0 then sortStringArrayWithData(@file_names^[0], @file_sizes^[0], file_count); if file_count > 0 then sortNamesWithSizes(file_names^, file_sizes^, file_count);
{ --- Build directory rows --- } { --- Build directory rows --- }
if dir_count > 0 then if dir_count > 0 then
+7 -9
View File
@@ -33,7 +33,8 @@ uses
//dispatch //dispatch
driver.storage.filedispatch, driver.storage.filedispatch,
//wasm //wasm
app.wasm.runner; app.wasm.runner,
app.divzero;
{ Initialize all baked-in programs } { Initialize all baked-in programs }
procedure init(); procedure init();
@@ -44,8 +45,7 @@ uses
core.version, core.version,
//command provider units //command provider units
arch.x86.cpu, arch.x86.cpu,
app.diskcmd, driver.bus.usb.core, app.diskutil, app.notepad, app.partcmd, app.volcmd, app.diskcmd, driver.bus.usb.core, app.diskutil, app.notepad, app.partcmd, app.volcmd;
app.filebrowser;
procedure init(); procedure init();
begin begin
@@ -64,10 +64,6 @@ begin
io.stdio.registerCommand('TCPHTTP', @driver.net.proto.tcp.terminal_command_tcphttp, 'Send HTTP GET to a host IP (port 80 default).'); io.stdio.registerCommand('TCPHTTP', @driver.net.proto.tcp.terminal_command_tcphttp, 'Send HTTP GET to a host IP (port 80 default).');
io.stdio.registerCommand('USB', @driver.bus.usb.core.terminal_command_usb, 'driver.bus.usb subsystem information.'); io.stdio.registerCommand('USB', @driver.bus.usb.core.terminal_command_usb, 'driver.bus.usb subsystem information.');
{ File dispatch — must init before apps that register handlers }
driver.storage.ctl.ram.init();
driver.storage.filedispatch.init();
{ Initialize baked-in programs } { Initialize baked-in programs }
app.diskcmd.init(); app.diskcmd.init();
app.partcmd.init(); app.partcmd.init();
@@ -81,10 +77,12 @@ begin
app.testcmd.init(); app.testcmd.init();
app.ping.init(); app.ping.init();
app.meminfo.init(); app.meminfo.init();
{ WASM & remaining apps } { File dispatch & WASM integration }
driver.storage.ctl.ram.init();
driver.storage.filedispatch.init();
app.wasm.runner.init(); app.wasm.runner.init();
app.setres.init(); app.setres.init();
app.filebrowser.init(); app.divzero.init();
end; end;
end. end.
Loaded 20 of 41 files, more files were not shown because too many files have changed in this diff. Show more