libfdt_env.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. #ifndef _LIBFDT_ENV_H
  9. #define _LIBFDT_ENV_H
  10. #include <Library/BaseLib.h>
  11. #include <Library/BaseMemoryLib.h>
  12. typedef UINT16 fdt16_t;
  13. typedef UINT32 fdt32_t;
  14. typedef UINT64 fdt64_t;
  15. typedef UINT8 uint8_t;
  16. typedef UINT16 uint16_t;
  17. typedef UINT32 uint32_t;
  18. typedef UINT64 uint64_t;
  19. typedef UINTN uintptr_t;
  20. typedef UINTN size_t;
  21. static inline uint16_t
  22. fdt16_to_cpu (
  23. fdt16_t x
  24. )
  25. {
  26. return SwapBytes16 (x);
  27. }
  28. #define cpu_to_fdt16(x) fdt16_to_cpu(x)
  29. static inline uint32_t
  30. fdt32_to_cpu (
  31. fdt32_t x
  32. )
  33. {
  34. return SwapBytes32 (x);
  35. }
  36. #define cpu_to_fdt32(x) fdt32_to_cpu(x)
  37. static inline uint64_t
  38. fdt64_to_cpu (
  39. fdt64_t x
  40. )
  41. {
  42. return SwapBytes64 (x);
  43. }
  44. #define cpu_to_fdt64(x) fdt64_to_cpu(x)
  45. static inline void *
  46. memcpy (
  47. void *dest,
  48. const void *src,
  49. size_t len
  50. )
  51. {
  52. return CopyMem (dest, src, len);
  53. }
  54. static inline void *
  55. memmove (
  56. void *dest,
  57. const void *src,
  58. size_t n
  59. )
  60. {
  61. return CopyMem (dest, src, n);
  62. }
  63. static inline void *
  64. memset (
  65. void *s,
  66. int c,
  67. size_t n
  68. )
  69. {
  70. return SetMem (s, n, c);
  71. }
  72. static inline int
  73. memcmp (
  74. const void *dest,
  75. const void *src,
  76. int len
  77. )
  78. {
  79. return CompareMem (dest, src, len);
  80. }
  81. static inline void *
  82. memchr (
  83. const void *s,
  84. int c,
  85. size_t n
  86. )
  87. {
  88. return ScanMem8 (s, n, c);
  89. }
  90. static inline size_t
  91. strlen (
  92. const char *str
  93. )
  94. {
  95. return AsciiStrLen (str);
  96. }
  97. static inline char *
  98. strchr (
  99. const char *s,
  100. int c
  101. )
  102. {
  103. char pattern[2];
  104. pattern[0] = c;
  105. pattern[1] = 0;
  106. return AsciiStrStr (s, pattern);
  107. }
  108. static inline size_t
  109. strnlen (
  110. const char *str,
  111. size_t strsz
  112. )
  113. {
  114. return AsciiStrnLenS (str, strsz);
  115. }
  116. static inline size_t
  117. strcmp (
  118. const char *str1,
  119. const char *str2
  120. )
  121. {
  122. return AsciiStrCmp (str1, str2);
  123. }
  124. static inline size_t
  125. strncmp (
  126. const char *str1,
  127. const char *str2,
  128. size_t strsz
  129. )
  130. {
  131. return AsciiStrnCmp (str1, str2, strsz);
  132. }
  133. static inline size_t
  134. strncpy (
  135. char *dest,
  136. const char *source,
  137. size_t dest_max
  138. )
  139. {
  140. return AsciiStrCpyS (dest, dest_max, source);
  141. }
  142. #endif /* _LIBFDT_ENV_H */