/// <summary>
        /// Creates the partition devices.
        /// </summary>
        public void CreatePartitionDevices()
        {
            // FIXME: Do not create multiple partition devices if this method executed more than once

            // Find all online disk devices
            foreach (var device in deviceManager.GetDevices(new IsDiskDevice(), new IsOnline()))
            {
                var diskDevice = device as IDiskDevice;

                var mbr = new MasterBootBlock(diskDevice);

                if (!mbr.Valid)
                {
                    return;
                }

                for (uint i = 0; i < MasterBootBlock.MaxMBRPartitions; i++)
                {
                    if (mbr.Partitions[i].PartitionType != PartitionType.Empty)
                    {
                        deviceManager.Add(new PartitionDevice(diskDevice, mbr.Partitions[i], false));
                    }
                }
            }
        }
Пример #2
0
        public static void StartISADevice(ISADeviceDriverRegistryEntry driver)
        {
            var hardwareDevice = driver.Factory() as IHardwareDevice;

            var ioPortRegions = new List <IOPortRegion>();
            var memoryRegions = new List <MemoryRegion>();

            ioPortRegions.Add(new IOPortRegion(driver.BasePort, driver.PortRange));

            if (driver.AltBasePort != 0x00)
            {
                ioPortRegions.Add(new IOPortRegion(driver.AltBasePort, driver.AltPortRange));
            }

            if (driver.BaseAddress != 0x00)
            {
                memoryRegions.Add(new MemoryRegion(driver.BaseAddress, driver.AddressRange));
            }

            //if (driver.PhysicalMemory != null)
            //{
            //	foreach (var physicalMemory in driver.PhysicalMemory)
            //	{
            //		if (physicalMemory.MemorySize > 0)
            //		{
            //			var memory = HAL.AllocateMemory(physicalMemory.MemorySize, physicalMemory.MemoryAlignment);

            //			memoryRegions.Add(new MemoryRegion(memory.Address, memory.Size));
            //		}
            //	}
            //}

            var interruptHandler = new InterruptHandler(InterruptManager, driver.IRQ, hardwareDevice);

            var hardwareResources = new HardwareResources(ioPortRegions, memoryRegions, interruptHandler);

            hardwareDevice.Setup(hardwareResources);

            if (!hardwareDevice.Probe())
            {
                return;
            }

            DeviceManager.Add(hardwareDevice);

            hardwareResources.EnableIRQ();

            hardwareDevice.Start();
        }
        /// <summary>
        /// Creates the disk devices.
        /// </summary>
        public void CreateDiskDevices()
        {
            // FIXME: Do not create disk devices if this method executed more than once

            // Find disk controller devices
            var controllers = deviceManager.GetDevices <IDiskControllerDevice>(DeviceStatus.Online);

            // For each controller
            foreach (var device in controllers)
            {
                var controller = device as IDiskControllerDevice;

                // Create disk devices
                var disks = CreateDevices(controller);

                // Add them to the device manager
                foreach (var disk in disks)
                {
                    deviceManager.Add(disk);
                }
            }
        }