2 Copyright 2007-2015 Broadcom Corporation
4 <:label-BRCM:2015:DUAL/GPL:standard
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2, as published by
8 the Free Software Foundation (the "GPL").
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
16 A copy of the GPL is available at http://www.broadcom.com/licenses/GPLv2.php, or by
17 writing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
24 // bcmtypes.h - misc useful typedefs
31 // These are also defined in typedefs.h in the application area, so I need to
32 // protect against re-definition.
36 typedef unsigned char uint8
;
37 typedef unsigned short uint16
;
38 typedef unsigned int uint32
;
39 typedef unsigned long long uint64
;
40 typedef signed char int8
;
41 typedef signed short int16
;
42 typedef signed int int32
;
43 typedef signed long long int64
;
44 typedef unsigned long BcmHandle
;
46 #if !defined(__cplusplus) && !defined(__KERNEL__) && !defined(_LINUX_TYPES_H) && !defined(_LINUX_IF_H) && !defined(_ATF_)
52 typedef unsigned char byte
;
54 typedef unsigned long HANDLE
,*PULONG
;
55 typedef int DWORD
,*PDWORD
;
57 typedef signed long LONG
,*PLONG
;
60 typedef unsigned int *PUINT
;
61 typedef signed int INT
;
63 typedef unsigned short *PUSHORT
;
64 typedef signed short SHORT
,*PSHORT
;
65 typedef unsigned short WORD
,*PWORD
;
67 typedef unsigned char *PUCHAR
;
68 typedef signed char *PCHAR
;
72 typedef unsigned char BOOLEAN
, *PBOOL
, *PBOOLEAN
;
74 typedef unsigned char BYTE
,*PBYTE
;
76 typedef signed int *PINT
;
78 #ifndef NUMBER_TYPES_ALREADY_DEFINED
79 #define NUMBER_TYPES_ALREADY_DEFINED
80 typedef signed char INT8
;
81 typedef signed char SINT8
;
82 typedef signed short INT16
;
83 typedef signed short SINT16
;
84 typedef signed int INT32
;
85 typedef signed int sint32
;
86 typedef signed int SINT32
;
87 typedef signed long long SINT64
;
89 typedef unsigned char UINT8
;
90 typedef unsigned short UINT16
;
91 typedef unsigned int UINT32
;
92 typedef unsigned long long UINT64
;
95 #ifndef BOOL_TYPE_ALREADY_DEFINED
96 #define BOOL_TYPE_ALREADY_DEFINED
97 typedef unsigned char UBOOL8
;
100 #ifndef BASE_TYPE_ALREADY_DEFINED
101 #define BASE_TYPE_ALREADY_DEFINED
102 typedef unsigned char UCHAR
;
103 typedef unsigned short USHORT
;
104 typedef unsigned int UINT
;
105 typedef unsigned long ULONG
;
109 typedef unsigned char BOOL
;
111 // These are also defined in typedefs.h in the application area, so I need to
112 // protect against re-definition.
115 // Maximum and minimum values for a signed 16 bit integer.
116 #define MAX_INT16 32767
117 #define MIN_INT16 -32768
119 // Useful for true/false return values. This uses the
120 // Taligent notation (k for constant).
137 #define READ32(addr) (*(volatile UINT32 *)((ULONG)&addr))
138 #define READ16(addr) (*(volatile UINT16 *)((ULONG)&addr))
139 #define READ8(addr) (*(volatile UINT8 *)((ULONG)&addr))
141 typedef unsigned long long uint64_aligned
__attribute__((aligned(8)));
142 typedef signed long long int64_aligned
__attribute__((aligned(8)));
144 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
145 #define BCM_IOC_PTR(ptr_t, ptr) union { ptr_t ptr; uint64_aligned ptr##64; }
146 #define BCM_IOC_PTR_ZERO_EXT(ptr) if (is_compat_task()) ((ptr##64) = (uint64_aligned)(uint32_t)(ptr##64))
148 #define BCM_IOC_PTR(ptr_t, ptr) ptr_t ptr;
149 #define BCM_IOC_PTR_ZERO_EXT(ptr)
152 /*Example usage of above types/macro to a create 32/64-bit compatible ioctl message:
155 BCM_IOC_PTR(void*, exPtr);
156 uint32 exWord; /.Never use long. Always use (u)int32./
157 uint64_aligned ex64bitValue; /.Never use long long. Always use (u)int64_aligned../