http://www.usr.com/support/gpl/USR9107_release1.1.tar.gz
[bcm963xx.git] / bcmdrivers / opensource / include / bcm963xx / bcmtypes.h
1 /*
2 <:copyright-gpl 
3  Copyright 2002 Broadcom Corp. All Rights Reserved. 
4  
5  This program is free software; you can distribute it and/or modify it 
6  under the terms of the GNU General Public License (Version 2) as 
7  published by the Free Software Foundation. 
8  
9  This program is distributed in the hope it will be useful, but WITHOUT 
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
11  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
12  for more details. 
13  
14  You should have received a copy of the GNU General Public License along 
15  with this program; if not, write to the Free Software Foundation, Inc., 
16  59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 
17 :>
18 */
19
20 //
21 // bcmtypes.h - misc useful typedefs
22 //
23 #ifndef BCMTYPES_H
24 #define BCMTYPES_H
25
26 // These are also defined in typedefs.h in the application area, so I need to
27 // protect against re-definition.
28
29 #ifndef _TYPEDEFS_H_
30 typedef unsigned char   uint8;
31 typedef unsigned short  uint16;
32 typedef unsigned long   uint32;
33 typedef signed char     int8;
34 typedef signed short    int16;
35 typedef signed long     int32;
36 #if !defined(__cplusplus)
37 typedef int     bool;
38 #endif
39 #endif
40
41 typedef unsigned char   byte;
42 // typedef unsigned long   sem_t;
43
44 typedef unsigned long   HANDLE,*PULONG,DWORD,*PDWORD;
45 typedef signed long     LONG,*PLONG;
46
47 typedef unsigned int    *PUINT;
48 typedef signed int      INT;
49
50 typedef unsigned short  *PUSHORT;
51 typedef signed short    SHORT,*PSHORT;
52 typedef unsigned short  WORD,*PWORD;
53
54 typedef unsigned char   *PUCHAR;
55 typedef signed char     *PCHAR;
56
57 typedef void            *PVOID;
58
59 typedef unsigned char   BOOLEAN, *PBOOL, *PBOOLEAN;
60
61 typedef unsigned char   BYTE,*PBYTE;
62
63 //#ifndef __GNUC__
64 //The following has been defined in Vxworks internally: vxTypesOld.h
65 //redefine under vxworks will cause error
66 typedef signed int      *PINT;
67
68 typedef signed char     INT8;
69 typedef signed short    INT16;
70 typedef signed long     INT32;
71
72 typedef unsigned char   UINT8;
73 typedef unsigned short  UINT16;
74 typedef unsigned long   UINT32;
75
76 typedef unsigned char   UCHAR;
77 typedef unsigned short  USHORT;
78 typedef unsigned int    UINT;
79 typedef unsigned long   ULONG;
80
81 typedef void            VOID;
82 typedef unsigned char   BOOL;
83
84 //#endif  /* __GNUC__ */
85
86
87 // These are also defined in typedefs.h in the application area, so I need to
88 // protect against re-definition.
89 #ifndef TYPEDEFS_H
90
91 // Maximum and minimum values for a signed 16 bit integer.
92 #define MAX_INT16 32767
93 #define MIN_INT16 -32768
94
95 // Useful for true/false return values.  This uses the
96 // Taligent notation (k for constant).
97 typedef enum
98 {
99     kFalse = 0,
100     kTrue = 1
101 } Bool;
102
103 #endif
104
105 /* macros to protect against unaligned accesses */
106
107 #if 0
108 /* first arg is an address, second is a value */
109 #define PUT16( a, d ) {                 \
110   *((byte *)a) = (byte)((d)>>8);        \
111   *(((byte *)a)+1) = (byte)(d);         \
112 }
113
114 #define PUT32( a, d ) {                 \
115   *((byte *)a) = (byte)((d)>>24);       \
116   *(((byte *)a)+1) = (byte)((d)>>16);   \
117   *(((byte *)a)+2) = (byte)((d)>>8);    \
118   *(((byte *)a)+3) = (byte)(d);         \
119 }
120
121 /* first arg is an address, returns a value */
122 #define GET16( a ) (                    \
123   (*((byte *)a) << 8) |                 \
124   (*(((byte *)a)+1))                    \
125 )
126
127 #define GET32( a ) (                    \
128   (*((byte *)a) << 24)     |            \
129   (*(((byte *)a)+1) << 16) |            \
130   (*(((byte *)a)+2) << 8)  |            \
131   (*(((byte *)a)+3))                    \
132 )
133 #endif
134
135 #ifndef YES
136 #define YES 1
137 #endif
138
139 #ifndef NO
140 #define NO  0
141 #endif
142
143 #ifndef IN
144 #define IN
145 #endif
146
147 #ifndef OUT
148 #define OUT
149 #endif
150
151 #ifndef TRUE
152 #define TRUE 1
153 #endif
154
155 #ifndef FALSE
156 #define FALSE  0
157 #endif
158
159 #define READ32(addr)        (*(volatile UINT32 *)((ULONG)&addr))
160 #define READ16(addr)        (*(volatile UINT16 *)((ULONG)&addr))
161 #define READ8(addr)         (*(volatile UINT8  *)((ULONG)&addr))
162
163 #endif