]> git.proxmox.com Git - mirror_edk2.git/blame - EmbeddedPkg/Include/libfdt_env.h
EmbeddedPkg/FdtLib: Added support to load Fdt from Semihosting
[mirror_edk2.git] / EmbeddedPkg / Include / libfdt_env.h
CommitLineData
1e57a462 1/** @file\r
2*\r
3e8576dd 3* Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
1e57a462 4*\r
3402aac7
RC
5* This program and the accompanying materials\r
6* are licensed and made available under the terms and conditions of the BSD License\r
7* which accompanies this distribution. The full text of the license may be found at\r
8* http://opensource.org/licenses/bsd-license.php\r
9*\r
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
1e57a462 12*\r
13**/\r
14\r
15#ifndef _LIBFDT_ENV_H\r
16#define _LIBFDT_ENV_H\r
17\r
af16798e 18#include <Uefi.h>\r
1e57a462 19#include <Library/BaseLib.h>\r
20#include <Library/BaseMemoryLib.h>\r
21\r
3e8576dd
OM
22typedef UINT16 fdt16_t;\r
23typedef UINT32 fdt32_t;\r
24typedef UINT64 fdt64_t;\r
25\r
1e57a462 26typedef UINT8 uint8_t;\r
27typedef UINT16 uint16_t;\r
28typedef UINT32 uint32_t;\r
29typedef UINT64 uint64_t;\r
30typedef UINTN uintptr_t;\r
31typedef UINTN size_t;\r
32\r
3e8576dd 33static inline uint16_t fdt16_to_cpu(fdt16_t x)\r
1e57a462 34{\r
35 return SwapBytes16 (x);\r
36}\r
37#define cpu_to_fdt16(x) fdt16_to_cpu(x)\r
38\r
3e8576dd 39static inline uint32_t fdt32_to_cpu(fdt32_t x)\r
1e57a462 40{\r
41 return SwapBytes32 (x);\r
42}\r
43#define cpu_to_fdt32(x) fdt32_to_cpu(x)\r
44\r
3e8576dd 45static inline uint64_t fdt64_to_cpu(fdt64_t x)\r
1e57a462 46{\r
47 return SwapBytes64 (x);\r
48}\r
49#define cpu_to_fdt64(x) fdt64_to_cpu(x)\r
50\r
51static inline void* memcpy(void* dest, const void* src, size_t len) {\r
52 return CopyMem (dest, src, len);\r
53}\r
54\r
55static inline void *memmove(void *dest, const void *src, size_t n) {\r
56 return CopyMem (dest, src, n);\r
57}\r
58\r
59static inline void *memset(void *s, int c, size_t n) {\r
60 return SetMem (s, n, c);\r
61}\r
62\r
63static inline int memcmp(const void* dest, const void* src, int len) {\r
64 return CompareMem (dest, src, len);\r
65}\r
66\r
67static inline void *memchr(const void *s, int c, size_t n) {\r
68 return ScanMem8 (s, n, c);\r
69}\r
70\r
71static inline size_t strlen (const char* str) {\r
72 return AsciiStrLen (str);\r
73}\r
74\r
75static inline char *strchr(const char *s, int c) {\r
76 char pattern[2];\r
77 pattern[0] = c;\r
78 pattern[1] = 0;\r
79 return AsciiStrStr (s, pattern);\r
80}\r
81\r
af16798e
OM
82/**\r
83 Load and Install FDT from Semihosting\r
84\r
85 @param Filename Name of the file to load from semihosting\r
86\r
87 @return EFI_SUCCESS Fdt Blob was successfully installed into the configuration table\r
88 from semihosting\r
89 @return EFI_NOT_FOUND Fail to locate the file in semihosting\r
90 @return EFI_OUT_OF_RESOURCES Fail to allocate memory to contain the blob\r
91**/\r
92EFI_STATUS\r
93InstallFdtFromSemihosting (\r
94 IN CONST CHAR16* FileName\r
95 );\r
96\r
1e57a462 97#endif /* _LIBFDT_ENV_H */\r