Refactor SMFI interface and ectool

This commit is contained in:
Jeremy Soller
2020-09-25 19:41:38 -06:00
committed by Jeremy Soller
parent 39e2586c50
commit eff4caa752
19 changed files with 718 additions and 363 deletions

View File

@@ -1,25 +1,28 @@
use hwio::{Io, Pio};
/// Super I/O interface provided by LPC ECs
pub struct SuperIo {
addr: Pio<u8>,
data: Pio<u8>,
}
impl SuperIo {
/// Create a new SuperIo. `base` identifies the address port. The data port
/// will be `base + 1`
pub fn new(base: u16) -> Self {
/// Create a new SuperIo using direct hardware access. `base` identifies the address port. The
/// data port will be `base + 1`. Unsafe due to no mutual exclusion
pub unsafe fn new(base: u16) -> Self {
Self {
addr: Pio::new(base),
data: Pio::new(base + 1),
}
}
/// Read a Super I/O register
pub unsafe fn read(&mut self, addr: u8) -> u8 {
self.addr.write(addr);
self.data.read()
}
/// Write a Super I/O register
pub unsafe fn write(&mut self, addr: u8, data: u8) {
self.addr.write(addr);
self.data.write(data);