Example #1
0
        internal static IoApic [] CreateIOApics()
        {
            // Prefer to get the list of IoApics from the MADT
            Madt madt = AcpiTables.GetMadt();

            if (madt != null)
            {
                ArrayList alist = madt.GetIoApics();
                if (alist.Count > 0)
                {
                    IoApic [] apics = new IoApic[alist.Count];
                    for (int i = 0; i < alist.Count; i++)
                    {
                        // Have to convert from a ...Hal.Acpi.IoApic into a Hal.IoApic:
                        Microsoft.Singularity.Hal.Acpi.IoApic sourceEntry = (Microsoft.Singularity.Hal.Acpi.IoApic)alist[i];
                        IoApic destEntry = new IoApic(sourceEntry.Address, sourceEntry.InterruptBase);
                        destEntry.SetId(sourceEntry.Id);
                        apics[i] = destEntry;
                    }
                    DebugStub.Print("Created IoApics from MADT table\n");
                    return(apics);
                }
            }
            DebugStub.Print("Created IoApics from MpResources table table\n");
            // Otherwise, create from Mp tables
            return(CreateFromMpResources());
        }
Example #2
0
        public void Write(Bytes data)
        {
            if (tcpSession.CurrentState < TcpState.ESTABLISHED)
            {
                state = State.Closed;
                DebugStub.Print("Connection unexpectedly closed\n");
                throw new Exception("Write: CantSend");
            }

            int bytesToWrite = data.Length;
            int written      = tcpSession.Send(data);

            if (written == -1)
            {
                state = State.Closed;
                // A -1 return value indicates the connection has been closed
                // underneath us while we were trying to write.
                throw new Exception("WriteData: CantSend");
            }
            else if (written != bytesToWrite)
            {
                // This is unexpected; the current implementation always
                // blocks and writes as much data as is provided.
                throw new Exception("Unexpected partial write in TcpSession.WriteData");
            }
        }
Example #3
0
 internal static void DebugPrint(string format, params object [] args)
 {
     DebugStub.Print("DhcpClient: {0}",
                     DebugStub.ArgList(
                         string.Format(format, args))
                     );
 }
Example #4
0
        public override void DisableIrq(byte irq)
        {
#if DEBUG_IO_APIC_IRQ_MASK
            DebugStub.Print("Disabling IRQ 0x{0:x}\n", __arglist(irq));
#endif

            foreach (IoApic ioApic in ioApics)
            {
#if DEBUG_IO_APIC_IRQ_MASK
                DebugStub.Print("Found IoApic 0x{0:x}; interrupt base 0x{1:x}, entry count 0x{2:x}\n",
                                __arglist(ioApic.GetId(), ioApic.InterruptBase, ioApic.RedirectionEntryCount));
#endif

                if ((ioApic.InterruptBase <= irq) &&
                    (irq < (ioApic.InterruptBase + ioApic.RedirectionEntryCount)))
                {
#if DEBUG_IO_APIC_IRQ_MASK
                    DebugStub.Print("Disabling IRQ 0x{0:x} as 0x{1:x} on ioApic 0x{2:x}\n",
                                    __arglist(irq, irq - ioApic.InterruptBase, ioApic.GetId()));
#endif
                    ioApic.SetEntryMask(irq - ioApic.InterruptBase, true);
                    break;
                }
            }

#if DEBUG_IO_APIC_IRQ_MASK
            PrintIoApics();
#endif
        }
Example #5
0
        public static void PrintApic(IoApic ioApic)
        {
            DebugStub.Print("Io Apic\n");
            DebugStub.Print("  Id: {0:x2} Version: {1:x4} ArbitrationId: {2:x2}\n",
                            __arglist(
                                ioApic.GetId(),
                                ioApic.GetVersion(),
                                ioApic.GetArbitrationId()));

            for (uint i = 0; i < ioApic.RedirectionEntryCount; i++)
            {
                RedirectionEntry e  = ioApic.GetRedirectionEntry(i);
                IoBits           ib = (IoBits)((int)e.IoBits & ~(int)IoBits.DelModMask);

                DebugStub.Print("  IoRedTbl[{0:x2}]" +
                                "Dst: {1:x2} IntVec: {2:x2} Control: {3} {4} {5} {6} {7} {8}" +
                                "Delivery Mode ",
                                __arglist(
                                    i,
                                    e.Destination,
                                    e.InterruptVector,
                                    ((ib & IoBits.DstLogical) != 0) ? "Logical" : "Physical",
                                    ((ib & IoBits.IrqMask) != 0) ? "Masked" : "Unmasked",
                                    ((ib & IoBits.TriggerModeMask) != 0) ? "Level" : "Edge",
                                    ((ib & IoBits.RemoteIRR) != 0) ? "Accept" : "Recv",
                                    ((ib & IoBits.IntPolMask) != 0) ? "Hi active" : "Lo active",
                                    ((ib & IoBits.DeliveryStatus) != 0) ? "Pending" : "Idle"));
                DescribeModMask(e.IoBits);
            }
        }
Example #6
0
        // Constructor
        internal RTClockApic(PnpConfig config, Apic apic)
        {
            int cpuId;

            Microsoft.Singularity.Hal.Platform p = Microsoft.Singularity.Hal.Platform.ThePlatform;
            cpuId = p.ApicId;

            DebugStub.Print("RTClock: create\n");

            // /pnp/08/03/01/PNP0B00 0003 cfg dis : ISA RTC Controller : AT RTC
            // IRQ mask=0100 type=47
            // I/O Port inf=01 min=0070 max=0070 aln=01 len=02 0070..0071

            this.config      = config;
            this.irq         = ((IoIrqRange)config.DynamicRanges[1]).Irq;
            this.apic        = apic;
            this.rtcSpinLock = new SpinLock(SpinLock.Types.RTClock);

            rtcadd = ((IoPortRange)config.DynamicRanges[0])
                     .PortAtOffset(0, 1, Access.ReadWrite);
            rtcdat = ((IoPortRange)config.DynamicRanges[0])
                     .PortAtOffset(1, 1, Access.ReadWrite);

            if (cpuId == 0)
            {
                this.interrupt = Initialize();
                DebugStub.Print("RTClock: interrupt {0:x2}\n",
                                __arglist(this.interrupt));
            }
        }
Example #7
0
        public Packet Pop()
        {
            {
                if (this.length < 1)
                {
                    DebugStub.Print("ACK! packetfifo empty??\n");
                    throw new Exception();
                }
                Packet packet;
                int    index = (this.Capacity + this.head - this.length) % this.Capacity;

                if (index > packets.Length || index < 0)
                {
                    DebugStub.Print("ACK index {0}\n", packets.Length);
                    DebugStub.Print("ACK plength {0}\n", packets.Length);
                    DebugStub.Print("ACK head {0}\n", this.head);
                    DebugStub.Print("ACK length {0}\n", this.length);
                    DebugStub.Print("ACK capacity {0}\n", this.Capacity);
                    throw new Exception();
                }
                packet = packets[index];
                this.packets[index] = null;
                this.length--;
                return(packet);
            }
        }
Example #8
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();
     }
 }
Example #9
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);
        }
Example #10
0
        uint capabilities;          // bits 0-31 at offset 0

        internal Hpet(PnpConfig config)
        {
            int cpuId;

            Microsoft.Singularity.Hal.Platform p = Microsoft.Singularity.Hal.Platform.ThePlatform;
            cpuId = p.ApicId;

            this.config = config;
            IoMemoryRange imr = (IoMemoryRange)config.DynamicRanges[0];

            this.region = imr.MemoryAtOffset(0, (int)imr.Length.ToUInt32(),
                                             Access.ReadWrite);

            capabilities = region.Read32(0x00);
            periodFs     = region.Read32(0x04);

            if (cpuId == 0)
            {
                DebugStub.Print("new Hpet writing regions\n");
                // Disable interrupts on timers
                for (uint i = 0; i <= MaxCounterIndex; i++)
                {
                    DisableInterrupt(i);
                }

                uint gc = region.Read32(0x10) & ~3u;    // Clear legacy bits
                region.Write32(0x10, gc | 1);           // Enable main counter
            }
        }
Example #11
0
 private static void DisplayResults(ulong tscHz, int i8254Hz)
 {
     DebugStub.Print("TSC measured at {0} MHz\n",
                     __arglist((int)(tscHz / 1000000)));
     DebugStub.Print("i8254 measured at {0} Hz\n",
                     __arglist(i8254Hz));
 }
        private Packet MakePacketFromDescriptor(DmaMemory mem, ulong controlBits)
        {
            PacketFifo inDevPkts = rxPacketsInDevice.Acquire();
            Packet     packet    = inDevPkts.Pop();
            int        length    = (int)((controlBits & RxDescriptor.LENGTH_MASK)
                                         >> RxDescriptor.LENGTH_SHIFT);
            uint stat_err = (uint)((controlBits & RxDescriptor.ERR_STAT_MASK)
                                   >> RxDescriptor.ERR_STAT_SHIFT);

            // can't deal with fragments yet
            if ((stat_err & RxErrStatFields.END_OF_PACKET) == 0)
            {
                INucleusCalls.DebugPrintHex(40, 0xd0);
                DebugStub.Print("FRAGMENT\n");
                throw new Exception();
            }

            //DebugStub.Assert((stat_err & RxErrStatFields.END_OF_PACKET) != 0);
            //DebugStub.Assert(packet.GetFragmentVirtualAddress(0) == fragmentVirtAddr);
            packet.FromDeviceFlags = GetRecvPktFlags(stat_err);
            packet.SetFragment(0, mem.BytesRef(0, length));
            rxPacketsInDevice.Release(inDevPkts);

            return(packet);
        }
Example #13
0
        internal static void CpuCycleCounter(PMTimer pmTimer)
        {
            uint  pmLast  = pmTimer.Value;
            ulong tscLast = Processor.CycleCount;

            uint  pmLimit = PMTimer.FrequencyHz / 15;
            uint  pmAccum = 0;
            ulong tscNow  = 0;

            // Initial measurements
            tscLast = Processor.CycleCount;
            pmLast  = pmTimer.Value;

            // Measurement loop
            do
            {
                tscNow = Processor.CycleCount;
                uint pmNow = pmTimer.Value;
                pmAccum += PmDelta(pmNow, pmLast);
                pmLast   = pmNow;
            } while (pmAccum < pmLimit);

            ulong tscHz = PMTimer.FrequencyHz * (tscNow - tscLast) / pmAccum;

            DebugStub.Print("Cpu{0}: TSC frequency {1} Hz\n",
                            __arglist(Processor.CurrentProcessor.Id, tscHz));
            Processor.CyclesPerSecond = tscHz;
        }
Example #14
0
        internal static void ApicTimer(PMTimer pmTimer, ApicTimer apicTimer)
        {
            apicTimer.SetDivisor(1);
            apicTimer.SetOneShot();
            apicTimer.SetInterruptEnabled(false);
            apicTimer.SetInitialCount(~0u);

            uint apicLast = apicTimer.Value;
            uint pmLast   = pmTimer.Value;

            uint pmLimit = PMTimer.FrequencyHz / 15;
            uint pmAccum = 0;
            uint apicNow = 0;

            // Initial measurements
            apicLast = apicTimer.Value;
            pmLast   = pmTimer.Value;
            do
            {
                apicNow = apicTimer.Value;
                uint pmNow = pmTimer.Value | 0xff000000;
                pmAccum += PmDelta(pmNow, pmLast);
                pmLast   = pmNow;
            } while (pmAccum < pmLimit);

            ulong apicHz = PMTimer.FrequencyHz * (ulong)(apicLast - apicNow) / pmAccum;

            DebugStub.Print("Cpu{0}: APIC timer frequency {1} Hz\n",
                            __arglist(Processor.CurrentProcessor.Id, apicHz));

            apicTimer.SetBusFrequency((uint)apicHz);
        }
Example #15
0
        public byte Initialize(byte baseVector)
        {
            DebugStub.Print("Pic.Initializing IRQs at interrupt {0:x2}\n",
                            __arglist(baseVector));

            this.baseVector = baseVector;
            irqMask         = unchecked ((ushort)~PIC_I_PIC1);

            // Set ICW1 (must be followed by ICW2, ICW3, and ICW4).
            //  00010001b - 8-byte,cascaded,triggered,w/ICW4
            pic1CtrlPort.Write8(0x11);
            pic0CtrlPort.Write8(0x11);

            // Set ICW2..ICW3 (must follow ICW1)
            pic1MaskPort.Write8((byte)(baseVector + 8));
            pic0MaskPort.Write8(baseVector);

            pic1MaskPort.Write8(0x02); // Cascaded interrupt number
            pic0MaskPort.Write8(0x04); // Cascaded interrupt bit.

            pic1MaskPort.Write8(1);    // End of Interrupt
            pic0MaskPort.Write8(1);

            pic1CtrlPort.Write8(0x20);  // EOI
            pic0CtrlPort.Write8(0x20);  // EOI

            MaskAll();

            return(PIC_VECTORS);
        }
Example #16
0
        public override void AckIrq(byte irq)
        {
            DebugStub.Assert(Processor.InterruptsDisabled());
#if PIC_DEBUG
            DumpRegisters();
#endif

            // Mark the IRQ as activated and mask it
#if DEBUG_INTERRUPTS
            DebugStub.Print("Int{0:x2}  Acked, Mask={1:x4}\n",
                            __arglist(irq + baseVector, irqMask));
#endif

            // Quite the interrupt controller.
            IoResult result;
            if (irq >= 8)
            {
                result = pic1CtrlPort.Write8NoThrow(PIC_NS_EOI);
                DebugStub.Assert(IoResult.Success == result);
            }
            result = pic0CtrlPort.Write8NoThrow(PIC_NS_EOI);
            DebugStub.Assert(IoResult.Success == result);

#if PIC_DEBUG
            DumpRegisters();
#endif
        }
Example #17
0
        private void Unmask(byte irq)
        {
            DebugStub.Assert(Processor.InterruptsDisabled());
            ushort newMask = (ushort)(irqMask & ~(1 << irq));

            if (newMask != irqMask)
            {
#if DEBUG_DISPATCH_IO
                DebugStub.WriteLine("-- Unmask IRQs: old={0:x4} new={1:x4}",
                                    __arglist(irqMask, newMask));
#endif
                irqMask = newMask;
                IoResult result;

                result = pic1MaskPort.Write8NoThrow((byte)(irqMask >> 8));
                DebugStub.Assert(IoResult.Success == result);

                result = pic0MaskPort.Write8NoThrow((byte)(irqMask & 0xff));
                DebugStub.Assert(IoResult.Success == result);
#if PIC_DEBUG
                byte mask0;
                result = pic0MaskPort.Read8(out mask0);
                DebugStub.Assert(IoResult.Success == result);

                byte mask1;
                result = pic1MaskPort.Read8(out mask1);
                DebugStub.Assert(IoResult.Success == result);

                DebugStub.Print("PIC Mask: {0:x2}{1:x2}\n",
                                __arglist(mask1, mask0));
#endif
            }
        }
Example #18
0
        private void PushRtcTime(DateTime dt)
        {
            bool iflag = Processor.DisableInterrupts();
            byte saved = ReadRtc(DS1287_B);

            try {
                // Set UTI bit to stop transfers between RTC
                // bytes and user buffer.
                WriteRtc(DS1287_B, (byte)(saved | DS1287_B_UTI));
                // Write new values
                WriteRtc(DS1287_SECONDS, HexToBcd(dt.Second));
                WriteRtc(DS1287_MINUTES, HexToBcd(dt.Minute));
                WriteRtc(DS1287_HOURS, HexToBcd(dt.Hour));
                WriteRtc(DS1287_DAY_OF_MONTH, HexToBcd(dt.Day));
                WriteRtc(DS1287_MONTH, HexToBcd(dt.Month));

                int century = dt.Year / 100;
                WriteRtc(9, HexToBcd(dt.Year - century * 100));
                WriteRtc(DS1287_YEAR, HexToBcd(dt.Year - century * 100));
                WriteRtc(DS1287_USERDATA, HexToBcd(century));
                // Clear UTI bit to enable transfers again
                DebugStub.Print("PushRtcTime {3:2}:{4:d2}:{5:d2} {0}/{1}-{2:d4}\n",
                                __arglist(dt.Month, dt.Day,
                                          100 * century + dt.Year, dt.Hour,
                                          dt.Minute, dt.Second));
            }
            finally {
                WriteRtc(DS1287_B, saved);
                Processor.RestoreInterrupts(iflag);
            }
        }
Example #19
0
        public override void ClearInterrupt()
        {
#if RTC_NO_GO
            DebugStub.Print("Unwanted RTC interrupt! (b = {0})\n",
                            __arglist(ReadRtc(DS1287_B)));
            return;
#endif // RTC_NO_GO

            byte status = ReadRtc(DS1287_C);
            if ((status & 0x40) != 0x40)
            {
                // We may get Update-Ended interrupts even though we've
                // not requested them.
                pic.AckIrq(irq);
                return;
            }

            ClockLogger.AddEntry(4, rps, timer);
            rps.pitLastClock = timer.Timer2Read();
            rps.upTime      += InterruptGapTicks;

            ClockLogger.AddEntry(5, rps, timer);
            irqCount++;

            if (timer.InterruptPending == false)
            {
                // This is to keep time progressing if the user has
                // not set an interrupt
                timer.SetKeepAliveInterrupt();
            }
            pic.AckIrq(irq);

            // Invalidate TSC snapshot to force clock synchronization
            this.tscSnapshotValid = false;
        }
Example #20
0
        internal byte Initialize()
        {
            DebugStub.Print("RTClock: initialize\n");

            rps = timer.rps;

            // Turn oscillator on, but disable and clear interrupts
            if (Processor.SamplingEnabled())
            {
                WriteRtc(DS1287_A, DS1287_A_DIVON | DS1287_A_SAMPLING_HZ);
            }
            else
            {
                WriteRtc(DS1287_A, DS1287_A_DIVON | DS1287_A_64HZ);
            }
            WriteRtc(DS1287_B, DS1287_B_24H | DS1287_B_DF_BCD);
            ReadRtc(DS1287_C);  // Clear any update bits

            if ((ReadRtc(DS1287_D) & DS1287_D_VRT) == 0)
            {
                DebugStub.Print("RTClock weak or defective power source.\n");
            }

            rtcBootTime = PullRtcTime().Ticks;

            // Enable and clear interrupts
            // NB it may take 500ms for first interrupt to be generated.
            pic.EnableIrq(irq);
            return(pic.IrqToInterrupt(irq));
        }
Example #21
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);
        }
Example #22
0
        static ClockLogger()
        {
            InitializeEntries();
#if LOG_CLOCK
            DebugStub.Print("Initializing ClockLogger.\n");
#endif // LOG_CLOCK
        }
Example #23
0
        static void DumpEntries()
        {
            DebugStub.Print("# Clock column 1 who\n");
            DebugStub.Print("# Clock column 2 time in cpu cycles\n");
            DebugStub.Print("# Clock column 3 time from clock\n");
            DebugStub.Print("# Clock column 4 pitLastClock\n");
            DebugStub.Print("# Clock column 5 pitNow\n");
            DebugStub.Print("# Clock column 6 upTime\n");
            DebugStub.Print("# Clock column 7 currentTime\n");
            DebugStub.Print("# Clock column 8 cookie\n");
            DebugStub.Print("# Clock column 9 record number\n");

            for (int i = 0; i != currentRecord; i++)
            {
                DebugStub.Print("Clock {0:d6} {1:d6} {2} {3} {4} {5} {6} {7}\n",
                                __arglist(
                                    ToMicros(entries[i].when,
                                             entries[0].when,
                                             Processor.CyclesPerSecond),
                                    ToMicros(entries[i].currentTime, 0, 10000000),
                                    entries[i].pitLastClock,
                                    entries[i].pitNow,
                                    entries[i].upTime,
                                    entries[i].currentTime,
                                    entries[i].cookie,
                                    i));
            }
        }
Example #24
0
        private void InitializeRouteableEntries()
        {
            DebugStub.Print("Initializing Apic routeable entries\n");
            // Initialize entries that may not be part of MP set
            // configuration, but might be utilizable via a
            // programmable interrupt routing on PCI-LPC bridge
            // or elsewhere.
            byte   irq        = 16;
            IoBits stdPciBits = (IoBits.DstPhysical | IoBits.DelModFixed |
                                 IoBits.IrqMask | IoBits.IntPolActiveLow |
                                 IoBits.TriggerModeLevel);

            for (int id = 0; id < ioApics.Length; id++)
            {
                uint start = (id == 0) ? 16u : 0u;
                uint end   = ioApics[id].RedirectionEntryCount;
                for (uint index = start; index < end; index++)
                {
                    RedirectionEntry re =
                        new RedirectionEntry(this.Id, stdPciBits,
                                             IrqToInterrupt(irq));
                    ioApics[id].SetRedirectionEntry(index, ref re);
                    irq++;
#if PRINT_IO_APICS
                    DebugStub.Print("Added routeable entry for apic 0x{0:x}: IRQ 0x{1:x} => 0x{2:x}\n",
                                    __arglist(id, irq, IrqToInterrupt(irq)));
#endif
                }
            }
            maxIrq = (byte)(irq - 1);
            PrintIoApics();
        }
Example #25
0
 internal static void DebugPrint(string format,
                                 params object [] arguments)
 {
     DebugStub.Print("ARPModule: {0}",
                     __arglist(
                         string.Format(format, arguments))
                     );
 }
Example #26
0
 internal static void DebugPrint(string format,
                                 params object [] arguments)
 {
     DebugStub.Print("UDP: {0}",
                     DebugStub.ArgList(
                         string.Format(format, arguments))
                     );
 }
Example #27
0
 internal void SwitchToHpetClock(HpetClock hc)
 {
     // Change rt clock interrupt frequency to appropriate
     // rate for HPET main clock.
     rtClock.SetFrequency(HpetClock.UpdateFrequency(hc.Hpet));
     hpetClock = hc;
     DebugStub.Print("Hal switching to HpetClock.\n");
 }
Example #28
0
 internal static void Run(HalClockNull clock, TimerOmap3430 gpTimer1)
 {
     DebugStub.Print("CLOCK CALIBRATION NOT ATTEMPTED.\n");
     // hacked, should calibrate
     Processor.CyclesPerSecond = 687 * 1000 * 1000; // MPU runs @ 687Mhz in OPP1
     gpTimer1.SetTicksPerSecond(32768);
     return;
 }
Example #29
0
        internal static int AppMain(Parameters !config)
        {
            DebugStub.Print("About to write to console\n");
            Console.WriteLine("Hello World!");
            DebugStub.Print("Wrote to console\n");

            return(0);
        }
Example #30
0
        internal static void ParseMpTables()
        {
            UIntPtr mpFloat = GetMpFloatBase();

            if (mpFloat == UIntPtr.Zero)
            {
                DebugStub.Print("MP Floating Pointer Structure not found.\n");
                return;
            }

            mpFloatRegion =
                IoMemory.MapPhysicalMemory(mpFloat, new UIntPtr(16), true, false);

            FloatingPointer = MpFloatingPointer.Parse(mpFloatRegion);
            if (FloatingPointer == null)
            {
                DebugStub.Print("Failed to parse MP Floating Pointer " +
                                "Structure.\n");
                return;
            }

            if (FloatingPointer.MpConfTablePresent)
            {
                mpConfTableRegion = IoMemory.MapPhysicalMemory(
                    new UIntPtr(FloatingPointer.ConfTableBase),
                    new UIntPtr(0x2c), true, false);

                DebugStub.Print("Found MP Conf Table\n");

                ConfTable = MpConfTable.Parse(mpConfTableRegion);
                if (ConfTable == null)
                {
                    DebugStub.Print("Failed to parse MP Configuration table.\n");
                }

                IoMemory mpResourceRegion =
                    IoMemory.MapPhysicalMemory(
                        new UIntPtr(FloatingPointer.ConfTableBase + 0x2c),
                        new UIntPtr(ConfTable.BaseTableLength - 0x2c),
                        true, false);
                DebugStub.Print("Parsing MP Conf Table Resources\n");
                MpResources.Parse(mpResourceRegion,
                                  ConfTable.BaseTableLength - 0x2c,
                                  ConfTable.EntryCount);
            }
            else
            {
                DebugStub.Print("MP Configuration table not present.\n");
                DebugStub.Print("MP Floating Pointer features: " +
                                "{0:x8} {1:x8} {2:x8} {3:x8} {4:x8}\n",
                                __arglist(
                                    FloatingPointer.Feature[0],
                                    FloatingPointer.Feature[1],
                                    FloatingPointer.Feature[2],
                                    FloatingPointer.Feature[3],
                                    FloatingPointer.Feature[4]));
            }
        }