rust-osdev / x86_64

Library to program x86_64 hardware.
https://docs.rs/x86_64
Apache License 2.0
797 stars 132 forks source link

TryFrom implementation for ExceptionVector #506

Closed mrjbom closed 12 hours ago

mrjbom commented 3 weeks ago

There is currently no way to create an instance of idt::ExceptionVector having an interrupt number. At the same time it would be convenient for the user to use this enum to handle interrupts.

As for the implementation, I couldn't think of what type of error it should return.

Freax13 commented 3 weeks ago

Thank you for your contribution!

There is currently no way to create an instance of idt::ExceptionVector having an interrupt number. At the same time it would be convenient for the user to use this enum to handle interrupts.

As for the implementation, I couldn't think of what type of error it should return.

Let's use a simple error type that wraps the invalid u8. Feel free to use PcidTooBig as inspiration: https://github.com/rust-osdev/x86_64/blob/323d46c46554f4c47b3e63b4b7c3facbc4bc46b8/src/instructions/tlb.rs#L78-L88

mrjbom commented 3 weeks ago

Made Error as enum for more details

Freax13 commented 13 hours ago

I rebased this PR onto the lastest master branch to fix CI.