avrora.sim
Class InterruptTable

java.lang.Object
  extended byavrora.sim.InterruptTable

public class InterruptTable
extends java.lang.Object

The InterruptTable class encapsulates the functionality relating to handling the state of the interrupts in the simulation. It allows probes to be inserted on each interrupt (and globally, for each interrupt) that allow the user's code to be called back when the state of interrupts changes.


Nested Class Summary
static interface InterruptTable.Notification
          The Notification interface serves a very specific role in simulation; for device implementations to be notified when an interrupt that a device may have posted is executed, or when the user forces an interrupt to be notified.
 
Field Summary
protected  long enabled
           
protected  MulticastInterruptProbe globalProbe
           
protected  BaseInterpreter interpreter
           
protected  InterruptTable.Notification[] notify
           
protected  int numInterrupts
           
protected  long pending
           
protected  long posted
           
protected  MulticastInterruptProbe[] probes
           
 
Method Summary
 long getEnabledInterrupts()
          The getEnabledInterrupts() method returns a long integer that represents a bit map of which interrupts are currently enabled, meaning not masked out.
 int getNumberOfInterrupts()
          The getNumberOfInterrupts() method returns the number of interrupts in this interrupt table.
 long getPendingInterrupts()
          The getPendingInterrupts() method returns a long integer that represents a bit map of which interrupts are currently pending, meaning they are both posted and enabled.
 long getPostedInterrupts()
          The getPostedInterrupts() method returns a long integer that represents a bit map of which interrupts are currently posted.
 void insertProbe(Simulator.InterruptProbe p)
          The insertProbe() method inserts a global probe on all of the interrupts.
 void insertProbe(Simulator.InterruptProbe p, int inum)
          The insertProbe() method inserts an interrupt probe on the specified interrupt.
 boolean isEnabled(int inum)
          The isEnabled() method checks whether the specified interrupt is currently enabled.
 boolean isPending(int inum)
          The isPending() method checks whether the specified interrupt is currently pending.
 boolean isPosted(int inum)
          The isPosted() method checks whether the specified interrupt is currently posted.
 void post(int inum)
          The post() method is called by the interpreter when an interrupt is posted.
 void registerInternalNotification(InterruptTable.Notification n, int inum)
          The registerInternalNotification() method is used by devices that require notifications when their interrupt numbers are either forced or invoked.
 void removeProbe(Simulator.InterruptProbe p)
          The removeProbe() method removes a global probe from all of the interrupts.
 void removeProbe(Simulator.InterruptProbe p, int inum)
          The removeProbe() method removes a probe from an interrupt.
 void unpost(int inum)
          The unpost() method is called by the interpreter when an interrupt is unposted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numInterrupts

protected final int numInterrupts

posted

protected long posted

pending

protected long pending

enabled

protected long enabled

globalProbe

protected MulticastInterruptProbe globalProbe

probes

protected final MulticastInterruptProbe[] probes

notify

protected final InterruptTable.Notification[] notify

interpreter

protected final BaseInterpreter interpreter
Method Detail

post

public void post(int inum)
The post() method is called by the interpreter when an interrupt is posted. The interrupt table will adjust the posted and pending masks appropriately and notify any probes for the interrupt.

Parameters:
inum - the interrupt number to post

unpost

public void unpost(int inum)
The unpost() method is called by the interpreter when an interrupt is unposted. The interrupt table will adjust the posted and pending masks appropriately and notify any probes for the interrupt.

Parameters:
inum - the interrupt number to unpost

registerInternalNotification

public void registerInternalNotification(InterruptTable.Notification n,
                                         int inum)
The registerInternalNotification() method is used by devices that require notifications when their interrupt numbers are either forced or invoked.

Parameters:
n - the notification to register for this interrupt
inum - the interrupt number for which to register the notification

getPostedInterrupts

public long getPostedInterrupts()
The getPostedInterrupts() method returns a long integer that represents a bit map of which interrupts are currently posted. For example, bit 1 of this long corresponds to whether interrupt 1 is currently posted.

Returns:
a long integer representing a bit map of the posted interrupts

getPendingInterrupts

public long getPendingInterrupts()
The getPendingInterrupts() method returns a long integer that represents a bit map of which interrupts are currently pending, meaning they are both posted and enabled. For example, bit 1 of this long corresponds to whether interrupt 1 is currently pending.

Returns:
a long integer representing a bit map of the pending interrupts

getEnabledInterrupts

public long getEnabledInterrupts()
The getEnabledInterrupts() method returns a long integer that represents a bit map of which interrupts are currently enabled, meaning not masked out. For example, bit 1 of this long corresponds to whether interrupt 1 is currently enabled.

Returns:
a long integer representing a bit map of the posted interrupts

isPosted

public boolean isPosted(int inum)
The isPosted() method checks whether the specified interrupt is currently posted.

Parameters:
inum - the interrupt number to check
Returns:
true if the specified interrupt is currently posted; false otherwise

isPending

public boolean isPending(int inum)
The isPending() method checks whether the specified interrupt is currently pending.

Parameters:
inum - the interrupt number to check
Returns:
true if the specified interrupt is currently pending; false otherwise

isEnabled

public boolean isEnabled(int inum)
The isEnabled() method checks whether the specified interrupt is currently enabled.

Parameters:
inum - the interrupt number to check
Returns:
true if the specified interrupt is currently enabled; false otherwise

insertProbe

public void insertProbe(Simulator.InterruptProbe p,
                        int inum)
The insertProbe() method inserts an interrupt probe on the specified interrupt. When the specified interrupt changes state, i.e. it is either posted, unposted, or invoked, the probe will be notified.

Parameters:
p - the probe to insert on the specified interrupt
inum - the interrupt on which to insert the probe

removeProbe

public void removeProbe(Simulator.InterruptProbe p,
                        int inum)
The removeProbe() method removes a probe from an interrupt.

Parameters:
p - the probe to remove from this interrupt
inum - the interrupt number from which to remove this probe

insertProbe

public void insertProbe(Simulator.InterruptProbe p)
The insertProbe() method inserts a global probe on all of the interrupts. This probe will be notified when any of the interrupts changes state, and also when the global interrupt flag is enabled or disabled. When the global interrupt flag (master bit) is changed, the special interrupt number 0 will be passed to the fireWhenEnabled() method of the probe.

Parameters:
p - the probe to insert on all the interrupts

removeProbe

public void removeProbe(Simulator.InterruptProbe p)
The removeProbe() method removes a global probe from all of the interrupts.

Parameters:
p - the probe to remove from all of the interrupts

getNumberOfInterrupts

public int getNumberOfInterrupts()
The getNumberOfInterrupts() method returns the number of interrupts in this interrupt table.

Returns:
the number of interrupts in this interrupt table