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: Add load_unchecked, from_raw_slice, and as_raw_slice. #210

Merged
merged 6 commits into from
Dec 28, 2020
Merged

GDT: Add load_unchecked, from_raw_slice, and as_raw_slice. #210

merged 6 commits into from
Dec 28, 2020

Conversation

mental32
Copy link
Member

@mental32 mental32 commented Dec 27, 2020

Currently the API for structures::GlobalDescriptorTable feels like it requires you to either:

That's because there's no way to actually form your GDT entries without using add_entry which takes &mut self... which seems contradictory that load requires the GDT to be &'static self!

you can get around this using a lazy_static of course but what if I want to use once_cell instead? there's no nice way of going about this... that's why this PR inroduces load_unchecked which is the same as load without the 'static requirement and marked unsafe (of course.)

Also I noticed that sometimes you just know ahead of time what you want your GDT to be initialized with which lead me to add the const unsafe from_raw_parts constructor and into_raw_parts.

@mental32 mental32 changed the title Add unsafe load_unchecked, from_raw_parts, and into_raw_parts. GDT: Add load_unchecked, from_raw_parts, and into_raw_parts. Dec 27, 2020
Copy link
Member

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request! I have a few suggestions, but otherwise I agree that these methods would be useful.

src/structures/gdt.rs Outdated Show resolved Hide resolved
src/structures/gdt.rs Outdated Show resolved Hide resolved
src/structures/gdt.rs Outdated Show resolved Hide resolved
src/structures/gdt.rs Outdated Show resolved Hide resolved
src/structures/gdt.rs Outdated Show resolved Hide resolved
@phil-opp phil-opp added the waiting-on-author Waiting for the author to act on review feedback. label Dec 28, 2020
src/structures/gdt.rs Outdated Show resolved Hide resolved
@mental32
Copy link
Member Author

mental32 commented Dec 28, 2020

CI builds for stable are failing for from_raw_parts, should I cfg them behind instructions feature? I just noticed the nightly feature.

Copy link
Member

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! A few nits, then this should be ready for merging.

src/structures/gdt.rs Outdated Show resolved Hide resolved
src/structures/gdt.rs Outdated Show resolved Hide resolved
src/structures/gdt.rs Outdated Show resolved Hide resolved
src/structures/gdt.rs Show resolved Hide resolved
Co-authored-by: Philipp Oppermann <[email protected]>
@phil-opp
Copy link
Member

Thanks a lot!

@phil-opp phil-opp changed the title GDT: Add load_unchecked, from_raw_parts, and into_raw_parts. GDT: Add load_unchecked, from_raw_slice, and as_raw_slice. Dec 28, 2020
@phil-opp phil-opp enabled auto-merge (squash) December 28, 2020 15:36
@phil-opp phil-opp merged commit 77eaadf into rust-osdev:master Dec 28, 2020
phil-opp added a commit that referenced this pull request Dec 28, 2020
@mental32 mental32 deleted the mental/gdt branch December 28, 2020 15:38
@phil-opp phil-opp mentioned this pull request Dec 28, 2020
@phil-opp phil-opp removed the waiting-on-author Waiting for the author to act on review feedback. label Dec 28, 2020
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.

2 participants