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

Re: [Xen-devel] [PATCH 7/8] arm, device tree: parse the DTB for RAM location and size



Hi, 

At 13:03 +0000 on 10 Feb (1328879023), David Vrabel wrote:
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 51afb31..e212a2e 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -19,6 +19,7 @@
>  
>  #include <xen/config.h>
>  #include <xen/compile.h>
> +#include <xen/device_tree.h>
>  #include <xen/domain_page.h>
>  #include <xen/types.h>
>  #include <xen/string.h>
> @@ -68,8 +69,12 @@ void __init start_xen(unsigned long boot_phys_offset,
>                        unsigned long atag_paddr)
>  
>  {
> +    void *fdt;
>      int i;
>  
> +    fdt = (void *)BOOT_MISC_VIRT_START + (atag_paddr & ((1 << SECOND_SHIFT) 
> - 1));

Please linewrap below 80 coluns. 

> +static void __init process_memory_node(const void *fdt, int node,
> +                                       u32 address_cells, u32 size_cells)
> +{
> +    const struct fdt_property *prop;
> +    size_t reg_cells;
> +    int i;
> +    int banks;
> +    const u32 *cell;
> +    paddr_t start, size;
> +
> +    if (address_cells < 1 || size_cells < 1) {
> +        early_printk("fdt: node `%s': invalid #address-cells or #size-cells",
> +                     fdt_get_name(fdt, node, NULL));
> +        return;
> +    }
> +
> +    prop = fdt_get_property(fdt, node, "reg", NULL);
> +    if (!prop) {
> +        early_printk("fdt: node `%s': missing `reg' property\n",
> +                     fdt_get_name(fdt, node, NULL));
> +        return;
> +    }
> +
> +    cell = (const u32 *)prop->data;
> +    reg_cells = address_cells + size_cells;
> +    banks = fdt32_to_cpu(prop->len) / (reg_cells * sizeof(u32));
> +
> +    for (i = 0; i < banks; i++) {
> +        get_register(&cell, address_cells, size_cells, &start, &size);
> +        early_info.mem.bank[early_info.mem.nr_banks].start = start;
> +        early_info.mem.bank[early_info.mem.nr_banks].size = size;
> +        early_info.mem.nr_banks++;

This needs a check that you don't overrun NR_MEM_BANKS. 

Aside from that, this whole series gets my ack.

Cheers,

Tim

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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