/// <summary> /// Initializes the Device Driver System. /// </summary> static public void Initialize() { // Create the Device Driver Manager deviceDriverRegistry = new DeviceDriverRegistry(PlatformArchitecture.X86); // Create Resource Manager resourceManager = new ResourceManager(); // Create Device Manager deviceManager = new DeviceManager(); // Create the PCI Controller Manager pciControllerManager = new PCIControllerManager(deviceManager); }
/// <summary> /// Initializes the Device Driver System. /// </summary> public static void Initialize() { // Create the Device Driver Manager deviceDriverRegistry = new DeviceDriverRegistry(PlatformArchitecture.X86); // Create Resource Manager resourceManager = new ResourceManager(); // Create Device Manager deviceManager = new DeviceManager(); // Create the PCI Controller Manager pciControllerManager = new PCIControllerManager(deviceManager); }
public static void Initialize(BaseHardwareAbstraction hardware) { // Create Device Manager DeviceManager = new DeviceManager(); // Create Interrupt Manager InterruptManager = new InterruptManager(); // Create the Device Driver Manager DeviceDriverRegistry = new DeviceDriverRegistry(PlatformArchitecture.X86); // Create the PCI Controller Manager PCIControllerManager = new PCIControllerManager(DeviceManager); // Set device driver system to the hardware HAL HAL.SetHardwareAbstraction(hardware); // Set the interrupt handler HAL.SetInterruptHandler(InterruptManager.ProcessInterrupt); }
/// <summary> /// Starts this instance. /// </summary> public static void Start() { // Setup hardware abstraction interface IHardwareAbstraction hardwareAbstraction = new Mosa.EmulatedKernel.HardwareAbstraction(); // Set device driver system to the emulator port and memory methods Mosa.DeviceSystem.HAL.SetHardwareAbstraction(hardwareAbstraction); // Start the emulated devices Mosa.EmulatedDevices.Setup.Initialize(); // Initialize the driver system Mosa.DeviceSystem.Setup.Initialize(); // Registry device drivers Mosa.DeviceSystem.Setup.DeviceDriverRegistry.RegisterBuiltInDeviceDrivers(); Mosa.DeviceSystem.Setup.DeviceDriverRegistry.RegisterDeviceDrivers(typeof(Mosa.DeviceDrivers.ISA.CMOS).Module.Assembly); // Set the interrupt handler Mosa.DeviceSystem.HAL.SetInterruptHandler(Mosa.DeviceSystem.Setup.ResourceManager.InterruptManager.ProcessInterrupt); // Start the driver system Mosa.DeviceSystem.Setup.Start(); // Create pci controller manager PCIControllerManager pciControllerManager = new PCIControllerManager(Mosa.DeviceSystem.Setup.DeviceManager); // Create pci controller devices pciControllerManager.CreatePartitionDevices(); // Create synthetic graphic pixel device Mosa.EmulatedDevices.Synthetic.PixelGraphicDevice pixelGraphicDevice = new Mosa.EmulatedDevices.Synthetic.PixelGraphicDevice(Mosa.EmulatedDevices.Setup.PrimaryDisplayForm); // Added the synthetic graphic device to the device drivers Mosa.DeviceSystem.Setup.DeviceManager.Add(pixelGraphicDevice); // Create synthetic ram disk device Mosa.EmulatedDevices.Synthetic.RamDiskDevice ramDiskDevice = new Mosa.EmulatedDevices.Synthetic.RamDiskDevice(1024 * 1024 * 10 / 512); // Add emulated ram disk device to the device drivers Mosa.DeviceSystem.Setup.DeviceManager.Add(ramDiskDevice); // Create disk controller manager DiskControllerManager diskControllerManager = new DiskControllerManager(Mosa.DeviceSystem.Setup.DeviceManager); // Create disk devices from disk controller devices diskControllerManager.CreateDiskDevices(); // Get the text VGA device LinkedList<IDevice> devices = Mosa.DeviceSystem.Setup.DeviceManager.GetDevices(new FindDevice.WithName("VGAText")); // Create a screen interface to the text VGA device ITextScreen screen = new TextScreen((ITextDevice)devices.First.value); // Create synthetic keyboard device Mosa.EmulatedDevices.Synthetic.Keyboard keyboard = new Mosa.EmulatedDevices.Synthetic.Keyboard(Mosa.EmulatedDevices.Setup.PrimaryDisplayForm); // Add the synthetic keyboard device to the device drivers Mosa.DeviceSystem.Setup.DeviceManager.Add(keyboard); // Create master boot block record MasterBootBlock mbr = new MasterBootBlock(ramDiskDevice); mbr.DiskSignature = 0x12345678; mbr.Partitions[0].Bootable = true; mbr.Partitions[0].StartLBA = 17; mbr.Partitions[0].TotalBlocks = ramDiskDevice.TotalBlocks - 17; mbr.Partitions[0].PartitionType = PartitionType.FAT12; mbr.Write(); // Create partition device PartitionDevice partitionDevice = new PartitionDevice(ramDiskDevice, mbr.Partitions[0], false); // Set FAT settings FatSettings fatSettings = new FatSettings(); fatSettings.FATType = FatType.FAT12; fatSettings.FloppyMedia = false; fatSettings.VolumeLabel = "MOSADISK"; fatSettings.SerialID = new byte[4] { 0x01, 0x02, 0x03, 0x04 }; // Create FAT file system FatFileSystem fat12 = new FatFileSystem(partitionDevice); fat12.Format(fatSettings); // Create partition manager PartitionManager partitionManager = new PartitionManager(Mosa.DeviceSystem.Setup.DeviceManager); // Create partition devices partitionManager.CreatePartitionDevices(); // Get a list of all devices devices = Mosa.DeviceSystem.Setup.DeviceManager.GetAllDevices(); // Print them screen.WriteLine("Devices: "); foreach (IDevice device in devices) { screen.Write(device.Name); screen.Write(" ["); switch (device.Status) { case DeviceStatus.Online: screen.Write("Online"); break; case DeviceStatus.Available: screen.Write("Available"); break; case DeviceStatus.Initializing: screen.Write("Initializing"); break; case DeviceStatus.NotFound: screen.Write("Not Found"); break; case DeviceStatus.Error: screen.Write("Error"); break; } screen.Write("]"); if (device.Parent != null) { screen.Write(" - Parent: "); screen.Write(device.Parent.Name); } screen.WriteLine(); if (device is IPartitionDevice) { FileSystem.FAT.FatFileSystem fat = new Mosa.FileSystem.FAT.FatFileSystem(device as IPartitionDevice); screen.Write(" File System: "); if (fat.IsValid) { switch (fat.FATType) { case FatType.FAT12: screen.WriteLine("FAT12"); break; case FatType.FAT16: screen.WriteLine("FAT16"); break; case FatType.FAT32: screen.WriteLine("FAT32"); break; default: screen.WriteLine("Unknown"); break; } screen.WriteLine(" Volume Name: " + fat.VolumeLabel); } else screen.WriteLine("Unknown"); } if (device is PCIDevice) { PCIDevice pciDevice = (device as PCIDevice); screen.Write(" Vendor:0x"); screen.Write(pciDevice.VendorID.ToString("X")); screen.Write(" ["); screen.Write(DeviceTable.Lookup(pciDevice.VendorID)); screen.WriteLine("]"); screen.Write(" Device:0x"); screen.Write(pciDevice.DeviceID.ToString("X")); screen.Write(" Rev:0x"); screen.Write(pciDevice.RevisionID.ToString("X")); screen.Write(" ["); screen.Write(DeviceTable.Lookup(pciDevice.VendorID, pciDevice.DeviceID)); screen.WriteLine("]"); screen.Write(" Class:0x"); screen.Write(pciDevice.ClassCode.ToString("X")); screen.Write(" ["); screen.Write(ClassCodeTable.Lookup(pciDevice.ClassCode)); screen.WriteLine("]"); screen.Write(" SubClass:0x"); screen.Write(pciDevice.SubClassCode.ToString("X")); screen.Write(" ["); screen.Write(SubClassCodeTable.Lookup(pciDevice.ClassCode, pciDevice.SubClassCode, pciDevice.ProgIF)); screen.WriteLine("]"); // screen.Write(" "); // screen.WriteLine(DeviceTable.Lookup(pciDevice.VendorID, pciDevice.DeviceID, pciDevice.SubDeviceID, pciDevice.SubVendorID)); foreach (BaseAddress address in pciDevice.BaseAddresses) { if (address == null) continue; if (address.Address == 0) continue; screen.Write(" "); if (address.Region == AddressType.IO) screen.Write("I/O Port at 0x"); else screen.Write("Memory at 0x"); screen.Write(address.Address.ToString("X")); screen.Write(" [size="); if ((address.Size & 0xFFFFF) == 0) { screen.Write((address.Size >> 20).ToString()); screen.Write("M"); } else if ((address.Size & 0x3FF) == 0) { screen.Write((address.Size >> 10).ToString()); screen.Write("K"); } else screen.Write(address.Size.ToString()); screen.Write("]"); if (address.Prefetchable) screen.Write("(prefetchable)"); screen.WriteLine(); } if (pciDevice.IRQ != 0) { screen.Write(" "); screen.Write("IRQ at "); screen.Write(pciDevice.IRQ.ToString()); screen.WriteLine(); } } } //while (keyboard.GetKeyPressed() == null) ; Mosa.HelloWorld.Boot.Main(); //EmulatorDemo.StartDemo(); return; }
/// <summary> /// Initializes the Device Driver System. /// </summary> public static void Initialize() { // Create Resource Manager resourceManager = new ResourceManager(); // Create Device Manager deviceManager = new DeviceManager(); // Create the Device Driver Manager deviceDriverRegistry = new DeviceDriverRegistry(PlatformArchitecture.X86); // Create the PCI Controller Manager pciControllerManager = new PCIControllerManager(deviceManager); // Setup hardware abstraction interface IHardwareAbstraction hardwareAbstraction = new Mosa.CoolWorld.x86.HAL.HardwareAbstraction(); // Set device driver system to the hardware HAL Mosa.DeviceSystem.HAL.SetHardwareAbstraction(hardwareAbstraction); // Set the interrupt handler Mosa.DeviceSystem.HAL.SetInterruptHandler(ResourceManager.InterruptManager.ProcessInterrupt); }
/// <summary> /// Starts the ISA devices. /// </summary> public static void StartISADevices() { //LinkedList<DeviceDriver> deviceDrivers = deviceDriverRegistry.GetISADeviceDrivers(); //foreach (DeviceDriver deviceDriver in deviceDrivers) // StartDevice(deviceDriver); //[ISADeviceDriver(AutoLoad = true, BasePort = 0x60, PortRange = 1, AltBasePort = 0x64, AltPortRange = 1, IRQ = 1, Platforms = PlatformArchitecture.X86AndX64)] ISADeviceDriverAttribute keyboardDeviceAttributes = new ISADeviceDriverAttribute(); keyboardDeviceAttributes.AutoLoad = true; keyboardDeviceAttributes.BasePort = 0x60; keyboardDeviceAttributes.PortRange = 1; keyboardDeviceAttributes.AltBasePort = 0x64; keyboardDeviceAttributes.IRQ = 1; keyboardDeviceAttributes.Platforms = PlatformArchitecture.X86AndX64; //[ISADeviceDriver(AutoLoad = true, BasePort = 0x0CF8, PortRange = 8, Platforms = PlatformArchitecture.X86AndX64)] ISADeviceDriverAttribute pciAttributes = new ISADeviceDriverAttribute(); pciAttributes.AutoLoad = true; pciAttributes.BasePort = 0x0CF8; pciAttributes.PortRange = 8; pciAttributes.Platforms = PlatformArchitecture.X86AndX64; //[ISADeviceDriver(AutoLoad = true, BasePort = 0x20, PortRange = 2, AltBasePort = 0xA0, AltPortRange = 2, Platforms = PlatformArchitecture.X86AndX64)] ISADeviceDriverAttribute picAttributes = new ISADeviceDriverAttribute(); picAttributes.AutoLoad = true; picAttributes.BasePort = 0x20; picAttributes.PortRange = 2; picAttributes.AltBasePort = 0xA0; picAttributes.AltPortRange = 2; picAttributes.Platforms = PlatformArchitecture.X86AndX64; //[ISADeviceDriver(AutoLoad = true, BasePort = 0x40, PortRange = 4, IRQ = 0, Platforms = PlatformArchitecture.X86AndX64)] ISADeviceDriverAttribute pitAttributes = new ISADeviceDriverAttribute(); pitAttributes.AutoLoad = true; pitAttributes.BasePort = 0x40; pitAttributes.PortRange = 4; pitAttributes.IRQ = 0; pitAttributes.Platforms = PlatformArchitecture.X86AndX64; Keyboard = new StandardKeyboard(); PCI = new PCIController(); PIC = new PIC(); PIT = new PIT(); //StartDevice(picAttributes, PIC); StartDevice(pitAttributes, PIT); StartDevice(pciAttributes, PCI); StartDevice(keyboardDeviceAttributes, Keyboard); PCIControllerManager pciController = new PCIControllerManager(deviceManager); Console.Write("Probing PCI devices..."); //pciController.CreatePCIDevices(); Console.WriteLine("[Completed]"); }