1 #ifndef __VTPMMGR_ENDIAN_INT_H
2 #define __VTPMMGR_ENDIAN_INT_H
3 
4 #include <mini-os/byteorder.h>
5 
6 /* These wrapper structs force the use of endian-to-CPU conversions */
7 
8 typedef struct be_int16 {
9 	uint16_t value;
10 } be16_t;
11 
12 typedef struct be_int32 {
13 	uint32_t value;
14 } be32_t;
15 
16 typedef struct le_int32 {
17 	uint32_t value;
18 } le32_t;
19 
20 typedef struct be_int64 {
21 	uint64_t value;
22 } be64_t;
23 
be16_native(be16_t v)24 static inline uint16_t be16_native(be16_t v)
25 {
26 	return be16_to_cpu(v.value);
27 }
28 
le32_native(le32_t v)29 static inline uint32_t le32_native(le32_t v)
30 {
31 	return le32_to_cpu(v.value);
32 }
33 
be32_native(be32_t v)34 static inline uint32_t be32_native(be32_t v)
35 {
36 	return be32_to_cpu(v.value);
37 }
38 
be64_native(be64_t v)39 static inline uint64_t be64_native(be64_t v)
40 {
41 	return be64_to_cpu(v.value);
42 }
43 
native_be16(uint16_t v)44 static inline be16_t native_be16(uint16_t v)
45 {
46 	be16_t rv;
47 	rv.value = cpu_to_be16(v);
48 	return rv;
49 }
50 
native_le32(uint32_t v)51 static inline le32_t native_le32(uint32_t v)
52 {
53 	le32_t rv;
54 	rv.value = cpu_to_le32(v);
55 	return rv;
56 }
57 
native_be32(uint32_t v)58 static inline be32_t native_be32(uint32_t v)
59 {
60 	be32_t rv;
61 	rv.value = cpu_to_be32(v);
62 	return rv;
63 }
64 
native_be64(uint64_t v)65 static inline be64_t native_be64(uint64_t v)
66 {
67 	be64_t rv;
68 	rv.value = cpu_to_be64(v);
69 	return rv;
70 }
71 
72 #endif
73