SimAVR
AVR Simulator
sim_irq.h
Go to the documentation of this file.
1 /*
2  * sim_irq.h
3  *
4  * Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
5  *
6  * This file is part of simavr.
7  *
8  * simavr is free software: you can redistribute it and/or modify it under the terms of the GNU
9  * General Public License as published by Free Software Foundation, either version 3 of the License,
10  * or (at your option) any later version.
11  *
12  * simavr is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
13  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14  * Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with simavr. If not, see
17  * <http://www.gnu.org/licenses/>.
18  */
19 
42 #ifndef __SIM_IRQ_H__
43 #define __SIM_IRQ_H__
44 
45 #include <stdint.h>
46 
47 #ifdef __cplusplus
48 extern "C"
49 {
50 #endif
51 
52  struct avr_irq_t;
53 
58  typedef void (*avr_irq_notify_t) (struct avr_irq_t * irq, uint32_t value, void *param);
59 
60  enum
61  {
62  IRQ_FLAG_NOT = (1 << 0),
63  IRQ_FLAG_FILTERED = (1 << 1),
64  IRQ_FLAG_ALLOC = (1 << 2),
65  IRQ_FLAG_INIT = (1 << 3),
66  };
67 
69  typedef struct avr_irq_pool_t
70  {
71  int count;
72  struct avr_irq_t **irq;
74 
76  typedef struct avr_irq_t
77  {
78  struct avr_irq_pool_t *pool; // TODO: migration in progress
79  const char *name;
80  uint32_t irq;
81  uint32_t value;
82  uint8_t flags;
83  struct avr_irq_hook_t *hook;
84  } avr_irq_t;
85 
87  avr_irq_t *avr_alloc_irq (avr_irq_pool_t * pool, uint32_t base, uint32_t count,
88  const char **names /* optional */ );
90  void avr_free_irq (avr_irq_t * irq, uint32_t count);
91 
93  void avr_init_irq (avr_irq_pool_t * pool, avr_irq_t * irq, uint32_t base, uint32_t count,
94  const char **names /* optional */ );
95 
97  void avr_raise_irq (avr_irq_t * irq, uint32_t value);
98 
100  void avr_connect_irq (avr_irq_t * src, avr_irq_t * dst);
102  void avr_unconnect_irq (avr_irq_t * src, avr_irq_t * dst);
103 
109 
110 #ifdef __cplusplus
111 };
112 #endif
113 
114 #endif /* __SIM_IRQ_H__ */
115 
do not "notify" if "value" is the same as previous raise
Definition: sim_irq.h:63
void * param
Definition: sim_irq.c:34
uint8_t flags
IRQ_* flags.
Definition: sim_irq.h:82
void avr_free_irq(avr_irq_t *irq, uint32_t count)
Free allocated IRQs.
Definition: sim_irq.c:101
change polarity of the IRQ
Definition: sim_irq.h:62
IRQ Pool structure.
Definition: sim_irq.h:69
void avr_irq_unregister_notify(avr_irq_t *irq, avr_irq_notify_t notify, void *param)
Unregister a callback for an irq.
Definition: sim_irq.c:149
struct avr_irq_pool_t * pool
Definition: sim_irq.h:78
uint32_t value
current value
Definition: sim_irq.h:81
struct avr_irq_t ** irq
irqs belonging in this pool
Definition: sim_irq.h:72
Definition: sim_irq.c:27
struct avr_irq_t avr_irq_t
Public IRQ structure.
void avr_connect_irq(avr_irq_t *src, avr_irq_t *dst)
Connect a source IRQ to a destination IRQ.
Definition: sim_irq.c:210
struct avr_irq_hook_t * hook
list of hooks to be notified
Definition: sim_irq.h:83
struct avr_irq_pool_t avr_irq_pool_t
IRQ Pool structure.
void avr_init_irq(avr_irq_pool_t *pool, avr_irq_t *irq, uint32_t base, uint32_t count, const char **names)
Init 'count' IRQs, initializes their "irq" starting from 'base' and increment.
Definition: sim_irq.c:59
this irq structure was malloced via avr_alloc_irq
Definition: sim_irq.h:64
const char * name
Definition: sim_irq.h:79
void avr_raise_irq(avr_irq_t *irq, uint32_t value)
Raise an IRQ. I.e. call their 'hooks', and raise any chained IRQs, and set the new 'value'...
Definition: sim_irq.c:174
uint32_t irq
any value the user needs
Definition: sim_irq.h:80
void avr_irq_register_notify(avr_irq_t *irq, avr_irq_notify_t notify, void *param)
Register a notification hook (callback) for an irq.
Definition: sim_irq.c:129
this irq hasn't been used yet
Definition: sim_irq.h:65
avr_irq_notify_t notify
Definition: sim_irq.c:33
void avr_unconnect_irq(avr_irq_t *src, avr_irq_t *dst)
Disconnect a source IRQ to a destination IRQ.
Definition: sim_irq.c:232
int count
number of irqs living in the pool
Definition: sim_irq.h:71
Public IRQ structure.
Definition: sim_irq.h:76
avr_irq_t * avr_alloc_irq(avr_irq_pool_t *pool, uint32_t base, uint32_t count, const char **names)
Allocates 'count' IRQs, initializes their "irq" starting from 'base' and increment.
Definition: sim_irq.c:79
void(* avr_irq_notify_t)(struct avr_irq_t *irq, uint32_t value, void *param)
Callback Prototype.
Definition: sim_irq.h:58