IRQ: Made the hook structure private
authorMichel Pollet <buserror@gmail.com>
Mon, 21 Dec 2009 21:07:42 +0000 (21:07 +0000)
committerMichel Pollet <buserror@gmail.com>
Mon, 21 Dec 2009 21:07:42 +0000 (21:07 +0000)
No functional changes

Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr/sim/sim_irq.c
simavr/sim/sim_irq.h

index 8faff3f..54e319b 100644 (file)
 #include <string.h>
 #include "sim_irq.h"
 
+// internal structure for a hook, never seen by the notify procs
+typedef struct avr_irq_hook_t {
+       struct avr_irq_hook_t * next;
+       int busy;       // prevent reentrance of callbacks
+       
+       struct avr_irq_t * chain;       // raise the IRQ on this too - optional if "notify" is on
+       avr_irq_notify_t notify;        // called when IRQ is raised - optional if "chain" is on
+       void * param;                           // "notify" parameter
+} avr_irq_hook_t;
 
 void avr_init_irq(avr_irq_t * irq, uint32_t base, uint32_t count)
 {
index 6c5e945..b09137b 100644 (file)
@@ -43,15 +43,6 @@ struct avr_irq_t;
 
 typedef void (*avr_irq_notify_t)(struct avr_irq_t * irq, uint32_t value, void * param);
 
-// internal structure for a hook, never seen by the notify procs
-typedef struct avr_irq_hook_t {
-       struct avr_irq_hook_t * next;
-       int busy;       // prevent reentrance of callbacks
-       
-       struct avr_irq_t * chain;       // raise the IRQ on this too - optional if "notify" is on
-       avr_irq_notify_t notify;        // called when IRQ is raised - optional if "chain" is on
-       void * param;                           // "notify" parameter
-} avr_irq_hook_t;
 
 enum {
        IRQ_FLAG_NOT            = (1 << 0),     // change polarity of the IRQ
@@ -63,19 +54,23 @@ enum {
  * Public IRQ structure
  */
 typedef struct avr_irq_t {
-       uint32_t                        irq;
-       uint32_t                        value;
-       uint8_t                         flags;  // IRQ_*
-       avr_irq_hook_t *        hook;
+       uint32_t                        irq;            // any value the user needs
+       uint32_t                        value;          // current value
+       uint8_t                         flags;          // IRQ_* flags
+       struct avr_irq_hook_t * hook;   // list of hooks to be notified
 } avr_irq_t;
 
+// allocates 'count' IRQs, initializes their "irq" starting from 'base' and increment
 avr_irq_t * avr_alloc_irq(uint32_t base, uint32_t count);
 void avr_free_irq(avr_irq_t * irq, uint32_t count);
 
+// init 'count' IRQs, initializes their "irq" starting from 'base' and increment
 void avr_init_irq(avr_irq_t * irq, uint32_t base, uint32_t count);
+// 'raise' an IRQ. Ie call their 'hooks', and raise any chained IRQs, and set the new 'value'
 void avr_raise_irq(avr_irq_t * irq, uint32_t value);
 // this connects a "source" IRQ to a "destination" IRQ
 void avr_connect_irq(avr_irq_t * src, avr_irq_t * dst);
+// register a notification 'hook' for 'irq' -- 'param' is anything that your want passed back as argument
 void avr_irq_register_notify(avr_irq_t * irq, avr_irq_notify_t notify, void * param);
 
 #endif /* __SIM_IRQ_H__ */