source: drsdaq/VME/struck/sis1100/V2.02/dev/pci/sis1100_dsp.c@ 23

Last change on this file since 23 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
File size: 4.0 KB
Line 
1/* $ZEL: sis1100_dsp.c,v 1.2 2004/05/27 23:10:19 wuestner Exp $ */
2
3/*
4 * Copyright (c) 2003-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#include "sis1100_sc.h"
30
31#if !defined(__NetBSD__) && ! defined(__linux__)
32#error Invalid or Unknown Operating System
33#endif
34
35int
36sis1100_dsp_reset(struct sis1100_softc* sc, struct sis1100_fdata* fd)
37{
38 int error;
39
40 if (!sc->dsp_present) return ENXIO;
41 switch (sc->remote_hw) {
42 case sis1100_hw_vme:
43 SEM_LOCK(sc->sem_hw);
44 error=sis3100writeremreg(sc, dsp_sc, sis3100_dsp_boot_ctrl, 1);
45 if (!error) error=sis3100writeremreg(sc, dsp_sc, sis3100_dsp_run<<16, 1);
46 SEM_UNLOCK(sc->sem_hw);
47 break;
48 case sis1100_hw_camac:
49 SEM_LOCK(sc->sem_hw);
50 error=sis5100writeremreg(sc, dsp_sc, sis5100_dsp_boot_ctrl, 1);
51 if (!error) error=sis5100writeremreg(sc, dsp_sc, sis5100_dsp_run<<16, 1);
52 SEM_UNLOCK(sc->sem_hw);
53 break;
54 default:
55 return ENOTTY;
56 }
57/*
58 if (error) {
59 pINFO(sc, "dsp_reset: error=0x%x", error);
60 return EIO;
61 }
62*/
63 return error?EIO:0;
64}
65
66int
67sis1100_dsp_start(struct sis1100_softc* sc, struct sis1100_fdata* fd)
68{
69 int error;
70
71 if (!sc->dsp_present) return ENXIO;
72 switch (sc->remote_hw) {
73 case sis1100_hw_vme:
74 error=sis3100writeremreg(sc, dsp_sc, sis3100_dsp_run, 0);
75 break;
76 case sis1100_hw_camac:
77 error=sis5100writeremreg(sc, dsp_sc, sis5100_dsp_run, 0);
78 break;
79 default:
80 return ENOTTY;
81 }
82 return error?EIO:0;
83}
84
85#define SHARCRAM 0x81200000
86#define D48REG 0x81300000
87
88int
89sis1100_dsp_load(struct sis1100_softc* sc, struct sis1100_fdata* fd,
90 struct sis1100_dsp_code* d)
91{
92 u_int8_t* code=d->src;
93 u_int8_t v[6];
94 u_int32_t addr, w0, w12;
95 int error=0, i, j;
96
97 if (!sc->dsp_present) return ENXIO;
98if (sc->remote_hw!=sis1100_hw_vme) return ENXIO;
99
100 if (d->dst%4) return EINVAL;
101 if (d->size%6) return EINVAL;
102
103 addr=d->dst+SHARCRAM;
104 for (i=d->size/6; i && !error; i--) {
105 for (j=0; j<6; j++) {
106#ifdef __NetBSD__
107 v[j]=fubyte(code);
108#elif __linux__
109 get_user(v[j], code);
110#endif
111 code++;
112 }
113#if 0
114 pINFO("%08x %02x%02x%02x%02x%02x%02x",
115 (addr-SHARCRAM)>>2,
116 v[0], v[1], v[2], v[3], v[4], v[5]);
117#endif
118 w0=v[5]|(v[4]<<8);
119 w12=(v[3] | (v[2]<<8) | (v[1]<<16) | (v[0]<<24));
120 SEM_LOCK(sc->sem_hw);
121 error=sis1100_remote_reg_write(sc, D48REG, w0, 1);
122 error|=sis1100_remote_reg_write(sc, addr, w12, 1);
123 SEM_UNLOCK(sc->sem_hw);
124 addr+=4;
125 }
126 return error?EIO:0;
127}
Note: See TracBrowser for help on using the repository browser.