RTEMS: bsps/include/grlib/grtm.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
grtm.h
1/* GRTM Telemetry (TM) driver interface
2 *
3 * COPYRIGHT (c) 2007.
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 __GRTM_H__
12#define __GRTM_H__
13
14#include <rtems.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#define GRTM_IOC_UNUSED 0
21
22/* Driver operation controlling commands */
23#define GRTM_IOC_START 1
24#define GRTM_IOC_STOP 2
25#define GRTM_IOC_ISSTARTED 3
26#define GRTM_IOC_SET_BLOCKING_MODE 4
27#define GRTM_IOC_SET_TIMEOUT 5
28
29/* Available only in STOPPED mode */
30#define GRTM_IOC_SET_CONFIG 32
31
32/* Available in both running and stopped mode */
33#define GRTM_IOC_RECLAIM 64
34#define GRTM_IOC_GET_CONFIG 65
35#define GRTM_IOC_GET_HW_IMPL 66
36#define GRTM_IOC_GET_HW_STATUS 67 /* Not implemented */
37#define GRTM_IOC_GET_OCFREG 68
38#define GRTM_IOC_GET_STATS 69
39#define GRTM_IOC_CLR_STATS 70
40
41/* Available only in RUNNING mode */
42#define GRTM_IOC_SEND 96
43
44/* Args to GRTC_IOC_SET_BLOCKING_MODE */
45enum {
46 GRTM_BLKMODE_POLL = 0, /* Never block (polling mode) */
47 GRTM_BLKMODE_BLK = 1, /* Block until at least 1 byte can be read */
48};
49
50/* Reed Solomon Encoder implemented */
51enum {
52 GRTM_RS_IMPL_NONE = 0,
53 GRTM_RS_IMPL_E16 = 1, /* E16 */
54 GRTM_RS_IMPL_E8 = 2, /* E8 */
55 GRTM_RS_IMPL_BOTH = 3 /* Both E8 and E16 */
56
57};
58
59 struct grtm_ioc_hw {
60 char cs; /* Sub Carrier */
61 char sp; /* Split-Phase Level */
62 char ce;
63 char nrz;
64 char psr;
65 char te;
66 unsigned char rsdep;
67 unsigned char rs;
68 char aasm;
69 char fecf;
70 char ocf;
71 char evc;
72 char idle;
73 char fsh;
74 char mcg;
75 char iz;
76 char fhec;
77 char aos;
78 char cif;
79 char ocfb;
80
81 unsigned short blk_size; /* Block Size */
82 unsigned short fifo_size; /* FIFO Size */
83
84};
85
86/* Driver Mode */
87enum {
88 GRTM_MODE_TM = 0, /* TM */
89 GRTM_MODE_AOS = 1 /* AOS */
90};
91
92/* Physical layer Options */
93#define GRTM_IOC_PHY_SCF (1<<15) /* Sub Carrier Fall */
94#define GRTM_IOC_PHY_SF (1<<31) /* Symbol Fall */
95
96/* Coding Sub-layer Options */
97#define GRTM_IOC_CODE_SC (1<<0) /* Enable Sub Carrier modulation */
98#define GRTM_IOC_CODE_SP (1<<1) /* Enable Split-Phase (SP) level modulation */
99#define GRTM_IOC_CODE_CE (1<<5) /* Enable Convolutional Encoding */
100#define GRTM_IOC_CODE_NRZ (1<<6) /* Enable Non-Return-to-Zero mark encoding */
101#define GRTM_IOC_CODE_PSR (1<<7) /* Enable Pseudo-Randomizer */
102#define GRTM_IOC_CODE_RS8 (1<<11) /* Reed-solomon Encoder to use: 0=E16, 1=E8 */
103#define GRTM_IOC_CODE_RS (1<<15) /* Enable Reed-Solomon Encoder */
104#define GRTM_IOC_CODE_AASM (1<<16) /* Enable Alternative attached synchronization marker */
105#define GRTM_IOC_CODE_ALL (GRTM_IOC_CODE_SC|GRTM_IOC_CODE_SP|GRTM_IOC_CODE_CE| \
106 GRTM_IOC_CODE_NRZ|GRTM_IOC_CODE_PSR|GRTM_IOC_CODE_RS8|\
107 GRTM_IOC_CODE_RS|GRTM_IOC_CODE_AASM)
108
109enum {
110 GRTM_CERATE_00 = 0, /* Rate 1/2, no puncturing */
111 GRTM_CERATE_02 = 2, /* Rate 1/2, punctured */
112 GRTM_CERATE_04 = 4, /* Rate 2/3, punctured */
113 GRTM_CERATE_05 = 5, /* Rate 3/4, punctured */
114 GRTM_CERATE_06 = 6, /* Rate 5/6, punctured */
115 GRTM_CERATE_07 = 7, /* Rate 7/8, punctured */
116};
117
118/* Options for Generating all frames */
119#define GRTM_IOC_ALL_FHEC 0x01 /* Enable Frame Header Error Control (Only AOS) */
120#define GRTM_IOC_ALL_FECF 0x02 /* Enable Transfer Frame CRC */
121#define GRTM_IOC_ALL_IZ 0x04 /* Enable Insert Zone */
122#define GRTM_IOC_ALL_ALL (GRTM_IOC_ALL_FHEC|GRTM_IOC_ALL_FECF|GRTM_IOC_ALL_IZ)
123
124/* Master Frame Generation Options */
125#define GRTM_IOC_MF_OW 0x01 /* Over Write OCF bits 16 and 17 */
126#define GRTM_IOC_MF_OCF 0x02 /* Enable Operation Control Field (OCF) for master channel */
127#define GRTM_IOC_MF_FSH 0x04 /* Enable MC_FSH for master channel */
128#define GRTM_IOC_MF_MC 0x08 /* Enable Master channel counter generation */
129#define GRTM_IOC_MF_ALL (GRTM_IOC_MF_OW|GRTM_IOC_MF_OCF|GRTM_IOC_MF_FSH|GRTM_IOC_MF_MC)
130
131/* Idle Frames Generation Options */
132#define GRTM_IOC_IDLE_MC 0x01 /* Enable Master Channel (MC) counter generation (TM Only) */
133#define GRTM_IOC_IDLE_VCC 0x02 /* Enable Virtual Channel counter cycle generation (AOS Only)*/
134#define GRTM_IOC_IDLE_FSH 0x04 /* Enable Frame Secondary Header (FSH) for idle frames (TM Only) */
135#define GRTM_IOC_IDLE_EVC 0x08 /* Enable Extended Virtual Channel Counter Generation */
136#define GRTM_IOC_IDLE_OCF 0x10 /* Enable OCF/CLCW in idle frame */
137#define GRTM_IOC_IDLE_EN 0x20 /* Enable Idle frame generation */
138#define GRTM_IOC_IDLE_ALL (GRTM_IOC_IDLE_MC|GRTM_IOC_IDLE_VCC|GRTM_IOC_IDLE_FSH| \
139 GRTM_IOC_IDLE_EVC|GRTM_IOC_IDLE_OCF|GRTM_IOC_IDLE_EN)
140
141/* Argument of GRTM_IOC_SET_CONFIG and GRTM_IOC_GET_CONFIG.
142 * Driver and Hardware configuration.
143 *
144 * Pointer to:
145 */
146 struct grtm_ioc_config {
147
148 /* Mode AOS or TM */
149 unsigned char mode; /* 0=TM, 1=AOS */
150
151 unsigned short frame_length; /* Length of every frame transmitted */
152 unsigned short limit; /* Number of data bytes fetched by DMA before transmission starts */
153 unsigned int as_marker; /* Attached Synchronization Marker */
154
155 /* Physical layer options */
156 unsigned short phy_subrate; /* Sub Carrier rate - sub carrier devision factor - 1 */
157 unsigned short phy_symbolrate; /* Symbol Rate division factor - 1 */
158 unsigned char phy_opts; /* Mask of GRTM_IOC_PHY_XXXX */
159
160 /* Coding sub-layer Options */
161 unsigned char code_rsdep; /* Coding sub-layer Reed-Solomon interleave depth (3-bit) */
162 unsigned char code_ce_rate; /* Convolutional encoding rate, select one of GRTM_CERATE_00 ... GRTM_CERATE_07 */
163 unsigned char code_csel; /* */
164 unsigned int code_opts; /* Mask of GRTM_IOC_CODE_XXXX */
165
166 /* All Frames Generation */
167 unsigned char all_izlen; /* FSH/IZ Length (5-bit) */
168 unsigned char all_opts; /* Mask of GRTM_IOC_ALL_XXXX */
169
170 /* Master Frame Generation */
171 unsigned char mf_opts; /* Mask of GRTM_IOC_MF_XXXX */
172
173 /* Idle frame Generation */
174 unsigned short idle_scid;
175 unsigned char idle_vcid;
176 unsigned char idle_opts; /* Mask of GRTM_IOC_IDLE_XXXX */
177
178 /* Interrupt options */
179 unsigned int enable_cnt; /* Number of frames in between Interrupt is generated, Zero disables interrupt */
180 int isr_desc_proc; /* Enable ISR to process descriptors */
181 int blocking; /* Blocking mode select (POLL,BLK..) */
182 rtems_interval timeout; /* Blocking mode timeout */
183};
184
185struct grtm_frame;
186
187 struct grtm_list {
188 struct grtm_frame *head; /* First Frame in list */
189 struct grtm_frame *tail; /* Last Frame in list */
190};
191
192#define GRTM_FLAGS_SENT 0x01
193#define GRRM_FLAGS_ERR 0x02
194
195#define GRTM_FLAGS_TRANSLATE (1<<31) /* Translate frame payload address from CPU address to remote bus (the bus GRTM is resident on) */
196#define GRTM_FLAGS_TRANSLATE_AND_REMEMBER (1<<30) /* As GRTM_FLAGS_TRANSLATE, however if the translated payload address equals the payload address
197 * the GRTM_FLAGS_TRANSLATE_AND_REMEMBER bit is cleared and the GRTM_FLAGS_TRANSLATE bit is set */
198#define GRTM_FLAGS_COPY_DATA (1<<29) /* Where available: Transfer Frame payload to target, may be used for SpaceWire, where the GRTM driver transfer
199 * the payload to a buffer on the SpaceWire target.
200 */
201
202#define GRTM_FLAGS_TS (1<<14)
203#define GRTM_FLAGS_VCE (1<<9)
204#define GRTM_FLAGS_MCB (1<<8)
205#define GRTM_FLAGS_FSHB (1<<7)
206#define GRTM_FLAGS_OCFB (1<<6)
207#define GRTM_FLAGS_FHECB (1<<5)
208#define GRTM_FLAGS_IZB (1<<4)
209#define GRTM_FLAGS_FECFB (1<<3)
210
211#define GRTM_FLAGS_MASK (GRTM_FLAGS_TS|GRTM_FLAGS_VCE|GRTM_FLAGS_MCB|\
212 GRTM_FLAGS_FSHB|GRTM_FLAGS_OCFB|GRTM_FLAGS_FHECB|\
213 GRTM_FLAGS_IZB|GRTM_FLAGS_FECFB)
214
215/* The GRTM software representation of a Frame */
216struct grtm_frame {
217 /* Options and status */
218 unsigned int flags; /* bypass options, and sent/error status */
219
220 struct grtm_frame *next; /* Next packet in chain */
221
222 unsigned int *payload; /* The Headers and Payload, Frame data and header must be word aligned */
223};
224
225#define FRAME_SIZE(payloadlen) (sizeof(struct grtm_frame)+payloadlen)
226
227struct grtm_ioc_stats {
228 unsigned long long frames_sent;
229 unsigned int err_underrun;
230 unsigned int err_tx;
231 unsigned int err_ahb;
232 unsigned int err_transfer_frame;
233};
234
235/* Register GRTM driver at driver manager */
236void grtm_register_drv(void);
237
238/* Register GRTM RMAP driver at driver manager */
239void grtm_rmap_register_drv (void);
240
241#ifdef __cplusplus
242}
243#endif
244
245#endif /* __GRTM_H__ */
rtems_interval
Watchdog_Interval rtems_interval
Used to manage and manipulate intervals specified by clock ticks.
Definition: types.h:127
rtems.h
grtm_frame
Definition: grtm.h:213
grtm_ioc_config
Definition: grtm.h:146
grtm_ioc_hw
Definition: grtm.h:59
grtm_ioc_stats
Definition: grtm.h:224
grtm_list
Definition: grtm.h:187