示例#1
0
 private void RangeCheck(uint value, uint max, string name)
 {
     if (value > max)
     {
         DebugStub.Break();
     }
 }
示例#2
0
 public void Write32(int offset, uint value)
 {
     if (!PciPortHandle.Write32(handle, offset, value))
     {
         DebugStub.Break();
     }
 }
示例#3
0
        public override void EnableIrq(byte irq)
        {
            if (irq >= INTCPS_Vectors)
            {
                DebugStub.Break();
                // throw new OverflowException
                // (String.Format("irq {0} out of range.", irq));
            }

#if DEBUG_INTERRUPTS
            DebugStub.WriteLine("Int{0:x2}  Enable, Mask={3:x8}{2:x8}{1:x8}",
                                __arglist(irq, irqMask0, irqMask1, irqMask2));
#endif

            bool saved = Processor.DisableInterrupts();
            try {
                Unmask(irq);
#if PIC_DEBUG
                DumpRegisters();
#endif
            }
            finally {
                Processor.RestoreInterrupts(saved);
            }
        }
示例#4
0
        public Bytes GetNextBuffer(out int start, out int length)
        {
            if (this.Empty)
            {
                start  = -1;
                length = -1;
                return(null);
            }

            if (this.currentTxBuff == null)
            {
                this.currentTxBuff         = this.listHead.next;
                this.currentTxTotalOffset  = 0;
                this.currentTxBufferOffset = this.currentTxBuff.startOffset;
            }
            else
            {
                this.currentTxBuff         = this.currentTxBuff.next;
                this.currentTxBufferOffset = this.currentTxBuff.startOffset;
                if (this.currentTxBuff == this.listTail)
                {
                    DebugStub.Print("GetBuffer: Empty list???\n");
                    DebugStub.Break();
                    start  = -1;
                    length = -1;
                    return(null);
                }
            }
            start  = (int)this.currentTxBuff.startOffset;
            length = (int)this.currentTxBuff.length;

            return(this.currentTxBuff.data);
        }
示例#5
0
        public Bytes PopAllPackets()
        {
            Bytes packet;
            int   sizeOfData;
            Bytes buffer;

            if (byteCount <= 0)
            {
                DebugStub.WriteLine("UDP PopAllPackets: no data???\n");
                DebugStub.Break();
                return(null);
            }
            using (thisLock.Lock()) {
                DebugPrint("Popping {0} bytes of data to client\n", byteCount);
                buffer = new Bytes(new byte[byteCount]);

                VectorQueueByte incomingPacketQueue = packetContainer.Acquire();
                int             offset = 0;
                while ((packet = incomingPacketQueue.ExtractHead()) != null)
                {
                    VTable.Assert(packet != null);
                    Bitter.Copy(buffer, offset, packet.Length, packet, 0);
                    offset    += packet.Length;
                    byteCount -= packet.Length;
                    //delete packet;
                }
                packetContainer.Release(incomingPacketQueue);
                DebugStub.Assert(byteCount == 0);
            }
            return(buffer);
        }
示例#6
0
 public void Write8(int offset, byte value)
 {
     if (!PciPortHandle.Write8(handle, offset, value))
     {
         DebugStub.Break();
     }
 }
示例#7
0
        public static void Assert(bool assertion)
        {
            if (!assertion)
            {
                DebugStub.WriteLine("assertion failure, stack trace:");
#if !SINGULARITY
                StackTrace st          = new StackTrace(true);
                string     stackIndent = "";
                for (int i = 0; i < st.FrameCount; i++)
                {
                    // Low down the call stack there are four
                    // stack frames, one for each method invocation.
                    StackFrame sf = st.GetFrame(i);
                    Console.WriteLine("\n" + stackIndent + " Method: {0}",
                                      sf.GetMethod());
                    Console.WriteLine(stackIndent + " File: {0}", sf.GetFileName());
                    Console.WriteLine(stackIndent + " Line Number: {0}",
                                      sf.GetFileLineNumber());
                    stackIndent += "  ";
                }
#endif
                DebugStub.Break();
                throw new Exception("Assertion failed");
            }
        }
示例#8
0
        internal static unsafe UIntPtr GetStackSegment(UIntPtr size,
                                                       ref ThreadContext context,
                                                       bool kernelAllocation,
                                                       bool initialStack)
        {
#if SINGULARITY_LINKED_STACKS
#else
            if (!initialStack)
            {
                // If we get here, then the initial stack size must not have
                // been sufficient to ensure that we don't need linked stacks.
                DebugStub.Break();
            }
#endif
            UIntPtr begin = context.stackBegin;
            UIntPtr limit = context.stackLimit;
#if DO_TRACE_STACKS
            Kernel.Waypoint(666);
#endif
            StackHead *head = GetStackSegmentRaw(size, ref context, kernelAllocation, initialStack);
            if (head != null)
            {
                head->prevBegin = begin;
                head->prevLimit = limit;
                head->esp       = 0;
            }
            return((UIntPtr)head);
        }
示例#9
0
        public static ExternalProcessState GetState(ProcessHandle handle)
        {
            Process process = HandleTable.GetHandle(handle.id) as Process;

            switch (process.State)
            {
            case InternalProcessState.Unstarted:
            case InternalProcessState.Running:
                return(ExternalProcessState.Active);

            case InternalProcessState.Suspending:
            case InternalProcessState.SuspendingRecursive:
            case InternalProcessState.Suspended:
                return(ExternalProcessState.Suspended);

            case InternalProcessState.Stopping:
            case InternalProcessState.Stopped:
                return(ExternalProcessState.Stopped);

            default:
                // handle new missing case
                DebugStub.Break();
                return(ExternalProcessState.Stopped);
            }
        }
示例#10
0
        private void TxExchange()
        {
            int toCount   = 0;
            int fromCount = 0;

            NicDeviceContract /*.Imp*/ imp = (NicDeviceContract)nicChannel.Acquire();

            try {
                PacketFifo src  = this.txFifo.Acquire();
                PacketFifo free = this.txFreeFifo.Acquire();

                toCount = src.Count;
                try {
                    src = imp.GiveTxPacketsToDevice(src);

                    fromCount = src.Count;
                    free.Push(src);
                }
                finally {
                    this.txFreeFifo.Release(free);
                    this.txFifo.Release(src);
                }
            }
            catch (Exception e) {
                DebugStub.Print("TxExchange FAILED arg {0}\n", DebugStub.ArgList(e.ToString()));
                DebugStub.Break();
            }
            finally {
                nicChannel.Release(imp);
            }
            DebugPrint("TxExchange out: {0} in: {1}\n",
                       toCount, fromCount);
        }
示例#11
0
        //| <include path='docs/doc[@for="Assert.Fail"]/*' />
        public static void Fail(String conditionString, String message)
        {
            // Run through the list of filters backwards (the last filter in the list
            // is the default filter. So we're guaranteed that there will be at least
            // one filter to handle the assert.

            int iTemp = iNumOfFilters;

            while (iTemp > 0)
            {
                AssertFilters iResult = ListOfFilters [--iTemp].AssertFailure(conditionString, message);

                if (iResult == AssertFilters.FailDebug)
                {
#if SINGULARITY_KERNEL
                    DebugStub.Break();
#elif SINGULARITY_PROCESS
                    VTable.DebugBreak();
#endif
                    break;
                }
                else if (iResult == AssertFilters.FailTerminate)
#if SINGULARITY_KERNEL
                { Kernel.Shutdown(-1); }
#elif SINGULARITY_PROCESS
                { AppRuntime.Stop(-1); }
示例#12
0
        // template for static creation method
        new public static EachSourceClass Create(string sourcename,
                                                 uint size,
                                                 uint storageOptions,
                                                 uint sourceFlags)
        {
            EventingStorage storage = EventingStorage.CreateLocalStorage(storageOptions,
                                                                         size);

            if (storage == null)
            {
                DebugStub.WriteLine("Failure to create local storage " + sourcename);
                DebugStub.Break();
                return(null);
            }

            EachSourceClass Source = new EachSourceClass_Impl(sourcename,
                                                              storage,
                                                              sourceFlags);

            if (Source != null)
            {
                if (!Source.Register())
                {
                    DebugStub.WriteLine("Error initializing the source " + sourcename);
                    return(null);
                }
            }

            return(Source);
        }
示例#13
0
        public static void DeferedUpdateNotification()
        {
            uint CapturedValue = DeferedCommand;

            DeferedCommand = 0;

            // TODO: This needs to be be moved later in a work item thread pool mechanism
            // of some sort

            if ((CapturedValue & DEFERED_COMMAND_ENABLE_KERNEL_GC) != 0)
            {
                // TODO: This API has disappeared in the arm branch
                // - may need to get moved to a new API
                // GCProfilerLogger.StartProfiling();
            }

            if ((CapturedValue & DEFERED_COMMAND_FORCE_GC_COLLECTION) != 0)
            {
                DebugStub.WriteLine("Kernel GC collection started\n");
                System.GC.Collect();
                System.GC.WaitForPendingFinalizers();
                System.GC.Collect();
                DebugStub.WriteLine("Kernel GC collection completed\n");
                DebugStub.Break();
            }
        }
示例#14
0
        // Returns true if the channel allows writing
        private bool CanWrite(TcpConnectionContract /*.Imp*/ conn)
        {
            if (conn.InState(TcpConnectionContract.State.Connected /*.Value*/))
            {
                return(true);
            }
//            else  if(conn.InState(TcpConnectionContract.SendOnly/*.Value*/)) {
//                return true;
//            }
//            if (conn.InState(TcpConnectionContract.ReceiveOnly/*.Value*/)) {
//                DebugStub.Break();
//                return false;
//            }
            if (conn.InState(TcpConnectionContract.State.ReadyState /*.Value*/))
            {
                DebugStub.Break();
                return(false);
            }
            if (conn.InState(TcpConnectionContract.State.Listening /*.Value*/))
            {
                DebugStub.Break();
                return(false);
            }
            return(false);
        }
示例#15
0
        public Bytes ExtractHead(out uint startOffset, out uint length)
        {
            if (this.Empty)
            {
                startOffset = 0;
                length      = 0;
                return(null);
            }
            TcpVectorNode candidate = this.listHead.next;
            Bytes         data      = candidate.Unlink();

            count--;
            if (data != null)
            {
                size -= candidate.length;
            }
            else
            {
                DebugStub.WriteLine("Extracthead no data??\n");
                DebugStub.Break();
                VTable.Assert(false);
            }
            startOffset = candidate.startOffset;
            length      = candidate.length;
            return(data);
        }
示例#16
0
 //push a single packet onto the ring
 void IAdapter.PopulateTxRing(Bytes header, Bytes data)
 {
     try {
         PacketFifo txFree     = this.txFreeFifo.Acquire();
         PacketFifo txToDevice = this.txFifo.Acquire();
         DebugPrint("populate tx ring\n");
         try {
             Packet packet = txFree.Pop();
             packet.SetFragment(0, header);
             packet.SetFragment(1, data);
             txToDevice.Push(packet);
         }
         finally {
             this.txFreeFifo.Release(txFree);
             this.txFifo.Release(txToDevice);
         }
     }
     catch (Exception e) {
         DebugStub.Print("Populate tx ring failed?? {0}\n", DebugStub.ArgList(e));
         DebugStub.Break();
     }
     //When to exchange?
     //how do we best manage the tradeoff of throughput and latency?
     //to begin let's just send one at a time.
     //I think i'd rather have another thread....
     using (thisLock.Lock()) {
         TxExchange();
     }
 }
示例#17
0
        private void DispatchRequest(object dispatchObject)
        {
            Console.WriteLine(dispatchObject as string);
            Console.WriteLine("We should Never get here");
#if SINGULARITY
            DebugStub.Break();
#endif
        }
示例#18
0
        private void DebugBreak()
        {
#if SINGULARITY_KERNEL
            DebugStub.Break();
#elif SINGULARITY_PROCESS
            DebugService.Break();
#endif // SINGULARITY_PROCESS
        }
        public static int DriverMain(IntelResources resources)
        {
            ExtensionContract /*.Exp*/       ep = (resources.ec).Acquire();
            ServiceProviderContract /*.Exp*/ sp = (resources.nicsp).Acquire();

            Intel device = new Intel(resources);

            device.Initialize();

            ep.SendSuccess();

            try {
                for (bool run = true; run;)
                {
                    switch receive {
                    case sp.Connect(ServiceContract /*.Exp*/ exp):
                        NicDeviceContract /*.Exp*/ nd = exp as NicDeviceContract /*.Exp*/;

                        if (nd != null)
                        {
                            Tracing.Log(Tracing.Debug, "Connect success.");
                            sp.SendAckConnect();
                            IntelDeviceChannel.CreateThread(device, nd);
                        }
                        else
                        {
                            Tracing.Log(Tracing.Error, "Connect failed.");
                            sp.SendNackConnect(exp);
                        }
                        break;

                    case sp.ChannelClosed():
                        device.Shutdown();
                        run = false;
                        break;

                    case ep.Shutdown():
                        device.Shutdown();
                        ep.SendAckShutdown();
                        break;

                    case ep.ChannelClosed():
                        device.Shutdown();
                        run = false;
                        break;

                    case unsatisfiable:
                        DebugStub.Break();
                        break;
                    }
                }
            }
            finally {
                //delete ep;
                //delete sp;
            }
            return(0);
        }
示例#20
0
        //
        // This is invoked on SIP OOM to "fail-fast" the SIP
        //
        internal static void UserMemoryFailure()
        {
            DebugStub.WriteLine("******** SIP OOM on Heap, Failing Fast ********");

            // This does not make a stack transition record
            Thread.CurrentProcess.Stop((int)System.ProcessExitCode.ErrorDefault);

            // Should not return
            DebugStub.Break();
        }
示例#21
0
 internal UIntPtr AllocateExtend(UIntPtr addr,
                                 UIntPtr bytes,
                                 Process process,
                                 uint extra,
                                 PageType type)
 {
     // TODO: Extend not yet implemented
     DebugStub.Break();
     return((UIntPtr)null);
 }
示例#22
0
 internal PageType Query(UIntPtr queryAddr,
                         Process process,
                         out UIntPtr regionAddr,
                         out UIntPtr regionSize)
 {
     // TODO: Query not yet implemented
     DebugStub.Break();
     regionAddr = 0;
     regionSize = 0;
     return(0);
 }
示例#23
0
        /// <summary>
        /// Look up the Monitor for the specified object in the SyncBlock
        /// tables. If no Monitor exists for the object then one is created.
        /// </summary>
        private static Monitor GetMonitorFromObject(Object obj)
        {
            if (obj == null)
            {
                DebugStub.Break();
                throw new ArgumentNullException("obj");
            }
            Monitor result = MultiUseWord.GetMonitor(obj);

            return(result);
        }
示例#24
0
 //dups?
 //XXX fix the dupes!
 public bool RegisterAdapter(IAdapter adapter)
 {
     if (adapters.Contains(adapter))
     {
         DebugStub.Print("Duplicate adapters???\n");
         DebugStub.Break();
         return(false);
     }
     adapters.Add(adapter);
     return(true);
 }
示例#25
0
 //push a single packet onto the ring
 void IAdapter.PopulateTxRing(Bytes header, Bytes data)
 {
     try {
         PacketFifo txFree     = this.txFreeFifo.Acquire();
         PacketFifo txCoalesce = this.txCoalesceFifo.Acquire();
         try {
             DebugStub.Assert(txFree.Count > 0);
             int cnt = 0;
             while (txFree.Count <= 0)
             {
                 //try again...
                 //this happens when we're hammering the outgoing connection
                 this.txCoalesceFifo.Release(txCoalesce);
                 this.txFreeFifo.Release(txFree);
                 this.muxEvent.Set();
                 Thread.Yield();
                 txFree     = this.txFreeFifo.Acquire();
                 txCoalesce = this.txCoalesceFifo.Acquire();
                 if (cnt > 100)
                 {
                     DebugStub.Print("txFree empty???\n");
                     //DebugStub.Break();
                 }
                 cnt++;
             }
             Packet packet = txFree.Pop();
             packet.SetFragment(0, header);
             packet.SetFragment(1, data);
             if ((txCoalesce.Count + 1) > txCoalesce.Capacity)
             {
                 DebugStub.Break();
             }
             DebugStub.Assert((txCoalesce.Count + 1) <= txCoalesce.Capacity);
             txCoalesce.Push(packet);
         }
         catch {
             DebugStub.Print("failure in populate tx ring\n");
             DebugStub.Break();
             DebugStub.Assert(false);
         }
         finally {
             this.txCoalesceFifo.Release(txCoalesce);
             this.txFreeFifo.Release(txFree);
             //notify the mux that there are waiting packets
             this.muxEvent.Set();
         }
     }
     catch (Exception e) {
         DebugStub.Print("Populate tx ring failed?? {0}\n", DebugStub.ArgList(e));
         DebugStub.Break();
     }
 }
示例#26
0
        /// <summary>
        /// Wait to be woken up by a holder of the monitor. Give up after
        /// a specified timeout.
        ///
        /// Overload exists to match the CLR. Exit Context not supported.
        /// </summary>
        public static bool Wait(Object obj,
                                TimeSpan timeout,
                                bool exitContext)
        {
            if (exitContext)
            {
                DebugStub.Break();
                throw new NotSupportedException("exitContext not supported!");
            }
            Monitor monitor = GetMonitorFromObject(obj);

            return(monitor.Wait(SchedulerTime.Now + timeout));
        }
示例#27
0
        private static void AnnounceApFail(int nextCpu)
        {
            MpSyncState localMpState = mpSyncState;

            DebugStub.Print("MpState {0}", __arglist(localMpState));
            DebugStub.Break();
            Platform bi = Platform.ThePlatform;

            DebugStub.Print("Cpu {0} failed. ",
                            __arglist(nextCpu));
            DebugStub.Print("GotBack-> Status {0} Count {1:x8}\n",
                            __arglist(bi.MpStatus32, bi.MpCpuCount));
        }
示例#28
0
        private unsafe byte Read8Impl(int offset)
        {
            byte v;

            if (PciPortHandle.Read8Impl(handle, offset, &v))
            {
                return(v);
            }
            else
            {
                DebugStub.Break();
                return(0);
            }
        }
示例#29
0
        /// <summary>
        /// Exit the monitor.
        /// </summary>
        internal void Exit()
        {
            if (!mutex.IsOwnedByCurrentThread())
            {
                DebugStub.Break();
                throw new SynchronizationLockException("Monitor not held on Exit");
            }

            depth--;
            if (depth == 0)
            {
                mutex.ReleaseMutex();
            }
        }
示例#30
0
        private unsafe uint Read32Impl(int offset)
        {
            uint v;

            if (PciPortHandle.Read32Impl(handle, offset, &v))
            {
                return(v);
            }
            else
            {
                DebugStub.Break();
                return(0);
            }
        }