packages feed

hsXenCtrl 0.0.4 → 0.0.5

raw patch · 2 files changed

+159/−1 lines, 2 files

Files

System/Xen/CBindings.hsc view
@@ -65,6 +65,44 @@     , xc_memory_op     , xc_get_pfn_type_batch     , xc_get_tot_pages+    -- Trace buffer operations+    , xc_tbuf_enable+    , xc_tbuf_disable+    , xc_tbuf_get_size+    , xc_tbuf_set_cpu_mask+    , xc_tbuf_set_evt_mask+    , xc_domctl+    , xc_sysctl+    , xc_version+    , xc_acm_op+    -- Grant table operations+    , GTHandle (..)+    , xc_gnttab_open+    , xc_gnttab_close+    , xc_gnttab_map_grant_ref+    , xc_gnttab_map_grant_refs+    , xc_gnttab_munmap+    , DomId_t+    , xc_hvm_set_pci_intx_level+    , xc_hvm_set_isa_irq_level+    , xc_hvm_set_pci_link_route+    -- Error handling operations+    , XCErrorCode(..)+    , xcMaxErrorMsgLen+    , XCError(..)+    , xc_get_last_error+    , xc_clear_last_error+    , XCErrorHandler+    , xc_default_error_handler+    , xc_error_code_to_desc+    , xc_set_error_handler+    , xc_set_hvm_param+    , xc_get_hvm_param+    , xc_alloc_real_mode_area+#if defined(__ia64__)+    , xc_ia64_save_to_nvram+    , xc_ia64_nvram_init+#endif     -- Start data types     , xc_CORE_MAGIC     , xc_CORE_MAGIC_HVM@@ -538,6 +576,126 @@  foreign import ccall unsafe "xenctrl.h xc_get_tot_pages"     xc_get_tot_pages :: XCHandle -> DomId -> IO CLong++-- Trace buffer operations+foreign import ccall unsafe "xenctrl.h xc_tbuf_enable"+    xc_tbuf_enable :: XCHandle -> CULong -> Ptr CULong -> Ptr CULong -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_tbuf_disable"+    xc_tbuf_disable :: XCHandle -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_tbuf_get_size"+    xc_tbuf_get_size :: XCHandle -> Ptr CULong -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_tbuf_set_cpu_mask"+    xc_tbuf_set_cpu_mask :: XCHandle -> Word32 -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_tbuf_set_evt_mask"+    xc_tbuf_set_evt_mask :: XCHandle -> Word32 -> IO CInt++data XenDomCtl = XenDomCtl+data XenSysCtl = XenSysCtl++foreign import ccall unsafe "xenctrl.h xc_domctl"+    xc_domctl :: XCHandle -> Ptr XenDomCtl -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_sysctl"+    xc_sysctl :: XCHandle -> Ptr XenSysCtl -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_version"+    xc_version :: XCHandle -> CInt -> Ptr () -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_acm_op"+    xc_acm_op :: XCHandle -> CInt -> Ptr () -> CULong -> IO CInt++-- Grant Table Operations++newtype GTHandle = GTHandle CInt deriving (Eq, Ord, Show)++instance Storable GTHandle where+    sizeOf _ = sizeOf (undefined :: CInt)+    alignment _ = alignment (undefined :: CInt)+    peek ptr = peek (castPtr ptr) >>= return . GTHandle+    poke ptr (GTHandle h) = poke (castPtr ptr) h++foreign import ccall unsafe "xenctrl.h xc_gnttab_open"+    xc_gnttab_open :: IO CInt -- Does not return GTHandle because (-1) can be returned.++foreign import ccall unsafe "xenctrl.h xc_gnttab_close"+    xc_gnttab_close :: GTHandle -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_gnttab_map_grant_ref"+    xc_gnttab_map_grant_ref :: GTHandle -> DomId -> Word32 -> CInt -> IO (Ptr a)++foreign import ccall unsafe "xenctrl.h xc_gnttab_map_grant_refs"+   xc_gnttab_map_grant_refs :: GTHandle -> Word32 -> Ptr Word32 -> Ptr Word32 -> CInt -> IO (Ptr a)++foreign import ccall unsafe "xenctrl.h xc_gnttab_munmap"+    xc_gnttab_munmap :: GTHandle -> Ptr a -> Word32 -> IO CInt++-- FIXME: Why does much of Xen use uint32_t for 'dom' args then have a 16 bit domid_t?+type DomId_t = Word16 ++foreign import ccall unsafe "xenctrl.h xc_hvm_set_pci_intx_level"+    xc_hvm_set_pci_intx_level :: XCHandle -> DomId_t -> Word8 -> Word8 -> Word8 -> Word8 -> CUInt -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_hvm_set_isa_irq_level"+      xc_hvm_set_isa_irq_level :: XCHandle -> DomId_t -> Word8 -> CUInt -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_hvm_set_pci_link_route"+      xc_hvm_set_pci_link_route :: XCHandle -> DomId_t -> Word8 -> Word8 -> IO CInt++data XCErrorCode = XCErrorNone | XCInternalError | XCInvalidKernel | XCInvalidParam | XCOutOfMemory+    deriving (Eq, Ord, Show, Enum)++instance Storable XCErrorCode where+    sizeOf _ = sizeOf (undefined :: CInt)+    alignment _ = alignment (undefined :: CInt)+    peek ptr = peek (castPtr ptr :: Ptr CInt) >>= return . toEnum . fromIntegral+    poke ptr a = poke (castPtr ptr) (fromIntegral (fromEnum a) :: CInt)++xcMaxErrorMsgLen = 1024++data XCError = XCError { xceCode :: XCErrorCode, xceMsg :: B.ByteString } deriving (Eq, Ord, Show)++foreign import ccall unsafe "xenctrl.h xc_get_last_error"+      xc_get_last_error :: IO (Ptr XCError)++foreign import ccall unsafe "xenctrl.h xc_clear_last_error"+      xc_clear_last_error :: IO ()++type XCErrorHandler = FunPtr (XCError -> IO ())++foreign import ccall unsafe "xenctrl.h xc_default_error_handler"+      xc_default_error_handler :: Ptr XCErrorHandler -> IO ()++-- arg1 should be XCErrorCode, but GHC rejects that+foreign import ccall unsafe "xenctrl.h xc_error_code_to_desc"+      xc_error_code_to_desc_c :: CInt -> IO CString++xc_error_code_to_desc :: XCErrorCode -> IO CString+xc_error_code_to_desc c = do+    xc_error_code_to_desc_c (fromIntegral $ fromEnum c)++foreign import ccall unsafe "xenctrl.h xc_set_error_handler"+      xc_set_error_handler :: XCErrorHandler -> IO XCErrorHandler++foreign import ccall unsafe "xenctrl.h xc_set_hvm_param"+      xc_set_hvm_param :: XCHandle -> DomId_t -> CInt -> CULong -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_get_hvm_param"+      xc_get_hvm_param :: XCHandle -> DomId_t -> CInt -> Ptr CULong -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_alloc_real_mode_area"+      xc_alloc_real_mode_area :: XCHandle -> DomId -> CUInt -> IO CInt++#if defined(__ia64__)+foreign import ccall unsafe "xenctrl.h xc_ia64_save_to_nvram"+      xc_ia64_save_to_nvram :: XCHandle -> DomId -> IO CInt++foreign import ccall unsafe "xenctrl.h xc_ia64_nvram_init"+      xc_ia64_nvram_init :: XCHandle -> CString -> DomId -> IO CInt+#endif  -- Data and functions for debugging data XC_Core_Header = XC_Core_Header {
hsXenCtrl.cabal view
@@ -1,5 +1,5 @@ name:                hsXenCtrl-version:             0.0.4+version:             0.0.5 synopsis:            FFI bindings to the Xen Control library. description:         FFI bindings to xenctrl.h and perhaps more.                      The System.Xen.CBindings should provide direct access