mirror of https://gitee.com/openkylin/linux.git
x86: use generic early mem copy
The early_ioremap library now has a generic copy_from_early_mem() function. Use the generic copy function for x86 relocate_initrd(). [akpm@linux-foundation.org: remove MAX_MAP_CHUNK define, per Yinghai Lu] Signed-off-by: Mark Salter <msalter@redhat.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Russell King <rmk@arm.linux.org.uk> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
1570f0d7ab
commit
5dd2c4bded
|
@ -317,15 +317,12 @@ static u64 __init get_ramdisk_size(void)
|
|||
return ramdisk_size;
|
||||
}
|
||||
|
||||
#define MAX_MAP_CHUNK (NR_FIX_BTMAPS << PAGE_SHIFT)
|
||||
static void __init relocate_initrd(void)
|
||||
{
|
||||
/* Assume only end is not page aligned */
|
||||
u64 ramdisk_image = get_ramdisk_image();
|
||||
u64 ramdisk_size = get_ramdisk_size();
|
||||
u64 area_size = PAGE_ALIGN(ramdisk_size);
|
||||
unsigned long slop, clen, mapaddr;
|
||||
char *p, *q;
|
||||
|
||||
/* We need to move the initrd down into directly mapped mem */
|
||||
relocated_ramdisk = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped),
|
||||
|
@ -343,25 +340,8 @@ static void __init relocate_initrd(void)
|
|||
printk(KERN_INFO "Allocated new RAMDISK: [mem %#010llx-%#010llx]\n",
|
||||
relocated_ramdisk, relocated_ramdisk + ramdisk_size - 1);
|
||||
|
||||
q = (char *)initrd_start;
|
||||
copy_from_early_mem((void *)initrd_start, ramdisk_image, ramdisk_size);
|
||||
|
||||
/* Copy the initrd */
|
||||
while (ramdisk_size) {
|
||||
slop = ramdisk_image & ~PAGE_MASK;
|
||||
clen = ramdisk_size;
|
||||
if (clen > MAX_MAP_CHUNK-slop)
|
||||
clen = MAX_MAP_CHUNK-slop;
|
||||
mapaddr = ramdisk_image & PAGE_MASK;
|
||||
p = early_memremap(mapaddr, clen+slop);
|
||||
memcpy(q, p+slop, clen);
|
||||
early_memunmap(p, clen+slop);
|
||||
q += clen;
|
||||
ramdisk_image += clen;
|
||||
ramdisk_size -= clen;
|
||||
}
|
||||
|
||||
ramdisk_image = get_ramdisk_image();
|
||||
ramdisk_size = get_ramdisk_size();
|
||||
printk(KERN_INFO "Move RAMDISK from [mem %#010llx-%#010llx] to"
|
||||
" [mem %#010llx-%#010llx]\n",
|
||||
ramdisk_image, ramdisk_image + ramdisk_size - 1,
|
||||
|
|
Loading…
Reference in New Issue