more progress on UART read
This commit is contained in:
parent
7265728932
commit
8d5cd862ab
9 changed files with 77 additions and 31 deletions
14
hs/Bus.hs
14
hs/Bus.hs
|
@ -30,6 +30,8 @@ alignCheck addr SizeQuadWord = addr `mod` 16 == 0
|
|||
(ramStart, ramEnd) = (0x80000000 :: Addr, ramStart + (bytesInRam - 1))
|
||||
(uartStart, uartEnd) = (0x10000000 :: Addr, uartStart + 7)
|
||||
|
||||
-- reading/writing from/to UART is implemented as reading/writing
|
||||
-- from/to STDIO, so we need IO.
|
||||
read :: Request -> Peripherals -> IO ReadResponse
|
||||
read (Request addr size) peripherals
|
||||
| not (alignCheck addr size) = return $ ReadResponse $ Error UnAligned
|
||||
|
@ -40,15 +42,3 @@ read (Request addr size) peripherals
|
|||
ramAddrNoOffset = addr - ramStart
|
||||
ramAddr :: RamAddr
|
||||
ramAddr = resize ramAddrNoOffset
|
||||
|
||||
-- | (addr > ramStart) && (addr < ramEnd) = return $ ReadResponse $ Peripherals.Ram.read addr size (ram peripherals)
|
||||
-- | addr >= numBytesInRam = ReadError UnMapped
|
||||
-- case size of
|
||||
-- SizeByte -> BusByte $ fromIntegral $ extractByte (ramRead 0)
|
||||
-- SizeHalfWord -> BusHalfWord $ fromIntegral $ (ramRead 0 `shiftL` 8) .|. ramRead 1
|
||||
-- SizeWord -> BusWord $ fromIntegral $ concatReads [0..3]
|
||||
-- SizeDoubleWord -> BusDoubleWord $ fromIntegral $ concatReads [0..7]
|
||||
-- SizeQuadWord -> BusQuadWord $ fromIntegral $ concatReads [0..15]
|
||||
-- where
|
||||
-- ramRead offset = Peripherals.Ram.read (ram peripherals) (fromIntegral (addr + offset))
|
||||
-- concatReads offsets = foldl (\acc o -> (acc `shiftL` 8) .|. ramRead o) 0 offsets
|
||||
|
|
Reference in a new issue