]> git.proxmox.com Git - mirror_edk2.git/blob - EmbeddedPkg/Library/FdtLib/0001-EmbeddedPkg-Added-libfdt-port.patch
EmbeddedPkg/FdtLib: Added patches to support libfdt in EDK2
[mirror_edk2.git] / EmbeddedPkg / Library / FdtLib / 0001-EmbeddedPkg-Added-libfdt-port.patch
1 From 669778eab2092ef85ed5b5e537203721cfb1215d Mon Sep 17 00:00:00 2001
2 From: Olivier Martin <olivier.martin@arm.com>
3 Date: Thu, 16 Feb 2012 15:44:35 +0000
4 Subject: [PATCH 1/3] EmbeddedPkg: Added libfdt port
5
6 This port is based on the 'libfdt' project (dual licensed BSD/GPL).
7
8 Prior to apply this patch you must execute the following steps:
9
10 1. Clone the dtc into a temporary directory:
11 cd EmbeddedPkg/Library
12 git clone git://git.jdl.com/software/dtc.git
13
14 2. Copy the content of 'libfdt' into EmbeddedPkg/Library/FdtLib/
15 cd dtc
16 cp -a libfdt ../FdtLib
17
18 3. Copy the libfdt headers:
19 mv ../FdtLib/libfdt.h ../../Include/
20 mv ../FdtLib/fdt.h ../../Include/
21 rm ../FdtLib/libfdt_env.h
22 ---
23 EmbeddedPkg/EmbeddedPkg.dsc | 1 +
24 EmbeddedPkg/Include/libfdt_env.h | 77 +++++++++++++++++++++++++++++++++
25 EmbeddedPkg/Library/FdtLib/FdtLib.inf | 38 ++++++++++++++++
26 EmbeddedPkg/Library/FdtLib/README.txt | 38 ++++++++++++++++
27 4 files changed, 154 insertions(+), 0 deletions(-)
28 mode change 100644 => 100755 EmbeddedPkg/EmbeddedPkg.dsc
29 create mode 100755 EmbeddedPkg/Include/libfdt_env.h
30 create mode 100755 EmbeddedPkg/Library/FdtLib/FdtLib.inf
31 create mode 100755 EmbeddedPkg/Library/FdtLib/README.txt
32
33 diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc
34 old mode 100644
35 new mode 100755
36 index 8862f3d..c3a2464
37 --- a/EmbeddedPkg/EmbeddedPkg.dsc
38 +++ b/EmbeddedPkg/EmbeddedPkg.dsc
39 @@ -97,6 +97,7 @@
40
41 EblNetworkLib|EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf
42
43 + FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
44
45 [LibraryClasses.common.DXE_DRIVER]
46 PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
47 diff --git a/EmbeddedPkg/Include/libfdt_env.h b/EmbeddedPkg/Include/libfdt_env.h
48 new file mode 100755
49 index 0000000..8c4f1c7
50 --- /dev/null
51 +++ b/EmbeddedPkg/Include/libfdt_env.h
52 @@ -0,0 +1,77 @@
53 +/** @file
54 +*
55 +* Copyright (c) 2011, ARM Limited. All rights reserved.
56 +*
57 +* This program and the accompanying materials
58 +* are licensed and made available under the terms and conditions of the BSD License
59 +* which accompanies this distribution. The full text of the license may be found at
60 +* http://opensource.org/licenses/bsd-license.php
61 +*
62 +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
63 +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
64 +*
65 +**/
66 +
67 +#ifndef _LIBFDT_ENV_H
68 +#define _LIBFDT_ENV_H
69 +
70 +#include <Library/BaseLib.h>
71 +#include <Library/BaseMemoryLib.h>
72 +
73 +typedef UINT8 uint8_t;
74 +typedef UINT16 uint16_t;
75 +typedef UINT32 uint32_t;
76 +typedef UINT64 uint64_t;
77 +typedef UINTN uintptr_t;
78 +typedef UINTN size_t;
79 +
80 +static inline uint16_t fdt16_to_cpu(uint16_t x)
81 +{
82 + return SwapBytes16 (x);
83 +}
84 +#define cpu_to_fdt16(x) fdt16_to_cpu(x)
85 +
86 +static inline uint32_t fdt32_to_cpu(uint32_t x)
87 +{
88 + return SwapBytes32 (x);
89 +}
90 +#define cpu_to_fdt32(x) fdt32_to_cpu(x)
91 +
92 +static inline uint64_t fdt64_to_cpu(uint64_t x)
93 +{
94 + return SwapBytes64 (x);
95 +}
96 +#define cpu_to_fdt64(x) fdt64_to_cpu(x)
97 +
98 +static inline void* memcpy(void* dest, const void* src, size_t len) {
99 + return CopyMem (dest, src, len);
100 +}
101 +
102 +static inline void *memmove(void *dest, const void *src, size_t n) {
103 + return CopyMem (dest, src, n);
104 +}
105 +
106 +static inline void *memset(void *s, int c, size_t n) {
107 + return SetMem (s, n, c);
108 +}
109 +
110 +static inline int memcmp(const void* dest, const void* src, int len) {
111 + return CompareMem (dest, src, len);
112 +}
113 +
114 +static inline void *memchr(const void *s, int c, size_t n) {
115 + return ScanMem8 (s, n, c);
116 +}
117 +
118 +static inline size_t strlen (const char* str) {
119 + return AsciiStrLen (str);
120 +}
121 +
122 +static inline char *strchr(const char *s, int c) {
123 + char pattern[2];
124 + pattern[0] = c;
125 + pattern[1] = 0;
126 + return AsciiStrStr (s, pattern);
127 +}
128 +
129 +#endif /* _LIBFDT_ENV_H */
130 diff --git a/EmbeddedPkg/Library/FdtLib/FdtLib.inf b/EmbeddedPkg/Library/FdtLib/FdtLib.inf
131 new file mode 100755
132 index 0000000..9753ed8
133 --- /dev/null
134 +++ b/EmbeddedPkg/Library/FdtLib/FdtLib.inf
135 @@ -0,0 +1,38 @@
136 +#/* @file
137 +# Copyright (c) 2011, ARM Limited. All rights reserved.
138 +#
139 +# This program and the accompanying materials
140 +# are licensed and made available under the terms and conditions of the BSD License
141 +# which accompanies this distribution. The full text of the license may be found at
142 +# http://opensource.org/licenses/bsd-license.php
143 +#
144 +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
145 +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
146 +#
147 +#*/
148 +
149 +[Defines]
150 + INF_VERSION = 0x00010005
151 + BASE_NAME = FdtLib
152 + FILE_GUID = 6b2478c0-be23-11e0-a28c-0002a5d5c51b
153 + MODULE_TYPE = BASE
154 + VERSION_STRING = 1.0
155 + LIBRARY_CLASS = FdtLib
156 +
157 +#
158 +# The following information is for reference only and not required by the build tools.
159 +#
160 +# VALID_ARCHITECTURES = ARM
161 +#
162 +
163 +[Sources]
164 + fdt_ro.c
165 + fdt_rw.c
166 + fdt_strerror.c
167 + fdt_sw.c
168 + fdt_wip.c
169 + fdt.c
170 +
171 +[Packages]
172 + MdePkg/MdePkg.dec
173 + EmbeddedPkg/EmbeddedPkg.dec
174 diff --git a/EmbeddedPkg/Library/FdtLib/README.txt b/EmbeddedPkg/Library/FdtLib/README.txt
175 new file mode 100755
176 index 0000000..c74db7a
177 --- /dev/null
178 +++ b/EmbeddedPkg/Library/FdtLib/README.txt
179 @@ -0,0 +1,38 @@
180 +Credits
181 +-------
182 +Principal original author: David Gibson (david AT gibson.dropbear.id.au)
183 +Maintainer: Jon Loeliger (jdl AT jdl.com)
184 +
185 +
186 +Licensing:
187 +----------
188 +libfdt is GPL/BSD dual-licensed.
189 +
190 +
191 +Current version:
192 +----------------
193 +
194 +# Latest commit in dtc.git repository :
195 +commit a31e3ef83bfce62d07695355e5f06cd4d0e44b86
196 +Author: Minghuan Lian <Minghuan.Lian@freescale.com>
197 +Date: Mon Dec 5 12:22:07 2011 +1100
198 +
199 +# Latest commit in libfdt :
200 +commit a31e3ef83bfce62d07695355e5f06cd4d0e44b86
201 +Author: Minghuan Lian <Minghuan.Lian@freescale.com>
202 +Date: Mon Dec 5 12:22:07 2011 +1100
203 +
204 +
205 +How to update EmbeddedPkg/Library/FdtLib
206 +----------------------------------------
207 +1. Clone the dtc into a temporary directory:
208 +git clone git://git.jdl.com/software/dtc.git
209 +
210 +2. Copy the content of 'libfdt' into EmbeddedPkg/Library/FdtLib/
211 +cd dtc
212 +cp -a libfdt/* $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/
213 +
214 +3. Copy the libfdt headers:
215 +mv $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/libfdt.h $(EDK2_ROOT)/EmbeddedPkg/Include/
216 +mv $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/fdt.h $(EDK2_ROOT)/EmbeddedPkg/Include/
217 +rm $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/libfdt_env.h
218 --
219 1.7.0.4
220