Skip to content

Commit

Permalink
squash haskell: PR suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Corey Lewis <[email protected]>
  • Loading branch information
corlewis committed Sep 26, 2024
1 parent 6662cb6 commit 285ecfc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions spec/haskell/src/SEL4/Object/FPU/AARCH64.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {-# SOURCE #-} SEL4.Object.TCB(asUser, threadGet)

import Data.Bits
import Data.Maybe
import Data.Traversable(for)

saveFpuState :: PPtr TCB -> Kernel ()
saveFpuState tcbPtr = do
Expand All @@ -33,10 +34,10 @@ switchLocalFpuOwner :: Maybe (PPtr TCB) -> Kernel ()
switchLocalFpuOwner newOwner = do
doMachineOp enableFpu
curFpuOwner <- gets (armKSCurFPUOwner . ksArchState)
when (isJust curFpuOwner) (saveFpuState (fromJust curFpuOwner))
if isJust newOwner
then loadFpuState (fromJust newOwner)
else doMachineOp disableFpu
for curFpuOwner saveFpuState
case newOwner of
Nothing -> doMachineOp disableFpu
Just tcbPtr -> loadFpuState tcbPtr
modifyArchState (\s -> s { armKSCurFPUOwner = newOwner })

fpuRelease :: PPtr TCB -> Kernel ()
Expand Down
2 changes: 2 additions & 0 deletions spec/haskell/src/SEL4/Object/TCB/AARCH64.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ postSetFlags :: PPtr TCB -> TcbFlags -> Kernel ()
postSetFlags t flags =
when (tcbFlagToWord (ArchFlag FpuDisabled) .&. flags /= 0) (fpuRelease t)

-- Save and clear FPU state before setting the domain of a TCB, to ensure that
-- we do not later write to cross-domain state.
prepareSetDomain :: PPtr TCB -> Domain -> Kernel ()
prepareSetDomain t newDom = do
curDom <- curDomain
Expand Down

0 comments on commit 285ecfc

Please sign in to comment.