Reduce memory footprint on SGI by putting modules before the kernel
as opposed to after. * grub-core/Makefile.core.def (kernel): Increase linking address. (none_decompress): Likewise. (xz_decompress): Likewise. * grub-core/boot/mips/startup_raw.S: Use prewritten uncompression address. * grub-core/kern/mips/arc/init.c (grub_machine_init): Handle memory layout change. (grub_arch_modules_addr): New function. * grub-core/kern/mips/init.c (grub_arch_modules_addr): Moved from here... * grub-core/kern/mips/loongson/init.c (grub_arch_modules_addr): .. here * grub-core/kern/mips/qemu_mips/init.c (grub_arch_modules_addr): ... and here. * grub-core/kern/mips/startup.S (total_size): Rename to ... (grub_total_modules_size): ... this. Make global. [GRUB_MACHINE_ARC]: Don't attempt to move modules out of the bss. * include/grub/offsets.h (GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR): New definition. (GRUB_KERNEL_MIPS_QEMU_MIPS_UNCOMPRESSED_ADDR): Likewise. (GRUB_KERNEL_MIPS_ARC_UNCOMPRESSED_ADDR): Likewise. (GRUB_KERNEL_MACHINE_UNCOMPRESSED_ADDR): Likewise. (GRUB_KERNEL_MIPS_ARC_LINK_ADDR): Increased. * util/grub-mkimage.c (image_target_desc): New flag PLATFORM_FLAGS_MODULES_BEFORE_KERNEL. (image_targets): Set PLATFORM_FLAGS_MODULES_BEFORE_KERNEL on mips-arc. (generate_image): Handle images with modules before kernel.
This commit is contained in:
parent
566a191715
commit
b772baedcd
10 changed files with 123 additions and 37 deletions
|
@ -124,6 +124,8 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
|||
}
|
||||
}
|
||||
|
||||
extern grub_uint32_t grub_total_modules_size;
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
|
@ -148,8 +150,10 @@ grub_machine_init (void)
|
|||
start = ((grub_uint64_t) cur->start_page) << 12;
|
||||
end = ((grub_uint64_t) cur->num_pages) << 12;
|
||||
end += start;
|
||||
if ((grub_uint64_t) end > (GRUB_KERNEL_MIPS_ARC_LINK_ADDR & 0x1fffffff))
|
||||
end = (GRUB_KERNEL_MIPS_ARC_LINK_ADDR & 0x1fffffff);
|
||||
if ((grub_uint64_t) end > ((GRUB_KERNEL_MIPS_ARC_LINK_ADDR
|
||||
- grub_total_modules_size) & 0x1fffffff))
|
||||
end = ((GRUB_KERNEL_MIPS_ARC_LINK_ADDR - grub_total_modules_size)
|
||||
& 0x1fffffff);
|
||||
if (end > start)
|
||||
grub_mm_init_region ((void *) (grub_addr_t) (start | 0x80000000),
|
||||
end - start);
|
||||
|
@ -160,6 +164,12 @@ grub_machine_init (void)
|
|||
grub_arcdisk_init ();
|
||||
}
|
||||
|
||||
grub_addr_t
|
||||
grub_arch_modules_addr (void)
|
||||
{
|
||||
return GRUB_KERNEL_MIPS_ARC_LINK_ADDR - grub_total_modules_size;
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_fini (void)
|
||||
{
|
||||
|
|
|
@ -42,11 +42,3 @@ grub_machine_set_prefix (void)
|
|||
{
|
||||
grub_env_set ("prefix", grub_prefix);
|
||||
}
|
||||
|
||||
extern char _end[];
|
||||
|
||||
grub_addr_t
|
||||
grub_arch_modules_addr (void)
|
||||
{
|
||||
return (grub_addr_t) _end;
|
||||
}
|
||||
|
|
|
@ -257,3 +257,10 @@ grub_reboot (void)
|
|||
while (1);
|
||||
}
|
||||
|
||||
extern char _end[];
|
||||
|
||||
grub_addr_t
|
||||
grub_arch_modules_addr (void)
|
||||
{
|
||||
return (grub_addr_t) _end;
|
||||
}
|
||||
|
|
|
@ -60,3 +60,11 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
|||
hook (0, grub_arch_memsize, GRUB_MEMORY_AVAILABLE);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
extern char _end[];
|
||||
|
||||
grub_addr_t
|
||||
grub_arch_modules_addr (void)
|
||||
{
|
||||
return (grub_addr_t) _end;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ start:
|
|||
nop
|
||||
|
||||
. = _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
|
||||
total_module_size:
|
||||
VARIABLE(grub_total_modules_size)
|
||||
.long 0
|
||||
|
||||
. = _start + GRUB_KERNEL_MACHINE_PREFIX
|
||||
|
@ -84,6 +84,7 @@ cont:
|
|||
#endif
|
||||
|
||||
/* Move the modules out of BSS. */
|
||||
#ifndef GRUB_MACHINE_ARC
|
||||
lui $t2, %hi(__bss_start)
|
||||
addiu $t2, %lo(__bss_start)
|
||||
|
||||
|
@ -113,6 +114,7 @@ modulesmovcont:
|
|||
b modulesmovcont
|
||||
addiu $t3, $t3, -1
|
||||
modulesmovdone:
|
||||
#endif
|
||||
|
||||
/* Clean BSS. */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue