[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 04/10] xen: arm: rename early_info structs
There isn't really anything Device Tree specific about the early_info, we just happen to get it from device tree (but in the future it might come e.g. from UEFI or ACPI or something else). Move the relevant structs out of device_tree.h and into asm/setup.h and rename to be more neutral. For now the code to parse the DT into the now arch specific structs remains in common code. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Acked-by: Julien Grall <julien.grall@xxxxxxxxxx> Acked-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> --- xen/arch/arm/domain_build.c | 13 ++++++----- xen/arch/arm/kernel.c | 6 ++--- xen/arch/arm/kernel.h | 3 ++- xen/arch/arm/setup.c | 51 ++++++++++++++++++++++------------------- xen/common/device_tree.c | 38 +++++++++++++++--------------- xen/include/asm-arm/setup.h | 40 ++++++++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 39 ------------------------------- 7 files changed, 98 insertions(+), 92 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index c58ad75..a065442 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -16,6 +16,7 @@ #include <asm/setup.h> #include <asm/platform.h> #include <asm/psci.h> +#include <asm/setup.h> #include <asm/gic.h> #include <xen/irq.h> @@ -404,9 +405,9 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo, int res = 0; int had_dom0_bootargs = 0; - if ( early_info.modules.nr_mods >= MOD_KERNEL && - early_info.modules.module[MOD_KERNEL].cmdline[0] ) - bootargs = &early_info.modules.module[MOD_KERNEL].cmdline[0]; + if ( bootinfo.modules.nr_mods >= MOD_KERNEL && + bootinfo.modules.module[MOD_KERNEL].cmdline[0] ) + bootargs = &bootinfo.modules.module[MOD_KERNEL].cmdline[0]; dt_for_each_property_node (node, prop) { @@ -465,7 +466,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo, * If the bootloader provides an initrd, we must create a placeholder * for the initrd properties. The values will be replaced later. */ - if ( early_info.modules.module[MOD_INITRD].size ) + if ( bootinfo.modules.module[MOD_INITRD].size ) { u64 a = 0; res = fdt_property(kinfo->fdt, "linux,initrd-start", &a, sizeof(a)); @@ -1221,8 +1222,8 @@ static void dtb_load(struct kernel_info *kinfo) static void initrd_load(struct kernel_info *kinfo) { paddr_t load_addr = kinfo->initrd_paddr; - paddr_t paddr = early_info.modules.module[MOD_INITRD].start; - paddr_t len = early_info.modules.module[MOD_INITRD].size; + paddr_t paddr = bootinfo.modules.module[MOD_INITRD].start; + paddr_t len = bootinfo.modules.module[MOD_INITRD].size; unsigned long offs; int node; int res; diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 69182ec..ce5b95a 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -69,7 +69,7 @@ static void place_modules(struct kernel_info *info, { /* Align DTB and initrd size to 2Mb. Linux only requires 4 byte alignment */ const paddr_t initrd_len = - ROUNDUP(early_info.modules.module[MOD_INITRD].size, MB(2)); + ROUNDUP(bootinfo.modules.module[MOD_INITRD].size, MB(2)); const paddr_t dtb_len = ROUNDUP(fdt_totalsize(info->fdt), MB(2)); const paddr_t modsize = initrd_len + dtb_len; @@ -376,8 +376,8 @@ int kernel_probe(struct kernel_info *info) paddr_t start, size; - start = early_info.modules.module[MOD_KERNEL].start; - size = early_info.modules.module[MOD_KERNEL].size; + start = bootinfo.modules.module[MOD_KERNEL].start; + size = bootinfo.modules.module[MOD_KERNEL].size; if ( !size ) { diff --git a/xen/arch/arm/kernel.h b/xen/arch/arm/kernel.h index fd2f61d..7c7f624 100644 --- a/xen/arch/arm/kernel.h +++ b/xen/arch/arm/kernel.h @@ -8,6 +8,7 @@ #include <xen/libelf.h> #include <xen/device_tree.h> +#include <asm/setup.h> struct kernel_info { #ifdef CONFIG_ARM_64 @@ -16,7 +17,7 @@ struct kernel_info { void *fdt; /* flat device tree */ paddr_t unassigned_mem; /* RAM not (yet) assigned to a bank */ - struct dt_mem_info mem; + struct meminfo mem; /* kernel entry point */ paddr_t entry; diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 78dc7f5..b1aa9c3 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -43,8 +43,11 @@ #include <asm/cpufeature.h> #include <asm/platform.h> #include <asm/procinfo.h> +#include <asm/setup.h> #include <xsm/xsm.h> +struct bootinfo __initdata bootinfo; + struct cpuinfo_arm __read_mostly boot_cpu_data; static __used void init_done(void) @@ -182,7 +185,7 @@ static void dt_unreserved_regions(paddr_t s, paddr_t e, void __init discard_initial_modules(void) { - struct dt_module_info *mi = &early_info.modules; + struct bootmodules *mi = &bootinfo.modules; int i; for ( i = MOD_DISCARD_FIRST; i <= mi->nr_mods; i++ ) @@ -210,7 +213,7 @@ static paddr_t __init consider_modules(paddr_t s, paddr_t e, uint32_t size, paddr_t align, int first_mod) { - const struct dt_module_info *mi = &early_info.modules; + const struct bootmodules *mi = &bootinfo.modules; int i; int nr_rsvd; @@ -275,7 +278,7 @@ static paddr_t __init consider_modules(paddr_t s, paddr_t e, */ static paddr_t __init next_module(paddr_t s, paddr_t *end) { - struct dt_module_info *mi = &early_info.modules; + struct bootmodules *mi = &bootinfo.modules; paddr_t lowest = ~(paddr_t)0; int i; @@ -308,7 +311,7 @@ static paddr_t __init next_module(paddr_t s, paddr_t *end) */ static paddr_t __init get_xen_paddr(void) { - struct dt_mem_info *mi = &early_info.mem; + struct meminfo *mi = &bootinfo.mem; paddr_t min_size; paddr_t paddr = 0, last_end; int i; @@ -357,8 +360,8 @@ static paddr_t __init get_xen_paddr(void) printk("Placing Xen at 0x%"PRIpaddr"-0x%"PRIpaddr"\n", paddr, paddr + min_size); - early_info.modules.module[MOD_XEN].start = paddr; - early_info.modules.module[MOD_XEN].size = min_size; + bootinfo.modules.module[MOD_XEN].start = paddr; + bootinfo.modules.module[MOD_XEN].size = min_size; return paddr; } @@ -376,7 +379,7 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) int i; void *fdt; - if ( !early_info.mem.nr_banks ) + if ( !bootinfo.mem.nr_banks ) panic("No memory bank"); /* @@ -393,15 +396,15 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) * We also track the number of actual RAM pages (i.e. not counting * the holes). */ - ram_size = early_info.mem.bank[0].size; + ram_size = bootinfo.mem.bank[0].size; - contig_start = ram_start = early_info.mem.bank[0].start; + contig_start = ram_start = bootinfo.mem.bank[0].start; contig_end = ram_end = ram_start + ram_size; - for ( i = 1; i < early_info.mem.nr_banks; i++ ) + for ( i = 1; i < bootinfo.mem.nr_banks; i++ ) { - paddr_t bank_start = early_info.mem.bank[i].start; - paddr_t bank_size = early_info.mem.bank[i].size; + paddr_t bank_start = bootinfo.mem.bank[i].start; + paddr_t bank_size = bootinfo.mem.bank[i].size; paddr_t bank_end = bank_start + bank_size; paddr_t new_ram_size = ram_size + bank_size; @@ -434,11 +437,11 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) ram_end = new_ram_end; } - if ( i != early_info.mem.nr_banks ) + if ( i != bootinfo.mem.nr_banks ) { printk("WARNING: only using %d out of %d memory banks\n", - i, early_info.mem.nr_banks); - early_info.mem.nr_banks = i; + i, bootinfo.mem.nr_banks); + bootinfo.mem.nr_banks = i; } total_pages = ram_pages = ram_size >> PAGE_SHIFT; @@ -497,10 +500,10 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) device_tree_flattened = fdt; /* Add non-xenheap memory */ - for ( i = 0; i < early_info.mem.nr_banks; i++ ) + for ( i = 0; i < bootinfo.mem.nr_banks; i++ ) { - paddr_t bank_start = early_info.mem.bank[i].start; - paddr_t bank_end = bank_start + early_info.mem.bank[i].size; + paddr_t bank_start = bootinfo.mem.bank[i].start; + paddr_t bank_end = bank_start + bootinfo.mem.bank[i].size; s = bank_start; while ( s < bank_end ) @@ -557,10 +560,10 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) void *fdt; total_pages = 0; - for ( bank = 0 ; bank < early_info.mem.nr_banks; bank++ ) + for ( bank = 0 ; bank < bootinfo.mem.nr_banks; bank++ ) { - paddr_t bank_start = early_info.mem.bank[bank].start; - paddr_t bank_size = early_info.mem.bank[bank].size; + paddr_t bank_start = bootinfo.mem.bank[bank].start; + paddr_t bank_size = bootinfo.mem.bank[bank].size; paddr_t bank_end = bank_start + bank_size; paddr_t s, e; @@ -609,11 +612,11 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) } } - if ( bank != early_info.mem.nr_banks ) + if ( bank != bootinfo.mem.nr_banks ) { printk("WARNING: only using %d out of %d memory banks\n", - bank, early_info.mem.nr_banks); - early_info.mem.nr_banks = bank; + bank, bootinfo.mem.nr_banks); + bootinfo.mem.nr_banks = bank; } total_pages += ram_size >> PAGE_SHIFT; diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index dba2fba..c0b2b95 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -23,8 +23,8 @@ #include <xen/cpumask.h> #include <xen/ctype.h> #include <xen/lib.h> +#include <asm/setup.h> -struct dt_early_info __initdata early_info; const void *device_tree_flattened; dt_irq_xlate_func dt_irq_xlate; /* Host device tree */ @@ -238,10 +238,10 @@ const char *device_tree_bootargs(const void *fdt) prop = fdt_get_property(fdt, node, "xen,xen-bootargs", NULL); if ( prop == NULL ) { - struct dt_mb_module *dom0_mod = NULL; + struct bootmodule *dom0_mod = NULL; - if ( early_info.modules.nr_mods >= MOD_KERNEL ) - dom0_mod = &early_info.modules.module[MOD_KERNEL]; + if ( bootinfo.modules.nr_mods >= MOD_KERNEL ) + dom0_mod = &bootinfo.modules.module[MOD_KERNEL]; if (fdt_get_property(fdt, node, "xen,dom0-bootargs", NULL) || ( dom0_mod && dom0_mod->cmdline[0] ) ) @@ -319,14 +319,14 @@ static void __init process_memory_node(const void *fdt, int node, cell = (const __be32 *)prop->data; banks = fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); - for ( i = 0; i < banks && early_info.mem.nr_banks < NR_MEM_BANKS; i++ ) + for ( i = 0; i < banks && bootinfo.mem.nr_banks < NR_MEM_BANKS; i++ ) { device_tree_get_reg(&cell, address_cells, size_cells, &start, &size); if ( !size ) continue; - 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++; + bootinfo.mem.bank[bootinfo.mem.nr_banks].start = start; + bootinfo.mem.bank[bootinfo.mem.nr_banks].size = size; + bootinfo.mem.nr_banks++; } } @@ -337,7 +337,7 @@ static void __init process_multiboot_node(const void *fdt, int node, const struct fdt_property *prop; const __be32 *cell; int nr; - struct dt_mb_module *mod; + struct bootmodule *mod; int len; if ( fdt_node_check_compatible(fdt, node, "xen,linux-zimage") == 0 || @@ -351,7 +351,7 @@ static void __init process_multiboot_node(const void *fdt, int node, else panic("%s not a known xen multiboot type\n", name); - mod = &early_info.modules.module[nr]; + mod = &bootinfo.modules.module[nr]; prop = fdt_get_property(fdt, node, "reg", &len); if ( !prop ) @@ -376,8 +376,8 @@ static void __init process_multiboot_node(const void *fdt, int node, else mod->cmdline[0] = 0; - if ( nr > early_info.modules.nr_mods ) - early_info.modules.nr_mods = nr; + if ( nr > bootinfo.modules.nr_mods ) + bootinfo.modules.nr_mods = nr; } static void __init process_chosen_node(const void *fdt, int node, @@ -385,7 +385,7 @@ static void __init process_chosen_node(const void *fdt, int node, u32 address_cells, u32 size_cells) { const struct fdt_property *prop; - struct dt_mb_module *mod = &early_info.modules.module[MOD_INITRD]; + struct bootmodule *mod = &bootinfo.modules.module[MOD_INITRD]; paddr_t start, end; int len; @@ -427,7 +427,7 @@ static void __init process_chosen_node(const void *fdt, int node, mod->start = start; mod->size = end - start; - early_info.modules.nr_mods = max(MOD_INITRD, early_info.modules.nr_mods); + bootinfo.modules.nr_mods = max(MOD_INITRD, bootinfo.modules.nr_mods); } static int __init early_scan_node(const void *fdt, @@ -448,8 +448,8 @@ static int __init early_scan_node(const void *fdt, static void __init early_print_info(void) { - struct dt_mem_info *mi = &early_info.mem; - struct dt_module_info *mods = &early_info.modules; + struct meminfo *mi = &bootinfo.mem; + struct bootmodules *mods = &bootinfo.modules; int i, nr_rsvd; for ( i = 0; i < mi->nr_banks; i++ ) @@ -485,18 +485,18 @@ static void __init early_print_info(void) */ size_t __init device_tree_early_init(const void *fdt, paddr_t paddr) { - struct dt_mb_module *mod; + struct bootmodule *mod; int ret; ret = fdt_check_header(fdt); if ( ret < 0 ) panic("No valid device tree\n"); - mod = &early_info.modules.module[MOD_FDT]; + mod = &bootinfo.modules.module[MOD_FDT]; mod->start = paddr; mod->size = fdt_totalsize(fdt); - early_info.modules.nr_mods = max(MOD_FDT, early_info.modules.nr_mods); + bootinfo.modules.nr_mods = max(MOD_FDT, bootinfo.modules.nr_mods); device_tree_for_each_node((void *)fdt, early_scan_node, NULL); early_print_info(); diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h index b09f688..ea0dc46 100644 --- a/xen/include/asm-arm/setup.h +++ b/xen/include/asm-arm/setup.h @@ -3,6 +3,46 @@ #include <public/version.h> +#define NR_MEM_BANKS 8 + +#define MOD_XEN 0 +#define MOD_FDT 1 +#define MOD_KERNEL 2 +#define MOD_INITRD 3 +#define MOD_XSM 4 +#define NR_MODULES 5 + +#define MOD_DISCARD_FIRST MOD_FDT + +struct membank { + paddr_t start; + paddr_t size; +}; + +struct meminfo { + int nr_banks; + struct membank bank[NR_MEM_BANKS]; +}; + +struct bootmodule { + paddr_t start; + paddr_t size; + char cmdline[1024]; +}; + +struct bootmodules { + int nr_mods; + /* Module 0 is Xen itself, followed by the provided modules-proper */ + struct bootmodule module[NR_MODULES]; +}; + +struct bootinfo { + struct meminfo mem; + struct bootmodules modules; +}; + +extern struct bootinfo bootinfo; + void arch_init_memory(void); void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len); diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 865e1ef..717ef55 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -20,44 +20,6 @@ #define DEVICE_TREE_MAX_DEPTH 16 -#define NR_MEM_BANKS 8 - -#define MOD_XEN 0 -#define MOD_FDT 1 -#define MOD_KERNEL 2 -#define MOD_INITRD 3 -#define MOD_XSM 4 -#define NR_MODULES 5 - -#define MOD_DISCARD_FIRST MOD_FDT - -struct membank { - paddr_t start; - paddr_t size; -}; - -struct dt_mem_info { - int nr_banks; - struct membank bank[NR_MEM_BANKS]; -}; - -struct dt_mb_module { - paddr_t start; - paddr_t size; - char cmdline[1024]; -}; - -struct dt_module_info { - int nr_mods; - /* Module 0 is Xen itself, followed by the provided modules-proper */ - struct dt_mb_module module[NR_MODULES]; -}; - -struct dt_early_info { - struct dt_mem_info mem; - struct dt_module_info modules; -}; - /* * Struct used for matching a device */ @@ -195,7 +157,6 @@ typedef int (*device_tree_node_func)(const void *fdt, u32 address_cells, u32 size_cells, void *data); -extern struct dt_early_info early_info; extern const void *device_tree_flattened; size_t __init device_tree_early_init(const void *fdt, paddr_t paddr); -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |