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

const fn gdt creation #405

Open
tepperson2 opened this issue Feb 28, 2023 · 4 comments
Open

const fn gdt creation #405

tepperson2 opened this issue Feb 28, 2023 · 4 comments

Comments

@tepperson2
Copy link
Contributor

I would like the ability to create a GlobalDescriptorTable with a const fn. I am writing a kernel and need to ensure that no 64-bit code runs before I jump to long mode because the kernel is started in 32-bit mode. I want to define the gdt structure with rust.

@tepperson2
Copy link
Contributor Author

I just noticed the "const_fn" feature, but I would like to do this on stable rust.

@phil-opp
Copy link
Member

phil-opp commented Mar 1, 2023

The const_fn feature is using the compiler's unstable const_mut_refs feature, which is hopefully stabilized soon. See rust-lang/rust#57349 for the current state. Unfortunately, we don't have any other way to create a GDT in a const environment at the moment. If you have an idea how we could implement it, please let us know!

@tepperson2
Copy link
Contributor Author

I added a pull request #406

@josephlr
Copy link
Contributor

josephlr commented Mar 3, 2023

Note that you can also use GlobalDescriptorTable::from_raw_slice if you want something that works on the current version of stable Rust.

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

No branches or pull requests

3 participants