MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / read_byte

Method read_byte

crates/virtual-machine/src/devices/keyboard.rs:79–89  ·  view source on GitHub ↗
(&mut self, addr: u64)

Source from the content-addressed store, hash-verified

77impl MemoryAccess for Keyboard {
78 fn read_byte(&mut self, addr: u64) -> Result<u8, VmError> {
79 let a = addr as usize;
80 if a >= KBD_TOTAL_BYTES {
81 return Err(VmError::BusError(addr));
82 }
83 // A byte read returns the matching byte of the register word. Reading the
84 // DATA byte still pops, so guests should use a word read.
85 let reg = a & !0x3;
86 let shift = (a & 0x3) * 8;
87 Ok((self.read_reg(reg) >> shift) as u8)
88 }
89
90 fn read_word(&mut self, addr: u64) -> Result<u32, VmError> {
91 let a = addr as usize;
92 if a + 4 > KBD_TOTAL_BYTES {

Callers

nothing calls this directly

Calls 1

read_regMethod · 0.80

Tested by

no test coverage detected