When purgatory mangles the pal code it ends up fragmenting some
of the regions. This code merges these regions back together.

This is mainly cosmetic, but at the same time, its not really
that correct to have the regions split up.

Cc: Nanhai Zou <[EMAIL PROTECTED]>
Signed-Off-By: Simon Horman <[EMAIL PROTECTED]>

Index: kexec-tools-unstable/purgatory/arch/ia64/purgatory-ia64.c
===================================================================
--- kexec-tools-unstable.orig/purgatory/arch/ia64/purgatory-ia64.c      
2006-11-02 16:18:37.000000000 +0900
+++ kexec-tools-unstable/purgatory/arch/ia64/purgatory-ia64.c   2006-11-02 
18:20:34.000000000 +0900
@@ -151,6 +151,45 @@
        return addr - PAGE_OFFSET;
 }
 
+/* Merge ranges 
+ * assumes that mergable ranges are consicutive and ordered */
+void
+merge_efi_memmap(struct kexec_boot_params *params,
+               struct ia64_boot_param *boot_param)
+{
+       efi_memory_desc_t *dst_md, *next_md, *tmp_md;
+
+       dst_md = (efi_memory_desc_t *)params->efi_memmap_base;
+       while(dst_md < (void *)params->efi_memmap_base +
+             boot_param->efi_memmap_size) {
+               next_md = (void *)dst_md + boot_param->efi_memdesc_size;
+
+               if (dst_md->type != next_md->type ||
+                   dst_md->attribute != next_md->attribute ||
+                   dst_md->phys_addr + (dst_md->num_pages << EFI_PAGE_SHIFT)
+                   < next_md->phys_addr) {
+                       dst_md = (void *)dst_md + boot_param->efi_memdesc_size;
+                       continue;
+               }
+
+               dst_md->num_pages = (next_md->phys_addr + 
+                       (next_md->num_pages << EFI_PAGE_SHIFT) -
+                       dst_md->phys_addr) >> EFI_PAGE_SHIFT;
+
+               /* Do memmove manually */
+               for (tmp_md = next_md; tmp_md < 
+                    (void *)params->efi_memmap_base +
+                    boot_param->efi_memmap_size;
+                    tmp_md = (void *)tmp_md + boot_param->efi_memdesc_size) {
+                       memcpy(tmp_md, (void *)tmp_md + 
+                              boot_param->efi_memdesc_size,
+                              boot_param->efi_memdesc_size);
+               }
+               boot_param->efi_memmap_size -= boot_param->efi_memdesc_size;
+       }
+
+}
+
 void
 patch_efi_memmap(struct kexec_boot_params *params,
                struct ia64_boot_param *boot_param)
@@ -217,6 +256,7 @@
        }
 
        boot_param->efi_memmap_size = dest - (void *)params->efi_memmap_base;
+       merge_efi_memmap(params, boot_param);
 }
 
 void
_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot

Reply via email to