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

Re: [Minios-devel] [UNIKRAFT PATCHv5 38/46] plat/kvm: Get PSCI conduit method from DTB for Arm64





On 10.08.2018 09:08, Wei Chen wrote:
From: Wei Chen <Wei.Chen@xxxxxxx>

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. We only support PSCI-1.0 and PSCI-0.2 in this
stage.

Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx>
---
  plat/kvm/arm/setup.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 44 insertions(+)

diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
index a74c85f..a0b1f50 100644
--- a/plat/kvm/arm/setup.c
+++ b/plat/kvm/arm/setup.c
@@ -22,6 +22,7 @@
  #include <kvm/console.h>
  #include <uk/assert.h>
  #include <mm.h>
+#include <arm/cpu.h>
  #include <uk/arch/limits.h>
void *_libkvmplat_pagetable;
@@ -33,6 +34,8 @@ void *_libkvmplat_dtb;
  #define MAX_CMDLINE_SIZE 1024
  static char cmdline[MAX_CMDLINE_SIZE];
+smcc_psci_callfn_t smcc_psci_call;
+
  static void _init_dtb(void *dtb_pointer)
  {
        int ret;
@@ -44,6 +47,44 @@ static void _init_dtb(void *dtb_pointer)
        uk_printd(DLVL_INFO, "Found device tree on: %p\n", dtb_pointer);
  }
+static void _dtb_get_psci_method(void)
+{
+       int fdtpsci, len;
+       const char *fdtmethod;
+
+       /*
+        * We just support PSCI-0.2 and PSCI-1.0, the PSCI-0.1 would not
+        * be supported.
+        */
+       fdtpsci = fdt_node_offset_by_compatible(_libkvmplat_dtb,
+                                               -1, "arm,psci-1.0");
+       if (fdtpsci < 0)
+               fdtpsci = fdt_node_offset_by_compatible(_libkvmplat_dtb,
+                                                       -1, "arm,psci-0.2");
+       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"))
+               smcc_psci_call = smcc_psci_hvc_call;
+       else if (!strcmp(fdtmethod, "smc"))
+               smcc_psci_call = smcc_psci_smc_call;

What if you find something else than hvc or smc on the device tree?

+
+       uk_printd(DLVL_INFO, "PSCI method: %s\n", fdtmethod);
+       return;
+
+enomethod:
+       uk_printd(DLVL_INFO, "Support PSCI from PSCI-0.2\n");
+       smcc_psci_call = NULL;
+}
+
  static void _init_dtb_mem(void)
  {
        extern char _text[];
@@ -143,6 +184,9 @@ void _libkvmplat_start(void *dtb_pointer)
_dtb_get_cmdline(cmdline, sizeof(cmdline)); + /* Get PSCI method from DTB */
+       _dtb_get_psci_method();
+
        /* Initialize memory from DTB */
        _init_dtb_mem();

_______________________________________________
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®.