コード例 #1
0
        public RPCResult <GlobalSystemInterrupt> GetInterruptLine(int gsi_num)
        {
            if (gsi_num < gsibase || gsi_num >= gsibase + 24)
            {
                return new RPCResult <GlobalSystemInterrupt> {
                           Result = null
                }
            }
            ;

            int ioapic_idx = gsi_num - (int)gsibase;

            if (gsis[ioapic_idx] == null)
            {
                return new RPCResult <GlobalSystemInterrupt> {
                           Result = null
                }
            }
            ;
            else
            {
                IOAPICGSI ret = gsis[ioapic_idx];

                gsis[ioapic_idx] = null;
                return(ret);
            }
        }
    }
コード例 #2
0
        public override bool InitServer()
        {
            System.Diagnostics.Debugger.Log(0, "ioapic", "IOAPIC driver started");

            /* Parse properties looking for resources */

            foreach (var prop in props)
            {
                if (prop.Name == "pmem")
                {
                    p_conf = prop.Value as tysos.PhysicalMemoryResource64;
                }
                else if (prop.Name == "vmem")
                {
                    v_conf = prop.Value as tysos.VirtualMemoryResource64;
                }
                else if (prop.Name == "gsibase")
                {
                    gsibase = (uint)prop.Value;
                }
                else if (prop.Name == "ioapicid")
                {
                    id = (uint)prop.Value;
                }
                else if (prop.Name == "interrupts")
                {
                    ints.AddRange(prop.Value as IEnumerable <tysos.Resources.InterruptLine>);
                }
            }

            if (p_conf == null)
            {
                System.Diagnostics.Debugger.Log(0, "ioapic", "no physical memory provided");
                return(false);
            }
            if (v_conf == null)
            {
                System.Diagnostics.Debugger.Log(0, "ioapic", "no virtual memory provided");
                return(false);
            }


            /* Map our configuration space */
            p_conf.Map(v_conf);

            /* Get number of pins */
            uint ioapicver = ReadRegister(0x1);

            redirs = ((ioapicver >> 16) & 0xffU) + 1;

            System.Diagnostics.Debugger.Log(0, "ioapic", "Configuration: p_conf: " + p_conf.Addr64.ToString("X8") +
                                            ", v_conf: " + v_conf.Addr64.ToString("X16") + ", gsibase: " + gsibase.ToString() +
                                            ", ioapicid: " + id.ToString() + ", redirs: " + redirs.ToString());

            /* Build a list of free GSIs.  The standard IOAPIC has 24 pins. */
            for (uint i = 0; i < redirs; i++)
            {
                IOAPICGSI gsi = new IOAPICGSI();
                gsi.apic       = this;
                gsi.gsi_num    = (int)(gsibase + i);
                gsi.ioapic_idx = (int)i;
                gsis[i]        = gsi;
            }

            return(true);
        }