Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrintJSON: add support for x86 MSI and IOAPIC IRQs, fix typo #1

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion 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 @@ -120,12 +126,14 @@ instance ToJSON Cap where
Cap_Notification cap -> tagged "Notification" cap
Cap_CNode cap -> tagged "CNode" cap
Cap_TCB cap -> tagged "Tcb" cap
Cap_IRQHandler cap -> tagged "IRQHandler" cap
Cap_IRQHandler cap -> tagged "IrqHandler" cap
Cap_VCPU cap -> tagged "VCpu" cap
Cap_Frame cap -> tagged "Frame" cap
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
{ handle:: Word
, pci_bus :: Word
, pci_dev :: Word
, pci_func :: 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 handle bus dev fun -> Object_IRQMSI (ObjectIRQMSI (renderCapTable slots) (ObjectIRQMSIExtraInfo handle bus dev fun))
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