osmo-sdr/utils/rum-ba/src/lattice/slim_vme.c @ master
1 |
/**************************************************************
|
---|---|
2 |
*
|
3 |
* Lattice Semiconductor Corp. Copyright 2008
|
4 |
*
|
5 |
*
|
6 |
***************************************************************/
|
7 |
|
8 |
|
9 |
/**************************************************************
|
10 |
*
|
11 |
* Revision History of slim_vme.c
|
12 |
*
|
13 |
*
|
14 |
* 09/11/07 NN Updated to support version 1.3
|
15 |
* This version supported new POLING STATUS LOOP opcodes (LOOP and ENDLOOP)
|
16 |
* for Flash programming of the Lattice FPGA devices
|
17 |
* 09/11/07 NN Added Global variables initialization
|
18 |
* 09/11/07 NN type cast all mismatch variables
|
19 |
***************************************************************/
|
20 |
|
21 |
|
22 |
#include <stdlib.h>
|
23 |
#include "opcode.h"
|
24 |
#include "hardware.h"
|
25 |
|
26 |
#define xdata
|
27 |
#define reentrant
|
28 |
|
29 |
/*************************************************************
|
30 |
* *
|
31 |
* EXTERNAL FUNCTIONS *
|
32 |
* *
|
33 |
*************************************************************/
|
34 |
|
35 |
extern unsigned char GetByte( int a_iCurrentIndex, char a_cAlgo ); |
36 |
extern short ispProcessVME(); |
37 |
extern void EnableHardware(); |
38 |
extern void DisableHardware(); |
39 |
|
40 |
/***************************************************************
|
41 |
*
|
42 |
* Supported VME versions.
|
43 |
*
|
44 |
***************************************************************/
|
45 |
char *g_szSupportedVersions[] = { "_SVME1.1", "_SVME1.2", "_SVME1.3", 0 }; |
46 |
|
47 |
/*************************************************************
|
48 |
* *
|
49 |
* EXTERNAL VARIABLES *
|
50 |
* *
|
51 |
* If the algorithm does not require the data, then *
|
52 |
* declare the variables g_pucDataArray and g_iDataSize *
|
53 |
* as local variables and set them to NULL and 0, *
|
54 |
* respectively. *
|
55 |
* *
|
56 |
* Example: *
|
57 |
* xdata unsigned char * g_pucDataArray = NULL; *
|
58 |
* xdata int g_iDataSize = 0; *
|
59 |
* *
|
60 |
*************************************************************/
|
61 |
|
62 |
extern int g_iMovingAlgoIndex; |
63 |
extern int g_iMovingDataIndex; |
64 |
extern unsigned short g_usDataType; |
65 |
|
66 |
|
67 |
/*************************************************************
|
68 |
* *
|
69 |
* ISPVMENTRYPOINT *
|
70 |
* *
|
71 |
* INPUT: *
|
72 |
* a_pszAlgoFile: this is the name of the algorithm file. *
|
73 |
* *
|
74 |
* a_pszDataFile: this is the name of the data file. *
|
75 |
* Note that this argument may be empty if the algorithm *
|
76 |
* does not require a data file. *
|
77 |
* *
|
78 |
* RETURN: *
|
79 |
* The return value will be a negative number if an error *
|
80 |
* occurred, or 0 if everything was successful *
|
81 |
* *
|
82 |
* DESCRIPTION: *
|
83 |
* This function opens the file pointers to the algo and *
|
84 |
* data file. It intializes global variables to their *
|
85 |
* default values and enters the processor. *
|
86 |
* *
|
87 |
*************************************************************/
|
88 |
|
89 |
short int ispEntryPoint() |
90 |
{
|
91 |
char szFileVersion[ 9 ] = { 0 }; |
92 |
short int siRetCode = 0; |
93 |
short int iIndex = 0; |
94 |
short int cVersionIndex = 0; |
95 |
|
96 |
/*************************************************************
|
97 |
* *
|
98 |
* VARIABLES INITIALIZATION *
|
99 |
* *
|
100 |
*************************************************************/
|
101 |
|
102 |
g_usDataType = 0; |
103 |
g_iMovingAlgoIndex = 0; |
104 |
g_iMovingDataIndex = 0; |
105 |
|
106 |
if ( g_ispDataSize ) { |
107 |
if ( GetByte( g_iMovingDataIndex++, 0 ) ) { |
108 |
g_usDataType |= COMPRESS; |
109 |
}
|
110 |
}
|
111 |
/***************************************************************
|
112 |
*
|
113 |
* Read and store the version of the VME file.
|
114 |
*
|
115 |
***************************************************************/
|
116 |
|
117 |
for ( iIndex = 0; iIndex < 8; iIndex++ ) { |
118 |
szFileVersion[ iIndex ] = GetByte( g_iMovingAlgoIndex++, 1 ); |
119 |
}
|
120 |
|
121 |
/***************************************************************
|
122 |
*
|
123 |
* Compare the VME file version against the supported version.
|
124 |
*
|
125 |
***************************************************************/
|
126 |
|
127 |
for ( cVersionIndex = 0; g_szSupportedVersions[ cVersionIndex ] != 0; cVersionIndex++ ) { |
128 |
for ( iIndex = 0; iIndex < 8; iIndex++ ) { |
129 |
if ( szFileVersion[ iIndex ] != g_szSupportedVersions[ cVersionIndex ][ iIndex ] ) { |
130 |
siRetCode = ERR_WRONG_VERSION; |
131 |
break; |
132 |
}
|
133 |
siRetCode = 0; |
134 |
}
|
135 |
|
136 |
if ( siRetCode == 0 ) { |
137 |
|
138 |
/***************************************************************
|
139 |
*
|
140 |
* Found matching version, break.
|
141 |
*
|
142 |
***************************************************************/
|
143 |
|
144 |
break; |
145 |
}
|
146 |
}
|
147 |
|
148 |
if ( siRetCode < 0 ) { |
149 |
|
150 |
/***************************************************************
|
151 |
*
|
152 |
* VME file version failed to match the supported versions.
|
153 |
*
|
154 |
***************************************************************/
|
155 |
|
156 |
return ERR_WRONG_VERSION; |
157 |
}
|
158 |
|
159 |
|
160 |
/*************************************************************
|
161 |
* *
|
162 |
* Start the hardware. *
|
163 |
* *
|
164 |
*************************************************************/
|
165 |
|
166 |
EnableHardware(); |
167 |
|
168 |
/*************************************************************
|
169 |
* *
|
170 |
* Begin processing algorithm and data file. *
|
171 |
* *
|
172 |
*************************************************************/
|
173 |
|
174 |
siRetCode = ispProcessVME(); |
175 |
|
176 |
/*************************************************************
|
177 |
* *
|
178 |
* Stop the hardware. *
|
179 |
* *
|
180 |
*************************************************************/
|
181 |
|
182 |
DisableHardware(); |
183 |
|
184 |
/*************************************************************
|
185 |
* *
|
186 |
* Return the return code. *
|
187 |
* *
|
188 |
*************************************************************/
|
189 |
|
190 |
return ( siRetCode ); |
191 |
}
|
192 |
/*************************************************************
|
193 |
* *
|
194 |
* MAIN *
|
195 |
* *
|
196 |
*************************************************************/
|
197 |
|
198 |
#if 0
|
199 |
short int main()
|
200 |
{
|
201 |
/*************************************************************
|
202 |
* *
|
203 |
* LOCAL VARIABLES: *
|
204 |
* siRetCode: this variable holds the return. *
|
205 |
* *
|
206 |
*************************************************************/
|
207 |
|
208 |
short int siRetCode = 0;
|
209 |
/*************************************************************
|
210 |
* *
|
211 |
* Pass in the command line arguments to the entry point. *
|
212 |
* *
|
213 |
*************************************************************/
|
214 |
|
215 |
siRetCode = ispEntryPoint();
|
216 |
return( siRetCode );
|
217 |
}
|
218 |
#endif
|
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »