-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aarch64 haskell+design: update exec spec to use semi-lazy FPU switching
Signed-off-by: Corey Lewis <[email protected]>
- Loading branch information
Showing
25 changed files
with
191 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(* | ||
* Copyright 2024, Proofcraft Pty Ltd | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-only | ||
*) | ||
|
||
chapter "FPU" | ||
|
||
theory FPU_H | ||
imports | ||
Hardware_H | ||
TCBDecls_H | ||
begin | ||
context Arch begin arch_global_naming (H) | ||
|
||
#INCLUDE_HASKELL SEL4/Object/FPU/AARCH64.hs CONTEXT AARCH64_H ArchInv=Arch | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
-- | ||
-- Copyright 2024, Proofcraft Pty Ltd | ||
-- | ||
-- SPDX-License-Identifier: GPL-2.0-only | ||
-- | ||
|
||
{-# LANGUAGE CPP #-} | ||
|
||
module SEL4.Object.FPU.AARCH64 where | ||
|
||
--{-# BOOT-IMPORTS: SEL4.Machine SEL4.Object.TCB #-} | ||
--{-# BOOT-EXPORTS: saveFpuState loadFpuState switchLocalFpuOwner fpuRelease #-} | ||
|
||
import SEL4.Machine | ||
import SEL4.Model | ||
import SEL4.Object.Structures | ||
import SEL4.Machine.Hardware.AARCH64 | ||
import SEL4.Machine.RegisterSet.AARCH64 | ||
import SEL4.Model.StateData.AARCH64 | ||
import {-# SOURCE #-} SEL4.Object.TCB(asUser, threadGet) | ||
|
||
import Data.Bits | ||
import Data.Maybe | ||
|
||
saveFpuState :: PPtr TCB -> Kernel () | ||
saveFpuState tcbPtr = do | ||
fpuState <- doMachineOp readFpuState | ||
asUser tcbPtr (setFPUState fpuState) | ||
|
||
loadFpuState :: PPtr TCB -> Kernel () | ||
loadFpuState tcbPtr = do | ||
fpuState <- asUser tcbPtr getFPUState | ||
doMachineOp (writeFpuState fpuState) | ||
|
||
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 | ||
modifyArchState (\s -> s { armKSCurFPUOwner = newOwner }) | ||
|
||
fpuRelease :: PPtr TCB -> Kernel () | ||
fpuRelease tcbPtr = do | ||
curFpuOwner <- gets (armKSCurFPUOwner . ksArchState) | ||
when (curFpuOwner /= Just tcbPtr) (switchLocalFpuOwner Nothing) | ||
|
||
lazyFpuRestore :: PPtr TCB -> Kernel () | ||
lazyFpuRestore tcbPtr = do | ||
flags <- threadGet tcbFlags tcbPtr | ||
if (tcbFlagToWord (ArchFlag FpuDisabled) .&. flags /= 0) | ||
then doMachineOp disableFpu | ||
else do | ||
doMachineOp enableFpu | ||
switchLocalFpuOwner (Just tcbPtr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.