mirror of
https://github.com/torvalds/linux
synced 2024-09-06 18:01:05 +00:00
[MIPS] setup.c: clean up initrd related code
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
parent
f5bffe3a9b
commit
a7837b76b6
|
@ -145,13 +145,12 @@ static int __init rd_start_early(char *p)
|
||||||
unsigned long start = memparse(p, &p);
|
unsigned long start = memparse(p, &p);
|
||||||
|
|
||||||
#ifdef CONFIG_64BIT
|
#ifdef CONFIG_64BIT
|
||||||
/* HACK: Guess if the sign extension was forgotten */
|
/* Guess if the sign extension was forgotten by bootloader */
|
||||||
if (start > 0x0000000080000000 && start < 0x00000000ffffffff)
|
if (start < XKPHYS)
|
||||||
start |= 0xffffffff00000000UL;
|
start = (int)start;
|
||||||
#endif
|
#endif
|
||||||
initrd_start = start;
|
initrd_start = start;
|
||||||
initrd_end += start;
|
initrd_end += start;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
early_param("rd_start", rd_start_early);
|
early_param("rd_start", rd_start_early);
|
||||||
|
@ -159,41 +158,64 @@ early_param("rd_start", rd_start_early);
|
||||||
static int __init rd_size_early(char *p)
|
static int __init rd_size_early(char *p)
|
||||||
{
|
{
|
||||||
initrd_end += memparse(p, &p);
|
initrd_end += memparse(p, &p);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
early_param("rd_size", rd_size_early);
|
early_param("rd_size", rd_size_early);
|
||||||
|
|
||||||
|
/* it returns the next free pfn after initrd */
|
||||||
static unsigned long __init init_initrd(void)
|
static unsigned long __init init_initrd(void)
|
||||||
{
|
{
|
||||||
unsigned long tmp, end, size;
|
unsigned long end;
|
||||||
u32 *initrd_header;
|
u32 *initrd_header;
|
||||||
|
|
||||||
ROOT_DEV = Root_RAM0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Board specific code or command line parser should have
|
* Board specific code or command line parser should have
|
||||||
* already set up initrd_start and initrd_end. In these cases
|
* already set up initrd_start and initrd_end. In these cases
|
||||||
* perfom sanity checks and use them if all looks good.
|
* perfom sanity checks and use them if all looks good.
|
||||||
*/
|
*/
|
||||||
size = initrd_end - initrd_start;
|
if (initrd_start && initrd_end > initrd_start)
|
||||||
if (initrd_end == 0 || size == 0) {
|
goto sanitize;
|
||||||
initrd_start = 0;
|
|
||||||
initrd_end = 0;
|
|
||||||
} else
|
|
||||||
return initrd_end;
|
|
||||||
|
|
||||||
end = (unsigned long)&_end;
|
/*
|
||||||
tmp = PAGE_ALIGN(end) - sizeof(u32) * 2;
|
* See if initrd has been added to the kernel image by
|
||||||
if (tmp < end)
|
* arch/mips/boot/addinitrd.c. In that case a header is
|
||||||
tmp += PAGE_SIZE;
|
* prepended to initrd and is made up by 8 bytes. The fisrt
|
||||||
|
* word is a magic number and the second one is the size of
|
||||||
|
* initrd. Initrd start must be page aligned in any cases.
|
||||||
|
*/
|
||||||
|
initrd_header = __va(PAGE_ALIGN(__pa_symbol(&_end) + 8)) - 8;
|
||||||
|
if (initrd_header[0] != 0x494E5244)
|
||||||
|
goto disable;
|
||||||
|
initrd_start = (unsigned long)(initrd_header + 2);
|
||||||
|
initrd_end = initrd_start + initrd_header[1];
|
||||||
|
|
||||||
initrd_header = (u32 *)tmp;
|
sanitize:
|
||||||
if (initrd_header[0] == 0x494E5244) {
|
if (initrd_start & ~PAGE_MASK) {
|
||||||
initrd_start = (unsigned long)&initrd_header[2];
|
printk(KERN_ERR "initrd start must be page aligned\n");
|
||||||
initrd_end = initrd_start + initrd_header[1];
|
goto disable;
|
||||||
}
|
}
|
||||||
return initrd_end;
|
if (initrd_start < PAGE_OFFSET) {
|
||||||
|
printk(KERN_ERR "initrd start < PAGE_OFFSET\n");
|
||||||
|
goto disable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sanitize initrd addresses. For example firmware
|
||||||
|
* can't guess if they need to pass them through
|
||||||
|
* 64-bits values if the kernel has been built in pure
|
||||||
|
* 32-bit. We need also to switch from KSEG0 to XKPHYS
|
||||||
|
* addresses now, so the code can now safely use __pa().
|
||||||
|
*/
|
||||||
|
end = __pa(initrd_end);
|
||||||
|
initrd_end = (unsigned long)__va(end);
|
||||||
|
initrd_start = (unsigned long)__va(__pa(initrd_start));
|
||||||
|
|
||||||
|
ROOT_DEV = Root_RAM0;
|
||||||
|
return PFN_UP(end);
|
||||||
|
disable:
|
||||||
|
initrd_start = 0;
|
||||||
|
initrd_end = 0;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init finalize_initrd(void)
|
static void __init finalize_initrd(void)
|
||||||
|
@ -259,8 +281,7 @@ static void __init bootmem_init(void)
|
||||||
* not selected. Once that done we can determine the low bound
|
* not selected. Once that done we can determine the low bound
|
||||||
* of usable memory.
|
* of usable memory.
|
||||||
*/
|
*/
|
||||||
reserved_end = init_initrd();
|
reserved_end = max(init_initrd(), PFN_UP(__pa_symbol(&_end)));
|
||||||
reserved_end = PFN_UP(max(__pa(reserved_end), __pa_symbol(&_end)));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the highest page frame number we have available.
|
* Find the highest page frame number we have available.
|
||||||
|
|
|
@ -460,11 +460,6 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
|
||||||
#ifdef CONFIG_BLK_DEV_INITRD
|
#ifdef CONFIG_BLK_DEV_INITRD
|
||||||
void free_initrd_mem(unsigned long start, unsigned long end)
|
void free_initrd_mem(unsigned long start, unsigned long end)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_64BIT
|
|
||||||
/* Switch from KSEG0 to XKPHYS addresses */
|
|
||||||
start = (unsigned long)phys_to_virt(CPHYSADDR(start));
|
|
||||||
end = (unsigned long)phys_to_virt(CPHYSADDR(end));
|
|
||||||
#endif
|
|
||||||
free_init_pages("initrd memory", start, end);
|
free_init_pages("initrd memory", start, end);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue