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