public static InBrackets ( string message, byte outerColor, byte innerColor ) : void | ||
message | string | |
outerColor | byte | |
innerColor | byte | |
return | void |
/// <summary> /// Starts the device. /// </summary> /// <param name="deviceDriver">The device driver.</param> static public void StartDevice(Mosa.HardwareSystem.DeviceDriver deviceDriver) { var driverAtttribute = deviceDriver.Attribute as ISADeviceDriverAttribute; // TEMP: Don't load the VGAText and PIC drivers if (driverAtttribute.BasePort == 0x03B0 || driverAtttribute.BasePort == 0x20) { return; } if (!driverAtttribute.AutoLoad) { return; } var hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType) as IHardwareDevice; var ioPortRegions = new LinkedList <IOPortRegion>(); var memoryRegions = new LinkedList <MemoryRegion>(); ioPortRegions.AddLast(new IOPortRegion(driverAtttribute.BasePort, driverAtttribute.PortRange)); if (driverAtttribute.AltBasePort != 0x00) { ioPortRegions.AddLast(new IOPortRegion(driverAtttribute.AltBasePort, driverAtttribute.AltPortRange)); } if (driverAtttribute.BaseAddress != 0x00) { memoryRegions.AddLast(new MemoryRegion(driverAtttribute.BaseAddress, driverAtttribute.AddressRange)); } foreach (var memoryAttribute in deviceDriver.MemoryAttributes) { if (memoryAttribute.MemorySize > 0) { var memory = Mosa.HardwareSystem.HAL.AllocateMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment); memoryRegions.AddLast(new MemoryRegion(memory.Address, memory.Size)); } } var hardwareResources = new HardwareResources( ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(InterruptManager, driverAtttribute.IRQ, hardwareDevice) ); hardwareDevice.Setup(hardwareResources); Boot.Console.Write("Adding device "); Boot.InBrackets(hardwareDevice.Name, Mosa.Kernel.x86.Colors.White, Mosa.Kernel.x86.Colors.LightGreen); Boot.Console.WriteLine(); deviceManager.Add(hardwareDevice); hardwareResources.EnableIRQ(); hardwareDevice.Start(); }
/// <summary> /// Start the Device Driver System. /// </summary> static public void Start() { // Find all drivers Boot.Console.Write("Finding Drivers..."); deviceDriverRegistry.RegisterBuiltInDeviceDrivers(); var count = deviceDriverRegistry.GetPCIDeviceDrivers().Count + deviceDriverRegistry.GetISADeviceDrivers().Count; Boot.Console.WriteLine("[Completed: " + count.ToString() + " found]"); // Start drivers for ISA devices StartISADevices(); // Start drivers for PCI devices StartPCIDevices(); // Get CMOS, StandardKeyboard, and PIC driver instances CMOS = (CMOS)deviceManager.GetDevices(new WithName("CMOS")).First.Value; StandardKeyboard = (StandardKeyboard)deviceManager.GetDevices(new WithName("StandardKeyboard")).First.Value; Boot.Console.Write("Finding disk controllers..."); var diskcontroller = new DiskControllerManager(Setup.DeviceManager); diskcontroller.CreateDiskDevices(); var diskcontrollers = deviceManager.GetDevices(new IsDiskControllerDevice()); Boot.Console.WriteLine("[Completed: " + diskcontrollers.Count.ToString() + " found]"); foreach (var device in diskcontrollers) { Boot.Console.Write("Found controller "); Boot.InBrackets(device.Name, Mosa.Kernel.x86.Colors.White, Mosa.Kernel.x86.Colors.LightGreen); Boot.Console.WriteLine(); } Boot.Console.Write("Finding disks..."); var disks = deviceManager.GetDevices(new IsDiskDevice()); Boot.Console.WriteLine("[Completed: " + disks.Count.ToString() + " found]"); foreach (var disk in disks) { Boot.Console.Write("Spinning up disk "); Boot.InBrackets(disk.Name, Mosa.Kernel.x86.Colors.White, Mosa.Kernel.x86.Colors.LightGreen); Boot.Console.Write(" " + (disk as IDiskDevice).TotalBlocks.ToString() + " blocks"); Boot.Console.WriteLine(); } partitionManager.CreatePartitionDevices(); Boot.Console.Write("Finding partitions..."); var partitions = deviceManager.GetDevices(new IsPartitionDevice()); Boot.Console.WriteLine("[Completed: " + partitions.Count.ToString() + " found]"); foreach (var partition in partitions) { Boot.Console.Write("Opening partition: "); Boot.InBrackets(partition.Name, Mosa.Kernel.x86.Colors.White, Mosa.Kernel.x86.Colors.LightGreen); Boot.Console.Write(" " + (partition as IPartitionDevice).BlockCount.ToString() + " blocks"); Boot.Console.WriteLine(); } Boot.Console.Write("Finding file systems..."); var filesystem = deviceManager.GetDevices(new IsPartitionDevice()); //Boot.Console.WriteLine("[Completed: " + filesystem.Count.ToString() + " found]"); foreach (var partition in partitions) { var fat = new FatFileSystem(partition as IPartitionDevice); if (fat.IsValid) { Boot.Console.WriteLine("Found a FAT file system!"); var filename = "TEST.TXT"; var location = fat.FindEntry(filename); if (location.IsValid) { Boot.Console.WriteLine("Found: " + filename); var fatFileStream = new FatFileStream(fat, location); uint len = (uint)fatFileStream.Length; Boot.Console.WriteLine("Length: " + len.ToString()); Boot.Console.WriteLine("Reading File:"); for (;;) { int i = fatFileStream.ReadByte(); if (i < 0) { break; } Boot.Console.Write((char)i); } } } } }