source: drsdaq/VME/struck/sis1100_var.h@ 23

Last change on this file since 23 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
File size: 11.2 KB
Line 
1/* $ZEL: sis1100_var.h,v 1.5 2004/05/27 23:10:37 wuestner Exp $ */
2
3/*
4 * Copyright (c) 2001-2004
5 * Peter Wuestner. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _sis1100_var_h_
30#define _sis1100_var_h_
31
32#define SIS1100_MinVersion 0
33#define SIS1100_MajVersion 2
34#define SIS1100_Version (SIS1100_MinVersion|(SIS1100_MajVersion<<16))
35
36#ifdef __NetBSD__
37#include <sys/types.h>
38#include <sys/time.h>
39#include <sys/param.h>
40#include <sys/proc.h>
41#elif __linux__
42#include "linux/ioctl.h"
43#endif
44
45/*
46 * minorbits:
47 * ccttuuuu
48 */
49
50/* used bits of minor number */
51#define sis1100_MINORBITS 8
52/* bits used for cardnumber, number_of_cards<=(1<<MINORCARDBITS) */
53#define sis1100_MINORCARDBITS 2
54/* type 0: VME; type 1: SDRAM; type 2: sis1100_control; type 3: dsp*/
55#define sis1100_MINORTYPEBITS 2
56
57#define sis1100_MAXCARDS (1<<sis1100_MINORCARDBITS)
58#define sis1100_MINORUSERBITS (sis1100_MINORBITS-sis1100_MINORCARDBITS-sis1100_MINORTYPEBITS)
59
60#define sis1100_MINORCARDSHIFT (sis1100_MINORUSERBITS+sis1100_MINORTYPEBITS)
61#define sis1100_MINORCARDMASK (((1<<sis1100_MINORCARDBITS)-1)<<(sis1100_MINORUSERBITS+sis1100_MINORTYPEBITS))
62#define sis1100_MINORTYPESHIFT sis1100_MINORUSERBITS
63#define sis1100_MINORTYPEMASK (((1<<sis1100_MINORTYPEBITS)-1)<<sis1100_MINORUSERBITS)
64#define sis1100_MINORUSERSHIFT 0
65#define sis1100_MINORUSERMASK ((1<<sis1100_MINORUSERBITS)-1)
66#define sis1100_MINORUTMASK (sis1100_MINORTYPEMASK|sis1100_MINORUSERMASK)
67
68enum sis1100_subdev {sis1100_subdev_remote, sis1100_subdev_ram,
69 sis1100_subdev_ctrl, sis1100_subdev_dsp};
70enum sis1100_hw_type {
71 sis1100_hw_invalid=0,
72 sis1100_hw_pci=1,
73 sis1100_hw_vme=2,
74 sis1100_hw_camac=3,
75 sis1100_hw_f1=4, /* FZJ only */
76 sis1100_hw_vertex=5, /* FZJ only */
77};
78
79/*
80 * error codes:
81 * sis1100 local:
82 * 0x005: deadlock (only transient)
83 * 0x101: missing synchronisation
84 * 0x102: inhibit
85 * 0x103: output fifo full
86 * 0x104: buffer full
87 * 0x105: deadlock; transfer aborted
88 * 0x107: timeout
89 * sis1100 remote:
90 * 0x202: not ready
91 * 0x206: protocoll error
92 * 0x207: timeout; indication not complete
93 * 0x208: bus error
94 * 0x209: fifo error
95 * sis3100 remote:
96 * 0x211: bus error
97 * 0x212: retry
98 * 0x214: arbitration timeout
99 * sis5100 remote:
100 * ???
101 * #ifdef FZJ_ZEL
102 * straw and vertex:
103 * same as sis1100 remote
104 * #endif
105 * synthetic errors:
106 * 0x301: DMA interrupted
107 * 0x302: synchronisation lost during DMA
108 * 0x303 == 0x301|0x302
109 */
110
111struct sis1100_vme_req {
112 int size;
113 int32_t am;
114 u_int32_t addr;
115 u_int32_t data;
116 u_int32_t error;
117};
118
119/*
120 * struct sis1100_vme_req {
121 * int size;
122 * int32_t am;
123 * u_int32_t addr;
124 * union {
125 * u_int8_t u8;
126 * u_int16_t u16;
127 * u_int32_t u32;
128 * u_int64_t u64;
129 * } data;
130 * u_int32_t error;
131 * };
132 */
133
134struct sis1100_vme_block_req {
135 int size; /* size of dataword */
136 int fifo;
137 size_t num; /* number of datawords */
138 int32_t am;
139 u_int32_t addr; /* remote bus address */
140 u_int8_t* data; /* local user space address */
141 u_int32_t error;
142};
143
144struct sis1100_vme_super_block_req {
145 int n;
146 int error;
147 struct sis1100_vme_block_req* reqs;
148};
149
150struct sis1100_camac_req {
151 u_int32_t N;
152 u_int32_t A;
153 u_int32_t F;
154 u_int32_t data;
155 u_int32_t error;
156};
157
158struct sis1100_camac_scan_req {
159 u_int32_t N;
160 u_int32_t A;
161 u_int32_t F;
162 u_int32_t data;
163 u_int32_t error;
164};
165
166struct sis1100_pipelist {
167 u_int32_t head; /* masked with 0xff3f0400: */
168 /* only 'be', remote space and w/r are used */
169 int32_t am;
170 u_int32_t addr;
171 u_int32_t data; /* only used for write access */
172};
173
174struct sis1100_pipe {
175 int num;
176 struct sis1100_pipelist* list;
177 u_int32_t* data;
178 u_int32_t error;
179};
180
181struct sis1100_writepipe {
182 int num;
183 int am;
184 u_int32_t* data; /* num*{addr, data} */
185 u_int32_t error;
186};
187
188struct vmespace {
189 int32_t am;
190 u_int32_t datasize;
191 int swap; /* 1: swap words 0: don't swap -1: not changed */
192 int mapit; /* not used */
193 ssize_t mindmalen; /* 0: never use DMA; 1: always use DMA; -1: not changed */
194};
195
196struct sis1100_ident_dev {
197 enum sis1100_hw_type hw_type;
198 int hw_version;
199 int fw_type;
200 int fw_version;
201};
202
203struct sis1100_ident {
204 struct sis1100_ident_dev local;
205 struct sis1100_ident_dev remote;
206 int remote_ok;
207 int remote_online;
208};
209
210struct sis1100_ctrl_reg {
211 int offset;
212 u_int32_t val;
213 u_int32_t error;
214};
215
216struct sis1100_irq_ctl {
217 u_int32_t irq_mask;
218 int signal; /* >0: signal; ==0: disable; <0: no signal but select */
219};
220
221struct sis1100_irq_get {
222 u_int32_t irq_mask;
223 int remote_status; /* -1: down 1: up 0: unchanged */
224 u_int32_t opt_status;
225 u_int32_t mbx0;
226 u_int32_t irqs;
227 int level;
228 int32_t vector;
229};
230
231struct sis1100_irq_ack {
232 u_int32_t irq_mask;
233};
234
235struct sis1100_dma_alloc {
236 size_t size;
237 off_t offset;
238 u_int32_t dma_addr;
239};
240
241struct sis1100_dsp_code {
242 void* src; /* pointer to code */
243 u_int32_t dst; /* load address in SHARC memory*/
244 int size; /* code size in bytes */
245};
246
247struct sis1100_eeprom_req {
248 u_int8_t num; /* number of 16-bit-words */
249 u_int8_t addr; /* eeprom address */
250 u_int16_t* data; /* user space address */
251};
252
253#define SIS3100_VME_IRQS 0xFE
254#define SIS3100_FLAT_IRQS 0xF00
255#define SIS3100_LEMO_IRQS 0x7000
256#define SIS3100_DSP_IRQ 0x8000
257#define SIS3100_FRONT_IRQS (SIS3100_FLAT_IRQS | SIS3100_LEMO_IRQS)
258#define SIS3100_EXT_IRQS (SIS3100_FRONT_IRQS | SIS3100_DSP_IRQ )
259#define SIS3100_IRQS (SIS3100_VME_IRQS | SIS3100_EXT_IRQS )
260
261/*
262 * 24*LAM
263 * 3* LEMO IN 3* LEMO OUT
264 * 3* ECL IN 3* ECL OUT
265 */
266#define SIS5100_LAM_IRQS 0
267#define SIS5100_FLAT_IRQS 0
268#define SIS5100_LEMO_IRQS 0
269#define SIS5100_DSP_IRQ 0
270#define SIS5100_FRONT_IRQS (SIS5100_FLAT_IRQS | SIS5100_LEMO_IRQS)
271#define SIS5100_EXT_IRQS (SIS5100_FRONT_IRQS | SIS5100_DSP_IRQ )
272#define SIS5100_IRQS (SIS5100_LAM_IRQS | SIS5100_EXT_IRQS )
273
274#define SIS1100_FRONT_IRQS 0x30000
275#define SIS1100_MBX0_IRQ 0x100000
276#define SIS1100_IRQS (SIS1100_FRONT_IRQS|SIS1100_MBX0_IRQ)
277
278#define GLINK_MAGIC 'g'
279
280#define SIS1100_NEW_CTRL
281
282#define SIS1100_SETVMESPACE _IOW (GLINK_MAGIC, 1, struct vmespace)
283#define SIS3100_VME_PROBE _IOW (GLINK_MAGIC, 2, u_int32_t)
284#define SIS3100_VME_READ _IOWR(GLINK_MAGIC, 3, struct sis1100_vme_req)
285#define SIS3100_VME_WRITE _IOWR(GLINK_MAGIC, 4, struct sis1100_vme_req)
286#define SIS3100_VME_BLOCK_READ _IOWR(GLINK_MAGIC, 5, struct sis1100_vme_block_req)
287#define SIS3100_VME_BLOCK_WRITE _IOWR(GLINK_MAGIC, 6, struct sis1100_vme_block_req)
288#ifdef SIS1100_NEW_CTRL
289#define SIS1100_CTRL_READ _IOWR(GLINK_MAGIC, 7, struct sis1100_ctrl_reg)
290#define SIS1100_CTRL_WRITE _IOWR(GLINK_MAGIC, 8, struct sis1100_ctrl_reg)
291#else
292#define SIS1100_LOCAL_CTRL_READ _IOWR(GLINK_MAGIC, 7, struct sis1100_ctrl_reg)
293#define SIS1100_LOCAL_CTRL_WRITE _IOWR(GLINK_MAGIC, 8, struct sis1100_ctrl_reg)
294#define SIS1100_REMOTE_CTRL_READ _IOWR(GLINK_MAGIC, 9, struct sis1100_ctrl_reg)
295#define SIS1100_REMOTE_CTRL_WRITE _IOWR(GLINK_MAGIC, 10, struct sis1100_ctrl_reg)
296#endif
297#define SIS1100_PIPE _IOWR(GLINK_MAGIC, 11, struct sis1100_pipe)
298#define SIS1100_MAPSIZE _IOR (GLINK_MAGIC, 12, u_int32_t)
299#define SIS1100_LAST_ERROR _IOR (GLINK_MAGIC, 13, u_int32_t)
300#define SIS1100_IDENT _IOR (GLINK_MAGIC, 14, struct sis1100_ident)
301#define SIS1100_FIFOMODE _IOWR(GLINK_MAGIC, 15, int)
302
303#define SIS1100_IRQ_CTL _IOW (GLINK_MAGIC, 17, struct sis1100_irq_ctl)
304#define SIS1100_IRQ_GET _IOWR(GLINK_MAGIC, 18, struct sis1100_irq_get)
305#define SIS1100_IRQ_ACK _IOW (GLINK_MAGIC, 19, struct sis1100_irq_ack)
306#define SIS1100_IRQ_WAIT _IOWR(GLINK_MAGIC, 20, struct sis1100_irq_get)
307
308#define SIS1100_MINDMALEN _IOWR(GLINK_MAGIC, 21, int[2])
309
310#define SIS1100_FRONT_IO _IOWR(GLINK_MAGIC, 22, u_int32_t)
311#define SIS1100_FRONT_PULSE _IOW (GLINK_MAGIC, 23, u_int32_t)
312#define SIS1100_FRONT_LATCH _IOWR(GLINK_MAGIC, 24, u_int32_t)
313
314#define SIS3100_VME_SUPER_BLOCK_READ _IOWR(GLINK_MAGIC, 25, struct sis1100_vme_super_block_req)
315#define SIS1100_WRITE_PIPE _IOWR(GLINK_MAGIC, 26, struct sis1100_writepipe)
316
317#define SIS1100_DMA_ALLOC _IOWR(GLINK_MAGIC, 27, struct sis1100_dma_alloc)
318#define SIS1100_DMA_FREE _IOW (GLINK_MAGIC, 28, struct sis1100_dma_alloc)
319
320#define SIS5100_CCCZ _IO (GLINK_MAGIC, 29)
321#define SIS5100_CCCC _IO (GLINK_MAGIC, 30)
322#define SIS5100_CCCI _IOW (GLINK_MAGIC, 31, int)
323#define SIS5100_CNAF _IOWR(GLINK_MAGIC, 32, struct sis1100_camac_req)
324#define SIS1100_SWAP _IOWR(GLINK_MAGIC, 33, int)
325#define SIS3100_TIMEOUTS _IOWR(GLINK_MAGIC, 34, int[2])
326
327#define SIS1100_DSP_LOAD _IOW (GLINK_MAGIC, 35, struct sis1100_dsp_code)
328#define SIS1100_DSP_RESET _IO (GLINK_MAGIC, 36)
329#define SIS1100_DSP_START _IO (GLINK_MAGIC, 37)
330
331/* the following functions (1xx) are not designed for "daily use",
332 but will be usefull */
333#define SIS1100_RESET _IO (GLINK_MAGIC, 102)
334#define SIS1100_REMOTE_RESET _IO (GLINK_MAGIC, 103)
335#define SIS1100_DEVTYPE _IOR (GLINK_MAGIC, 104, enum sis1100_subdev)
336#define SIS1100_DRIVERVERSION _IOR (GLINK_MAGIC, 105, int)
337#define SIS1100_READ_EEPROM _IOW (GLINK_MAGIC, 106, struct sis1100_eeprom_req)
338#define SIS1100_WRITE_EEPROM _IOW (GLINK_MAGIC, 107, struct sis1100_eeprom_req)
339#define SIS1100_JTAG_ENABLE _IOW (GLINK_MAGIC, 108, u_int32_t)
340#define SIS1100_JTAG_CTRL _IOWR(GLINK_MAGIC, 109, u_int32_t)
341#define SIS1100_JTAG_DATA _IOR (GLINK_MAGIC, 110, u_int32_t)
342#define SIS1100_JTAG_PUT _IOW (GLINK_MAGIC, 111, u_int32_t)
343#define SIS1100_JTAG_GET _IOR (GLINK_MAGIC, 112, u_int32_t)
344
345#ifndef PURE_SIS1100_NAMESPACE
346#define SETVMESPACE SIS1100_SETVMESPACE
347#define VME_PROBE SIS3100_VME_PROBE
348#endif
349
350#endif
Note: See TracBrowser for help on using the repository browser.