public override void MainMethod() { Ensure.Init(); CPU.DisableInts(); GDT.Init(); IDT.Init(); ISR.Init(); Console.Clear(); ACPI.Init(); ACPI.Enable(); PageManager.Init(); Heap.Init(); GC.Init(); Paging.Init(); PIT.Init(); RTC.Init(); Scheduler.Init(); CPU.EnableInts(); DiskDrive.Init(); //FatFileSystem.Init(); PCI.Init(); Driver.Init(); AudioMixer.Init(); new Thread(Event.Init, "Events").Start(); new Thread(new SCI().Main, "Shell").Start(); Scheduler.Idle(); }
private static void LoadATA() { PCIDevice xDevice = PCI.GetDeviceClass(0x1, 0x1); //Media Storage - IDE Controller if (xDevice != null) { //We are going to support only parallel ata PrimaryIDE = new IDE(false); SecondayIDE = new IDE(true); if (PrimaryIDE.DriveInfo.Device != Device.IDE_None) { Devices.Add(PrimaryIDE); xINT.RegisterHandler(delegate() { PrimaryIDE.IRQInvoked = true; }, 0x2E); } if (SecondayIDE.DriveInfo.Device != Device.IDE_None) { Devices.Add(SecondayIDE); xINT.RegisterHandler(delegate() { SecondayIDE.IRQInvoked = true; }, 0x2F); } } /* * xDevice = PCI.GetDeviceClass(0x1, 0x6);//Media Storage - SATA * if (xDevice != null) * { * * }*/ }
static public void Init(TextScreenBase textScreen) { Console.WriteLine("[Aura Operating System v" + Aura_OS.Kernel.version + " - Made by valentinbreiz and geomtech]"); Aura_OS.System.CustomConsole.WriteLineInfo("Starting Cosmos kernel..."); PCI.Setup(); Aura_OS.System.CustomConsole.WriteLineOK("PCI Devices Scan"); ACPI.Start(); Aura_OS.System.CustomConsole.WriteLineOK("ACPI Initialization"); /*Cosmos.HAL.BlockDevice.IDE.InitDriver(); * Aura_OS.System.CustomConsole.WriteLineOK("IDE Driver Initialization"); * * Cosmos.HAL.BlockDevice.AHCI.InitDriver(); * Aura_OS.System.CustomConsole.WriteLineOK("AHCI Driver Initialization");*/ Cosmos.HAL.Global.PS2Controller.Initialize(); Aura_OS.System.CustomConsole.WriteLineOK("PS/2 Controller Initialization"); //Cosmos.Core.Processing.ProcessorScheduler.Initialize(); //Aura_OS.System.CustomConsole.WriteLineOK("Processor Scheduler Initialization"); Aura_OS.System.CustomConsole.WriteLineOK("Kernel successfully initialized!"); }
private void ComposeGPUData() { m_PGPUs = new List <PGPUInfo>(); var PGPUs = new List <XenAPI.PGPU>(Connection.Cache.PGPUs); PGPUs.Sort(); foreach (XenAPI.PGPU pGpu in PGPUs) { Host host = Connection.Resolve(pGpu.host); if (host == null) { continue; } PCI pci = Connection.Resolve(pGpu.PCI); string temperature = PropertyAccessorHelper.PGPUTemperatureString(pGpu, MetricUpdater); string powerStatus = PropertyAccessorHelper.PGPUPowerUsageString(pGpu, MetricUpdater); string utilisation = PropertyAccessorHelper.PGPUUtilisationString(pGpu, MetricUpdater); string memInfo = PropertyAccessorHelper.PGPUMemoryUsageString(pGpu, MetricUpdater); PGPUInfo buf = new PGPUInfo(pGpu.Name(), pGpu.uuid, host.Name(), pci.pci_id, utilisation, memInfo, temperature, powerStatus); m_PGPUs.Add(buf); } }
public static void Init() { int NetworkDeviceID = 0; Console.WriteLine("Searching for Ethernet Controllers..."); foreach (PCIDevice device in PCI.Devices) { if ((device.ClassCode == 0x02) && (device.Subclass == 0x00) && // is Ethernet Controller device == PCI.GetDevice(device.bus, device.slot, device.function)) { Console.WriteLine("Found " + PCIDevice.DeviceClass.GetDeviceString(device) + " on PCI " + device.bus + ":" + device.slot + ":" + device.function); #region PCNETII if (device.VendorID == (ushort)VendorID.AMD && device.DeviceID == (ushort)DeviceID.PCNETII) { Console.WriteLine("NIC IRQ: " + device.InterruptLine); var AMDPCNetIIDevice = new AMDPCNetII(device); AMDPCNetIIDevice.NameID = ("eth" + NetworkDeviceID); Console.WriteLine("Registered at " + AMDPCNetIIDevice.NameID + " (" + AMDPCNetIIDevice.MACAddress.ToString() + ")"); AMDPCNetIIDevice.Enable(); NetworkDeviceID++; } #endregion #region RTL8139 if (device.VendorID == 0x10EC && device.DeviceID == 0x8139) { var RTL8139Device = new RTL8139(device); RTL8139Device.NameID = ("eth" + NetworkDeviceID); RTL8139Device.Enable(); NetworkDeviceID++; } #endregion } } if (NetworkDevice.Devices.Count == 0) { Console.WriteLine("No supported network card found!!"); } else { Console.WriteLine("Network initialization done!"); } }
protected override void ControlsToData() { if (_bus == null) { _bus = new PCI(); } base.ControlsToData(); ((PCI)_bus).deviceID = edtDeviceId.GetValue <string>(); ((PCI)_bus).vendorID = edtVendorId.GetValue <string>(); }
public static void Init(bool debug = true) { if (debug) { CustomConsole.WriteLineInfo("Finding nic..."); } PCIDevice RTL8168 = PCI.GetDevice((VendorID)0x10EC, (DeviceID)0x8168); if (RTL8168 != null) { if (debug) { CustomConsole.WriteLineOK("Found RTL8168 NIC on PCI " + RTL8168.bus + ":" + RTL8168.slot + ":" + RTL8168.function); CustomConsole.WriteLineInfo("NIC IRQ: " + RTL8168.InterruptLine); } RTL8168NIC = new HAL.Drivers.Network.RTL8168(RTL8168); if (debug) { CustomConsole.WriteLineInfo("NIC MAC Address: " + RTL8168NIC.MACAddress.ToString()); } Network.NetworkStack.Init(); RTL8168NIC.Enable(); } PCIDevice AMDPCNETII = PCI.GetDevice(VendorID.AMD, DeviceID.PCNETII); if (AMDPCNETII != null) { if (debug) { CustomConsole.WriteLineOK("Found AMDPCNETII NIC on PCI " + AMDPCNETII.bus + ":" + AMDPCNETII.slot + ":" + AMDPCNETII.function); CustomConsole.WriteLineInfo("NIC IRQ: " + AMDPCNETII.InterruptLine); } AMDPCNetIINIC = new HAL.Drivers.Network.AMDPCNetII(AMDPCNETII); if (debug) { CustomConsole.WriteLineInfo("NIC MAC Address: " + AMDPCNetIINIC.MACAddress.ToString()); } Network.NetworkStack.Init(); AMDPCNetIINIC.Enable(); } if (RTL8168 == null && AMDPCNETII == null) { CustomConsole.WriteLineError("No supported network card found!!"); return; } if (debug) { CustomConsole.WriteLineOK("Network initialization done!"); } }
public static bool NetworkCardAvailable() { PCIDevice device; device = PCI.GetDevice(VendorID.AMD, DeviceID.PCNETII); if (device != null) { return(true); } else { return(false); } }
private static Canvas GetVideoDriver() { if (_SVGAIIDevice != null && PCI.Exists(_SVGAIIDevice)) { return(new SVGAIICanvas()); } else if (BGAExists()) { return(new VBECanvas()); } else { return(new VGACanvas()); } }
/// <summary> /// Get video driver. /// </summary> /// <param name="mode">Mode.</param> /// <returns>Canvas value.</returns> /// <exception cref="sys.ArgumentOutOfRangeException">Thrown if graphics mode is not suppoted.</exception> private static Canvas GetVideoDriver(Mode mode) { if (_SVGAIIDevice != null && PCI.Exists(_SVGAIIDevice)) { return(new SVGAIICanvas(mode)); } else if (VBEAvailable()) { return(new VBECanvas(mode)); } else { return(new VGACanvas(mode)); } }
/// <summary> /// Get MAC Address String /// </summary> public static string PhysicalAddress() { PCIDevice device; device = PCI.GetDevice(VendorID.AMD, DeviceID.PCNETII); if (NetworkCardAvailable()) { AMDPCNetII nic = new AMDPCNetII(device); return(nic.MACAddress.ToString()); } else { return(""); } }
/// <summary> /// Initializes a new generic host controller interface using the specified PCI device. /// </summary> /// <param name="aPCIDevice">The PCI device that represents the HCI device.</param> public HCI(PCI.PCIDeviceNormal aPCIDevice) : base() { Status = HCIStatus.Unset; pciDevice = aPCIDevice; for (byte i = 0; i < RootPortCount; i++) { RootPorts.Add(new HCPort() { portNum = i }); } }
public static string PGPUUtilisationString(PGPU pGpu, MetricUpdater MetricUpdater) { PCI pci = pGpu.Connection.Resolve(pGpu.PCI); Host host = pGpu.Connection.Resolve(pGpu.host); string pci_id = pci.pci_id.Replace(@":", "/"); double utilisation = MetricUpdater.GetValue(host, String.Format("gpu_utilisation_computer_{0}", pci_id)); if (utilisation == 0 || Double.IsNaN(utilisation) || Double.IsNaN(utilisation)) { return(Messages.HYPHEN); } else { return(utilisation.ToString()); } }
public static string PGPUPowerUsageString(PGPU pGpu, MetricUpdater MetricUpdater) { PCI pci = pGpu.Connection.Resolve(pGpu.PCI); string pci_id = pci.pci_id.Replace(@":", "/"); Host host = pGpu.Connection.Resolve(pGpu.host); double powerUsage = MetricUpdater.GetValue(host, String.Format("gpu_power_usage_{0}", pci_id)); if (powerUsage == 0 || Double.IsNaN(powerUsage) || Double.IsNaN(powerUsage)) { return(Messages.HYPHEN); } else { return(powerUsage.ToString()); } }
public static void Init() { //Load Serial Port at COM-1 Console.Write("Loading Serial Ports... "); Serials.SetupPort(); Console.WriteLine("OK"); // Setup PCI Console.Write("Setting up PCI... "); PCI.Setup(); Console.WriteLine("OK"); // Start ACPI // Initializes and enables itself Console.Write("Setting up ACPI... "); //ACPI = new acpi(true, true); Console.WriteLine("OK"); // Setup Keyboard Console.Write("Setting up PS/2 Keyboard... "); KBD = new Keyboard(); Console.WriteLine("OK"); // Setup Mouse //Console.Write ("Setting up PS/2 Mouse... "); Mouse = new PS2Mouse(); //Console.WriteLine ("OK"); //Loading ATA Console.Write("Loading ATA/SATA SubSystem... "); LoadATA(); Console.WriteLine("OK"); //Load Parts Console.Write("Loading Partitions... "); if (PrimaryIDE != null && PrimaryIDE.DriveInfo.Device == Device.IDE_ATA) { var xMBR = new Drivers.PartInfo.MBR(PrimaryIDE); for (int i = 0; i < xMBR.PartInfo.Count; i++) { Devices.Add(xMBR.PartInfo[i]); } } Console.WriteLine("OK"); }
public static string PGPUMemoryUsageString(PGPU pGpu, MetricUpdater MetricUpdater) { PCI pci = pGpu.Connection.Resolve(pGpu.PCI); string pci_id = pci.pci_id.Replace(@":", "/"); Host host = pGpu.Connection.Resolve(pGpu.host); double free = MetricUpdater.GetValue(host, String.Format("gpu_memory_free_{0}", pci_id)); double used = MetricUpdater.GetValue(host, String.Format("gpu_memory_used_{0}", pci_id)); double total = free + used; if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free)) { return(Messages.HYPHEN); } else { return(String.Format(Messages.QUERY_MEMORY_USAGE, (used / (free + used) * 100).ToString("0.") + "%", Util.MemorySizeString(free + used))); } }
public static void DetectHyperVisor() { AreaInfo.HALDevInfo.WriteDevicePrefix("VIRT", "Detecting host platform..."); PCIDevice Virtualizor = PCI.GetDevice((VendorID)PCIDevicesExtended.VendorID.Virtualbox, (DeviceID)PCIDevicesExtended.DeviceID.VirtualBox); Kernel.VM = Kernel.Hypervisor.VirtualBox; Kernel.Host = PCIDevicesExtended.DeviceIDStr(PCIDevicesExtended.DeviceID.VirtualBox); if (Virtualizor == null) { Virtualizor = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter); Kernel.VM = Kernel.Hypervisor.VMWare; Kernel.Host = PCIDevicesExtended.VendorIDStr(PCIDevicesExtended.VendorID.VMWare); if (Virtualizor == null) { Kernel.IsVirtualised = false; Kernel.VM = Kernel.Hypervisor.RealShit; Kernel.Host = "Non-virtualised hardware or unrecognised host"; } } }
public override void Init() { vendorId = ReadRegister16(PCI.PCI_CONFIG_VENDOR_ID); deviceId = ReadRegister16(PCI.PCI_CONFIG_DEVICE_ID); progIntf = ReadRegister8(PCI.PCI_CONFIG_PROG_INTF); subclass = ReadRegister8(PCI.PCI_CONFIG_SUBCLASS); classCode = ReadRegister8(PCI.PCI_CONFIG_CLASS_CODE); intLine = ReadRegister8(PCI.PCI_CONFIG_INTERRUPT_LINE); secondBus = ReadRegister8(0x19); header = (PCIHeaderType)ReadRegister8(0x0E); label = PCI.GetDetails(vendorId, deviceId, classCode, subclass, progIntf, out type); ushort command = ReadRegister16(0x04); ushort flags = 0x0007; command |= flags; WriteRegister16(0x04, command); if (intLine != 255 && intLine != 0 && classCode != 6 && subclass != 4) { Console.WriteLine(label); } }
/// <summary> /// Checks is VBE is supported exists /// </summary> /// <returns></returns> private static bool VBEAvailable() { if (BGAExists()) { return(true); } else if (PCI.Exists(VendorID.VirtualBox, DeviceID.VBVGA)) { return(true); } else if (PCI.Exists(VendorID.Bochs, DeviceID.BGA)) { return(true); } else if (VBE.IsAvailable()) { return(true); } else { return(false); } }
public VMWareSVGAII() { Device = PCI.GetDeviceVendorID(misc.PCI_VENDOR_ID_VMWARE, misc.PCI_DEVICE_ID_VMWARE_SVGA2); if (Device == null) { throw new Exception("Device Not Found"); } Device.EnableMemory(true); //IO Ports var IOBase = Device.BaseAddressBar[0].BaseAddress; IndexPort = new IOPort((ushort)(IOBase + (ushort)IOPortOffset.Index)); ValuePort = new IOPort((ushort)(IOBase + (ushort)IOPortOffset.Value)); //Memory Block FB_Memory = new MemoryBlock32(Device.BaseAddressBar[1].BaseAddress); FIFO_Memory = new MemoryBlock32(Device.BaseAddressBar[2].BaseAddress); //Version Check VersionID = (UInt32)Versions.SVGA_ID_2; do { WriteRegister(Registers.SVGA_REG_ID, VersionID); if (ReadRegister(Registers.SVGA_REG_ID) == VersionID) { break; } else { VersionID--; } }while (VersionID >= (UInt32)Versions.SVGA_ID_0); if (VersionID < (UInt32)Versions.SVGA_ID_0) { throw new Exception("Error negotiating SVGA device version."); } //Memory Block Length FB_Memory.Length = ReadRegister(Registers.SVGA_REG_FB_SIZE); FIFO_Memory.Length = ReadRegister(Registers.SVGA_REG_MEM_SIZE); //Memory Block Length Check if (FB_Memory.Length < 0x100000) { throw new Exception("FB size very small, probably incorrect."); } if (FIFO_Memory.Length < 0x20000) { throw new Exception("FIFO size very small, probably incorrect."); } if (VersionID >= (UInt32)Versions.SVGA_ID_1) { Capabilities = ReadRegister(Registers.SVGA_REG_CAPABILITIES); } }
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(); }
/// <summary> /// Initialises a new EHCI device using the specified PCI device. Includes starting the host controller. /// </summary> /// <param name="aPCIDevice">The PCI device that represents the physical EHCI device.</param> public EHCI(PCI.PCIDeviceNormal aPCIDevice) : base(aPCIDevice) { #if EHCI_TESTS try { EHCITesting.Test_PointerManipulation(); EHCITesting.Test_StructValueSetting(); EHCITesting.Test_QueueHeadWrapper(); EHCITesting.Test_qTDWrapper(); } catch { BasicConsole.SetTextColour(BasicConsole.warning_colour); BasicConsole.WriteLine(ExceptionMethods.CurrentException.Message); BasicConsole.SetTextColour(BasicConsole.default_colour); } #endif // The USB Base Address is the physical address of the memory mapped registers // used to control the host controller. It is a Memory Space BAR. // The BAR to use is BAR0. // Section 2.1.3 of the Intel EHCI Spec usbBaseAddress = pciDevice.BaseAddresses[0].BaseAddress(); #if EHCI_TRACE BasicConsole.WriteLine(((FOS_System.String)"EHCI: usbBaseAddress=") + (uint)usbBaseAddress); #endif // Map in the required memory - we will use identity mapping for the PCI / USB registers for now Processes.ProcessManager.CurrentProcess.TheMemoryLayout.AddDataPage( (uint)usbBaseAddress & 0xFFFFF000, (uint)usbBaseAddress & 0xFFFFF000); VirtMemManager.Map((uint)usbBaseAddress & 0xFFFFF000, (uint)usbBaseAddress & 0xFFFFF000, 4096, VirtMem.VirtMemImpl.PageFlags.KernelOnly); // Caps registers start at the beginning of the memory mapped IO registers. // Section 2 of the Intel EHCI Spec CapabilitiesRegAddr = usbBaseAddress; #if EHCI_TRACE DBGMSG("CapabilitiesRegAddr: " + (FOS_System.String)(uint)CapabilitiesRegAddr); #endif // Read the Serial Bus Release Number // This is an 8-bit register where 0xXY means Revision X.Y // e.g. 0x20 means Revision 2.0 // Section 2.1.4 of the Intel EHCI Spec SBRN = pciDevice.ReadRegister8(0x60); #if EHCI_TRACE DBGMSG("SBRN: " + (FOS_System.String)SBRN); #endif // The first register of the Capabilities Registers tells you the length // of the registers (in bytes). This provides the offset from the start of // the capabilities registers to the start of the Operational registers. CapabilitiesRegsLength = *CapabilitiesRegAddr; // BCD encoding of the HC Interface version supported by this host controller. // Most Significant Byte is major version // Least Significant Byte is minor version // e.g. 0x20 = Version 2.0 HCIVersion = *((UInt16*)(CapabilitiesRegAddr + 2)); // Host Controller Structural Params // Section 2.2.3 of the Intel EHCI Spec // This register contains various bit fields providing specific information // about the HC hardware / firmware physical design (e.g. number of root ports) HCSParams = *((UInt32*)(CapabilitiesRegAddr + 4)); // Host Controller Capability Params // Section 2.2.4 of the Intel EHCI Spec // This register contains various bit fields providing specific information // about the HC hardware / firmware capabilities (e.g. 64-bit addressing capaiblity) HCCParams = *((UInt32*)(CapabilitiesRegAddr + 8)); // Operational registers address. Calculated as stated above from: // USB Base Address + Length of Capabilities registers. // Section 2.3 of the Intel EHCI Spec OpRegAddr = (uint*)(usbBaseAddress + CapabilitiesRegsLength); #if EHCI_TRACE DBGMSG("CapabilitiesRegsLength: " + (FOS_System.String)CapabilitiesRegsLength); DBGMSG("HCIVersion: " + (FOS_System.String)HCIVersion); DBGMSG("HCSParams: " + (FOS_System.String)HCSParams); DBGMSG("HCCParams: " + (FOS_System.String)HCCParams); //DBGMSG("HCSPPortRouteDesc: " + (FOS_System.String)HCSPPortRouteDesc); DBGMSG("OpRegAddr: " + (FOS_System.String)(uint)OpRegAddr); #endif // Number of root ports // Section 2.2.3 of Intel EHCI Spec RootPortCount = (byte)(HCSParams & 0x000F); // Start the host controller Start(); }
protected override void BeforeRun() { Console.Clear(); #region Register additional network cards int i = 1; foreach (PCIDevice device in PCI.Devices) { if ((device.ClassCode == 0x02) && (device.Subclass == 0x00) && // is Ethernet Controller device == PCI.GetDevice(device.bus, device.slot, device.function)) { Console.WriteLine("Found " + PCIDevice.DeviceClass.GetDeviceString(device) + " on PCI " + device.bus + ":" + device.slot + ":" + device.function); if (device.VendorID == 0x10EC && device.DeviceID == 0x8168) { Console.WriteLine("RTL8168 NIC IRQ: " + device.InterruptLine); var RTL8168Device = new RTL8168(device); RTL8168Device.NameID = "eth" + i; Console.WriteLine("Registered at " + RTL8168Device.NameID + " (" + RTL8168Device.MACAddress.ToString() + ")"); RTL8168Device.Enable(); i++; } } } foreach (var item in Intel8254X.FindAll()) { item.NameID = "eth" + i; item.Enable(); Console.WriteLine("Registered at " + item.NameID + " (" + item.MACAddress.ToString() + ")"); i++; } #endregion try { using (var xClient = new DHCPClient()) { /** Send a DHCP Discover packet **/ //This will automatically set the IP config after DHCP response NetworkStack.Update(); int r = xClient.SendDiscoverPacket(); if (r == -1) { Console.WriteLine("Failure while configuring DHCP: timeout"); xClient.Close(); return; } else { Console.WriteLine("DHCP Configure: result: " + r); } xClient.Close(); //don't forget to close! } ipconfig(); } catch (Exception x) { Console.WriteLine("err: " + x.Message); } NTPClient client = new NTPClient(); var t = client.GetNetworkTime(); Console.WriteLine("Curent time: " + t); HTTPClient http = new HTTPClient("github.com"); var responce = http.GET("/test.html"); Console.WriteLine("===="); Console.WriteLine(responce); }