source: drsdaq/VME/struck/sis1100/V2.02/dev/pci/sis1100_ioctl.c.~1.5.~@ 23

Last change on this file since 23 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
File size: 23.2 KB
Line 
1/* $ZEL: sis1100_ioctl.c,v 1.5 2004/05/27 23:10:22 wuestner Exp $ */
2
3/*
4 * Copyright (c) 2001-2004
5 * Matthias Drochner, 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#include "sis1100_sc.h"
30
31#if !defined(__NetBSD__) && ! defined(__linux__)
32#error Invalid or Unknown Operating System
33#endif
34
35static int
36test_super(struct sis1100_softc* sc, struct sis1100_fdata* fd)
37{
38return 0;
39#ifdef __NetBSD__
40 if (suser(fd->p->p_ucred, &fd->p->p_acflag)) return EPERM;
41#elif __linux__
42 if (!capable(CAP_SYS_RAWIO)) return EPERM;
43#endif
44 return 0;
45}
46
47#ifdef SIS1100_NEW_CTRL
48static int
49ioctl_ctrl_read(struct sis1100_softc* sc, struct sis1100_fdata* fd,
50 struct sis1100_ctrl_reg* d)
51{
52 if (fd->subdev==sis1100_subdev_ctrl) {
53 SEM_LOCK(sc->sem_hw);
54 d->val=plxreadlocal0(sc, d->offset&0x7ff);
55 SEM_UNLOCK(sc->sem_hw);
56 d->error=0;
57 } else {
58 if (sc->remote_hw==sis1100_hw_invalid) return ENXIO;
59 d->error=sis1100_remote_reg_read(sc, d->offset, &d->val, 1);
60 }
61 return 0;
62}
63
64static int
65ioctl_ctrl_write(struct sis1100_softc* sc, struct sis1100_fdata* fd,
66 struct sis1100_ctrl_reg* d)
67{
68 if (fd->subdev==sis1100_subdev_ctrl) {
69 SEM_LOCK(sc->sem_hw);
70 plxwritelocal0(sc, d->offset&0x7ff, d->val);
71 SEM_UNLOCK(sc->sem_hw);
72 d->error=0;
73 } else {
74 if (sc->remote_hw==sis1100_hw_invalid) return ENXIO;
75 d->error=sis1100_remote_reg_write(sc, d->offset, d->val, 0);
76 }
77 return 0;
78}
79
80#else
81
82static int
83ioctl_local_ctrl_read(struct sis1100_softc* sc, struct sis1100_fdata* fd,
84 struct sis1100_ctrl_reg* d)
85{
86 SEM_LOCK(sc->sem_hw);
87 d->val=plxreadlocal0(sc, d->offset&0x7ff);
88 SEM_UNLOCK(sc->sem_hw);
89 d->error=0;
90 return 0;
91}
92
93static int
94ioctl_local_ctrl_write(struct sis1100_softc* sc, struct sis1100_fdata* fd,
95 struct sis1100_ctrl_reg* d)
96{
97 SEM_LOCK(sc->sem_hw);
98 plxwritelocal0(sc, d->offset&0x7ff, d->val);
99 SEM_UNLOCK(sc->sem_hw);
100 d->error=0;
101 return 0;
102}
103
104static int
105ioctl_remote_ctrl_read(struct sis1100_softc* sc, struct sis1100_fdata* fd,
106 struct sis1100_ctrl_reg* d)
107{
108 if (sc->remote_hw==sis1100_hw_invalid) return ENXIO;
109 d->error=sis1100_remote_reg_read(sc, d->offset, &d->val, 0);
110 return 0;
111}
112
113static int
114ioctl_remote_ctrl_write(struct sis1100_softc* sc, struct sis1100_fdata* fd,
115 struct sis1100_ctrl_reg* d)
116{
117 if (sc->remote_hw==sis1100_hw_invalid) return ENXIO;
118 d->error=sis1100_remote_reg_write(sc, d->offset, d->val, 0);
119 return 0;
120}
121#endif
122
123static int
124ioctl_ident(struct sis1100_softc* sc, struct sis1100_fdata* fd,
125 struct sis1100_ident* d)
126{
127 d->local.hw_type=sc->local_ident&0xff;
128 d->local.hw_version=(sc->local_ident>>8)&0xff;
129 d->local.fw_type=(sc->local_ident>>16)&0xff;
130 d->local.fw_version=(sc->local_ident>>24)&0xff;
131
132 d->remote.hw_type=sc->remote_ident&0xff;
133 d->remote.hw_version=(sc->remote_ident>>8)&0xff;
134 d->remote.fw_type=(sc->remote_ident>>16)&0xff;
135 d->remote.fw_version=(sc->remote_ident>>24)&0xff;
136
137 d->remote_ok=sc->remote_hw!=sis1100_hw_invalid;
138 d->remote_online=(sis1100readreg(sc, sr)&sr_synch)==sr_synch;
139 return 0;
140}
141
142static int
143ioctl_remote_reset(struct sis1100_softc* sc, struct sis1100_fdata* fd)
144{
145#if 0
146 SEM_LOCK(sc->sem_hw);
147 sis1100writereg(sc, cr, cr_rem_reset);
148 switch (sc->remote_hw) {
149 case sis1100_hw_invalid:
150 SEM_UNLOCK(sc->sem_hw);
151 return ENXIO;
152 case sis1100_hw_pci:
153 /* do nothing */
154 break;
155 case sis1100_hw_vme:
156 sis3100writeremreg(sc, vme_master_sc, 8, 1);
157 break;
158 case sis1100_hw_camac:
159 break;
160 }
161 SEM_UNLOCK(sc->sem_hw);
162 mdelay(500);
163 sis1100_init_remote(sc);
164#endif
165 return ENOTTY;
166}
167
168static int
169ioctl_devtype(struct sis1100_softc* sc, struct sis1100_fdata* fd, int* d)
170{
171 *d=fd->subdev;
172 return 0;
173}
174
175static int
176ioctl_driverversion(struct sis1100_softc* sc, struct sis1100_fdata* fd, int* d)
177{
178 *d=SIS1100_Version;
179 return 0;
180}
181
182static int
183ioctl_mindmalen(struct sis1100_softc* sc, struct sis1100_fdata* fd,
184 int* d)
185{
186/*
187 * 0: never use DMA
188 * 1: always use DMA (if size>4)
189 * >1: use DMA if transfersize (in Bytes) is >= mindmalen
190 * -1: don't change old value
191 */
192 int tmp[2];
193
194 tmp[0]=fd->mindmalen_r;
195 tmp[1]=fd->mindmalen_w;
196 if (d[0]>=0) fd->mindmalen_r=d[0];
197 if (d[1]>=0) fd->mindmalen_w=d[1];
198 d[0]=tmp[0];
199 d[1]=tmp[1];
200 return 0;
201}
202
203static int
204ioctl_setvmespace(struct sis1100_softc* sc, struct sis1100_fdata* fd,
205 struct vmespace* d)
206{
207 if ((d->datasize!=1) && (d->datasize!=2) && (d->datasize!=4))
208 return EINVAL;
209 fd->vmespace_am=d->am;
210 fd->vmespace_datasize=d->datasize;
211 if (d->swap>=0) {
212 sc->user_wants_swap=d->swap;
213 sis1100_update_swapping(sc, "ioctl_setvmespace");
214 }
215 if (d->mindmalen>=0) {
216 fd->mindmalen_r=d->mindmalen;
217 fd->mindmalen_w=d->mindmalen;
218 }
219 return 0;
220}
221
222static int
223ioctl_swap(struct sis1100_softc* sc, struct sis1100_fdata* fd, int* d)
224{
225 int old;
226
227 old=sc->user_wants_swap;
228 sc->user_wants_swap=*d;
229 sis1100_update_swapping(sc, "ioctl_swap");
230 *d=old;
231 return 0;
232}
233
234static int
235ioctl_3100_timeouts(struct sis1100_softc* sc, struct sis1100_fdata* fd, int* d)
236{
237/*
238 * d[0]: bus error terms of 10**-9 s
239 * d[1]: arbitration timeout in terms of 10**-3 s
240 */
241 int tmp[2];
242 if ((fd->subdev!=sis1100_subdev_remote)
243 || (sc->remote_hw!=sis1100_hw_vme))
244 return ENXIO;
245 if (sis3100_get_timeouts(sc, tmp+0, tmp+1)) return EIO;
246 if (sis3100_set_timeouts(sc, d[0], d[1])) return EIO;
247 d[0]=tmp[0];
248 d[1]=tmp[1];
249 return 0;
250}
251
252static int
253ioctl_front_io(struct sis1100_softc* sc, struct sis1100_fdata* fd,
254 u_int32_t* d)
255{
256 return sis1100_front_io(sc, d, 0);
257}
258
259static int
260ioctl_front_pulse(struct sis1100_softc* sc, struct sis1100_fdata* fd,
261 u_int32_t* d)
262{
263 return sis1100_front_pulse(sc, d, 0);
264}
265
266static int
267ioctl_front_latch(struct sis1100_softc* sc, struct sis1100_fdata* fd,
268 u_int32_t* d)
269{
270 return sis1100_front_latch(sc, d, 0);
271}
272
273static int
274ioctl_last_error(struct sis1100_softc* sc, struct sis1100_fdata* fd,
275 u_int32_t* d)
276{
277 *d=fd->last_prot_err;
278 return 0;
279}
280
281static int
282ioctl_mapsize(struct sis1100_softc* sc, struct sis1100_fdata* fd, u_int32_t* d)
283{
284 switch (fd->subdev) {
285 case sis1100_subdev_remote:
286 *d=sc->rem_size;
287 break;
288 case sis1100_subdev_ram:
289 *d=sc->ram_size;
290 break;
291 case sis1100_subdev_ctrl:
292 *d=sc->reg_size;
293 break;
294 case sis1100_subdev_dsp:
295 *d=0;
296 break;
297 default:
298 return EINVAL;
299 }
300 return 0;
301}
302
303static int
304ioctl_pipe(struct sis1100_softc* sc, struct sis1100_fdata* fd,
305 struct sis1100_pipe* d)
306{
307 int res;
308 if (sc->remote_hw==sis1100_hw_invalid) return ENXIO;
309 res=sis1100_read_pipe(sc, d);
310 return res;
311}
312
313static int
314ioctl_write_pipe(struct sis1100_softc* sc, struct sis1100_fdata* fd,
315 struct sis1100_writepipe* d)
316{
317 u_int32_t* list;
318 int res;
319
320 if (sc->remote_hw==sis1100_hw_invalid) return ENXIO;
321
322#ifdef __NetBSD__
323 list=malloc(d->num*2*sizeof(u_int32_t), M_IOCTLOPS,
324 M_WAITOK/*|M_CANFAIL*/);
325#elif __linux__
326 list=kmalloc(d->num*2*sizeof(u_int32_t), GFP_KERNEL);
327#endif
328 if (!list) return ENOMEM;
329
330 if (
331#ifdef __NetBSD__
332 copyin(d->data, list, d->num*2*sizeof(u_int32_t))
333#elif __linux__
334 copy_from_user(list, d->data, d->num*2*sizeof(u_int32_t))
335#endif
336 ) {
337 res=EFAULT;
338 goto raus;
339 }
340
341 res=0;
342 d->error=sis1100_write_pipe(sc, d->am, 1/*space*/, d->num, list);
343
344 raus:
345#ifdef __NetBSD__
346 free(list, M_IOCTLOPS);
347#elif __linux__
348 kfree(list);
349#endif
350 return res;
351}
352
353static int
354ioctl_vme_probe(struct sis1100_softc* sc, struct sis1100_fdata* fd, int* d)
355{
356 int dummy;
357 if (sc->remote_hw!=sis1100_hw_vme) return ENXIO;
358 if (sis1100_tmp_read(sc, *d, fd->vmespace_am,
359 fd->vmespace_datasize, 1/*space*/, &dummy))
360 return EIO;
361 return 0;
362}
363
364static int
365ioctl_vme_read(struct sis1100_softc* sc, struct sis1100_fdata* fd,
366 struct sis1100_vme_req* d)
367{
368 if (sc->remote_hw==sis1100_hw_invalid) return ENXIO;
369 d->error=sis1100_tmp_read(sc, d->addr, d->am, d->size,
370 1/*space*/, &d->data);
371 return 0;
372}
373
374static int
375ioctl_vme_write(struct sis1100_softc* sc, struct sis1100_fdata* fd,
376 struct sis1100_vme_req* d)
377{
378 if (sc->remote_hw==sis1100_hw_invalid) return ENXIO;
379 d->error=sis1100_tmp_write(sc, d->addr, d->am, d->size,
380 1/*space*/, d->data);
381 return 0;
382}
383
384static int
385ioctl_vme_block_read(struct sis1100_softc* sc, struct sis1100_fdata* fd,
386 struct sis1100_vme_block_req* d)
387{
388 int res;
389 int space=1;
390#if 0
391 switch (sc->remote_hw) {
392 case sis1100_hw_invalid: return ENXIO;
393 case sis1100_hw_pci: space=1; break;
394 case sis1100_hw_vme: space=1; break;
395 case sis1100_hw_camac: space=1; break;
396 case sis1100_hw_f1: space=1; break;
397 case sis1100_hw_vertex: space=1; break;
398 }
399#else
400 if (sc->remote_hw==sis1100_hw_invalid) return ENXIO;
401#endif
402 res=sis1100_read_block(sc, fd, d->size, d->fifo, d->num, &d->num,
403 space, d->am, d->addr, d->data, &d->error);
404 return res;
405}
406
407static int
408ioctl_vme_super_block_read(struct sis1100_softc* sc, struct sis1100_fdata* fd,
409 struct sis1100_vme_super_block_req* d)
410{
411 struct sis1100_vme_block_req* reqs;
412 int res, i;
413
414 if (sc->remote_hw==sis1100_hw_invalid) return ENXIO;
415#ifdef __NetBSD__
416 reqs=malloc(d->n*sizeof(struct sis1100_vme_block_req), M_IOCTLOPS,
417 M_WAITOK/*|M_CANFAIL*/);
418#elif __linux__
419 reqs=kmalloc(d->n*sizeof(struct sis1100_vme_block_req), GFP_KERNEL);
420#endif
421 if (!reqs) return ENOMEM;
422
423 if (
424#ifdef __NetBSD__
425 copyin(d->reqs, reqs, d->n*sizeof(struct sis1100_vme_block_req))
426#elif __linux__
427 copy_from_user(reqs, d->reqs,
428 d->n*sizeof(struct sis1100_vme_block_req))
429#endif
430 ) {
431 res=EFAULT;
432 goto raus;
433 }
434
435 d->error=0;
436 for (i=0; i<d->n; i++) {
437 struct sis1100_vme_block_req* r=reqs+i;
438 res=sis1100_read_block(sc, fd, r->size, r->fifo, r->num,
439 &r->num, 1/*space*/, r->am, r->addr, r->data, &r->error);
440 if (res) {
441 d->n=i;
442 d->error=res;
443 break;
444 }
445 }
446 res=0;
447 if (
448#ifdef __NetBSD__
449 copyout(reqs, d->reqs, d->n*sizeof(struct sis1100_vme_block_req))
450#elif __linux__
451 copy_to_user(d->reqs, reqs,
452 d->n*sizeof(struct sis1100_vme_block_req))
453#endif
454 ) res=EFAULT;
455
456 raus:
457#ifdef __NetBSD__
458 free(reqs, M_IOCTLOPS);
459#elif __linux__
460 kfree(reqs);
461#endif
462 return res;
463}
464
465static int
466ioctl_vme_block_write(struct sis1100_softc* sc, struct sis1100_fdata* fd,
467 struct sis1100_vme_block_req* d)
468{
469 int res;
470
471 if (sc->remote_hw==sis1100_hw_invalid) return ENXIO;
472 res=sis1100_write_block(sc, fd, d->size, d->fifo, d->num,
473 &d->num, 1/*space*/, d->am, d->addr, d->data, &d->error);
474 return res;
475}
476
477static int
478ioctl_fifomode(struct sis1100_softc* sc, struct sis1100_fdata* fd, int* d)
479{
480 int tmp;
481 tmp=fd->fifo_mode;
482 if (*d>=0) fd->fifo_mode=!!*d;
483 *d=tmp;
484 return 0;
485}
486
487static int
488ioctl_irq_ctl(struct sis1100_softc* sc, struct sis1100_fdata* fd,
489 struct sis1100_irq_ctl* d)
490{
491 return sis1100_irq_ctl(sc, fd, d);
492}
493
494static int
495ioctl_irq_get(struct sis1100_softc* sc, struct sis1100_fdata* fd,
496 struct sis1100_irq_get* d)
497{
498 return sis1100_irq_get(sc, fd, d);
499}
500
501static int
502ioctl_irq_ack(struct sis1100_softc* sc, struct sis1100_fdata* fd,
503 struct sis1100_irq_ack* d)
504{
505 return sis1100_irq_ack(sc, fd, d);
506}
507
508static int
509ioctl_irq_wait(struct sis1100_softc* sc, struct sis1100_fdata* fd,
510 struct sis1100_irq_get* d)
511{
512 return sis1100_irq_wait(sc, fd, d);
513}
514
515static int
516ioctl_dma_alloc(struct sis1100_softc* sc, struct sis1100_fdata* fd,
517 struct sis1100_dma_alloc* d)
518{
519#ifdef __NetBSD__
520 return sis1100_dma_alloc(sc, fd, d);
521#elif __linux__
522 return ENOTTY;
523#endif
524}
525
526static int
527ioctl_dma_free(struct sis1100_softc* sc, struct sis1100_fdata* fd,
528 struct sis1100_dma_alloc* d)
529{
530 /*return sis1100_dma_free(sc, fd, d);*/
531 return ENOTTY;
532}
533#if 0
534static int
535ioctl_reset(struct sis1100_softc* sc, struct sis1100_fdata* fd)
536{
537 return sis1100_reset(sc);
538}
539#endif
540
541static int
542ioctl_cccz(struct sis1100_softc* sc, struct sis1100_fdata* fd)
543{
544 u_int32_t data;
545 int res;
546 return 0;
547
548 if (sc->remote_hw!=sis1100_hw_camac) return ENXIO;
549 res=sis1100_tmp_camacread(sc, SIS5100_CAMACaddr(28, 8, 26), &data);
550pINFO(sc, "CCCZ: data=0x%x res=0x%x", data, res);
551 return 0;
552}
553
554static int
555ioctl_cccc(struct sis1100_softc* sc, struct sis1100_fdata* fd)
556{
557 u_int32_t data;
558 int res;
559 return 0;
560
561 if (sc->remote_hw!=sis1100_hw_camac) return ENXIO;
562 res=sis1100_tmp_camacread(sc, SIS5100_CAMACaddr(28, 9, 26), &data);
563pINFO(sc, "CCCC: data=0x%x res=0x%x", data, res);
564 return 0;
565}
566
567static int
568ioctl_ccci(struct sis1100_softc* sc, struct sis1100_fdata* fd, int* d)
569{
570 u_int32_t data;
571 int res;
572
573 if (sc->remote_hw!=sis1100_hw_camac) return ENXIO;
574 res=sis5100writeremreg(sc, camac_sc, *d?1:0x1000, 0);
575
576 /*res=sis1100_tmp_camacread(sc, SIS5100_CAMACaddr(30, 9, *d?26:24), &data);*/
577pINFO(sc, "CCCI(%d): res=0x%x", *d, res);
578 res=sis5100readremreg(sc, camac_sc, &data, 0);
579pINFO(sc, "CCCI : data=0x%x, res=0x%x", data, res);
580 return 0;
581}
582
583static int
584ioctl_cnaf(struct sis1100_softc* sc, struct sis1100_fdata* fd,
585 struct sis1100_camac_req* d)
586{
587 u_int32_t addr;
588 int res;
589
590 addr=SIS5100_CAMACaddr(d->N, d->A, d->F);
591 if ((d->F&0x18)==0x10) { /* write */
592 res=sis1100_tmp_camacwrite(sc, addr, d->data);
593 d->data=(~res<<24)&0xc0000000;
594 if ((res&~0x2c0)==0) { /* X or Q missing; not an error */
595 res=0;
596 }
597 } else { /* read or control */
598 res=sis1100_tmp_camacread(sc, addr, &d->data);
599 d->data^=0xc0000000;
600 }
601 d->error=res;
602 return 0;
603}
604
605static int
606ioctl_read_eeprom(struct sis1100_softc* sc, struct sis1100_fdata* fd,
607 struct sis1100_eeprom_req* d)
608{
609 return sis1100_read_eeprom(sc, d->num, d->addr, d->data);
610}
611
612static int
613ioctl_write_eeprom(struct sis1100_softc* sc, struct sis1100_fdata* fd,
614 struct sis1100_eeprom_req* d)
615{
616 if (test_super(sc, fd)) return EPERM;
617 return sis1100_write_eeprom(sc, d->num, d->addr, d->data);
618}
619
620static int
621ioctl_jtag_enable(struct sis1100_softc* sc, struct sis1100_fdata* fd,
622 u_int32_t* d)
623{
624 if (test_super(sc, fd)) return EPERM;
625 *d<<=8;
626 sis1100writereg(sc, jtag_csr.jtag_csrl, *d);
627 return 0;
628}
629
630static int
631ioctl_jtag_ctrl(struct sis1100_softc* sc, struct sis1100_fdata* fd,
632 u_int32_t* d)
633{
634 if (test_super(sc, fd)) return EPERM;
635 sis1100writereg(sc, jtag_csr.jtag_csrb[1], *d);
636 *d=sis1100readreg(sc, jtag_csr.jtag_csrl);
637 return 0;
638}
639
640static int
641ioctl_jtag_data(struct sis1100_softc* sc, struct sis1100_fdata* fd,
642 u_int32_t* d)
643{
644 *d=sis1100readreg(sc, jtag_data);
645 return 0;
646}
647
648static int
649ioctl_jtag_put(struct sis1100_softc* sc, struct sis1100_fdata* fd,
650 u_int32_t* d)
651{
652 if (test_super(sc, fd)) return EPERM;
653 sis1100writereg(sc, jtag_csr.jtag_csrl, *d);
654 return 0;
655}
656
657static int
658ioctl_jtag_get(struct sis1100_softc* sc, struct sis1100_fdata* fd,
659 u_int32_t* d)
660{
661 *d=sis1100readreg(sc, jtag_csr.jtag_csrl);
662 return 0;
663}
664
665static int
666_sis1100_ioctl(struct sis1100_softc* sc, struct sis1100_fdata* fd,
667 unsigned int cmd, void* data)
668{
669 int res=0;
670
671 switch (cmd) {
672 case SIS1100_SETVMESPACE:
673 res=ioctl_setvmespace(sc, fd, (struct vmespace*)data); break;
674 case SIS3100_VME_PROBE:
675 res=ioctl_vme_probe(sc, fd, (int*)data); break;
676 case SIS3100_VME_READ:
677 res=ioctl_vme_read(sc, fd, (struct sis1100_vme_req*)data); break;
678 case SIS3100_VME_WRITE:
679 res=ioctl_vme_write(sc, fd, (struct sis1100_vme_req*)data); break;
680 case SIS3100_VME_BLOCK_READ:
681 res=ioctl_vme_block_read(sc, fd, (struct sis1100_vme_block_req*)data);
682 break;
683 case SIS3100_VME_BLOCK_WRITE:
684 res=ioctl_vme_block_write(sc, fd, (struct sis1100_vme_block_req*)data);
685 break;
686#ifdef SIS1100_NEW_CTRL
687 case SIS1100_CTRL_READ:
688 res=ioctl_ctrl_read(sc, fd, (struct sis1100_ctrl_reg*)data);
689 break;
690 case SIS1100_CTRL_WRITE:
691 res=ioctl_ctrl_write(sc, fd, (struct sis1100_ctrl_reg*)data);
692 break;
693#else
694 case SIS1100_LOCAL_CTRL_READ:
695 res=ioctl_local_ctrl_read(sc, fd, (struct sis1100_ctrl_reg*)data);
696 break;
697 case SIS1100_LOCAL_CTRL_WRITE:
698 res=ioctl_local_ctrl_write(sc, fd, (struct sis1100_ctrl_reg*)data);
699 break;
700 case SIS1100_REMOTE_CTRL_READ:
701 res=ioctl_remote_ctrl_read(sc, fd, (struct sis1100_ctrl_reg*)data);
702 break;
703 case SIS1100_REMOTE_CTRL_WRITE:
704 res=ioctl_remote_ctrl_write(sc, fd, (struct sis1100_ctrl_reg*)data);
705 break;
706#endif
707 case SIS1100_PIPE:
708 res=ioctl_pipe(sc, fd, (struct sis1100_pipe*)data); break;
709 case SIS1100_MAPSIZE:
710 res=ioctl_mapsize(sc, fd, (u_int32_t*)data); break;
711 case SIS1100_LAST_ERROR:
712 res=ioctl_last_error(sc, fd, (u_int32_t*)data); break;
713 case SIS1100_IDENT:
714 res=ioctl_ident(sc, fd, (struct sis1100_ident*)data); break;
715 case SIS1100_FIFOMODE:
716 res=ioctl_fifomode(sc, fd, (int*)data); break;
717
718 case SIS1100_IRQ_CTL:
719 res=ioctl_irq_ctl(sc, fd, (struct sis1100_irq_ctl*)data); break;
720 case SIS1100_IRQ_GET:
721 res=ioctl_irq_get(sc, fd, (struct sis1100_irq_get*)data); break;
722 case SIS1100_IRQ_ACK:
723 res=ioctl_irq_ack(sc, fd, (struct sis1100_irq_ack*)data); break;
724 case SIS1100_IRQ_WAIT:
725 res=ioctl_irq_wait(sc, fd, (struct sis1100_irq_get*)data); break;
726
727 case SIS1100_MINDMALEN:
728 res=ioctl_mindmalen(sc, fd, (int*)data); break;
729
730 case SIS1100_FRONT_IO:
731 res=ioctl_front_io(sc, fd, (u_int32_t*)data); break;
732 case SIS1100_FRONT_PULSE:
733 res=ioctl_front_pulse(sc, fd, (u_int32_t*)data); break;
734 case SIS1100_FRONT_LATCH:
735 res=ioctl_front_latch(sc, fd, (u_int32_t*)data); break;
736
737 case SIS3100_VME_SUPER_BLOCK_READ:
738 res=ioctl_vme_super_block_read(sc, fd,
739 (struct sis1100_vme_super_block_req*)data);
740 break;
741 case SIS1100_WRITE_PIPE:
742 res=ioctl_write_pipe(sc, fd, (struct sis1100_writepipe*)data); break;
743
744 case SIS1100_DMA_ALLOC:
745 res=ioctl_dma_alloc(sc, fd, (struct sis1100_dma_alloc*)data); break;
746 case SIS1100_DMA_FREE:
747 res=ioctl_dma_free(sc, fd, (struct sis1100_dma_alloc*)data); break;
748
749 case SIS5100_CCCZ:
750 res=ioctl_cccz(sc, fd); break;
751 case SIS5100_CCCC:
752 res=ioctl_cccc(sc, fd); break;
753 case SIS5100_CCCI:
754 res=ioctl_ccci(sc, fd, (int*)data); break;
755 case SIS5100_CNAF:
756 res=ioctl_cnaf(sc, fd, (struct sis1100_camac_req*)data); break;
757 case SIS1100_SWAP:
758 res=ioctl_swap(sc, fd, (int*)data); break;
759 case SIS3100_TIMEOUTS:
760 res=ioctl_3100_timeouts(sc, fd, (int*)data); break;
761
762 case SIS1100_DSP_LOAD:
763 res=sis1100_dsp_load(sc, fd, (struct sis1100_dsp_code*)data); break;
764 case SIS1100_DSP_RESET:
765 res=sis1100_dsp_reset(sc, fd); break;
766 case SIS1100_DSP_START:
767 res=sis1100_dsp_start(sc, fd); break;
768
769#if 0
770 case SIS1100_RESET:
771 res=ioctl_reset(sc, fd); break;
772#endif
773 case SIS1100_REMOTE_RESET:
774 res=ioctl_remote_reset(sc, fd); break;
775 case SIS1100_DEVTYPE:
776 res=ioctl_devtype(sc, fd, (int*)data); break;
777 case SIS1100_DRIVERVERSION:
778 res=ioctl_driverversion(sc, fd, (int*)data); break;
779 case SIS1100_READ_EEPROM:
780 res=ioctl_read_eeprom(sc, fd, (struct sis1100_eeprom_req*)data); break;
781 case SIS1100_WRITE_EEPROM:
782 res=ioctl_write_eeprom(sc, fd, (struct sis1100_eeprom_req*)data); break;
783
784 case SIS1100_JTAG_ENABLE:
785 res=ioctl_jtag_enable(sc, fd, (u_int32_t*)data); break;
786 case SIS1100_JTAG_CTRL:
787 res=ioctl_jtag_ctrl(sc, fd, (u_int32_t*)data); break;
788 case SIS1100_JTAG_DATA:
789 res=ioctl_jtag_data(sc, fd, (u_int32_t*)data); break;
790 case SIS1100_JTAG_PUT:
791 res=ioctl_jtag_put(sc, fd, (u_int32_t*)data); break;
792 case SIS1100_JTAG_GET:
793 res=ioctl_jtag_get(sc, fd, (u_int32_t*)data); break;
794
795 default:
796 res=ENOTTY; break;
797 }
798 return res;
799}
800
801#ifdef __NetBSD__
802int
803sis1100_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
804{
805 struct sis1100_softc* sc=SIS1100SC(dev);
806 struct sis1100_fdata* fd=SIS1100FD(dev);
807 fd->p=p;
808 return _sis1100_ioctl(sc, fd, cmd, data);
809}
810#elif __linux__
811
812union alles {
813 struct vmespace vmespace;
814 struct sis1100_vme_req vme_req;
815 struct sis1100_vme_block_req vme_block_req;
816 struct sis1100_ctrl_reg ctrl_reg;
817 struct sis1100_pipe pipe;
818 struct sis1100_ident ident;
819 struct sis1100_irq_ctl irq_ctl;
820 struct sis1100_irq_get irq_get;
821 struct sis1100_irq_ack irq_ackirq_ack;
822 struct sis1100_vme_super_block_req vme_super_block_req;
823 struct sis1100_writepipe writepipe;
824 struct sis1100_dma_alloc dma_alloc;
825 struct sis1100_camac_req camac_req;
826 struct sis1100_dsp_code dsp_code;
827 struct sis1100_eeprom_req eeprom_req;
828};
829
830#define MAX_DATA (sizeof(union alles))
831
832int
833sis1100_ioctl(struct inode *inode, struct file *file,
834 unsigned int cmd, unsigned long arg)
835{
836 struct sis1100_softc* sc=SIS1100SC(file);
837 struct sis1100_fdata* fd=SIS1100FD(file);
838 u_int8_t data[MAX_DATA];
839 int res;
840
841 if ((cmd&IOC_INOUT) && (_IOC_SIZE(cmd)>MAX_DATA)) {
842 pINFO(sc, "sis1100_ioctl: cmd=0x%08x _IOC_SIZE(cmd)=%d",
843 cmd, _IOC_SIZE(cmd));
844 return -EINVAL;
845 }
846
847 if (cmd&IOC_IN) {
848 if (copy_from_user(&data, (void *)arg, _IOC_SIZE(cmd)))
849 return -EFAULT;
850 }
851 if ((res=_sis1100_ioctl(sc, fd, cmd, &data)))
852 return -res;
853
854 if (cmd&IOC_OUT) {
855 if (copy_to_user((void *)arg, &data, _IOC_SIZE(cmd)))
856 return -EFAULT;
857 }
858 return 0;
859}
860#endif
Note: See TracBrowser for help on using the repository browser.