[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 14/15] add a domU script to fetch overlays and applying them to linux


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Henry Wang <xin.wang2@xxxxxxx>
  • Date: Wed, 24 Apr 2024 11:34:48 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=P4gTMnujfvEGKwn+wIQsB0+jlCBFdxbEKPbGnjsFUW0=; b=a5ztsyrWPlNBC/3ifDww/JtjBO6P3V67Sr+h+CgNQrMSYJksQ/Jx3FxGdgjuXohd3HI0PeipVUG+q/eJIcQ3zpp9i6JLJqhpIBwgv1nbft7dYJS6N+A6b3ka7OWlpyl3Vyb5MZ8mAd88eiqDS0KY7lLn/LDHYS4j2xJuZMYy8LrUJW2WZNvmOiA+9oYe1KOQc6U6BvS50fYGMTG+/0Q36HLdzqukSYdEvNHfz9c7YR7W/sx33TtKU9YqeCQnUX4YrZucudCp5p5ZPHG1Oi2L8noBLBpUz4zDgk8KqHwvKnhTyPU0LR3dBmWJ8MbwIfdwh/TtEowIjvkRNiLmc750+Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aDSJRmQIiiiLCz9avQGyQktVTogrll7840XOI1Gxap3xP8Ys3sZXilkNbRoV4ddzWH5Ye7fr9tDHF2sKrDrVcdax5PhW9N44JLAAuKSseRwV09/fURn4de0qwHGX20uueNYyP1HiEaYDSMoQGeu/tZBna2euOkvGCXZEFegR1camIYUhuPWev/pkRu2CfF+fckM+E2snbiL3jsVbZKBpXavCVbRKDt11+3l9//G3UF6FXeC/1NwUA6o5aGXT0SHpd8zMFiSkm1kLc3no7tLXQRO/cQWyTnFlnv3fFA6IIzLXc7Fpimdeex/SC/OKKK+oqwGAyKdlUQoyZgN9Wj0Tyg==
  • Cc: Vikram Garhwal <fnu.vikram@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>, Henry Wang <xin.wang2@xxxxxxx>
  • Delivery-date: Wed, 24 Apr 2024 03:44:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Vikram Garhwal <fnu.vikram@xxxxxxxxxx>

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@xxxxxxxxxx>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>
Signed-off-by: Henry Wang <xin.wang2@xxxxxxx>
---
 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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.