Skip to contentSkip to conversation

Changes for libfdt v.1.6.1

PATCH In review Vikram Garhwal 2 participants 4 messages Nov 5, 2021

lore
Share & tools
lore
#0 lore raw

cover Changes for libfdt v.1.6.1

This patch series is NOT INTENDED for commit. Instead this is just a helper patch series to highlight the changes made to ported DTC 1.6.1.

Hopefully, it will save time while reviewing "[XEN][PATCH v2 1/1] Update libfdt to v1.6.1" series.

[Patch 1/2] is just copy of DTC v1.6.1.
[Patch 2/2] contains the changes made to make it work with Xen.

Regards,
Vikram

Vikram Garhwal (2):
Update libfdt to v1.6.1
xen: libfdt: Changes to make libfdt v1.6.1 compatible with Xen

 xen/common/libfdt/Makefile.libfdt   |  10 +-
 xen/common/libfdt/fdt.c             | 226 ++++++---
 xen/common/libfdt/fdt_addresses.c   | 101 ++++
 xen/common/libfdt/fdt_check.c       |  93 ++++
 xen/common/libfdt/fdt_empty_tree.c  |  46 +-
 xen/common/libfdt/fdt_overlay.c     | 884 ++++++++++++++++++++++++++++++++++++
 xen/common/libfdt/fdt_ro.c          | 514 ++++++++++++++++-----
 xen/common/libfdt/fdt_rw.c          | 249 +++++-----
 xen/common/libfdt/fdt_strerror.c    |  55 +--
 xen/common/libfdt/fdt_sw.c          | 312 +++++++++----
 xen/common/libfdt/fdt_wip.c         |  88 ++--
 xen/common/libfdt/libfdt_internal.h | 223 ++++++---
 xen/include/xen/libfdt/fdt.h        |  51 +--
 xen/include/xen/libfdt/libfdt.h     | 858 +++++++++++++++++++++++++++++-----
 xen/include/xen/libfdt/libfdt_env.h | 100 +++-
 15 files changed, 3025 insertions(+), 785 deletions(-)
 create mode 100644 xen/common/libfdt/fdt_addresses.c
 create mode 100644 xen/common/libfdt/fdt_check.c
 create mode 100644 xen/common/libfdt/fdt_overlay.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 Update libfdt to v1.6.1

Update libfdt to v1.6.1 of libfdt taken from git://github.com/dgibson/dtc.
This update is done to support device tree overlays.

---
 xen/common/libfdt/Makefile.libfdt   |  10 +-
 xen/common/libfdt/fdt.c             | 226 ++++++---
 xen/common/libfdt/fdt_addresses.c   | 101 +++++
 xen/common/libfdt/fdt_check.c       |  93 ++++
 xen/common/libfdt/fdt_empty_tree.c  |  46 +-
 xen/common/libfdt/fdt_overlay.c     | 882 ++++++++++++++++++++++++++++++++++++
 xen/common/libfdt/fdt_ro.c          | 514 ++++++++++++++++-----
 xen/common/libfdt/fdt_rw.c          | 249 +++++-----
 xen/common/libfdt/fdt_strerror.c    |  55 +--
 xen/common/libfdt/fdt_sw.c          | 312 +++++++++----
 xen/common/libfdt/fdt_wip.c         |  88 ++--
 xen/common/libfdt/libfdt_internal.h | 223 ++++++---
 xen/include/xen/libfdt/fdt.h        |  51 +--
 xen/include/xen/libfdt/libfdt.h     | 868 +++++++++++++++++++++++++++++------
 xen/include/xen/libfdt/libfdt_env.h | 108 ++++-
 15 files changed, 3031 insertions(+), 795 deletions(-)
 create mode 100644 xen/common/libfdt/fdt_addresses.c
 create mode 100644 xen/common/libfdt/fdt_check.c
 create mode 100644 xen/common/libfdt/fdt_overlay.c
xen/common/libfdt/Makefile.libfdt +9 -1
index 91126c0..b6d8fc0 100644
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
 # Makefile.libfdt
 #
 # This is not a complete Makefile of itself.  Instead, it is designed to
@@ -6,5 +7,12 @@
 LIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1
 LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h
 LIBFDT_VERSION = version.lds
-LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c
+LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \
+	fdt_addresses.c fdt_overlay.c fdt_check.c
 LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
+LIBFDT_LIB = libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT)
+
+libfdt_clean:
+	@$(VECHO) CLEAN "(libfdt)"
+	rm -f $(STD_CLEANFILES:%=$(LIBFDT_dir)/%)
+	rm -f $(LIBFDT_dir)/$(LIBFDT_soname)
xen/common/libfdt/fdt.c +156 -70

312 lines not on this page · raw message

xen/common/libfdt/fdt_addresses.c new file +101 -0

101 lines not on this page · raw message

xen/common/libfdt/fdt_check.c new file +93 -0

93 lines not on this page · raw message

xen/common/libfdt/fdt_empty_tree.c +1 -45

55 lines not on this page · raw message

xen/common/libfdt/fdt_overlay.c new file +882 -0

882 lines not on this page · raw message

xen/common/libfdt/fdt_ro.c +401 -113

728 lines not on this page · raw message

xen/common/libfdt/fdt_rw.c +129 -120

514 lines not on this page · raw message

xen/common/libfdt/fdt_strerror.c +10 -45

80 lines not on this page · raw message

xen/common/libfdt/fdt_sw.c +221 -91

218 lines not on this page · raw message

xen/common/libfdt/fdt_wip.c +33 -55

88 lines not on this page · raw message

xen/common/libfdt/libfdt_internal.h +161 -62

223 lines not on this page · raw message

xen/include/xen/libfdt/fdt.h +4 -47

51 lines not on this page · raw message

xen/include/xen/libfdt/libfdt.h +739 -129

868 lines not on this page · raw message

xen/include/xen/libfdt/libfdt_env.h +91 -17

108 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.7.4

Part of the diff is not shown here. View the raw message.

#2 lore raw

PATCH 2/2 xen: libfdt: Changes to make libfdt v1.6.1 compatible with Xen

In reply to Vikram Garhwal

A few minor changes are done to make it compatible with Xen:
fdt_overlay.c: overlay_fixup_phandle()

Replace strtoul() with simple_strtoul() as strtoul() is not available in Xen lib and included lib.h.

Change char *endptr to const char *endptr.

libfdt_env.h:
Changed path for config.h and stdbool.h. Remaining Xen changes to libfdt_env.h carried over from existing libfdt (v1.4.0)

---
 xen/common/libfdt/fdt_overlay.c     |  6 ++++--
 xen/include/xen/libfdt/libfdt.h     |  4 ++--
 xen/include/xen/libfdt/libfdt_env.h | 14 ++++++++------
 3 files changed, 14 insertions(+), 10 deletions(-)
xen/common/libfdt/fdt_overlay.c +4 -2
index d217e79..7b95e2b 100644
@@ -8,6 +8,7 @@
 
 #include <fdt.h>
 #include <libfdt.h>
+#include <xen/lib.h>
 
 #include "libfdt_internal.h"
 
@@ -446,7 +447,8 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
 		const char *fixup_str = value;
 		uint32_t path_len, name_len;
 		uint32_t fixup_len;
-		char *sep, *endptr;
+		char *sep;
+		const char *endptr;
 		int poffset, ret;
 
 		fixup_end = memchr(value, '\0', len);
@@ -476,7 +478,7 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
 		if (!name_len)
 			return -FDT_ERR_BADOVERLAY;
 
-		poffset = strtoul(sep + 1, &endptr, 10);
+		poffset = simple_strtoul(sep + 1, &endptr, 10);
 		if ((*endptr != '\0') || (endptr <= (sep + 1)))
 			return -FDT_ERR_BADOVERLAY;
 
xen/include/xen/libfdt/libfdt.h +2 -2
index 73467f7..c71689e 100644
@@ -6,8 +6,8 @@
  * Copyright (C) 2006 David Gibson, IBM Corporation.
  */
 
-#include <libfdt_env.h>
-#include <fdt.h>
+#include <xen/libfdt/libfdt_env.h>
+#include <xen/libfdt/fdt.h>
 
 #ifdef __cplusplus
 extern "C" {
xen/include/xen/libfdt/libfdt_env.h +8 -6
index 73b6d40..03380d5 100644
@@ -7,12 +7,11 @@
  * Copyright 2012 Kim Phillips, Freescale Semiconductor.
  */
 
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
+#include <xen/config.h>
+#include <xen/types.h>
+#include <xen/string.h>
+#include <asm/byteorder.h>
+#include <xen/stdbool.h>
 
 #ifdef __CHECKER__
 #define FDT_FORCE __attribute__((force))
@@ -35,6 +34,9 @@ typedef uint64_t FDT_BITWISE fdt64_t;
 			 (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
 			 (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
 
+/* Xen-specific libfdt error code. */
+#define FDT_ERR_XEN(err) (FDT_ERR_MAX + (err))
+
 static inline uint16_t fdt16_to_cpu(fdt16_t x)
 {
 	return (FDT_FORCE uint16_t)CPU_TO_FDT16(x);
Signature · 1 line
2.7.4
#3 lore raw

Re: [XEN][PATCH 2/2] xen: libfdt: Changes to make libfdt v1.6.1 compatible with Xen

Quoted 6 lines · Vikram Garhwal

A few minor changes are done to make it compatible with Xen:
fdt_overlay.c: overlay_fixup_phandle()

Replace strtoul() with simple_strtoul() as strtoul() is not available in Xen lib and included lib.h.

Quoted 7 lines

Change char *endptr to const char *endptr.

libfdt_env.h:
Changed path for config.h and stdbool.h. Remaining Xen changes to libfdt_env.h carried over from existing libfdt (v1.4.0)

Thanks! All makes sense to me.

Quoted 87 lines
---
 xen/common/libfdt/fdt_overlay.c     |  6 ++++--
 xen/include/xen/libfdt/libfdt.h     |  4 ++--
 xen/include/xen/libfdt/libfdt_env.h | 14 ++++++++------
 3 files changed, 14 insertions(+), 10 deletions(-)
xen/common/libfdt/fdt_overlay.c +4 -2
index d217e79..7b95e2b 100644
@@ -8,6 +8,7 @@
 
 #include <fdt.h>
 #include <libfdt.h>
+#include <xen/lib.h>
 
 #include "libfdt_internal.h"
 
@@ -446,7 +447,8 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
 		const char *fixup_str = value;
 		uint32_t path_len, name_len;
 		uint32_t fixup_len;
-		char *sep, *endptr;
+		char *sep;
+		const char *endptr;
 		int poffset, ret;
 
 		fixup_end = memchr(value, '\0', len);
@@ -476,7 +478,7 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
 		if (!name_len)
 			return -FDT_ERR_BADOVERLAY;
 
-		poffset = strtoul(sep + 1, &endptr, 10);
+		poffset = simple_strtoul(sep + 1, &endptr, 10);
 		if ((*endptr != '\0') || (endptr <= (sep + 1)))
 			return -FDT_ERR_BADOVERLAY;
 
xen/include/xen/libfdt/libfdt.h +2 -2
index 73467f7..c71689e 100644
@@ -6,8 +6,8 @@
  * Copyright (C) 2006 David Gibson, IBM Corporation.
  */
 
-#include <libfdt_env.h>
-#include <fdt.h>
+#include <xen/libfdt/libfdt_env.h>
+#include <xen/libfdt/fdt.h>
 
 #ifdef __cplusplus
 extern "C" {
xen/include/xen/libfdt/libfdt_env.h +8 -6
index 73b6d40..03380d5 100644
@@ -7,12 +7,11 @@
  * Copyright 2012 Kim Phillips, Freescale Semiconductor.
  */
 
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
+#include <xen/config.h>
+#include <xen/types.h>
+#include <xen/string.h>
+#include <asm/byteorder.h>
+#include <xen/stdbool.h>
 
 #ifdef __CHECKER__
 #define FDT_FORCE __attribute__((force))
@@ -35,6 +34,9 @@ typedef uint64_t FDT_BITWISE fdt64_t;
 			 (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
 			 (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
 
+/* Xen-specific libfdt error code. */
+#define FDT_ERR_XEN(err) (FDT_ERR_MAX + (err))
+
 static inline uint16_t fdt16_to_cpu(fdt16_t x)
 {
 	return (FDT_FORCE uint16_t)CPU_TO_FDT16(x);
Signature · 1 line
2.7.4