-
Notifications
You must be signed in to change notification settings - Fork 26
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
mmio: use one VolatilePtr
instead of many AtomicPtr
#35
Comments
I think besides being volatile, the only thing an atomic pointer would do is make sure that part of a byte isn't written before the other part of the byte (which Rust wouldn't do anyways, but it doesn't promise that it won't). So nothing should break with this change right? I was also confused why the code uses |
@mkroening how would this work with stride (for example with each register takes up 32 bits in MMIO). |
We could make #[derive(VolatileFieldAccess)]
pub struct MmioSerialPort<const PAD: usize = 0> {
data: u8,
__pad1: [u8; PAD],
int_en: u8,
__pad2: [u8; PAD],
fifo_ctrl: u8,
__pad3: [u8; PAD],
line_ctrl: u8,
__pad4: [u8; PAD],
modem_ctrl: u8,
__pad5: [u8; PAD],
line_sts: u8,
__pad6: [u8; PAD],
} What do you think about this approach? |
The I made #39, which still uses 6 different volatile pointers instead of a volatile struct, but I could adjust it to instead have functions like |
I see. Having |
For MMIO the serial port is defined as:
with
Instead, it should be only one pointer in size and using volatile operations instead of atomic ones via
#[derive(VolatileFieldAccess)
.I can take a look at this in the coming weeks.
The text was updated successfully, but these errors were encountered: