devLib2  2.11
devcsr.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2010 Brookhaven Science Associates, as Operator of
3 * Brookhaven National Laboratory.
4 * Copyright (c) 2006 The University of Chicago,
5 * as Operator of Argonne National Laboratory.
6 * Copyright (c) 2006 The Regents of the University of California,
7 * as Operator of Los Alamos National Laboratory.
8 * Copyright (c) 2006 The Board of Trustees of the Leland Stanford Junior
9 * University, as Operator of the Stanford Linear Accelerator Center.
10 * devLib2 is distributed subject to a Software License Agreement found
11 * in file LICENSE that is included with this distribution.
12 \*************************************************************************/
13 /*
14  * Author: Michael Davidsaver <mdavidsaver@gmail.com>
15  */
16 
17 #ifndef DEVLIBCSR_H
18 #define DEVLIBCSR_H 1
19 
28 #include <epicsVersion.h>
29 
30 #if EPICS_VERSION==3 && EPICS_REVISION==14 && EPICS_MODIFICATION<10
31 # include "devLibVME.h"
32 #else
33 # include "devLib.h"
34 #endif
35 
36 #include <epicsTypes.h>
37 #include "epicsMMIO.h"
38 #include "vmedefs.h"
39 
40 #include <shareLib.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 
45 # ifndef INLINE
46 # define INLINE inline
47 # endif
48 #endif
49 
50 #define DEVLIBVME_MAJOR 1
51 #define DEVLIBVME_MINOR 0
58 struct VMECSRID {
59  epicsUInt32 vendor,board,revision;
60 };
61 
63 #define VMECSR_END {0,0,0}
64 
66 #define VMECSRANY 0xFfffFfff
67 
69 #define VMECSRSLOTMAX ((1<<5)-1)
70 
86 epicsShareFunc
87 volatile unsigned char* devCSRProbeSlot(int slot);
88 
116 epicsShareFunc
117 volatile unsigned char* devCSRTestSlot(
118  const struct VMECSRID* devs,
119  int slot,
120  struct VMECSRID* info
121 );
122 
130 #define CSRSlotBase(slot) ( (slot)<<19 )
131 
137 #define CSRADER(addr,mod) ( ((addr)&0xFfffFf00) | ( ((mod)&0x3f)<<2 ) )
138 
139 /* Read/Write CR for standard sizes
140  */
141 
142 #define CSRRead8(addr) ioread8(addr)
143 
144 #define CSRRead16(addr) ( CSRRead8(addr)<<8 | CSRRead8(addr+4) )
145 
146 #define CSRRead24(addr) ( CSRRead16(addr)<<8 | CSRRead8(addr+8) )
147 
148 #define CSRRead32(addr) ( CSRRead24(addr)<<8 | CSRRead8(addr+12) )
149 
150 #define CSRWrite8(addr,val) iowrite8(addr, val)
151 
152 #define CSRWrite16(addr,val) \
153 do{ CSRWrite8(addr,(val&0xff00)>>8); CSRWrite8(addr+4,val&0xff); }while(0)
154 
155 #define CSRWrite24(addr,val) \
156 do{ CSRWrite16(addr,(val&0xffff00)>>8); CSRWrite8(addr+8,val&0xff); }while(0)
157 
158 #define CSRWrite32(addr,val) \
159 do{ CSRWrite24(addr,(val&0xffffff00)>>8); CSRWrite8(addr+12,val&0xff); }while(0)
160 
161 /*
162  * Utility functions
163  */
164 
174 epicsShareExtern void vmecsrprint(int N,int verb);
175 
182 epicsShareExtern void vmecsrdump(int verb);
183 
210 /**************************************************************************************************/
211 /* CR/CSR Configuration ROM (CR) Register Definitions */
212 /**************************************************************************************************/
213 
214 /* VME64 required CR registers */
215 
216 #define CR_ROM_CHECKSUM 0x0003
217 #define CR_ROM_LENGTH 0x0007
218 #define CR_DATA_ACCESS_WIDTH 0x0013
219 #define CSR_DATA_ACCESS_WIDTH 0x0017
220 #define CR_SPACE_ID 0x001B
222 #define CR_ASCII_C 0x001F
223 #define CR_ASCII_R 0x0023
225 #define CR_IEEE_OUI 0x0027
226 #define CR_IEEE_OUI_BYTES 3
227 #define CR_BOARD_ID 0x0033
228 #define CR_BOARD_ID_BYTES 4
229 #define CR_REVISION_ID 0x0043
230 #define CR_REVISION_ID_BYTES 4
231 #define CR_ASCII_STRING 0x0053
232 #define CR_PROGRAM_ID 0x007F
234 /* VME64x required CR registers */
235 
236 #define CR_BEG_UCR 0x0083
237 #define CR_END_UCR 0x008F
238 #define CR_BEG_UCSR_BYTES 3
240 #define CR_BEG_CRAM 0x009B
241 #define CR_END_CRAM 0x00A7
243 #define CR_BEG_UCSR 0x00B3
244 #define CR_END_UCSR 0x00BF
246 #define CR_BEG_SN 0x00CB
247 #define CR_END_SN 0x00DF
249 #define CR_SLAVE_CHAR 0x00E3
250 #define CR_UD_SLAVE_CHAR 0x00E7
252 #define CR_MASTER_CHAR 0x00EB
253 #define CR_UD_MASTER_CHAR 0x00EF
255 #define CR_IRQ_HANDLER_CAP 0x00F3
256 #define CR_IRQ_CAP 0x00F7
258 #define CR_CRAM_WIDTH 0x00FF
260 #define CR_FN_DAWPR(N) ( 0x0103 + (N)*0x04 ) /* N = 0 -> 7 */
261 
262 #define CR_DAWPR_BYTES 1 /* Number of bytes in a DAWPR register */
264 #define CR_FN_AMCAP(N) ( 0x0123 + (N)*0x20 ) /* N = 0 -> 7 */
266 #define CR_AMCAP_BYTES 8 /* Number of bytes in an AMCAP register */
267 
268 #define CR_FN_XAMCAP(N) ( 0x0223 + (N)*0x80 ) /* N = 0 -> 7 */
269 
270 #define CR_XAMCAP_BYTES 32 /* Number of bytes in an XAMCAP register */
271 
272 #define CR_FN_ADEM(N) ( 0x0623 + (N)*0x10 ) /* N = 0 -> 7 */
274 #define CR_ADEM_BYTES 4 /* Number of bytes in an ADEM register */
276 #define CR_MASTER_DAWPR 0x06AF
277 #define CR_MASTER_AMCAP 0x06B3
278 #define CR_MASTER_XAMCAP 0x06D3
280 /*---------------------
281  * Size (in total bytes) of CR space
282  */
283 #define CR_SIZE 0x0750
284 #define CR_BYTES (CR_SIZE>>2)
286 /**************************************************************************************************/
287 /* CR/CSR Control and Status Register (CSR) Offsets */
288 /**************************************************************************************************/
289 
290 /* VME64 required CSR registers */
291 
292 #define CSR_BAR 0x7ffff
293 #define CSR_BIT_SET 0x7fffb
294 #define CSR_BIT_CLEAR 0x7fff7
296 /* VME64x required CSR registers */
298 #define CSR_CRAM_OWNER 0x7fff3
299 #define CSR_UD_BIT_SET 0x7ffef
300 #define CSR_UD_BIT_CLEAR 0x7ffeb
301 #define CSR_FN_ADER(N) (0x7ff63 + (N)*0x10) /* N = 0 -> 7 */
303 #define CSR_ADER_BYTES 4 /* Number of bytes in an ADER register */
305 /*---------------------
306  * Bit offset definitions for the Bit Set Status Register
307  */
308 #define CSR_BITSET_RESET_MODE 0x80
309 #define CSR_BITSET_SYSFAIL_ENA 0x40
310 #define CSR_BITSET_MODULE_FAIL 0x20
311 #define CSR_BITSET_MODULE_ENA 0x10
312 #define CSR_BITSET_BERR 0x08
313 #define CSR_BITSET_CRAM_OWNED 0x04
316 /* Common things to set in CSR
317  */
328 INLINE
329 void
330 CSRSetBase(volatile void* base, epicsUInt8 N, epicsUInt32 addr, epicsUInt8 amod)
331 {
332  volatile char* ptr=(volatile char*)base;
333  if (N>7) return;
334  CSRWrite32((ptr) + CSR_FN_ADER(N), CSRADER(addr,amod) );
335 }
336 
337 #ifdef __cplusplus
338 } /* extern "C" */
339 #endif
340 
341 #endif /* DEVLIBCSR_H */
epicsUInt32 vendor
Definition: devcsr.h:59
INLINE void CSRSetBase(volatile void *base, epicsUInt8 N, epicsUInt32 addr, epicsUInt8 amod)
Set base address for VME64x function N.
Definition: devcsr.h:335
epicsShareExtern void vmecsrprint(int N, int verb)
Decode contents of CSR/CR and print to screen.
Definition: devcsr.c:119
epicsShareFunc volatile unsigned char * devCSRTestSlot(const struct VMECSRID *devs, int slot, struct VMECSRID *info)
Probe a VME slot then check its ID.
Definition: devcsr.c:83
ID info for a VME64(x) device This structure is used to hold identifying information for a VME64 comp...
Definition: devcsr.h:58
epicsShareFunc volatile unsigned char * devCSRProbeSlot(int slot)
Get the CSR base address for a slot.
Definition: devcsr.c:18
epicsUInt32 board
Definition: devcsr.h:59
#define CSRWrite32(addr, val)
Definition: devcsr.h:158
#define CSR_FN_ADER(N)
Function N Address Decoder Compare Register (1st byte)
Definition: devcsr.h:305
epicsShareExtern void vmecsrdump(int verb)
Decode contents of CSR/CR for all cards and print to screen.
Definition: devcsr.c:233
epicsUInt32 revision
Definition: devcsr.h:59
#define CSRADER(addr, mod)
Computes values for the VME64x address decode registers (ADER).
Definition: devcsr.h:137