Esempio n. 1
0
        /// <summary>
        /// Starts the device.
        /// </summary>
        /// <param name="pciDevice">The pci device.</param>
        static public void StartDevice(IPCIDevice pciDevice)
        {
            var deviceDriver = deviceDriverRegistry.FindDriver(pciDevice);

            if (deviceDriver == null)
            {
                pciDevice.SetNoDriverFound();
                return;
            }

            var hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType);

            if (hardwareDevice == null)
            {
                Mosa.Kernel.x86.Panic.Error("ERROR: hardwareDevice == null");
                return;
            }

            var iHardwareDevice = hardwareDevice as IHardwareDevice;

            if (iHardwareDevice == null)
            {
                Mosa.Kernel.x86.Panic.Error("ERROR: iHardwareDevice == null");
                return;
            }

            //Boot.Console.WriteLine("Found Driver");

            StartDevice(pciDevice, deviceDriver, iHardwareDevice);
        }
Esempio n. 2
0
        /// <summary>
        /// Starts the device.
        /// </summary>
        /// <param name="pciDevice">The pci device.</param>
        static public void StartDevice(IPCIDevice pciDevice)
        {
            DeviceDriver deviceDriver = deviceDriverRegistry.FindDriver(pciDevice);

            if (deviceDriver == null)
            {
                pciDevice.SetNoDriverFound();
                return;
            }

            IHardwareDevice hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType) as IHardwareDevice;

            // MR 07/21/09: Commenting out, causes mono xbuild to fail on MacOS X
            // PCIDeviceDriverAttribute attribute = deviceDriver.Attribute as PCIDeviceDriverAttribute;

            LinkedList <IIOPortRegion> ioPortRegions = new LinkedList <IIOPortRegion>();
            LinkedList <IMemoryRegion> memoryRegions = new LinkedList <IMemoryRegion>();

            foreach (BaseAddress pciBaseAddress in pciDevice.BaseAddresses)
            {
                switch (pciBaseAddress.Region)
                {
                case AddressType.IO: ioPortRegions.Add(new IOPortRegion((ushort)pciBaseAddress.Address, (ushort)pciBaseAddress.Size)); break;

                case AddressType.Memory: memoryRegions.Add(new MemoryRegion(pciBaseAddress.Address, pciBaseAddress.Size)); break;

                default: break;
                }
            }

            foreach (DeviceDriverPhysicalMemoryAttribute memoryAttribute in deviceDriver.MemoryAttributes)
            {
                if (memoryAttribute.MemorySize > 0)
                {
                    IMemory memory = HAL.RequestPhysicalMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment);
                    memoryRegions.Add(new MemoryRegion(memory.Address, memory.Size));
                }
            }

            HardwareResources hardwareResources = new HardwareResources(resourceManager, ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(resourceManager.InterruptManager, pciDevice.IRQ, hardwareDevice), pciDevice as IDeviceResource);

            if (resourceManager.ClaimResources(hardwareResources))
            {
                hardwareResources.EnableIRQ();
                if (hardwareDevice.Start() == DeviceDriverStartStatus.Started)
                {
                    pciDevice.SetDeviceOnline();
                }
                else
                {
                    hardwareResources.DisableIRQ();
                    resourceManager.ReleaseResources(hardwareResources);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Starts the device.
        /// </summary>
        /// <param name="pciDevice">The pci device.</param>
        static public void StartDevice(IPCIDevice pciDevice)
        {
            var deviceDriver = deviceDriverRegistry.FindDriver(pciDevice);

            if (deviceDriver == null)
            {
                pciDevice.SetNoDriverFound();
                return;
            }

            var hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType) as IHardwareDevice;

            StartDevice(pciDevice, deviceDriver, hardwareDevice);
        }
Esempio n. 4
0
        /// <summary>
        /// Starts the device.
        /// </summary>
        /// <param name="pciDevice">The pci device.</param>
        static public void StartDevice(IPCIDevice pciDevice)
        {
            var deviceDriver = deviceDriverRegistry.FindDriver(pciDevice);

            if (deviceDriver == null)
            {
                pciDevice.SetNoDriverFound();
                return;
            }

            var hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType);

            StartDevice(pciDevice, deviceDriver, hardwareDevice as IHardwareDevice);

            if (pciDevice.VendorID == 0x15AD && pciDevice.DeviceID == 0x0405)
            {
                var display = hardwareDevice as IPixelGraphicsDevice;

                var color = new Color(255, 0, 0);

                display.WritePixel(color, 100, 100);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Starts the device.
        /// </summary>
        /// <param name="pciDevice">The pci device.</param>
        public static void StartDevice(IPCIDevice pciDevice)
        {
            DeviceDriver deviceDriver = deviceDriverRegistry.FindDriver(pciDevice);

            if (deviceDriver == null)
            {
                pciDevice.SetNoDriverFound();
                return;
            }

            IHardwareDevice hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType) as IHardwareDevice;

            LinkedList<IIOPortRegion> ioPortRegions = new LinkedList<IIOPortRegion>();
            LinkedList<IMemoryRegion> memoryRegions = new LinkedList<IMemoryRegion>();

            foreach (BaseAddress pciBaseAddress in pciDevice.BaseAddresses)
            {
                switch (pciBaseAddress.Region)
                {
                    case AddressType.IO: ioPortRegions.Add(new IOPortRegion((ushort)pciBaseAddress.Address, (ushort)pciBaseAddress.Size)); break;
                    case AddressType.Memory: memoryRegions.Add(new MemoryRegion(pciBaseAddress.Address, pciBaseAddress.Size)); break;
                    default: break;
                }
            }

            foreach (DeviceDriverPhysicalMemoryAttribute memoryAttribute in deviceDriver.MemoryAttributes)
            {
                if (memoryAttribute.MemorySize > 0)
                {
                    IMemory memory = HAL.AllocateMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment);
                    memoryRegions.Add(new MemoryRegion(memory.Address, memory.Size));
                }
            }

            HardwareResources hardwareResources = new HardwareResources(resourceManager, ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(resourceManager.InterruptManager, pciDevice.IRQ, hardwareDevice), pciDevice as IDeviceResource);

            if (resourceManager.ClaimResources(hardwareResources))
            {
                hardwareResources.EnableIRQ();
                if (hardwareDevice.Start() == DeviceDriverStartStatus.Started)
                {
                    pciDevice.SetDeviceOnline();
                }
                else
                {
                    hardwareResources.DisableIRQ();
                    resourceManager.ReleaseResources(hardwareResources);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Starts the device.
        /// </summary>
        /// <param name="pciDevice">The pci device.</param>
        public static void StartDevice(IPCIDevice pciDevice)
        {
            var deviceDriver = deviceDriverRegistry.FindDriver(pciDevice);

            if (deviceDriver == null)
            {
                pciDevice.SetNoDriverFound();
                return;
            }

            var hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType);

            StartDevice(pciDevice, deviceDriver, hardwareDevice as IHardwareDevice);

            if (pciDevice.VendorID == 0x15AD && pciDevice.DeviceID == 0x0405)
            {
                var display = hardwareDevice as IPixelGraphicsDevice;

                var color = new Color(255, 0, 0);

                display.WritePixel(color, 100, 100);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Starts the device.
        /// </summary>
        /// <param name="pciDevice">The pci device.</param>
        public static void StartDevice(IPCIDevice pciDevice)
        {
            var deviceDriver = deviceDriverRegistry.FindDriver(pciDevice);

            if (deviceDriver == null)
            {
                pciDevice.SetNoDriverFound();
                return;
            }

            var hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType);

            StartDevice(pciDevice, deviceDriver, hardwareDevice as IHardwareDevice);
        }
Esempio n. 8
0
        /// <summary>
        /// Starts the device.
        /// </summary>
        /// <param name="pciDevice">The pci device.</param>
        public static void StartDevice(IPCIDevice pciDevice)
        {
            var deviceDriver = deviceDriverRegistry.FindDriver(pciDevice);

            if (deviceDriver == null)
            {
                pciDevice.SetNoDriverFound();
                return;
            }

            var hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType);

            if (hardwareDevice == null)
            {
                Mosa.Kernel.x86.Panic.Error("ERROR: hardwareDevice == null");
                return;
            }

            var iHardwareDevice = hardwareDevice as IHardwareDevice;

            if (iHardwareDevice == null)
            {
                Mosa.Kernel.x86.Panic.Error("ERROR: iHardwareDevice == null");
                return;
            }

            //Boot.Console.WriteLine("Found Driver");

            StartDevice(pciDevice, deviceDriver, iHardwareDevice);
        }