RTEMS  5.1
gr1553bm.h
1 /* GR1553B BM driver
2  *
3  * COPYRIGHT (c) 2010.
4  * Cobham Gaisler AB.
5  *
6  * The license and distribution terms for this file may be
7  * found in the file LICENSE in this distribution or at
8  * http://www.rtems.org/license/LICENSE.
9  */
10 
11 #ifndef __GR1553BM_H__
12 #define __GR1553BM_H__
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /* Register GR1553B driver needed by BM driver */
19 extern void gr1553bm_register(void);
20 
22  uint32_t time; /* bit31=1, bit 30=0 */
23  uint32_t data; /* bit31=0, bit 30=0 */
24 };
25 
26 #define GR1553BM_ERROPTS_MANL 0x02
27 #define GR1553BM_ERROPTS_UDWL 0x04
28 #define GR1553BM_ERROPTS_IMCL 0x08
29 #define GR1553BM_ERROPTS_ALL 0x0e
30 
31 /* Function used to implement a custom copy routine.
32  * Returns number of bytes the desctionation address
33  * should be incremented with.
34  *
35  * \param dst Optional Destination address
36  * \param src Source DMA address
37  * \param nentires Number of entries to be processed.
38  * \param data Custom Data (set by config)
39  */
40 typedef int (*bmcopy_func_t)(
41  unsigned int dst,
42  struct gr1553bm_entry *src,
43  int nentries,
44  void *data
45  );
46 
47 /* IRQ function callback, called on BM DMA error */
48 typedef void (*bmisr_func_t)(void *bm, void *data);
49 
50 /* BM driver configuration */
52 
53  /*** Time options ***/
54 
55  /* 8-bit time resolution, the BM will update the time according
56  * to this setting. 0 will make the time tag be of highest
57  * resolution (no division), 1 will make the BM increment the
58  * time tag once for two time ticks (div with 2), etc.
59  */
60  uint8_t time_resolution;
61 
62  /* Enable Time Overflow IRQ handling. Setting this to 1
63  * makes the driver to update the 64-bit time by it self,
64  * it will use time overflow IRQ to detect when the 64-bit
65  * time counter must be incremented.
66  *
67  * If set to zero, the driver expect the user to call
68  * gr1553bm_time() regularly, it must be called more often
69  * than the time overflows to avoid an incorrect time.
70  */
71  int time_ovf_irq;
72 
73 
74 
75  /*** Filtering options ***/
76 
77  /* Bus error log options
78  *
79  * bit0,4-31 = reserved, set to zero
80  * Bit1 = Enables logging of Invalid mode code errors
81  * Bit2 = Enables logging of Unexpected Data errors
82  * Bit3 = Enables logging of Manchester/parity errors
83  */
84  unsigned int filt_error_options;
85 
86  /* RT Address filtering bit mask. Each bit enables (if set)
87  * logging of a certain RT sub address. Bit 31 enables logging
88  * of broadcast messages.
89  */
90  unsigned int filt_rtadr;
91 
92  /* RT Subaddress filtering bit mask, bit definition:
93  * 31: Enables logging of mode commands on subadr 31
94  * 1..30: BitN enables/disables logging of RT subadr N
95  * 0: Enables logging of mode commands on subadr 0
96  */
97  unsigned int filt_subadr;
98 
99  /* Mode code Filter, is written into "BM RT Mode code filter"
100  * register, please see hardware manual for bit declarations.
101  */
102  unsigned int filt_mc;
103 
104 
105 
106  /*** Buffer options ***/
107 
108  /* Size of buffer in bytes, must be aligned to 8-byte
109  * The size is limited to max 4Mb.
110  */
111  unsigned int buffer_size;
112 
113  /* Custom buffer, must be aligned to 8-byte and be of buffer_size
114  * length. If NULL dynamic memory allocation is used.
115  */
116  void *buffer_custom;
117 
118  /* Custom Copy function, may be used to implement a more
119  * effective way of copying the DMA buffer. For example
120  * the DMA log may need to be compressed before copied
121  * onto a storage, this function can be used to avoid an
122  * extra copy.
123  */
124  bmcopy_func_t copy_func;
125 
126  /* Optional Custom Data passed on to copy_func() */
127  void *copy_func_arg;
128 
129 
130 
131  /*** Interrupt options ***/
132 
133  /* Custom DMA error function, note that this function is called
134  * from Interrupt Context. Set to NULL to disable this callback.
135  */
136  bmisr_func_t dma_error_isr;
137 
138  /* Optional Custom Data passed on to dma_error_isr() */
139  void *dma_error_arg;
140 };
141 
142 /* Open BM device by instance number (minor)
143  *
144  * The return value is used as input parameter in all other function calls
145  * in the A
146  */
147 extern void *gr1553bm_open(int minor);
148 
149 /* Close previously opened Bm device */
150 extern void gr1553bm_close(void *bm);
151 
152 /* Configure the BM driver before starting */
153 extern int gr1553bm_config(void *bm, struct gr1553bm_config *cfg);
154 
155 /* Start logging */
156 extern int gr1553bm_start(void *bm);
157 
158 /* Get 64-bit 1553 Time. Low 24-bit time is acquired from BM hardware,
159  * the MSB is taken from a software counter internal to the driver. The
160  * counter is incremented every time the Time overflows by:
161  * - using "Time overflow" IRQ if enabled in user configuration
162  * - by checking IRQ flag (IRQ disabled), it is required that user
163  * calls this function before the next time overflow.
164  *
165  * The BM timer is limited to 24-bits, in order to handle overflows
166  * correctly and maintain a valid time an Interrupt handler is used
167  * or this function must be called when IRQ is not used.
168  *
169  * Update software time counters and return the current time.
170  */
171 extern void gr1553bm_time(void *bm, uint64_t *time);
172 
173 /* Return zero when logging has not been started, non-zero when logging
174  * has been started
175  */
176 extern int gr1553bm_started(void *bm);
177 
178 /* Check how many entries are currently stored in the BM Log DMA-area */
179 extern int gr1553bm_available(void *bm, int *nentries);
180 
181 /* Stop logging */
182 extern void gr1553bm_stop(void *bm);
183 
184 /* Read a maximum number of entries from LOG buffer. This function
185  * must be
186  *
187  * Arguments
188  * bm - Private pointer returned by gr1553bm_open()
189  * dst - Address where log data is written
190  * max - (IN/OUT) Maximum number of entires, when successfull
191  * the number of entries actually written is stored
192  * into the address of max.
193  *
194  * Result
195  * 0 = success
196  * -1 = fail. (may be due to BM logging not started)
197  */
198 extern int gr1553bm_read(void *bm, struct gr1553bm_entry *dst, int *max);
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #endif /* __GR1553BM_H__ */
Definition: gr1553bm.h:21
Definition: gr1553bm.h:51