]> git.proxmox.com Git - mirror_edk2.git/blobdiff - 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
diff --git a/EmbeddedPkg/Library/FdtLib/0001-EmbeddedPkg-Added-libfdt-port.patch b/EmbeddedPkg/Library/FdtLib/0001-EmbeddedPkg-Added-libfdt-port.patch
new file mode 100644 (file)
index 0000000..ae06b6f
--- /dev/null
@@ -0,0 +1,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\r
++#  Copyright (c) 2011, ARM Limited. All rights reserved.\r
++#  \r
++#  This program and the accompanying materials                          \r
++#  are licensed and made available under the terms and conditions of the BSD License         \r
++#  which accompanies this distribution.  The full text of the license may be found at        \r
++#  http://opensource.org/licenses/bsd-license.php                                            \r
++#\r
++#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
++#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
++#\r
++#*/\r
++\r
++[Defines]\r
++  INF_VERSION                    = 0x00010005\r
++  BASE_NAME                      = FdtLib\r
++  FILE_GUID                      = 6b2478c0-be23-11e0-a28c-0002a5d5c51b\r
++  MODULE_TYPE                    = BASE\r
++  VERSION_STRING                 = 1.0\r
++  LIBRARY_CLASS                  = FdtLib\r
++\r
++#\r
++# The following information is for reference only and not required by the build tools.\r
++#\r
++#  VALID_ARCHITECTURES           = ARM\r
++#\r
++\r
++[Sources]\r
++  fdt_ro.c\r
++  fdt_rw.c\r
++  fdt_strerror.c\r
++  fdt_sw.c\r
++  fdt_wip.c\r
++  fdt.c\r
++\r
++[Packages]\r
++  MdePkg/MdePkg.dec\r
++  EmbeddedPkg/EmbeddedPkg.dec\r
+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\r
++-------\r
++Principal original author: David Gibson (david AT gibson.dropbear.id.au)\r
++Maintainer: Jon Loeliger (jdl AT jdl.com)\r
++\r
++\r
++Licensing:\r
++----------\r
++libfdt is GPL/BSD dual-licensed.\r
++\r
++\r
++Current version:\r
++----------------\r
++\r
++# Latest commit in dtc.git repository :\r
++commit a31e3ef83bfce62d07695355e5f06cd4d0e44b86\r
++Author: Minghuan Lian <Minghuan.Lian@freescale.com>\r
++Date:   Mon Dec 5 12:22:07 2011 +1100\r
++\r
++# Latest commit in libfdt :\r
++commit a31e3ef83bfce62d07695355e5f06cd4d0e44b86\r
++Author: Minghuan Lian <Minghuan.Lian@freescale.com>\r
++Date:   Mon Dec 5 12:22:07 2011 +1100\r
++\r
++\r
++How to update EmbeddedPkg/Library/FdtLib\r
++----------------------------------------\r
++1. Clone the dtc into a temporary directory:\r
++git clone git://git.jdl.com/software/dtc.git\r
++\r
++2. Copy the content of 'libfdt' into EmbeddedPkg/Library/FdtLib/\r
++cd dtc\r
++cp -a libfdt/* $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/\r
++\r
++3. Copy the libfdt headers:\r
++mv $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/libfdt.h $(EDK2_ROOT)/EmbeddedPkg/Include/\r
++mv $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/fdt.h $(EDK2_ROOT)/EmbeddedPkg/Include/\r
++rm $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/libfdt_env.h\r
+-- 
+1.7.0.4
+