]> git.proxmox.com Git - mirror_edk2.git/blob - EmbeddedPkg/Include/libfdt_env.h
dfd3bac01fcf298d3a2b8412f1132bb25283625c
[mirror_edk2.git] / EmbeddedPkg / Include / libfdt_env.h
1 /** @file
2 *
3 * Copyright (c) 2011-2014, ARM Limited. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-2-Clause-Patent
6 *
7 **/
8
9 #ifndef _LIBFDT_ENV_H
10 #define _LIBFDT_ENV_H
11
12 #include <Library/BaseLib.h>
13 #include <Library/BaseMemoryLib.h>
14
15 typedef UINT16 fdt16_t;
16 typedef UINT32 fdt32_t;
17 typedef UINT64 fdt64_t;
18
19 typedef UINT8 uint8_t;
20 typedef UINT16 uint16_t;
21 typedef UINT32 uint32_t;
22 typedef UINT64 uint64_t;
23 typedef UINTN uintptr_t;
24 typedef UINTN size_t;
25
26 static inline uint16_t
27 fdt16_to_cpu (
28 fdt16_t x
29 )
30 {
31 return SwapBytes16 (x);
32 }
33
34 #define cpu_to_fdt16(x) fdt16_to_cpu(x)
35
36 static inline uint32_t
37 fdt32_to_cpu (
38 fdt32_t x
39 )
40 {
41 return SwapBytes32 (x);
42 }
43
44 #define cpu_to_fdt32(x) fdt32_to_cpu(x)
45
46 static inline uint64_t
47 fdt64_to_cpu (
48 fdt64_t x
49 )
50 {
51 return SwapBytes64 (x);
52 }
53
54 #define cpu_to_fdt64(x) fdt64_to_cpu(x)
55
56 static inline void *
57 memcpy (
58 void *dest,
59 const void *src,
60 size_t len
61 )
62 {
63 return CopyMem (dest, src, len);
64 }
65
66 static inline void *
67 memmove (
68 void *dest,
69 const void *src,
70 size_t n
71 )
72 {
73 return CopyMem (dest, src, n);
74 }
75
76 static inline void *
77 memset (
78 void *s,
79 int c,
80 size_t n
81 )
82 {
83 return SetMem (s, n, c);
84 }
85
86 static inline int
87 memcmp (
88 const void *dest,
89 const void *src,
90 int len
91 )
92 {
93 return CompareMem (dest, src, len);
94 }
95
96 static inline void *
97 memchr (
98 const void *s,
99 int c,
100 size_t n
101 )
102 {
103 return ScanMem8 (s, n, c);
104 }
105
106 static inline size_t
107 strlen (
108 const char *str
109 )
110 {
111 return AsciiStrLen (str);
112 }
113
114 static inline char *
115 strchr (
116 const char *s,
117 int c
118 )
119 {
120 char pattern[2];
121
122 pattern[0] = c;
123 pattern[1] = 0;
124 return AsciiStrStr (s, pattern);
125 }
126
127 static inline size_t
128 strnlen (
129 const char *str,
130 size_t strsz
131 )
132 {
133 return AsciiStrnLenS (str, strsz);
134 }
135
136 static inline size_t
137 strcmp (
138 const char *str1,
139 const char *str2
140 )
141 {
142 return AsciiStrCmp (str1, str2);
143 }
144
145 static inline size_t
146 strncmp (
147 const char *str1,
148 const char *str2,
149 size_t strsz
150 )
151 {
152 return AsciiStrnCmp (str1, str2, strsz);
153 }
154
155 static inline size_t
156 strncpy (
157 char *dest,
158 const char *source,
159 size_t dest_max
160 )
161 {
162 return AsciiStrCpyS (dest, dest_max, source);
163 }
164
165 #endif /* _LIBFDT_ENV_H */