riscv haskell: lookupIPCBuffer

This commit is contained in:
Gerwin Klein 2018-06-15 12:20:11 +02:00
parent 2e7c6ed252
commit 537360b065
1 changed files with 16 additions and 3 deletions

View File

@ -62,10 +62,23 @@ copyGlobalMappings newPT = do
{- IPC Buffer Accesses -}
-- physical address of the IPC buffer, if it is accessible
lookupIPCBuffer :: Bool -> PPtr TCB -> Kernel (Maybe (PPtr Word))
lookupIPCBuffer isReceiver thread = error "FIXME RISCV TODO"
-- FIXME RISCV TODO
lookupIPCBuffer isReceiver thread = do
bufferPtr <- threadGet tcbIPCBuffer thread
bufferFrameSlot <- getThreadBufferSlot thread
bufferCap <- getSlotCap bufferFrameSlot
case bufferCap of
ArchObjectCap (FrameCap {capFIsDevice = False, capFBasePtr = basePtr,
capFVMRights = rights, capFSize = sz}) -> do
let pBits = pageBitsForSize sz
if (rights == VMReadWrite || not isReceiver && rights == VMReadOnly)
then do
let ptr = basePtr + PPtr (fromVPtr bufferPtr .&. mask pBits)
assert (ptr /= 0) "IPC buffer pointer must be non-null"
return $ Just ptr
else return Nothing
_ -> return Nothing
{- ASID Lookups -}