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
6 This port is based on the 'libfdt' project (dual licensed BSD/GPL).
8 Prior to apply this patch you must execute the following steps:
10 1. Clone the dtc into a temporary directory:
11 cd EmbeddedPkg/Library
12 git clone git://git.jdl.com/software/dtc.git
14 2. Copy the content of 'libfdt' into EmbeddedPkg/Library/FdtLib/
16 cp -a libfdt ../FdtLib
18 3. Copy the libfdt headers:
19 mv ../FdtLib/libfdt.h ../../Include/
20 mv ../FdtLib/fdt.h ../../Include/
21 rm ../FdtLib/libfdt_env.h
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
33 diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc
36 index 8862f3d..c3a2464
37 --- a/EmbeddedPkg/EmbeddedPkg.dsc
38 +++ b/EmbeddedPkg/EmbeddedPkg.dsc
41 EblNetworkLib|EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf
43 + FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
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
49 index 0000000..8c4f1c7
51 +++ b/EmbeddedPkg/Include/libfdt_env.h
55 +* Copyright (c) 2011, ARM Limited. All rights reserved.
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
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.
67 +#ifndef _LIBFDT_ENV_H
68 +#define _LIBFDT_ENV_H
70 +#include <Library/BaseLib.h>
71 +#include <Library/BaseMemoryLib.h>
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;
80 +static inline uint16_t fdt16_to_cpu(uint16_t x)
82 + return SwapBytes16 (x);
84 +#define cpu_to_fdt16(x) fdt16_to_cpu(x)
86 +static inline uint32_t fdt32_to_cpu(uint32_t x)
88 + return SwapBytes32 (x);
90 +#define cpu_to_fdt32(x) fdt32_to_cpu(x)
92 +static inline uint64_t fdt64_to_cpu(uint64_t x)
94 + return SwapBytes64 (x);
96 +#define cpu_to_fdt64(x) fdt64_to_cpu(x)
98 +static inline void* memcpy(void* dest, const void* src, size_t len) {
99 + return CopyMem (dest, src, len);
102 +static inline void *memmove(void *dest, const void *src, size_t n) {
103 + return CopyMem (dest, src, n);
106 +static inline void *memset(void *s, int c, size_t n) {
107 + return SetMem (s, n, c);
110 +static inline int memcmp(const void* dest, const void* src, int len) {
111 + return CompareMem (dest, src, len);
114 +static inline void *memchr(const void *s, int c, size_t n) {
115 + return ScanMem8 (s, n, c);
118 +static inline size_t strlen (const char* str) {
119 + return AsciiStrLen (str);
122 +static inline char *strchr(const char *s, int c) {
126 + return AsciiStrStr (s, pattern);
129 +#endif /* _LIBFDT_ENV_H */
130 diff --git a/EmbeddedPkg/Library/FdtLib/FdtLib.inf b/EmbeddedPkg/Library/FdtLib/FdtLib.inf
132 index 0000000..9753ed8
134 +++ b/EmbeddedPkg/Library/FdtLib/FdtLib.inf
137 +# Copyright (c) 2011, ARM Limited. All rights reserved.
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
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.
150 + INF_VERSION = 0x00010005
152 + FILE_GUID = 6b2478c0-be23-11e0-a28c-0002a5d5c51b
154 + VERSION_STRING = 1.0
155 + LIBRARY_CLASS = FdtLib
158 +# The following information is for reference only and not required by the build tools.
160 +# VALID_ARCHITECTURES = ARM
173 + EmbeddedPkg/EmbeddedPkg.dec
174 diff --git a/EmbeddedPkg/Library/FdtLib/README.txt b/EmbeddedPkg/Library/FdtLib/README.txt
176 index 0000000..c74db7a
178 +++ b/EmbeddedPkg/Library/FdtLib/README.txt
182 +Principal original author: David Gibson (david AT gibson.dropbear.id.au)
183 +Maintainer: Jon Loeliger (jdl AT jdl.com)
188 +libfdt is GPL/BSD dual-licensed.
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
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
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
210 +2. Copy the content of 'libfdt' into EmbeddedPkg/Library/FdtLib/
212 +cp -a libfdt/* $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/
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