1 | // $Id: vme_rcc.h,v 1.11 2007/11/08 07:56:44 joos Exp $
|
---|
2 | /************************************************************************/
|
---|
3 | /* */
|
---|
4 | /* File: vme_rcc.h */
|
---|
5 | /* */
|
---|
6 | /* This is the public header file for RCC VMEbus library */
|
---|
7 | /* */
|
---|
8 | /* 12. Oct. 01 MAJO created */
|
---|
9 | /* */
|
---|
10 | /* 011101 JOP add error codes */
|
---|
11 | /* 020418 JOP ROAK / RORA */
|
---|
12 | /* 020527 JOP update interrupt API */
|
---|
13 | /* */
|
---|
14 | /************ C 2003 - The software with that certain something *********/
|
---|
15 |
|
---|
16 | #ifndef _VME_RCC_H
|
---|
17 | #define _VME_RCC_H
|
---|
18 |
|
---|
19 | #include <linux/types.h>
|
---|
20 | #include "vme_rcc_common.h"
|
---|
21 |
|
---|
22 | /***********************************/
|
---|
23 | /*VMEbus transfer type definitions*/
|
---|
24 | /***********************************/
|
---|
25 | #define VME_RP 0x01
|
---|
26 | #define VME_WP 0x02
|
---|
27 | #define VME_A16 0x0
|
---|
28 | #define VME_A24 0x1
|
---|
29 | #define VME_A32 0x2
|
---|
30 | #define VME_CRCSR 0x5
|
---|
31 | #define VME_USER1 0x6
|
---|
32 | #define VME_USER2 0x7
|
---|
33 | #define VME_AM09 (VME_A32)
|
---|
34 | #define VME_AM39 (VME_A24)
|
---|
35 | #define VME_AM29 (VME_A16)
|
---|
36 | #define VME_AM2f (VME_CRCSR)
|
---|
37 | #define VME_AM_PROGRAM 0x00004000
|
---|
38 | #define VME_AM_DATA 0x00000000
|
---|
39 | #define VME_AM_USER 0x00000000
|
---|
40 | #define VME_AM_SUPERVISOR 0x00001000
|
---|
41 | #define VME_DMA_READ 0x00000000
|
---|
42 | #define VME_DMA_WRITE 0x80000000
|
---|
43 | #define VME_DMA_D32 0x00800000
|
---|
44 | #define VME_DMA_D64 0x00c00000
|
---|
45 | #define VME_DMA_DEF 0x00020100 //A32, user, data, BLT
|
---|
46 | #define VME_DMA_D32W (VME_DMA_DEF | VME_DMA_D32 | VME_DMA_WRITE)
|
---|
47 | #define VME_DMA_D32R (VME_DMA_DEF | VME_DMA_D32 | VME_DMA_READ)
|
---|
48 | #define VME_DMA_D64W (VME_DMA_DEF | VME_DMA_D64 | VME_DMA_WRITE)
|
---|
49 | #define VME_DMA_D64R (VME_DMA_DEF | VME_DMA_D64 | VME_DMA_READ)
|
---|
50 | #define VME_DMA_DEF_A24 0x00010100 //A24, user, data, BLT
|
---|
51 | #define VME_DMA_A24D32W (VME_DMA_DEF_A24 | VME_DMA_D32 | VME_DMA_WRITE)
|
---|
52 | #define VME_DMA_A24D32R (VME_DMA_DEF_A24 | VME_DMA_D32 | VME_DMA_READ)
|
---|
53 | #define VME_FIFO_DMA_D32W 0x80820200 //Write in A32/D32 single cycle mode to a constant address
|
---|
54 | #define VME_FIFO_DMA_D32R 0x00820200 //Read in A32/D32 single cycle mode from a constant address
|
---|
55 |
|
---|
56 | /************************************************/
|
---|
57 | /*Identifier definitions for CR/CSR space access*/
|
---|
58 | /* */
|
---|
59 | /* Bits 31..28 Number of bytes to read */
|
---|
60 | /* Bits 27..24 Data width */
|
---|
61 | /* 0 = D08 */
|
---|
62 | /* 1 = D16 */
|
---|
63 | /* 2 = D32 */
|
---|
64 | /* Bits 19..00 Offset of first byte */
|
---|
65 | /************************************************/
|
---|
66 | #define ONE_BYTE 0x10000000
|
---|
67 | #define TWO_BYTE 0x20000000
|
---|
68 | #define THREE_BYTE 0x30000000
|
---|
69 | #define FOUR_BYTE 0x40000000
|
---|
70 |
|
---|
71 | #define CRCSR_D08 0x00000000
|
---|
72 | #define CRCSR_D16 0x01000000
|
---|
73 | #define CRCSR_D32 0x02000000
|
---|
74 |
|
---|
75 | #define CR_CHECKSUM (CRCSR_D08 | ONE_BYTE | 0x00003)
|
---|
76 | #define CR_LENGTH (CRCSR_D08 | THREE_BYTE | 0x00007)
|
---|
77 | #define CR_CRACCESSWIDTH (CRCSR_D08 | ONE_BYTE | 0x00013)
|
---|
78 | #define CR_CSRACCESSWIDTH (CRCSR_D08 | ONE_BYTE | 0x00017)
|
---|
79 | #define CR_CRCSRSPEC (CRCSR_D08 | ONE_BYTE | 0x0001b)
|
---|
80 | #define CR_ASCII1 (CRCSR_D08 | ONE_BYTE | 0x0001f)
|
---|
81 | #define CR_ASCII2 (CRCSR_D08 | ONE_BYTE | 0x00023)
|
---|
82 | #define CR_MANUFID (CRCSR_D08 | THREE_BYTE | 0x00027)
|
---|
83 | #define CR_BOARDID (CRCSR_D08 | FOUR_BYTE | 0x00033)
|
---|
84 | #define CR_REVID (CRCSR_D08 | FOUR_BYTE | 0x00043)
|
---|
85 |
|
---|
86 | #define CSR_BAR (CRCSR_D08 | ONE_BYTE | 0x7ffff)
|
---|
87 | #define CSR_BSR (CRCSR_D08 | ONE_BYTE | 0x7fffb)
|
---|
88 | #define CSR_BCR (CRCSR_D08 | ONE_BYTE | 0x7fff7)
|
---|
89 | #define CSR_ADER7 (CRCSR_D08 | FOUR_BYTE | 0x7ffd3)
|
---|
90 | #define CSR_ADER6 (CRCSR_D08 | FOUR_BYTE | 0x7ffc3)
|
---|
91 | #define CSR_ADER5 (CRCSR_D08 | FOUR_BYTE | 0x7ffb3)
|
---|
92 | #define CSR_ADER4 (CRCSR_D08 | FOUR_BYTE | 0x7ffa3)
|
---|
93 | #define CSR_ADER3 (CRCSR_D08 | FOUR_BYTE | 0x7ff93)
|
---|
94 | #define CSR_ADER2 (CRCSR_D08 | FOUR_BYTE | 0x7ff83)
|
---|
95 | #define CSR_ADER1 (CRCSR_D08 | FOUR_BYTE | 0x7ff73)
|
---|
96 | #define CSR_ADER0 (CRCSR_D08 | FOUR_BYTE | 0x7ff63)
|
---|
97 |
|
---|
98 | /***************************************/
|
---|
99 | /*various upper limits for arrays, etc.*/
|
---|
100 | /***************************************/
|
---|
101 | #define VME_MAXSTRING 256
|
---|
102 |
|
---|
103 |
|
---|
104 | /******************/
|
---|
105 | /*type definitions*/
|
---|
106 | /******************/
|
---|
107 | typedef struct
|
---|
108 | {
|
---|
109 | int number_of_items;
|
---|
110 | VME_BlockTransferItem_t list_of_items[VME_MAXCHAINEL];
|
---|
111 | } VME_BlockTransferList_t;
|
---|
112 |
|
---|
113 | typedef struct
|
---|
114 | {
|
---|
115 | int number_of_items;
|
---|
116 | VME_InterruptItem_t list_of_items[VME_MAXINTERRUPT];
|
---|
117 | } VME_InterruptList_t;
|
---|
118 |
|
---|
119 |
|
---|
120 | /************/
|
---|
121 | /*Prototypes*/
|
---|
122 | /************/
|
---|
123 | #ifdef __cplusplus
|
---|
124 | extern "C" {
|
---|
125 | #endif
|
---|
126 |
|
---|
127 |
|
---|
128 | /*******************************/
|
---|
129 | /*Official functions of the API*/
|
---|
130 | /*******************************/
|
---|
131 | int VME_ErrorPrint(VME_ErrorCode_t error_code);
|
---|
132 | int VME_ErrorString(VME_ErrorCode_t error_code, char *error_string);
|
---|
133 | int VME_ErrorNumber(VME_ErrorCode_t error_code, int *error_number);
|
---|
134 | VME_ErrorCode_t VME_Open(void);
|
---|
135 | VME_ErrorCode_t VME_Close(void);
|
---|
136 | VME_ErrorCode_t VME_ReadCRCSR(int slot_number, u_int crcsr_identifier, u_int *value);
|
---|
137 | VME_ErrorCode_t VME_WriteCRCSR(int slot_number, u_int crcsr_identifier, u_int value);
|
---|
138 | VME_ErrorCode_t VME_MasterMap(VME_MasterMap_t *master_map, int *master_mapping);
|
---|
139 | VME_ErrorCode_t VME_MasterMapVirtualAddress(int master_mapping, u_int *virtual_address);
|
---|
140 | VME_ErrorCode_t VME_ReadSafeUInt(int master_mapping, u_int address_offset, u_int *value);
|
---|
141 | VME_ErrorCode_t VME_ReadSafeUShort(int master_mapping, u_int address_offset, u_short *value);
|
---|
142 | VME_ErrorCode_t VME_ReadSafeUChar(int master_mapping, u_int address_offset, u_char *value);
|
---|
143 | VME_ErrorCode_t VME_WriteSafeUInt(int master_mapping, u_int address_offset, u_int value);
|
---|
144 | VME_ErrorCode_t VME_WriteSafeUShort(int master_mapping, u_int address_offset, u_short value);
|
---|
145 | VME_ErrorCode_t VME_WriteSafeUChar(int master_mapping, u_int address_offset, u_char value);
|
---|
146 | VME_ErrorCode_t VME_MasterUnmap(int master_mapping);
|
---|
147 | VME_ErrorCode_t VME_MasterMapDump(void);
|
---|
148 | VME_ErrorCode_t VME_BusErrorRegisterSignal(int signal_number);
|
---|
149 | VME_ErrorCode_t VME_BusErrorInfoGet(VME_BusErrorInfo_t *bus_error_info);
|
---|
150 | VME_ErrorCode_t VME_SlaveMap(VME_SlaveMap_t *slave_map, int *slave_mapping);
|
---|
151 | VME_ErrorCode_t VME_SlaveMapVmebusAddress(int slave_mapping, u_int *vmebus_address);
|
---|
152 | VME_ErrorCode_t VME_SlaveUnmap(int slave_mapping);
|
---|
153 | VME_ErrorCode_t VME_SlaveMapDump(void);
|
---|
154 | VME_ErrorCode_t VME_BlockTransferInit(VME_BlockTransferList_t *block_transfer_list, int *block_transfer);
|
---|
155 | VME_ErrorCode_t VME_BlockTransferStart(int block_transfer);
|
---|
156 | VME_ErrorCode_t VME_BlockTransferWait(int block_transfer, int time_out, VME_BlockTransferList_t *block_transfer_list);
|
---|
157 | VME_ErrorCode_t VME_BlockTransferEnd(int block_transfer);
|
---|
158 | VME_ErrorCode_t VME_BlockTransfer(VME_BlockTransferList_t *block_transfer_list, int time_out);
|
---|
159 | VME_ErrorCode_t VME_BlockTransferDump(void);
|
---|
160 | VME_ErrorCode_t VME_BlockTransferStatus(VME_BlockTransferList_t *block_transfer_list, int position_of_block, VME_ErrorCode_t *status);
|
---|
161 | VME_ErrorCode_t VME_BlockTransferRemaining(VME_BlockTransferList_t *block_transfer_list, int position_of_block, int *remaining);
|
---|
162 | VME_ErrorCode_t VME_InterruptLink(VME_InterruptList_t* vmebus_interrupt_list, int *interrupt);
|
---|
163 | VME_ErrorCode_t VME_InterruptReenable(int interrupt);
|
---|
164 | VME_ErrorCode_t VME_InterruptWait(int interrupt, int time_out, VME_InterruptInfo_t* ir_info);
|
---|
165 | VME_ErrorCode_t VME_InterruptRegisterSignal(int interrupt, int signal_number);
|
---|
166 | VME_ErrorCode_t VME_InterruptInfoGet(int interrupt, VME_InterruptInfo_t* ir_info);
|
---|
167 | VME_ErrorCode_t VME_InterruptUnlink(int interrupt);
|
---|
168 | VME_ErrorCode_t VME_InterruptGenerate(int level, u_char vector);
|
---|
169 | VME_ErrorCode_t VME_InterruptDump(void);
|
---|
170 | VME_ErrorCode_t VME_SysfailInterruptLink(void);
|
---|
171 | VME_ErrorCode_t VME_SysfailInterruptRegisterSignal(int signal_number);
|
---|
172 | VME_ErrorCode_t VME_SysfailInterruptWait(int time_out);
|
---|
173 | VME_ErrorCode_t VME_SysfailInterruptUnlink(void);
|
---|
174 | VME_ErrorCode_t VME_SysfailInterruptReenable(void);
|
---|
175 | VME_ErrorCode_t VME_SysfailSet(void);
|
---|
176 | VME_ErrorCode_t VME_SysfailReset(void);
|
---|
177 | VME_ErrorCode_t VME_SysfailPoll(int *flag);
|
---|
178 | VME_ErrorCode_t VME_UniverseMap(u_int *virtual_address);
|
---|
179 | VME_ErrorCode_t VME_UniverseUnmap(u_int virtual_address);
|
---|
180 | VME_ErrorCode_t VME_CCTSetSwap(u_char data);
|
---|
181 | VME_ErrorCode_t VME_Update(u_int *data);
|
---|
182 | VME_ErrorCode_t VME_SendSysreset(void);
|
---|
183 | void VME_ReadFastUInt(int master_mapping, u_int address_offset, u_int *value);
|
---|
184 | void VME_ReadFastUShort(int master_mapping, u_int address_offset, u_short *value);
|
---|
185 | void VME_ReadFastUChar(int master_mapping, u_int address_offset, u_char *value);
|
---|
186 | void VME_WriteFastUInt(int master_mapping, u_int address_offset, u_int value);
|
---|
187 | void VME_WriteFastUShort(int master_mapping, u_int address_offset, u_short value);
|
---|
188 | void VME_WriteFastUChar(int master_mapping, u_int address_offset, u_char value);
|
---|
189 |
|
---|
190 | /******************************/
|
---|
191 | /* Internal service functions */
|
---|
192 | /******************************/
|
---|
193 | VME_ErrorCode_t vmercc_err_get(err_pack err, err_str pid, err_str code);
|
---|
194 |
|
---|
195 | /**********************************/
|
---|
196 | /*Additional (temporary) functions*/
|
---|
197 | /**********************************/
|
---|
198 | VME_ErrorCode_t VME_test(void);
|
---|
199 |
|
---|
200 |
|
---|
201 | #ifdef __cplusplus
|
---|
202 | }
|
---|
203 | #endif
|
---|
204 |
|
---|
205 | #endif
|
---|