sdio-adma2-refactor #34
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "sdio-adma2-refactor"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
@pca006132 Every commit compiles for me, so you can review and pick them one by one.
Apart from removing that one global
static mut
and theattribute.modify()
, the changes are not supposed to change the build. They still need to be tested as I don't know what data to expect from the Sdcard.Still thinking about undefined behavior...
https://doc.rust-lang.org/std/mem/union.MaybeUninit.html#method.as_mut_ptr
https://doc.rust-lang.org/std/mem/union.MaybeUninit.html#incorrect-usages-of-this-method-1
From what I've seen, it seems that the only safe way is to use
write
to write to the uninit memory directly without referencing any of its content. However, withbitfield
andVolatileCell
, we cannot initialize the struct directly without unsafe operations like transmute or something like that...I'm thinking if it would be easier to just stick with the current implementation... I think the volatile register crate was meant to be used with memory mapped registers but not a generic volatile cell, so it did not implement
Copy
.I cannot think of any safer way to circumvent that, and it seems that implementing a custom
VolatileCell
withCopy
would also be weird, as we cannot enforce theCopy
to be volatile. (or not, not familiar with this)@sb10q what do you think?
Good point. I'm going to look if we can just 0-initialize instead.
I wonder if
align(4)
would be correct... from the SD Specification Part A2, the ADMA2 descriptor table format is:OK nevermind, I think I misunderstood the alignment attribute, it is for the whole struct instead of individual fields.
I've tested it and it works, I think we can merge it.