예제 #1
0
 public void EnableSource(IrqSource s, bool enabled)
 {
     if (enabled)
     {
         enabledSources.Add(s);
     }
     else
     {
         enabledSources.Remove(s);
     }
     irqController.Log(LogLevel.Noisy, "{0} source #{1} @ {2}", enabled ? "Enabling" : "Disabling", s.Id, this);
     RefreshInterrupt();
 }
예제 #2
0
        public void CompleteHandlingInterrupt(IrqSource irq)
        {
            irqController.Log(LogLevel.Noisy, "Completing irq {0} at {1}", irq.Id, this);

            if (activeInterrupts.Count == 0)
            {
                irqController.Log(LogLevel.Error, "Trying to complete irq {0} @ {1}, there are no active interrupts left", irq.Id, this);
                return;
            }
            var topActiveInterrupt = activeInterrupts.Pop();

            if (topActiveInterrupt != irq)
            {
                irqController.Log(LogLevel.Error, "Trying to complete irq {0} @ {1}, but {2} is the active one", irq.Id, this, topActiveInterrupt.Id);
                return;
            }

            irq.IsPending = irq.State;
            RefreshInterrupt();
        }
예제 #3
0
        public PlatformLevelInterruptControllerBase(int numberOfSources, int numberOfContexts, bool prioritiesEnabled, uint extraInterrupts = 0)
        {
            var connections = new Dictionary <int, IGPIO>();

            for (var i = 0; i < numberOfContexts + extraInterrupts; i++)
            {
                connections[i] = new GPIO();
            }
            Connections = connections;

            irqSources = new IrqSource[numberOfSources];
            for (var i = 0u; i < numberOfSources; i++)
            {
                irqSources[i] = new IrqSource(i, this);
            }

            irqContexts = new IrqContext[numberOfContexts];
            for (var i = 0u; i < irqContexts.Length; i++)
            {
                irqContexts[i] = new IrqContext(i, this);
            }
        }