Beispiel #1
0
        protected UHCI_qTD_Struct *CreateQTD_IO(UHCI_QueueHead_Struct *uQH, uint *next, byte direction, bool toggle, ushort tokenBytes, byte device, byte endpoint, uint packetSize)
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Create qTD IO");
            BasicConsole.DelayOutput(5);
#endif

            UHCI_qTD_Struct *td = AllocQTD(next);

            UHCI_qTD.SetPacketID(td, direction);

            if (tokenBytes != 0)
            {
                UHCI_qTD.SetMaxLength(td, (ushort)((tokenBytes - 1u) & 0x7FFu));
            }
            else
            {
                UHCI_qTD.SetMaxLength(td, 0x7FF);
            }

            UHCI_qTD.SetDataToggle(td, toggle);
            UHCI_qTD.SetC_ERR(td, 0x3);
            UHCI_qTD.SetDeviceAddress(td, device);
            UHCI_qTD.SetEndpoint(td, endpoint);

            AllocQTDbuffer(td);

            uQH->q_last = td;
            return(td);
        }
Beispiel #2
0
        public PCIDevice(uint bus, uint slot, uint function)
        {
            this.bus      = bus;
            this.slot     = slot;
            this.function = function;

#if PCI_TRACE || COMPILER_TRACE
            ushort vendorID = ReadRegister16(0x00);
            VendorID = ReadRegister16(0x00);
            BasicConsole.WriteLine(((FOS_System.String) "New PCI device. bus(arg)=") + bus + ", bus(fld)=" + this.bus);
            BasicConsole.WriteLine(((FOS_System.String) "                slot(arg)=") + slot + ", slot(fld)=" + this.slot);
            BasicConsole.WriteLine(((FOS_System.String) "                func(arg)=") + function + ", func(fld)=" + this.function);
            BasicConsole.WriteLine(((FOS_System.String) "                vendorID(loc)=") + vendorID + ", vendorID(fld)=" + this.VendorID);
            BasicConsole.DelayOutput(4);
#else
            VendorID = ReadRegister16(0x00);
#endif
            DeviceID = ReadRegister16(0x02);

            RevisionID = ReadRegister8(0x08);
            ProgIF     = ReadRegister8(0x09);
            Subclass   = ReadRegister8(0x0A);
            ClassCode  = ReadRegister8(0x0B);

            CacheLineSize = ReadRegister8(0x0C);
            LatencyTimer  = ReadRegister8(0x0D);
            HeaderType    = (PCIHeaderType)ReadRegister8(0x0E);
            BIST          = (PCIBISTs)ReadRegister8(0x0F);

            InterruptLine = ReadRegister8(0x3C);
            InterruptPIN  = (PCIInterruptPIN)ReadRegister8(0x3D);

            DeviceExists = (uint)VendorID != 0xFFFF && (uint)DeviceID != 0xFFFF;
        }
Beispiel #3
0
        public static void HandlePageFault(uint eip, uint errorCode, uint address)
        {
            Hardware.VirtMem.MemoryLayout memLayout = ProcessManager.CurrentProcess.TheMemoryLayout;
            BasicConsole.WriteLine("Code pages:");
            string TempDisplayString = "0x        ";

            UInt32Dictionary.Iterator iterator = memLayout.CodePages.GetIterator();
            while (iterator.HasNext())
            {
                UInt32Dictionary.KeyValuePair pair = iterator.Next();
                uint vAddr = pair.Key;
                WriteNumber(TempDisplayString, vAddr);
                BasicConsole.WriteLine(TempDisplayString);
            }
            BasicConsole.WriteLine("Data pages:");
            iterator = memLayout.DataPages.GetIterator();
            while (iterator.HasNext())
            {
                UInt32Dictionary.KeyValuePair pair = iterator.Next();
                uint vAddr = pair.Key;
                WriteNumber(TempDisplayString, vAddr);
                BasicConsole.WriteLine(TempDisplayString);
            }
            BasicConsole.DelayOutput(100);
        }
Beispiel #4
0
        public UHCI(PCI.PCIDeviceNormal aPCIDevice)
            : base(aPCIDevice)
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Constructor");
            BasicConsole.DelayOutput(5);
#endif

            usbBaseAddress = pciDevice.BaseAddresses[4].BaseAddress();
            Processes.ProcessManager.CurrentProcess.TheMemoryLayout.AddDataPage(
                (uint)usbBaseAddress & 0xFFFFF000,
                (uint)usbBaseAddress & 0xFFFFF000);
            VirtMemManager.Map((uint)usbBaseAddress & 0xFFFFF000, (uint)usbBaseAddress & 0xFFFFF000, 4096,
                               VirtMem.VirtMemImpl.PageFlags.KernelOnly);

            RootPortCount = UHCI_Consts.PORTMAX;
            EnabledPorts  = false;

            USBCMD    = new IO.IOPort(MapPort(UHCI_Consts.USBCMD));
            USBINTR   = new IO.IOPort(MapPort(UHCI_Consts.USBINTR));
            USBSTS    = new IO.IOPort(MapPort(UHCI_Consts.USBSTS));
            SOFMOD    = new IO.IOPort(MapPort(UHCI_Consts.SOFMOD));
            FRBASEADD = new IO.IOPort(MapPort(UHCI_Consts.FRBASEADD));
            FRNUM     = new IO.IOPort(MapPort(UHCI_Consts.FRNUM));
            PORTSC1   = new IO.IOPort(MapPort(UHCI_Consts.PORTSC1));
            PORTSC2   = new IO.IOPort(MapPort(UHCI_Consts.PORTSC2));

            FrameList = (uint *)VirtMemManager.MapFreePage(VirtMem.VirtMemImpl.PageFlags.KernelOnly);
            Processes.ProcessManager.CurrentProcess.TheMemoryLayout.AddDataPage(
                (uint)FrameList & 0xFFFFF000,
                (uint)FrameList & 0xFFFFF000);

            Start();
        }
Beispiel #5
0
        protected override void _OUTTransaction(USBTransfer transfer, USBTransaction uTransaction, bool toggle, void *buffer, ushort length)
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: OUT Transaction");
            BasicConsole.DelayOutput(5);
#endif

            UHCITransaction uT = new UHCITransaction();
            uTransaction.underlyingTz = uT;
            uT.inBuffer = null;
            uT.inLength = 0;

            uT.qTD       = CreateQTD_IO((UHCI_QueueHead_Struct *)transfer.underlyingTransferData, (uint *)1, UHCI_Consts.TD_OUT, toggle, length, transfer.device.address, transfer.endpoint, transfer.packetSize);
            uT.qTDBuffer = uT.qTD->virtBuffer;

            if (buffer != null && length != 0)
            {
                MemoryUtils.MemCpy_32((byte *)uT.qTDBuffer, (byte *)buffer, length);
            }

            if (transfer.transactions.Count > 0)
            {
                UHCITransaction uLastTransaction = (UHCITransaction)((USBTransaction)(transfer.transactions[transfer.transactions.Count - 1])).underlyingTz;
                uLastTransaction.qTD->next   = (((uint)VirtMemManager.GetPhysicalAddress(uT.qTD) & 0xFFFFFFF0) | UHCI_Consts.BIT_Vf); // build TD queue
                uLastTransaction.qTD->q_next = uT.qTD;
            }
        }
Beispiel #6
0
        protected UHCI_qTD_Struct *CreateQTD_SETUP(UHCI_QueueHead_Struct *uQH, uint *next, bool toggle, ushort tokenBytes, byte type, byte req, byte hiVal, byte loVal, ushort i, ushort length, byte device, byte endpoint, uint packetSize)
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Create qTD SETUP");
            BasicConsole.DelayOutput(5);
#endif

            UHCI_qTD_Struct *td = AllocQTD(next);

            UHCI_qTD.SetPacketID(td, UHCI_Consts.TD_SETUP);
            UHCI_qTD.SetDataToggle(td, toggle);
            UHCI_qTD.SetDeviceAddress(td, device);
            UHCI_qTD.SetEndpoint(td, endpoint);
            UHCI_qTD.SetMaxLength(td, (ushort)(tokenBytes - 1));
            UHCI_qTD.SetC_ERR(td, 0x3);

            //TODO: *buffer =
            USBRequest *request = (USBRequest *)(AllocQTDbuffer(td));
            request->type    = type;
            request->request = req;
            request->valueHi = hiVal;
            request->valueLo = loVal;
            request->index   = i;
            request->length  = length;

            uQH->q_last = td;
            return(td);
        }
Beispiel #7
0
        /// <summary>
        /// Parses partition information from the MBR data at the specified offset.
        /// </summary>
        /// <param name="aMBR">The MBR data.</param>
        /// <param name="aLoc">The offset of the partition information in the MBR data.</param>
        /// <returns>The partition information or null if the information is not a valid partition.</returns>
        protected static PartitionInfo ParsePartition(byte[] aMBR, UInt32 aLoc)
        {
#if MBR_TRACE
            BasicConsole.WriteLine("MBR: 3");
#endif
            //System ID gives you preliminary information
            //  about what type of data is in the partition and whether
            //  the partition is empty or not.
            byte systemID = aMBR[aLoc + 4];

#if MBR_TRACE
            BasicConsole.WriteLine("MBR: 4");
#endif

            if (systemID == 0)
            {
                // If SystemID == 0 means, this partition entry is un-used
                return(null);
            }

#if MBR_TRACE
            BasicConsole.WriteLine("MBR: 5");
#endif
            //Various System IDs for EBR (Extended Boot Record)
            //  (I'd like to know why developers felt the need to each create their own
            //   ID for an EBR partition entry within MBR. Seems silly...)
            if (systemID == 0x5 || systemID == 0xF || systemID == 0x85)
            {
#if MBR_TRACE
                BasicConsole.WriteLine("MBR: 6");
#endif

                //Extended Boot Record formatted partition detected
                //DOS only knows about 05, Windows 95 introduced 0F, Linux introduced 85
                //Search for logical volumes
                //http://thestarman.pcministry.com/asm/mbr/PartTables2.htm
                return(new PartitionInfo(FOS_System.ByteConverter.ToUInt32(aMBR, aLoc + 8)));
            }
            else
            {
#if MBR_TRACE
                BasicConsole.WriteLine("MBR: 7");
#endif

                UInt32 startSector = FOS_System.ByteConverter.ToUInt32(aMBR, aLoc + 8);
                UInt32 sectorCount = FOS_System.ByteConverter.ToUInt32(aMBR, aLoc + 12);

#if MBR_TRACE
                BasicConsole.WriteLine(((FOS_System.String) "startSector: ") + startSector);
                BasicConsole.WriteLine(((FOS_System.String) "sectorCount: ") + sectorCount);
                BasicConsole.DelayOutput(5);
#endif

#if MBR_TRACE
                BasicConsole.WriteLine("MBR: 8");
#endif
                bool bootable = aMBR[aLoc + 0] == 0x81;
                return(new PartitionInfo(bootable, systemID, startSector, sectorCount));
            }
        }
Beispiel #8
0
        protected static UHCI_qTD_Struct *AllocQTD(uint *next)
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Alloc qTD");
            BasicConsole.DelayOutput(5);
#endif

            UHCI_qTD_Struct *td = (UHCI_qTD_Struct *)FOS_System.Heap.AllocZeroedAPB((uint)sizeof(UHCI_qTD_Struct), 32, "UHCI : AllocQTD");

            if ((uint)next != Utils.BIT(0))
            {
                td->next   = ((uint)VirtMemManager.GetPhysicalAddress(next) & 0xFFFFFFF0) | UHCI_Consts.BIT_Vf;
                td->q_next = (UHCI_qTD_Struct *)next;
            }
            else
            {
                td->next = UHCI_Consts.BIT_T;
            }

            UHCI_qTD.SetActive(td, true);    // to be executed
            UHCI_qTD.SetPacketID(td, UHCI_Consts.TD_SETUP);
            UHCI_qTD.SetMaxLength(td, 0x3F); // 64 byte // uhci, rev. 1.1, page 24

            return(td);
        }
Beispiel #9
0
        private static void EnterCritical(FOS_System.String caller)
        {
            //BasicConsole.WriteLine("Entering critical section...");
            if (AccessLockInitialised)
            {
                if (AccessLock == null)
                {
                    BasicConsole.WriteLine("HeapAccessLock is initialised but null?!");
                    BasicConsole.DelayOutput(10);
                }
                else
                {
                    if (AccessLock.Locked && OutputTrace)
                    {
                        BasicConsole.SetTextColour(BasicConsole.warning_colour);
                        BasicConsole.WriteLine("Warning: Heap about to try to re-enter spin lock...");
                        BasicConsole.Write("Enter lock caller: ");
                        BasicConsole.WriteLine(caller);
                        BasicConsole.SetTextColour(BasicConsole.default_colour);
                    }

                    AccessLock.Enter();
                }
            }
            //else
            //{
            //    BasicConsole.WriteLine("HeapAccessLock not initialised - ignoring lock conditions.");
            //    BasicConsole.DelayOutput(5);
            //}
        }
Beispiel #10
0
        /// <summary>
        /// Tests the virtual memory system.
        /// </summary>
        public static void Test()
        {
            BasicConsole.WriteLine("Starting virt mem test...");

            try
            {
                impl.Test();

                byte *ptr = (byte *)MapFreePage(VirtMemImpl.PageFlags.KernelOnly);
                for (int i = 0; i < 4096; i++, ptr++)
                {
                    *ptr = 5;

                    if (*ptr != 5)
                    {
                        BasicConsole.WriteLine("Failed to set mem!");
                    }
                }
            }
            catch
            {
                BasicConsole.WriteLine("Exception. Failed test.");
                BasicConsole.WriteLine(ExceptionMethods.CurrentException._Type.Signature);
                BasicConsole.WriteLine(ExceptionMethods.CurrentException.Message);
            }

            BasicConsole.DelayOutput(5);
        }
Beispiel #11
0
        /// <summary>
        /// Initializes the specified disk device.
        /// </summary>
        /// <param name="aDiskDevice">The disk device to initialize.</param>
        public static void InitDisk(DiskDevice aDiskDevice)
        {
            //TODO - Add more partitioning schemes.


            if (InitAsISO9660(aDiskDevice))
            {
#if FSM_TRACE
                BasicConsole.WriteLine("ISO9660 CD/DVD disc detected!");
                BasicConsole.DelayOutput(3);
#endif
            }
            //Must check for GPT before MBR because GPT uses a protective
            //  MBR entry so will be seen as valid MBR.
            else if (InitAsGPT(aDiskDevice))
            {
#if FSM_TRACE
                BasicConsole.WriteLine("GPT formatted disk detected!");
                BasicConsole.DelayOutput(3);
#endif
            }
            else if (!InitAsMBR(aDiskDevice))
            {
                ExceptionMethods.Throw(new FOS_System.Exceptions.NotSupportedException("Non MBR/EBR/GPT/ISO9660 formatted disks not supported."));
            }
        }
Beispiel #12
0
        private void IRQHandler()
        {
#if PATAPI_TRACE
            BasicConsole.WriteLine("PATAPI IRQ occurred!");
            BasicConsole.DelayOutput(10);
#endif
            IRQInvoked = true;
        }
Beispiel #13
0
        protected void Start()
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Start");
            BasicConsole.DelayOutput(5);
#endif

            InitHC();
        }
Beispiel #14
0
 public static bool Sleep_Indefinitely()
 {
     if (ProcessManager.CurrentThread == null)
     {
         BasicConsole.WriteLine("Massive problem! The current thread is null! Can't sleep null thread.");
         BasicConsole.DelayOutput(5);
     }
     return(ProcessManager.CurrentThread._Sleep_Indefinitely());
 }
Beispiel #15
0
 public static void Wake()
 {
     if (ProcessManager.CurrentThread == null)
     {
         BasicConsole.WriteLine("Massive problem! The current thread is null! Can't wake null thread.");
         BasicConsole.DelayOutput(5);
     }
     ProcessManager.CurrentThread._Wake();
 }
Beispiel #16
0
        protected override void _SetupTransfer(USBTransfer transfer)
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Setup Transfer");
            BasicConsole.DelayOutput(5);
#endif

            transfer.underlyingTransferData = qhPointer; // QH
        }
Beispiel #17
0
 public static void EnterSleep(int ms)
 {
     if (ProcessManager.CurrentThread == null)
     {
         BasicConsole.WriteLine("Massive problem! The current thread is null! Can't sleep null thread.");
         BasicConsole.DelayOutput(5);
     }
     ProcessManager.CurrentThread._EnterSleep(ms);
 }
Beispiel #18
0
 /// <summary>
 /// Outputs, via the basic console, how much memory was cleaned up.
 /// </summary>
 /// <param name="startNumObjs">The number of objects before the cleanup.</param>
 /// <param name="startNumStrings">The number of strings before the cleanup.</param>
 private static void PrintCleanupData(int startNumObjs, int startNumStrings)
 {
     int numObjsFreed = startNumObjs - NumObjs;
     int numStringsFreed = startNumStrings - NumStrings;
     BasicConsole.SetTextColour(BasicConsole.warning_colour);
     BasicConsole.WriteLine(((FOS_System.String)"Freed objects: ") + numObjsFreed);
     BasicConsole.WriteLine(((FOS_System.String)"Freed strings: ") + numStringsFreed);
     BasicConsole.WriteLine(((FOS_System.String)"Used memory  : ") + (Heap.FBlock->used * Heap.FBlock->bsize) + " / " + Heap.FBlock->size);
     BasicConsole.DelayOutput(2);
     BasicConsole.SetTextColour(BasicConsole.default_colour);
 }
Beispiel #19
0
        protected bool isTransactionSuccessful(UHCITransaction uT)
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Is Transaction Successful");
            BasicConsole.DelayOutput(5);
#endif
            //TODO: Check actual length field

            //Zero bits:
            //  17, 18, 19, 20, 21, 22, 23
            return((uT.qTD->u1 & 0x00FE0000) == 0);
        }
Beispiel #20
0
        protected static void *AllocQTDbuffer(UHCI_qTD_Struct *td)
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Alloc qTD Buffer");
            BasicConsole.DelayOutput(5);
#endif

            td->virtBuffer = FOS_System.Heap.AllocZeroedAPB(0x1000, 0x1000, "UHCI : AllocQTDBuffer");
            td->buffer     = (uint *)VirtMemManager.GetPhysicalAddress(td->virtBuffer);

            return(td->virtBuffer);
        }
Beispiel #21
0
        protected void AnalysePortStatus(byte j, ushort val)
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Anaylse port status");
            BasicConsole.DelayOutput(5);
#endif

            HCPort port = GetPort(j);
            if ((val & UHCI_Consts.PORT_LOWSPEED_DEVICE) != 0)
            {
#if UHCI_TRACE
                BasicConsole.Write("UHCI: Lowspeed device");
#endif
                port.speed = USBPortSpeed.Low; // Save lowspeed/fullspeed information in data
            }
            else
            {
#if UHCI_TRACE
                BasicConsole.Write("UHCI: Fullspeed device");
#endif
                port.speed = USBPortSpeed.Full; // Save lowspeed/fullspeed information in data
            }

            if (((val & UHCI_Consts.PORT_CS) != 0) && !port.connected)
            {
#if UHCI_TRACE
                BasicConsole.WriteLine(" attached.");
#endif
                port.connected = true;
                ResetPort(j);      // reset on attached

                SetupUSBDevice(j);
            }
            else if (port.connected)
            {
#if UHCI_TRACE
                BasicConsole.WriteLine(" removed.");
#endif
                port.connected = false;

                if (port.deviceInfo != null)
                {
                    port.deviceInfo.FreePort();
                }
            }
#if UHCI_TRACE
            else
            {
                BasicConsole.WriteLine(" not attached.");
            }
#endif
        }
Beispiel #22
0
        /// <summary>
        /// Sets up an IN transaction and adds it to the specified transfer.
        /// </summary>
        /// <param name="transfer">The transfer to which the transaction should be added.</param>
        /// <param name="controlHandshake">Whether the transaction is part of a control handshake or not.</param>
        /// <param name="buffer">The buffer to store the incoming data in.</param>
        /// <param name="length">The length of the buffer.</param>
        public void INTransaction(USBTransfer transfer, bool controlHandshake, void *buffer, ushort length)
        {
#if HCI_TRACE || USB_TRACE
            BasicConsole.WriteLine(((FOS_System.String) "transfer.packetSize=") + transfer.packetSize +
                                   ", length=" + length);
#endif
            ushort clampedLength = FOS_System.Math.Min(transfer.packetSize, length);
            length -= clampedLength;
#if HCI_TRACE || USB_TRACE
            BasicConsole.WriteLine(((FOS_System.String) "clampedLength=") + clampedLength);
            BasicConsole.DelayOutput(1);
#endif
            ushort remainingTransactions = (ushort)(length / transfer.packetSize);
#if HCI_TRACE || USB_TRACE
            BasicConsole.WriteLine("Division passed.");
            BasicConsole.DelayOutput(1);
#endif
            if (length % transfer.packetSize != 0)
            {
                remainingTransactions++;
            }

            USBTransaction transaction = new USBTransaction();
            transaction.type = USBTransactionType.IN;

            if (controlHandshake) // Handshake transaction of control transfers always have toggle set to 1
            {
                ((Endpoint)transfer.device.Endpoints[transfer.endpoint]).Toggle = true;
            }

#if HCI_TRACE
            BasicConsole.WriteLine("Call _INTransaction...");
            BasicConsole.DelayOutput(1);
#endif

            _INTransaction(transfer, transaction, ((Endpoint)transfer.device.Endpoints[transfer.endpoint]).Toggle, buffer, clampedLength);

#if HCI_TRACE
            BasicConsole.WriteLine("Done.");
            BasicConsole.DelayOutput(1);
#endif

            transfer.transactions.Add(transaction);

            ((Endpoint)transfer.device.Endpoints[transfer.endpoint]).Toggle = !((Endpoint)transfer.device.Endpoints[transfer.endpoint]).Toggle; // Switch toggle

            if (remainingTransactions > 0)
            {
                INTransaction(transfer, controlHandshake, ((byte *)buffer + clampedLength), length);
            }
        }
Beispiel #23
0
        public override uint FindFreeVirtPageAddrs(int num)
        {
            int result = UsedVirtPages.FindContiguousClearEntries(num);

            if (result == -1)
            {
                BasicConsole.WriteLine("Error finding free virtual pages!");
                BasicConsole.DelayOutput(10);

                ExceptionMethods.Throw(new FOS_System.Exceptions.OutOfMemoryException("Could not find any more free virtual pages."));
            }

            return((uint)(result * 4096));
        }
Beispiel #24
0
        private static void AddDevice(PCIDevice device, uint step)
        {
            Devices.Add(device);
            DeviceManager.AddDevice(device);

            if (device is PCIDeviceBridge)
            {
#if PCI_TRACE
                BasicConsole.WriteLine("Enumerating PCI Bridge Device...");
                BasicConsole.DelayOutput(5);
#endif

                EnumerateBus(((PCIDeviceBridge)device).SecondaryBusNumber, step + 1);
            }
        }
Beispiel #25
0
        protected void CreateQH(UHCI_QueueHead_Struct *head, uint horizPtr, UHCI_qTD_Struct *firstTD)
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Create QH");
            BasicConsole.DelayOutput(5);
#endif

            head->next = (UHCI_QueueHead_Struct *)UHCI_Consts.BIT_T; // (paging_getPhysAddr((void*)horizPtr) & 0xFFFFFFF0) | BIT_QH;

            if (firstTD == null)
            {
                head->transfer = (UHCI_qTD_Struct *)UHCI_Consts.BIT_T;
            }
            else
            {
                head->transfer = (UHCI_qTD_Struct *)((uint)VirtMemManager.GetPhysicalAddress(firstTD) & 0xFFFFFFF0);
                head->q_first  = firstTD;
            }
        }
Beispiel #26
0
        protected void EnablePorts()
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Enable ports");
            BasicConsole.DelayOutput(5);
#endif

            EnabledPorts = true;

            for (byte j = 0; j < RootPortCount; j++)
            {
                ResetPort(j);

                ushort val = PORTSC1.Read_UInt16((ushort)(2 * j));
#if UHCI_TRACE
                BasicConsole.WriteLine(((FOS_System.String) "UHCI: Port ") + j + " : " + val);
#endif
                AnalysePortStatus(j, val);
            }
        }
Beispiel #27
0
 /// <summary>
 /// Dequeues the oldest scancode from the scancode buffer.
 /// </summary>
 /// <returns>The dequeued scancode.</returns>
 public uint Dequeue()
 {
     //Pops the first item off the top of the queue
     try
     {
         uint result = scancodeBuffer[0];
         scancodeBuffer.RemoveAt(0);
         return(result);
     }
     catch
     {
         for (int i = 0; i < 20; i++)
         {
             BasicConsole.WriteLine(ExceptionMethods.CurrentException.Message);
             BasicConsole.DelayOutput(1);
         }
         ExceptionMethods.Rethrow();
     }
     return(0xFFFFFFFF);
 }
Beispiel #28
0
        public static void HandlePageFault(uint eip, uint errorCode, uint address)
        {
            Hardware.VirtMem.MemoryLayout memLayout = ProcessManager.CurrentProcess.TheMemoryLayout;
            BasicConsole.WriteLine("Code pages:");
            string TempDisplayString = "0x        ";

            for (int i = 0; i < memLayout.CodePages.Keys.Count; i++)
            {
                uint vAddr = memLayout.CodePages.Keys[i];
                WriteNumber(TempDisplayString, vAddr);
                BasicConsole.WriteLine(TempDisplayString);
            }
            BasicConsole.WriteLine("Data pages:");
            for (int i = 0; i < memLayout.DataPages.Keys.Count; i++)
            {
                uint vAddr = memLayout.DataPages.Keys[i];
                WriteNumber(TempDisplayString, vAddr);
                BasicConsole.WriteLine(TempDisplayString);
            }
            BasicConsole.DelayOutput(100);
        }
Beispiel #29
0
        public override void Update()
        {
#if UHCI_TRACE
            BasicConsole.WriteLine("UHCI: Update");
            BasicConsole.DelayOutput(5);
#endif

            for (byte j = 0; j < RootPortCount; j++)
            {
                ushort val = PORTSC1.Read_UInt16((ushort)(2 * j));

                if ((val & UHCI_Consts.PORT_CS_CHANGE) != 0)
                {
#if UHCI_TRACE
                    BasicConsole.WriteLine(((FOS_System.String) "UHCI: Port ") + j + " changed.");
#endif
                    PORTSC1.Write_UInt16(UHCI_Consts.PORT_CS_CHANGE, (ushort)(2 * j));
                    AnalysePortStatus(j, val);
                }
            }
        }
Beispiel #30
0
 private static void ExitCritical()
 {
     //BasicConsole.WriteLine("Exiting critical section...");
     if (AccessLockInitialised)
     {
         if (AccessLock == null)
         {
             BasicConsole.WriteLine("GCAccessLock is initialised but null?!");
             BasicConsole.DelayOutput(10);
         }
         else
         {
             AccessLock.Exit();
         }
     }
     //else
     //{
     //    BasicConsole.WriteLine("GCAccessLock not initialised - ignoring lock conditions.");
     //    BasicConsole.DelayOutput(5);
     //}
 }