[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] xen/arm: efi: Avoid duplicating the addition of a new efi memory descriptor
commit d229f7de70610a1983842e7a113db26c053bc592 Author: Julien Grall <julien.grall@xxxxxxx> AuthorDate: Wed Mar 8 17:54:34 2017 +0000 Commit: Stefano Stabellini <sstabellini@xxxxxxxxxx> CommitDate: Wed Mar 8 10:24:01 2017 -0800 xen/arm: efi: Avoid duplicating the addition of a new efi memory descriptor 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 <julien.grall@xxxxxxx> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> --- 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); -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |