Belle II Software development
copper.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#ifndef _COPPER_H_
9#define _COPPER_H_
10
11#define COPPER_DRIVER_HEADER_MAGIC 0x7FFF0008
12#define COPPER_DRIVER_FOOTER_MAGIC 0x7FFF0009
13
15 int magic;
16 int event_number;
17 int subsys;
18 int crate;
19 int slot;
20 unsigned int ttrx[2];
21};
22
24 int chksum_xor;
25 int magic;
26};
27
28#ifndef _LINUX_IOCTL_H
29#include <linux/ioctl.h>
30#endif
31
32int peek_next_event_size(void);
33int shift_next_event_size(void);
34
35/* register positions */
36#define COPPER_FF_STA 0x00000000 // COPPER Event FIFO Status
37#define COPPER_CONF_WA_AE 0x00000010 // COPPER Event FIFO Ach Almost Empty
38#define COPPER_CONF_WB_AE 0x00000014 // COPPER Event FIFO Bch Almost Empty
39#define COPPER_CONF_WC_AE 0x00000018 // COPPER Event FIFO Cch Almost Empty
40#define COPPER_CONF_WD_AE 0x0000001C // COPPER Event FIFO Dch Almost Empty
41#define COPPER_CONF_WA_FF 0x00000020 // COPPER Event FIFO Ach Defined Quantity
42#define COPPER_CONF_WB_FF 0x00000024 // COPPER Event FIFO Bch Defined Quantity
43#define COPPER_CONF_WC_FF 0x00000028 // COPPER Event FIFO Cch Defined Quantity
44#define COPPER_CONF_WD_FF 0x0000002C // COPPER Event FIFO Dch Defined Quantity
45#define COPPER_CONF_WA_AF 0x00000030 // COPPER Event FIFO Ach Almost Full
46#define COPPER_CONF_WB_AF 0x00000034 // COPPER Event FIFO Bch Almost Full
47#define COPPER_CONF_WC_AF 0x00000038 // COPPER Event FIFO Cch Almost Full
48#define COPPER_CONF_WD_AF 0x0000003C // COPPER Event FIFO Dch Almost Full
49#define COPPER_FF_RST 0x00000050 // COPPER Event FIFO & FINESSE Soft Reset
50#define COPPER_FINESSE_STA 0x00000054 // FINESSE Status
51#define COPPER_ALMFULL_ENB 0x00000058 // COPPER Almost Full Flag Enable
52#define COPPER_VERSION 0x0000005C // COPPER firmware version
53#define COPPER_TRGCM 0x00000060 // COPPER Trigger Command
54#define COPPER_TRG_LENG 0x00000064 // COPPER Trigger Interval
55#define COPPER_LEF_READSEL 0x00000068 // Length FIFO Read Select
56#define COPPER_LEF_TOTAL 0x0000006C // Length FIFO Total Data
57#define COPPER_LEF_AB 0x00000080 // COPPER Length FIFO A&Bch Data
58#define COPPER_LEF_CD 0x00000084 // COPPER Length FIFO C&Dch Data
59#define COPPER_LEF_STA 0x00000088 // COPPER Length FIFO Status
60#define COPPER_LEF_WA_FF 0x00000090 // COPPER Length FIFO Ach Defined Quantity
61#define COPPER_LEF_WB_FF 0x00000094 // COPPER Length FIFO Bch Defined Quantity
62#define COPPER_LEF_WC_FF 0x00000098 // COPPER Length FIFO Cch Defined Quantity
63#define COPPER_LEF_WD_FF 0x0000009C // COPPER Length FIFO Dch Defined Quantity
64#define COPPER_LEF_WA_AF 0x000000A0 // COPPER Length FIFO Ach Almost Full
65#define COPPER_LEF_WB_AF 0x000000A4 // COPPER Length FIFO Bch Almost Full
66#define COPPER_LEF_WC_AF 0x000000A8 // COPPER Length FIFO Cch Almost Full
67#define COPPER_LEF_WD_AF 0x000000AC // COPPER Length FIFO Dch Almost Full
68#define COPPER_INT_STA 0x000000B0 // COPPER Interrupt Status
69#define COPPER_INT_MASK 0x000000B4 // COPPER Interrupt Mask
70#define COPPER_FF_RW 0x000000B8 // COPPER Event FIFO Single Read/Write Control
71#define COPPER_INT_FACTOR 0x000000BC // COPPER Interruption Factor Reg.
72#define COPPER_FF_WA 0x00000100 // COPPER Event FIFO Ach Single Write
73#define COPPER_FF_WB 0x00000104 // COPPER Event FIFO Bch Single Write
74#define COPPER_FF_WC 0x00000108 // COPPER Event FIFO Cch Single Write
75#define COPPER_FF_WD 0x0000010C // COPPER Event FIFO Dch Single Write
76#define COPPER_FF_RA 0x00000110 // COPPER Event FIFO Ach Single Read
77#define COPPER_FF_RB 0x00000114 // COPPER Event FIFO Bch Single Read
78#define COPPER_FF_RC 0x00000118 // COPPER Event FIFO Cch Single Read
79#define COPPER_FF_RD 0x0000011C // COPPER Event FIFO Dch Single Read
80#define COPPER_FF_DMA 0x00400000 // Event FIFO DMA Read Reg.
81
82// 2005/01/17 Append
83#define COPPER_EWRP_A 0x00000140 // COPPER Event FIFO Ach Read/Write Pointer
84#define COPPER_EWRP_B 0x00000144 // COPPER Event FIFO Bch Read/Write Pointer
85#define COPPER_EWRP_C 0x00000148 // COPPER Event FIFO Cch Read/Write Pointer
86#define COPPER_EWRP_D 0x0000014C // COPPER Event FIFO Dch Read/Write Pointer
87
88#define COPPER_WEA_COUNTER 0x00000150 // FINESSE Ach WE Counter
89#define COPPER_WEB_COUNTER 0x00000154 // FINESSE Bch WE Counter
90#define COPPER_WEC_COUNTER 0x00000158 // FINESSE Cch WE Counter
91#define COPPER_WED_COUNTER 0x0000015C // FINESSE Dch WE Counter
92
93#define COPPER_LWRA_DMA 0x00000160 // COPPER Length FIFO Ach Read/Write Pointer for DMA
94#define COPPER_LWRB_DMA 0x00000164 // COPPER Length FIFO Bch Read/Write Pointer for DMA
95#define COPPER_LWRC_DMA 0x00000168 // COPPER Length FIFO Cch Read/Write Pointer for DMA
96#define COPPER_LWRD_DMA 0x0000016C // COPPER Length FIFO Dch Read/Write Pointer for DMA
97
98#define COPPER_DMA_TRANS 0x00000170 // COPPER DMA Counter
99#define COPPER_DMA_TS_ENB 0x00000174 // COPPER DMA Counter Control
100
101#define COPPER_RW_DEBUG 0x000000FC // Memory for Debug
102
103/* alias */
104
105#define COPPER_LEF_WA_THR COPPER_LEF_WA_FF
106#define COPPER_LEF_WB_THR COPPER_LEF_WB_FF
107#define COPPER_LEF_WC_THR COPPER_LEF_WC_FF
108#define COPPER_LEF_WD_THR COPPER_LEF_WD_FF
109
110/* ioctl cmds */
111
112#define COPPER_MAGIC 0xdf
113
114#define CPRIOGET_FF_STA _IOR(COPPER_MAGIC, COPPER_FF_STA, sizeof(unsigned int))
115#define CPRIOGET_CONF_WA_AE _IOR(COPPER_MAGIC, COPPER_CONF_WA_AE, sizeof(unsigned int))
116#define CPRIOGET_CONF_WB_AE _IOR(COPPER_MAGIC, COPPER_CONF_WB_AE, sizeof(unsigned int))
117#define CPRIOGET_CONF_WC_AE _IOR(COPPER_MAGIC, COPPER_CONF_WC_AE, sizeof(unsigned int))
118#define CPRIOGET_CONF_WD_AE _IOR(COPPER_MAGIC, COPPER_CONF_WD_AE, sizeof(unsigned int))
119#define CPRIOGET_CONF_WA_FF _IOR(COPPER_MAGIC, COPPER_CONF_WA_FF, sizeof(unsigned int))
120#define CPRIOGET_CONF_WB_FF _IOR(COPPER_MAGIC, COPPER_CONF_WB_FF, sizeof(unsigned int))
121#define CPRIOGET_CONF_WC_FF _IOR(COPPER_MAGIC, COPPER_CONF_WC_FF, sizeof(unsigned int))
122#define CPRIOGET_CONF_WD_FF _IOR(COPPER_MAGIC, COPPER_CONF_WD_FF, sizeof(unsigned int))
123#define CPRIOGET_CONF_WA_AF _IOR(COPPER_MAGIC, COPPER_CONF_WA_AF, sizeof(unsigned int))
124#define CPRIOGET_CONF_WB_AF _IOR(COPPER_MAGIC, COPPER_CONF_WB_AF, sizeof(unsigned int))
125#define CPRIOGET_CONF_WC_AF _IOR(COPPER_MAGIC, COPPER_CONF_WC_AF, sizeof(unsigned int))
126#define CPRIOGET_CONF_WD_AF _IOR(COPPER_MAGIC, COPPER_CONF_WD_AF, sizeof(unsigned int))
127#define CPRIOGET_FF_RST _IOR(COPPER_MAGIC, COPPER_FF_RST, sizeof(unsigned int))
128#define CPRIOGET_FINESSE_STA _IOR(COPPER_MAGIC, COPPER_FINESSE_STA, sizeof(unsigned int))
129#define CPRIOGET_ALMFULL_ENB _IOR(COPPER_MAGIC, COPPER_ALMFULL_ENB, sizeof(unsigned int))
130#define CPRIOGET_VERSION _IOR(COPPER_MAGIC, COPPER_VERSION, sizeof(unsigned int))
131#define CPRIOGET_TRGCM _IOR(COPPER_MAGIC, COPPER_TRGCM, sizeof(unsigned int))
132#define CPRIOGET_TRG_LENG _IOR(COPPER_MAGIC, COPPER_TRG_LENG, sizeof(unsigned int))
133#define CPRIOGET_LEF_READSEL _IOR(COPPER_MAGIC, COPPER_LEF_READSEL, sizeof(unsigned int))
134#define CPRIOGET_LEF_TOTAL _IOR(COPPER_MAGIC, COPPER_LEF_TOTAL, sizeof(unsigned int))
135#define CPRIOGET_LEF_AB _IOR(COPPER_MAGIC, COPPER_LEF_AB, sizeof(unsigned int))
136#define CPRIOGET_LEF_CD _IOR(COPPER_MAGIC, COPPER_LEF_CD, sizeof(unsigned int))
137#define CPRIOGET_LEF_STA _IOR(COPPER_MAGIC, COPPER_LEF_STA, sizeof(unsigned int))
138#define CPRIOGET_LEF_WA_FF _IOR(COPPER_MAGIC, COPPER_LEF_WA_FF, sizeof(unsigned int))
139#define CPRIOGET_LEF_WB_FF _IOR(COPPER_MAGIC, COPPER_LEF_WB_FF, sizeof(unsigned int))
140#define CPRIOGET_LEF_WC_FF _IOR(COPPER_MAGIC, COPPER_LEF_WC_FF, sizeof(unsigned int))
141#define CPRIOGET_LEF_WD_FF _IOR(COPPER_MAGIC, COPPER_LEF_WD_FF, sizeof(unsigned int))
142#define CPRIOGET_LEF_WA_AF _IOR(COPPER_MAGIC, COPPER_LEF_WA_AF, sizeof(unsigned int))
143#define CPRIOGET_LEF_WB_AF _IOR(COPPER_MAGIC, COPPER_LEF_WB_AF, sizeof(unsigned int))
144#define CPRIOGET_LEF_WC_AF _IOR(COPPER_MAGIC, COPPER_LEF_WC_AF, sizeof(unsigned int))
145#define CPRIOGET_LEF_WD_AF _IOR(COPPER_MAGIC, COPPER_LEF_WD_AF, sizeof(unsigned int))
146#define CPRIOGET_INT_STA _IOR(COPPER_MAGIC, COPPER_INT_STA, sizeof(unsigned int))
147#define CPRIOGET_INT_MASK _IOR(COPPER_MAGIC, COPPER_INT_MASK, sizeof(unsigned int))
148#define CPRIOGET_FF_RW _IOR(COPPER_MAGIC, COPPER_FF_RW, sizeof(unsigned int))
149#define CPRIOGET_INT_FACTOR _IOR(COPPER_MAGIC, COPPER_INT_FACTOR, sizeof(unsigned int))
150#define CPRIOGET_FF_WA _IOR(COPPER_MAGIC, COPPER_FF_WA, sizeof(unsigned int))
151#define CPRIOGET_FF_WB _IOR(COPPER_MAGIC, COPPER_FF_WB, sizeof(unsigned int))
152#define CPRIOGET_FF_WC _IOR(COPPER_MAGIC, COPPER_FF_WC, sizeof(unsigned int))
153#define CPRIOGET_FF_WD _IOR(COPPER_MAGIC, COPPER_FF_WD, sizeof(unsigned int))
154#define CPRIOGET_FF_RA _IOR(COPPER_MAGIC, COPPER_FF_RA, sizeof(unsigned int))
155#define CPRIOGET_FF_RB _IOR(COPPER_MAGIC, COPPER_FF_RB, sizeof(unsigned int))
156#define CPRIOGET_FF_RC _IOR(COPPER_MAGIC, COPPER_FF_RC, sizeof(unsigned int))
157#define CPRIOGET_FF_RD _IOR(COPPER_MAGIC, COPPER_FF_RD, sizeof(unsigned int))
158#define CPRIOGET_FF_DMA _IOR(COPPER_MAGIC, COPPER_FF_DMA, sizeof(unsigned int))
159
160#define CPRIOSET_FF_STA _IOW(COPPER_MAGIC, COPPER_FF_STA, sizeof(unsigned int))
161#define CPRIOSET_CONF_WA_AE _IOW(COPPER_MAGIC, COPPER_CONF_WA_AE, sizeof(unsigned int))
162#define CPRIOSET_CONF_WB_AE _IOW(COPPER_MAGIC, COPPER_CONF_WB_AE, sizeof(unsigned int))
163#define CPRIOSET_CONF_WC_AE _IOW(COPPER_MAGIC, COPPER_CONF_WC_AE, sizeof(unsigned int))
164#define CPRIOSET_CONF_WD_AE _IOW(COPPER_MAGIC, COPPER_CONF_WD_AE, sizeof(unsigned int))
165#define CPRIOSET_CONF_WA_FF _IOW(COPPER_MAGIC, COPPER_CONF_WA_FF, sizeof(unsigned int))
166#define CPRIOSET_CONF_WB_FF _IOW(COPPER_MAGIC, COPPER_CONF_WB_FF, sizeof(unsigned int))
167#define CPRIOSET_CONF_WC_FF _IOW(COPPER_MAGIC, COPPER_CONF_WC_FF, sizeof(unsigned int))
168#define CPRIOSET_CONF_WD_FF _IOW(COPPER_MAGIC, COPPER_CONF_WD_FF, sizeof(unsigned int))
169#define CPRIOSET_CONF_WA_AF _IOW(COPPER_MAGIC, COPPER_CONF_WA_AF, sizeof(unsigned int))
170#define CPRIOSET_CONF_WB_AF _IOW(COPPER_MAGIC, COPPER_CONF_WB_AF, sizeof(unsigned int))
171#define CPRIOSET_CONF_WC_AF _IOW(COPPER_MAGIC, COPPER_CONF_WC_AF, sizeof(unsigned int))
172#define CPRIOSET_CONF_WD_AF _IOW(COPPER_MAGIC, COPPER_CONF_WD_AF, sizeof(unsigned int))
173#define CPRIOSET_FF_RST _IOW(COPPER_MAGIC, COPPER_FF_RST, sizeof(unsigned int))
174#define CPRIOSET_FINESSE_STA _IOW(COPPER_MAGIC, COPPER_FINESSE_STA, sizeof(unsigned int))
175#define CPRIOSET_ALMFULL_ENB _IOW(COPPER_MAGIC, COPPER_ALMFULL_ENB, sizeof(unsigned int))
176#define CPRIOSET_TRGCM _IOW(COPPER_MAGIC, COPPER_TRGCM, sizeof(unsigned int))
177#define CPRIOSET_TRG_LENG _IOW(COPPER_MAGIC, COPPER_TRG_LENG, sizeof(unsigned int))
178#define CPRIOSET_LEF_READSEL _IOW(COPPER_MAGIC, COPPER_LEF_READSEL, sizeof(unsigned int))
179#define CPRIOSET_LEF_TOTAL _IOW(COPPER_MAGIC, COPPER_LEF_TOTAL, sizeof(unsigned int))
180#define CPRIOSET_LEF_AB _IOW(COPPER_MAGIC, COPPER_LEF_AB, sizeof(unsigned int))
181#define CPRIOSET_LEF_CD _IOW(COPPER_MAGIC, COPPER_LEF_CD, sizeof(unsigned int))
182#define CPRIOSET_LEF_STA _IOW(COPPER_MAGIC, COPPER_LEF_STA, sizeof(unsigned int))
183#define CPRIOSET_LEF_WA_FF _IOW(COPPER_MAGIC, COPPER_LEF_WA_FF, sizeof(unsigned int))
184#define CPRIOSET_LEF_WB_FF _IOW(COPPER_MAGIC, COPPER_LEF_WB_FF, sizeof(unsigned int))
185#define CPRIOSET_LEF_WC_FF _IOW(COPPER_MAGIC, COPPER_LEF_WC_FF, sizeof(unsigned int))
186#define CPRIOSET_LEF_WD_FF _IOW(COPPER_MAGIC, COPPER_LEF_WD_FF, sizeof(unsigned int))
187#define CPRIOSET_LEF_WA_AF _IOW(COPPER_MAGIC, COPPER_LEF_WA_AF, sizeof(unsigned int))
188#define CPRIOSET_LEF_WB_AF _IOW(COPPER_MAGIC, COPPER_LEF_WB_AF, sizeof(unsigned int))
189#define CPRIOSET_LEF_WC_AF _IOW(COPPER_MAGIC, COPPER_LEF_WC_AF, sizeof(unsigned int))
190#define CPRIOSET_LEF_WD_AF _IOW(COPPER_MAGIC, COPPER_LEF_WD_AF, sizeof(unsigned int))
191#define CPRIOSET_INT_STA _IOW(COPPER_MAGIC, COPPER_INT_STA, sizeof(unsigned int))
192#define CPRIOSET_INT_MASK _IOW(COPPER_MAGIC, COPPER_INT_MASK, sizeof(unsigned int))
193#define CPRIOSET_FF_RW _IOW(COPPER_MAGIC, COPPER_FF_RW, sizeof(unsigned int))
194#define CPRIOSET_INT_FACTOR _IOW(COPPER_MAGIC, COPPER_INT_FACTOR, sizeof(unsigned int))
195#define CPRIOSET_FF_WA _IOW(COPPER_MAGIC, COPPER_FF_WA, sizeof(unsigned int))
196#define CPRIOSET_FF_WB _IOW(COPPER_MAGIC, COPPER_FF_WB, sizeof(unsigned int))
197#define CPRIOSET_FF_WC _IOW(COPPER_MAGIC, COPPER_FF_WC, sizeof(unsigned int))
198#define CPRIOSET_FF_WD _IOW(COPPER_MAGIC, COPPER_FF_WD, sizeof(unsigned int))
199#define CPRIOSET_FF_RA _IOW(COPPER_MAGIC, COPPER_FF_RA, sizeof(unsigned int))
200#define CPRIOSET_FF_RB _IOW(COPPER_MAGIC, COPPER_FF_RB, sizeof(unsigned int))
201#define CPRIOSET_FF_RC _IOW(COPPER_MAGIC, COPPER_FF_RC, sizeof(unsigned int))
202#define CPRIOSET_FF_RD _IOW(COPPER_MAGIC, COPPER_FF_RD, sizeof(unsigned int))
203#define CPRIOSET_FF_DMA _IOW(COPPER_MAGIC, COPPER_FF_DMA, sizeof(unsigned int))
204
205/* alias */
206
207#define CPRIOSET_LEF_WA_THR CPRIOSET_LEF_WA_FF
208#define CPRIOSET_LEF_WB_THR CPRIOSET_LEF_WB_FF
209#define CPRIOSET_LEF_WC_THR CPRIOSET_LEF_WC_FF
210#define CPRIOSET_LEF_WD_THR CPRIOSET_LEF_WD_FF
211
212#define CPRIOGET_LEF_WA_THR CPRIOGET_LEF_WA_FF
213#define CPRIOGET_LEF_WB_THR CPRIOGET_LEF_WB_FF
214#define CPRIOGET_LEF_WC_THR CPRIOGET_LEF_WC_FF
215#define CPRIOGET_LEF_WD_THR CPRIOGET_LEF_WD_FF
216
217/* cmds */
218
219#define CPRIO_RESET_FINESSE _IO(COPPER_MAGIC, 1)
220#define CPRIO_INIT_RUN _IO(COPPER_MAGIC, 2)
221#define CPRIO_RESET_COPPER _IO(COPPER_MAGIC, 3)
222#define CPRIO_SET_SUBSYS _IO(COPPER_MAGIC, 4)
223#define CPRIO_SET_CRATE _IO(COPPER_MAGIC, 5)
224#define CPRIO_SET_SLOT _IO(COPPER_MAGIC, 6)
225#define CPRIO_FORCE_DMA _IO(COPPER_MAGIC, 7)
226#define CPRIO_END_RUN _IO(COPPER_MAGIC, 8)
227
228#endif /* _COPPER_H_ */