libfdt_env.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 fdt16_to_cpu(fdt16_t x)
  22. {
  23. return SwapBytes16 (x);
  24. }
  25. #define cpu_to_fdt16(x) fdt16_to_cpu(x)
  26. static inline uint32_t fdt32_to_cpu(fdt32_t x)
  27. {
  28. return SwapBytes32 (x);
  29. }
  30. #define cpu_to_fdt32(x) fdt32_to_cpu(x)
  31. static inline uint64_t fdt64_to_cpu(fdt64_t x)
  32. {
  33. return SwapBytes64 (x);
  34. }
  35. #define cpu_to_fdt64(x) fdt64_to_cpu(x)
  36. static inline void* memcpy(void* dest, const void* src, size_t len) {
  37. return CopyMem (dest, src, len);
  38. }
  39. static inline void *memmove(void *dest, const void *src, size_t n) {
  40. return CopyMem (dest, src, n);
  41. }
  42. static inline void *memset(void *s, int c, size_t n) {
  43. return SetMem (s, n, c);
  44. }
  45. static inline int memcmp(const void* dest, const void* src, int len) {
  46. return CompareMem (dest, src, len);
  47. }
  48. static inline void *memchr(const void *s, int c, size_t n) {
  49. return ScanMem8 (s, n, c);
  50. }
  51. static inline size_t strlen (const char* str) {
  52. return AsciiStrLen (str);
  53. }
  54. static inline char *strchr(const char *s, int c) {
  55. char pattern[2];
  56. pattern[0] = c;
  57. pattern[1] = 0;
  58. return AsciiStrStr (s, pattern);
  59. }
  60. static inline size_t strnlen (const char* str, size_t strsz ) {
  61. return AsciiStrnLenS (str, strsz);
  62. }
  63. #endif /* _LIBFDT_ENV_H */