From e71fad3a8d1fb840d32e745ff88f7c9843d8c2ae Mon Sep 17 00:00:00 2001 From: Ivan Velickovic Date: Tue, 20 Feb 2024 11:37:13 +1100 Subject: [PATCH 1/2] PrintJSON: add support for x86 MSI and IOAPIC IRQs Signed-off-by: Ivan Velickovic --- capDL-tool/CapDL/PrintJSON.hs | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/capDL-tool/CapDL/PrintJSON.hs b/capDL-tool/CapDL/PrintJSON.hs index 69a347e..714045c 100644 --- a/capDL-tool/CapDL/PrintJSON.hs +++ b/capDL-tool/CapDL/PrintJSON.hs @@ -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) @@ -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" @@ -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) @@ -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 @@ -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 @@ -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) @@ -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 @@ -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)) From 5756c76dbe702cd46090b9bf60d0e1fa9818a82b Mon Sep 17 00:00:00 2001 From: Ivan Velickovic Date: Tue, 20 Feb 2024 13:48:53 +1100 Subject: [PATCH 2/2] PrintJSON: fix typo Signed-off-by: Ivan Velickovic --- capDL-tool/CapDL/PrintJSON.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capDL-tool/CapDL/PrintJSON.hs b/capDL-tool/CapDL/PrintJSON.hs index 714045c..9f9fa0a 100644 --- a/capDL-tool/CapDL/PrintJSON.hs +++ b/capDL-tool/CapDL/PrintJSON.hs @@ -126,7 +126,7 @@ 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