From mboxrd@z Thu Jan 1 00:00:00 1970 From: Parth Dixit Subject: [PATCH v2 31/41] arm : acpi estimate memory required for acpi/efi tables Date: Mon, 18 May 2015 01:33:58 +0530 Message-ID: <1431893048-5214-32-git-send-email-parth.dixit@linaro.org> References: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, tim@xen.org, julien.grall@citrix.com, stefano.stabellini@citrix.com, jbeulich@suse.com, parth.dixit@linaro.org, christoffer.dall@linaro.org List-Id: xen-devel@lists.xenproject.org Estimate the memory required for loading acpi/efi tablee in DOM0. Initialize the size of acpi/efi tables. Signed-off-by: Parth Dixit --- xen/arch/arm/domain_build.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 9d98f64..f2ca525 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -69,6 +69,9 @@ struct meminfo __initdata acpi_mem; #ifdef CONFIG_ACPI /* Reserve DOM0 FDT size in ACPI case only */ #define DOM0_FDT_MIN_SIZE 4096 +#define NR_NEW_XEN_TABLES 2 +/* Constant to indicate "Xen" in unicode u16 format */ +static const u16 XEN_EFI_FW_VENDOR[] ={0x0058,0x0065,0x006E,0x0000}; #endif struct vcpu *__init alloc_dom0_vcpu0(struct domain *dom0) @@ -1222,6 +1225,51 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, return res; } #ifdef CONFIG_ACPI +static int estimate_acpi_size(struct domain *d,struct kernel_info *kinfo, struct membank tbl_add[]) +{ + int size = 0; + u64 addr; + struct acpi_table_header *table; + struct acpi_table_rsdp *rsdp_tbl; + + set_acpi_size(size); + tbl_add[TBL_EFIT].size = sizeof(struct efi_system_table) + + sizeof(struct efi_config_table) + + sizeof(XEN_EFI_FW_VENDOR); + + tbl_add[TBL_MMAP].size = sizeof(struct efi_memory_desc) + *(kinfo->mem.nr_banks + acpi_mem.nr_banks + TBL_MMAX); + tbl_add[TBL_XENV].size = sizeof(struct acpi_table_xenv); + tbl_add[TBL_STAO].size = sizeof(struct acpi_table_stao); + + addr = acpi_os_get_root_pointer(); + if( !addr ) + return -ENODEV; + + rsdp_tbl = acpi_os_map_memory(addr, sizeof(struct acpi_table_rsdp)); + if( !rsdp_tbl ) + return -ENOMEM; + + table = acpi_os_map_memory(rsdp_tbl->xsdt_physical_address, + sizeof(struct acpi_table_header)); + if ( !table ) + return -ENOMEM; + + tbl_add[TBL_XSDT].size = table->length + +( NR_NEW_XEN_TABLES*sizeof(acpi_native_uint) ); + tbl_add[TBL_XSDT].start = rsdp_tbl->xsdt_physical_address; + acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); + acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp)); + size = tbl_add[TBL_EFIT].size + + tbl_add[TBL_MMAP].size + + tbl_add[TBL_XENV].size + + tbl_add[TBL_STAO].size + + tbl_add[TBL_XSDT].size; + + set_acpi_size(size); + return 0; +} + /* * Create place holder for efi values. * Actual values will be replaced later @@ -1365,7 +1413,11 @@ static int create_acpi_dtb(struct domain *d, struct kernel_info *kinfo, struct m if ( ret < 0 ) goto err; - return 0; + ret = estimate_acpi_size(d, kinfo, tbl_add); + if ( ret < 0 ) + goto err; + + return 0; err: printk("Device tree generation failed (%d).\n", ret); -- 1.9.1