Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[metal] Show "screen of death" on VGA console upon program crash #650

Merged
merged 6 commits into from
Oct 6, 2022
Merged

[metal] Show "screen of death" on VGA console upon program crash #650

merged 6 commits into from
Oct 6, 2022

Conversation

tkchia
Copy link
Contributor

@tkchia tkchia commented Oct 5, 2022

With commit 5aaadf1, the VGA console code can now display information about program crashes:
20221005-1
My aim in implementing a "screen of death" is to make it easier to debug program crashes on actual bare metal setups (where we will not be able to use e.g. QEMU's or Bochs's debugging features). So yes, I have tested the "screen of death" on a real machine. And it does work. 🙂

I also included a few other less major changes within this PR, namely https://github.com/tkchia/cosmopolitan/commit/9926ed74f11222d4bf0c71a1944c2e717a9552b8, https://github.com/tkchia/cosmopolitan/commit/7059a7109d3a7647ecafc3f7b178b1dd12ec83d8, and https://github.com/tkchia/cosmopolitan/commit/b8cd8a07b48b726fde2c544ea42f715e80d23a04.

tkchia added 5 commits October 5, 2022 16:25
If using a pre-existing VGA text console, the VGA initialization
code now retrieves the cursor position & character height from
the BIOS data area while still in real mode — rather than
reading from the BIOS data area only after entering long mode.

(This should help make the code more correct, if Cosmopolitan
were to support UEFI graphics output in the future.  If the
program were booted via UEFI, then the long mode IsMetal()
code would still be activated, but the BIOS data area might
not have been initialized in that case.)

This change also means that there are now a few more fields
in the `struct mman`.
There is now a new function _klog_vga(), which can be called
by kprintf() to output system messages — e.g. information about
CPU exceptions — on the VGA screen.
Copy link
Owner

@jart jart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love our red screen of death! Thank you!

@@ -188,6 +189,7 @@ privileged static void klog(const char *b, size_t n) {
: /* no inputs */
: "a"(b[i]), "dN"(dx));
}
if (_weaken(_klog_vga)) _weaken(_klog_vga)(b, n);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@jart jart merged commit d3efa47 into jart:master Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants