Skip to content

Commit

Permalink
PrintJSON: add support for x86 MSI and IOAPIC IRQs
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Velickovic <[email protected]>
  • Loading branch information
Ivan-Velickovic committed Feb 20, 2024
1 parent a001646 commit ccbaffd
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions capDL-tool/CapDL/PrintJSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ data Object =
| Object_PageTable ObjectPageTable
| Object_ASIDPool ObjectASIDPool
| Object_ArmIRQ ObjectArmIRQ
| Object_IRQMSI ObjectIRQMSI
| Object_IRQIOAPIC ObjectIRQIOAPIC
| Object_SchedContext ObjectSchedContext
| Object_Reply
deriving (Eq, Show)
Expand All @@ -94,6 +96,8 @@ instance ToJSON Object where
Object_PageTable obj -> tagged "PageTable" obj
Object_ASIDPool obj -> tagged "AsidPool" obj
Object_ArmIRQ obj -> tagged "ArmIrq" obj
Object_IRQMSI obj -> tagged "IrqMsi" obj
Object_IRQIOAPIC obj -> tagged "IrqIoapic" obj
Object_SchedContext obj -> tagged "SchedContext" obj
Object_Reply -> String "Reply"

Expand All @@ -109,6 +113,8 @@ data Cap =
| Cap_PageTable CapPageTable
| Cap_ASIDPool CapASIDPool
| Cap_ArmIRQHandler CapArmIRQHandler
| Cap_IRQMSIHandler CapIRQMSIHandler
| Cap_IRQIOAPICHandler CapIRQIOAPICHandler
| Cap_SchedContext CapSchedContext
| Cap_Reply CapReply
deriving (Eq, Show)
Expand All @@ -126,6 +132,8 @@ instance ToJSON Cap where
Cap_PageTable cap -> tagged "PageTable" cap
Cap_ASIDPool cap -> tagged "AsidPool" cap
Cap_ArmIRQHandler cap -> tagged "ArmIrqHandler" cap
Cap_IRQMSIHandler cap -> tagged "IrqMSIHandler" cap
Cap_IRQIOAPICHandler cap -> tagged "IrqIOAPICHandler" cap
Cap_SchedContext cap -> tagged "SchedContext" cap
Cap_Reply cap -> tagged "Reply" cap

Expand Down Expand Up @@ -250,6 +258,30 @@ data ObjectArmIRQExtraInfo = ObjectArmIRQExtraInfo
, target :: Word
} deriving (Eq, Show, Generic, ToJSON)

data ObjectIRQMSI = ObjectIRQMSI
{ slots :: CapTable
, extra :: ObjectIRQMSIExtraInfo
} deriving (Eq, Show, Generic, ToJSON)

data ObjectIRQMSIExtraInfo = ObjectIRQMSIExtraInfo
{ pci_bus :: Word
, pci_dev :: Word
, pci_func :: Word
, handle :: Word
} deriving (Eq, Show, Generic, ToJSON)

data ObjectIRQIOAPIC = ObjectIRQIOAPIC
{ slots :: CapTable
, extra :: ObjectIRQIOAPICExtraInfo
} deriving (Eq, Show, Generic, ToJSON)

data ObjectIRQIOAPICExtraInfo = ObjectIRQIOAPICExtraInfo
{ ioapic :: Word
, pin :: Word
, level :: Word
, polarity :: Word
} deriving (Eq, Show, Generic, ToJSON)

data ObjectSchedContext = ObjectSchedContext
{ size_bits :: Word
, extra :: ObjectSchedContextExtraInfo
Expand Down Expand Up @@ -313,6 +345,14 @@ data CapArmIRQHandler = CapArmIRQHandler
{ object :: ObjID
} deriving (Eq, Show, Generic, ToJSON)

data CapIRQMSIHandler = CapIRQMSIHandler
{ object :: ObjID
} deriving (Eq, Show, Generic, ToJSON)

data CapIRQIOAPICHandler = CapIRQIOAPICHandler
{ object :: ObjID
} deriving (Eq, Show, Generic, ToJSON)

data CapSchedContext = CapSchedContext
{ object :: ObjID
} deriving (Eq, Show, Generic, ToJSON)
Expand Down Expand Up @@ -401,6 +441,8 @@ render objSizeMap (C.Model arch objMap irqNode _ coverMap) = Spec
C.CNode slots sizeBits -> Object_CNode (ObjectCNode sizeBits (renderCapTable slots))
C.VCPU -> Object_VCPU
C.ARMIrq slots trigger target -> Object_ArmIRQ (ObjectArmIRQ (renderCapTable slots) (ObjectArmIRQExtraInfo trigger target))
C.MSIIrq slots bus dev fun handle -> Object_IRQMSI (ObjectIRQMSI (renderCapTable slots) (ObjectIRQMSIExtraInfo bus dev fun handle))
C.IOAPICIrq slots ioapic pin ioapic_level polarity -> Object_IRQIOAPIC (ObjectIRQIOAPIC (renderCapTable slots) (ObjectIRQIOAPICExtraInfo ioapic pin ioapic_level polarity))
C.ASIDPool slots (Just asidHigh) -> assert (M.null slots) Object_ASIDPool (ObjectASIDPool asidHigh)
C.RTReply -> Object_Reply
C.TCB
Expand Down Expand Up @@ -467,6 +509,8 @@ render objSizeMap (C.Model arch objMap irqNode _ coverMap) = Spec
C.PDPTCap capObj _ -> Cap_PageTable (CapPageTable (renderId capObj))
C.PML4Cap capObj _ -> Cap_PageTable (CapPageTable (renderId capObj))
C.ARMIRQHandlerCap capObj -> Cap_ArmIRQHandler (CapArmIRQHandler (renderId capObj))
C.IRQMSIHandlerCap capObj -> Cap_IRQMSIHandler (CapIRQMSIHandler (renderId capObj))
C.IRQIOAPICHandlerCap capObj -> Cap_IRQIOAPICHandler (CapIRQIOAPICHandler (renderId capObj))
C.ASIDPoolCap capObj -> Cap_ASIDPool (CapASIDPool (renderId capObj))
C.SCCap capObj -> Cap_SchedContext (CapSchedContext (renderId capObj))
C.RTReplyCap capObj -> Cap_Reply (CapReply (renderId capObj))
Expand Down

0 comments on commit ccbaffd

Please sign in to comment.