From: Vikram Garhwal <fnu.vikram@xilinx.com>
Introduce a shell script that runs in the background and calls
get_overlay to retrive overlays and add them (or remove them) to Linux
device tree (running as a domU).
Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Signed-off-by: Henry Wang <xin.wang2@amd.com>
---
tools/helpers/Makefile | 2 +-
tools/helpers/get_overlay.sh | 81 ++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 1 deletion(-)
create mode 100755 tools/helpers/get_overlay.sh
diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile
index dfe17ef269..2d0558aeb8 100644
--- a/tools/helpers/Makefile
+++ b/tools/helpers/Makefile
@@ -58,7 +58,6 @@ init-dom0less: $(INIT_DOM0LESS_OBJS)
get_overlay: $(SHARE_OVERLAY_OBJS)
$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenvchan) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxengnttab) $(APPEND_LDFLAGS)
-
.PHONY: install
install: all
$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
@@ -67,6 +66,7 @@ install: all
.PHONY: uninstall
uninstall:
for i in $(TARGETS); do rm -f $(DESTDIR)$(LIBEXEC_BIN)/$$i; done
+ $(RM) $(DESTDIR)$(LIBEXEC_BIN)/get_overlay.sh
.PHONY: clean
clean:
diff --git a/tools/helpers/get_overlay.sh b/tools/helpers/get_overlay.sh
new file mode 100755
index 0000000000..2e8c6ecefd
--- /dev/null
+++ b/tools/helpers/get_overlay.sh
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+modprobe xen_gntalloc
+modprobe xen_gntdev
+
+while :
+do
+ overlay_node_name=""
+ type_overlay="normal"
+ is_partial_dtb=""
+
+ output=`/usr/lib/xen/bin/get_overlay 0`
+
+ if test $? -ne 0
+ then
+ echo error
+ exit 1
+ fi
+
+ if test -z "$output"
+ then
+ echo ""
+ exit 1
+ fi
+
+ # output: add overlay-name normal partial
+ operation=`echo $output | cut -d " " -f 1`
+ overlay_node_name=`echo $output | cut -d " " -f 2`
+ type_overlay=`echo $output | cut -d " " -f 3`
+ is_partial_dtb=`echo $output | cut -d " " -f 4`
+
+ if test -z "$operation" || test -z "$overlay_node_name"
+ then
+ echo "invalid ops"
+ exit 1
+ fi
+
+ if test $operation = "add"
+ then
+ echo "Overlay received"
+
+ if test "$type_overlay" = "normal"
+ then
+ final_path="/sys/kernel/config/device-tree/overlays/$overlay_node_name"
+ mkdir -p $final_path
+ cat overlay.dtbo > $final_path/dtbo
+ else
+ # fpga overlay
+ cp overlay.dtbo lib/firmware/
+ mkdir /configfs
+ mount -t configfs configfs /configfs
+ cd /configfs/device-tree/overlays/
+
+ if test "$is_partial_dtb"
+ then
+ mkdir partial
+ echo 1 > /sys/class/fpga_manager/fpga0/flags
+ echo -n "overlay.dtbo" > /configfs/device-tree/overlays/partial
+ else
+ mkdir full
+ echo -n "overlay.dtbo" > /configfs/device-tree/overlays/full
+ fi
+ fi
+ elif test $operation = "remove"
+ then
+ if test "$type_overlay" = "normal"
+ then
+ # implement remove
+ path=/sys/kernel/config/device-tree/overlays/$overlay_node_name/dtbo
+ if ! test -f $path
+ then
+ echo "error: path doesn't exist"
+ exit 1
+ fi
+ rm $path
+ fi
+ else
+ echo "operation unsupported"
+ exit 1
+ fi
+done
--
2.34.1
Introduce a shell script that runs in the background and calls
get_overlay to retrive overlays and add them (or remove them) to Linux
device tree (running as a domU).
Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Signed-off-by: Henry Wang <xin.wang2@amd.com>
---
tools/helpers/Makefile | 2 +-
tools/helpers/get_overlay.sh | 81 ++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 1 deletion(-)
create mode 100755 tools/helpers/get_overlay.sh
diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile
index dfe17ef269..2d0558aeb8 100644
--- a/tools/helpers/Makefile
+++ b/tools/helpers/Makefile
@@ -58,7 +58,6 @@ init-dom0less: $(INIT_DOM0LESS_OBJS)
get_overlay: $(SHARE_OVERLAY_OBJS)
$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenvchan) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxengnttab) $(APPEND_LDFLAGS)
-
.PHONY: install
install: all
$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
@@ -67,6 +66,7 @@ install: all
.PHONY: uninstall
uninstall:
for i in $(TARGETS); do rm -f $(DESTDIR)$(LIBEXEC_BIN)/$$i; done
+ $(RM) $(DESTDIR)$(LIBEXEC_BIN)/get_overlay.sh
.PHONY: clean
clean:
diff --git a/tools/helpers/get_overlay.sh b/tools/helpers/get_overlay.sh
new file mode 100755
index 0000000000..2e8c6ecefd
--- /dev/null
+++ b/tools/helpers/get_overlay.sh
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+modprobe xen_gntalloc
+modprobe xen_gntdev
+
+while :
+do
+ overlay_node_name=""
+ type_overlay="normal"
+ is_partial_dtb=""
+
+ output=`/usr/lib/xen/bin/get_overlay 0`
+
+ if test $? -ne 0
+ then
+ echo error
+ exit 1
+ fi
+
+ if test -z "$output"
+ then
+ echo ""
+ exit 1
+ fi
+
+ # output: add overlay-name normal partial
+ operation=`echo $output | cut -d " " -f 1`
+ overlay_node_name=`echo $output | cut -d " " -f 2`
+ type_overlay=`echo $output | cut -d " " -f 3`
+ is_partial_dtb=`echo $output | cut -d " " -f 4`
+
+ if test -z "$operation" || test -z "$overlay_node_name"
+ then
+ echo "invalid ops"
+ exit 1
+ fi
+
+ if test $operation = "add"
+ then
+ echo "Overlay received"
+
+ if test "$type_overlay" = "normal"
+ then
+ final_path="/sys/kernel/config/device-tree/overlays/$overlay_node_name"
+ mkdir -p $final_path
+ cat overlay.dtbo > $final_path/dtbo
+ else
+ # fpga overlay
+ cp overlay.dtbo lib/firmware/
+ mkdir /configfs
+ mount -t configfs configfs /configfs
+ cd /configfs/device-tree/overlays/
+
+ if test "$is_partial_dtb"
+ then
+ mkdir partial
+ echo 1 > /sys/class/fpga_manager/fpga0/flags
+ echo -n "overlay.dtbo" > /configfs/device-tree/overlays/partial
+ else
+ mkdir full
+ echo -n "overlay.dtbo" > /configfs/device-tree/overlays/full
+ fi
+ fi
+ elif test $operation = "remove"
+ then
+ if test "$type_overlay" = "normal"
+ then
+ # implement remove
+ path=/sys/kernel/config/device-tree/overlays/$overlay_node_name/dtbo
+ if ! test -f $path
+ then
+ echo "error: path doesn't exist"
+ exit 1
+ fi
+ rm $path
+ fi
+ else
+ echo "operation unsupported"
+ exit 1
+ fi
+done
--
2.34.1