tool: Move read_debug to trait so generic code can use it

Returns error for backends that don't support it.
This commit is contained in:
Ian Douglas Scott
2021-02-18 14:14:44 -08:00
committed by Jeremy Soller
parent 0c1584385c
commit 504284bf72
4 changed files with 16 additions and 12 deletions

View File

@ -71,12 +71,6 @@ impl AccessLpcSim {
self.outb(SMFI_CMD_BASE + u16::from(addr), data)
}
/// Read from the debug space
//TODO: better public interface
pub unsafe fn read_debug(&mut self, addr: u8) -> Result<u8, Error> {
self.inb(SMFI_DBG_BASE + u16::from(addr))
}
/// Returns Ok if a command can be sent
unsafe fn command_check(&mut self) -> Result<(), Error> {
if self.read_cmd(SMFI_CMD_CMD)? == 0 {
@ -121,4 +115,8 @@ impl Access for AccessLpcSim {
fn data_size(&self) -> usize {
SMFI_CMD_SIZE - SMFI_CMD_DATA as usize
}
unsafe fn read_debug(&mut self, addr: u8) -> Result<u8, Error> {
self.inb(SMFI_DBG_BASE + u16::from(addr))
}
}