rust-osdev / uart_16550

Minimal support for uart_16550 serial output.
MIT License
33 stars 25 forks source link

mmio: use one `VolatilePtr` instead of many `AtomicPtr` #35

Open mkroening opened 4 months ago

mkroening commented 4 months ago

For MMIO the serial port is defined as:

pub struct MmioSerialPort {
    data: AtomicPtr<u8>,
    int_en: AtomicPtr<u8>,
    fifo_ctrl: AtomicPtr<u8>,
    line_ctrl: AtomicPtr<u8>,
    modem_ctrl: AtomicPtr<u8>,
    line_sts: AtomicPtr<u8>,
}

with

        Self {
            data: AtomicPtr::new(base_pointer),
            int_en: AtomicPtr::new(base_pointer.add(1)),
            fifo_ctrl: AtomicPtr::new(base_pointer.add(2)),
            line_ctrl: AtomicPtr::new(base_pointer.add(3)),
            modem_ctrl: AtomicPtr::new(base_pointer.add(4)),
            line_sts: AtomicPtr::new(base_pointer.add(5)),
        }

Instead, it should be only one pointer in size and using volatile operations instead of atomic ones via [#[derive(VolatileFieldAccess)](https://docs.rs/volatile/latest/volatile/derive.VolatileFieldAccess.html).

I can take a look at this in the coming weeks.