1
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3
File: oct6100_miscellaneous_priv.h
5
Copyright (c) 2001-2006 Octasic Inc.
9
File containing all private defines, macros, structures and prototypes
10
pertaining to the file oct6100_miscellaneous.c. All elements defined in
11
this file are for private usage of the API.
13
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is
14
free software; you can redistribute it and/or modify it under the terms of
15
the GNU General Public License as published by the Free Software Foundation;
16
either version 2 of the License, or (at your option) any later version.
18
The OCT6100 GPL API is distributed in the hope that it will be useful, but
19
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23
You should have received a copy of the GNU General Public License
24
along with the OCT6100 GPL API; if not, write to the Free Software
25
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27
$Octasic_Release: OCT612xAPI-01.00-PR43 $
29
$Octasic_Revision: 20 $
31
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
33
#ifndef __OCT6100_MISCELLANEOUS_PRIV_H__
34
#define __OCT6100_MISCELLANEOUS_PRIV_H__
36
/***************************** INCLUDE FILES *******************************/
39
/***************************** DEFINES *************************************/
42
/*---------------------------------------------------------------------------*\
43
Macros used to shell the user function calls. These macros are used to
44
assert that the user does not change any of the members of the function's
45
parameter structure, as required and indicated in the API specification.
46
Ofcourse, these macros make the code heavier and thus slower. That is why
47
there is a compile option for disabling the extra checking. These can be
48
very helpful tools in debugging.
49
\*---------------------------------------------------------------------------*/
51
#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK
52
#define mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) \
54
PVOID _pProcessContext; \
55
UINT32 _ulUserChipId; \
56
UINT32 _ulWriteAddress; \
57
UINT16 _usWriteData; \
59
/* Store the data that is to be passed to the user. */ \
60
_pProcessContext = WriteParams.pProcessContext; \
61
_ulUserChipId = WriteParams.ulUserChipId; \
62
_ulWriteAddress = WriteParams.ulWriteAddress; \
63
_usWriteData = WriteParams.usWriteData; \
65
/* Call user function. */ \
66
ulResult = Oct6100UserDriverWriteApi( &WriteParams ); \
68
/* Check if user changed members of function's parameter structure. */ \
69
if ( WriteParams.pProcessContext != _pProcessContext || \
70
WriteParams.ulUserChipId != _ulUserChipId || \
71
WriteParams.ulWriteAddress != _ulWriteAddress || \
72
WriteParams.ulWriteAddress != _ulWriteAddress || \
73
WriteParams.usWriteData != _usWriteData ) \
74
ulResult = cOCT6100_ERR_FATAL_DRIVER_WRITE_API; \
77
#define mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ) \
78
ulResult = Oct6100UserDriverWriteApi( &WriteParams );
79
#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */
82
#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK
83
#define mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult ) \
85
PVOID _pProcessContext; \
86
UINT32 _ulUserChipId; \
87
UINT32 _ulWriteAddress; \
88
UINT16 _usWriteData; \
89
UINT32 _ulWriteLength; \
91
/* Store the data that is to be passed to the user. */ \
92
_pProcessContext = SmearParams.pProcessContext; \
93
_ulUserChipId = SmearParams.ulUserChipId; \
94
_ulWriteAddress = SmearParams.ulWriteAddress; \
95
_usWriteData = SmearParams.usWriteData; \
96
_ulWriteLength = SmearParams.ulWriteLength; \
98
/* Call user function. */ \
99
ulResult = Oct6100UserDriverWriteSmearApi( &SmearParams ); \
101
/* Check if user changed members of function's paraeter structure. */ \
102
if ( SmearParams.pProcessContext != _pProcessContext || \
103
SmearParams.ulUserChipId != _ulUserChipId || \
104
SmearParams.usWriteData != _usWriteData || \
105
SmearParams.ulWriteLength != _ulWriteLength) \
106
ulResult = cOCT6100_ERR_FATAL_DRIVER_WRITE_SMEAR_API; \
109
#define mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult ) \
110
ulResult = Oct6100UserDriverWriteSmearApi( &SmearParams );
111
#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */
114
#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK
115
#define mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult ) \
117
PVOID _pProcessContext; \
118
UINT32 _ulUserChipId; \
119
UINT32 _ulWriteAddress; \
120
PUINT16 _pusWriteData; \
121
UINT32 _ulWriteLength; \
123
/* Store the data that is to be passed to the user. */ \
124
_pProcessContext = BurstParams.pProcessContext; \
125
_ulUserChipId = BurstParams.ulUserChipId; \
126
_ulWriteAddress = BurstParams.ulWriteAddress; \
127
_pusWriteData = BurstParams.pusWriteData; \
128
_ulWriteLength = BurstParams.ulWriteLength; \
130
/* Call user function. */ \
131
ulResult = Oct6100UserDriverWriteBurstApi( &BurstParams ); \
133
/* Check if user changed members of function's parameter structure. */ \
134
if ( BurstParams.pProcessContext != _pProcessContext || \
135
BurstParams.ulUserChipId != _ulUserChipId || \
136
BurstParams.ulWriteAddress != _ulWriteAddress || \
137
BurstParams.pusWriteData != _pusWriteData || \
138
BurstParams.ulWriteLength != _ulWriteLength ) \
139
ulResult = cOCT6100_ERR_FATAL_DRIVER_WRITE_BURST_API; \
142
#define mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult ) \
143
ulResult = Oct6100UserDriverWriteBurstApi( &BurstParams );
144
#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */
147
#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK
148
#define mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) \
150
PVOID _pProcessContext; \
151
UINT32 _ulUserChipId; \
152
UINT32 _ulReadAddress; \
153
PUINT16 _pusReadData; \
155
/* Store the data that is to be passed to the user. */ \
156
_pProcessContext = ReadParams.pProcessContext; \
157
_ulUserChipId = ReadParams.ulUserChipId; \
158
_ulReadAddress = ReadParams.ulReadAddress; \
159
_pusReadData = ReadParams.pusReadData; \
161
/* Call user function. */ \
162
ulResult = Oct6100UserDriverReadApi( &ReadParams ); \
164
/* Check if user changed members of function's parameter structure. */ \
165
if ( ReadParams.pProcessContext != _pProcessContext || \
166
ReadParams.ulUserChipId != _ulUserChipId || \
167
ReadParams.ulReadAddress != _ulReadAddress || \
168
ReadParams.pusReadData != _pusReadData ) \
169
ulResult = cOCT6100_ERR_FATAL_DRIVER_READ_API; \
172
#define mOCT6100_DRIVER_READ_API( ReadParams, ulResult ) \
173
ulResult = Oct6100UserDriverReadApi( &ReadParams );
174
#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */
177
#ifndef cOCT6100_REMOVE_USER_FUNCTION_CHECK
178
#define mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult ) \
180
PVOID _pProcessContext; \
181
UINT32 _ulUserChipId; \
182
UINT32 _ulReadAddress; \
183
PUINT16 _pusReadData; \
184
UINT32 _ulReadLength; \
186
/* Store the data that is to be passed to the user. */ \
187
_pProcessContext = BurstParams.pProcessContext; \
188
_ulUserChipId = BurstParams.ulUserChipId; \
189
_ulReadAddress = BurstParams.ulReadAddress; \
190
_pusReadData = BurstParams.pusReadData; \
191
_ulReadLength = BurstParams.ulReadLength; \
193
/* Call user function. */ \
194
ulResult = Oct6100UserDriverReadBurstApi( &BurstParams ); \
196
/* Check if user changed members of function's parameter structure. */ \
197
if ( BurstParams.pProcessContext != _pProcessContext || \
198
BurstParams.ulUserChipId != _ulUserChipId || \
199
BurstParams.ulReadAddress != _ulReadAddress || \
200
BurstParams.pusReadData != _pusReadData || \
201
BurstParams.ulReadLength != _ulReadLength ) \
202
ulResult = cOCT6100_ERR_FATAL_DRIVER_READ_BURST_API; \
205
#define mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult ) \
206
ulResult = Oct6100UserDriverReadBurstApi( &BurstParams );
207
#endif /* cOCT6100_REMOVE_USER_FUNCTION_CHECK */
209
#define mOCT6100_ASSIGN_USER_READ_WRITE_OBJ( f_pApiInst, Params )
212
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
214
Function: mOCT6100_RETRIEVE_NLP_CONF_DWORD
216
Description: This function is used by the API to store on a per channel basis
217
the various confguration DWORD from the device. The API performs
218
less read to the chip that way since it is always in synch
221
-------------------------------------------------------------------------------
222
| Argument | Description
223
-------------------------------------------------------------------------------
225
IN f_pApiInst Pointer to API instance. This memory is used to keep
226
the present state of the chip and all its resources.
227
IN f_pChanEntry Pointer to an API channel structure..
228
IN f_ulAddress Address that needs to be modified..
229
IN f_pulConfigDword Pointer to the content stored in the API located at the
232
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
233
#define mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInst, f_pChanEntry, f_ulAddress, f_pulConfigDword, f_ulResult ) \
235
UINT32 _ulFirstEmptyIndex = 0xFFFFFFFF; \
238
f_ulResult = cOCT6100_ERR_FATAL_8E; \
239
(*f_pulConfigDword) = cOCT6100_INVALID_VALUE; \
241
/* Search for the Dword.*/ \
242
for ( _i = 0; _i < cOCT6100_MAX_NLP_CONF_DWORD; _i++ ) \
244
if ( ( _ulFirstEmptyIndex == 0xFFFFFFFF ) && ( f_pChanEntry->aulNlpConfDword[ _i ][ 0 ] == 0x0 ) ) \
245
_ulFirstEmptyIndex = _i; \
247
if ( f_pChanEntry->aulNlpConfDword[ _i ][ 0 ] == f_ulAddress ) \
249
/* We found the matching Dword.*/ \
250
(*f_pulConfigDword) = f_pChanEntry->aulNlpConfDword[ _i ][ 1 ]; \
251
f_ulResult = cOCT6100_ERR_OK; \
255
if ( ( _i == cOCT6100_MAX_NLP_CONF_DWORD ) && ( _ulFirstEmptyIndex == 0xFFFFFFFF ) ) \
257
/* Nothing to do here, a fatal error occured, no memory was left. */ \
261
if ( f_ulResult != cOCT6100_ERR_OK ) \
263
tOCT6100_READ_PARAMS _ReadParams; \
264
UINT16 _usReadData; \
266
/* We did not found any entry, let's create a new entry.*/ \
267
f_pChanEntry->aulNlpConfDword[ _ulFirstEmptyIndex ][ 0 ] = f_ulAddress; \
269
_ReadParams.pProcessContext = f_pApiInst->pProcessContext; \
270
mOCT6100_ASSIGN_USER_READ_WRITE_OBJ( f_pApiInst, _ReadParams ); \
271
_ReadParams.ulUserChipId = f_pApiInst->pSharedInfo->ChipConfig.ulUserChipId; \
272
_ReadParams.pusReadData = &_usReadData; \
274
/* Read the first 16 bits.*/ \
275
_ReadParams.ulReadAddress = f_ulAddress; \
276
mOCT6100_DRIVER_READ_API( _ReadParams, f_ulResult ); \
277
if ( f_ulResult == cOCT6100_ERR_OK ) \
280
(*f_pulConfigDword) = _usReadData << 16; \
282
/* Read the last 16 bits .*/ \
283
_ReadParams.ulReadAddress += 2; \
284
mOCT6100_DRIVER_READ_API( _ReadParams, f_ulResult ); \
285
if ( f_ulResult == cOCT6100_ERR_OK ) \
288
(*f_pulConfigDword) |= _usReadData; \
289
f_ulResult = cOCT6100_ERR_OK; \
297
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
299
Function: mOCT6100_SAVE_NLP_CONF_DWORD
301
Description: This function stores a configuration Dword within an API channel
302
structure and then writes it into the chip.
304
-------------------------------------------------------------------------------
305
| Argument | Description
306
-------------------------------------------------------------------------------
308
IN f_pApiInst Pointer to API instance. This memory is used to keep
309
the present state of the chip and all its resources.
310
IN f_pChanEntry Pointer to an API channel structure..
311
IN f_ulAddress Address that needs to be modified..
312
IN f_pulConfigDword content to be stored in the API located at the
315
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
316
#define mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInst, f_pChanEntry, f_ulAddress, f_ulConfigDword, f_ulResult ) \
319
UINT32 _ulLastValue = 0x0; \
321
/* Search for the Dword.*/ \
322
for ( _i = 0; _i < cOCT6100_MAX_NLP_CONF_DWORD; _i++ ) \
324
if ( f_pChanEntry->aulNlpConfDword[ _i ][ 0 ] == f_ulAddress ) \
326
/* We found the matching Dword.*/ \
327
_ulLastValue = f_pChanEntry->aulNlpConfDword[ _i ][ 1 ]; \
328
f_pChanEntry->aulNlpConfDword[ _i ][ 1 ] = f_ulConfigDword; \
333
if ( _i == cOCT6100_MAX_NLP_CONF_DWORD ) \
335
f_ulResult = cOCT6100_ERR_FATAL_8F; \
339
/* Write the config DWORD. */ \
340
tOCT6100_WRITE_PARAMS _WriteParams; \
342
_WriteParams.pProcessContext = f_pApiInst->pProcessContext; \
343
mOCT6100_ASSIGN_USER_READ_WRITE_OBJ( f_pApiInst, _WriteParams ) \
344
_WriteParams.ulUserChipId = f_pApiInst->pSharedInfo->ChipConfig.ulUserChipId; \
346
/* Check if it is worth calling the user function. */ \
347
if ( ( f_ulConfigDword & 0xFFFF0000 ) != ( _ulLastValue & 0xFFFF0000 ) ) \
349
/* Write the first 16 bits. */ \
350
_WriteParams.ulWriteAddress = f_ulAddress; \
351
_WriteParams.usWriteData = (UINT16)((f_ulConfigDword >> 16) & 0xFFFF); \
352
mOCT6100_DRIVER_WRITE_API( _WriteParams, f_ulResult ); \
356
f_ulResult = cOCT6100_ERR_OK; \
359
if ( f_ulResult == cOCT6100_ERR_OK ) \
361
if ( ( f_ulConfigDword & 0x0000FFFF ) != ( _ulLastValue & 0x0000FFFF ) ) \
363
/* Write the last word. */ \
364
_WriteParams.ulWriteAddress = f_ulAddress + 2; \
365
_WriteParams.usWriteData = (UINT16)(f_ulConfigDword & 0xFFFF); \
366
mOCT6100_DRIVER_WRITE_API( _WriteParams, f_ulResult ); \
373
#define mOCT6100_CREATE_FEATURE_MASK( f_ulFieldSize, f_ulFieldBitOffset, f_pulFieldMask ) \
375
(*f_pulFieldMask) = ( 1 << f_ulFieldSize ); \
376
(*f_pulFieldMask) --; \
377
(*f_pulFieldMask) <<= f_ulFieldBitOffset; \
381
/***************************** TYPES ***************************************/
384
/************************** FUNCTION PROTOTYPES *****************************/
386
UINT32 Oct6100ApiWaitForTime(
387
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
388
IN UINT32 f_aulWaitTime[ 2 ] );
390
UINT32 Oct6100ApiWaitForPcRegisterBit(
391
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
392
IN UINT32 f_ulPcRegAdd,
393
IN UINT32 f_ulPcBitNum,
395
IN UINT32 f_ulTimeoutUs,
396
OUT PBOOL f_pfBitEqual );
398
UINT32 Oct6100ApiWriteDword(
399
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
400
IN UINT32 f_ulAddress,
401
IN UINT32 f_ulWriteData );
403
UINT32 Oct6100ApiReadDword(
404
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
405
IN UINT32 f_ulAddress,
406
OUT PUINT32 f_pulReadData );
408
VOID Oct6100ApiCreateFeatureMask(
409
IN UINT32 f_ulFieldSize,
410
IN UINT32 f_ulFieldBitOffset,
411
OUT PUINT32 f_pulFieldMask );
413
PUINT8 Oct6100ApiStrStr(
414
IN PUINT8 f_pszSource,
415
IN PUINT8 f_pszString,
416
IN PUINT8 f_pszLastCharPtr );
418
UINT32 Oct6100ApiStrLen(
419
IN PUINT8 f_pszString );
421
UINT32 Oct6100ApiAsciiToHex(
422
IN UINT8 f_chCharacter,
423
IN PUINT32 f_pulValue );
425
UINT8 Oct6100ApiHexToAscii(
426
IN UINT32 f_ulNumber );
428
UINT32 Oct6100ApiRand(
429
IN UINT32 f_ulRange );
431
#endif /* __OCT6100_MISCELLANEOUS_PRIV_H__ */