summaryrefslogtreecommitdiffstats
path: root/target/linux/realtek/files/include/asm-mips/rtl865x/rtl_types.h
blob: b7376761742ca96396a93c37bdf78677f92f65e9 (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
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
/*
* Copyright c                  Realtek Semiconductor Corporation, 2002  
* All rights reserved.                                                    
* 
* Program : The header file of realtek type definition
* Abstract :                                                           
* Author :              
* $Id: rtl_types.h,v 1.1 2007-12-07 05:52:23 alva_zhang Exp $
* $Log: not supported by cvs2svn $
* Revision 1.1.1.1  2007/08/06 10:04:57  root
* Initial import source to CVS
*
*
*/


#ifndef _RTL_TYPES_H
#define _RTL_TYPES_H

#ifndef RTL865X_OVER_KERNEL
	#undef __KERNEL__
#endif

#ifndef RTL865X_OVER_LINUX
	#undef __linux__
#endif

/*
 * Internal names for basic integral types.  Omit the typedef if
 * not possible for a machine/compiler combination.
 */
#ifdef __linux__
#ifdef __KERNEL__
#include <linux/version.h>
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
#include <linux/config.h>
#endif
#include <linux/ctype.h>
#include <linux/module.h>
#include <linux/string.h>
#endif /*__KERNEL__*/
#endif /*__linux__*/

/* ===============================================================================
		IRAM / DRAM definition
    =============================================================================== */
#undef __DRAM_GEN
#undef __DRAM_FWD
#undef __DRAM_L2_FWD
#undef __DRAM_L34_FWD
#undef __DRAM_EXTDEV
#undef __DRAM_AIRGO
#undef __DRAM_RTKWLAN
#undef __DRAM_CRYPTO
#undef __DRAM_VOIP
#undef __DRAM_TX
#undef __DRAM

#undef __IRAM_GEN
#undef __IRAM_FWD
#undef __IRAM_L2_FWD
#undef __IRAM_L34_FWD
#undef __IRAM_EXTDEV
#undef __IRAM_AIRGO
#undef __IRAM_RTKWLAN
#undef __IRAM_CRYPTO
#undef __IRAM_VOIP
#undef __IRAM_TX
#undef __IRAM

#if defined(__linux__)&&defined(__KERNEL__)&&defined(CONFIG_RTL865X)
	#define __DRAM_GEN			__attribute__  ((section(".dram-gen")))
	#define __DRAM_FWD			__attribute__  ((section(".dram-fwd")))
	#define __DRAM_L2_FWD		__attribute__  ((section(".dram-l2-fwd")))
	#define __DRAM_L34_FWD	__attribute__  ((section(".dram-l34-fwd")))
	#define __DRAM_EXTDEV		__attribute__  ((section(".dram-extdev")))
	#define __DRAM_AIRGO		__attribute__  ((section(".dram-airgo")))
	#define __DRAM_RTKWLAN	__attribute__  ((section(".dram-rtkwlan")))
	#define __DRAM_CRYPTO		__attribute__  ((section(".dram-crypto")))
	#define __DRAM_VOIP			__attribute__  ((section(".dram-voip")))
	#define __DRAM_TX			__attribute__  ((section(".dram-tx")))
	#define __DRAM				__attribute__  ((section(".dram")))

	#define __IRAM_GEN			__attribute__  ((section(".iram-gen")))
	#define __IRAM_FWD			__attribute__  ((section(".iram-fwd")))
	#define __IRAM_L2_FWD		__attribute__  ((section(".iram-l2-fwd")))
	#define __IRAM_L34_FWD		__attribute__  ((section(".iram-l34-fwd")))
	#define __IRAM_EXTDEV		__attribute__  ((section(".iram-extdev")))
	#define __IRAM_AIRGO		__attribute__  ((section(".iram-airgo")))
	#define __IRAM_RTKWLAN		__attribute__  ((section(".iram-rtkwlan")))
	#define __IRAM_CRYPTO		__attribute__  ((section(".iram-crypto")))
	#define __IRAM_VOIP			__attribute__  ((section(".iram-voip")))
	#define __IRAM_TX			__attribute__  ((section(".iram-tx")))
	#define __IRAM				__attribute__  ((section(".iram")))
#else
	#define __DRAM_GEN
	#define __DRAM_FWD
	#define __DRAM_L2_FWD
	#define __DRAM_L34_FWD
	#define __DRAM_EXTDEV
	#define __DRAM_AIRGO
	#define __DRAM_RTKWLAN
	#define __DRAM_CRYPTO
	#define __DRAM_VOIP
	#define __DRAM_TX
	#define __DRAM

	#define __IRAM_GEN
	#define __IRAM_FWD
	#define __IRAM_L2_FWD
	#define __IRAM_L34_FWD
	#define __IRAM_EXTDEV
	#define __IRAM_AIRGO
	#define __IRAM_RTKWLAN
	#define __IRAM_CRYPTO
	#define __IRAM_VOIP
	#define __IRAM_TX
	#define __IRAM
#endif

/* ===============================================================================
		print macro
    =============================================================================== */
#if	defined(__linux__)&&defined(__KERNEL__)

	#define rtlglue_printf	printk

#else	/* defined(__linux__)&&defined(__KERNEL__) */

#ifdef	RTL865X_TEST
	#include <ctype.h>
#endif	/* RTL865X_TEST */

#define rtlglue_printf	printf

#endif	/* defined(__linux__)&&defined(__KERNEL__) */

/* ===============================================================================
		Type definition
    =============================================================================== */

typedef unsigned long long	uint64;
typedef long long		int64;
typedef unsigned int	uint32;
typedef int			int32;
typedef unsigned short	uint16;
typedef short			int16;
typedef unsigned char	uint8;
typedef char			int8;


typedef uint32		memaddr;	
typedef uint32          ipaddr_t;
typedef struct {
    uint16      mac47_32;
    uint16      mac31_16;
    uint16      mac15_0;
} macaddr_t;

#define ETHER_ADDR_LEN				6
typedef struct ether_addr_s {
	uint8 octet[ETHER_ADDR_LEN];
} ether_addr_t;



#ifndef NULL
#define NULL 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif

#ifndef SUCCESS
#define SUCCESS 	0
#endif
#ifndef FAILED
#define FAILED -1
#endif



#define DEBUG_P(args...) while(0);
#ifndef OK
#define OK		0
#endif
#ifndef NOT_OK
#define NOT_OK  1
#endif

#ifndef CLEARBITS
#define CLEARBITS(a,b)	((a) &= ~(b))
#endif

#ifndef SETBITS
#define SETBITS(a,b)		((a) |= (b))
#endif

#ifndef ISSET
#define ISSET(a,b)		(((a) & (b))!=0)
#endif

#ifndef ISCLEARED
#define ISCLEARED(a,b)	(((a) & (b))==0)
#endif

#ifndef max
#define max(a,b)  (((a) > (b)) ? (a) : (b))
#endif			   /* max */

#ifndef min
#define min(a,b)  (((a) < (b)) ? (a) : (b))
#endif			   /* min */

//round down x to multiple of y.  Ex: ROUNDDOWN(20, 7)=14
#ifndef ROUNDDOWN
#define	ROUNDDOWN(x, y)	(((x)/(y))*(y))
#endif

//round up x to multiple of y. Ex: ROUNDUP(11, 7) = 14
#ifndef ROUNDUP
#define	ROUNDUP(x, y)	((((x)+((y)-1))/(y))*(y))  /* to any y */
#endif

#ifndef ROUNDUP2
#define	ROUNDUP2(x, y)	(((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
#endif

#ifndef ROUNDUP4
#define	ROUNDUP4(x)		((1+(((x)-1)>>2))<<2)
#endif

#ifndef IS4BYTEALIGNED
#define IS4BYTEALIGNED(x)	 ((((x) & 0x3)==0)? 1 : 0)
#endif

#ifndef __offsetof
#define __offsetof(type, field) ((unsigned long)(&((type *)0)->field))
#endif

#ifndef offsetof
#define offsetof(type, field) __offsetof(type, field)
#endif

#ifndef RTL_PROC_CHECK
#define RTL_PROC_CHECK(expr, success) \
	do {\
			int __retval; \
			if ((__retval = (expr)) != (success))\
			{\
				rtlglue_printf("ERROR >>> [%s]:[%d] failed -- return value: %d\n", __FUNCTION__,__LINE__, __retval);\
				return __retval; \
			}\
		}while(0)
#endif

#ifndef RTL_STREAM_SAME
#define RTL_STREAM_SAME(s1, s2) \
	((strlen(s1) == strlen(s2)) && (strcmp(s1, s2) == 0))
#endif

#define ASSERT_ISR(x) if(!(x)) {while(1);}
#define RTL_STATIC_INLINE   static __inline__

#define ASSERT_CSP(x) if (!(x)) {rtlglue_printf("\nAssert Fail: %s %d", __FILE__, __LINE__); while(1);}

#if defined(RTL865X_TEST) || defined(RTL865X_MODEL_USER)
/* Only model code needs to define the following code. */
typedef struct { } spinlock_t;
typedef uint8 u8;
typedef uint16 u16;
typedef uint32 u32;
#endif
 
#if defined(DRTL_TBLDRV)||defined(RTL865X_TEST)
//only ROME driver and module test code need to include this header file
#include "rtl_glue.h"
#endif

#if defined(RTL865X_TEST)||defined(RTL865X_MODEL_USER)
#define UNCACHE_MASK		0
#define UNCACHE(addr)		(addr)
#define CACHED(addr)			((uint32)(addr))
#else
#define UNCACHE_MASK		0x20000000
#define UNCACHE(addr)		((UNCACHE_MASK)|(uint32)(addr))
#define CACHED(addr)			((uint32)(addr) & ~(UNCACHE_MASK))
#endif


#endif