]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/unisys/include/commontypes.h
Merge branch 'for-3.15' of git://linux-nfs.org/~bfields/linux
[karo-tx-linux.git] / drivers / staging / unisys / include / commontypes.h
1 /* Copyright © 2010 - 2013 UNISYS CORPORATION
2  * All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or (at
7  * your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12  * NON INFRINGEMENT.  See the GNU General Public License for more
13  * details.
14  */
15
16 #ifndef _COMMONTYPES_H_
17 #define _COMMONTYPES_H_
18
19 /* define the following to prevent include nesting in kernel header files of
20  * similar abreviated content */
21 #define _SUPERVISOR_COMMONTYPES_H_
22
23 #ifdef __KERNEL__
24 #include <linux/types.h>
25 #include <linux/version.h>
26 #include <linux/io.h>
27 #else
28 #include <stdint.h>
29 #include <syslog.h>
30 #endif
31
32 #define U8  uint8_t
33 #define U16 uint16_t
34 #define U32 uint32_t
35 #define U64 uint64_t
36 #define S8  int8_t
37 #define S16 int16_t
38 #define S32 int32_t
39 #define S64 int64_t
40
41 #ifdef __KERNEL__
42
43 #ifdef CONFIG_X86_32
44 #define UINTN U32
45 #else
46 #define UINTN U64
47 #endif
48
49 #else
50
51 #include <stdint.h>
52 #if __WORDSIZE == 32
53 #define UINTN U32
54 #elif __WORDSIZE == 64
55 #define UINTN U64
56 #else
57 #error Unsupported __WORDSIZE
58 #endif
59
60 #endif
61
62 typedef struct {
63         U32 data1;
64         U16 data2;
65         U16 data3;
66         U8 data4[8];
67 } __attribute__ ((__packed__)) GUID;
68
69 #ifndef GUID0
70 #define GUID0 {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} }
71 #endif
72 typedef U64 GUEST_PHYSICAL_ADDRESS;
73
74 #define MEMSET(ptr, val, len) memset(ptr, val, len)
75 #define MEMCMP(m1, m2, len) memcmp(m1, m2, len)
76 #define MEMCMP_IO(m1, m2, len) memcmp((void __force *)m1, m2, len)
77 #define STRLEN(s) ((UINTN)strlen((const char *)s))
78 #define STRCPY(d, s) (strcpy((char *)d, (const char *)s))
79
80 #define INLINE inline
81 #define OFFSETOF offsetof
82
83 #ifdef __KERNEL__
84 #define MEMORYBARRIER mb()
85 #define MEMCPY(dest, src, len) memcpy(dest, src, len)
86 #define MEMCPY_TOIO(dest, src, len) memcpy_toio(dest, src, len)
87 #define MEMCPY_FROMIO(dest, src, len) memcpy_fromio(dest, src, len)
88
89 #define CHANNEL_GUID_MISMATCH(chType, chName, field, expected, actual, fil, \
90                               lin, logCtx)                              \
91         do {                                                            \
92                 char s1[50], s2[50], s3[50];                            \
93                 pr_err("Channel mismatch on channel=%s(%s) field=%s expected=%s actual=%s @%s:%d\n", \
94                        chName, GUID_format2(&chType, s1), field,        \
95                        GUID_format2(&expected, s2), GUID_format2(&actual, s3), \
96                        fil, lin);                                       \
97         } while (0)
98 #define CHANNEL_U32_MISMATCH(chType, chName, field, expected, actual, fil, \
99                              lin, logCtx)                               \
100         do {                                                            \
101                 char s1[50];                                            \
102                 pr_err("Channel mismatch on channel=%s(%s) field=%s expected=0x%-8.8lx actual=0x%-8.8lx @%s:%d\n", \
103                        chName, GUID_format2(&chType, s1), field,        \
104                        (unsigned long)expected, (unsigned long)actual,  \
105                        fil, lin);                                       \
106         } while (0)
107
108 #define CHANNEL_U64_MISMATCH(chType, chName, field, expected, actual, fil, \
109                              lin, logCtx)                               \
110         do {                                                            \
111                 char s1[50];                                            \
112                 pr_err("Channel mismatch on channel=%s(%s) field=%s expected=0x%-8.8Lx actual=0x%-8.8Lx @%s:%d\n", \
113                        chName, GUID_format2(&chType, s1), field,        \
114                        (unsigned long long)expected,                    \
115                        (unsigned long long)actual,                      \
116                        fil, lin);                                       \
117         } while (0)
118
119 #define UltraLogEvent(logCtx, EventId, Severity, SubsystemMask, pFunctionName, \
120                       LineNumber, Str, args...)                         \
121         pr_info(Str, ## args)
122
123 #else
124 #define MEMCPY(dest, src, len) memcpy(dest, src, len)
125
126 #define MEMORYBARRIER mb()
127
128 #define CHANNEL_GUID_MISMATCH(chType, chName, field, expected, actual, fil, \
129                               lin, logCtx)                              \
130         do {                                                            \
131                 char s1[50], s2[50], s3[50];                            \
132                 syslog(LOG_USER | LOG_ERR,                              \
133                        "Channel mismatch on channel=%s(%s) field=%s expected=%s actual=%s @%s:%d", \
134                        chName, GUID_format2(&chType, s1), field,        \
135                        GUID_format2(&expected, s2), GUID_format2(&actual, s3), \
136                        fil, lin);                                       \
137         } while (0)
138
139 #define CHANNEL_U32_MISMATCH(chType, chName, field, expected, actual, fil, \
140                              lin, logCtx)                               \
141         do {                                                            \
142                 char s1[50];                                            \
143                 syslog(LOG_USER | LOG_ERR,                              \
144                        "Channel mismatch on channel=%s(%s) field=%s expected=0x%-8.8lx actual=0x%-8.8lx @%s:%d", \
145                        chName, GUID_format2(&chType, s1), field,        \
146                        (unsigned long)expected, (unsigned long)actual,  \
147                        fil, lin);                                       \
148         } while (0)
149
150 #define CHANNEL_U64_MISMATCH(chType, chName, field, expected, actual, fil, \
151                              lin, logCtx)                               \
152         do {                                                            \
153                 char s1[50];                                            \
154                 syslog(LOG_USER | LOG_ERR,                              \
155                        "Channel mismatch on channel=%s(%s) field=%s expected=0x%-8.8Lx actual=0x%-8.8Lx @%s:%d", \
156                        chName, GUID_format2(&chType, s1), field,        \
157                        (unsigned long long)expected,                    \
158                        (unsigned long long)actual,                      \
159                        fil, lin);                                       \
160         } while (0)
161
162 #define UltraLogEvent(logCtx, EventId, Severity, SubsystemMask, pFunctionName, \
163                       LineNumber, Str, args...)                         \
164         syslog(LOG_USER | LOG_INFO, Str, ## args)
165 #endif
166
167 #define VolatileBarrier() MEMORYBARRIER
168
169 #endif
170 #include "guidutils.h"