From patchwork Fri Feb 3 19:18:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 93312 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp738164qgi; Fri, 3 Feb 2017 11:21:09 -0800 (PST) X-Received: by 10.36.178.21 with SMTP id u21mr2262216ite.103.1486149669801; Fri, 03 Feb 2017 11:21:09 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id h130si4129336ioa.188.2017.02.03.11.21.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 11:21:09 -0800 (PST) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZjOG-0004Pr-CV; Fri, 03 Feb 2017 19:19:24 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZjOE-0004Ll-EW for xen-devel@lists.xen.org; Fri, 03 Feb 2017 19:19:22 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 8A/72-01948-9B7D4985; Fri, 03 Feb 2017 19:19:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTXfH9Sk RBs9/cFss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBk7zv1mLPgkXnFtRUoD4wPBLkYuDiGBTYwS reebWSCc04wSL0/vYupi5ORgE9CUuPP5E5gtIiAtce3zZUYQm1kgSuLOxZ0sILawQILEidmfg eIcHCwCqhKLJgaBhHkFXCUu7n/EDGJLCMhJnDw2mRXE5gSKfz+3DmykkICLxOL2DpYJjNwLGB lWMWoUpxaVpRbpGlrqJRVlpmeU5CZm5ugaGpjq5aYWFyemp+YkJhXrJefnbmIEereegYFxB+O jfr9DjJIcTEqivEXXpkQI8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuBdAJITLEpNT61Iy8wBhhlM WoKDR0mEVw8kzVtckJhbnJkOkTrFqCglzmsMkhAASWSU5sG1wUL7EqOslDAvIwMDgxBPQWpRb mYJqvwrRnEORiVh3lqQKTyZeSVw018BLWYCWvzz8SSQxSWJCCmpBsYAGbZJ4X4XRJY458+73m MmUvnmVZ1HDJOQU+CllGgl4yfO89fsSGWY+fz2lV06dQ/XMHNpLs/Ijvn689bq3AcffI5cb51 zUT/CdH/jn6mLr8rfvnW1Iz9cdvH9I073jzNf35TeYveZvd2nLFFFSsiJxd9KIUY76Pb2DW1v NmuVyB6d6JP144sSS3FGoqEWc1FxIgAGZZyLaAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1486149559!46910621!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5698 invoked from network); 3 Feb 2017 19:19:20 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-206.messagelabs.com with SMTP; 3 Feb 2017 19:19:20 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 68DE1AD7; Fri, 3 Feb 2017 11:19:19 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 623ED3F242; Fri, 3 Feb 2017 11:19:18 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 3 Feb 2017 19:18:54 +0000 Message-Id: <1486149538-20432-11-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486149538-20432-1-git-send-email-julien.grall@arm.com> References: <1486149538-20432-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, shankerd@codeaurora.org Subject: [Xen-devel] [PATCH 6/8] xen/arm: efi: Avoid duplicating the addition of a new efi memory descriptor X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The code to add a new memory descriptor is duplicated three times. Add a new helper that adds the descriptor. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/efi/efi-dom0.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/efi/efi-dom0.c b/xen/arch/arm/efi/efi-dom0.c index c40a7c5..f307f26 100644 --- a/xen/arch/arm/efi/efi-dom0.c +++ b/xen/arch/arm/efi/efi-dom0.c @@ -96,6 +96,18 @@ void __init acpi_create_efi_system_table(struct domain *d, tbl_add[TBL_EFIT].size = table_size; } +static void __init fill_efi_memory_descriptor(EFI_MEMORY_DESCRIPTOR *desc, + UINT32 type, + EFI_PHYSICAL_ADDRESS start, + UINT64 size) +{ + desc->Type = type; + desc->PhysicalStart = start; + BUG_ON(size & EFI_PAGE_MASK); + desc->NumberOfPages = EFI_SIZE_TO_PAGES(size); + desc->Attribute = EFI_MEMORY_WB; +} + void __init acpi_create_efi_mmap_table(struct domain *d, const struct meminfo *mem, struct membank tbl_add[]) @@ -110,28 +122,16 @@ void __init acpi_create_efi_mmap_table(struct domain *d, offset = 0; for( i = 0; i < mem->nr_banks; i++, offset++ ) - { - memory_map[offset].Type = EfiConventionalMemory; - memory_map[offset].PhysicalStart = mem->bank[i].start; - BUG_ON(mem->bank[i].size & EFI_PAGE_MASK); - memory_map[offset].NumberOfPages = EFI_SIZE_TO_PAGES(mem->bank[i].size); - memory_map[offset].Attribute = EFI_MEMORY_WB; - } + fill_efi_memory_descriptor(&memory_map[offset], EfiConventionalMemory, + mem->bank[i].start, mem->bank[i].size); for( i = 0; i < acpi_mem.nr_banks; i++, offset++ ) - { - memory_map[offset].Type = EfiACPIReclaimMemory; - memory_map[offset].PhysicalStart = acpi_mem.bank[i].start; - BUG_ON(acpi_mem.bank[i].size & EFI_PAGE_MASK); - memory_map[offset].NumberOfPages = EFI_SIZE_TO_PAGES(acpi_mem.bank[i].size); - memory_map[offset].Attribute = EFI_MEMORY_WB; - } - - memory_map[offset].Type = EfiACPIReclaimMemory; - memory_map[offset].PhysicalStart = d->arch.efi_acpi_gpa; - BUG_ON(d->arch.efi_acpi_len & EFI_PAGE_MASK); - memory_map[offset].NumberOfPages = EFI_SIZE_TO_PAGES(d->arch.efi_acpi_len); - memory_map[offset].Attribute = EFI_MEMORY_WB; + fill_efi_memory_descriptor(&memory_map[offset], EfiACPIReclaimMemory, + acpi_mem.bank[i].start, + acpi_mem.bank[i].size); + + fill_efi_memory_descriptor(&memory_map[offset], EfiACPIReclaimMemory, + d->arch.efi_acpi_gpa, d->arch.efi_acpi_len); tbl_add[TBL_MMAP].start = d->arch.efi_acpi_gpa + acpi_get_table_offset(tbl_add, TBL_MMAP);