diff mbox

[Xen-devel,RFC,22/35] xen/arm: Create chosen node for DOM0

Message ID 1423058539-26403-23-git-send-email-parth.dixit@linaro.org
State New
Headers show

Commit Message

Parth Dixit Feb. 4, 2015, 2:02 p.m. UTC
From: Naresh Bhat <naresh.bhat@linaro.org>

Create a chosen node for DOM0 with
 - bootargs
 - rsdp

Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
---
 xen/arch/arm/domain_build.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

Comments

Julien Grall Feb. 6, 2015, 12:29 a.m. UTC | #1
Hi Stefano,

On 06/02/2015 00:09, Stefano Stabellini wrote:
> On Wed, 4 Feb 2015, parth.dixit@linaro.org wrote:
>> From: Naresh Bhat <naresh.bhat@linaro.org>
>>
>> Create a chosen node for DOM0 with
>>   - bootargs
>>   - rsdp
>>
>> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> ---
>>   xen/arch/arm/domain_build.c | 41 +++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 41 insertions(+)
>>
>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> index 30bebe5..d781c63 100644
>> --- a/xen/arch/arm/domain_build.c
>> +++ b/xen/arch/arm/domain_build.c
>> @@ -19,6 +19,7 @@
>>   #include <asm/setup.h>
>>   #include <asm/cpufeature.h>
>>   #include <asm/acpi.h>
>> +#include <xen/acpi.h>
>>
>>   #include <asm/gic.h>
>>   #include <xen/irq.h>
>> @@ -1199,6 +1200,41 @@ static int make_memory_node_acpi(const struct domain *d,
>>       return res;
>>   }
>>
>> +static int make_chosen_node(const struct domain *d, const struct kernel_info *kinfo)
>> +{
>> +   int res = 0;
>> +   const char *bootargs = NULL;
>> +   const struct bootmodule *mod = kinfo->kernel_bootmodule;
>> +   u64 a = acpi_os_get_root_pointer();
>> +   void *fdt = kinfo->fdt;
>> +   __be32 val[2];
>> +   __be32 *cellp;
>> +
>> +   DPRINT("Create bootargs chosen node\n");
>> +
>> +   if ( mod && mod->cmdline[0] )
>> +        bootargs = &mod->cmdline[0];
>> +
>> +   res = fdt_begin_node(fdt, "chosen");
>> +   if ( res )
>> +       return res;
>> +
>> +   res = fdt_property(fdt, "bootargs", bootargs, (strlen(bootargs)+1));
>> +   if ( res )
>> +      return res;
>> +
>> +   cellp = (__be32 *)val;
>> +   dt_set_cell(&cellp, ARRAY_SIZE(val), a);
>> +
>> +   res = fdt_property(fdt, "rsdp", &val, sizeof(val));
>> +   if ( res )
>> +       return res;
>> +
>> +    res = fdt_end_node(fdt);
>> +
>> +    return res;
>> +}
>
> This is similar to setup_chosen_node in xen/arch/arm/efi/efi-boot.h.
> It might make sense to refactor the code to avoid code duplication.

I don't think it make sense to have a common function between efi-boot.h 
(which create the DT for Xen) and here (which create the DT for DOM0).

The former one is adding a node into an existing device tree while the 
former creating the device tree. Futhermore, the rsdp property doesn't 
exist on EFI boot.

Regads,
diff mbox

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 30bebe5..d781c63 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -19,6 +19,7 @@ 
 #include <asm/setup.h>
 #include <asm/cpufeature.h>
 #include <asm/acpi.h>
+#include <xen/acpi.h>
 
 #include <asm/gic.h>
 #include <xen/irq.h>
@@ -1199,6 +1200,41 @@  static int make_memory_node_acpi(const struct domain *d,
     return res;
 }
 
+static int make_chosen_node(const struct domain *d, const struct kernel_info *kinfo)
+{
+   int res = 0;
+   const char *bootargs = NULL;
+   const struct bootmodule *mod = kinfo->kernel_bootmodule;
+   u64 a = acpi_os_get_root_pointer();
+   void *fdt = kinfo->fdt;
+   __be32 val[2];
+   __be32 *cellp;
+
+   DPRINT("Create bootargs chosen node\n");
+
+   if ( mod && mod->cmdline[0] )
+        bootargs = &mod->cmdline[0];
+
+   res = fdt_begin_node(fdt, "chosen");
+   if ( res )
+       return res;
+
+   res = fdt_property(fdt, "bootargs", bootargs, (strlen(bootargs)+1));
+   if ( res )
+      return res;
+
+   cellp = (__be32 *)val;
+   dt_set_cell(&cellp, ARRAY_SIZE(val), a);
+
+   res = fdt_property(fdt, "rsdp", &val, sizeof(val));
+   if ( res )
+       return res;
+
+    res = fdt_end_node(fdt);
+
+    return res;
+}
+
 /*
  * Prepare a minimal DTB for DOM0 which contains
  * bootargs, memory information,
@@ -1244,6 +1280,11 @@  static int prepare_dtb_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( ret )
         goto err;
 
+    /* Create a chosen node for DOM0 */
+    ret = make_chosen_node(d, kinfo);
+    if ( ret )
+        goto err;
+
     ret = fdt_end_node(kinfo->fdt);
     if ( ret < 0 )
         goto err;