-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvims.h
371 lines (353 loc) · 14.4 KB
/
vims.h
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
/******************************************************************************
* Filename: vims.h
* Revised: 2016-10-06 17:21:09 +0200 (Thu, 06 Oct 2016)
* Revision: 47343
*
* Description: Defines and prototypes for the VIMS.
*
* Copyright (c) 2015 - 2017, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2) Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3) Neither the name of the ORGANIZATION nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
//*****************************************************************************
//
//! \addtogroup system_control_group
//! @{
//! \addtogroup vims_api
//! @{
//
//*****************************************************************************
#ifndef __VIMS_H__
#define __VIMS_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdbool.h>
#include <stdint.h>
#include "../inc/hw_types.h"
#include "../inc/hw_memmap.h"
#include "../inc/hw_vims.h"
#include "debug.h"
//*****************************************************************************
//
// Support for DriverLib in ROM:
// This section renames all functions that are not "static inline", so that
// calling these functions will default to implementation in flash. At the end
// of this file a second renaming will change the defaults to implementation in
// ROM for available functions.
//
// To force use of the implementation in flash, e.g. for debugging:
// - Globally: Define DRIVERLIB_NOROM at project level
// - Per function: Use prefix "NOROM_" when calling the function
//
//*****************************************************************************
#if !defined(DOXYGEN)
#define VIMSConfigure NOROM_VIMSConfigure
#define VIMSModeSet NOROM_VIMSModeSet
#define VIMSModeGet NOROM_VIMSModeGet
#define VIMSModeSafeSet NOROM_VIMSModeSafeSet
#endif
//*****************************************************************************
//
// Values that can be passed to VIMSModeSet() as the ui32IntFlags parameter,
// and returned from VIMSModeGet().
//
//*****************************************************************************
#define VIMS_MODE_CHANGING 0x4 // VIMS mode is changing now and VIMS_MODE
// can not be changed at moment.
#define VIMS_MODE_DISABLED (VIMS_CTL_MODE_GPRAM) // Disabled mode (GPRAM enabled).
#define VIMS_MODE_ENABLED (VIMS_CTL_MODE_CACHE) // Enabled mode, only USERCODE is cached.
#define VIMS_MODE_OFF (VIMS_CTL_MODE_OFF) // VIMS Cache RAM is off
//*****************************************************************************
//
// API Functions and prototypes
//
//*****************************************************************************
#ifdef DRIVERLIB_DEBUG
//*****************************************************************************
//
//! \brief Checks a VIMS base address.
//!
//! This function determines if the VIMS base address is valid.
//!
//! \param ui32Base is the base address of the VIMS.
//!
//! \return Returns \c true if the base address is valid and \c false
//! otherwise.
//
//*****************************************************************************
static bool
VIMSBaseValid(uint32_t ui32Base)
{
return(ui32Base == VIMS_BASE);
}
#endif
//*****************************************************************************
//
//! \brief Configures the VIMS.
//!
//! This function sets general control settings of the VIMS system.
//!
//! \note The VIMS mode must be set using the \ref VIMSModeSet() call.
//!
//! \param ui32Base is the base address of the VIMS.
//! \param bRoundRobin specifies the arbitration method.
//! - \c true : Round Robin arbitration between the two available read/write interfaces
//! (i.e. Icode/Dcode and Sysbus) is to be used.
//! - \c false : Strict arbitration will be used, where Icode/Dcode
//! is preferred over the Sysbus.
//! \param bPrefetch specifies if prefetching is to be used.
//! - \c true : Cache is to prefetch tag data for the following address.
//! - \c false : No prefetch.
//!
//! \return None
//!
//! \sa \ref VIMSModeSet()
//
//*****************************************************************************
extern void VIMSConfigure(uint32_t ui32Base, bool bRoundRobin,
bool bPrefetch);
//*****************************************************************************
//
//! \brief Set the operational mode of the VIMS.
//!
//! This function sets the operational mode of the VIMS.
//!
//! Upon reset the VIMS will be in \ref VIMS_MODE_CHANGING mode.
//! In this mode the VIMS will initialize the cache (GP) RAM (to all zeros).
//! The GP RAM will not be operational (read/write will result in bus fault).
//! The Cache will not be operational.
//! Reads and writes to flash will be uncached.
//! After a short delay (approx. 1029 clock cycles) the VIMS will
//! automatically switch mode to \ref VIMS_MODE_DISABLED (GPRAM enabled).
//!
//! In \ref VIMS_MODE_DISABLED mode, the cache is disabled but the GP RAM is
//! accessible:
//! The GP RAM will be accessible.
//! The Cache will not be operational.
//! Reads from flash will be uncached.
//! From this mode, the VIMS may be put in \ref VIMS_MODE_ENABLED (CACHE mode).
//!
//! In \ref VIMS_MODE_ENABLED mode, the cache is enabled for \b USERCODE space.
//! The GP RAM will not be operational (read/write will result in bus fault).
//! The Cache will be operational for SYSCODE space.
//! Reads from flash in USERCODE space will be uncached.
//!
//! In \ref VIMS_MODE_OFF the cache RAM is off to conserve power.
//!
//! \note The VIMS must be invalidated when switching mode.
//! This is done by setting VIMS_MODE_OFF before setting any new mode.
//! This is automatically handled in \ref VIMSModeSafeSet()
//!
//! \note It is highly recommended that the VIMS is put in disabled mode before
//! \b writing to flash, since the cache will not be updated nor invalidated
//! by flash writes. The line buffers should also be disabled when updating the
//! flash. Once \ref VIMSModeSet() is used to set the VIMS in
//! \ref VIMS_MODE_CHANGING mode, the user should check using
//! \ref VIMSModeGet() when the mode switches to \ref VIMS_MODE_DISABLED. Only when
//! the mode has changed the cache has been completely invalidated.
//!
//! \note Access from System Bus is never cached. Only access through ICODE
//! DCODE bus from the System CPU is cached.
//!
//! \param ui32Base is the base address of the VIMS.
//! \param ui32Mode is the operational mode.
//! - \ref VIMS_MODE_DISABLED (GPRAM enabled)
//! - \ref VIMS_MODE_ENABLED (CACHE mode)
//! - \ref VIMS_MODE_OFF
//!
//! \return None
//!
//! \sa \ref VIMSModeGet() and \ref VIMSModeSafeSet()
//
//*****************************************************************************
extern void VIMSModeSet(uint32_t ui32Base, uint32_t ui32Mode);
//*****************************************************************************
//
//! \brief Get the current operational mode of the VIMS.
//!
//! This function returns the operational mode of the VIMS.
//!
//! \param ui32Base is the base address of the VIMS.
//!
//! \return Returns one of:
//! - \ref VIMS_MODE_CHANGING
//! - \ref VIMS_MODE_DISABLED (GPRAM enabled)
//! - \ref VIMS_MODE_ENABLED (CACHE mode)
//! - \ref VIMS_MODE_OFF
//!
//! \sa \ref VIMSModeSet()
//
//*****************************************************************************
extern uint32_t VIMSModeGet(uint32_t ui32Base);
//*****************************************************************************
//
//! \brief Set the operational mode of the VIMS in a safe sequence.
//!
//! This function sets the operational mode of the VIMS in a safe sequence
//!
//! Upon reset the VIMS will be in \ref VIMS_MODE_CHANGING mode.
//! In this mode the VIMS will initialize the cache (GP) RAM (to all zeros).
//! The GP RAM will not be operational (read/write will result in bus fault).
//! The Cache will not be operational (read/write to flash will be uncached).
//! After a short delay (approx. 1029 clock cycles) the VIMS will
//! automatically switch mode to \ref VIMS_MODE_DISABLED (GPRAM enabled).
//!
//! In \ref VIMS_MODE_DISABLED mode, the cache is disabled but the GP RAM is
//! accessible:
//! The GP RAM will be accessible.
//! The Cache will not be operational.
//! Reads from flash will be uncached.
//! From this mode, the VIMS may be put in \ref VIMS_MODE_ENABLED (CACHE mode).
//!
//! In \ref VIMS_MODE_ENABLED mode, the cache is enabled for \b USERCODE space.
//! The GP RAM will not be operational (read/write will result in bus fault).
//! The Cache will be operational for SYSCODE space.
//! Reads from flash in USERCODE space will be uncached.
//!
//! In \ref VIMS_MODE_OFF the cache RAM is off to conserve power.
//!
//! \note The VIMS must be invalidated when switching mode.
//! This is done by setting VIMS_MODE_OFF before setting any new mode.
//! This is automatically handled in this function.
//!
//! \note It is highly recommended that the VIMS is put in disabled mode before
//! \b writing to flash, since the cache will not be updated nor invalidated
//! by flash writes. The line buffers should also be disabled when updating the
//! flash.
//!
//! \note Access from System Bus is never cached. Only access through ICODE
//! DCODE bus from the System CPU is cached.
//!
//! \param ui32Base is the base address of the VIMS.
//! \param ui32NewMode is the new operational mode:
//! - \ref VIMS_MODE_DISABLED (GPRAM enabled)
//! - \ref VIMS_MODE_ENABLED (CACHE mode)
//! - \ref VIMS_MODE_OFF
//! \param blocking shall be set to TRUE if further code execution shall be
//! blocked (delayed) until mode change is completed.
//!
//! \return None
//!
//! \sa \ref VIMSModeSet() and \ref VIMSModeGet()
//
//*****************************************************************************
extern void VIMSModeSafeSet( uint32_t ui32Base ,
uint32_t ui32NewMode ,
bool blocking );
//*****************************************************************************
//
//! \brief Disable VIMS linebuffers.
//!
//! Linebuffers should only be disabled when attempting to update the flash, to
//! ensure that the content of the buffers is not stale. As soon as flash is
//! updated the linebuffers should be reenabled. Failing to enable
//! will have a performance impact.
//!
//! \param ui32Base is the base address of the VIMS.
//!
//! \return None.
//
//*****************************************************************************
__STATIC_INLINE void
VIMSLineBufDisable(uint32_t ui32Base)
{
// Disable line buffers
HWREG(ui32Base + VIMS_O_CTL) |= VIMS_CTL_IDCODE_LB_DIS_M |
VIMS_CTL_SYSBUS_LB_DIS_M;
}
//*****************************************************************************
//
//! \brief Enable VIMS linebuffers.
//!
//! Linebuffers should only be disabled when attempting to update the flash, to
//! ensure that the content of the buffers is not stale. As soon as flash is
//! updated the linebuffers should be reenabled. Failing to enable
//! will have a performance impact.
//!
//! \param ui32Base is the base address of the VIMS.
//!
//! \return None.
//
//*****************************************************************************
__STATIC_INLINE void
VIMSLineBufEnable(uint32_t ui32Base)
{
// Enable linebuffers
HWREG(ui32Base + VIMS_O_CTL) &= ~(VIMS_CTL_IDCODE_LB_DIS_M |
VIMS_CTL_SYSBUS_LB_DIS_M);
}
//*****************************************************************************
//
// Support for DriverLib in ROM:
// Redirect to implementation in ROM when available.
//
//*****************************************************************************
#if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
#include "../driverlib/rom.h"
#ifdef ROM_VIMSConfigure
#undef VIMSConfigure
#define VIMSConfigure ROM_VIMSConfigure
#endif
#ifdef ROM_VIMSModeSet
#undef VIMSModeSet
#define VIMSModeSet ROM_VIMSModeSet
#endif
#ifdef ROM_VIMSModeGet
#undef VIMSModeGet
#define VIMSModeGet ROM_VIMSModeGet
#endif
#ifdef ROM_VIMSModeSafeSet
#undef VIMSModeSafeSet
#define VIMSModeSafeSet ROM_VIMSModeSafeSet
#endif
#endif
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __VIMS_H__
//*****************************************************************************
//
//! Close the Doxygen group.
//! @}
//! @}
//
//*****************************************************************************