//////////////////////////////////////////////////////////////////////////////// // // Microsoft Research Singularity - Singularity ABI // // Copyright (c) Microsoft Corporation. All rights reserved. // // File: ChannelService.csi // // Note: // using System; using System.Runtime.CompilerServices; using Microsoft.Singularity; using Microsoft.Singularity.V1.Security; using Microsoft.Singularity.V1.Threads; using Microsoft.Singularity.V1.Types; using Allocation = Microsoft.Singularity.V1.Services.SharedHeapService.Allocation; namespace Microsoft.Singularity.V1.Services { [CLSCompliant(false)] unsafe public struct EndpointCore { /// /// Used to allocate a channel endpoint. The size must be correctly computed by /// the trusted caller (currently trusted code NewChannel) /// [NoHeapAllocation] public static Allocation* //EndpointCore* opt(ExHeap)! Allocate(uint size, SystemType st); /// /// Closes this end of the channel and frees associated resources, EXCEPT the block /// of memory for this endpoint. It must be released by the caller. Sing# does this /// for the programmer. /// Returns true for success, false for failure. /// [NoHeapAllocation] public static bool Dispose(ref EndpointCore endpoint); /// /// Deallocates this end of the channel. If other end is also /// deallocated, the entire channel is deallocated. /// [NoHeapAllocation] public static void Free(Allocation* /* EndpointCore* opt(ExHeap) */ endpoint); /// /// Performs the initialization of the core part of each endpoint and cross links /// them to form a channel. /// [NoHeapAllocation] public static void Connect( Allocation* /*EndpointCore* opt(ExHeap)!*/ imp, Allocation* /*EndpointCore* opt(ExHeap)!*/ exp, Allocation* /*EndpointCore* opt(ExHeap)!*/ ep); /// /// Indicates if this endpoint is closed /// [NoHeapAllocation] public static bool Closed(ref EndpointCore ep); /// /// Indicates if this endpoint is closed /// [NoHeapAllocation] public static bool PeerClosed(ref EndpointCore ep); /// /// Indicates if this endpoint is closed (ABI call version) /// [NoHeapAllocation] public static bool PeerClosedABI(ref EndpointCore ep); /// /// Set this endpoint to closed /// [NoHeapAllocation] public static void Close(ref EndpointCore ep); /// /// The endpoint to which this endpoint is connected. /// [NoHeapAllocation] public static Allocation* /*EndpointCore* opt(ExHeap) */ GetPeer(ref EndpointCore ep, out bool marshall); /// /// The endpoint to which this endpoint is connected. (ABI version) /// [NoHeapAllocation] public static Allocation* GetPeerABI(ref EndpointCore ep, out bool marshall); /// /// The event to wait for messages on this endpoint. Used by Select. /// [NoHeapAllocation] public static SyncHandle GetWaitHandle(ref EndpointCore ep); /// /// Notify the the peer endpoint that a message is ready. /// Notifies the set if the peer endpoint is part of a set. /// [NoHeapAllocation] public static void NotifyPeer(ref EndpointCore ep); /// /// Wait for a message to arrive on this endpoint. /// [NoHeapAllocation] public static void Wait(ref EndpointCore ep); /// /// Transfer the given Allocation block to the target endpoint /// [NoHeapAllocation] public static void TransferBlockOwnership(Allocation* ptr, ref EndpointCore target); /// /// Transfer any contents that needs to be adjusted from the transferee to the target /// endpoint. /// [NoHeapAllocation] public static void TransferContentOwnership( ref EndpointCore transferee, ref EndpointCore target); [NoHeapAllocation] public static void AcceptDelegation(Allocation* /*EndpointCore* opt(ExHeap)!*/ imp, Allocation* /*EndpointCore* opt(ExHeap)!*/ exp, Allocation* /*EndpointCore* opt(ExHeap)!*/ ep); [NoHeapAllocation] public static void EnableDelegation(ref EndpointCore ep, bool allowMediation); /// /// Obtain the process identifier of the owner. /// [NoHeapAllocation] public static int GetOwnerProcessID(ref EndpointCore ep); /// /// Obtain the principal identifier of the owner. /// [NoHeapAllocation] public static PrincipalHandle GetOwnerPrincipalHandle(ref EndpointCore ep); /// /// Obtain the process identifier of the owner of the other endpoint /// [NoHeapAllocation] public static int GetPeerProcessID(ref EndpointCore ep); /// /// Obtain the process identifier of the owner of the other endpoint (ABI version) /// [NoHeapAllocation] public static int GetPeerProcessIDABI(ref EndpointCore ep); /// /// Obtain the principal identifier of the owner of the other endpoint /// [NoHeapAllocation] public static PrincipalHandle GetPeerPrincipalHandle(ref EndpointCore ep); /// /// Obtain the channel identifier of this endpoint. /// [NoHeapAllocation] public static int GetChannelID(ref EndpointCore ep); /// /// Instruct the selectable object to signal events on the given AutoResetEvent /// rather than its normal event in order to aggregate signalling into a set. /// A selectable object need only support being part of a single collection at /// any point in time. /// [NoHeapAllocation] public static void LinkIntoCollection(ref EndpointCore ep, AutoResetEventHandle ev); /// /// Instruct the selectable object to stop signalling events on the given /// AutoResetEvent. /// [NoHeapAllocation] public static void UnlinkFromCollection(ref EndpointCore ep, AutoResetEventHandle ev); /// /// Called when sending a message across domains. Instructs the kernel /// to prepare an update record to push into the peer when the peer /// is running. /// /// This call starts a sequence of MarshallPointer calls that will /// end with a call to NotifyPeer. /// [NoHeapAllocation] unsafe public static void MarshallMessage(ref EndpointCore ep, byte* basep, byte* source, int* tagAddress, int msgSize); [NoHeapAllocation] unsafe public static void MarshallPointer(ref EndpointCore ep, byte* basep, byte** target, SystemType type, byte* parent, int offset); } }