Add Broadcom's code for bcm63xx support
[project/bcm63xx/atf.git] / plat / bcm / include / bcm963xx / bcmtypes.h
1 /*
2 Copyright 2007-2015 Broadcom Corporation
3
4 <:label-BRCM:2015:DUAL/GPL:standard
5
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").
9
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.
14
15
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.
19
20 :>
21 */
22
23 //
24 // bcmtypes.h - misc useful typedefs
25 //
26 #ifndef BCMTYPES_H
27 #define BCMTYPES_H
28
29 #ifndef __ASSEMBLER__
30
31 // These are also defined in typedefs.h in the application area, so I need to
32 // protect against re-definition.
33
34 #ifndef _TYPEDEFS_H_
35
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;
45
46 #if !defined(__cplusplus) && !defined(__KERNEL__) && !defined(_LINUX_TYPES_H) && !defined(_LINUX_IF_H) && !defined(_ATF_)
47 typedef int bool;
48 #endif
49
50 #endif
51
52 typedef unsigned char byte;
53
54 typedef unsigned long HANDLE,*PULONG;
55 typedef int DWORD,*PDWORD;
56 #ifndef LONG
57 typedef signed long LONG,*PLONG;
58 #endif
59
60 typedef unsigned int *PUINT;
61 typedef signed int INT;
62
63 typedef unsigned short *PUSHORT;
64 typedef signed short SHORT,*PSHORT;
65 typedef unsigned short WORD,*PWORD;
66
67 typedef unsigned char *PUCHAR;
68 typedef signed char *PCHAR;
69
70 typedef void *PVOID;
71
72 typedef unsigned char BOOLEAN, *PBOOL, *PBOOLEAN;
73
74 typedef unsigned char BYTE,*PBYTE;
75
76 typedef signed int *PINT;
77
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;
88
89 typedef unsigned char UINT8;
90 typedef unsigned short UINT16;
91 typedef unsigned int UINT32;
92 typedef unsigned long long UINT64;
93 #endif
94
95 #ifndef BOOL_TYPE_ALREADY_DEFINED
96 #define BOOL_TYPE_ALREADY_DEFINED
97 typedef unsigned char UBOOL8;
98 #endif
99
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;
106 #endif
107
108 typedef void VOID;
109 typedef unsigned char BOOL;
110
111 // These are also defined in typedefs.h in the application area, so I need to
112 // protect against re-definition.
113 #ifndef TYPEDEFS_H
114
115 // Maximum and minimum values for a signed 16 bit integer.
116 #define MAX_INT16 32767
117 #define MIN_INT16 -32768
118
119 // Useful for true/false return values. This uses the
120 // Taligent notation (k for constant).
121 typedef enum
122 {
123 kFalse = 0,
124 kTrue = 1
125 } Bool;
126
127 #endif
128
129 #ifndef TRUE
130 #define TRUE 1
131 #endif
132
133 #ifndef FALSE
134 #define FALSE 0
135 #endif
136
137 #define READ32(addr) (*(volatile UINT32 *)((ULONG)&addr))
138 #define READ16(addr) (*(volatile UINT16 *)((ULONG)&addr))
139 #define READ8(addr) (*(volatile UINT8 *)((ULONG)&addr))
140
141 typedef unsigned long long uint64_aligned __attribute__((aligned(8)));
142 typedef signed long long int64_aligned __attribute__((aligned(8)));
143
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))
147 #else
148 #define BCM_IOC_PTR(ptr_t, ptr) ptr_t ptr;
149 #define BCM_IOC_PTR_ZERO_EXT(ptr)
150 #endif
151
152 /*Example usage of above types/macro to a create 32/64-bit compatible ioctl message:
153 typedef struct {
154 uint8 exByte;
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../
158 } ExampleIoctlMsg;
159 */
160 #endif
161
162 #endif