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

gdt: Improve panic message when SystemSegment is pushed #361

Merged
merged 3 commits into from
Mar 28, 2022
Merged

Conversation

josephlr
Copy link
Contributor

This is a minor, non-breaking change.

When pushing a SystemSegment the GDT has to have two entries free. Rather than pushing part of the SystemSegment and then panicking, we can panic before we even modify the GDT, and give a better error message. This new behavior also seems less surprising, as normally if a mutation operation panics, the structure isn't modified.

I also renamed the next_free private member to len (with these changes it makes the code more readable). I also added some tests to make sure we are correctly handling the add_entry command.

Signed-off-by: Joe Richey joerichey@google.com

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
@josephlr josephlr requested review from phil-opp and Freax13 March 28, 2022 06:50
@josephlr
Copy link
Contributor Author

Build failure is unrelated, see rust-osdev/uart_16550#22

@phil-opp
Copy link
Member

Build failure is unrelated, see rust-osdev/uart_16550#22

I just released a new uart_16550 version and restarted the failed CI jobs.

Copy link
Member

@Freax13 Freax13 left a 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!

src/structures/gdt.rs Outdated Show resolved Hide resolved
Signed-off-by: Joe Richey <joerichey@google.com>
@josephlr josephlr enabled auto-merge March 28, 2022 19:30
@josephlr josephlr merged commit aab60f7 into master Mar 28, 2022
@josephlr josephlr deleted the gdt_check branch March 28, 2022 19:32
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.

3 participants