Ejemplo n.º 1
0
        /// <summary>
        /// Attempts to initialise a disk treating it as MBR formatted.
        /// </summary>
        /// <param name="aDiskDevice">The disk to initialise.</param>
        /// <returns>True if a valid MBR was detected and the disk was successfully initialised. Otherwise, false.</returns>
        private static bool InitAsMBR(DiskDevice aDiskDevice)
        {
#if FSM_TRACE
            BasicConsole.WriteLine("Attempting to read MBR...");
#endif
            byte[] MBRData = new byte[512];
            aDiskDevice.ReadBlock(0UL, 1U, MBRData);
#if FSM_TRACE
            BasicConsole.WriteLine("Read potential MBR data. Attempting to init MBR...");
#endif
            MBR TheMBR = new MBR(MBRData);

            if (!TheMBR.IsValid)
            {
                return(false);
            }
            else
            {
#if FSM_TRACE
                BasicConsole.WriteLine("Valid MBR found.");
#endif
                ProcessMBR(TheMBR, aDiskDevice);

                return(true);
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Reads the directory's listings off disk unless they have already been
        /// cached.
        /// </summary>
        /// <returns>The listings.</returns>
        public override List GetListings()
        {
            if (_cachedlistings == null)
            {
#if FATDIR_TRACE
                BasicConsole.WriteLine("Getting stream...");
#endif
                Get_FileStream();
#if FATDIR_TRACE
                BasicConsole.WriteLine("Got stream. Calculating actual size...");
#endif
                ulong actualSize = _fileStream.GetActualSize();
#if FATDIR_TRACE
                BasicConsole.WriteLine(((FOS_System.String) "actualSize: ") + actualSize);
                BasicConsole.WriteLine("Creating data array...");
#endif
                byte[] xData = new byte[(uint)actualSize];
#if FATDIR_TRACE
                BasicConsole.WriteLine("Created data array.");
#endif
                _fileStream.Position = 0;
#if FATDIR_TRACE
                BasicConsole.WriteLine("Reading data...");
#endif
                int actuallyRead = _fileStream.Read(xData, 0, (int)xData.Length);
#if FATDIR_TRACE
                BasicConsole.WriteLine("Read data. Parsing table...");
#endif
                _cachedlistings = ((FATFileSystem)TheFileSystem).ParseDirectoryTable(xData, actuallyRead, this);
#if FATDIR_TRACE
                BasicConsole.WriteLine("Parsed table.");
#endif
            }
            return(_cachedlistings);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public static int SyscallHandler(uint syscallNumber, uint param1, uint param2, uint param3,
                                         ref uint Return2, ref uint Return3, ref uint Return4,
                                         uint callerProcesId, uint callerThreadId)
        {
            SystemCallResults result = SystemCallResults.Unhandled;

            switch ((SystemCallNumbers)syscallNumber)
            {
            case SystemCallNumbers.RegisterPipeOutpoint:
                BasicConsole.WriteLine("WM > IH > Actioning Register Pipe Outpoint system call...");
                Pipes.PipeClasses    Class    = (Pipes.PipeClasses)param1;
                Pipes.PipeSubclasses Subclass = (Pipes.PipeSubclasses)param2;
                if (Class == Pipes.PipeClasses.Standard &&
                    Subclass == Pipes.PipeSubclasses.Standard_Out)
                {
                    BasicConsole.WriteLine("WM > IH > Register Pipe Outpoint has desired pipe class and subclass.");
                    result  = SystemCallResults.RequestAction_WakeThread;
                    Return2 = InputProcessingThreadId;
                    InputProcessingThreadAwake = true;
                }
                break;
            }

            return((int)result);
        }
Ejemplo n.º 7
0
        private static void CommonISR(uint ISRNum)
        {
            InsideCriticalHandler = true;

            try
            {
                try
                {
                    if (ISRNum > 31 && ISRNum < 48)
                    {
                        HandleIRQ(ISRNum - 32);
                    }
                    else
                    {
                        HandleISR(ISRNum);
                    }
                }
                catch
                {
                    BasicConsole.WriteLine("Error processing ISR/IRQ!");
                    BasicConsole.WriteLine(ExceptionMethods.CurrentException.Message);
                }
            }
            finally
            {
                InsideCriticalHandler = false;
            }

#if INTERRUPTS_TRACE
            //if (Processes.ProcessManager.Processes.Count > 1)
            //if (ISRNum == 33)
            BasicConsole.WriteLine("Interrupts: 19");
#endif
        }
Ejemplo n.º 8
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);
            //}
        }
Ejemplo n.º 9
0
        public ELFFile(File file)
        {
            theFile = file;
            if (theFile == null)
            {
                Console.Default.ErrorColour();
                Console.Default.Write("Error constructing ELF file! theFile is null");
                BasicConsole.Write("Error constructing ELF file! theFile is null");
                if (file == null)
                {
                    Console.Default.Write(" and file is null");
                    BasicConsole.Write(" and file is null");
                }
                else
                {
                    Console.Default.Write(" and file is NOT null");
                    BasicConsole.Write(" and file is NOT null");
                }
                Console.Default.WriteLine(".");
                BasicConsole.WriteLine(".");
                Console.Default.DefaultColour();
                ExceptionMethods.Throw(new FOS_System.Exception("Error loading ELF file! Supplied file is null."));
            }
            theStream = new CachedFileStream(theFile.GetStream());
            ReadHeader();

            if (IsValidFile())
            {
                ReadSectionHeaders();
                ReadSegmentHeaders();
            }
        }
Ejemplo n.º 10
0
        public virtual Thread CreateThread(ThreadStartMethod MainMethod, FOS_System.String Name)
        {
#if PROCESS_TRACE
            BasicConsole.WriteLine("Creating thread...");
#endif

            Thread newThread = new Thread(this, MainMethod, ThreadIdGenerator++, UserMode, Name);
#if PROCESS_TRACE
            BasicConsole.WriteLine("Adding data page...");
#endif
            // Add the page to the processes memory layout
            uint threadStackVirtAddr = (uint)newThread.State->ThreadStackTop - 4092;
            uint threadStackPhysAddr = (uint)VirtMemManager.GetPhysicalAddress(newThread.State->ThreadStackTop - 4092);
            TheMemoryLayout.AddDataPage(threadStackPhysAddr, threadStackVirtAddr);
            if (ProcessManager.KernelProcess != null)
            {
                ProcessManager.KernelProcess.TheMemoryLayout.AddDataPage(threadStackPhysAddr, threadStackVirtAddr);
            }

#if PROCESS_TRACE
            BasicConsole.WriteLine("Adding thread...");
#endif

            Threads.Add(newThread);
            if (Registered)
            {
                Scheduler.InitThread(this, newThread);
            }

            return(newThread);
        }
Ejemplo n.º 11
0
        public override void ReadBlock(ulong aBlockNo, uint aBlockCount, byte[] aData)
        {
            //ExceptionMethods.Throw(new FOS_System.Exceptions.NotSupportedException("Cannot read from PATAPI device (yet)!"));

            // Reset IRQ (by reading status register)
#if PATAPI_TRACE
            BasicConsole.WriteLine("Reset IRQ");
#endif
            BaseDevice.IO.Status.Read_Byte();
            IRQInvoked = false;

            // Select the drive
#if PATAPI_TRACE
            BasicConsole.WriteLine("Select drive");
#endif
            BaseDevice.SelectDrive(0, false);

            // Read the data
            for (uint i = 0; i < aBlockCount; i++)
            {
#if PATAPI_TRACE
                BasicConsole.WriteLine("Read block");
#endif
                _ReadBlock(aBlockNo + i, aData, (uint)(i * BlockSize));
            }
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
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."));
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Initializes all available file systems by searching for
        /// valid partitions on the available disk devices.
        /// </summary>
        public static void Init()
        {
            Partitions.Empty();
            FileSystemMappings.Empty();

            for (int i = 0; i < DeviceManager.Devices.Count; i++)
            {
                Device aDevice = (Device)DeviceManager.Devices[i];
                if (aDevice is DiskDevice)
                {
                    try
                    {
                        InitDisk((DiskDevice)aDevice);
                    }
                    catch
                    {
                        BasicConsole.WriteLine("Error initializing disk: " + (FOS_System.String)i);
                        BasicConsole.WriteLine(ExceptionMethods.CurrentException.Message);
                        //BasicConsole.DelayOutput(20);
                    }
                }
            }

            InitPartitions();
        }
Ejemplo n.º 15
0
        public virtual Thread CreateThread(ThreadStartMethod MainMethod, FOS_System.String Name)
        {
#if PROCESS_TRACE
            BasicConsole.WriteLine("Process: CreateThread: Creating thread...");
#endif
            //TODO: Wrap EnableKernelAccessToProcessMemory in try-finally blocks

            // Required so that page allocations by new Thread don't create conflicts
            ProcessManager.EnableKernelAccessToProcessMemory(this);

            Thread newThread = new Thread(this, MainMethod, ThreadIdGenerator++, UserMode, Name);
#if PROCESS_TRACE
            BasicConsole.WriteLine("Adding data page...");
#endif
            // Add the page to the processes memory layout
            uint threadStackVirtAddr = (uint)newThread.State->ThreadStackTop - 4092;
            uint threadStackPhysAddr = (uint)VirtMemManager.GetPhysicalAddress(newThread.State->ThreadStackTop - 4092);
            TheMemoryLayout.AddDataPage(threadStackPhysAddr, threadStackVirtAddr);

            ProcessManager.DisableKernelAccessToProcessMemory(this);

#if PROCESS_TRACE
            BasicConsole.WriteLine("Adding thread...");
#endif

            Threads.Add(newThread);

            if (Registered)
            {
                Scheduler.InitThread(this, newThread);
            }

            return(newThread);
        }
Ejemplo n.º 16
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));
            }
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Adds partition info to the list of partitions.
        /// </summary>
        /// <param name="partInfo">The partition info to add.</param>
        protected void AddPartitionToList(PartitionInfo partInfo)
        {
#if MBR_TRACE
            BasicConsole.WriteLine("MBR: 9");
#endif

            //If we need to expand the capacity of the partitions array
            //Note: This stuff was programmed before the List class was programmed.
            if (numPartitions >= PartitionsCapacity)
            {
#if MBR_TRACE
                BasicConsole.WriteLine("MBR: 10");
#endif

                PartitionInfo[] newArray = new PartitionInfo[NumPartitions + 4];
                for (int i = 0; i < numPartitions; i++)
                {
                    newArray[i] = Partitions[i];
                }
                Partitions = newArray;

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

            //Add the partition entry.
            Partitions[numPartitions++] = partInfo;

#if MBR_TRACE
            BasicConsole.WriteLine("MBR: 12");
#endif
        }
Ejemplo n.º 19
0
 public static void DBGERR(FOS_System.String testName, FOS_System.String msg)
 {
     BasicConsole.SetTextColour(BasicConsole.error_colour);
     DBGMSG(testName, msg);
     BasicConsole.SetTextColour(BasicConsole.default_colour);
     errors++;
 }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
0
        private static void OnTimerInterrupt(FOS_System.Object state)
        {
#if SCHEDULER_HANDLER_TRACE || SCHEDULER_HANDLER_MIN_TRACE
            BasicConsole.Write("T");
#endif

            //LockupCounter++;

            //if (LockupCounter > 2000)
            //{
            //    Enable();
            //}

            if (!Enabled || !Initialised)
            {
                return;
            }

            //LockupCounter = 0;

#if SCHEDULER_HANDLER_TRACE || SCHEDULER_HANDLER_MIN_TRACE
            BasicConsole.Write("E");
#endif

            //UpdateCountdown -= MSFreq;

            //if (UpdateCountdown <= 0)
            //{
            //    UpdateCountdown = UpdatePeriod;
            UpdateCurrentState();
            //}
        }
Ejemplo n.º 22
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;
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Performs Deregister System Call Handler system call processing for the Kernel Task.
        /// </summary>
        /// <param name="syscallNum">The system call number to deregister.</param>
        /// <param name="callerProcessId">The Id of the process to deregister the handler of.</param>
        private static void SysCall_DeregisterSyscallHandler(int syscallNum, uint callerProcessId)
        {
#if SYSCALLS_TRACE
            BasicConsole.WriteLine("Deregistering syscall handler...");
#endif
            ProcessManager.GetProcessById(callerProcessId).SyscallsToHandle.Clear(syscallNum);
        }
Ejemplo n.º 24
0
            public override void Print()
            {
                base.Print();

                BasicConsole.WriteLine("    Primary Volume Descriptor:");
                BasicConsole.WriteLine("        > SystemIdentifier : " + SystemIdentifier);
                BasicConsole.WriteLine("        > VolumeIdentifier : " + VolumeIdentifier);
                BasicConsole.WriteLine("        > VolumeSpaceSize : " + (FOS_System.String)VolumeSpaceSize);
                BasicConsole.WriteLine("        > VolumeSetSize : " + (FOS_System.String)VolumeSetSize);
                BasicConsole.WriteLine("        > VolumeSequenceNumber : " + (FOS_System.String)VolumeSequenceNumber);
                BasicConsole.WriteLine("        > LogicalBlockSize : " + (FOS_System.String)LogicalBlockSize);
                BasicConsole.WriteLine("        > PathTableSize : " + (FOS_System.String)PathTableSize);
                BasicConsole.WriteLine("        > Location_PathTable_TypeL : " + (FOS_System.String)Location_PathTable_TypeL);
                BasicConsole.WriteLine("        > Location_PathTable_Optional_TypeL : " + (FOS_System.String)Location_PathTable_Optional_TypeL);
                BasicConsole.WriteLine("        > VolumeSetIdentifier : " + VolumeSetIdentifier);
                BasicConsole.WriteLine("        > PublisherIdentifier : " + PublisherIdentifier);
                BasicConsole.WriteLine("        > DataPreparerIdentifier : " + DataPreparerIdentifier);
                BasicConsole.WriteLine("        > ApplicationIdentifier : " + ApplicationIdentifier);
                BasicConsole.WriteLine("        > CopyrightFileIdentifier : " + CopyrightFileIdentifier);
                BasicConsole.WriteLine("        > AbstractFileIdentifier : " + AbstractFileIdentifier);
                BasicConsole.WriteLine("        > BibliographicFileIdentifier : " + BibliographicFileIdentifier);
                BasicConsole.WriteLine("        > VolumeCreationDateTime : " + VolumeCreationDateTime.ConvertToString());
                BasicConsole.WriteLine("        > VolumeModificationDateTime : " + VolumeModificationDateTime.ConvertToString());
                BasicConsole.WriteLine("        > VolumeExpirationDateTime : " + VolumeExpirationDateTime.ConvertToString());
                BasicConsole.WriteLine("        > VolumeEffectiveDateTime : " + VolumeEffectiveDateTime.ConvertToString());
                BasicConsole.WriteLine("        > FileStructureVersion : " + (FOS_System.String)FileStructureVersion);
                BasicConsole.WriteLine("        Root directory: ");
                BasicConsole.WriteLine(RootDirectory.ConvertToString());
            }
Ejemplo n.º 25
0
        /// <summary>
        /// Performs Wake system call processing for the Kernel Task.
        /// </summary>
        /// <param name="callerProcessId">The Id of the process to wake.</param>
        /// <param name="threadToWakeId">The Id of the thread to wake.</param>
        private static void SysCall_Wake(uint callerProcessId, uint threadToWakeId)
        {
#if SYSCALLS_TRACE
            BasicConsole.WriteLine("Waking thread...");
#endif
            ProcessManager.GetThreadById(threadToWakeId, ProcessManager.GetProcessById(callerProcessId))._Wake();
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Performs Deregister IRQ Handler system call processing for the Kernel Task.
        /// </summary>
        /// <param name="IRQNum">The IRQ number to deregister.</param>
        /// <param name="callerProcessId">The Id of the process to deregister the handler of.</param>
        private static void SysCall_DeregisterIRQHandler(int IRQNum, uint callerProcessId)
        {
#if SYSCALLS_TRACE
            BasicConsole.WriteLine("Deregistering IRQ handler...");
#endif
            ProcessManager.GetProcessById(callerProcessId).IRQsToHandle.Clear(IRQNum);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Performs Sleep system call processing for the Kernel Task.
        /// </summary>
        /// <param name="ms">The number of milliseconds to sleep for.</param>
        /// <param name="callerProcessId">The Id of the process to sleep.</param>
        /// <param name="callerThreadId">The Id of the thread to sleep.</param>
        private static void SysCall_Sleep(int ms, uint callerProcessId, uint callerThreadId)
        {
#if SYSCALLS_TRACE
            BasicConsole.WriteLine("Sleeping thread...");
#endif
            ProcessManager.GetThreadById(callerThreadId, ProcessManager.GetProcessById(callerProcessId))._EnterSleep(ms);
        }
Ejemplo n.º 28
0
        public static Process CreateProcess(ThreadStartMethod MainMethod, FOS_System.String Name, bool UserMode, bool CreateHeap)
        {
#if PROCESSMANAGER_TRACE
            BasicConsole.WriteLine("Creating process object...");
#endif
            return(new Process(MainMethod, ProcessIdGenerator++, Name, UserMode, CreateHeap));
        }
Ejemplo n.º 29
0
        public void Load(bool ProcessIsUM)
        {
            VirtMemImpl.PageFlags flags = ProcessIsUM ? VirtMemImpl.PageFlags.None : VirtMemImpl.PageFlags.KernelOnly;

            UInt32Dictionary.Iterator iterator = CodePages.GetIterator();
            while (iterator.HasNext())
            {
                UInt32Dictionary.KeyValuePair pair = iterator.Next();
                uint vAddr = pair.Key;
                uint pAddr = pair.Value;

#if MEMLAYOUT_TRACE
                BasicConsole.WriteLine("Loading code page...");
#endif
                VirtMemManager.Map(pAddr, vAddr, 4096, flags, UpdateUsedPagesFlags.Virtual);
            }
            iterator.RestoreState();

            flags    = ProcessIsUM ? VirtMemImpl.PageFlags.None : VirtMemImpl.PageFlags.KernelOnly;
            iterator = DataPages.GetIterator();
            while (iterator.HasNext())
            {
                UInt32Dictionary.KeyValuePair pair = iterator.Next();
                uint vAddr = pair.Key;
                uint pAddr = pair.Value;

#if MEMLAYOUT_TRACE
                BasicConsole.WriteLine("Loading data page...");
#endif
                VirtMemManager.Map(pAddr, vAddr, 4096, flags, UpdateUsedPagesFlags.Virtual);
            }
            iterator.RestoreState();
        }
Ejemplo n.º 30
0
        public void Unload()
        {
            if (NoUnload)
            {
                return;
            }

            UInt32Dictionary.Iterator iterator = CodePages.GetIterator();
            while (iterator.HasNext())
            {
                UInt32Dictionary.KeyValuePair pair = iterator.Next();
                uint vAddr = pair.Key;

#if MEMLAYOUT_TRACE
                BasicConsole.WriteLine("Unloading code page...");
#endif
                VirtMemManager.Unmap(vAddr, UpdateUsedPagesFlags.Virtual);
            }
            iterator.RestoreState();

            iterator = DataPages.GetIterator();
            while (iterator.HasNext())
            {
                UInt32Dictionary.KeyValuePair pair = iterator.Next();
                uint vAddr = pair.Key;

#if MEMLAYOUT_TRACE
                BasicConsole.WriteLine("Unloading data page...");
#endif
                VirtMemManager.Unmap(vAddr, UpdateUsedPagesFlags.Virtual);
            }
            iterator.RestoreState();
        }
Ejemplo n.º 31
0
        static void Main(string[] args) {

            Program.m_Args = args;

            bool dotNETCheck = checkNetVersion("3.5");

            if (PRoConApplication.IsProcessOpen() == false && dotNETCheck == true) {

                if (Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Updates")) == true) {
                    AutoUpdater.Arguments = args;
                    AutoUpdater.BeginUpdateProcess(null);
                }
                else {
                    //PRoConApplication paProcon = null;

                    try {

                        bool blBasicConsole = false;
                        bool blGspUpdater = false;

                        int iValue;
                        if (args != null && args.Length >= 2) {
                            for (int i = 0; i < args.Length; i = i + 2) {
                                if (String.Compare("-console", args[i], true) == 0 && int.TryParse(args[i + 1], out iValue) == true && iValue == 1) {
                                    blBasicConsole = true;
                                }
                                if (String.Compare("-gspupdater", args[i], true) == 0 && int.TryParse(args[i + 1], out iValue) == true && iValue == 1) {
                                    blGspUpdater = true;
                                }
                                if (String.Compare("-use_core", args[i], true) == 0 && int.TryParse(args[i + 1], out iValue) == true && iValue > 0)
                                {
                                    System.Diagnostics.Process.GetCurrentProcess().ProcessorAffinity = (System.IntPtr)iValue;
                                }
                            }
                        }

                        //Thread.Sleep(5000);
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);

                        if (blGspUpdater == true) {
                            Application.Run(new GspUpdater());
                        }
                        else {

                            if (blBasicConsole == true) {
                                BasicConsole basicWindow = new BasicConsole();
                                basicWindow.WindowLoaded += new BasicConsole.WindowLoadedHandler(procon_WindowLoaded);

                                Application.Run(basicWindow);

                            }
                            else {
                                frmMain mainWindow = new frmMain(args);
                                mainWindow.WindowLoaded += new frmMain.WindowLoadedHandler(procon_WindowLoaded);
                                Application.Run(mainWindow);
                            }

                        }
                    }
                    catch (Exception e) {
                        FrostbiteConnection.LogError("Application error", String.Empty, e);
                        MessageBox.Show("PRoCon ran into a critical error, but hopefully it logged that error in DEBUG.txt.  Please post/pm/email this to phogue at www.phogue.net.");
                    }
                    finally {
                        if (Program.m_application != null) {
                            Program.m_application.Shutdown();
                        }
                    }
                }
            }
            else {
                // Possible prevention of a cpu consumption bug I can see at the time of writing.
                // TCAdmin: Start procon.exe
                // procon.exe has an update to install
                // procon.exe loads proconupdater.exe
                // procon.exe unloads
                // proconupdater.exe begins update
                // TCAdmin detects procon.exe shutdown - attempts to reload
                Thread.Sleep(50);
            }
        }