public virtual void Print() { BasicConsole.WriteLine("Volume Descriptor:"); BasicConsole.WriteLine(" > Type Code : " + (FOS_System.String)(byte) Code); BasicConsole.WriteLine(" > Id : " + Id); BasicConsole.WriteLine(" > Version : " + (FOS_System.String)Version); }
/// <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); }
/// <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); }
/// <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); }
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(); }
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); }
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); }
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); }
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)); } }
/// <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.")); } }
/// <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); }
/// <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(); }
/// <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); } }
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()); }
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(); }
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); //} }
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; } }
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(); } }
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); }
/// <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)); } }
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 }
/// <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 }
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(); }
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); }
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)); }
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); }
/// <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(); }
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); }
/// <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); }
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; }