# BRCM_VERSION=3
[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,WORD,*PWORD;
52
53 typedef unsigned char   *PUCHAR;
54 typedef signed char     *PCHAR;
55
56 typedef void            *PVOID;
57
58 typedef unsigned char   BOOLEAN, *PBOOL, *PBOOLEAN;
59
60 typedef unsigned char   BYTE,*PBYTE;
61
62 //#ifndef __GNUC__
63 //The following has been defined in Vxworks internally: vxTypesOld.h
64 //redefine under vxworks will cause error
65 typedef signed int      *PINT;
66
67 typedef signed char     INT8;
68 typedef signed short    INT16;
69 typedef signed long     INT32;
70
71 typedef unsigned char   UINT8;
72 typedef unsigned short  UINT16;
73 typedef unsigned long   UINT32;
74
75 typedef unsigned char   UCHAR;
76 typedef unsigned short  USHORT;
77 typedef unsigned int    UINT;
78 typedef unsigned long   ULONG;
79
80 typedef void            VOID;
81 typedef unsigned char   BOOL;
82
83 //#endif  /* __GNUC__ */
84
85
86 // These are also defined in typedefs.h in the application area, so I need to
87 // protect against re-definition.
88 #ifndef TYPEDEFS_H
89
90 // Maximum and minimum values for a signed 16 bit integer.
91 #define MAX_INT16 32767
92 #define MIN_INT16 -32768
93
94 // Useful for true/false return values.  This uses the
95 // Taligent notation (k for constant).
96 typedef enum
97 {
98     kFalse = 0,
99     kTrue = 1
100 } Bool;
101
102 #endif
103
104 /* macros to protect against unaligned accesses */
105
106 #if 0
107 /* first arg is an address, second is a value */
108 #define PUT16( a, d ) {                 \
109   *((byte *)a) = (byte)((d)>>8);        \
110   *(((byte *)a)+1) = (byte)(d);         \
111 }
112
113 #define PUT32( a, d ) {                 \
114   *((byte *)a) = (byte)((d)>>24);       \
115   *(((byte *)a)+1) = (byte)((d)>>16);   \
116   *(((byte *)a)+2) = (byte)((d)>>8);    \
117   *(((byte *)a)+3) = (byte)(d);         \
118 }
119
120 /* first arg is an address, returns a value */
121 #define GET16( a ) (                    \
122   (*((byte *)a) << 8) |                 \
123   (*(((byte *)a)+1))                    \
124 )
125
126 #define GET32( a ) (                    \
127   (*((byte *)a) << 24)     |            \
128   (*(((byte *)a)+1) << 16) |            \
129   (*(((byte *)a)+2) << 8)  |            \
130   (*(((byte *)a)+3))                    \
131 )
132 #endif
133
134 #ifndef YES
135 #define YES 1
136 #endif
137
138 #ifndef NO
139 #define NO  0
140 #endif
141
142 #ifndef IN
143 #define IN
144 #endif
145
146 #ifndef OUT
147 #define OUT
148 #endif
149
150 #ifndef TRUE
151 #define TRUE 1
152 #endif
153
154 #ifndef FALSE
155 #define FALSE  0
156 #endif
157
158 #define READ32(addr)        (*(volatile UINT32 *)((ULONG)&addr))
159 #define READ16(addr)        (*(volatile UINT16 *)((ULONG)&addr))
160 #define READ8(addr)         (*(volatile UINT8  *)((ULONG)&addr))
161
162 #endif