-
Notifications
You must be signed in to change notification settings - Fork 56
Add a builder to multiboot2 #133
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
Conversation
Hi @YtvwlD I will have a more detailed look in the upcoming days. |
That's great to hear. :) I've tried rebasing this on Monday, but it didn't compile afterwards, sadly. I hope to be able to do it this weekend. |
So, this took a bit longer than expected. :) I've removed error[E0606]: casting `*const Tag` as `*const T` is invalid
--> multiboot2/src/tag_type.rs:307:20
|
307 | unsafe { &*(self as *const Tag as *const T) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: vtable kinds may not match (I've tried to put a minimal example in the playground.) |
Yes, because DSTs uses fat pointers. This is also an existing problem in the multiboot2 crate. I plan to refactor this eventually - If I find some time.. One can fix this with https://crates.io/crates/ptr_meta for example. |
But I', not sure how you can encounter this issue after you rebased your code. I think I didn't change anything in that regard |
|
Ah yes, totally right. I broke the API with that change... the right solution would be to remove cast_tag() and properly support DSTs... a quick fix for you might be to add something like |
ah, I've just reverted the two commits that added it (the last two commits in this PR). |
The msrv fail is because |
I started working on DSTs which should fix your
problem. What do you think about my changes in #132 ? We could also merge your PR first and I adapt it then to my changes. But I'd like to hear if the new API would work in your case. I still hadn't much time to look into your code, unfortunately
I don't have anything against a MSVR bump, but I do not see a benefit in using this abstraction here. Multiboot2 strings and Rust strings are guaranteed to be valid UTF-8, CStrings are not. So I think it would be better to use regular Rust strings and push a final PS: I don't quite understand at this point why your DST additions compile and why you do not have the fat pointer cast problem. |
I don't have any problems with fat pointers (anymore), because here, Casting raw bytes to a struct still requires explicit fat pointers, though (as can be seen in the tests for Having a I'd rebase this PR to keep using |
I'm on vacation right now, so I won't have much capacity for more review in the next 7 days. But overall, the changes look good and I'm looking forward to merging them soon! |
Have fun. :) |
I've had time to review everything. I converted this MR as draft, as there are several points to address before getting this merged. I hope I do not make the contribution process for you too frustrating or so, but this PR is in its current state to big to pass the review process. I'd prefer to have dedicated PRs for the following things:
I think, and as you already said, that the DST approach I took in #132 is more mature. Maybe you can have a look there and tell me if it would work with your contribution. Then we merge it and you can rebase your code onto those changes. I'd highly appreciate if you can address (at least some of) my concerns and improvement suggestions. Otherwise, I'd assist you and do (some) of the work myself. Don't get me wrong, U'm are very happy of merging the changes. But this PR is just to big. PS: You live/are from germany? Wir können auch gerne in nem Video Call oder so bequatschen, wie wir hier am besten weiter machen :D |
Do we want a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks! Please address that one single remark regarding the sections(n) method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. I'm glad we finally can merge it.
I address some open issues and then going to release it in a couple of days.
Thanks, but I'd still like to talk about modifying the memory map. 🙃 |
Via git bisecting, I could find that you might have broke something with commit d198dce Since then, the debug print of the MBI doesn't work anymore and operates on wrong memory. I guess, some pointer magic is now wrong. I try to trace it down and create a unit test for it :) |
Hey, I'm currently working on adding Multiboot 2 support to a bootloader (towboot) and while using the multiboot2 and multiboot2-header crates, I encountered some pieces that were missing.
I particular:
This is mostly just boilerplate, but there were two bigger problems I had to work around:
I've solved this by prefilling the memory map tags with empty entries and overwriting them later on. It seems to work, but it's not pretty.
I made them dynamically sized – which is worse to handle in Rust (you can't put them on the stack anymore).
In addition, since the
ptr_metadata
feature is currently unstable, I used the slice methods instead. (You can probably revert 800567f once it's stable).I tried to adjust the tests and add some where appropriate. If that's not enough, I'll add more. :)
There's one test that fails for me on stable Rust (rustc 1.68.0 (2c8cc3432 2023-03-06)), though it works on nightly (rustc 1.70.0-nightly (900c35403 2023-03-08)).
I tried to keep the changes small. I think eg. that it would be nicer if
Multiboot2Header::from_addr
returned aResult
, but I didn't change it