x86_64
x86_64 copied to clipboard
Implement function for creating a gdt in a const environment.
As mentioned in another pull request, the form for this function was preferred over the other implementation. #406
For some reason, I am just now seeing your comments on the pull request. I will look into it in the next week or so.
@Freax13 I think the function I added with this pull request is a bit redundant now that I see the const_fn feature in the crate, however I do need a way to generate a GdtTablePointer with a const fn.
@Freax13 I think the function I added with this pull request is a bit redundant now that I see the const_fn feature in the crate,
Yeah, you're right. I'm sorry about that, we had some breaking changes in the next branch for a really long time to the point where even we maintainers forgot some of the changes.
however I do need a way to generate a GdtTablePointer with a const fn.
That won't be easy. Our DescriptorTablePointer type uses a VirtAddr for the base field. VirtAddr stores the address as a u64 and Rust doesn't allow casting a pointer to a u64 during const evaluation. I think the best way here is to go with your original plan of adding a len function to query the number of entries in the GDT and then use that with your custom type.
Just out of curiosity, what's your use case for creating the pointer at compile time?
No worries on the changes. I am writing a kernel, that boots into a 32-bit assembly stub to bring the system into long mode. I need a valid gdt pointer for the lgdt command and containing the struct in rust code seemed more convenient than trying to do the same thing in an assembly file. See here and here for some details.
Any thoughts on what the name of this function should be?
Any thoughts on what the name of this function should be?
limit seems reasonable to me. Can you move the function down (before or after pointer) and also change pointer to use it?
@uglyoldbob @tepperson2 something seems to have gotten messed up on this PR, it's showing >1000 lines changed. Could you fix this PR to only include the last two commits?
I wasn't quite sure the best way to fix it, so i redid the last commit and force pushed it without the merge.
I wasn't quite sure the best way to fix it, so i redid the last commit and force pushed it without the merge.
Can you rebase onto the latest master so that there aren't conflicts?
It should be ready. I combined it into a single commit.