Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork175
mem: introduce traits MemoryMap and MemoryMapMut#1234
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
4eb4b7f
to1197782
Compare
Could the kernel take ownership of this memory and use the existing |
phip1611 commentedJul 8, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Don't think so (from a library standpoint) . Most abstraction for boot loader information provide you only |
Only |
phip1611 commentedJul 9, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Yes, there were actually requests to be able to modify structures, such as the memory map. For example in themultiboot2 repository. Limine's boot protocol, or to be more specific, the limine crate, also provides you witha slice/a buffer - this is however not mutable yet - but it could be extended in the future. Note that we need mutable access so that one can call the I'm not sure if the proposed solution is 100% perfect - but it enables all use cases users will have - giving developers maximum freedom. What do you think about this? What about the other questions mentioned above? |
Makes sense. I haven't looked through the details of the PR yet (doing so now), I just wanted to make sure I understood how it would be used at a high level first. |
This seems to work: pubtraitMemoryMap:Debug +Index<usize,Output =MemoryDescriptor>{ (At least, it compiles, I didn't test it thoroughly.) |
Uh oh!
There was an error while loading.Please reload this page.
I think it's OK as-is, there is some code repetition but it's not too bad. |
This provides API users all the flexibility they need. The main motivation forthe addition is that one can use a chunk of memory in a kernel (provided by abootloader) and parse it as EFI memory map. The main motivation for the specificimplementation (via traits) is code reduction.
phip1611 commentedJul 14, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'll do/try this in a follow-up (#1240 ). So,@nicholasbishop , what do you think? I know, I did a major overhaul of the MemoryType API in the past weeks. But I think it is worth it and that we now reached it a point where it is mature and sustainable. However, I'm also biased 😁 What do you think? |
I think it's a reasonable change, looks good to me. FWIW I don't think there's anything wrong with making more API changes after a recent API change if we realize that more improvements are needed. For me the important thing is that it's easy for users of the API to update their code when updating to a new version of uefi-rs. And certainly for these changes I don't think there's any problem there, it's very straightforward to change |
380f98f
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
In#1175 we lost the flexibility to use the memory map on any buffer. However, if you write a kernel and get the raw memory map from your bootloader, one has to parse the memory map from this raw memory. To solve this (leveraging the
uefi
crate), I introduced:MemoryMap
andMemoryMapMut
, whereMemoryMapMut
extendsMemoryMap
MemoryMapRef
,MemoryMapRefMut
, andMemoryMapOwned
, where the latter two implementMemoryMapMut
This helps to have a common API for all these use-cases. However, there are the
following open questions:
Index
andIndexMut
which I have to provide 3 times. Any idea for improvement? Just use a macro?Index
andIndexMut
- I gave up after many compiler warnings.Checklist