Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*
* Porting to u-boot:
*
* (C) Copyright 2010
* Stefano Babic, DENX Software Engineering, sbabic@denx.de.
*
* Lattice ispVME Embedded code to load Lattice's FPGA:
*
* Copyright 2009 Lattice Semiconductor Corp.
*
* ispVME Embedded allows programming of Lattice's suite of FPGA
* devices on embedded systems through the JTAG port. The software
* is distributed in source code form and is open to re - distribution
* and modification where applicable.
*
* Revision History of ivm_core.c module:
* 4/25/06 ht Change some variables from unsigned short or int
* to long int to make the code compiler independent.
* 5/24/06 ht Support using RESET (TRST) pin as a special purpose
* control pin such as triggering the loading of known
* state exit.
* 3/6/07 ht added functions to support output to terminals
*
* 09/11/07 NN Type cast mismatch variables
* Moved the sclock() function to hardware.c
* 08/28/08 NN Added Calculate checksum support.
* 4/1/09 Nguyen replaced the recursive function call codes on
* the ispVMLCOUNT function
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include <linux/string.h>
#include <malloc.h>
#include <lattice.h>
#define vme_out_char(c) printf("%c", c)
#define vme_out_hex(c) printf("%x", c)
#define vme_out_string(s) printf("%s", s)
/*
*
* Global variables used to specify the flow control and data type.
*
* g_usFlowControl: flow control register. Each bit in the
* register can potentially change the
* personality of the embedded engine.
* g_usDataType: holds the data type of the current row.
*
*/
static unsigned short g_usFlowControl;
unsigned short g_usDataType;
/*
*
* Global variables used to specify the ENDDR and ENDIR.
*
* g_ucEndDR: the state that the device goes to after SDR.
* g_ucEndIR: the state that the device goes to after SIR.
*
*/
unsigned char g_ucEndDR = DRPAUSE;
unsigned char g_ucEndIR = IRPAUSE;
/*
*
* Global variables used to support header/trailer.
*
* g_usHeadDR: the number of lead devices in bypass.
* g_usHeadIR: the sum of IR length of lead devices.
* g_usTailDR: the number of tail devices in bypass.
* g_usTailIR: the sum of IR length of tail devices.
*
*/
static unsigned short g_usHeadDR;
static unsigned short g_usHeadIR;
static unsigned short g_usTailDR;
static unsigned short g_usTailIR;
/*
*
* Global variable to store the number of bits of data or instruction
* to be shifted into or out from the device.
*
*/
static unsigned short g_usiDataSize;
/*
*
* Stores the frequency. Default to 1 MHz.
*
*/
static int g_iFrequency = 1000;
/*
*
* Stores the maximum amount of ram needed to hold a row of data.
*
*/
static unsigned short g_usMaxSize;
/*
*
* Stores the LSH or RSH value.
*
*/
static unsigned short g_usShiftValue;
/*
*
* Stores the current repeat loop value.
*
*/
static unsigned short g_usRepeatLoops;
/*
*
* Stores the current vendor.
*
*/
static signed char g_cVendor = LATTICE;
/*
*
* Stores the VME file CRC.
*
*/
unsigned short g_usCalculatedCRC;
/*
*
* Stores the Device Checksum.
*
*/
/* 08/28/08 NN Added Calculate checksum support. */
unsigned long g_usChecksum;
static unsigned int g_uiChecksumIndex;
/*
*
* Stores the current state of the JTAG state machine.
*
*/
static signed char g_cCurrentJTAGState;
/*
*
* Global variables used to support looping.
*
* g_pucHeapMemory: holds the entire repeat loop.
* g_iHeapCounter: points to the current byte in the repeat loop.
* g_iHEAPSize: the current size of the repeat in bytes.
*
*/
unsigned char *g_pucHeapMemory;
unsigned short g_iHeapCounter;
unsigned short g_iHEAPSize;
static unsigned short previous_size;
/*
*
* Global variables used to support intelligent programming.
*
* g_usIntelDataIndex: points to the current byte of the
* intelligent buffer.
* g_usIntelBufferSize: holds the size of the intelligent
* buffer.
*
*/
unsigned short g_usIntelDataIndex;
unsigned short g_usIntelBufferSize;
Loading
Loading full blame...