summaryrefslogtreecommitdiff
path: root/arch/arm/plat-omap/include/syslink/GlobalTypes.h
blob: 6cd959cde9521e1634f8761ce448e242007aa953 (plain)
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
/*
 * GlobalTypes.h
 *
 * Syslink driver support for OMAP Processors.
 *
 * Copyright (C) 2008-2009 Texas Instruments, Inc.
 *
 * This package is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#ifndef __GLOBALTYPES_H
#define __GLOBALTYPES_H

#define  REG volatile

/*
 * Definition: RET_CODE_BASE
 *
 * DESCRIPTION:  Base value for return code offsets
 *
 *
 */
#define RET_CODE_BASE        0

/*
 * TYPE: ReturnCode_t
 *
 * DESCRIPTION:  Return codes to be returned by all library functions
 *
 *
 */
enum ReturnCode_label {
RET_OK = 0,
RET_FAIL = -1,
RET_BAD_NULL_PARAM = -2,
RET_PARAM_OUT_OF_RANGE = -3,
RET_INVALID_ID = -4,
RET_EMPTY = -5,
RET_FULL = -6,
RET_TIMEOUT = -7,
RET_INVALID_OPERATION = -8,
/* Add new error codes at end of above list */
RET_NUM_RET_CODES     /* this should ALWAYS be LAST entry */
};



/*
 * MACRO: RD_MEM_32_VOLATILE, WR_MEM_32_VOLATILE
 *
 * DESCRIPTION:  32 bit register access macros
 *
 *
 */
#define RD_MEM_32_VOLATILE(addr) \
((unsigned long)(*((REG unsigned long *)(addr))))

#define WR_MEM_32_VOLATILE(addr, data) \
(*((REG unsigned long *)(addr)) = (unsigned long)(data))




#ifdef CHECK_INPUT_PARAMS
/*
 * MACRO: CHECK_INPUT_PARAMS
 *
 * DESCRIPTION:  Checks an input code and returns a specified value if code is
 *               invalid value, also writes spy value if error found.
 *
 * NOTE:         Can be disabled to save HW cycles.
 *
 *
 */
#define CHECK_INPUT_PARAM(actualValue, invalidValue,  \
returnCodeIfMismatch, spyCodeIfMisMatch) do {\
	if ((invalidValue) == (actualValue)) {\
		RES_Set((spyCodeIfMisMatch));\
		return returnCodeIfMismatch; \
	} \
} while (0)

/*
 * MACRO: CHECK_INPUT_RANGE
 *
 * DESCRIPTION:  Checks an input value and returns a specified value if not in
 *               specified range, also writes spy value if error found.
 *
* NOTE:         Can be disabled to save HW cycles.
 *
 *
 */
#define CHECK_INPUT_RANGE(actualValue, minValidValue, maxValidValue, \
returnCodeIfMismatch, spyCodeIfMisMatch) do {\
	if (((actualValue) < (minValidValue)) || \
		((actualValue) > (maxValidValue))) {\
		RES_Set((spyCodeIfMisMatch));\
		return returnCodeIfMismatch; \
	} \
} while (0)

/*
 * MACRO: CHECK_INPUT_RANGE_MIN0
 *
 * DESCRIPTION:  Checks an input value and returns a
 * specified value if not in
 * specified range, also writes spy value if error found.
 * The minimum
 * value is 0.
 *
 * NOTE:         Can be disabled to save HW cycles.
 *
 *
 */
#define CHECK_INPUT_RANGE_MIN0(actualValue, maxValidValue, \
returnCodeIfMismatch, spyCodeIfMisMatch) do {\
	if ((actualValue) > (maxValidValue)) {\
		RES_Set((spyCodeIfMisMatch));\
		return returnCodeIfMismatch; \
	} \
} while (0)

#else

#define CHECK_INPUT_PARAM(actualValue, invalidValue, returnCodeIfMismatch,\
spyCodeIfMisMatch)

#define CHECK_INPUT_PARAM_NO_SPY(actualValue, invalidValue, \
returnCodeIfMismatch)

#define CHECK_INPUT_RANGE(actualValue, minValidValue, maxValidValue, \
returnCodeIfMismatch, spyCodeIfMisMatch)

#define CHECK_INPUT_RANGE_NO_SPY(actualValue, minValidValue , \
maxValidValue, returnCodeIfMismatch)

#define CHECK_INPUT_RANGE_MIN0(actualValue, maxValidValue, \
returnCodeIfMismatch, spyCodeIfMisMatch)

#define CHECK_INPUT_RANGE_NO_SPY_MIN0(actualValue, \
maxValidValue, returnCodeIfMismatch)

#endif

#ifdef __cplusplus
}
#endif
#endif	/* __GLOBALTYPES_H */