-
Notifications
You must be signed in to change notification settings - Fork 133
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
idt: Fixup Options structure and cleanup set_handler_fn #226
Conversation
This change: - Moves the IDT entry's CS GDT selector to the options structure - It also now uses SegmentSelector - The `set_handler_fn` is now a proper generic function - This is done by adding the `InterruptFn` trait - Change behavior (and document) so `set_handler_fn` resets _all_ the options (as opposed to some). Signed-off-by: Joe Richey <[email protected]>
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.
Looks good to me overall, thanks! There is one small documentation issue about the default CS value though (see inline comments).
src/structures/idt.rs
Outdated
/// Set the code segment that will be used by this interrupt. By default, | ||
/// the current code segment is used. |
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.
By default, the current code segment is used.
This is not true, as minimal()
uses 0 as default CS.
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.
Agreed. I just removed this line as to avoid confusion.
Saying "By default" here is confusing, as it could mean the defaults from set_handler_fn
or the defaults from minimal()
.
This change should be non-breaking, right? |
Pretty sure the change on |
Signed-off-by: Joe Richey <[email protected]>
Correct, as the only function that's changed is set_handler_fn which went from an explicit implementation on 5 types to an implementation on an interface that is implemented by those types, so all existing code should still work. There is a functional change. Before, |
I don't think the |
Ah, good point! However, I think the only way to change the entry options is to call let mut entry = idt[42];
entry.set_handler_fn(foo).disable_interrupts(false);
entry.set_handler_fn(bar); // this now disables interrupts again So I don't expect much breakage from this in practice. However, I would still classify this as a breaking change to be on the safe side. I therefore changed the base branch of this PR to the |
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.
Thanks for the doc updates! Looks ready for me now.
Right! I'm muddling those two up, my bad 😅 |
This moves the code_selector to the `EntryOptions` structure. While rebasing this, I also updated the `Debug` implementation to actually print out useful information instead of just hex codes. I left the type field as binary, as that's what the SDM does. Signed-off-by: Joe Richey <[email protected]>
This moves the code_selector to the `EntryOptions` structure. While rebasing this, I also updated the `Debug` implementation to actually print out useful information instead of just hex codes. I left the type field as binary, as that's what the SDM does. Signed-off-by: Joe Richey <[email protected]>
This moves the code_selector to the `EntryOptions` structure. While rebasing this, I also updated the `Debug` implementation to actually print out useful information instead of just hex codes. I left the type field as binary, as that's what the SDM does. Signed-off-by: Joe Richey <[email protected]>
This change is an alternative to #225:
set_handler_fn
is now a proper generic functionInterruptFn
traitset_handler_fn
resets all theoptions (as opposed to some). This is a breaking change.
Signed-off-by: Joe Richey [email protected]