summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg/Include/libfdt_env.h
blob: dfd3bac01fcf298d3a2b8412f1132bb25283625c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/** @file
*
*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
*
*  SPDX-License-Identifier: BSD-2-Clause-Patent
*
**/

#ifndef _LIBFDT_ENV_H
#define _LIBFDT_ENV_H

#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>

typedef UINT16  fdt16_t;
typedef UINT32  fdt32_t;
typedef UINT64  fdt64_t;

typedef UINT8   uint8_t;
typedef UINT16  uint16_t;
typedef UINT32  uint32_t;
typedef UINT64  uint64_t;
typedef UINTN   uintptr_t;
typedef UINTN   size_t;

static inline uint16_t
fdt16_to_cpu (
  fdt16_t  x
  )
{
  return SwapBytes16 (x);
}

#define cpu_to_fdt16(x)  fdt16_to_cpu(x)

static inline uint32_t
fdt32_to_cpu (
  fdt32_t  x
  )
{
  return SwapBytes32 (x);
}

#define cpu_to_fdt32(x)  fdt32_to_cpu(x)

static inline uint64_t
fdt64_to_cpu (
  fdt64_t  x
  )
{
  return SwapBytes64 (x);
}

#define cpu_to_fdt64(x)  fdt64_to_cpu(x)

static inline void *
memcpy (
  void        *dest,
  const void  *src,
  size_t      len
  )
{
  return CopyMem (dest, src, len);
}

static inline void *
memmove (
  void        *dest,
  const void  *src,
  size_t      n
  )
{
  return CopyMem (dest, src, n);
}

static inline void *
memset (
  void    *s,
  int     c,
  size_t  n
  )
{
  return SetMem (s, n, c);
}

static inline int
memcmp (
  const void  *dest,
  const void  *src,
  int         len
  )
{
  return CompareMem (dest, src, len);
}

static inline void *
memchr (
  const void  *s,
  int         c,
  size_t      n
  )
{
  return ScanMem8 (s, n, c);
}

static inline size_t
strlen (
  const char  *str
  )
{
  return AsciiStrLen (str);
}

static inline char *
strchr (
  const char  *s,
  int         c
  )
{
  char  pattern[2];

  pattern[0] = c;
  pattern[1] = 0;
  return AsciiStrStr (s, pattern);
}

static inline size_t
strnlen (
  const char  *str,
  size_t      strsz
  )
{
  return AsciiStrnLenS (str, strsz);
}

static inline size_t
strcmp (
  const char  *str1,
  const char  *str2
  )
{
  return AsciiStrCmp (str1, str2);
}

static inline size_t
strncmp (
  const char  *str1,
  const char  *str2,
  size_t      strsz
  )
{
  return AsciiStrnCmp (str1, str2, strsz);
}

static inline size_t
strncpy (
  char        *dest,
  const char  *source,
  size_t      dest_max
  )
{
  return AsciiStrCpyS (dest, dest_max, source);
}

#endif /* _LIBFDT_ENV_H */