summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg/Library/FdtLib/0001-EmbeddedPkg-Added-libfdt-port.patch
blob: ae06b6f39681f81ab9464d0df18db8edff14640f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
From 669778eab2092ef85ed5b5e537203721cfb1215d Mon Sep 17 00:00:00 2001
From: Olivier Martin <olivier.martin@arm.com>
Date: Thu, 16 Feb 2012 15:44:35 +0000
Subject: [PATCH 1/3] EmbeddedPkg: Added libfdt port

This port is based on the 'libfdt' project (dual licensed BSD/GPL).

Prior to apply this patch you must execute the following steps:

1. Clone the dtc into a temporary directory:
cd EmbeddedPkg/Library
git clone git://git.jdl.com/software/dtc.git

2. Copy the content of 'libfdt' into EmbeddedPkg/Library/FdtLib/
cd dtc
cp -a libfdt ../FdtLib

3. Copy the libfdt headers:
mv ../FdtLib/libfdt.h ../../Include/
mv ../FdtLib/fdt.h ../../Include/
rm ../FdtLib/libfdt_env.h
---
 EmbeddedPkg/EmbeddedPkg.dsc           |    1 +
 EmbeddedPkg/Include/libfdt_env.h      |   77 +++++++++++++++++++++++++++++++++
 EmbeddedPkg/Library/FdtLib/FdtLib.inf |   38 ++++++++++++++++
 EmbeddedPkg/Library/FdtLib/README.txt |   38 ++++++++++++++++
 4 files changed, 154 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 EmbeddedPkg/EmbeddedPkg.dsc
 create mode 100755 EmbeddedPkg/Include/libfdt_env.h
 create mode 100755 EmbeddedPkg/Library/FdtLib/FdtLib.inf
 create mode 100755 EmbeddedPkg/Library/FdtLib/README.txt

diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc
old mode 100644
new mode 100755
index 8862f3d..c3a2464
--- a/EmbeddedPkg/EmbeddedPkg.dsc
+++ b/EmbeddedPkg/EmbeddedPkg.dsc
@@ -97,6 +97,7 @@
   
   EblNetworkLib|EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf
   
+  FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
 
 [LibraryClasses.common.DXE_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
diff --git a/EmbeddedPkg/Include/libfdt_env.h b/EmbeddedPkg/Include/libfdt_env.h
new file mode 100755
index 0000000..8c4f1c7
--- /dev/null
+++ b/EmbeddedPkg/Include/libfdt_env.h
@@ -0,0 +1,77 @@
+/** @file
+*
+*  Copyright (c) 2011, ARM Limited. All rights reserved.
+*  
+*  This program and the accompanying materials                          
+*  are licensed and made available under the terms and conditions of the BSD License         
+*  which accompanies this distribution.  The full text of the license may be found at        
+*  http://opensource.org/licenses/bsd-license.php                                            
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
+*
+**/
+
+#ifndef _LIBFDT_ENV_H
+#define _LIBFDT_ENV_H
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+
+typedef UINT8 uint8_t;
+typedef UINT16 uint16_t;
+typedef UINT32 uint32_t;
+typedef UINT64 uint64_t;
+typedef UINTN uintptr_t;
+typedef UINTN size_t;
+
+static inline uint16_t fdt16_to_cpu(uint16_t x)
+{
+       return SwapBytes16 (x);
+}
+#define cpu_to_fdt16(x) fdt16_to_cpu(x)
+
+static inline uint32_t fdt32_to_cpu(uint32_t x)
+{
+	return SwapBytes32 (x);
+}
+#define cpu_to_fdt32(x) fdt32_to_cpu(x)
+
+static inline uint64_t fdt64_to_cpu(uint64_t x)
+{
+	return SwapBytes64 (x);
+}
+#define cpu_to_fdt64(x) fdt64_to_cpu(x)
+
+static inline void* memcpy(void* dest, const void* src, size_t len) {
+  return CopyMem (dest, src, len);
+}
+
+static inline void *memmove(void *dest, const void *src, size_t n) {
+  return CopyMem (dest, src, n);
+}
+
+static inline void *memset(void *s, int c, size_t n) {
+  return SetMem (s, n, c);
+}
+
+static inline int memcmp(const void* dest, const void* src, int len) {
+  return CompareMem (dest, src, len);
+}
+
+static inline void *memchr(const void *s, int c, size_t n) {
+  return ScanMem8 (s, n, c);
+}
+
+static inline size_t strlen (const char* str) {
+  return AsciiStrLen (str);
+}
+
+static inline char *strchr(const char *s, int c) {
+  char pattern[2];
+  pattern[0] = c;
+  pattern[1] = 0;
+  return AsciiStrStr (s, pattern);
+}
+
+#endif /* _LIBFDT_ENV_H */
diff --git a/EmbeddedPkg/Library/FdtLib/FdtLib.inf b/EmbeddedPkg/Library/FdtLib/FdtLib.inf
new file mode 100755
index 0000000..9753ed8
--- /dev/null
+++ b/EmbeddedPkg/Library/FdtLib/FdtLib.inf
@@ -0,0 +1,38 @@
+#/* @file
+#  Copyright (c) 2011, ARM Limited. All rights reserved.
+#  
+#  This program and the accompanying materials                          
+#  are licensed and made available under the terms and conditions of the BSD License         
+#  which accompanies this distribution.  The full text of the license may be found at        
+#  http://opensource.org/licenses/bsd-license.php                                            
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
+#
+#*/
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = FdtLib
+  FILE_GUID                      = 6b2478c0-be23-11e0-a28c-0002a5d5c51b
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = FdtLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = ARM
+#
+
+[Sources]
+  fdt_ro.c
+  fdt_rw.c
+  fdt_strerror.c
+  fdt_sw.c
+  fdt_wip.c
+  fdt.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
diff --git a/EmbeddedPkg/Library/FdtLib/README.txt b/EmbeddedPkg/Library/FdtLib/README.txt
new file mode 100755
index 0000000..c74db7a
--- /dev/null
+++ b/EmbeddedPkg/Library/FdtLib/README.txt
@@ -0,0 +1,38 @@
+Credits
+-------
+Principal original author: David Gibson (david AT gibson.dropbear.id.au)
+Maintainer: Jon Loeliger (jdl AT jdl.com)
+
+
+Licensing:
+----------
+libfdt is GPL/BSD dual-licensed.
+
+
+Current version:
+----------------
+
+# Latest commit in dtc.git repository :
+commit a31e3ef83bfce62d07695355e5f06cd4d0e44b86
+Author: Minghuan Lian <Minghuan.Lian@freescale.com>
+Date:   Mon Dec 5 12:22:07 2011 +1100
+
+# Latest commit in libfdt :
+commit a31e3ef83bfce62d07695355e5f06cd4d0e44b86
+Author: Minghuan Lian <Minghuan.Lian@freescale.com>
+Date:   Mon Dec 5 12:22:07 2011 +1100
+
+
+How to update EmbeddedPkg/Library/FdtLib
+----------------------------------------
+1. Clone the dtc into a temporary directory:
+git clone git://git.jdl.com/software/dtc.git
+
+2. Copy the content of 'libfdt' into EmbeddedPkg/Library/FdtLib/
+cd dtc
+cp -a libfdt/* $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/
+
+3. Copy the libfdt headers:
+mv $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/libfdt.h $(EDK2_ROOT)/EmbeddedPkg/Include/
+mv $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/fdt.h $(EDK2_ROOT)/EmbeddedPkg/Include/
+rm $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/libfdt_env.h
-- 
1.7.0.4