WIP: Rewrote interrupt handling #3

Closed
Ghost wants to merge 1 commits from (deleted):interrupt-handlers into master

Purpose

This PR introduces a new system for handling interrupts:
When an interrupt is triggered, a corresponding routine from traps.s is ran, which does the following things:

  • Pushes a zero if there's no error code present to the stack
  • Pushes general purpose registers (rax - r15) to the stack
  • Calls a common handler routine written in C (which fills in the trap/exception frames)
  • If the handler returns (after processing an interrupt), all the previously pushed values are popped back, the RSP gets aligned properly and an iretq is executed, ensuring the OS can continue its execution normally.

This allows to easily add interrupt listeners for device drivers later.

Proposed changes

  • Only one common interrupt handler written in C which can then either handle an interrupt or print debugging information if an exception happens

TODO

  • Successfully handle any interrupt
  • Refactor traps.s to make use of compile-time loops and drastically reduce the file size
  • Actually implement the C handler

Notes

At the time of writing, the traps aren't handled correctly.

The ArTrapHandlers[] array contains invalid addresses that point to unknown locations.
Manually rewriting ArTrapHandlers[index] to ArHandleTrapX works, but a real fix should be found for this issue.

## Purpose This PR introduces a new system for handling interrupts: When an interrupt is triggered, a corresponding routine from `traps.s` is ran, which does the following things: - Pushes a zero if there's no error code present to the stack - Pushes general purpose registers (rax - r15) to the stack - Calls a common handler routine written in C (which fills in the trap/exception frames) - If the handler returns (after processing an interrupt), all the previously pushed values are popped back, the RSP gets aligned properly and an `iretq` is executed, ensuring the OS can continue its execution normally. This allows to easily add interrupt listeners for device drivers later. ## Proposed changes - Only one common interrupt handler written in C which can then either handle an interrupt or print debugging information if an exception happens ## TODO - [x] Successfully handle any interrupt - [ ] Refactor `traps.s` to make use of compile-time loops and drastically reduce the file size - [ ] Actually implement the C handler ## Notes At the time of writing, the traps aren't handled correctly. The `ArTrapHandlers[]` array contains invalid addresses that point to unknown locations. Manually rewriting `ArTrapHandlers[index]` to `ArHandleTrapX` works, but a real fix should be found for this issue.
Ghost added 1 commit 2023-11-21 18:50:03 +01:00
Ghost closed this pull request 2023-11-26 10:11:08 +01:00

Pull request closed

Sign in to join this conversation.
No description provided.