-
-
Notifications
You must be signed in to change notification settings - Fork 630
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
Bare metal: set up basic CPU exception handling, with IDT & TSS #640
Conversation
Amazing work, @tkchia! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't say how impressed I am with this change. Doing this is something that's mystified me for quite some time.
ezlea .excep_msg,di # stack should be 16-byte aligned now | ||
xor %eax,%eax # kprintf is variadic; remember to | ||
# pass no. of vector regs. used (= 0) | ||
call kprintf # print error message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to force a dependency on kprintf() into o/tiny/examples/life.com? If so, we might want to do a one-off error report.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @jart,
Is this going to force a dependency on kprintf() into o/tiny/examples/life.com?
Not yet. I am trying to arrange to link in the IDT logic only when the program is already linking in some sort of crash debugging (I am still not familiar with how Cosmopolitan's crash debugging capability works).
Thank you!
mov %cs,%eax | ||
stosw | ||
mov %rdx,%rax | ||
// ┌P:present |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love how you did the CP437 diagrams.
Hello @jart,
Well, it did take me quite a while to realize that I had to reload the GDTR to make it point to virtual memory — so that, when (re)loading Thank you! |
When a CPU exception (e.g. protection fault, divide by zero) happens in bare metal mode, the program should now be able to catch the exception and dump some information on the exception to the serial console, if one ropes in (
STATIC_YOINK
) the symbol_idt
.I hope to get the exception handlers to dump information to the VGA screen as well. It seems I will need to modify
kprintf
to do this. Once this is implemented, it should be easier to diagnose any program crashes that occur on bare metal.Thank you!