Exemplo n.º 1
0
        public override bool InitServer()
        {
            System.Diagnostics.Debugger.Log(0, "pciide", "PCI IDE driver started");

            /* Get our ports and interrupt */
            foreach (var r in root)
            {
                if (r.Name == "io" && (r.Value is tysos.x86_64.IOResource))
                {
                    var io = r.Value as tysos.x86_64.IOResource;
                    if (cmd == null && io.Length64 >= 8)
                    {
                        cmd = io;
                    }
                    else
                    {
                        ctrl = io;
                    }
                }
                if (r.Name == "interrupt" && (r.Value is tysos.Resources.InterruptLine))
                {
                    irq = r.Value as tysos.Resources.InterruptLine;
                }
            }

            if (cmd == null || ctrl == null || irq == null)
            {
                System.Diagnostics.Debugger.Log(0, "ata", "Insufficient resources provided");
                return(false);
            }

            Devices = new DeviceInfo[2];

            /* Set control register to 0 - enable interrupts */
            ctrl.Write(ctrl.Addr64, 1, 0);

            /* Enter Init state */
            s     = State.Init;
            drive = 0;

            /* Register IRQ */
            irq.RegisterHandler(new InterruptLine.InterruptHandler(IrqHandler));

            /* Run handler for Init state (unless the IRQ has already done this
             * for us) */
            if (s == State.Init)
            {
                StateMachine((uint)ctrl.Read(ctrl.Addr64, 1), (uint)cmd.Read(cmd.Addr64 + ERROR, 1));
            }

            root.Add(new File.Property {
                Name = "class", Value = "bus"
            });
            Tags.Add("class");

            return(true);
        }
Exemplo n.º 2
0
 public SharedInterruptLine(InterruptLine SharedLine)
 {
     shared_line = SharedLine;
 }
Exemplo n.º 3
0
        public override bool InitServer()
        {
            System.Diagnostics.Debugger.Log(0, "pciide", "PCI IDE driver started");

            pciconf = pci.PCIConfiguration.GetPCIConf(root);
            if (pciconf == null)
            {
                System.Diagnostics.Debugger.Log(0, "pciide", "no PCI configuration provided");
                return(false);
            }

            if (dt == DriverType.Unknown)
            {
                /* Get the type from PCI config space */
                uint conf_8 = pciconf.ReadConfig(0x8);
                uint progIF = (conf_8 >> 8) & 0xffU;
                if ((progIF & 0x5) == 0x5)
                {
                    dt = DriverType.PCINative;
                }
                else
                {
                    dt = DriverType.Legacy;
                }
            }

            /* Get IO port ranges */
            var pri_cmd  = pciconf.GetBAR(0);
            var pri_ctrl = pciconf.GetBAR(1);
            var sec_cmd  = pciconf.GetBAR(2);
            var sec_ctrl = pciconf.GetBAR(3);

            /* Get IRQ ports */
            tysos.Resources.InterruptLine pri_int = null, sec_int = null;
            switch (dt)
            {
            case DriverType.Legacy:
                foreach (var r in root)
                {
                    if (r.Name == "interrupt" && (r.Value is tysos.Resources.InterruptLine))
                    {
                        var r_int = r.Value as tysos.Resources.InterruptLine;
                        if (r_int.ShortName == "IRQ14")
                        {
                            pri_int = r_int;
                        }
                        else if (r_int.ShortName == "IRQ15")
                        {
                            sec_int = r_int;
                        }
                    }
                }
                break;

            case DriverType.PCINative:
                foreach (var r in root)
                {
                    if (r.Name == "interrupt" && (r.Value is tysos.Resources.InterruptLine))
                    {
                        var r_int = r.Value as tysos.Resources.InterruptLine;
                        if (r_int.ShortName.StartsWith("PCI"))
                        {
                            pri_int = r_int;
                            sec_int = r_int;
                            break;
                        }
                    }
                }
                break;
            }

            /* Create child devices */
            if (pri_cmd.Length64 != 0 && pri_ctrl.Length64 != 0 && pri_int != null)
            {
                CreateChannel(0, pri_cmd, pri_ctrl, pri_int);
            }
            if (sec_cmd.Length64 != 0 && sec_ctrl.Length64 != 0 && sec_int != null)
            {
                CreateChannel(1, sec_cmd, sec_ctrl, sec_int);
            }

            root.Add(new File.Property {
                Name = "class", Value = "bus"
            });
            Tags.Add("class");

            return(true);
        }