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