/// <summary> /// Generic copy (either from kernel or to kernel) /// Determines if the thing we are moving is an endpoint and copies it accordingly. /// </summary> public static Allocation *MoveData(SharedHeap fromHeap, SharedHeap toHeap, Process newOwner, Allocation *data) { if (data == null) { return(data); } if (!fromHeap.Validate(data)) { throw new ArgumentException("Bad argument. Not visible"); } // We can only transfer either into our out of the kernel's heap DebugStub.Assert(fromHeap == SharedHeap.KernelSharedHeap || toHeap == SharedHeap.KernelSharedHeap); if (SystemType.IsSubtype(data, EndpointCoreSystemType)) { // we have an endpoint DeliveryImpl di = EndpointCore.AllocationEndpointDeliveryImpl(data); return(di.MoveEndpoint(fromHeap, toHeap, newOwner)); } else { // we have a NON-endpoint // TODO FIX this! return(null); // MoveNonEndpoint(fromHeap, toHeap, newOwner, data); } }
/// <summary> /// Used internally by the kernel to transfer an endpoint to a new owner /// /// Can be used to transfer ANY kind of shared heap data, not just endpoints. /// </summary> public static Allocation *MoveEndpoint(SharedHeap fromHeap, SharedHeap toHeap, Process newOwner, Allocation *ep) { return(DeliveryImpl.MoveData(fromHeap, toHeap, newOwner, ep)); }
private static void FinalizePreMonitoring() { Stacks.Finalize(); HandleTable.Finalize(); SharedHeap.Finalize(); MemoryManager.Finalize(); }
public static unsafe void TransferFrom( Allocation *allocation, AllocationOwnerId oldOwner) { return(SharedHeap.TransferOwnership( (SharedHeap.Allocation *)allocation, oldOwner, SharedHeap.CurrentProcessSharedHeap.DataOwnerId)); }
public static unsafe void TransferTo( Allocation *allocation, AllocationOwnerId newOwner) { return(SharedHeap.TransferOwnership( (SharedHeap.Allocation *)allocation, SharedHeap.CurrentProcessSharedHeap.DataOwnerId, newOwner)); }
private static void InitGCSupport() { ARM_PROGRESS("Kernel!004"); // Initialize the rest of the primitive runtime. VTable.Initialize((RuntimeType)typeof(Kernel)); ARM_PROGRESS("Kernel!005"); // Must occur before MemoryManager.PostGCInitialize() ProtectionDomain.Initialize(); ARM_PROGRESS("Kernel!006"); // Must occur before SharedHeap.Initialize() MemoryManager.PostGCInitialize(); ARM_PROGRESS("Kernel!007"); // Allocates callback objects for stack growth Stacks.Initialize(); ARM_PROGRESS("Kernel!008"); // Initialize the HAL parts which require GC allocation Platform.ThePlatform.InitializeServices(); ARM_PROGRESS("Kernel!009"); SharedHeap.Initialize(); ARM_PROGRESS("Kernel!010"); // Must occur after SharedHeap.Initialize(); ProtectionDomain.DefaultDomain.InitHook(); }
// // Someone must arrange to call this from *within* the // Protection Domain for us to have an opportunity to finish // initializing. // internal unsafe void InitHook() { // If paging is disabled then just return immediately if (!MemoryManager.UseAddressTranslation) { return; } DebugStub.Assert(AddressSpace.CurrentAddressSpace == this.AddressSpace); if (this.initialized) { // Someone else has already set up the space return; } bool iflag = initSpin.Lock(); try { if (this.initialized) { // Someone else snuck in and initialized return; } // // We're first into this space, so set it up. // #if VERBOSE DebugStub.WriteLine("Setting up protection domain \"{0}\"", __arglist(this.name)); #endif userRange = new VirtualMemoryRange(VMManager.UserHeapBase, VMManager.UserHeapLimit, this); #if PAGING if (kernelMode) { // This will be a ring-0, trusted domain, so just // point the userSharedHeap at the kernel's comm heap. userSharedHeap = SharedHeap.KernelSharedHeap; this.initialized = true; } else { // Create a new shared heap that lives in // user-land. userSharedHeap = new SharedHeap(this, userRange); #if VERBOSE DebugStub.WriteLine(" ...Created a shared heap"); #endif // // N.B.: this is kind of tricky. Loading an // executable image involves allocating memory, // which goes through this object. So, before // attempting the load, mark ourselves as initialized. // // ---- DON'T PUT GENUINE INITIALIZATION // CODE BELOW HERE! --------- this.initialized = true; // Load our own, protection-domain-private copy of the // ABI stubs. These will get shared by all apps in // this domain. IoMemory syscallsMemory = Binder.LoadRawImage("/init", "syscalls.dll"); IoMemory loadedMemory; // Load the stubs library into the user range, but make // the kernel process the logical owner. This seems like // the only sensible approach since the stubs do not // belong to any particular process but must be in the // user range of memory. // N.B.: RE-ENTERS this object! ring3AbiImage = PEImage.Load(Process.kernelProcess, syscallsMemory, out loadedMemory, false, // isForMp false // inKernelSpace ); ring3AbiExports = ring3AbiImage.GetExportTable(loadedMemory); #if VERBOSE DebugStub.WriteLine(" ...Loaded ring-3 ABI stubs"); #endif } #else // PAGING this.initialized = true; #endif // PAGING } finally { DebugStub.Assert(this.initialized); initSpin.Unlock(iflag); } }
/// <summary> /// Move endpoint data to a new process /// </summary> internal abstract Allocation *MoveEndpoint(SharedHeap fromHeap, SharedHeap toHeap, Process newOwner);