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