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

[Minios-devel] [UNIKRAFT PATCHv4 33/43] plat/kvm: Get PSCI conduit method from DTB for arm64


  • To: <minios-devel@xxxxxxxxxxxxxxxxxxxx>, <simon.kuenzer@xxxxxxxxx>
  • From: Wei Chen <Wei.Chen@xxxxxxx>
  • Date: Fri, 6 Jul 2018 09:03:46 +0000
  • Authentication-results: spf=fail (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=arm.com;
  • Cc: Kaly.Xin@xxxxxxx, nd@xxxxxxx, wei.chen@xxxxxxx
  • Delivery-date: Fri, 06 Jul 2018 09:05:50 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Nodisclaimer: True
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:99

PSCI supports two conduit method: HVC and SMC. The method
would be set value in device tree's PSCI node. This value
would decide which instruction we should use to call PSCI
functions.

Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx>
---
 plat/common/include/arm/arm64/cpu.h |  6 +++++
 plat/kvm/arm/setup.c                | 39 +++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/plat/common/include/arm/arm64/cpu.h 
b/plat/common/include/arm/arm64/cpu.h
index 7c79462..cf0f6a2 100644
--- a/plat/common/include/arm/arm64/cpu.h
+++ b/plat/common/include/arm/arm64/cpu.h
@@ -70,3 +70,9 @@
 #define        SYSREG_WRITE(reg, val)      \
        __asm__ __volatile__("msr " __STRINGIFY(reg) ", %0" \
                                        : : "r" ((uint64_t)(val)))
+
+
+/* PSCI conduit types */
+#define PSCI_METHOD_NONE       0x0
+#define PSCI_METHOD_HVC                0x1
+#define PSCI_METHOD_SMC                0x2
diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
index 685308c..b7f3e47 100644
--- a/plat/kvm/arm/setup.c
+++ b/plat/kvm/arm/setup.c
@@ -35,6 +35,7 @@
 #include <uk/plat/console.h>
 #include <uk/assert.h>
 #include <uk/essentials.h>
+#include <arm/cpu.h>
 #include <arm/cpu_defs.h>
 
 #define MAX_CMDLINE_SIZE 1024
@@ -46,6 +47,8 @@ void *_libkvmplat_stack_top;
 void *_libkvmplat_mem_end;
 void *_libkvmplat_dtb;
 
+int psci_method;
+
 static void _init_dtb(void *dtb_pointer)
 {
        int ret;
@@ -83,6 +86,39 @@ enocmdl:
        strcpy(cmdline, CONFIG_UK_NAME);
 }
 
+static void _dtb_get_psci_method(void)
+{
+       int fdtpsci, len;
+       const char *fdtmethod;
+
+       fdtpsci = fdt_node_offset_by_compatible(_libkvmplat_dtb,
+                                               0, "arm,psci-0.2");
+       if (fdtpsci < 0)
+               fdtpsci = fdt_node_offset_by_compatible(_libkvmplat_dtb,
+                                                       0, "arm,psci-0.1");
+       if (fdtpsci < 0) {
+               uk_printd(DLVL_INFO, "No PSCI conduit found in DTB\n");
+               goto enomethod;
+       }
+
+       fdtmethod = fdt_getprop(_libkvmplat_dtb, fdtpsci, "method", &len);
+       if (!fdtmethod || (len <= 0)) {
+               uk_printd(DLVL_INFO, "No PSCI method found\n");
+               goto enomethod;
+       }
+
+       if (!strcmp(fdtmethod, "hvc"))
+               psci_method = PSCI_METHOD_HVC;
+       else if (!strcmp(fdtmethod, "smc"))
+               psci_method = PSCI_METHOD_SMC;
+
+       uk_printd(DLVL_INFO, "PSCI method: %s, %d\n", fdtmethod, psci_method);
+       return;
+
+enomethod:
+       psci_method = PSCI_METHOD_NONE;
+}
+
 static void _init_dtb_mem(void)
 {
        extern char _text[];
@@ -146,6 +182,9 @@ void _libkvmplat_start(void *dtb_pointer)
        /* Get command line from DTB */
        _dtb_get_cmdline(cmdline, sizeof(cmdline));
 
+       /* Get PSCI method from DTB */
+       _dtb_get_psci_method();
+
        /* Initialize memory from DTB */
        _init_dtb_mem();
 
-- 
2.17.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

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