RTEMS  5.1
grtc.h
1 /* GRTC Telecommand (TC) decoder 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 __GRTC_H__
12 #define __GRTC_H__
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #define GRTC_IOC_UNUSED 0
19 
20 /* Driver operation controlling commands */
21 #define GRTC_IOC_START 1
22 #define GRTC_IOC_STOP 2
23 #define GRTC_IOC_ISSTARTED 3
24 #define GRTC_IOC_SET_BLOCKING_MODE 4 /* Raw mode only */
25 #define GRTC_IOC_SET_TIMEOUT 5 /* Raw mode only */
26 
27 #define GRTC_IOC_ADD_BUFF 16 /* Frame mode only */
28 #define GRTC_IOC_RECV 17 /* Frame mode only */
29 
30 /* Available only in STOPPED mode */
31 #define GRTC_IOC_SET_MODE 32 /* Set frame mode (ioctl) or raw mode (read) */
32 #define GRTC_IOC_SET_BUF_PARAM 33
33 #define GRTC_IOC_SET_CONFIG 34
34 #define GRTC_IOC_POOLS_SETUP 35 /* Frame mode only */
35 
36 /* Available in both running and stopped mode */
37 #define GRTC_IOC_GET_CONFIG 64
38 #define GRTC_IOC_GET_BUF_PARAM 65
39 #define GRTC_IOC_GET_HW_STATUS 66
40 #define GRTC_IOC_ASSIGN_FRM_POOL 67
41 #define GRTC_IOC_GET_CLCW_ADR 68 /* Get address of CLCWRx1 */
42 #define GRTC_IOC_GET_STATS 69 /* Get statistics, note that most of the stats are only avilable in FRAME mode */
43 #define GRTC_IOC_CLR_STATS 70 /* Clear statistics */
44 
45 /* Available only in RUNNING mode */
46 
47 /* Args to GRTC_IOC_GET_BUF_PARAMS */
48 #define GRTC_BUF_MAXLEN (0x100*1024)
49 #define GRTC_BUF_MASK 0xfffffc00
51  unsigned int length; /* Length of new buffer in multiples of 1kbyte blocks */
52  void *custom_buffer; /* If set zero driver will allocate with malloc, set LSB to 1 to indicate remote address */
53 };
54 
55 /* Args to GRTC_IOC_SET_BLOCKING_MODE */
56 enum {
57  GRTC_BLKMODE_POLL = 0, /* Never block (polling mode) */
58  GRTC_BLKMODE_BLK = 1, /* Block until at least 1 byte can be read */
59  GRTC_BLKMODE_COMPLETE = 2 /* Block until all data requested has be read */
60 };
61 
62 /* Argument of GRTC_IOC_SET_CONFIG and GRTC_IOC_GET_CONFIG
63  * Pointer to:
64  */
66  int psr_enable;
67  int nrzm_enable;
68  int pss_enable;
69  int crc_calc; /* Enable Software CRC calculation (only Frame mode) */
70 };
71 
72 /* Argument of GRTC_IOC_GET_HW_STATUS:
73  * Pointer to a grtc_ioc_hw_status structure that will be filled
74  * in by driver.
75  */
77  unsigned int sir;
78  unsigned int far;
79  unsigned int clcw1;
80  unsigned int clcw2;
81  unsigned int phir;
82  unsigned int str;
83 };
84 
85 struct grtc_hdr {
86  unsigned short flags_scid;
87  unsigned short vc_len;
88  unsigned char seqnum;
89 } __attribute__((packed));
90 
91 /* Frame pool, all frames in pool have the same buffer length (frame mode only) */
92 struct grtc_frame {
93  struct grtc_frame *next; /* Next frame in list */
94  unsigned short len; /* Length of frame extracted */
95  unsigned short reserved; /* Reserved */
96  struct grtc_frame_pool *pool; /* The frame pool this frame belongs to */
97 
98  /* The Frame content */
99  struct grtc_hdr hdr; /* Primary Header */
100  unsigned char data[3]; /* Frame payload */
101 } __attribute__((packed));
102 
103 /* GRTC_IOC_RECV argument, single linked list of received frames */
104 struct grtc_list {
105  struct grtc_frame *head; /* First frame in list */
106  struct grtc_frame *tail; /* Last frame in list */
107  int cnt; /* Number of frames in list */
108 };
109 
111  unsigned int pool_cnt; /* Number of pools */
112  unsigned int pool_frame_len[1]; /* Array of 'pool_cnt' length: Frame length of frames in a pool
113  * Lengths must be sorted, starting with the smallest frame pool.
114  */
115 };
116 
118  unsigned int frame_len; /* The length of the pool to insert the frame into */
119  struct grtc_frame *frames; /* Frames to assign to a pool */
120 };
121 
122 enum {
123  GRTC_MODE_RAW = 0,
124  GRTC_MODE_FRAME = 1
125 };
126 
127 /* TC driver stats collected during receiving. The statistics is only available
128  * in FRAME mode. In RAW mode the user interprets the incoming frames and is
129  * therefore responsible for generating the staticstics.
130  */
132  unsigned long long frames_recv; /* Total number of non-erroneous frames received */
133  /* Errors related to incoming data */
134  unsigned int err; /* total number of errors */
135  unsigned int err_hdr; /* number of errors in Header */
136  unsigned int err_payload; /* Number of errors in payload */
137  unsigned int err_ending; /* Number of errors in end (Filler, end marker) */
138  unsigned int err_abandoned; /* Number of abandoned frames, NOT IMPLEMENTED */
139  /* Errors related to the handling of incoming frames */
140  unsigned int dropped; /* Number of dropped frames TC driver */
141  unsigned int dropped_no_buf; /* Number of dropped frame caused by no buffers were available */
142  unsigned int dropped_too_long; /* Number of dropped frames that was larger than any buffer available for driver */
143 };
144 
145 /* Register GRTC driver at driver manager */
146 void grtc_register_drv(void);
147 
148 /* Register GRTC RMAP driver at driver manager */
149 void grtc_rmap_register_drv (void);
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 
155 #endif /* __GRTC_H__ */
Definition: grtc.h:92
Definition: grtc.h:104
Definition: grtc.h:50
Definition: grtc.h:117
Definition: grtc.h:65
Definition: grtc.h:110
Definition: grtc.h:85
Definition: grtc.c:217
typedef __attribute__
Disable IRQ Interrupts.
Definition: cmsis_gcc.h:69
Definition: grtc.h:76
Definition: grtc.h:131