x86_64 icon indicating copy to clipboard operation
x86_64 copied to clipboard

Implement function for creating a gdt in a const environment.

Open uglyoldbob opened this issue 2 years ago • 1 comments

As mentioned in another pull request, the form for this function was preferred over the other implementation. #406

uglyoldbob avatar Mar 18 '23 00:03 uglyoldbob

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.

uglyoldbob avatar Mar 22 '24 15:03 uglyoldbob

@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.

uglyoldbob avatar Mar 25 '24 13:03 uglyoldbob

@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?

Freax13 avatar Mar 25 '24 19:03 Freax13

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.

uglyoldbob avatar Mar 25 '24 23:03 uglyoldbob

Any thoughts on what the name of this function should be?

uglyoldbob avatar Mar 25 '24 23:03 uglyoldbob

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?

Freax13 avatar Mar 26 '24 05:03 Freax13

@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?

josephlr avatar Mar 26 '24 21:03 josephlr

I wasn't quite sure the best way to fix it, so i redid the last commit and force pushed it without the merge.

uglyoldbob avatar Mar 26 '24 21:03 uglyoldbob

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?

josephlr avatar Mar 26 '24 21:03 josephlr

It should be ready. I combined it into a single commit.

uglyoldbob avatar Mar 26 '24 21:03 uglyoldbob